예제 #1
0
        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;
                }
            }
        }
예제 #2
0
        private static async Task TaoTaiKhoanAdmin(IServiceProvider serviceProvider)
        {
            //Lấy đối tượng môi trường đang chạy App
            var env = serviceProvider.GetService <IHostingEnvironment>();

            var cauhinhmoitruong = new ConfigurationBuilder()
                                   .SetBasePath(env.ContentRootPath)
                                   .AddJsonFile("appsettings.json")
                                   .AddEnvironmentVariables();
            var cauhinh = cauhinhmoitruong.Build();
            //Khởi tạo lớp hỗ trợ tạo tài khoãn
            var quanlynguoidung = serviceProvider.GetService <UserManager <NguoiDungEntity> >();
            //Kiểm tra có tài khoản admin chưa
            var user = await quanlynguoidung.FindByNameAsync(cauhinh[taikhoancuaadmin]);

            if (user == null)
            {
                var taikhoanadmin = new NguoiDungEntity()
                {
                    UserName = cauhinh[taikhoancuaadmin],
                    Email    = cauhinh[taikhoancuaadmin]
                };
                await quanlynguoidung.CreateAsync(taikhoanadmin, cauhinh[matkhaucuaadmin]);

                await quanlynguoidung.AddClaimAsync(taikhoanadmin, new Claim("Admin", "Allowed"));
            }
        }
예제 #3
0
        public static bool SaveNguoiDung(NguoiDungEntity eNguoiDung)
        {
            bool result;

            using (DataAccessAdapterBase dataAccessAdapterBase = new DataAccessAdapter(ManageBase.ConnectionString))
            {
                result = dataAccessAdapterBase.SaveEntity(eNguoiDung, true);
            }
            return(result);
        }
예제 #4
0
        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);
        }
예제 #5
0
        public static NguoiDungEntity SelectNguoiDungById(int nguoiDungId)
        {
            NguoiDungEntity result = null;

            using (DataAccessAdapterBase dataAccessAdapterBase = new DataAccessAdapter(ManageBase.ConnectionString))
            {
                NguoiDungEntity nguoiDungEntity = new NguoiDungEntity(nguoiDungId);
                bool            flag            = dataAccessAdapterBase.FetchEntity(nguoiDungEntity);
                if (flag)
                {
                    result = nguoiDungEntity;
                }
            }
            return(result);
        }
예제 #6
0
        public async Task <IActionResult> DangKy([FromBody] ModelDangKyMau taikhoandungdedangky)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var khachhang = new KhachHang()
            {
                Id    = Guid.NewGuid().ToString(),
                HoTen = taikhoandungdedangky.Ho + " " + taikhoandungdedangky.Ten,
            };

            await ketnoidatabase.KhachHang.AddAsync(khachhang);

            await ketnoidatabase.SaveChangesAsync();

            var kqTaoKhachHang = ketnoidatabase.KhachHang.Where(p => p.Id == khachhang.Id).SingleOrDefault();

            var taikhoan = new NguoiDungEntity()
            {
                UserName    = taikhoandungdedangky.Email,
                Email       = taikhoandungdedangky.Email,
                Ho          = taikhoandungdedangky.Ho,
                Ten         = taikhoandungdedangky.Ten,
                IdKhachHang = kqTaoKhachHang.Id
            };
            //Tao tai khoan user bang CreateAsync
            var kq = await _quanlyTaiKhoan.CreateAsync(taikhoan, taikhoandungdedangky.MatKhau);

            if (kq.Succeeded)
            {
                return(Ok(kq));
            }

            foreach (var err in kq.Errors)
            {
                ModelState.AddModelError("error", err.Description);
            }

            return(BadRequest(kq.Errors));
        }
예제 #7
0
        public static NguoiDungEntity SelectNguoiDung(string tenDangNhap, string matKhau)
        {
            NguoiDungEntity result = null;

            using (DataAccessAdapterBase dataAccessAdapterBase = new DataAccessAdapter(ManageBase.ConnectionString))
            {
                EntityCollection entityCollection = new EntityCollection(new NguoiDungEntityFactory());
                dataAccessAdapterBase.FetchEntityCollection(entityCollection, new RelationPredicateBucket
                {
                    PredicateExpression =
                    {
                        NguoiDungFields.TenDangNhap == tenDangNhap,
                        NguoiDungFields.MatKhau == matKhau
                    }
                });
                bool flag = entityCollection != null && entityCollection.Count > 0;
                if (flag)
                {
                    result = (NguoiDungEntity)entityCollection[0];
                }
            }
            return(result);
        }
예제 #8
0
        public static List <NguoiDung> GetAllNguoiDung()
        {
            List <NguoiDung> list             = new List <NguoiDung>();
            EntityCollection entityCollection = ManageBase.SelectAllNguoiDung();

            using (IEnumerator <EntityBase2> enumerator = entityCollection.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    NguoiDungEntity nguoiDungEntity = (NguoiDungEntity)enumerator.Current;
                    NguoiDung       nguoiDung       = new NguoiDung();
                    nguoiDung.NguoiDungId  = nguoiDungEntity.NguoiDungId;
                    nguoiDung.TenNguoiDung = nguoiDungEntity.HoTenNguoiDung;
                    bool flag = string.IsNullOrEmpty(nguoiDung.TenNguoiDung);
                    if (flag)
                    {
                        nguoiDung.TenNguoiDung = nguoiDungEntity.TenDangNhap;
                    }
                    list.Add(nguoiDung);
                }
            }
            return(list);
        }
예제 #9
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary.Add("Data Source", this.txtServerName.Text.Trim());
            dictionary.Add("Database", this.txtDatabasename.Text.Trim());
            dictionary.Add("User ID", this.txtUsernameSQL.Text.Trim());
            dictionary.Add("Password", this.txtPasswordSQL.Text.Trim());
            string text = ProcessConfigXML.Dictionary2ConfigString(dictionary);
            bool   flag = ManageBase.IsConnectDatabase(text);

            if (flag)
            {
                DataAccessAdapterManagerBase.SetCustomConnectString(text);
                string          text2           = Util.Encrypt(this.txtLISloginPassword.Text.Trim());
                NguoiDungEntity nguoiDungEntity = ManageBase.SelectNguoiDung(this.txtLISloginUserName.Text.Trim(), text2);
                bool            flag2           = nguoiDungEntity != null;
                if (flag2)
                {
                    Dictionary <string, object> dictionary2 = new Dictionary <string, object>();
                    bool @checked = this.chkLoginRemember.Checked;
                    if (@checked)
                    {
                        dictionary2.Add("User", this.txtLISloginUserName.Text.Trim());
                        dictionary2.Add("Pass", text2);
                        dictionary2.Add("Remember", this.chkLoginRemember.Checked ? "true" : "false");
                    }
                    else
                    {
                        dictionary2.Add("User", "");
                        dictionary2.Add("Pass", "");
                        dictionary2.Add("Remember", "false");
                    }
                    GlobalVariable.NguoiDungId      = nguoiDungEntity.NguoiDungId;
                    GlobalVariable.TenDangNhap      = nguoiDungEntity.TenDangNhap;
                    GlobalVariable.HoTenNguoiDung   = nguoiDungEntity.HoTenNguoiDung;
                    GlobalVariable.MatKhau          = nguoiDungEntity.MatKhau;
                    GlobalVariable.LaQuanTriHeThong = (nguoiDungEntity.VaiTro == 1);
                    dictionary["Password"]          = Util.Encrypt(this.txtPasswordSQL.Text.Trim());
                    text = ProcessConfigXML.Dictionary2ConfigString(dictionary);
                    string strValue = ProcessConfigXML.Dictionary2ConfigString(dictionary2);
                    ProcessConfigXML.SaveData("ConnectiontString", text);
                    ProcessConfigXML.SaveData("Account", strValue);
                    bool flag3 = GlobalVariable.CreateFTP();
                    if (flag3)
                    {
                        base.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        bool laQuanTriHeThong = GlobalVariable.LaQuanTriHeThong;
                        if (laQuanTriHeThong)
                        {
                            FormKetNoiFTP formKetNoiFTP = new FormKetNoiFTP();
                            formKetNoiFTP.ShowDialog();
                            bool flag4 = GlobalVariable.FTPLib != null;
                            if (flag4)
                            {
                                base.DialogResult = DialogResult.OK;
                                base.Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Hiện tại không thể kết nối tới FTP. Hãy liên hệ quản trị hệ thống thiết lập lại thông số kết nối.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.txtLISloginUserName.Focus();
                }
            }
            else
            {
                MessageBox.Show("Không kết nối được cơ sở dữ liệu. Kiểm tra lại thông số kết nối!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                this.txtServerName.Focus();
            }
            this.Cursor = Cursors.Default;
        }
예제 #10
0
        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;
        }
예제 #11
0
        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();
                    }
                }
            }
        }