基本信息
源码名称:C# 三层入门级实例(登陆注册,sqlite数据库)
源码大小:5.72M
文件格式:.rar
开发语言:C#
更新时间:2018-08-30
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

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

本次赞助数额为: 10 元 
   源码介绍


using System;
using System.Data;
using System.Windows.Forms;

namespace UI
{
    public partial class FormLogin : Form
    {
        public FormLogin()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox4.Text) || string.IsNullOrEmpty(textBox5.Text))
            {
                MessageBox.Show("请输入用户名和密码");
                return;
            }

            Maticsoft.BLL.Users users = new Maticsoft.BLL.Users();
            DataSet ds = users.GetList("UserName='"   textBox5.Text   "'");
            if (ds.Tables.Count < 1)
            {
                MessageBox.Show("用户名或密码不正确");
                return;
            }
            DataTable dt = ds.Tables[0];
            if (dt.Rows.Count < 1 || dt.Rows[0]["PassWord"].ToString() != textBox4.Text)
            {
                MessageBox.Show("用户名或密码不正确");
                return;
            }
            ((FormMain)this.Owner).userID = Convert.ToInt32(dt.Rows[0]["ID"]);
            ((FormMain)this.Owner).userName = textBox5.Text;
            ((FormMain)this.Owner).userGroup = Convert.ToInt32(dt.Rows[0]["UserGroup"]);
            if (((FormMain)this.Owner).userGroup == 8)
            {
                ((FormMain)this.Owner).button4.Visible = true;
                ((FormMain)this.Owner).button4.Enabled = true;
                ((FormMain)this.Owner).button5.Visible = true;
                ((FormMain)this.Owner).button5.Enabled = true;
            }
            ((FormMain)this.Owner).label13.Text = "用户名:"   textBox5.Text;

            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox1.Text) ||
                string.IsNullOrEmpty(textBox2.Text) ||
                string.IsNullOrEmpty(textBox3.Text) ||
                comboBox1.SelectedIndex < 0)
            {
                MessageBox.Show("请填写完注册资料!");
                return;
            }
            if (textBox2.Text != textBox3.Text)
            {
                MessageBox.Show("密码不一致!");
                return;
            }

            //确保用户名唯一
            Maticsoft.BLL.Users users = new Maticsoft.BLL.Users();
            DataSet ds = users.GetList("UserName='"   textBox1.Text   "'");
            if (ds.Tables.Count > 0)
            {
                DataTable dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    MessageBox.Show("该用户名已经存在!");
                    return;
                }
            }

            Maticsoft.Model.Users user = new Maticsoft.Model.Users();
            user.UserName = textBox1.Text;
            user.PassWord = textBox2.Text;
            user.UserGroup = comboBox1.SelectedIndex   7;

            users.Add(user);
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            comboBox1.SelectedIndex = -1;
            MessageBox.Show("注册成功!");
        }
    }
}