private void AddDeletedRowsToStudentGrid(StudentPromotionViewModel deletedRow) { List <StudentPromotionViewModel> _listStudent = new List <StudentPromotionViewModel>(); _listStudent = ConvertStudentGridToList(); _listStudent.Add(deletedRow); BindStudentGrid(_listStudent.OrderBy(x => x.StudentName).ToList()); }
private void GetStudentPromotionDetails() { studentPromotion = new StudentPromotion(); studentPromotionViewModel = studentPromotion.GetStudentPromotionDetails( Convert.ToInt16(ddlClass.SelectedValue), Convert.ToInt16(ddlSection.SelectedValue), Convert.ToInt32(ddlFromAcademicYear.SelectedValue)); BindStudentGrid(studentPromotionViewModel.ListStudent); BindStudentPromotionGrid(studentPromotionViewModel.ListStudentPromotion); }
public StudentPromotionViewModel GetStudentPromotionDetails(short ClassID, short SectionID, int Academic_Year) { this._studentPromotionViewModel = new StudentPromotionViewModel(); StudentPromotionViewModel studentPromotionViewModel; using (SqlService sqlService = new SqlService(ConnectionString.ConnectionStrings)) { sqlService.AddParameter("@ClassID", SqlDbType.SmallInt, ClassID); sqlService.AddParameter("@SectionID", SqlDbType.SmallInt, SectionID); sqlService.AddParameter("@From_Academic_Year", SqlDbType.Int, Academic_Year); using (SqlDataReader sqlDataReader = sqlService.ExecuteSPReader("dbo.USP_GetStudentPromotionDetails")) { this._studentPromotionViewModel.ListStudent = sqlDataReader.MapToList <StudentPromotionViewModel>(); sqlDataReader.NextResult(); this._studentPromotionViewModel.ListStudentPromotion = sqlDataReader.MapToList <StudentPromotionViewModel>(); sqlDataReader.NextResult(); studentPromotionViewModel = this._studentPromotionViewModel; } } return(studentPromotionViewModel); }
private void gridStudentPromotionHistory_CellContentClick(object sender, DataGridViewCellEventArgs e) { int rowIndex = e.RowIndex; if (e.ColumnIndex == 7) { try { StudentPromotionViewModel deletedRow = (StudentPromotionViewModel)gridStudentPromotionHistory.Rows[rowIndex].DataBoundItem; long?colPromotionID = Convert.ToInt64(gridStudentPromotionHistory.Rows[rowIndex].Cells["colPromotionID"].Value); if (colPromotionID == 0) { AddDeletedRowsToStudentGrid(deletedRow); gridStudentPromotionHistory.Rows.RemoveAt(rowIndex); } if (colPromotionID != 0) { DialogResult result = MessageBox.Show("Are you sure to delete this record from database?" + "\n\n Caution: \n \u2022 Deleting this record may affect monthly fee." + "\n \u2022 Deleting this record will revert the class of student in previous state.", "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { deletedRow.IsDeleted = true; List <StudentPromotionViewModel> listDeletedRow = new List <StudentPromotionViewModel>(); listDeletedRow.Add(deletedRow); DeletePromotionStudent(ConvertGridToXML(listDeletedRow)); gridStudentPromotionHistory.Rows.RemoveAt(rowIndex); AddDeletedRowsToStudentGrid(deletedRow); } } gridStudentPromotionHistory.ClearSelection(); } catch (Exception ex) { } finally { } } }