private void ViewStudents_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { ViewStudents.CancelUpdateCurrentRow(); } }
private void viewStudentsInformationToolStripMenuItem_Click(object sender, EventArgs e) { panel1.Controls.Clear(); ViewStudents add = new ViewStudents(); panel1.Controls.Add(add); }
// GET: /Account/ResetPasswordConfirmation public ActionResult Delete(string id) { var student = db.Users.Find(id); ViewStudents model = new ViewStudents { Id = student.Id, Email = student.Email, FullName = student.FullName }; return(PartialView(model)); }
// GET: Course/Edit/5 public ActionResult Edit(string id) { var query = db.Users.Find(id); ViewStudents model = new ViewStudents { FullName = query.FullName, Email = query.Email, Id = query.Id }; return(PartialView(model)); }
private void SaveAllUpdatedList() { ViewStudents.CloseEditForm(); ViewStudents.UpdateCurrentRow(); List <string> updateQueries = new List <string>(); for (int i = 0; i < ViewStudents.RowCount; i++) { if (ViewStudents.GetRowCellValue(i, "IsEdited").ToString().Equals("1")) { long courseID = Convert.ToInt64(ViewStudents.GetRowCellValue(i, "CourseID")); string section1 = db.GetValue("SELECT * FROM tblcourse WHERE CourseID = " + courseID + " ", "Abbrv"); long StudID = Convert.ToInt64(ViewStudents.GetRowCellValue(i, "StudentID")); string StudNum = ViewStudents.GetRowCellValue(i, "StudNum").ToString(); string fname = ViewStudents.GetRowCellValue(i, "FName").ToString(); string lname = ViewStudents.GetRowCellValue(i, "LName").ToString(); string section = ViewStudents.GetRowCellValue(i, "Section").ToString(); string status = ViewStudents.GetRowCellValue(i, "Status").ToString(); string query = "UPDATE attendance_db.tblstudent SET StudNum = " + StudNum + " , FName = '" + db.CorrectCasing(fname) + "' ,LName = '" + db.CorrectCasing(lname) + "', " + "Section = '" + section.ToUpper() + "' , Status = 'Active' , CourseID = " + courseID + " WHERE StudentID = " + StudID + ";"; updateQueries.Add(query); } else if (ViewStudents.GetRowCellValue(i, "IsEdited").ToString().Equals("2")) { if (InputValidation("")) { string StudNum = ViewStudents.GetRowCellValue(i, "StudNum").ToString(); string fName = ViewStudents.GetRowCellValue(i, "FName").ToString(); string lName = ViewStudents.GetRowCellValue(i, "LName").ToString(); string section = ViewStudents.GetRowCellValue(i, "Section").ToString(); long courseID = Convert.ToInt64(ViewStudents.GetRowCellValue(i, "CourseID")); string section1 = db.GetValue("SELECT * FROM tblcourse WHERE CourseID = " + courseID + " ", "Abbrv"); string query = "INSERT INTO `attendance_db`.`tblstudent` (`StudNum`, `FName`, `LName`, `Section`, `Status`, `CourseID` , UserID) " + "VALUES ('" + StudNum + "', '" + db.CorrectCasing(fName) + "', '" + db.CorrectCasing(lName) + "', '" + section1 + section.ToUpper() + "', 'Active', " + courseID + " , " + 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); grdStudents.DataSource = null; PopulateStudent(); } } else { PopulateStudent(); } } DateTime dateValue = DateTime.Now; }
private void ViewStudents_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (!e.Column.FieldName.ToString().Equals("IsEdited")) { if (ViewStudents.GetRowCellValue(e.RowHandle, "StudentID").ToString().Equals("")) { ViewStudents.SetRowCellValue(e.RowHandle, "IsEdited", "2"); } else { ViewStudents.SetRowCellValue(e.RowHandle, "IsEdited", "1"); } } }
private void btnDelete_Click(object sender, EventArgs e) { string id = ViewStudents.GetRowCellValue(selectedIndex, "StudentID").ToString(); if (DialogResult.Yes == MessageBox.Show("Are you sure, you want to delete the student? " + "\n" + "Note: All data of this student will also deleted.", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { string delete = "DELETE FROM tblstudent WHERE StudentID = " + id + " ;"; int result = db.RunUpdateQuery(delete); if (result > 0) { MessageBox.Show("Students was deleted."); PopulateStudent(); } } }
public ActionResult Edit([Bind(Include = "Id,FullName,Email")] ViewStudents model) { if (ModelState.IsValid) { var store = new UserStore <ApplicationUser>(db); var manager = new ApplicationUserManager(store); var user = manager.FindById(model.Id); user.FullName = model.FullName; user.Email = model.Email; user.UserName = model.Email; manager.Update(user); //db.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(PartialView(model)); }
public bool InputValidation(string cons) { for (int i = 0; i < ViewStudents.RowCount; i++) { if (ViewStudents.GetRowCellValue(i, "IsEdited").ToString().Equals("2")) { string studNum1 = ViewStudents.GetRowCellValue(i, "StudNum").ToString(); string fname = ViewStudents.GetRowCellValue(i, "FName").ToString(); string query = "SELECT * FROM tblstudent WHERE StudNum = " + studNum1 + " AND UserID = " + userid + "" + cons; DataTable dt = db.SelectQuery(query); if (dt.Rows.Count != 0) { MessageBox.Show("Student already exist", "Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Warning); PopulateStudent(); return(false); } } } return(true); }
private void ViewStudents_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e) { try { if (ViewStudents.GetRowCellValue(e.RowHandle, "IsEdited") == null) { return; } else if (ViewStudents.GetRowCellValue(e.RowHandle, "IsEdited").ToString().Equals("1")) { e.Appearance.BackColor = Color.DeepSkyBlue; } else if (ViewStudents.GetRowCellValue(e.RowHandle, "IsEdited").ToString().Equals("2")) { e.Appearance.BackColor = Color.Beige; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }