private bool DepartmentIsExists(String classCode) { bool isExistInCurrentData = (FindCurrentDataByClassCode(classCode)).Length > 0; bool isExistOnDatabase = SqlRequestFunction.ClassIsExist(classCode); return(isExistInCurrentData || isExistOnDatabase); }
private DataTable SetUpListTeacher() { List <object[]> list = SqlRequestFunction.GetListTeacherHadNotAccount(); DataTable table = new DataTable(); DataColumn[] columns = new DataColumn[] { new DataColumn("MAGV"), new DataColumn("HOTEN") }; table.Columns.AddRange(columns); list.ForEach((item) => { DataRow row = table.NewRow(); row.ItemArray = item; table.Rows.Add(item); }); return(table); }
private void btn_Logout_ItemClick(object sender, ItemClickEventArgs e) { if (XtraMessageBox.Show("Bạn có chắc muốn đăng xuất không?" , "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { SqlRequestFunction.Logout(Program.mlogin); if (Program.conn.State == ConnectionState.Open) { Program.conn.Close(); } this.Dispose(); } catch (SqlException) { MessageBox.Show("Không thể đăng xuất. Vui lòng thử lại." , "Lỗi đăng xuất." , MessageBoxButtons.OK , MessageBoxIcon.Error); return; } } }
private void gcGVDK_Click(object sender, EventArgs e) { DateTime currentDateTime1 = DateTime.Now; this.txtNgayThi.MinDate = currentDateTime1.AddDays(-1000); DateTime currentDateTime = DateTime.Now; this.txtNgayThi.MaxDate = currentDateTime.AddDays(60); DataRowView current = (DataRowView)bs_GVDK.Current; String x = current["MAMH"].ToString(); String nameMH = SqlRequestFunction.GetTenMH(x); this.txtMH2.Text = nameMH; String y = current["MALOP"].ToString(); String nameLOP = SqlRequestFunction.GetTenLop(y); this.txtMaLop1.Text = nameLOP; String z = current["TRINHDO"].ToString(); String TrinhDo = GetLevelName(z); this.txtTrinhDo1.Text = TrinhDo; String t = current["NGAYTHI"].ToString(); this.txtNgayThi.Text = t; }
private List <ExamTest> GetListQuestion() { DataGridViewRow gridView = dgv_Results.SelectedRows[0]; return(SqlRequestFunction.GetQuestionForTestExam(gridView.Cells[1].Value.ToString() , gridView.Cells[3].Value.ToString() , int.Parse(gridView.Cells[7].Value.ToString()))); }
private bool ValidateCodeRegister(String classCode, String courseCode, int time) { if (SqlRequestFunction.RegisterIsExists(classCode, courseCode, time)) { MessageBox.Show("Lượt thi của Môn thi này cho lớp đó đã được tổ chức thi hai lần. Và không thể tổ chức thêm.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }
private bool StudentCodeIsExists(String studentCode) { try { return(SqlRequestFunction.StudentIsExist(studentCode)); } catch (Exception ex) { Debug.Fail(ex.Message); return(false); } }
private void btn_Login_GV_Click(object sender, EventArgs e) { bool checkVal = CheckValidateLogin(cmb_Brand_GV.SelectedIndex, txt_UserName.Text, txt_Password.Text); if (!checkVal) { return; } //Start login Program.mlogin = txt_UserName.Text; Program.password = txt_Password.Text; if (Program.KetNoi() == 0) { return; } Program.mChinhanh = ((DataRowView)cmb_Brand_GV.SelectedItem).Row.ItemArray[0].ToString(); Program.mloginDN = Program.mlogin; Program.passwordDN = Program.password; string strLenh = "EXEC SP_THONGTINDANGNHAPGV '" + Program.mloginDN + "'"; Program.myReader = SqlRequestFunction.ExecSqlDataReader(strLenh); if (Program.myReader == null) { return; } Program.myReader.Read(); Program.username = Program.myReader.GetString(0); // Lay user name if (Convert.IsDBNull(Program.username)) { MessageBox.Show("Giáo viên không tồn tại.", "", MessageBoxButtons.OK); return; } Program.mHoten = Program.myReader.GetString(1); Program.mGroup = Program.myReader.GetString(2); Program.myReader.Close(); Program.conn.Close(); MessageBox.Show("Nhân viên - Nhóm : " + Program.mHoten + " - " + Program.mGroup , "Đăng nhập thành công!" , MessageBoxButtons.OK, MessageBoxIcon.Information); //Application.Run(new Frm_TN_CSDLPT()); //this.Dispose(); Frm_TN_CSDLPT frm_Tn_csdlpt = new Frm_TN_CSDLPT(); frm_Tn_csdlpt.Show(); //this.Visible = false; }
private bool ValidateGetQuestion(String courseCode, String level, int quantity) { bool isEnough = SqlRequestFunction.IsEnoughQuestion(courseCode, level, quantity); if (!isEnough) { MessageBox.Show("Không đủ câu hỏi để tổ chức thi. Vui lòng kiểm tra lại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(isEnough); }
private void btn_Login_SV_Click(object sender, EventArgs e) { bool checkVal = CheckValidateLogin(cmb_Brand_SV.SelectedIndex, txt_StudentCode.Text); if (!checkVal) { return; } //Start login Program.studentCode = txt_StudentCode.Text; Program.mlogin = "******"; Program.password = "******"; if (Program.KetNoi() == 0) { return; } Program.mChinhanh = ((DataRowView)cmb_Brand_SV.SelectedItem).Row.ItemArray[0].ToString(); Program.mloginDN = Program.mlogin; Program.passwordDN = Program.password; string strLenh = "EXEC SP_THONGTINDANGNHAPSV '" + Program.studentCode + "'"; Program.myReader = SqlRequestFunction.ExecSqlDataReader(strLenh); if (Program.myReader == null) { return; } Program.myReader.Read(); Program.username = Program.myReader.GetString(0); // Lay name if (Convert.IsDBNull(Program.username)) { MessageBox.Show("Sinh viên không tồn tại.", "", MessageBoxButtons.OK); return; } Program.mHoten = Program.myReader.GetString(1); Program.mGroup = Program.myReader.GetString(2); Program.myReader.Close(); Program.conn.Close(); MessageBox.Show("Sinh Viên " + Program.mHoten , "Đăng nhập thành công!" , MessageBoxButtons.OK , MessageBoxIcon.Information); Frm_TN_CSDLPT frm_Tn_csdlpt = new Frm_TN_CSDLPT(); frm_Tn_csdlpt.Show(); }
private int GetIndexCodeForQuestion() { List <int> lCode = SqlRequestFunction.GetListQuestionCode(); int count = lCode.Count; for (int index = 0; index < count; index++) { int expectValue = index + 1; if (expectValue != lCode[index]) { return(expectValue); } } return(lCode[count - 1] + 1); }
private void dgv_GiaoVien_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { string headerText = dgv_Teachers.Columns[e.ColumnIndex].HeaderText; if (headerText.Equals("MAGV")) { string valCurrent = e.FormattedValue.ToString(); if (SqlRequestFunction.TeacherIsExists(valCurrent)) { //dgv_Teachers.Rows[e.RowIndex].ErrorText = "Had error"; //dgv_Teachers.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "Teacher Code Is Exists."; //dgv_Teachers.CurrentCell = dgv_Teachers.Rows[e.RowIndex].Cells[e.ColumnIndex]; //e.Cancel = true; } } }
public void set() { if (bs_GVDK.Count == 0) { btn_Add.Enabled = true; btn_Edit.Enabled = btn_Ghi.Enabled = btn_Delete.Enabled = btn_Reload.Enabled = btn_Thoat.Enabled = btn_Reset.Enabled = false; this.groupBox1.Enabled = false; } else { btn_Ghi.Enabled = false; this.btn_Reset.Enabled = true; this.groupBox1.Enabled = false; this.txtMH2.Visible = this.txtMaLop1.Visible = this.txtTrinhDo1.Visible = true; gcGVDK.Enabled = true; /*DataRowView current1 = (DataRowView)bs_GVDK.Current * * /*String maGV = current1["MAGV"].ToString(); * this.bs_GVDK.Position = FindPointionCurrentTeacher(maGV);*/ DataRowView current = (DataRowView)bs_GVDK.Current; String x = current["MAMH"].ToString(); this.txtMaMH.Text = x; String nameMH = SqlRequestFunction.GetTenMH(x); this.txtMH2.Text = nameMH; String y = current["MALOP"].ToString(); String nameLOP = SqlRequestFunction.GetTenLop(y); this.txtMaLop1.Text = nameLOP; String z = current["TRINHDO"].ToString(); String TrinhDo = GetLevelName(z); this.txtTrinhDo1.Text = TrinhDo; DateTime currentDateTime = DateTime.Now; this.txtNgayThi.MinDate = currentDateTime.AddDays(-1000); this.txtNgayThi.MaxDate = currentDateTime.AddDays(60); String t = current["NGAYTHI"].ToString(); this.txtNgayThi.Text = t; } }
private void InitDataForCmbBrand() { SqlRequestFunction.GetListBrand(); cmb_Brand_SV.DataSource = Program.bds_ListBrand; cmb_Brand_SV.DisplayMember = "TENCOSO"; cmb_Brand_SV.ValueMember = "TENSERVER"; cmb_Brand_GV.DataSource = Program.bds_ListBrand; cmb_Brand_GV.DisplayMember = "TENCOSO"; cmb_Brand_GV.ValueMember = "TENSERVER"; cmb_Brand_SV.SelectedIndex = -1; cmb_Brand_GV.SelectedIndex = -1; cmb_Brand_GV.Text = "Chọn cơ sở"; cmb_Brand_SV.Text = "Chọn cơ sở"; }
public void set() { btn_Write.Enabled = false; this.btn_Reset.Enabled = true; this.groupBox1.Enabled = false; this.txtMH1.Visible = this.txtTrinhDo1.Visible = true; DataRowView current = (DataRowView)bs_BoDe.Current; String x = current["MAMH"].ToString(); String nameMH = SqlRequestFunction.GetTenMH(x); this.txtMH1.Text = nameMH; String z = current["TRINHDO"].ToString(); String TrinhDo = GetLevelName(z); this.txtTrinhDo1.Text = TrinhDo; }
private void Dgv_Students_RowValidating(object sender, DataGridViewCellCancelEventArgs e) { try { bool isFirst = true; int index = 0; foreach (DataGridViewCell drv in dgv_Students.Rows[e.RowIndex].Cells) { if (String.IsNullOrEmpty(drv.Value.ToString())) { e.Cancel = true; dgv_Students.Rows[e.RowIndex].ErrorText = "Had error"; dgv_Students.Rows[e.RowIndex].Cells[index].ErrorText = "Dose not empty."; dgv_Students.CurrentCell = drv; } else { dgv_Students.Rows[e.RowIndex].Cells[index].ErrorText = null; } if (isFirst) { string valCurrent = drv.FormattedValue.ToString(); if (SqlRequestFunction.StudentIsExist(valCurrent)) { dgv_Students.Rows[e.RowIndex].ErrorText = "Had error"; dgv_Students.Rows[e.RowIndex].Cells[index].ErrorText = "Student Code Is Exists."; dgv_Students.CurrentCell = drv; } else { dgv_Students.Rows[e.RowIndex].Cells[index].ErrorText = null; } isFirst = false; } index++; } } catch { } }
private void SetUp() { if (Program.mGroup.Equals("SINHVIEN")) { StudentInfo studentInfo = SqlRequestFunction.GetStudentInfo(Program.studentCode); this.lbl_StudentCode.Text = Program.studentCode; this.lbl_StudentName.Text = studentInfo.FullName; this.lbl_ClassCode.Text = studentInfo.ClassCode; this.lbl_ClassName.Text = studentInfo.ClassName; } this.dtp_DateExam.MinDate = DateTime.Now; DateTime currentDateTime = DateTime.Now; this.dtp_DateExam.MaxDate = currentDateTime.AddDays(60); this.grb_StartExam.Visible = false; }
private void btn_Register_Click(object sender, EventArgs e) { if (ValidateEmpty()) { int code = SqlRequestFunction.CreateAccount(txt_LoginName.Text , cmb_Employees.SelectedValue.ToString() , txt_Password.Text , cmb_Role.SelectedValue.ToString()); if (code == 1) { MessageBox.Show("Đăng nhập thành công.", "", MessageBoxButtons.OK); } switch (code) { case 15014: //Role does not exists ErrorHandler.ShowError(lbl_Err_Summary, new string[] { "Ox6001" }); break; case 15025: //login name exists ErrorHandler.ShowError(lbl_Err_LoginName, new string[] { "Ox6002" }); break; case 15023: //user name exists ErrorHandler.ShowError(lbl_Err_Employee, new string[] { "Ox6003" }); break; case 1: MessageBox.Show( "Đã tạo tài khoản thành công cho giáo viên: " + cmb_Employees.Text + "Với tài khảo đăng nhập: " + txt_LoginName.Text , "Success" , MessageBoxButtons.OK , MessageBoxIcon.Information); break; } } }
public bool Add() { bool isEmpty = ValidateEmpty(); if (!isEmpty) { return(false); } if (SqlRequestFunction.CauHoiExist(txtCH.Text.Trim())) { MessageBox.Show("Mã môn học đã tồn tại.", "", MessageBoxButtons.OK); return(false); } else { object[] data = new object[] { Int32.Parse(txtCH.Text.ToString()), cmbMonHoc.SelectedValue.ToString(), cmbTrinhDo.SelectedValue.ToString(), txtNoiDung.Text, txtA.Text, txtB.Text, txtC.Text, txtD.Text, cmbDapAn.Text, cmbMaGV.Text }; this._callAction.FillData(Share.Action.RecoveryAdd, SetUpCurrentData(data)); return(true); } }
private void btn_Start_Click(object sender, EventArgs e) { if (dgv_Results.SelectedRows == null && dgv_Results.Rows.Count > 0) { dgv_Results.Rows[0].Selected = true; } DataGridViewRow gridView = dgv_Results.SelectedRows[0]; TestInfo testInfo = new TestInfo() { CourseCode = cmb_Course.SelectedValue.ToString(), CourseName = cmb_Course.Text, StudentCode = lbl_StudentCode.Text, StudentName = lbl_StudentName.Text, TimesStep = int.Parse(gridView.Cells[5].Value.ToString()), TotalTime = int.Parse(gridView.Cells[7].Value.ToString()), DateExam = Convert.ToDateTime(gridView.Cells[4].Value), ClassName = lbl_ClassName.Text, listQuestion = GetListQuestion() }; if (Program.mGroup.Equals("SINHVIEN")) { if (SqlRequestFunction.HasBeenExamined(testInfo.StudentCode, testInfo.CourseCode, testInfo.TimesStep)) { MessageBox.Show("Bạn đã thi môn này rồi. Vui lòng kiểm tra lại thông tin." , "Đã kiểm tra." , MessageBoxButtons.OK , MessageBoxIcon.Information); return; } } TestExam testExam = new TestExam(testInfo); testExam.ShowDialog(); }
private void btn_DeleteAccount_ItemClick(object sender, ItemClickEventArgs e) { if (XtraMessageBox.Show("Bạn có chắc muốn xóa tài khoản không?" , "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { ChangeCurrentLogToKillSession(); SqlRequestFunction.Logout(Program.mlogin); if (SqlRequestFunction.DeleteAccount(Program.mlogin, Program.username)) { if (Program.conn.State == ConnectionState.Open) { Program.conn.Close(); } MessageBox.Show("Xóa tài khoản thành công.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.Dispose(); } catch (SqlException) { MessageBox.Show("Không thể đăng xuất. Vui lòng thử lại." , "Lỗi đăng xuất." , MessageBoxButtons.OK , MessageBoxIcon.Error); return; } } }
private void SetUp() { if (Program.mGroup.Equals("SINHVIEN")) { StudentInfo studentInfo = SqlRequestFunction.GetStudentInfo(Program.username); this.lbl_StudentCode.Text = Program.username; this.lbl_StudentName.Text = studentInfo.FullName; this.lbl_ClassCode.Text = studentInfo.ClassCode; this.lbl_ClassName.Text = studentInfo.ClassName; } this.dtp_DateExam.MinDate = DateTime.Now; DateTime currentDateTime = DateTime.Now; this.dtp_DateExam.MaxDate = currentDateTime.AddDays(60); this.grb_StartExam.Visible = false; string x = this.cmb_Course.SelectedValue.ToString(); String nameMH = SqlRequestFunction.GetTenMH(x); this.txtMH.Text = nameMH; }
private void btn_View_Click(object sender, EventArgs e) { List <Transcript> transcipts = SqlRequestFunction.GetTranscript(cmb_Class.SelectedValue.ToString() , cmb_Course.SelectedValue.ToString(), (int)nud_TimesStep.Value); if (transcipts.Count == 0) { lbl_ClassName.Text = ""; lbl_CourseName.Text = ""; lbl_TimesStep.Text = ""; dgv_Transcript.DataSource = null; MessageBox.Show("Không tìm thấy bảng điểm với thông tin tương ứng. Vui lòng kiểm tra lại.", "Không tìm thấy!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } lbl_ClassName.Text = cmb_Class.Text; lbl_CourseName.Text = cmb_Course.Text; lbl_TimesStep.Text = nud_TimesStep.Value.ToString(); this.dgv_Transcript.DataSource = SetUpDataTable(transcipts); }
private bool ChangePassword(String loginName, String newPassword, String oldPassword) { return(SqlRequestFunction.ChangePassword(loginName, newPassword, oldPassword)); }
private void btn_Edit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { this.btn_Ghi.Tag = "EDIT"; this.btn_Thoat.Tag = "EDIT"; this.txtNgayThi.MinDate = DateTime.Now; DateTime currentDateTime = DateTime.Now; this.txtNgayThi.MaxDate = currentDateTime.AddDays(60); gcGVDK.Enabled = false; vitri = bs_GVDK.Position; DataRowView current = (DataRowView)bs_GVDK.Current; String maMH = current["MAMH"].ToString(); String maLOP = current["MALOP"].ToString(); int lan = Int16.Parse(current["LAN"].ToString()); String daThi = SqlRequestFunction.GetRegisterExamed(maMH, maLOP, lan); if (daThi.Equals("X")) { MessageBox.Show("Phần đăng kí này đã thi rồi!!!", "", MessageBoxButtons.OK); set(); return; } if (Program.mGroup.Equals("GIANGVIEN")) { magv1 = current["MAGV"].ToString(); string m = magv1.Trim(); if (m == magv) { this.btn_Add.Enabled = false; this.btn_Edit.Enabled = false; this.btn_Delete.Enabled = false; this.btn_Ghi.Enabled = true; this.btn_Reload.Enabled = false; this.btn_Reset.Enabled = false; this.groupBox1.Enabled = true; this.txtMaMH.Enabled = false; this.txtMaLop.Enabled = false; this.txtLan.Enabled = false; this.txtMaLop1.Enabled = false; this.txtMH2.Enabled = false; y = current["SOCAUTHI"].ToString(); z = current["TRINHDO"].ToString(); t = Int16.Parse(current["LAN"].ToString()); t_do = 0; } else { MessageBox.Show("Bạn không sửa phần đăng kí này!!!", "", MessageBoxButtons.OK); } } else { this.btn_Add.Enabled = false; this.btn_Edit.Enabled = false; this.btn_Delete.Enabled = false; this.btn_Ghi.Enabled = true; this.btn_Reload.Enabled = false; this.btn_Reset.Enabled = false; this.groupBox1.Enabled = true; this.txtMaMH.Enabled = false; this.txtMaLop.Enabled = false; this.txtLan.Enabled = false; this.txtMaLop1.Enabled = false; this.txtMH2.Enabled = false; y = current["SOCAUTHI"].ToString(); z = current["TRINHDO"].ToString(); t = Int16.Parse(current["LAN"].ToString()); t_do = 0; } }
static void Main(string[] args) { SqlRequestFunction.SysPublication(); Console.ReadLine(); }