protected void btnActualizar_Click(object sender, EventArgs e) { string strDocumento, strNombre, strPrimerApellido, strSegundoApellido; string strDireccion, strTelefono; strDocumento = txtDocumento.Text; strNombre = txtNombre.Text; strPrimerApellido = txtPrimerApellido.Text; strSegundoApellido = txtSegundoApellido.Text; strDireccion = txtDireccion.Text; strTelefono = txtTelefono.Text; clsEmpleado oEmpleado = new clsEmpleado(); oEmpleado.Documento = strDocumento; oEmpleado.Nombre = strNombre; oEmpleado.PrimerApellido = strPrimerApellido; oEmpleado.SegundoApellido = strSegundoApellido; oEmpleado.Direccion = strDireccion; oEmpleado.Telefono = strTelefono; if (oEmpleado.Actualizar()) { lblError.Text = "Actualizó"; } else { lblError.Text = oEmpleado.Error; } oEmpleado = null; }
private void btnRegistrar_Click(object sender, EventArgs e) { string mensaje = ""; try { errorProvider1.Clear(); if (Utilidades.ValidarForm(this, errorProvider1) == false) { return; } if (Program.Evento == 0) { int anos = DateTime.Now.Date.Year; anos = anos - dtpFechanac.Value.Year; if (anos >= 18) { P.Nombre = txtNombre.Text; P.Apellidos = txtApellidos.Text; P.FechaNac = dtpFechanac.Value; P.Idnacionalidad = Convert.ToInt32(cbNacionalidad.SelectedValue); P.Idgenero = cbGenero.SelectedValue.ToString(); P.Idestadoc = Convert.ToInt32(cbEstadoCivil.SelectedValue); P.Sueldo = Convert.ToDouble(txtSueldo.Text); P.Idcargo = Convert.ToInt32(cbCargo.SelectedValue); P.Iddpto = Convert.ToInt32(cbDpto.SelectedValue); P.Idhorario = Convert.ToInt32(cbHorario.SelectedValue); P.Idseguro = Convert.ToInt32(cbHorario.SelectedValue); P.Idsucursal = Program.Idsucursal; mensaje = P.Registrar(); if (mensaje == "1") { for (int x = 0; x < dtgIdentificacion.Rows.Count; x++) { P.Identificacion = dtgIdentificacion.Rows[x].Cells[1].Value.ToString(); P.Idtipoi = Convert.ToInt32(dtgIdentificacion.Rows[x].Cells[2].Value); mensaje = P.RegistrarI(); } for (int x = 0; x < dtgContacto.Rows.Count; x++) { P.Contacto = dtgContacto.Rows[x].Cells[1].Value.ToString(); P.Idtipoc = Convert.ToInt32(dtgContacto.Rows[x].Cells[2].Value); mensaje = P.RegistrarC(); } for (int x = 0; x < dtgDireccion.Rows.Count; x++) { P.Direccion = dtgDireccion.Rows[x].Cells[1].Value.ToString(); P.Idbarrio = Convert.ToInt32(dtgDireccion.Rows[x].Cells[2].Value); P.Idciudad = Convert.ToInt32(dtgDireccion.Rows[x].Cells[3].Value); P.Idregion = Convert.ToInt32(dtgDireccion.Rows[x].Cells[4].Value); mensaje = P.RegistrarD(); } if (mensaje == "1") { MessageBoxEx.Show("Registrado con éxito", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(); } } } else { MessageBoxEx.Show("Empleado debe ser mayor de 18 años", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (Program.Evento == 1) { int anos = DateTime.Now.Date.Year; anos = anos - dtpFechanac.Value.Year; if (anos >= 18) { P.Idempleado = Program.Codigo; P.Nombre = txtNombre.Text; P.Apellidos = txtApellidos.Text; P.FechaNac = dtpFechanac.Value; P.Idnacionalidad = Convert.ToInt32(cbNacionalidad.SelectedValue); P.Idgenero = cbGenero.SelectedValue.ToString(); P.Idestadoc = Convert.ToInt32(cbEstadoCivil.SelectedValue); P.Sueldo = Convert.ToDouble(txtSueldo.Text); P.Idcargo = Convert.ToInt32(cbCargo.SelectedValue); P.Iddpto = Convert.ToInt32(cbDpto.SelectedValue); P.Idhorario = Convert.ToInt32(cbHorario.SelectedValue); P.Idseguro = Convert.ToInt32(cbHorario.SelectedValue); P.Idsucursal = Program.Idsucursal; mensaje = P.Actualizar(); if (mensaje == "1") { for (int x = 0; x < dtgIdentificacion.Rows.Count; x++) { P.Ididentificacion = Convert.ToInt32(dtgIdentificacion.Rows[x].Cells[0].Value); P.Identificacion = dtgIdentificacion.Rows[x].Cells[1].Value.ToString(); P.Idtipoi = Convert.ToInt32(dtgIdentificacion.Rows[x].Cells[2].Value); mensaje = P.ActualizarI(); } for (int x = 0; x < dtgContacto.Rows.Count; x++) { P.Idcontacto = Convert.ToInt32(dtgContacto.Rows[x].Cells[0].Value); P.Contacto = dtgContacto.Rows[x].Cells[1].Value.ToString(); P.Idtipoc = Convert.ToInt32(dtgContacto.Rows[x].Cells[2].Value); mensaje = P.ActualizarC(); } for (int x = 0; x < dtgDireccion.Rows.Count; x++) { P.Iddireccion = Convert.ToInt32(dtgDireccion.Rows[x].Cells[0].Value); P.Direccion = dtgDireccion.Rows[x].Cells[1].Value.ToString(); P.Idbarrio = Convert.ToInt32(dtgDireccion.Rows[x].Cells[2].Value); P.Idciudad = Convert.ToInt32(dtgDireccion.Rows[x].Cells[3].Value); P.Idregion = Convert.ToInt32(dtgDireccion.Rows[x].Cells[4].Value); mensaje = P.ActualizarD(); } if (mensaje == "1") { MessageBoxEx.Show("Actualizado con éxito", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(); } } } else { MessageBoxEx.Show("Empleado debe ser mayor de 18 años", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Information); } Program.Codigo = 0; } } catch (Exception ex) { MessageBoxEx.Show(ex.Message); } }