public void SaveData(Student_GroupEntity student) { using (IDbConnection con = new SQLiteConnection(AppData.ConnectionString)) { try { con.Execute("INSERT INTO Student_Main_Group (StudentId, AcademicYrSem, Programme, GroupNumber, GroupId) values (@StudentId, @AcademicYrSem, @Programme, @GroupNumber, @GroupId)", student); } catch (Exception e) { MessageBox.Show(e.Message); } } }
public void UpdateData(Student_GroupEntity student) { using (IDbConnection con = new SQLiteConnection(AppData.ConnectionString)) { try { con.Execute("UPDATE Student_Main_Group SET AcademicYrSem=@AcademicYrSem, Programme=@Programme, GroupNumber=@GroupNumber, GroupId=@GroupId WHERE StudentId=@StudentId", student); } catch (Exception e) { MessageBox.Show(e.Message); } } }
private void update_btn__Click(object sender, RoutedEventArgs e) { try { student = CreateStudentEntity(); _studentViewModel.UpdateStudentData(student); student_group_data_grid.ItemsSource = _studentViewModel.LoadStudentData(); ClearAll(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void student_group_data_grid_SelectionChanged(object sender, SelectionChangedEventArgs e) { updateMode = true; delete_btn_.IsEnabled = true; DataGrid dataGrid = (DataGrid)sender; student = dataGrid.SelectedItem as Student_GroupEntity; if (student != null) { academicYrSem_combobx.Text = student.AcademicYrSem; programme_combobx.Text = student.Programme; groupNumber_combobx.Text = student.GroupNumber.ToString(); groupId_txtbx.Text = student.GroupId; } }
private void grp_combobx_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox grpComboBx = sender as ComboBox; if (grpComboBx.SelectedItem != null) { if (tagName == "Lab") { Student_SubGroupEntity selectedGrp = grpComboBx.SelectedItem as Student_SubGroupEntity; grp_combobx_val = selectedGrp.SubGroupId; } else { Student_GroupEntity selectedGrp = grpComboBx.SelectedItem as Student_GroupEntity; grp_combobx_val = selectedGrp.GroupId; } CheckValidations(); } }
private Student_GroupEntity CreateStudentEntity() { int StudentId; if (updateMode) { StudentId = student.StudentId; } else { StudentId = students.Last().StudentId + 1; } string AcademicYrSem = academicYrSem_combobx.Text; string Programme = programme_combobx.Text; int GroupNumber = int.Parse(groupNumber_combobx.Text); string GroupId = groupId_txtbx.Text; student = new Student_GroupEntity(StudentId, AcademicYrSem, Programme, GroupNumber, GroupId); return(student); }
public void UpdateStudentData(Student_GroupEntity student) { _studentData.UpdateData(student); }
public void SaveStudentData(Student_GroupEntity student) { _studentData.SaveData(student); }