Silverlight实现和上一篇相同的登陆页面
来源:互联网 发布:socket server 阿里云 编辑:程序博客网 时间:2024/05/22 10:51
mainpage.xaml
<UserControl x:Class="Login.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="1366" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" Background="Red"> <Canvas Background="White"> <Border Background="#d1d1d1" CornerRadius="30" BorderBrush="Silver" BorderThickness="1" Canvas.Left="382" Canvas.Top="289" Height="338" Name="border1" Width="661" /> <Rectangle Fill="#3b3b3b" Canvas.Left="400" Canvas.Top="388" Height="220" Name="rectangle1" Stroke="Black" StrokeThickness="1" Width="513"/> <Rectangle Fill="#00eeee" Canvas.Left="913" Canvas.Top="308" Height="300" Name="rectangle2" Stroke="Black" StrokeThickness="1" Width="108" /> <Rectangle Fill="Black" Canvas.Left="400" Canvas.Top="308" Height="80" Name="rectangle3" Stroke="Black" StrokeThickness="1" Width="513" /> <TextBlock Foreground="White" FontSize="56" FontWeight="Bold" Canvas.Left="419" Canvas.Top="308" Height="67" Name="textBlock1" Text="LOGIN" Width="222" /> <TextBlock Foreground="White" FontSize="20" FontWeight="Bold" Canvas.Left="434" Canvas.Top="433" Height="30" Name="textBlock2" Text="username:" Width="129" /> <TextBlock Foreground="White" FontSize="20" FontWeight="Bold" Canvas.Left="434" Canvas.Top="532" Height="30" Name="textBlock3" Text="password:" Width="129" /> <TextBox Canvas.Left="600" Canvas.Top="421" Height="50" Name="textBox1" Width="230" /> <TextBox Canvas.Left="600" Canvas.Top="521" Height="50" Name="textBox2" Width="230" /> <Image Canvas.Left="922" Canvas.Top="345" Height="123" Name="image1" Source="images/jiantou.png" Stretch="Fill" Width="95" /> <Button Click="button1_Click" Background="Blue" Canvas.Left="922" Canvas.Top="517" Content="Button" Height="88" Name="button1" Width="93" /> </Canvas></UserControl>
mainpage.xaml.cs
using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Shapes;using Login.ServiceReference1;using System.ServiceModel;namespace Login{ public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void button1_Click(object sender, RoutedEventArgs e) { Get(); } private void Get() { User user = new User(); user.UserName = textBox1.Text; user.PassWord = textBox2.Text; EndpointAddress address = new EndpointAddress(new Uri(Application.Current.Host.Source, "/Login.Web/Service1.svc")); //Login.ServiceReference1.Service1Client Service1Client client = new Service1Client(/*new BasicHttpBinding(), address*/); client.GetCompleted += client_GetCompleted; client.GetAsync(user); } private void client_GetCompleted(object sender, GetCompletedEventArgs e) { if (e.Result) { MessageBox.Show("success"); } else { MessageBox.Show("false"); } } }}
server.svc
using System;using System.Linq;using System.Runtime.Serialization;using System.ServiceModel;using System.ServiceModel.Activation;using System.Data;using System.Data.SqlClient;using System.Web.Configuration;using System.Data.OleDb;namespace Login.Web{ [ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Service1 { [OperationContract] public void DoWork() { // 在此处添加操作实现 return; } // 在此处添加更多操作并使用 [OperationContract] 标记它们 private string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=D:/Projects/3层登陆注册/11111/App_Data/数据库1.accdb"; [OperationContract] public bool Get(User user) { OleDbConnection conn = new OleDbConnection(connectionString); string sql = "select * from userinfo where username='" + user.UserName + "' and password='" + user.PassWord + "'"; OleDbCommand cmd = new OleDbCommand(sql, conn); try { conn.Open(); OleDbDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { return true; } else { return false; } } catch { return false; } finally { conn.Close(); } } }}
User.cs
using System;using System.Collections.Generic;using System.Linq;using System.Web;namespace Login.Web{ public class User { private string userName; private string passWord; public string UserName { get { return userName; } set { userName = value; } } public string PassWord { get { return passWord; } set { passWord = value; } } public User() { this.userName = string.Empty; this.passWord = string.Empty; } }}
0 0
- Silverlight实现和上一篇相同的登陆页面
- ASP实现页面的“上一篇、下一篇”功能
- SQL实现上一篇和下一篇
- Silverlight -登陆页面布局设计
- 简单的实现页面登陆
- 实现上一篇,下一篇的效果
- Android 登陆页面 记住密码和自动登陆的简单实现
- Silverlight For WinEmbedded 的页面切换实现
- silverlight登陆页面的小细节【自动设置焦点,回车登陆】
- Android开发-UI控件:实现登陆页面并跳转和简单的注册页面
- 实现Silverlight 页面切换
- dedecms 修改留言板模板 实现和其他页面相同的布局
- 登陆之后跳转到登陆之前浏览页面的实现
- 一个简单的登陆页面实现
- 超简单的登陆注册页面实现
- 登陆页面的用户信息保存实现
- JQuery实现的登陆注册页面表单
- phpcms V9 实现调用上一篇和下一篇
- oracle建数据库,建用户,导入dmp文件
- Android 开源框架ViewPageIndicator 和 ViewPager 仿网易新闻客户端Tab标签
- 《Linux》天影linux系列笔记一——linux常用命令详解:tail
- (书稿底稿)(C/C++)第一章:CPU基础知识 1.1.2 CPU如何获取内容
- C# 关键字ref out 的区别
- Silverlight实现和上一篇相同的登陆页面
- 我国手机使用率达 83.4% 首次超越 PC
- 《Linux》天影linux系列笔记一——linux常用命令详解:od
- The PCI Layer and Network Interface Cards
- (书稿底稿)(C/C++)第一章:CPU基础知识 1.2 管道技术
- OC 通过点击button清除缓存
- Cocos2dx 三种缓存类介绍
- mongodb 实现关系型数据库中查询某一列 的效果
- 《Linux》天影linux系列笔记一——linux常用命令详解:chmod