private void updateData(NewEmployee emp, int index) { if (string.IsNullOrEmpty(txtName.Text) || string.IsNullOrEmpty(txtNoCedula.Text)) { MessageBox.Show("Completar Información"); return; } else { int Item = Int32.Parse(dataGridView1[0, index].Value.ToString()); var updateEmployee = (from a in bd.Empleados select a).Where(m => m.Id_Empleado.Equals(Item)).SingleOrDefault(); //var updateEmployee2 = (from a in bd.Usuarios // select a).Where(m => m.Id_empleado.Equals(Item)).SingleOrDefault(); updateEmployee.Nombre = txtName.Text; updateEmployee.Apellido = txtLastName.Text; updateEmployee.Cédula = Int32.Parse(txtNoCedula.Text); updateEmployee.Estado = comboEstado.Text.ToString() == "Activo" ? 1 : 0; updateEmployee.Porciento_Comision = Int32.Parse(comision.Text); //updateEmployee2.Usuario1 = txtUser.Text; //updateEmployee2.Contrasenia = txtUser.Text; //updateEmployee2.Estado = comboEstado.Text.ToString() == "Activo" ? 1 : 0; bd.SaveChanges(); txtName.Clear(); txtLastName.Clear(); txtNoCedula.Clear(); comision.Clear(); comboEstado.SelectedIndex = -1; this.loadDataGrid(); } }
private void btn_eliminate_Click(object sender, EventArgs e) { NewEmployee delVehi = new NewEmployee(); deleteData(); Refresh(); MessageBox.Show("Borrado efectivo"); }
private void btn_ok_update_Click(object sender, EventArgs e) { //if (validaCedula(txtNoCedula.Text)) //{ NewEmployee empl = new NewEmployee(); updateData(empl, index); btn_ok_update.Visible = false; btn_ok.Visible = true; MessageBox.Show("Actualizado"); Refresh(); //} //else //{ // MessageBox.Show("Digite un documento válido"); //} }