private void loginBtn_Click(object sender, EventArgs e) { if (loginNameTB.Text == "" || passwordTB.Text.Trim() == "") { MessageBox.Show("Vui lòng nhập đầy đủ thông tin để đăng nhập", "LỖI ĐĂNG NHẬP", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else { Program.mlogin = loginNameTB.Text; Program.password = passwordTB.Text; //MessageBox.Show(Program.mlogin + " " + Program.password + " " + Program.servername); // Lấy thông tin các ds phân mảnh về 1 lần, lưu lại trong biến bds_dspm để sử dụng cho các form khác Program.bds_dspm = this.BDS_View_DSPM; Program.mloginDN = Program.mlogin; Program.passwordDN = Program.password; if (Program.KetNoi() == false) { return; } else { //MessageBox.Show("Kết nối thành công"); // Ghi lại index của chi nhánh được chọn lúc đăng nhập Program.mChinhanh = comboBoxSVName.SelectedIndex; string command = "exec SP_DANGNHAP '" + Program.mlogin + "'"; Program.myReader = Program.ExecSqlDataReader(command); if (Program.myReader == null) { return; } if (Program.myReader.Read()) { Program.userID = Program.myReader.GetString(0); if (Convert.IsDBNull(Program.userID)) { MessageBox.Show("Login hiện tại không có quyền truy cập vào database", "Lỗi quyền truy cập", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Program.userName = Program.myReader.GetString(1); Program.userRole = Program.myReader.GetString(2); Program.myReader.Close(); Program.conn.Close(); } Program.mainForm.SignedInState(); //// Hiện thông tin người làm việc hiện tại trên thanh status bar của Main Form Program.mainForm.roleText.Caption = Program.userRole; Program.mainForm.hotenText.Caption = Program.userName; Program.mainForm.MaNVText.Caption = Program.userID; this.Hide(); //Program.mainForm.LoginState = CurrentSessionState.Activated; NhanVienForm staffForm = new NhanVienForm(); staffForm.MdiParent = Program.mainForm; staffForm.Show(); } } }
private void showNVFormBtn_ItemClick(object sender, ItemClickEventArgs e) { Form form = this.CheckExists(typeof(NhanVienForm)); if (form != null) { form.Focus(); } else { NhanVienForm newForm = new NhanVienForm(); newForm.MdiParent = this; newForm.Show(); } }