public override void EditObject() { DataGridViewRow dgvRow = base.getSelectedDataRow(); if (dgvRow != null) { int editId = (int)dgvRow.Cells["Id"].Value; Department dep = new Department() { Id = editId, Name = (string)dgvRow.Cells["Name"].Value }; DepartmentForm frm = new DepartmentForm(dep); DialogResult result = frm.ShowDialog(); AppFuncs.dialogCloseResult(frm.GetType().Name, result); if (result == DialogResult.OK) { bool dbResult = DBContext.UpdateEntity(frm.Department); if (dbResult) { this.LoadDataToGrid(); base.selectGridRowById(frm.Department.Id); } AppFuncs.saveToDBResult(dbResult); } base.EditObject(); } }
private void addToolStripMenuItem_Click(object sender, EventArgs e) { DepartmentForm form = new DepartmentForm(); form.ShowDialog(); refreshDataGrid(); }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { if (dataGridDepartments.SelectedRows.Count > 0) { DepartmentForm form = new DepartmentForm(list[dataGridDepartments.SelectedRows[0].Index]); form.ShowDialog(); refreshDataGrid(); } }
public override void CreateNewObject() { DepartmentForm frm = new DepartmentForm(); DialogResult result = frm.ShowDialog(); AppFuncs.dialogCloseResult(frm.GetType().Name, result); if ((result == DialogResult.OK) && (frm.Department != null)) { bool dbResult = DBContext.InsertEntity(frm.Department); if (dbResult) { this.LoadDataToGrid(); base.selectGridRowById(frm.Department.Id); } AppFuncs.saveToDBResult(dbResult); } frm.Dispose(); base.CreateNewObject(); }
private void dept_btn_Click(object sender, EventArgs e) { DepartmentForm dept = new DepartmentForm(); dept.ShowDialog(); }
private void button2_Click(object sender, EventArgs e) { var departmentForm = new DepartmentForm(); departmentForm.ShowDialog(); }
private void InitForm(string mode) { Form newForm; DataGridViewRow selectedRow = new DataGridViewRow(); if (mode.Equals("Edit")) { try { selectedRow = DgvGeneric.SelectedRows[0]; } catch (Exception ex) { Console.WriteLine(ex.Message); MessageBox.Show( text: "Debes seleccionar una fila", caption: "Error", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error); return; } } switch (activeGrid) { case 0: newForm = new EmployeeForm(mode, selectedRow); newForm.ShowDialog(); break; case 1: newForm = new DepartmentForm(mode, selectedRow); newForm.ShowDialog(); break; case 2: newForm = new ItemForm(mode, selectedRow); newForm.ShowDialog(); break; case 3: newForm = new BrandForm(mode, selectedRow); newForm.ShowDialog(); break; case 4: newForm = new UnitForm(mode, selectedRow); newForm.ShowDialog(); break; case 5: newForm = new ProviderForm(mode, selectedRow); newForm.ShowDialog(); break; case 6: newForm = new ItemRequestForm(mode, selectedRow); newForm.ShowDialog(); break; case 7: newForm = new PurchaseOrderForm(mode, selectedRow); newForm.ShowDialog(); break; case 8: newForm = new UserForm(mode, selectedRow); newForm.ShowDialog(); break; } }