C#示例-构建基于WebService技术的C/S系统[原创]
作者:C/S原创  发布日期:2011/04/09 21:00:22
  C#示例-构建基于WebService技术的C/S系统[原创]

C#示例-构建基于WebService技术的C/S系统[原创]



 本站的源码只求质量,不求数量,原创第一!花了一下午时间写了个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结构框架学习网





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结构框架学习网



C/S框架网|原创精神.创造价值.打造精品


扫一扫加作者微信
C/S框架网作者微信 C/S框架网|原创作品.质量保障.竭诚为您服务




源码下载:
点击下载附件 点击下载附件 (如下载失败,请邮件通知我们寄回给您,或QQ:23404761留言.)
上一篇 下一篇