C#示例-构建基于WebService技术的C/S系统[原创]
C#示例-构建基于WebService技术的C/S系统[原创]
本站的源码只求质量,不求数量,原创第一!花了一下午时间写了个WebService示例,希望对大家有帮助。
当然有任何建议请大人您高抬贵手Feedback下吧:
扫一扫加作者微信
源码下载:
本站的源码只求质量,不求数量,原创第一!花了一下午时间写了个WebService示例,希望对大家有帮助。
当然有任何建议请大人您高抬贵手Feedback下吧:
C# Code:
using System;
using System.Collections.Generic;
using System.Text;
using CommonUtils;
namespace BLL_Library
{
/// <summary>
/// 用户业务逻辑
/// </summary>
public class bllUser
{
/// <summary>
/// 检查登录凭证有效性
/// </summary>
/// <param name="loginer">登录凭证</param>
/// <returns></returns>
public static bool CheckLoginer(byte[] loginer)
{
TLoginer o = null;
try//第1层检查
{
//将Byte数组转换为登录凭证
o = (TLoginer)ZipTools.DecompressionObject(loginer);
}
catch//解密错误,表示凭证无效
{
return false;
}
//第2层检查, (可省略), 不必要访问每个方法去查用户信息
return (o != null) && (Login(o.LoginerID, o.Password));
}
public static bool Login(string user, string password)
{
string sql = "select count(*) from user where uid={1} and pwd={0}";
sql = string.Format(sql, password, user);
//
//从SQL查询用户数据
//
return true;//假设用户及密码正确
}
}
}
// 来源:www.CSFramework.com, C/S结构框架学习网
using System;
using System.Collections.Generic;
using System.Text;
using CommonUtils;
namespace BLL_Library
{
/// <summary>
/// 用户业务逻辑
/// </summary>
public class bllUser
{
/// <summary>
/// 检查登录凭证有效性
/// </summary>
/// <param name="loginer">登录凭证</param>
/// <returns></returns>
public static bool CheckLoginer(byte[] loginer)
{
TLoginer o = null;
try//第1层检查
{
//将Byte数组转换为登录凭证
o = (TLoginer)ZipTools.DecompressionObject(loginer);
}
catch//解密错误,表示凭证无效
{
return false;
}
//第2层检查, (可省略), 不必要访问每个方法去查用户信息
return (o != null) && (Login(o.LoginerID, o.Password));
}
public static bool Login(string user, string password)
{
string sql = "select count(*) from user where uid={1} and pwd={0}";
sql = string.Format(sql, password, user);
//
//从SQL查询用户数据
//
return true;//假设用户及密码正确
}
}
}
// 来源:www.CSFramework.com, C/S结构框架学习网
C# Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CommonUtils;
namespace ClientDemo
{
public partial class frmLogin : Form
{
public frmLogin()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//登录
bool logined = CheckUser(textBox1.Text, textBox2.Text);
if (logined)
{
TLoginer.Current.LoginerID = textBox1.Text;
TLoginer.Current.Password = textBox2.Text;
TLoginer.Current.LoginTime = DateTime.Now;
this.Hide();
new frmTestWebservice().ShowDialog();
}
else
MessageBox.Show("用户不存在!");
}
private bool CheckUser(string uid, string pwd)
{
//调用WebService接口
return new WSecuritySystem.SecuritySystem().Login(uid, pwd);
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
// 来源:www.CSFramework.com, C/S结构框架学习网
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CommonUtils;
namespace ClientDemo
{
public partial class frmLogin : Form
{
public frmLogin()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//登录
bool logined = CheckUser(textBox1.Text, textBox2.Text);
if (logined)
{
TLoginer.Current.LoginerID = textBox1.Text;
TLoginer.Current.Password = textBox2.Text;
TLoginer.Current.LoginTime = DateTime.Now;
this.Hide();
new frmTestWebservice().ShowDialog();
}
else
MessageBox.Show("用户不存在!");
}
private bool CheckUser(string uid, string pwd)
{
//调用WebService接口
return new WSecuritySystem.SecuritySystem().Login(uid, pwd);
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
// 来源:www.CSFramework.com, C/S结构框架学习网
扫一扫加作者微信
源码下载:
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网