基本信息
源码名称:WCF 身份验证实例源码(远程登录功能)桌面开发实例
源码大小:2.91M
文件格式:.rar
开发语言:C#
更新时间:2016-11-17
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍
服务端 用的 sqlite数据库存储

wcf服务端代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data.SQLite;
using System.Configuration;
using System.Data.SqlClient;
using ServicesDAL;
using Model;

namespace WcfServiceApplication
{
    // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名“Login”。
    // 注意: 为了启动 WCF 测试客户端以测试此服务,请在解决方案资源管理器中选择 Login.svc 或 Login.svc.cs,然后开始调试。
    
    public class Login : ILogin
    {
        public static readonly string connectionstring = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
        LoginDAL loginDAL = new LoginDAL();
        public void DoWork()
        {
        }
        //验证用户名
        public bool LoginUserName(User userName)
        {
            return loginDAL.LoginUserNameDAL(userName);
        }
        //验证密码
        public bool LoginUserPwd(User pwd)
        {
            return loginDAL.LoginUserPwdDAL(pwd);
        }

        //加载所有用户信息
        public List<User> LoadUserInfo()
        {
            return loginDAL.LoadUserInfoDAL();
        }

        //添加用户信息
        public int AddUserInfo(User user)
        {
            return loginDAL.AddUserInfoDAL(user);
        }

        //添加用户信息
        public bool AddUserInfoBool(User user)
        {
            return loginDAL.AddUserInfoDAL(user) > 0;
        }

        //删除用户信息
        public int DelUserInfo(User user)
        {
            return loginDAL.DelUserInfoDAL(user);
        }

        //修改用户信息
        public int EditUserInfo(User user)
        {
            return loginDAL.EditUserInfoDAL(user);
        }

        //获取用户ID
        //public User GetUserID(User user)
        //{
        //    return loginDAL.GetUserIDDAL(user);
        //}
    }
}

winform代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.ServiceModel;
using WCFClientCommon;
using WCFClientDemo.WCF_Login;

namespace WCFClientDemofrm
{
    public partial class Loginfrm : Form
    {
        public Loginfrm()
        {
            InitializeComponent();
        }

        private void btnLongin_Click(object sender, EventArgs e)
        {
            User loginModel = new User();
            loginModel.UserName = txtUserName.Text.Trim();
            loginModel.Pwd = txtPwd.Text.Trim();
            

            LoginClient client = new LoginClient();           
            if(Common.CheckDataIsNullOrEmpty(loginModel.UserName)&&Common.CheckDataIsNullOrEmpty(loginModel.Pwd))
            {
                MessageBox.Show("信息不能为空", "提示");
                return;
            }
            else
            {
                bool boolUserName = client.LoginUserName(loginModel);
                if (boolUserName)
                {
                    bool boolPwd = client.LoginUserPwd(loginModel);
                    if (boolPwd)
                    {
                        MessageBox.Show("登录成功", "提示");
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    }
                    else
                    {
                        MessageBox.Show("密码有误", "提示");
                    }
                }
                else
                {
                    MessageBox.Show("该用户不存在", "提示");
                    return;
                }   
            }           
        }
    }
}