Пример #1
0
 private void btnAccept_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtCMND.Text == "" || txtPass.Text == "" || txtTenDangNhap.Text == "")
         {
             Alert("Vui lòng điền đầy đủ", frmAlert.Type.Info);
         }
         if (txtPass.Text.Equals(txtPassRepeat.Text) && txtPassRepeat.Text != "")
         {
             DTO_Account acc = new DTO_Account();
             int         stt = BUS_Account.GetAllAccount().Count();
             if (key != 0)
             {
                 acc.STT = stt;
             }
             else
             {
                 acc.STT = stt + 1;
             }
             acc.CMND        = Convert.ToInt32(txtCMND.Text);
             acc.TenDangNhap = txtTenDangNhap.Text;
             acc.MatKhau     = BUS_Account.MaHoa(txtPassRepeat.Text);
             acc.ChucVu      = cbbChucVu.selectedValue.ToString();
             if (key != 0)
             {
                 acc.TenDangNhap = txtTenDangNhap.Text;
                 acc.MatKhau     = BUS_Account.MaHoa(txtPassRepeat.Text);
                 acc.ChucVu      = cbbChucVu.selectedValue.ToString();
                 BUS_Account.InsertUpdate(acc);
                 Alert(msg, frmAlert.Type.Success);
             }
             else
             {
                 BUS_Account.InsertUpdate(acc);
                 msg = "Đã thêm thành công ^^";
                 Alert(msg, frmAlert.Type.Success);
             }
         }
     }
     catch (Exception)
     {
         Alert("Hãy thêm hồ sơ người này trước!", frmAlert.Type.Error);
     }
 }