Beispiel #1
0
        private void ucBtnChangePwd_BtnClick(object sender, EventArgs e)
        {
            FrmInputs frm = new FrmInputs("修改密码",
                                          new string[] { "旧密码", "新密码", "确定密码" },
                                          new Dictionary <string, HZH_Controls.TextInputType>()
            {
            },
                                          new Dictionary <string, string>()
            {
            },
                                          new Dictionary <string, KeyBoardType>()
            {
                { "旧密码", KeyBoardType.UCKeyBorderAll_EN }, { "新密码", KeyBoardType.UCKeyBorderAll_EN }
            },
                                          new List <string>()
            {
                "旧密码", "新密码", "确定密码"
            });

            frm.ShowDialog(this);
            if (frm.DialogResult == DialogResult.OK)
            {
                string oldPwd = frm.Values[0];
                string newPwd = frm.Values[1];
                string comPwd = frm.Values[2];
                if (newPwd != comPwd)
                {
                    MessageBox.Show("两次密码不一致");
                    return;
                }

                //if (!Check.isPwd(newPwd))
                // {
                //     MessageBox.Show("密码最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符");
                //     return;
                // }

                if (MD5Encode.GetMd5(oldPwd) == teacher.PassWord)
                {
                    TeacherBLL bll = new TeacherBLL();
                    string     msg = bll.EditPwd(MD5Encode.GetMd5(newPwd), teacher.TID)?"修改成功":"修改失败";
                    MessageBox.Show(msg);
                }
                else
                {
                    MessageBox.Show("原密码错误");
                }
            }
        }
        //添加学生
        private void ucBtnSave_BtnClick(object sender, EventArgs e)
        {
            bool b;

            if (!Check.isStudentID(txtSID.Text))
            {
                FrmTips.ShowTipsWarning(this, "学号格式不正确");
                return;
            }

            try
            {
                Student stu = new Student();
                stu.SID           = txtSID.Text;
                stu.SName         = txtSname.Text;
                stu.PassWord      = MD5Encode.GetMd5("123456"); //学生默认密码123456
                stu.SGender       = cmbGender.SelectedIndex % 2 == 0 ? "男" : "女";
                stu.Class         = cmbClass.SelectedValue.ToString();
                stu.Departments   = cmbCollege.SelectedValue.ToString();
                stu.Birthday      = Convert.ToDateTime(dtpBir.Value.ToString("yyy/MM/dd"));
                stu.AdmissionTime = Convert.ToDateTime(dtpAdm.Value.ToString("yyy/MM/dd"));
                stu.Image         = null;
                StudentBLL bll = new StudentBLL();
                b = bll.AddStudentInfo(stu);
            }
            catch (Exception)
            {
                b = false;
            }

            if (b)
            {
                FrmTips.ShowTipsSuccess(this, "添加成功");
                txtSID.Clear();
                txtSname.Clear();
                txtSID.Focus();
            }
            else
            {
                FrmTips.ShowTipsError(this, "添加失败");
            }

            //MessageBox.Show(cmbGender.SelectedValue.ToString());
            //MessageBox.Show(cmbClass.SelectedValue.ToString());
        }
        private void ucBtnChangePwd_BtnClick(object sender, EventArgs e)
        {
            FrmInputs frm = new FrmInputs("修改密码",
                                          new string[] { "旧密码", "新密码", "确定密码" },
                                          new Dictionary <string, HZH_Controls.TextInputType>()
            {
            },
                                          new Dictionary <string, string>()
            {
            },
                                          new Dictionary <string, KeyBoardType>()
            {
                { "旧密码", KeyBoardType.UCKeyBorderAll_EN }, { "新密码", KeyBoardType.UCKeyBorderAll_EN }
            },
                                          new List <string>()
            {
                "旧密码", "新密码", "确定密码"
            });

            frm.ShowDialog(this);
            if (frm.DialogResult == DialogResult.OK)
            {
                string oldPwd = frm.Values[0];
                string newPwd = frm.Values[1];
                string comPwd = frm.Values[2];
                if (newPwd != comPwd)
                {
                    MessageBox.Show("两次密码不一致");
                    return;
                }
                if (MD5Encode.GetMd5(oldPwd) == student.PassWord)
                {
                    StudentBLL bll = new StudentBLL();
                    string     msg = bll.EditPwd(MD5Encode.GetMd5(newPwd), student.SID) ? "修改成功" : "修改失败";
                    MessageBox.Show(msg);
                }
                else
                {
                    MessageBox.Show("原密码错误");
                }
            }
        }