private void FormAccount_Load(object sender, EventArgs e) { NguoiDungEntity nguoiDungEntity = ManageBase.SelectNguoiDungById(GlobalVariable.NguoiDungId); this.txtUser.Text = nguoiDungEntity.TenDangNhap; this.txtPassNew.Text = ""; this.txtPassOld.Text = ""; this.txtHoTen.Text = nguoiDungEntity.HoTenNguoiDung; this.txtSoDienThoai.Text = nguoiDungEntity.SoDienThoai; this.txtEmail.Text = nguoiDungEntity.DiaChiEmail; bool flag = nguoiDungEntity.GioiTinh == 0; if (flag) { this.chkGioiTinh.CheckState = CheckState.Unchecked; } else { bool flag2 = nguoiDungEntity.GioiTinh == 1; if (flag2) { this.chkGioiTinh.CheckState = CheckState.Checked; } else { this.chkGioiTinh.CheckState = CheckState.Indeterminate; } } }
public static ThongTinHoSo MapThongTinHoSo(ThongTinHoSoEntity entity) { ThongTinHoSo thongTinHoSo = new ThongTinHoSo(); thongTinHoSo.SoBienNhan = entity.SoBienNhan; thongTinHoSo.NgayNop = entity.NgayNop; thongTinHoSo.NgayHenTra = entity.NgayHenTra; thongTinHoSo.NgayTraHoSo = entity.NgayTraHoSo; thongTinHoSo.NgayKiemTraNoiNghiep = entity.NgayKiemTraNoiNghiep; thongTinHoSo.SoBanVe = entity.SoBanVe; thongTinHoSo.PhiDoVe = entity.PhiDoVe; thongTinHoSo.GhiChu = entity.GhiChu; thongTinHoSo.GioiTinhNguoiNop = entity.GioiTinhNguoiNop.Value; thongTinHoSo.NguoiNopHoSo = entity.NguoiNopHoSo; thongTinHoSo.SoGiayToNguoiNop = entity.SoGiayToNguoiNop; thongTinHoSo.IsNew = false; thongTinHoSo.IsSuccess = false; thongTinHoSo.LaHoSoMoiNhat = entity.HoSoMoiNhat; thongTinHoSo.KhoaChaId = entity.KhoaChaId; thongTinHoSo.LoaiBienDongId = entity.LoaiBienDongId; thongTinHoSo.ThongTinChiTiet = JsonConvert.DeserializeObject <ChiTietHoSo>(entity.ChiTietHoSo); thongTinHoSo.ThongTinHoSoId = entity.ThongTinHoSoId; thongTinHoSo.PhiThamDinh = entity.PhiThamDinh; thongTinHoSo.ChuyenVienId = entity.ChuyenVienId; thongTinHoSo.ChuyenVienKiemTra = entity.ChuyenVienKiemTra; thongTinHoSo.CongTyDoVeId = entity.CongTyDoVeId; thongTinHoSo.CongTyDoVe = entity.CongTyDoVe; thongTinHoSo.HoSoChuaDat = entity.HoSoChuaDat; thongTinHoSo.HoSoDaKiemTra = entity.HoSoDaKiemTra; thongTinHoSo.HoSoKhongHopLy = entity.HoSoKhongHopLy; thongTinHoSo.RootId = entity.RootId; thongTinHoSo.NgayChinhSua = entity.NgayChinhSua; bool flag3 = !string.IsNullOrEmpty(entity.LichSuCapNhat); if (flag3) { thongTinHoSo.LichSuCapNhat = JsonConvert.DeserializeObject <UserLog>(entity.LichSuCapNhat); } bool hasValue = entity.NguoiDungId.HasValue; if (hasValue) { NguoiDungEntity nguoiDungEntity = ManageBase.SelectNguoiDungById(entity.NguoiDungId.Value); thongTinHoSo.NguoiCapNhat = nguoiDungEntity.HoTenNguoiDung; bool flag4 = string.IsNullOrEmpty(thongTinHoSo.NguoiCapNhat); if (flag4) { thongTinHoSo.NguoiCapNhat = nguoiDungEntity.TenDangNhap; } } return(thongTinHoSo); }
private void btnCapNhat_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; bool flag = false; int num = Convert.ToInt32(this.btnCapNhat.Tag.ToString()); NguoiDungEntity nguoiDungEntity = null; bool flag2 = !this.btnThemMoi.Enabled && num == 0; if (flag2) { nguoiDungEntity = new NguoiDungEntity(); flag = true; } else { bool flag3 = num > 0; if (flag3) { nguoiDungEntity = ManageBase.SelectNguoiDungById(num); } } bool flag4 = nguoiDungEntity != null; if (flag4) { bool flag5 = this.txtUser.Text.Trim() == "" || this.txtPass.Text.Trim() == ""; if (flag5) { MessageBox.Show("Tên đăng nhập và mật khẩu không được để trống!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.txtUser.Focus(); this.Cursor = Cursors.Default; return; } bool flag6 = ManageBase.NguoiDungExist(num, this.txtUser.Text.Trim()); if (flag6) { MessageBox.Show("Tên đăng nhập đã tồn tại. Hãy chọn tên đăng nhập khác!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.txtUser.Focus(); this.Cursor = Cursors.Default; return; } nguoiDungEntity.TenDangNhap = this.txtUser.Text.Trim(); nguoiDungEntity.MatKhau = Util.Encrypt(this.txtPass.Text.Trim()); nguoiDungEntity.HoTenNguoiDung = this.txtHoTen.Text.Trim(); nguoiDungEntity.SoDienThoai = this.txtSoDienThoai.Text.Trim(); nguoiDungEntity.DiaChiEmail = this.txtEmail.Text.Trim(); nguoiDungEntity.VaiTro = (byte)this.cboVaiTro.SelectedIndex; bool flag7 = this.chkGioiTinh.CheckState == CheckState.Checked; if (flag7) { nguoiDungEntity.GioiTinh = 1; } else { bool flag8 = this.chkGioiTinh.CheckState == CheckState.Unchecked; if (flag8) { nguoiDungEntity.GioiTinh = 0; } else { nguoiDungEntity.GioiTinh = 3; } } bool flag9 = ManageBase.SaveNguoiDung(nguoiDungEntity); if (flag9) { bool flag10 = nguoiDungEntity.NguoiDungId == GlobalVariable.NguoiDungId; if (flag10) { GlobalVariable.TenDangNhap = nguoiDungEntity.TenDangNhap; GlobalVariable.MatKhau = nguoiDungEntity.MatKhau; string text = ProcessConfigXML.LoadData("Account"); Dictionary <string, object> dictionary = ProcessConfigXML.ConfigString2Dictionary(text, new Dictionary <string, object> { { "User", "admin" }, { "Pass", "123" }, { "Remember", "true" } }); dictionary["User"] = nguoiDungEntity.TenDangNhap; dictionary["Pass"] = nguoiDungEntity.MatKhau; text = ProcessConfigXML.Dictionary2ConfigString(dictionary); ProcessConfigXML.SaveData("Account", text); } bool flag11 = flag; if (flag11) { DataTable dataTable = (DataTable)this._bindingTaiKhoan.DataSource; DataRow dataRow = dataTable.NewRow(); dataRow["NguoiDungId"] = nguoiDungEntity.NguoiDungId; dataRow["TenDangNhap"] = nguoiDungEntity.TenDangNhap; dataRow["MatKhau"] = nguoiDungEntity.MatKhau; dataRow["HoTenNguoiDung"] = nguoiDungEntity.HoTenNguoiDung; dataRow["GioiTinh"] = nguoiDungEntity.GioiTinh; dataRow["SoDienThoai"] = nguoiDungEntity.SoDienThoai; dataRow["DiaChiEmail"] = nguoiDungEntity.DiaChiEmail; dataRow["VaiTro"] = nguoiDungEntity.VaiTro; dataTable.Rows.Add(dataRow); this.dgvTaiKhoan.Rows[this.dgvTaiKhoan.Rows.Count - 1].Selected = true; } this.btnThemMoi.Enabled = true; this.dgvTaiKhoan.Enabled = true; this.btnXoa.Enabled = true; this.dgvTaiKhoan_SelectionChanged(null, null); MessageBox.Show("Cập nhật tài khoản thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("Cập nhật tài khoản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } this.Cursor = Cursors.Default; }
private void btnCapNhat_Click(object sender, EventArgs e) { bool flag = this.txtUser.Text.Trim() == "" || this.txtPassOld.Text.Trim() == "" || this.txtPassNew.Text.Trim() == ""; if (flag) { MessageBox.Show("Tên đăng nhập và mật khẩu không được để trống!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.txtUser.Focus(); } else { bool flag2 = this.txtPassOld.Text.Trim() != Util.Decrypt(GlobalVariable.MatKhau); if (flag2) { MessageBox.Show("Mật khẩu hiện tại không đúng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.txtUser.Focus(); } else { bool flag3 = !ManageBase.NguoiDungExist(GlobalVariable.NguoiDungId, this.txtUser.Text.Trim()); if (flag3) { NguoiDungEntity nguoiDungEntity = ManageBase.SelectNguoiDungById(GlobalVariable.NguoiDungId); nguoiDungEntity.TenDangNhap = this.txtUser.Text.Trim(); nguoiDungEntity.MatKhau = Util.Encrypt(this.txtPassNew.Text.Trim()); nguoiDungEntity.HoTenNguoiDung = this.txtHoTen.Text.Trim(); nguoiDungEntity.SoDienThoai = this.txtSoDienThoai.Text.Trim(); nguoiDungEntity.DiaChiEmail = this.txtEmail.Text.Trim(); bool flag4 = this.chkGioiTinh.CheckState == CheckState.Checked; if (flag4) { nguoiDungEntity.GioiTinh = 1; } else { bool flag5 = this.chkGioiTinh.CheckState == CheckState.Unchecked; if (flag5) { nguoiDungEntity.GioiTinh = 0; } else { nguoiDungEntity.GioiTinh = 3; } } bool flag6 = ManageBase.SaveNguoiDung(nguoiDungEntity); if (flag6) { GlobalVariable.TenDangNhap = nguoiDungEntity.TenDangNhap; GlobalVariable.MatKhau = nguoiDungEntity.MatKhau; string text = ProcessConfigXML.LoadData("Account"); Dictionary <string, object> dictionary = ProcessConfigXML.ConfigString2Dictionary(text, new Dictionary <string, object> { { "User", "" }, { "Pass", "" }, { "Remember", "true" } }); dictionary["User"] = nguoiDungEntity.TenDangNhap; dictionary["Pass"] = nguoiDungEntity.MatKhau; text = ProcessConfigXML.Dictionary2ConfigString(dictionary); ProcessConfigXML.SaveData("Account", text); MessageBox.Show("Cập nhật tài khoản thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("Cập nhật tài khoản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("Tên đăng nhập đã tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.txtUser.Focus(); } } } }