Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString      = "server=localhost;uid=root;pwd=12345;database=db",
                DbType                = SqlSugar.DbType.MySql, //设置数据库类型
                IsAutoCloseConnection = true,                  //自动释放数据务,如果存在事务,在事务结束后释放
                InitKeyType           = InitKeyType.Attribute  //从实体特性中读取主键自增列信息
            });

            var result = db.Updateable <merchants>().SetColumns(it => it.m_catalog == comboBox1.SelectedItem)
                         .Where(it => it.m_id == current_id)
                         .ExecuteCommand();
            var result1 = db.Updateable <merchants>().SetColumns(it => it.m_name == textBox1.Text)
                          .Where(it => it.m_id == current_id)
                          .ExecuteCommand();
            var result2 = db.Updateable <merchants>().SetColumns(it => it.m_address == textBox2.Text)
                          .Where(it => it.m_id == current_id)
                          .ExecuteCommand();
            var result3 = db.Updateable <merchants>().SetColumns(it => it.m_describe == textBox3.Text)
                          .Where(it => it.m_id == current_id)
                          .ExecuteCommand();

            this.Hide();
            Merchant_sys merchant = new Merchant_sys(login_window, current_id);

            merchant.Show();
            this.Hide();
        }
Ejemplo n.º 2
0
        private void Denglu_Click(object sender, EventArgs e) // 按下登陆键
        {
            string id     = id_shuru.Text;                    // 获取用户输入的账号
            int    option = option_list.SelectedIndex;        // 用户选择

            switch (option)
            {
            case 0:      // 用户端
                SqlSugarClient db_login = new SqlSugarClient(new ConnectionConfig()
                {
                    ConnectionString      = "server=localhost;uid=root;pwd=12345;database=db",
                    DbType                = SqlSugar.DbType.MySql, //设置数据库类型
                    IsAutoCloseConnection = true,                  //自动释放数据务,如果存在事务,在事务结束后释放
                    InitKeyType           = InitKeyType.Attribute  //从实体特性中读取主键自增列信息
                });

                string correct_password = "******";
                try
                {
                    var getByWhere = db_login.Queryable <users>().Where(it => it.u_zhanghao == id).ToList();   //根据条件查询
                    correct_password = getByWhere[0].u_passwd;
                }
                catch (Exception)
                {
                    MessageBox.Show("输入的账号或密码有误");
                }


                if (password_shuru.Text == correct_password) //密码正确
                {
                    User_sys user = new User_sys(this);      // 打开用户界面
                    this.Hide();
                    user.Show();
                }
                break;

            case 1:      // 商家端
                SqlSugarClient db_login1 = new SqlSugarClient(new ConnectionConfig()
                {
                    ConnectionString      = "server=localhost;uid=root;pwd=12345;database=db",
                    DbType                = SqlSugar.DbType.MySql, //设置数据库类型
                    IsAutoCloseConnection = true,                  //自动释放数据务,如果存在事务,在事务结束后释放
                    InitKeyType           = InitKeyType.Attribute  //从实体特性中读取主键自增列信息
                });

                string correct_password1 = "-1";
                try
                {
                    var getByWhere1 = db_login1.Queryable <merchants>().Where(it => it.m_identity == id).ToList();   //根据条件查询
                    correct_password1 = getByWhere1[0].m_password;
                }
                catch (Exception)
                {
                    MessageBox.Show("输入的账号或密码有误");
                }

                if (password_shuru.Text == correct_password1)                      //密码正确
                {
                    Merchant_sys merchant = new Merchant_sys(this, id_shuru.Text); // 打开用户界面
                    this.Hide();
                    merchant.Show();
                }
                break;

            case 2:                                                            // 管理端
                string correct_password2 = "1234567";                          // 管理端admin,密码1234567

                if (password_shuru.Text == correct_password2 && id == "admin") //密码正确
                {
                    admin admin = new admin(this);
                    this.Hide();
                    admin.Show();
                }
                else
                {
                    MessageBox.Show("输入的账号或密码有误");
                }
                break;
            }
        }