private void EditEmployee(Employee e) { FirstNameInput.Value = ((e != null ? e.firstName : null) ?? ""); LastNameInput.Value = ((e != null ? e.lastName : null) ?? ""); TitleInput.Value = ((e != null ? e.title : null) ?? ""); EmailInput.Value = ((e != null ? e.email : null) ?? ""); EditEmployeeDialog.Open(); }
private void button5_Click(object sender, EventArgs e) { var editDialog = new EditEmployeeDialog(employees, (dataGridView2.CurrentRow.DataBoundItem as DataRowView).Row); editDialog.ShowDialog(); commandBuilder = new SqlCommandBuilder(adapter2); adapter2.UpdateCommand = commandBuilder.GetUpdateCommand(); label2.Text = commandBuilder.GetUpdateCommand().CommandText; adapter2.Update(shopDB, "Employees"); employees.Clear(); adapter2.Fill(shopDB); }
private void EditEmployeeOKButton_Click(jQueryEvent evt) { string firstName = FirstNameInput.Value.Trim(), lastName = LastNameInput.Value.Trim(), title = TitleInput.Value.Trim(), email = EmailInput.Value.Trim(); if (firstName == "") { Window.Alert("You must enter a first name."); FirstNameInput.Focus(); return; } if (lastName == "") { Window.Alert("You must enter a last name."); LastNameInput.Focus(); return; } if (title == "") { title = null; } if (email == "") { Window.Alert("You must enter an email address."); EmailInput.Focus(); return; } bool add = (EmployeesGrid.GetData(EmployeesGrid.SelectedRowIndex) == null); Employee emp = new Employee(firstName, lastName, title, email); EmployeesGrid.UpdateItem(EmployeesGrid.SelectedRowIndex, GetGridTexts(emp), emp); if (add) { EmployeesGrid.AddItem(GetGridTexts(null), null); } Tree.SetTreeNodeData(DepartmentsTree.SelectedNode, GetCurrentEmployees()); EditEmployeeDialog.Close(); }
partial void Attached() { jQuery.FromElement(EditEmployeeOKButton).Click(EditEmployeeOKButton_Click); jQuery.FromElement(EditEmployeeCancelButton).Click(delegate { EditEmployeeDialog.Close(); }); DepartmentsTree_SelectionChanged(DepartmentsTree, EventArgs.Empty); }