Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.txtUserNmae.Text.Length <= 0)
            {
                MessageBox.Show(this, "用户名不可以为空!");
            }
            else if (this.txtUserNmae.Text.Length >= 50)
            {
                MessageBox.Show(this, "用户名长度不可以超过50!");
            }
            else if (this.txtPwd.Text.Length <= 0)
            {
                MessageBox.Show(this, "密码不可以为空!");
            }
            else if (this.txtPwd.Text.Length >= 50)
            {
                MessageBox.Show(this, "密码长度不可以超过50!");
            }
            else if (this.txtOrgCode.Text.Length <= 0)
            {
                MessageBox.Show(this, "机构编码不可以为空!");
            }
            else if (this.txtOrgCode.Text.Length >= 50)
            {
                MessageBox.Show(this, "机构编码不可以超过50!");
            }
            else if (this.txtOrgName.Text.Length <= 0)
            {
                MessageBox.Show(this, "机构名称不可以为空!");
            }
            else if (this.txtOrgName.Text.Length >= 50)
            {
                MessageBox.Show(this, "机构名称不可以超过50!");
            }
            else
            {
                Users model = new Users();
                model.LoginName = txtUserNmae.Text.Trim();
                model.LoginPwd  = txtPwd.Text.Trim();
                model.OrgCode   = txtOrgCode.Text.Trim();
                model.OrgName   = txtOrgName.Text.Trim();

                if (cbEnabled.Checked == true)
                {
                    model.Enabled = "1";
                }
                else
                {
                    model.Enabled = "0";
                }


                UserLogin dal = new UserLogin();

                if (dal.Add(model) > 0)
                {
                    SetUpUCEmpty();
                    MessageBox.Show(this, "添加成功");
                }
                else
                {
                    MessageBox.Show(this, "添加失败");
                }
            }
        }