private void SaveAllUpdatedList() { ViewCourse.CloseEditForm(); ViewCourse.UpdateCurrentRow(); List <string> updateQueries = new List <string>(); for (int i = 0; i < ViewCourse.RowCount; i++) { if (ViewCourse.GetRowCellValue(i, "IsEdited").ToString().Equals("1")) { long corID = Convert.ToInt64(ViewCourse.GetRowCellValue(i, "CourseID")); string courseName = ViewCourse.GetRowCellValue(i, "CourseName").ToString(); string abbrv = ViewCourse.GetRowCellValue(i, "Abbrv").ToString(); string query = "UPDATE attendance_db.tblcourse SET CourseName = '" + courseName + "' , Abbrv ='" + abbrv.ToUpper() + "' WHERE CourseID = " + corID + ""; updateQueries.Add(query); } else if (ViewCourse.GetRowCellValue(i, "IsEdited").ToString().Equals("2")) { if (InputValidation("")) { string courseName = ViewCourse.GetRowCellValue(i, "CourseName").ToString(); string abbrv = ViewCourse.GetRowCellValue(i, "Abbrv").ToString(); string query = "INSERT INTO attendance_db.tblcourse(CourseName , Abbrv , IsActive , UserID) VALUES('" + db.CorrectCasing(courseName) + "' , '" + abbrv.ToUpper() + "' , 'Active' , " + userid + ")"; updateQueries.Add(query); } } } if (updateQueries.Count > 0) { if (DialogResult.Yes == MessageBox.Show("Are you sure you want to save the following items. ", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { if (db.RunTransaction(updateQueries)) { MessageBox.Show("Selected records updated successfully. ", "Update Record", MessageBoxButtons.OK, MessageBoxIcon.Information); gridCourse.DataSource = null; PopulateCourse(); } } else { PopulateCourse(); } } DateTime dateValue = DateTime.Now; }