private void AddStudentButtonClick(object sender, EventArgs e) { this.SaveStudentButton.DialogResult = DialogResult.None; this.CancelButton.DialogResult = DialogResult.None; this.DialogResult = DialogResult.None; if (this.newStudent.ValidateEntries()) { Debug.WriteLine(this.newStudent.ToString()); bool result = DBRepo.AddStudent(this.newStudent); if (!result) { MessageBox.Show("Student already exists"); } else { this.SaveStudentButton.DialogResult = DialogResult.OK; this.CancelButton.DialogResult = DialogResult.OK; this.DialogResult = DialogResult.OK; MessageBox.Show("User added successfully"); } } else { MessageBox.Show("Please fill all the values"); } }
private void button2_Click(object sender, EventArgs e) { this.UpdateDetailsButton.DialogResult = DialogResult.None; this.CancelButton.DialogResult = DialogResult.None; this.DialogResult = DialogResult.None; if (this.student.ValidateEntries()) { bool result = DBRepo.UpdateStudentData(stud: this.student); if (!result) { MessageBox.Show("Failed to update student"); } else { this.UpdateDetailsButton.DialogResult = DialogResult.OK; this.CancelButton.DialogResult = DialogResult.OK; this.DialogResult = DialogResult.OK; MessageBox.Show("User updated successfully"); } } else { MessageBox.Show("Please fill all the values"); } }
private void DeleteButton_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show(text: "Are you sure you want to delete student?", caption: "This will not be reversible", buttons: MessageBoxButtons.OKCancel); this.UpdateDetailsButton.DialogResult = DialogResult.None; this.CancelButton.DialogResult = DialogResult.None; this.DialogResult = DialogResult.None; if (result == DialogResult.OK) { bool delresult = DBRepo.DeleteStudent(stud: this.student); if (!delresult) { MessageBox.Show("Failed to delete student"); } else { MessageBox.Show("Deleted successfully!"); this.UpdateDetailsButton.DialogResult = DialogResult.OK; this.CancelButton.DialogResult = DialogResult.OK; this.DialogResult = DialogResult.OK; } } else { } }
public UpdateDeleteForm(String studentId) { Student fetchedStudent = DBRepo.FetchStudentById(studentId); Debug.WriteLine(fetchedStudent.ToString()); this.student = fetchedStudent; InitializeComponent(); studentIDBox.Text = fetchedStudent.StudentId; firstNameBox.Text = fetchedStudent.FirstName; lastNameBox.Text = fetchedStudent.LastName; branchBox.SelectedItem = fetchedStudent.Branch; campusBox.SelectedItem = fetchedStudent.Campus; yearBox.SelectedItem = fetchedStudent.Year; cgpaBox.Text = fetchedStudent.Cgpa.ToString(); yearBox.Text = fetchedStudent.Year.ToString(); }
public void FetchAndUpdateStudentsList() { // use DBRepo to get the list of students from the db studentsList = DBRepo.FetchAllStudents(); //clear existing students and add them to the list studentsListView.Items.Clear(); foreach (Student s in studentsList) { Console.WriteLine(s.ToString()); string[] items = new string[7]; items[0] = s.StudentId; items[1] = s.FirstName; items[2] = s.LastName; items[3] = s.Year.ToString(); items[4] = s.Branch; items[5] = s.Cgpa.ToString(); items[6] = s.Campus; // append the students to the listView studentsListView.Items.Add(new ListViewItem(items)); } // Event handler to get more details of students }