private void btnIngresar_Click(object sender, EventArgs e) { if (txtUsuario.Text.Equals("") && txtContraseña.Text.Equals("")) { MessageBox.Show("Ingrese nombre de usuario y password"); } else { string nombreDeUsuario = txtUsuario.Text; string password = txtContraseña.Text; bool resultado = false; try { resultado = AD_Empleados.ValidarUsuario(nombreDeUsuario, password); if (resultado) { frmPrincipal ventana = new frmPrincipal(); ventana.Show(); this.Hide(); } else { MessageBox.Show("Usuario inexistente!"); } } catch (Exception ex) { MessageBox.Show("Error al consultar el usuario!"); } } }
//private void CargarCampos(Empleados em) //{ // frmModificarEmpleado vent = new frmModificarEmpleado(); // vent.txtLeg.Text = em.LegajoEmpleado.ToString(); // vent.txtNom.Text = em.NombreEmpleado; // vent.txtApe.Text = em.ApellidoEmpleado; // vent.txtDire.Text = em.CalleEmpleado; // vent.txtNroCall.Text = em.NroCalleEmpleado.ToString(); // vent.cmbBarr.SelectedValue = em.IdBarrioEmpleado; // vent.txtIDUsu.Text = em.IdUsuarioEmpleado.ToString(); // vent.txtNomUsu.Text = em.NombreUsuarioEmpleado; // vent.txtContra.Text = em.ContraseñaEmpleado; // vent.txtRepContra.Text = em.ContraseñaEmpleado; // vent.ShowDialog(); //} //private Empleados ObtenerEmpleado(string legajo) //{ // string cadenaConexion = System.Configuration.ConfigurationManager.AppSettings["CadenaBD"]; // SqlConnection cn = new SqlConnection(cadenaConexion); // Empleados em = new Empleados(); // try // { // SqlCommand cmd = new SqlCommand(); // string consulta = "SELECT * FROM empleados where legajo like @legajo"; // cmd.Parameters.Clear(); // cmd.Parameters.AddWithValue("@legajo", legajo); // cmd.CommandType = CommandType.Text; // cmd.CommandText = consulta; // cn.Open(); // cmd.Connection = cn; // SqlDataReader dr = cmd.ExecuteReader(); // if (dr != null && dr.Read()) // { // em.LegajoEmpleado = int.Parse(dr["legajo"].ToString()); // em.NombreEmpleado = dr["n_empleado"].ToString(); // em.ApellidoEmpleado = dr["apellido_empleado"].ToString(); // em.CalleEmpleado = dr["calle"].ToString(); // em.NroCalleEmpleado = int.Parse(dr["nro_calle"].ToString()); // em.IdBarrioEmpleado = int.Parse(dr["id_barrio"].ToString()); // em.IdUsuarioEmpleado = int.Parse(dr["id_usuario"].ToString()); // em.NombreUsuarioEmpleado = dr["n_usuario"].ToString(); // em.ContraseñaEmpleado = dr["contraseña"].ToString(); // } // } // catch (Exception) // { // throw; // } // finally // { // cn.Close(); // } // return em; //} private void btnBuscar_Click_1(object sender, EventArgs e) { try { if (txtFiltrarPorLegajo.Text.Equals("")) { CargarGrilla(); MessageBox.Show("Ingrese algun legajo"); } else { DataTable tablaResultado = AD_Empleados.ObtenerEmpleadoXLegajo(int.Parse(txtFiltrarPorLegajo.Text.Trim())); if (tablaResultado.Rows.Count > 0) { gdrEmpleados.DataSource = tablaResultado; } else { MessageBox.Show("Empleado Inexistente"); txtFiltrarPorLegajo.Focus(); } } } catch (Exception) { MessageBox.Show("Error"); } }
private void reportViewer1_Load(object sender, EventArgs e) { DataTable tabla = new DataTable(); tabla = AD_Empleados.ObtenerEmpleados(); ReportDataSource ds = new ReportDataSource("DatosEmpleados", tabla); reportViewer1.LocalReport.DataSources.Clear(); reportViewer1.LocalReport.DataSources.Add(ds); reportViewer1.LocalReport.Refresh(); }
public void CargarGrilla() { try { gdrEmpleados.DataSource = AD_Empleados.ObtenerListadoEmpleadosReducido(); } catch (Exception ex) { MessageBox.Show("Error al obtener empleados"); } }
private void btnAltaEmpleado_Click(object sender, EventArgs e) { string leg = ""; leg = txtLegajo.Text.Trim().ToString(); string nombreUsua = txtNombreUsuario.Text; if (txtContraseña.Text.Equals(txtRepContraseña.Text) == true && leg.Length == 5 && !txtNombre.Text.Trim().Equals("") && !txtApellido.Text.Trim().Equals("") && !txtDireccion.Text.Trim().Equals("") && !txtNroCalle.Text.Trim().Equals("") && !cmbBarrio.Text.Trim().Equals("") && !txtNombreUsuario.Text.Trim().Equals("") && !txtContraseña.Text.Trim().Equals("") && !txtRepContraseña.Text.Trim().Equals("") && AD_Empleados.ValidarAlRegistrar(int.Parse(txtLegajo.Text), nombreUsua) == false) { //Poner try cach Empleados em = ObtenerDatosEmpleado(); bool resultado = AD_Empleados.AgregarEmpleadoABD(em); if (resultado) { MessageBox.Show("Empleado agregado con éxito"); LimpiarCampos(); CargarComboBarrios(); //CargarComboCarreras(); //CargarComboTiposDocumentos(); } else { MessageBox.Show("Error al agregar la empleado"); } //MessageBox.Show(nombre + " " + apellido + " " + sexo + " " + tipoDocumento + " " + nroDocumento); //MessageBox.Show("Datos de la persona: " + per.NombrePersona + " " + per.ApellidoPersona + " " + per.DocumentoPersona); } else { if (AD_Empleados.ValidarAlRegistrar(int.Parse(txtLegajo.Text), nombreUsua) == true) { MessageBox.Show("Hay un problema, Legajo o nombre de usuario ya se encuentran ocupados"); } else if (txtContraseña.Text.Equals(txtRepContraseña.Text) == false) { MessageBox.Show("Las contraseñas no coinciden"); } else if (leg.Length < 5 || txtNombre.Text.Trim().Equals("") || txtApellido.Text.Trim().Equals("") || txtDireccion.Text.Trim().Equals("") || txtNroCalle.Text.Trim().Equals("") || cmbBarrio.Text.Trim().Equals("") || txtNombreUsuario.Text.Trim().Equals("") || txtContraseña.Text.Trim().Equals("") || txtRepContraseña.Text.Trim().Equals("")) { MessageBox.Show("Hay un problema, por favor verifique que todos los campos esten completos"); } else { MessageBox.Show("No se pudo cargar el empleado exitosamente"); } } }
private void btnEliminar_Click_1(object sender, EventArgs e) { Empleados em = AD_Empleados.ObtenerEmpleado(txtLeg.Text); bool resultado = EliminarEmpleado(em); if (resultado) { MessageBox.Show("Empleado eliminado con éxito"); CargarComboBarrios(); this.Close(); } else { MessageBox.Show("Error al eliminar empleado"); } }
private void gdrEmpleados_CellClick(object sender, DataGridViewCellEventArgs e) { try { CargarGrilla(); int indice = e.RowIndex; DataGridViewRow filaSeleccionada = gdrEmpleados.Rows[indice]; string legajo = filaSeleccionada.Cells["LegajoEmpleado"].Value.ToString(); Empleados em = AD_Empleados.ObtenerEmpleado(legajo); frmModificarEmpleado vent = new frmModificarEmpleado(em); //CargarCampos(em); } catch (Exception) { MessageBox.Show("Algo ha salido mal, por favor seleccione una fila"); } }
private void btnActualizar_Click(object sender, EventArgs e) { string leg = ""; leg = txtLeg.Text.Trim().ToString(); string nombreUsua = txtNomUsu.Text; if (txtContra.Text.Equals(txtRepContra.Text) == true && leg.Length == 5 && !txtNom.Text.Trim().Equals("") && !txtApe.Text.Trim().Equals("") && !txtDire.Text.Trim().Equals("") && !txtNroCall.Text.Trim().Equals("") && !cmbBarr.Text.Trim().Equals("") && !txtNomUsu.Text.Trim().Equals("") && !txtContra.Text.Trim().Equals("") && !txtRepContra.Text.Trim().Equals("") && (AD_Empleados.ValidarAlModificar(nombreUsua) == false || AD_Empleados.ObtenerEmpleado(txtLeg.Text.ToString()).NombreUsuarioEmpleado.Equals(txtNomUsu.Text))) { //Poner try cach Empleados em = ObtenerDatosEmpleado(); bool resultado = ActualizarEmpleado(em); if (resultado) { MessageBox.Show("Persona actualizada con éxito"); this.Close(); } else { MessageBox.Show("Error al actualizar persona"); } //MessageBox.Show(nombre + " " + apellido + " " + sexo + " " + tipoDocumento + " " + nroDocumento); //MessageBox.Show("Datos de la persona: " + per.NombrePersona + " " + per.ApellidoPersona + " " + per.DocumentoPersona); } else { if (AD_Empleados.ValidarAlRegistrar(int.Parse(txtLeg.Text), nombreUsua) == true) { MessageBox.Show("Hay un problema, Legajo o nombre de usuario ya se encuentran ocupados"); } else if (txtContra.Text.Equals(txtRepContra.Text) == false) { MessageBox.Show("Las contraseñas no coinciden"); } else if (leg.Length < 5 || txtNom.Text.Trim().Equals("") || txtApe.Text.Trim().Equals("") || txtDire.Text.Trim().Equals("") || txtNroCall.Text.Trim().Equals("") || cmbBarr.Text.Trim().Equals("") || txtNomUsu.Text.Trim().Equals("") || txtContra.Text.Trim().Equals("") || txtRepContra.Text.Trim().Equals("")) { MessageBox.Show("Hay un problema, por favor verifique que todos los campos esten completos"); } else { MessageBox.Show("No se pudo cargar el empleado exitosamente"); } } }
private void btnBuscar_Click(object sender, EventArgs e) { try { if (txtApellido.Text.Equals("")) { MessageBox.Show("Ingrese algun apellido"); DataTable tabla1 = new DataTable(); tabla1 = AD_Empleados.ObtenerEmpleados(); ReportDataSource ds = new ReportDataSource("DatosEmpleados", tabla1); reportViewer2.LocalReport.DataSources.Clear(); reportViewer2.LocalReport.DataSources.Add(ds); reportViewer2.RefreshReport(); } else { DataTable tabla = new DataTable(); tabla = AD_Empleados.ObtenerEmpleadoXApellido(txtApellido.Text.Trim()); if (tabla.Rows.Count > 0) { ReportDataSource ds = new ReportDataSource("DatosEmpleados", tabla); reportViewer2.LocalReport.DataSources.Clear(); reportViewer2.LocalReport.DataSources.Add(ds); reportViewer2.RefreshReport(); } else { MessageBox.Show("Empleado Inexistente"); txtApellido.Focus(); DataTable tabla1 = new DataTable(); tabla1 = AD_Empleados.ObtenerEmpleados(); ReportDataSource ds = new ReportDataSource("DatosEmpleados", tabla1); reportViewer2.LocalReport.DataSources.Clear(); reportViewer2.LocalReport.DataSources.Add(ds); reportViewer2.RefreshReport(); } } } catch (Exception) { MessageBox.Show("Error"); } }
private void btnBuscar_Click(object sender, EventArgs e) { try { if (cmbBarrio.Text.Equals("")) { MessageBox.Show("Selecciones algun barrio"); } else { DataTable tabla = new DataTable(); tabla = AD_Empleados.ObtenerEmpleadosXBarrio((int)cmbBarrio.SelectedValue); ReportDataSource ds = new ReportDataSource("DatosEmpleados", tabla); reportViewer1.LocalReport.DataSources.Clear(); reportViewer1.LocalReport.DataSources.Add(ds); reportViewer1.RefreshReport(); } } catch (Exception) { MessageBox.Show("Error"); } }