private void dgvEmpleados_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { string cargo = ""; frmLoginAdmin.MtdAuditoria(frmAdministrador.data.Rows[0][0].ToString(), "hizo doble click mara modificar empleado"); ClsNempleado N = new ClsNempleado(); ClsNcargo Nc = new ClsNcargo(); ClsEempleado E = null; foreach (ClsEempleado item in N.busquedaEmpleado(dgvEmpleados.CurrentRow.Cells[0].Value.ToString())) { foreach (ClsEcargo item1 in Nc.listarCargos()) { if (item1.Codigo_Cargo.Equals(item.Codigo_Cargo)) { cargo = item1.Descripcion; break; } } string estado = (item.Estado.Equals("1")) ? "Activo" : "Inactivo"; E = ClsEempleado.crear(item.DniEmpleado, item.Nombres, item.Apellidos, item.Direccion, item.Correo, item.Telefono, item.idTurno, cargo, estado, item.Usuario, item.Contraseña); } frmRegistroEmpleado f = new frmRegistroEmpleado(E); f.ShowDialog(); dgvEmpleados.DataSource = N.listarEmpleados(); }
private void btnGuardar_Click(object sender, EventArgs e) { accion = 0; if (MtdValidarCampos()) { ClsEempleado E = ClsEempleado.crear(txtDni.Text, txtNombres.Text, txtApellidos.Text, txtDireccion.Text, txtCorreo.Text, txtTelefono.Text, cmbTurno.SelectedIndex + 1, lblCargo.Text, lblEstado.Text, txtUsuario.Text, txtContraseña.Text); ClsNempleado N = new ClsNempleado(); if (N.agregarEmpleado(E)) { if (MessageBox.Show("Empleado guardado correctamente, ¿Desea continuar en el formulario de registro de empleados?", "JeaNet - Informa", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { frmLoginAdmin.MtdAuditoria(frmAdministrador.data.Rows[0][0].ToString(), "Presiono " + btnGuardar.Name + " para agregar nuevo empleado"); MtdLimpiar(); btnModificar.Enabled = false; } else { this.Close(); } } else { MessageBox.Show("No se pudo registrar el empleado, intente de nuevo, revise nombre de usuario o comuniquese con soporte", "JeaNet - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); frmLoginAdmin.MtdAuditoria(frmAdministrador.data.Rows[0][0].ToString(), "Presiono " + btnGuardar.Name + ". no se pudo agregar nuevo empleado"); } } }
private void llenarCamposPerfilUsuario(DataTable data) { datos = data; ClsNempleado N = new ClsNempleado(); ClsEempleado E = null; ClsNcargo Nc = new ClsNcargo(); foreach (ClsEempleado item in N.busquedaEmpleado(data.Rows[0][0].ToString())) { foreach (ClsEcargo item1 in Nc.listarCargos()) { if (item1.Codigo_Cargo.Equals(item.Codigo_Cargo)) { lblcargo.Text = item1.Descripcion; break; } } string estado = (item.Estado.Equals("1")) ? "Activo" : "Inactivo"; E = ClsEempleado.crear(item.DniEmpleado, item.Nombres, item.Apellidos, item.Direccion, item.Correo, item.Telefono, item.idTurno, lblcargo.Text, estado, item.Usuario, item.Contraseña); } if (E != null) { lblDNI.Text = E.DniEmpleado; lblNombre.Text = E.Nombres; lblApellido.Text = E.Apellidos; txtDireccion.Text = E.Direccion; lblCorreo.Text = E.Correo; txtCorreo.Text = E.Correo; txtTelefono.Text = E.Telefono; lblturno.Text = (E.idTurno == 1) ? "Mañana" : (E.idTurno == 2) ? "Tarde" : (E.idTurno == 3) ? "Noche" : ""; lblUsuario.Text = E.Usuario; txtUsuario.Text = E.Usuario; } }
private void btnNuevo_Click(object sender, EventArgs e) { frmLoginAdmin.MtdAuditoria(frmAdministrador.data.Rows[0][0].ToString(), "Presiono boton " + btnNuevo.Name + " para agregar nuevos empleados"); frmRegistroEmpleado f = new frmRegistroEmpleado(); ClsNempleado N = new ClsNempleado(); f.ShowDialog(); dgvEmpleados.DataSource = N.listarEmpleados(); }
private void dgvEmpleados_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { frmLoginAdmin.MtdAuditoria(frmAdministrador.data.Rows[0][0].ToString(), "hizo doble click mara modificar empleado"); ClsEempleado E = new ClsEempleado(); ClsNempleado N = new ClsNempleado(); ClsNcargo Nc = new ClsNcargo(); DataTable data = N.MtdBusquedaEmpleado(dgvEmpleados.CurrentRow.Cells[0].Value.ToString()); E.Dni = data.Rows[0][0].ToString(); E.Nombres = data.Rows[0][1].ToString(); E.Apellidos = data.Rows[0][2].ToString(); E.Direccion = data.Rows[0][3].ToString(); E.Correo = data.Rows[0][4].ToString(); E.Telefono = data.Rows[0][5].ToString(); //para cargo foreach (DataRow item in Nc.MtdListarCargos().Rows) { if (data.Rows[0][6].ToString() == item[0].ToString()) { E.Cargo = item[1].ToString(); break; } } //para turno if (data.Rows[0][7].ToString() == "1") { E.Turno = "Mañana"; } else if (data.Rows[0][7].ToString() == "2") { E.Turno = "Tarde"; } else if (data.Rows[0][7].ToString() == "3") { E.Turno = "Noche"; } //para estado if (data.Rows[0][8].ToString() == "1") { E.Estado = "Activo"; } else if (data.Rows[0][8].ToString() == "0") { E.Estado = "Inactivo"; } E.Usuario = data.Rows[0][9].ToString(); E.Contraseña = data.Rows[0][10].ToString(); frmRegistroEmpleado f = new frmRegistroEmpleado(E.Dni, E.Nombres, E.Apellidos, E.Direccion, E.Correo, E.Telefono, E.Cargo, E.Turno, E.Estado, E.Usuario, E.Contraseña); f.ShowDialog(); dgvEmpleados.DataSource = N.MtdListarEmpleados(); }
private void btnGuardar_Click(object sender, EventArgs e) { if (cambiar == true) { if (validarCampos()) { ClsEempleado E = ClsEempleado.crear(lblDNI.Text, lblNombre.Text, lblApellido.Text, txtDireccion.Text, txtCorreo.Text, txtTelefono.Text, Convert.ToInt32(datos.Rows[0][7]), datos.Rows[0][6].ToString(), datos.Rows[0][8].ToString(), txtUsuario.Text, txtClaveRepe.Text); ClsNempleado N = new ClsNempleado(); if (N.modificarEmpleado(E)) { MessageBox.Show("Datos modificados correctamente", "JeaNet - Informa", MessageBoxButtons.OK, MessageBoxIcon.Information); frmLoginAdmin.MtdAuditoria(frmAdministrador.data.Rows[0][0].ToString(), "Presiono " + btnGuardar.Name + " para modificar perfil " + frmAdministrador.data.Rows[0][0].ToString()); lblUsuario.Text = txtUsuario.Text; lblCorreo.Text = txtDireccion.Text; } else { MessageBox.Show("No se pudo modificar el empleado, intente de nuevo o comuniquese con soporte.", "JeaNet - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); frmLoginAdmin.MtdAuditoria(frmAdministrador.data.Rows[0][0].ToString(), "Presiono " + btnGuardar.Name + ", no se pudo modificar perfil " + frmAdministrador.data.Rows[0][0].ToString()); } cambiar = false; MtdLimpiar(); this.Size = new Size(475, 558); panel1.Visible = false; this.Close(); } } else if (validarCampos()) { ClsEempleado E = ClsEempleado.crear(lblDNI.Text, lblNombre.Text, lblApellido.Text, txtDireccion.Text, txtCorreo.Text, txtTelefono.Text, Convert.ToInt32(datos.Rows[0][7]), datos.Rows[0][6].ToString(), datos.Rows[0][8].ToString(), txtUsuario.Text, txtClaveRepe.Text); ClsNempleado N = new ClsNempleado(); if (N.modificarEmpleado(E)) { MessageBox.Show("Datos modificados correctamente", "JeaNet - Informa", MessageBoxButtons.OK, MessageBoxIcon.Information); frmLoginAdmin.MtdAuditoria(frmAdministrador.data.Rows[0][0].ToString(), "Presiono " + btnGuardar.Name + " para modificar perfil " + frmAdministrador.data.Rows[0][0].ToString()); lblUsuario.Text = txtUsuario.Text; lblCorreo.Text = txtDireccion.Text; } else { MessageBox.Show("No se pudo modificar el empleado, intente de nuevo o comuniquese con soporte.", "JeaNet - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); frmLoginAdmin.MtdAuditoria(frmAdministrador.data.Rows[0][0].ToString(), "Presiono " + btnGuardar.Name + ", no se pudo modificar perfil " + frmAdministrador.data.Rows[0][0].ToString()); } cambiar = false; MtdLimpiar(); this.Size = new Size(475, 558); panel1.Visible = false; } frmLoginAdmin.MtdAuditoria(frmAdministrador.data.Rows[0][0].ToString(), "Hizo clic en Guardar Cambio de su perfil"); }
public frmPerfilUsuario(DataTable data) { InitializeComponent(); datos = data; ClsNempleado N = new ClsNempleado(); data = N.MtdBusquedaEmpleado(data.Rows[0][0].ToString()); ClsEempleado E = new ClsEempleado(); ClsNcargo Nc = new ClsNcargo(); lblDNI.Text = data.Rows[0][0].ToString(); lblNombre.Text = data.Rows[0][1].ToString(); lblApellido.Text = data.Rows[0][2].ToString(); txtDireccion.Text = data.Rows[0][3].ToString(); lblCorreo.Text = data.Rows[0][4].ToString(); txtCorreo.Text = data.Rows[0][4].ToString(); txtTelefono.Text = data.Rows[0][5].ToString(); //para cargo foreach (DataRow item in Nc.MtdListarCargos().Rows) { if (data.Rows[0][6].ToString() == item[0].ToString()) { lblcargo.Text = item[1].ToString(); break; } } //para turno if (data.Rows[0][7].ToString() == "1") { lblturno.Text = "Mañana"; } else if (data.Rows[0][7].ToString() == "2") { lblturno.Text = "Tarde"; } else if (data.Rows[0][7].ToString() == "3") { lblturno.Text = "Noche"; } lblUsuario.Text = data.Rows[0][9].ToString(); txtUsuario.Text = data.Rows[0][9].ToString(); //txtClave.Text = data.Rows[0][10].ToString(); }
private void btnModificar_Click(object sender, EventArgs e) { ga = 1; if (MtdValidarCampos() == 0) { ClsEempleado E = new ClsEempleado(); ClsNempleado N = new ClsNempleado(); E.Dni = txtDni.Text; E.Nombres = txtNombres.Text; E.Apellidos = txtApellidos.Text; E.Direccion = txtDireccion.Text; E.Correo = txtCorreo.Text; E.Telefono = txtTelefono.Text; E.Cargo = lblCargo.Text; E.Turno = lblTurno.Text; E.Estado = lblEstado.Text; E.Usuario = txtUsuario.Text; E.Contraseña = txtContraseña.Text; if (N.MtdModificarEmpleado(E)) { if (MessageBox.Show("Empleado modificado correctamente, ¿Desea continuar en el formulario de registro de empleados?", "JeaNet - Informa", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { frmLoginAdmin.MtdAuditoria(frmAdministrador.data.Rows[0][0].ToString(), "Presiono " + btnModificar.Name + " para modificar empleado"); btnGuardar.Enabled = true; btnModificar.Enabled = false; txtDni.Enabled = true; MtdLimpiar(); } else { this.Close(); } } else { MessageBox.Show("No se pudo modificar el empleado, intente de nuevo o comuniquese con soporte.", "JeaNet - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); frmLoginAdmin.MtdAuditoria(frmAdministrador.data.Rows[0][0].ToString(), "Presiono " + btnModificar.Name + ", no se pudo modificar empleado"); } } }
private void txtBuscar_TextChanged(object sender, EventArgs e) { ClsNempleado N = new ClsNempleado(); dgvEmpleados.DataSource = N.filtrarEmpleados(txtBuscar.Text); }
private void listarEmpleado() { ClsNempleado N = new ClsNempleado(); dgvEmpleados.DataSource = N.listarEmpleados(); }
private int MtdValidarCampos() { int validar_campos = 5; if (txtDireccion.Text.Equals("")) //para la direccion { error1.SetError(txtDireccion, "Ingrese Direccion"); txtDireccion.Focus(); } else { error1.SetError(txtDireccion, ""); validar_campos--; } if (txtCorreo.Text.Equals("")) //para el correo { error1.SetError(txtCorreo, "Ingrese Correo"); txtCorreo.Focus(); } else if (!MtdValidarEmail(txtCorreo.Text)) { error1.SetError(txtCorreo, "Ingrese un correo valido"); txtCorreo.Focus(); } else { error1.SetError(txtCorreo, ""); validar_campos--; } if (txtTelefono.Text.Equals("")) //para el telefono { error1.SetError(txtTelefono, "Ingrese Telefono"); txtTelefono.Focus(); } else if (txtTelefono.TextLength != 9) { error1.SetError(txtTelefono, "Ingrese Telefono Valido"); txtTelefono.Focus(); } else { error1.SetError(txtTelefono, ""); validar_campos--; } if (txtUsuario.Text.Equals("")) //para el usuario { error1.SetError(txtUsuario, "Ingrese Usuario"); txtUsuario.Focus(); } else { bool verificar_existencia = false; ClsNempleado N = new ClsNempleado(); foreach (DataRow item in N.MtdListarEmpleados().Rows) { if (txtUsuario.Text == item[9].ToString()) { verificar_existencia = true; break; } } if (verificar_existencia is true) { if (lblUsuario.Text != txtUsuario.Text) { error1.SetError(txtUsuario, "El nombre usuario ya esta en uso."); txtUsuario.Focus(); } else { error1.SetError(txtUsuario, ""); validar_campos--; } } else { error1.SetError(txtUsuario, ""); validar_campos--; } } if (txtClave.Text.Equals("")) //para la clave { error1.SetError(txtClave, "Tiene que ingresar su contraseña par poder guardar los cambiosIngrese Contraseña"); txtClave.Focus(); } else if (txtClave.TextLength != 6) { error1.SetError(txtClave, "La contraseña tiene que tener 6 numeros"); txtClave.Focus(); } else { bool verificar_existencia = false; ClsNempleado N = new ClsNempleado(); foreach (DataRow item in N.MtdListarEmpleados().Rows) { if (txtClave.Text == item[10].ToString() && lblDNI.Text == item[0].ToString()) { verificar_existencia = true; break; } } if (verificar_existencia is false) { error1.SetError(txtClave, "La contraseña ingresada no coincide con la actual."); txtClave.Focus(); } else { error1.SetError(txtClave, ""); validar_campos--; } } if (cambiar is true) { validar_campos += 3; if (txtClaveNueva.Text.Equals("")) //para la clave nueva { error1.SetError(txtClaveNueva, "Tiene que ingresar su contraseña nueva"); txtClaveNueva.Focus(); } else if (txtClaveNueva.TextLength != 6) { error1.SetError(txtClaveNueva, "La contraseña tiene que tener 6 numeros"); txtClaveNueva.Focus(); } else { error1.SetError(txtClaveNueva, ""); validar_campos--; } if (txtClaveRepe.Text.Equals("")) //para la clave repetida { error1.SetError(txtClaveRepe, "Tiene que repetir su nueva clave"); txtClaveRepe.Focus(); } else if (txtClaveRepe.TextLength != 6) { error1.SetError(txtClaveRepe, "La contraseña tiene que tener 6 numeros"); txtClaveRepe.Focus(); } else { error1.SetError(txtClaveRepe, ""); validar_campos--; } if (txtClaveRepe.Text != txtClaveNueva.Text) //para las claves iguales { error1.SetError(txtClaveRepe, "La claves no coinciden"); error1.SetError(txtClaveNueva, "La claves no coinciden"); } else { error1.SetError(txtClaveRepe, ""); error1.SetError(txtClaveNueva, ""); validar_campos--; } } return(validar_campos); }
private void frmEmpleados_Load(object sender, EventArgs e) { ClsNempleado N = new ClsNempleado(); dgvEmpleados.DataSource = N.MtdListarEmpleados(); }
private void txtBuscar_Leave(object sender, EventArgs e) { ClsNempleado N = new ClsNempleado(); dgvEmpleados.DataSource = N.MtdListarEmpleados(); }
private int MtdValidarCampos() { int validar_campos = 9; if (txtDni.Text.Equals("")) //para el DNI { error1.SetError(txtDni, "Ingrese DNI"); txtDni.Focus(); } else if (txtDni.TextLength != 8 || txtNombres.Text.Equals("") || txtApellidos.Text.Equals("")) { error1.SetError(txtDni, "Ingrese un DNI valido"); txtDni.Focus(); } else { error1.SetError(txtDni, ""); validar_campos--; } if (txtDireccion.Text.Equals("")) //para la direccion { error1.SetError(txtDireccion, "Ingrese Direccion"); txtDireccion.Focus(); } else { error1.SetError(txtDireccion, ""); validar_campos--; } if (txtCorreo.Text.Equals("")) //para el correo { error1.SetError(txtCorreo, "Ingrese Correo"); txtCorreo.Focus(); } else if (!MtdValidarEmail(txtCorreo.Text)) { error1.SetError(txtCorreo, "Ingrese un correo valido"); txtCorreo.Focus(); } else { error1.SetError(txtCorreo, ""); validar_campos--; } if (txtTelefono.Text.Equals("")) //para el telefono { error1.SetError(txtTelefono, "Ingrese Telefono"); txtTelefono.Focus(); } else if (txtTelefono.TextLength != 9) { error1.SetError(txtTelefono, "Ingrese Telefono Valido"); txtTelefono.Focus(); } else { error1.SetError(txtTelefono, ""); validar_campos--; } if (cmbTurno.SelectedIndex == -1) //para el turno { error1.SetError(cmbTurno, "Seleccione un Turno"); } else { error1.SetError(cmbTurno, ""); validar_campos--; } if (cmbCargo.SelectedIndex == -1) //para el cargo { error1.SetError(cmbCargo, "Seleccione un Cargo"); } else { error1.SetError(cmbCargo, ""); validar_campos--; } if (cmbEstado.SelectedIndex == -1) //para el estado { error1.SetError(cmbEstado, "Seleccione un Estado"); } else { error1.SetError(cmbEstado, ""); validar_campos--; } if (txtUsuario.Text.Equals("")) //para el usuario { error1.SetError(txtUsuario, "Ingrese Usuario"); txtUsuario.Focus(); } else { bool verificar_existencia = false; ClsNempleado N = new ClsNempleado(); foreach (DataRow item in N.MtdListarEmpleados().Rows) { if (txtUsuario.Text == item[9].ToString()) { verificar_existencia = true; break; } } if (verificar_existencia is true && ga == 0) { error1.SetError(txtUsuario, "El nombre usuario ya esta en uso."); txtUsuario.Focus(); return(4); }