private void BindGrid() { DataTable dt = ClassEmployee.LoadData(); ss_dt = dt; datagrid.DataSource = dt; datagrid.DataBind(); }
private void ButtonAdd_Click(object sender, RoutedEventArgs e) { //Open a new window adding a new office staff ClassEmployee employee = new ClassEmployee(); WindowEmployeeDataEdition windowEmployeeDataEdition = new WindowEmployeeDataEdition(employee); windowEmployeeDataEdition.AddNew = true; bool update = (bool)windowEmployeeDataEdition.ShowDialog(); if (update) { UpdateEmployee(employee, windowEmployeeDataEdition.AddNew); LoadDataToDataGrid(); } }
private void UpdateEmployee(ClassEmployee employee, bool AddNew) { //Update doctor info in data base try { //If user choose edit if (!AddNew) { ClassSQLConnections.UpdateEmployee(employee); return; } //If user choose add ClassSQLConnections.AddNewEmployee(employee); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n Try again later", "Error"); } }
private void ButtonEdit_Click(object sender, RoutedEventArgs e) { //Check if user selected doctor if (DataGridListOfEmployee.SelectedIndex == -1) { MessageBox.Show("Select the row corresponding to the employee", "No row selected"); return; } //Open a new window editing existing doctor ClassEmployee employee = (ClassEmployee)DataGridListOfEmployee.SelectedItem; WindowEmployeeDataEdition windowEmployeeDataEdition = new WindowEmployeeDataEdition(employee); windowEmployeeDataEdition.AddNew = false; bool update = (bool)windowEmployeeDataEdition.ShowDialog(); if (update) { UpdateEmployee(employee, windowEmployeeDataEdition.AddNew); LoadDataToDataGrid(); } }