private void btnNewEmployee_Click(object sender, EventArgs e) { //instanciamos el formulario FrmNuevoProducto el cual se abrira como un modal FrmNewEmployee _newEmployeeForm = new FrmNewEmployee(); _newEmployeeForm.ShowDialog(); _newEmployeeForm.update = false; ShowEmployee(); }
private void tableEmployee_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (tableEmployee.Rows[e.RowIndex].Cells["delete"].Selected) { mensaje = new FrmError("ELIMINAR ESTE CLIENTE?"); DialogResult dialogResult = mensaje.ShowDialog(); if (dialogResult == DialogResult.OK) { int idEmployee = Convert.ToInt32(tableEmployee.Rows[e.RowIndex].Cells[2].Value.ToString()); objBusine.DeleteEmployee(idEmployee); this.mensaje = new FrmSuccess("REGISTRO ELIMINADO! "); this.mensaje.ShowDialog(); ShowEmployee(); } } else if (tableEmployee.Rows[e.RowIndex].Cells["edit"].Selected) { FrmNewEmployee frmNewEmployee = new FrmNewEmployee(); //actualizamos nuestra valiable actualizar para poder editar frmNewEmployee.update = true; //pasamos los valores a nuestro formulario nuevoEmpleado frmNewEmployee.txtIdEmployee.Text = tableEmployee.Rows[e.RowIndex].Cells[2].Value.ToString(); frmNewEmployee.txtNameEmployee.Text = tableEmployee.Rows[e.RowIndex].Cells[6].Value.ToString(); frmNewEmployee.txtLastName.Text = tableEmployee.Rows[e.RowIndex].Cells[8].Value.ToString(); frmNewEmployee.txtMothersLastName.Text = tableEmployee.Rows[e.RowIndex].Cells[7].Value.ToString(); frmNewEmployee.txtDni.Text = tableEmployee.Rows[e.RowIndex].Cells[3].Value.ToString(); frmNewEmployee.txtPhone.Text = tableEmployee.Rows[e.RowIndex].Cells[4].Value.ToString(); frmNewEmployee.txtEmail.Text = tableEmployee.Rows[e.RowIndex].Cells[9].Value.ToString(); frmNewEmployee.cmbCivilStatus.Text = tableEmployee.Rows[e.RowIndex].Cells[10].Value.ToString(); frmNewEmployee.cmbSex.Text = tableEmployee.Rows[e.RowIndex].Cells[11].Value.ToString(); frmNewEmployee.txtAddress.Text = tableEmployee.Rows[e.RowIndex].Cells[12].Value.ToString(); frmNewEmployee.dtDateAdmission.Text = tableEmployee.Rows[e.RowIndex].Cells[13].Value.ToString(); frmNewEmployee.cmbDepartment.Text = tableEmployee.Rows[e.RowIndex].Cells[14].Value.ToString(); frmNewEmployee.ShowDialog(); ShowEmployee(); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Valla a ocurrido un error"); } }