public bool checkExistenceClass(Entities.LOP LOP) { DataTable classTable = getAllClass(); for (int i = 0; i < classTable.Rows.Count; i++) { if ((int)classTable.Rows[i]["MALOP"] != LOP.MaLop && classTable.Rows[i]["TENLOP"].Equals(LOP.TenLop) && classTable.Rows[i]["NAMHOC"].ToString().Equals(LOP.NamHoc)) { return(false); } } return(true); }
private void btn_Save_ClassInformation_Click(object sender, EventArgs e) { if (!ClassBLL.Instance.IsNotEmpty(navPage_ClassDetail_Edit))//If any control Empty => return; { return; } if (!BLL.ClassBLL.Instance.checkSchoolYear(txt_Year_ClassInformation_Edit.Text)) { MessageBox.Show("The School year is not valid!, Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txt_Year_ClassInformation_Edit.Text = txt_Year_ClassInformation.Text; this.txt_Year_ClassInformation_Edit.Focus(); return; } Entities.LOP lop = new Entities.LOP(int.Parse(classID), txt_ClassName_ClassInformation_Edit.Text, int.Parse(txt_ClassTotal_ClassInformation_Edit.Text), txt_Year_ClassInformation_Edit.Text, this.MaGV); //If don't have any change then return if (!txt_ClassName_ClassInformation_Edit.Text.Equals(txt_ClassName_ClassInformation.Text) || !txt_Year_ClassInformation_Edit.Text.Equals(txt_Year_ClassInformation.Text)) { //If Class already exists then return; if (!ClassBLL.Instance.checkExistenceClass(lop)) { MessageBox.Show("Class already exists!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); txt_ClassName_ClassInformation_Edit.Text = txt_ClassName_ClassInformation.Text; txt_Year_ClassInformation_Edit.Text = txt_Year_ClassInformation.Text; return; } } ClassBLL.Instance.updateClassNameAndClassYear(lop); txt_ClassName_ClassInformation.Text = lop.TenLop; txt_Year_ClassInformation.Text = lop.NamHoc; txt_ClassTotal_ClassInformation.Text = lop.SiSo.ToString(); btn_DeleteStudent_ClassInformation.Hide(); btn_Save_ClassInformation.Hide(); btn_Edit_ClassInformation.Show(); btn_AddStudentForClass_ClassInformation.Hide(); btn_AddSubjectsForClass_ClassInformation.Hide(); linkEdit.Hide(); grd_StudentList_ClassInformation_View.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect; grd_SubjectList_ClassInformation_View.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect; navFrame_ClassInformation.SelectedPage = navPage_ClassDetail; this.className = txt_ClassName_ClassInformation.Text; this.classSize = int.Parse(txt_ClassTotal_ClassInformation.Text); this.classYear = txt_Year_ClassInformation.Text; }
public bool saveAddClass(Panel addClassPanel, TextEdit txt_ClassTotal_AddClass, string className, string year) { StudentManagements.Entities.LOP newLOP = new Entities.LOP(className, 0, year); if (!ClassBLL.Instance.checkExistenceClass(newLOP)) { MessageBox.Show("Class already exists!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (ClassBLL.Instance.insertClass(newLOP)) { MessageBox.Show("Create Class successful!"); return(true); } else { MessageBox.Show("Class is not exists in Rules, Please check again!"); return(false); } }
public bool updateClassNameAndClassYear(Entities.LOP lop) { lop.NamHoc = formatSchoolYear(lop.NamHoc); return(ClassDAL.Instance.updateClassNameAndClassYear(lop)); }
public bool insertClass(Entities.LOP myClass) { return(ClassDAL.Instance.insertClass(myClass)); }