private void btnDelete_Click(object sender, EventArgs e) { if (ID == 0) { MessageBox.Show("Please select Group Id first!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); initForm(); } else { ActionResult deleteResult = formCtrl._deleteFormData(new GroupIDModel() { Id = ID }); if (deleteResult.State) { GroupIDModel deleteObj = deleteResult.Data; MessageBox.Show("Group ID" + deleteObj.GroupID + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information); initForm(); } else { MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnSearch_Click(object sender, EventArgs e) { string searchTag = txtStudent.Text.Trim(); ActionResult lecturersResult = formCtrl._getFormData(typeof(GroupIDModel), "GroupID"); if (lecturersResult.State) { List <GroupIDModel> LecturerList = lecturersResult.Data; GroupIDModel lecturer = LecturerList.Find(lec => lec.GroupID == searchTag); if (lecturer == null) { MessageBox.Show("Group Id Does Not Exist.Please Enter Valid One.", "Info Message", MessageBoxButtons.OK, MessageBoxIcon.Question); } else if (string.IsNullOrEmpty(txtStudent.Text)) { MessageBox.Show("Plese Enter Group ID", "Info Message", MessageBoxButtons.OK, MessageBoxIcon.Question); } else { panel1.Visible = true; btnBack.Visible = true; lblYear.Text = lecturer.Year; lblSemester.Text = lecturer.Semester; lblPro.Text = lecturer.Programme; lblGroup.Text = lecturer.Group + ""; lblGrpID.Text = lecturer.GroupID; ActionResult groupResult = formCtrl._getFormData(typeof(SubGroupIDModel), "SubGroupID"); if (groupResult.State) { List <SubGroupIDModel> GroupsList = groupResult.Data; List <SubGroupIDModel> SlectedSubGroups = GroupsList.Where(grp => grp.Group == searchTag).ToList(); gridSubGroupDetails.DataSource = SlectedSubGroups; gridSubGroupDetails.Columns[1].HeaderCell.Value = "Year"; gridSubGroupDetails.Columns[2].HeaderCell.Value = "Semester"; gridSubGroupDetails.Columns[3].HeaderCell.Value = "Programme"; gridSubGroupDetails.Columns[4].HeaderCell.Value = "Group"; gridSubGroupDetails.Columns[5].HeaderCell.Value = "Sub Group"; gridSubGroupDetails.Columns[6].HeaderCell.Value = "Sub Group ID"; gridSubGroupDetails.Columns[0].Visible = false; gridSubGroupDetails.RowHeadersVisible = false; } } } }
private void btnUpdate_Click(object sender, EventArgs e) { if (comboYear.SelectedIndex == 0) { MessageBox.Show("Please Select Year!If Year List Empty Please Add Academic Year And Semster", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboYear.Focus(); } else if (comboSemester.SelectedIndex == 0) { MessageBox.Show("Please Select Year!If Year List Empty Please Add Academic Year And Semster", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboSemester.Focus(); } else if (comboProgramme.SelectedIndex == 0) { MessageBox.Show("Please Select Programme!If Year List Empty Please Add Programmes", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboProgramme.Focus(); } else if (comboGroup.SelectedIndex == 0) { MessageBox.Show("Please Select Group!If Year List Empty Please Add Groups", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboGroup.Focus(); } else { ActionResult updateResult = formCtrl._updateFormData(new GroupIDModel() { Id = ID, Year = comboYear.SelectedItem.ToString(), Semester = comboSemester.SelectedItem.ToString(), Programme = comboProgramme.SelectedItem.ToString(), Group = Int32.Parse(comboGroup.SelectedItem.ToString()), GroupID = comboYear.SelectedItem.ToString() + "." + comboSemester.SelectedItem.ToString() + "." + comboProgramme.SelectedItem.ToString() + "." + comboGroup.SelectedItem.ToString() }); if (updateResult.State) { GroupIDModel updateObj = updateResult.Data; MessageBox.Show("Group ID " + updateObj.GroupID + " Sucessfully Updated!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Information); initForm(); } else { MessageBox.Show(updateResult.Data, "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }