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 btnDelete_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSessionCode.Text)) { MessageBox.Show("Please select session first!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } ActionResult deleteResult = formCtrl._deleteFormData(new SessionsSubFormModel() { SessionCode = Convert.ToInt32(txtSessionCode.Text.Trim()) }); if (deleteResult.State) { SessionsSubFormModel deleteObj = deleteResult.Data; MessageBox.Show("Session " + deleteObj.SessionCode + " 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); } } }