private void LoadAccount() { var dtgv = dtgvAccount; dtgv.Tag = 0; clsTaiKhoanDangNhap cls = new clsTaiKhoanDangNhap(); DataTable dt = cls.SelectAll(); dt.DefaultView.RowFilter = "TonTai = 1"; dt = dt.DefaultView.ToTable(); dtgv.Rows.Clear(); int STT = 1; foreach (DataRow dr in dt.Rows) { DataGridViewRow row = (DataGridViewRow)dtgv.Rows[0].Clone(); row.Cells[0].Value = dr["ID_TaiKhoanDangNhap"]; row.Cells[1].Value = STT++; row.Cells[2].Value = dr["TenDangNhap"]; row.Cells[3].Value = dr["TenDayDu"]; dtgv.Rows.Add(row); } dtgv.Rows[dtgv.Rows.Count - 1].Selected = true; dtgv.Tag = 1; }
private void btnResetPassword_Click(object sender, EventArgs e) { if (dtgvAccount.CurrentRow.Index == dtgvAccount.Rows.Count - 1) { return; } clsTaiKhoanDangNhap cls = new clsTaiKhoanDangNhap(); cls.ID_TaiKhoanDangNhap = int.Parse(dtgvAccount.Rows[dtgvAccount.CurrentRow.Index].Cells[0].Value.ToString()); cls.SelectOne(); cls.MatKhau = GlobalMethods.MD5Hash("1"); cls.Update(); MessageBox.Show("Reset mật khẩu thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadAccount(); }
private void btnDeleteAccount_Click(object sender, EventArgs e) { if (dtgvAccount.CurrentRow.Index == dtgvAccount.Rows.Count - 1) { return; } clsTaiKhoanDangNhap cls = new clsTaiKhoanDangNhap(); cls.ID_TaiKhoanDangNhap = int.Parse(dtgvAccount.Rows[dtgvAccount.CurrentRow.Index].Cells[0].Value.ToString()); cls.SelectOne(); cls.TonTai = false; cls.Update(); MessageBox.Show("Xóa thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadAccount(); }
private void btnAddAccount_Click(object sender, EventArgs e) { if (!IsValid()) { return; } clsTaiKhoanDangNhap cls = new clsTaiKhoanDangNhap(); cls.TenDangNhap = txtUserName.Text.Trim(); cls.TenDayDu = txtTenDayDu.Text.Trim(); cls.MatKhau = GlobalMethods.MD5Hash("1"); cls.TonTai = true; cls.Insert(); MessageBox.Show("Thêm mới thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadAccount(); }
private void btnLogin_Click(object sender, EventArgs e) { if (txtTenDangNhap.Text.Trim() == "") { MessageBox.Show("Chưa nhập tên đăng nhập.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txtMatKhau.Text.Trim() == "") { MessageBox.Show("Chưa nhập mật khẩu.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } clsTaiKhoanDangNhap cls = new clsTaiKhoanDangNhap(); cls.TenDangNhap = txtTenDangNhap.Text.Trim(); cls.MatKhau = GlobalMethods.MD5Hash(txtMatKhau.Text.Trim()); DataTable dt = cls.CheckLogin(); if (dt.Rows.Count == 0) { MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng. Vui lòng thử lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { MessageBox.Show("Đăng nhập thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); GlobalVariables.ID_TaiKhoanDangNhap = dt.Rows[0].Field <int>("ID_TaiKhoanDangNhap"); GlobalVariables.TenDangNhap = dt.Rows[0].Field <string>("TenDangNhap"); GlobalVariables.TenDayDu = dt.Rows[0].Field <string>("TenDayDu"); frmMain frm = new frmMain(); frm.StartPosition = FormStartPosition.CenterScreen; this.Hide(); frm.ShowDialog(); this.Show(); } }
private void btnEditAccount_Click(object sender, EventArgs e) { if (dtgvAccount.CurrentRow.Index == dtgvAccount.Rows.Count - 1) { return; } if (!IsValid()) { return; } clsTaiKhoanDangNhap cls = new clsTaiKhoanDangNhap(); cls.ID_TaiKhoanDangNhap = int.Parse(dtgvAccount.Rows[dtgvAccount.CurrentRow.Index].Cells[0].Value.ToString()); cls.SelectOne(); cls.TenDangNhap = txtUserName.Text.Trim(); cls.TenDayDu = txtTenDayDu.Text.Trim(); cls.TonTai = true; cls.Update(); MessageBox.Show("Cập nhật thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadAccount(); }
static void Main() { string[] SwitchKeys = { "/TenND", "/MatKhauND", "/TenMC", "/TenDangNhapMC", "/MatKhauMC", "/Internet" }; string[] CommandLines = System.Environment.CommandLine.Split(SwitchKeys, StringSplitOptions.None); if (CommandLines.Length < 7) { BaseMessages.ShowErrorMessage("Sai tham số khởi tạo chương trình"); return; } //Khởi tạo kết nối clsConnecionString.ConnectionString_System = string.Format("Data Source={0};Initial Catalog={1}; User ID={2}; Password={3}", CommandLines[3].Trim(), clsConnecionString.DBName_System, CommandLines[4].Trim(), CommandLines[5].Trim()); if (CommandLines[6].Trim() == "Y") { clsConnecionString.KetNoiInternet = true; } Garco10.SystemModule.HeThong.GlobalVariables.uTenDangNhap = CommandLines[1].Trim().ToLower(); clsConnecionString.CreateAllConnections(); clsTaiKhoanDangNhap cls = new clsTaiKhoanDangNhap(); cls.TenDangNhap = GlobalVariables.uTenDangNhap; DataTable dt = cls.Select_ThongTinTaiKhoan(); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; GlobalVariables.uID_TaiKhoanDangNhap = Int16.Parse(dr["ID_TaiKhoanDangNhap"].ToString()); GlobalVariables.uID_ChucVu = Int16.Parse("0" + dr["ID_ChucVu"]); GlobalVariables.uID_DonVi = Int16.Parse("0" + dr["ID_DonVi"]); GlobalVariables.uID_BoPhan = Int16.Parse("0" + dr["ID_BoPhan"]); GlobalVariables.uTen_ChucVu = dr["Ten_ChucVu"].ToString(); GlobalVariables.uTen_DonVi = dr["Ten_DonVi"].ToString(); GlobalVariables.uTen_BoPhan = dr["Ten_BoPhan"].ToString(); GlobalVariables.uTenDayDu = dr["TenDayDu"].ToString(); GlobalVariables.uLoai_TaiKhoan = (Enumerations.Loai_TaiKhoan) int.Parse("0" + dr["Loai_TaiKhoan"]); GlobalVariables.uQuyen_TatCaDonVi = (bool)dr["Quyen_TatCaDonVi"]; GlobalVariables.uTaiKhoan_DanhGia = (bool)dr["TaiKhoan_DanhGia"]; } clsPQ_TaiKhoan_DonVi oDV = new clsPQ_TaiKhoan_DonVi(); oDV.ID_TaiKhoanDangNhap = GlobalVariables.uID_TaiKhoanDangNhap; dt = oDV.Select_wTaiKhoan(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { GlobalVariables.uListQuyen_DonVi.Add(dr["ID_DonVi"].ToString()); } } M10_System.clsFTP_Server o = new M10_System.clsFTP_Server(); dt = o.SelectAll(); String sLoaiServer = "FTP_Server_Local"; if (Garco10.ConnectionProviders.clsConnecionString.KetNoiInternet) { sLoaiServer = "FTP_Server_Internet"; } foreach (DataRow dr in dt.Rows) { Garco10.SystemModule.HeThong.FTP_FilesManager.FTP_Server = dr[sLoaiServer].ToString(); Garco10.SystemModule.HeThong.FTP_FilesManager.FTP_UserName = dr["FTP_UserName"].ToString(); Garco10.SystemModule.HeThong.FTP_FilesManager.FTP_PassWord = dr["FTP_PassWord"].ToString(); Garco10.SystemModule.HeThong.FTP_FilesManager.FTP_Port = dr["FTP_Port"].ToString(); break; } //Lấy CultureInfo của Win trước khi gán thành vi-VN của phần mềm System.Globalization.CultureInfo cultureinfo = new System.Globalization.CultureInfo("vi-VN", false); cultureinfo.NumberFormat.CurrencyDecimalSeparator = "."; cultureinfo.NumberFormat.CurrencyGroupSeparator = ","; cultureinfo.NumberFormat.NumberDecimalSeparator = "."; cultureinfo.NumberFormat.NumberGroupSeparator = ","; Application.CurrentCulture = cultureinfo; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); DevExpress.Skins.SkinManager.EnableFormSkins(); DevExpress.UserSkins.BonusSkins.Register(); DevExpress.XtraGrid.Localization.GridLocalizer.Active = new VSCM.Base.Classes.clsVietHoaDevGrid(); Application.Run(new frmMain_QLCV()); }