private void buttonSubmit_Click(object sender, EventArgs e) { DialogResult result1 = MessageBox.Show("Are you sure, you want to " + (isPassed?"Promote":"Demote") + " this student?", "Important Question", MessageBoxButtons.OKCancel); if (result1 == DialogResult.Cancel) { return; } int nextclassSecId = -1; if (comboBoxNextClassSection.Items.Count > 0) { nextclassSecId = ((ClassSectionViewModel)comboBoxNextClassSection.SelectedItem).ClassSectionId; } TempPromotionTable temp = new TempPromotionTable { Id = tempPromoteId, StudentId = studentInfo.StudentId, IsPassed = isPassed, NextClassId = isPassed ? (nextClassId == -1?(int?)null:nextClassId) : studentInfo.ClassId, NextClassSectionId = nextclassSecId == -1?(int?)null:nextclassSecId, CurrentYearId = _settingService.GetCurrentYear(), AverageMarks = _settingService.CalculateMarksForPromotion(studentInfo.StudentId), Remarks = textBoxRemarks.Text }; if (_settingService.UpdateTempPromoteData(temp)) { tempPromoteId = temp.Id; MessageBox.Show("Data Updated Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Data Update Failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }