Beispiel #1
0
        private void bar_save_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            mahoa  mahoa = new mahoa();
            string pass  = mahoa.EncryptString(passold.Text, "lamgico");

            #region check password old
            if (passnewagain.Text != passnew.Text)
            {
                XtraMessageBox.Show("Mật khẩu nhập lại không đúng");
                return;
            }
            if (pass != dinhdanh.password)
            {
                XtraMessageBox.Show("Mật khẩu cũ không đúng");
                return;
            }
            #endregion
            try
            {
                string passnew = mahoa.EncryptString(passnewagain.Text, "lamgico");
                using (khieunaitocaoContextDataContext khieunaitocaoContext = new khieunaitocaoContextDataContext())
                {
                    khieunaitocaoContext.UpdatePassword(dinhdanh.ma_canbo, passnew);
                    XtraMessageBox.Show("Đổi mật khẩu thành công");
                }
            }
            catch (Exception)
            {
                XtraMessageBox.Show("Đổi mật khẩu không thành công");
                //throw;
            }
        }
        private void _dangnhap()
        {
            mahoa  mh      = new mahoa();
            string matkhau = mh.EncryptString(txt_matkhaudangnhap.Text, "lamgico");

            try
            {
                int?status = _khieunaitocaoContext.login_canbo_linq(Convert.ToInt16(com_tendonvi.EditValue), txt_tendangnhap.Text, matkhau);
                if (status == 1)
                {
                    this.DialogResult = DialogResult.OK;
                    var _dinhdanh_canbo = _khieunaitocaoContext.dinhdanh_canbo(Convert.ToInt16(com_tendonvi.EditValue), txt_tendangnhap.Text).SingleOrDefault();
                    dinhdanh.madonvi      = _dinhdanh_canbo.ma_donvi;
                    dinhdanh.ma_canbo     = _dinhdanh_canbo.ma_canbo;
                    dinhdanh.sohieu_cand  = _dinhdanh_canbo.sohieu_cand;
                    dinhdanh.quyenhan     = _dinhdanh_canbo.quyenhan;
                    dinhdanh.kyhieu_donvi = _dinhdanh_canbo.kyhieu_donvi.Trim();
                    dinhdanh.tencanbo     = _dinhdanh_canbo.hoten_chiensy;
                    this.Close();
                }

                if (status == 0)
                {
                    XtraMessageBox.Show("Sai thông tin đăng nhập");
                }
            }
            catch (Exception)
            {
                XtraMessageBox.Show("Kiểm tra lại kết nối");
            }
            SaveSetting();
        }
Beispiel #3
0
 private void fun_save()
 {
     #region check permission
     if (dinhdanh.quyenhan != 0)
     {
         XtraMessageBox.Show("Bạn không có quyền sửa");
         return;
     }
     #endregion
     using (_khieunaitocaoContext = new khieunaitocaoContextDataContext())
     {
         try
         {
             #region rangbuoc
             if (txt_hoten.Text.Trim() == "")
             {
                 XtraMessageBox.Show("Vui lòng nhập họ tên chính xác");
                 txt_hoten.Focus();
                 return;
             }
             if (txt_sohieuCAND.Text.Trim() == "")
             {
                 XtraMessageBox.Show("Vui lòng nhập số hiệu CAND");
                 txt_sohieuCAND.Focus();
                 return;
             }
             if (txt_tendangnhap.Text.Trim() == "")
             {
                 XtraMessageBox.Show("Vui lòng nhập tên đăng nhập");
                 txt_tendangnhap.Focus();
                 return;
             }
             if (com_capbac.Text.Trim() == "")
             {
                 XtraMessageBox.Show("Vui lòng chọn cấp bậc");
                 com_capbac.Focus();
                 return;
             }
             if (com_chucvu.Text.Trim() == "")
             {
                 XtraMessageBox.Show("Vui lòng chọn chức vụ");
                 com_chucvu.Focus();
                 return;
             }
             if (txt_matkhau.Text.Trim() == "")
             {
                 XtraMessageBox.Show("Vui lòng nhập mật khẩu");
                 txt_matkhau.Focus();
                 return;
             }
             if (radio_quyenhan.SelectedIndex != 0 && radio_quyenhan.SelectedIndex != 1)
             {
                 XtraMessageBox.Show("Vui lòng chọn quyền hạn tài khoản");
                 radio_quyenhan.Focus();
                 return;
             }
             #endregion
             var _mk      = mh.EncryptString(txt_matkhau.Text, "lamgico");
             int _madonvi = Convert.ToInt16(search_coquandonvi.EditValue);
             if (radio_quyenhan.SelectedIndex == 0)
             {
                 quyen_han = 2;
             }
             if (radio_quyenhan.SelectedIndex == 1)
             {
                 quyen_han = 1;
             }
             if (bool_sua == false)
             {
                 _khieunaitocaoContext.them_canbo(_madonvi, Int32.Parse(txt_sohieuCAND.Text), txt_hoten.Text, txt_tendangnhap.Text, _mk, com_capbac.Text, com_chucvu.Text, quyen_han);
             }
             else
             {
                 _khieunaitocaoContext.sua_canbo(_madonvi, _macanbo, txt_sohieuCAND.Text, txt_hoten.Text, txt_tendangnhap.Text, _mk, com_capbac.Text, com_chucvu.Text, quyen_han);
             }
             XtraMessageBox.Show("Lưu thông tin thành công");
         }
         catch (Exception)
         {
             XtraMessageBox.Show("Vui lòng kiểm tra lại thông tin nhập vào.\n Không để trống các trường bắt buộc phải có.");
         }
     }
 }