private bool existeUsuario(int parametro) { bool existe = false; DataTable miDT = miGestorPE.consultarTabla("UsuariosExtractorio"); ResponsableExtraccion r = new ResponsableExtraccion(); foreach (DataRow fila in miDT.Rows) { if (fila != null) { r.pLegajo = Convert.ToInt32(fila["legajo"]); if (r.pLegajo == parametro) { existe = true; } } } return(existe); }
public ResponsableExtraccion[] GetResponsablesDeExtraciones() { ResponsableExtraccion[] miLista = new ResponsableExtraccion[tam]; cmd = new SqlCommand("select * from ResponsablesTecnicos", Conexion.ObtenerConexion()); dr = cmd.ExecuteReader(); int c = 0; while (dr.Read()) { ResponsableExtraccion nuevo = new ResponsableExtraccion(); if (!pDr.IsDBNull(0)) { nuevo.pLegajo = pDr.GetInt32(0); } if (!pDr.IsDBNull(1)) { nuevo.pMatricula = pDr.GetString(1); } if (!pDr.IsDBNull(2)) { nuevo.pIdTurnoTrabajo = pDr.GetInt32(2); } if (!pDr.IsDBNull(3)) { nuevo.pNombre = pDr.GetString(3); } if (!pDr.IsDBNull(4)) { nuevo.pApellido = pDr.GetString(4); } if (!pDr.IsDBNull(5)) { nuevo.pEdad = pDr.GetInt32(5); } if (!pDr.IsDBNull(6)) { nuevo.pIdGenero = pDr.GetInt32(6); } if (!pDr.IsDBNull(7)) { nuevo.pFechaNac = pDr.GetString(7); } if (!pDr.IsDBNull(8)) { nuevo.pFechaRegistro = pDr.GetString(8); } if (!pDr.IsDBNull(9)) { nuevo.pNroDoc = pDr.GetInt32(9); } if (!pDr.IsDBNull(10)) { nuevo.pTipoDoc = pDr.GetInt32(10); } if (!pDr.IsDBNull(11)) { nuevo.pEmail = pDr.GetString(11); } if (!pDr.IsDBNull(12)) { nuevo.pTitulo = pDr.GetInt32(12); } miLista[c] = nuevo; c++; } dr.Close(); Conexion.CerrarConexion(); return(miLista); }
private void btnGrabar_Click(object sender, EventArgs e) { try { if (validar()) { string sql = ""; if (bandera) { ResponsableExtraccion p = new ResponsableExtraccion(); p.pApellido = txtApellidoRT.Text; p.pNombre = txtNombreRT.Text; p.pEdad = Convert.ToInt32(txtEdadRT.Text); p.pNroDoc = Convert.ToInt32(txtNroDocRT.Text); p.pTipoDoc = Convert.ToInt32(cboTipoDocRT.SelectedValue); p.pFechaNac = dtpFechaNacRT.Value.ToShortDateString(); p.pEmail = txtEmailRT.Text; p.pTitulo = Convert.ToInt32(cboEspTecRT.SelectedValue); p.pIdTurnoTrabajo = Convert.ToInt32(cboTurnoRT.SelectedValue); p.pMatricula = txtMatriculaRT.Text; p.pIdGenero = Convert.ToInt32(cboGeneroRT.SelectedValue); sql = "insert into ResponsablesTecnicos(matricula,turno,nombre,apellido,edad,genero,fechaNac,NroDoc,tipoDoc,email,especialidadTecnica) values ('" + p.pMatricula + "'," + p.pIdTurnoTrabajo + ",'" + p.pNombre + "','" + p.pApellido + "'," + p.pEdad + "," + p.pIdGenero + ",'" + p.pFechaNac + "'," + p.pNroDoc + "," + p.pTipoDoc + ",'" + p.pEmail + "'," + p.pTitulo + "" + ")"; if (MetroFramework.MetroMessageBox.Show(this, "Desea registrar al Prof. de extractorio?", "Alta de personal extractorio", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { miGestorPE.actualizarBD(sql); miGestorPE.CargarListado(lstPersonalTecnico); ActualizarVectorPE(); inicio(); MessageBox.Show("Registro exitoso."); lstPersonalTecnico.SelectedIndex = 0; } else { } } else { int i = lstPersonalTecnico.SelectedIndex; vRespExt[i].pApellido = txtApellidoRT.Text; vRespExt[i].pNombre = txtNombreRT.Text; vRespExt[i].pIdGenero = Convert.ToInt32(cboGeneroRT.SelectedValue); vRespExt[i].pNroDoc = Convert.ToInt32(txtNroDocRT.Text); vRespExt[i].pTitulo = Convert.ToInt32(cboEspTecRT.SelectedValue); vRespExt[i].pFechaNac = txtFechaNacRT.Text; vRespExt[i].pLegajo = Convert.ToInt32(txtLegajoRT.Text); vRespExt[i].pEmail = txtEmailRT.Text; vRespExt[i].pIdTurnoTrabajo = Convert.ToInt32(cboTurnoRT.SelectedValue); vRespExt[i].pMatricula = txtMatriculaRT.Text; vRespExt[i].pEdad = Convert.ToInt32(txtEdadRT.Text); sql = "Update ResponsablesTecnicos set apellido ='" + vRespExt[i].pApellido + "'," + "nombre='" + vRespExt[i].pNombre + "'," + "genero= " + vRespExt[i].pIdGenero + "," + "nroDoc= " + vRespExt[i].pNroDoc + "," + "especialidadTecnica= " + vRespExt[i].pTitulo + "," + "fechaNac= '" + vRespExt[i].pFechaNac + "'," + "email= '" + vRespExt[i].pEmail + "'," + "turno= " + vRespExt[i].pIdTurnoTrabajo + "," + "matricula= '" + vRespExt[i].pMatricula + "'," + "edad= " + vRespExt[i].pEdad + "" + " Where legajo = " + vRespExt[i].pLegajo; if (MetroFramework.MetroMessageBox.Show(this, "Desea confirmar los cambios realizados?", "ActualizaciĆ³n de datos", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { miGestorPE.actualizarBD(sql); miGestorPE.CargarListado(lstPersonalTecnico); ActualizarVectorPE(); inicio(); MessageBox.Show("ActualizaciĆ³n correcta."); lstPersonalTecnico.SelectedIndex = 0; } else { } } } } catch (DataException error) { MessageBox.Show("No se puedo completar: " + error.ToString()); } }