C# winform 汽车租赁系统

C# winform 汽车租赁系统

本系统采用C# winform以及第三方控件书写,数据库采用sqlserver,已将程序进行exe打包
登录注册页面
在这里插入图片描述
代码:


        private void btnLogin_Click(object sender, EventArgs e)
        {
            /*string uneText = this.txtLoginName.Text.Trim();
            string pwdText = this.txtLoginPwd.Text.Trim();*/
            Computer computer = new Computer();
            if (user.Checked)
            {
                //根据用户名查找员工信息
                string sql = "select * from uUser where uUsername = @uUsername";
                SqlParameter p = new SqlParameter("@uUsername", txtLoginName.Text);
                DataTable dt = new DataTable();
                dt = DBHelper.ExecuteQuery(sql, p);
                if (dt.Rows.Count > 0)
                {
                    userInfo userInfo = new userInfo();
                    userInfo.uId = Convert.ToInt32(dt.Rows[0][0]);
                    userInfo.uUsername = dt.Rows[0][1].ToString();
                    userInfo.uPassword = dt.Rows[0][2].ToString();
                    userInfo.uPhone = dt.Rows[0][3].ToString();
                    userInfo.uAddress = dt.Rows[0][4].ToString();

                    //用户名存在验证密码
                    if (txtLoginPwd.Text == dt.Rows[0][2].ToString())
                    {
                        //密码正确
                        this.ShowSuccessTip("登录成功!");
                        //添加登陆者的信息到数据库
                        string sqlLog = "insert into logTable (logName,logTime,logIp,logPermission) values (@logName,@logTime,@logIp,@logPermission)";
                        SqlParameter[] logPs =
                        {                         
                            new SqlParameter("@logName",txtLoginName.Text),
                            new SqlParameter("@logTime",DateTime.Now),
                            new SqlParameter("@logIp",computer.IpAddress),
                            new SqlParameter("@logPermission","普通用户")
                    };
                        //DBHelper.ExecuteNonQuery(sqlLog, logPs);
                        userMain userMain = new userMain();
                        userMain.Tag = userInfo;
                        userMain.Show();
                        this.Hide();
                    }
                    else
                    {

                        this.ShowErrorDialog("密码错误");
                        txtLoginName.Text = "";
                        txtLoginPwd.Text = "";
                    }
                }
                else
                {
                    this.ShowErrorDialog("用户名不存在");
                    txtLoginName.Text = "";
                    txtLoginPwd.Text = "";
                }
            }
            
            else if (admin.Checked)
            {
                //根据用户名查找管理员信息
                string sql = "select * from Admin where superName = @superName";
                SqlParameter p = new SqlParameter("@superName", txtLoginName.Text);
                DataTable dt = new DataTable();
                dt = DBHelper.ExecuteQuery(sql, p);
                if (dt.Rows.Count > 0)
                {
                    Admin admin = new Admin();
                    admin.superName = dt.Rows[0][0].ToString();
                    admin.superPassword = dt.Rows[0][1].ToString();
                    //用户名存在验证密码
                    if (txtLoginPwd.Text == admin.superPassword)
                    {
                        ControlHelper.ThreadRunExt(this, () =>
                        {
                            Thread.Sleep(500);
                            ControlHelper.ThreadInvokerControl(this, () =>
                            {      
                                //添加登陆者的信息到数据库
                                string sqlLog = "insert into logTable (logName,logTime,logIp,logPermission) values (@logName,@logTime,@logIp,@logPermission)";
                                SqlParameter[] logPs =
                                {
                            new SqlParameter("@logName",txtLoginName.Text),
                            new SqlParameter("@logTime",DateTime.Now),
                            new SqlParameter("@logIp",computer.IpAddress),
                            new SqlParameter("@logPermission","超级管理员")
                    };
                                DBHelper.ExecuteNonQuery(sqlLog, logPs);
                                this.ShowSuccessTip("管理员账号登录成功!");
                                Form1 f1 = new Form1();
                                f1.Tag = admin;

                                f1.Show();
                                this.Hide();
                            });
                        }, null, this);

                        
                    }
                    else
                    {
                        this.ShowErrorDialog("管理员密码错误");
                        txtLoginName.Text = "";
                        txtLoginPwd.Text = "";
                    }
                }
                else
                {
                    this.ShowErrorDialog("此管理员不存在");
                    txtLoginName.Text = "";
                    txtLoginPwd.Text = "";
                }
            }
            else
            {
                this.ShowErrorDialog("请选择登录类型");
            }




        }

用户界面:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
管理员界面
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值