private void btnSearch_Click(object sender, EventArgs e) { string searchTag = txtSubject.Text.Trim(); ActionResult SubjectResult = formCtrl._getFormData(typeof(SubjectsFormModel), "Subjects"); if (SubjectResult.State) { List <SubjectsFormModel> SubList = SubjectResult.Data; SubjectsFormModel subject = SubList.Find(sub => sub.SubjectCode == searchTag); if (subject == null) { MessageBox.Show("Subject Code Does Not Exist.Please Enter Valid One.", "Info Message", MessageBoxButtons.OK, MessageBoxIcon.Question); } else if (string.IsNullOrEmpty(txtSubject.Text)) { MessageBox.Show("Plese Enter Subject Code", "Info Message", MessageBoxButtons.OK, MessageBoxIcon.Question); } else { panel1.Visible = true; btnBack.Visible = true; LSub.Text = subject.SubjectName; LYear.Text = subject.Year; LSem.Text = subject.Semester; LL.Text = subject.LectureHours + ""; LLab.Text = subject.LabHours + ""; LTute.Text = subject.TuteHours + ""; LEH.Text = subject.EvaluationHours + ""; } } }
private void btnUpdate_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSubjectCode.Text)) { MessageBox.Show("Please select subject first!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ActionResult updateResult = formCtrl._updateFormData(new SubjectsFormModel() { SubjectCode = txtSubjectCode.Text.Trim(), SubjectName = txtSubjectName.Text.Trim(), Year = comboYear.SelectedItem.ToString(), Semester = comboSem.SelectedItem.ToString(), LectureHours = string.IsNullOrEmpty(txtLecHrs.Text) ? 0 : Convert.ToInt32(txtLecHrs.Text), TuteHours = string.IsNullOrEmpty(txtTuteHrs.Text) ? 0 : Convert.ToInt32(txtTuteHrs.Text), LabHours = string.IsNullOrEmpty(txtLabHrs.Text) ? 0 : Convert.ToInt32(txtLabHrs.Text), EvaluationHours = string.IsNullOrEmpty(txtEvaHrs.Text) ? 0 : Convert.ToInt32(txtEvaHrs.Text) }); if (updateResult.State) { SubjectsFormModel updateObj = updateResult.Data; MessageBox.Show("Subject Code - " + updateObj.SubjectCode + " Sucessfully Updated!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Information); initForm(); } else { MessageBox.Show(updateResult.Data, "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnUpdate_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSessionCode.Text)) { MessageBox.Show("Please select session first!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string Lecturers = "", LecturersList = ""; foreach (var lecturer in chkListLecturers.CheckedItems) { if (Lecturers != "" && LecturersList != "") { Lecturers += ","; LecturersList += ","; } LecturersFormModel lecObj = lecturerList.Where(lec => lec.EmployeeName == lecturer.ToString()).FirstOrDefault(); Lecturers += lecObj.EmployeeId; LecturersList += lecObj.EmployeeName; } SubjectsFormModel subModel = subList.Where(sub => sub.SubjectName == comboSubjects.SelectedItem.ToString().Trim()).FirstOrDefault(); ActionResult updateResult = formCtrl._updateFormData(new SessionsSubFormModel() { SessionCode = Convert.ToInt32(txtSessionCode.Text), Lecturers = Lecturers, LecturersList = LecturersList, Tags = comboTags.SelectedItem.ToString(), GroupId = comboGroup.SelectedItem.ToString(), SubjectCode = subModel.SubjectCode, SubjectName = subModel.SubjectName, NoOfStudent = Convert.ToInt32(txtNoOfStudents.Text), Duration = Convert.ToInt32(txtDurations.Text) }); if (updateResult.State) { SessionsSubFormModel updateObj = updateResult.Data; MessageBox.Show("Session " + updateObj.SessionCode + " Sucessfully Updated!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Information); initForm(); } else { MessageBox.Show(updateResult.Data, "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnInsert_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSubjectName.Text)) { MessageBox.Show("Please Enter Subject Name!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtSubjectName.Focus(); } else if (comboYear.SelectedIndex == 0) { MessageBox.Show("Please Select Year!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboYear.Focus(); } else if (comboSem.SelectedIndex == 0) { MessageBox.Show("Please Select Semester!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboSem.Focus(); } else { ActionResult saveResult = formCtrl._saveFormData(new SubjectsFormModel() { SubjectName = txtSubjectName.Text.Trim(), Year = comboYear.SelectedItem.ToString(), Semester = comboSem.SelectedItem.ToString(), LectureHours = string.IsNullOrEmpty(txtLecHrs.Text) ? 0 : Convert.ToInt32(txtLecHrs.Text), TuteHours = string.IsNullOrEmpty(txtTuteHrs.Text) ? 0 : Convert.ToInt32(txtTuteHrs.Text), LabHours = string.IsNullOrEmpty(txtLabHrs.Text) ? 0 : Convert.ToInt32(txtLabHrs.Text), EvaluationHours = string.IsNullOrEmpty(txtEvaHrs.Text) ? 0 : Convert.ToInt32(txtEvaHrs.Text) }, true); if (saveResult.State) { SubjectsFormModel saveObj = saveResult.Data; MessageBox.Show("Subject Code - " + saveObj.SubjectCode + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information); initForm(); } else { MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnDelete_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSubjectCode.Text)) { MessageBox.Show("Please select subject first!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ActionResult deleteResult = formCtrl._deleteFormData(new SubjectsFormModel() { SubjectCode = txtSubjectCode.Text.Trim() }); if (deleteResult.State) { SubjectsFormModel deleteObj = deleteResult.Data; MessageBox.Show("Subject Code - " + deleteObj.SubjectCode + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); initForm(); } else { MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnInsert_Click(object sender, EventArgs e) { if (chkListLecturers.CheckedItems.Count == 0) { MessageBox.Show("Please Select The Lecturers!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (comboTags.SelectedIndex == 0) { MessageBox.Show("Please Select Tag!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboTags.Focus(); } else if (comboGroup.SelectedIndex == 0) { MessageBox.Show("Please Select Group Or Subgroup!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboGroup.Focus(); } else if (comboSubjects.SelectedIndex == 0) { MessageBox.Show("Please Select Subject!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboSubjects.Focus(); } else if (string.IsNullOrEmpty(txtNoOfStudents.Text)) { MessageBox.Show("Please Enter No Of Students!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtNoOfStudents.Focus(); } else if (string.IsNullOrEmpty(txtDurations.Text)) { MessageBox.Show("Please Enter Duration!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtDurations.Focus(); } else { string Lecturers = "", LecturersList = ""; foreach (var lecturer in chkListLecturers.CheckedItems) { if (Lecturers != "" && LecturersList != "") { Lecturers += ","; LecturersList += ","; } LecturersFormModel lecObj = lecturerList.Where(lec => lec.EmployeeName == lecturer.ToString()).FirstOrDefault(); Lecturers += lecObj.EmployeeId; LecturersList += lecObj.EmployeeName; } SubjectsFormModel subModel = subList.Where(sub => sub.SubjectName == comboSubjects.SelectedItem.ToString().Trim()).FirstOrDefault(); ActionResult saveResult = formCtrl._saveFormData(new SessionsSubFormModel() { Lecturers = Lecturers, LecturersList = LecturersList, Tags = comboTags.SelectedItem.ToString(), GroupId = comboGroup.SelectedItem.ToString(), SubjectCode = subModel.SubjectCode, SubjectName = subModel.SubjectName, NoOfStudent = Convert.ToInt32(txtNoOfStudents.Text), Duration = Convert.ToInt32(txtDurations.Text) }); if (saveResult.State) { SessionsSubFormModel saveObj = saveResult.Data; MessageBox.Show("Session " + saveObj.SessionCode + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information); initForm(); } else { MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }