private void btnSearch_Click(object sender, EventArgs e) { try { if (!txtCodigoEmpleado.Text.Equals(" ")) { RegistroPersonal search = new RegistroPersonal(); search.identificacion = Convert.ToInt32(txtCodigoEmpleado.Text.Trim()); List <RegistroPersonal> lstbusquedas = S02_02LogicaNegocio.Logica.BuscarPersonal(search); this.dataGridView.DataSource = lstbusquedas; this.dataGridView.Refresh(); } else if (txtCodigoEmpleado.Text.Equals(" ")) { CargarPersonal(); } } catch (Exception ex) { CargarPersonal(); //MessageBox.Show("Error \n" + ex.Message + "\nal Encontrar Datos en Tabla RegistroPersonal"); } Limpiar(); }
protected void Salida_Click(object sender, EventArgs e) { try { RegistroPersonal personal = new RegistroPersonal(); string hora, fecha; hora = DateTime.Now.ToString("hh:mm"); fecha = DateTime.Now.ToString("dd/MM/yyyy"); personal.nombreEmpleado = Nombre_Empleado.Text.Trim(); personal.identificacion = Convert.ToInt32(identificacion.Text.Trim()); personal.posicion = posicion.Text.Trim(); personal.area = area.Text.Trim(); personal.fechaEntrada = ""; personal.horaEntrada = ""; personal.fechaSalida = fecha; personal.horaSalida = hora; S02_02LogicaNegocio.Logica.ModificarHoraSalida(personal); CargarLista(); Limpiar(); Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Salida Registrada con exito');</script>"); } catch (Exception ex) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Error al Gestionar Salida');</script>"); } }
private void btnIniciar_Click(object sender, EventArgs e) { try { RegistroPersonal personal = new RegistroPersonal(); string hora, fecha; hora = DateTime.Now.ToString("hh:mm"); fecha = DateTime.Now.ToString("dd/MM/yyyy"); personal.codEntrada = Convert.ToInt32(txtCodigoEmpleado.Text.Trim()); personal.nombreEmpleado = txtNombre.Text.Trim(); personal.identificacion = Convert.ToInt32(txtIdEmpleado.Text.Trim()); personal.posicion = txtPosicion.Text.Trim(); personal.area = txtArea.Text.Trim(); personal.fechaEntrada = fecha; personal.horaEntrada = hora; personal.fechaSalida = ""; personal.horaSalida = ""; S02_02LogicaNegocio.Logica.ModificarHoraEntrada(personal); CargarPersonal(); Limpiar(); //MessageBox.Show("Persona Editada"); } catch (Exception ex) { MessageBox.Show("Error \n" + ex.Message + "\nal Insertar hora de Entrada"); } }
public static List <RegistroPersonal> BuscarPersonal(RegistroPersonal Regpersonal) { try { SQLSentencia sentencia = new SQLSentencia(); sentencia.PETICION = @"SELECT * FROM RegistroPersonal WHERE identificacion='" + Regpersonal.identificacion + "'"; S02_03AccedoDatos.Acceso objAcceso = new S02_03AccedoDatos.Acceso(); return(objAcceso.ObtenerPersonal(sentencia)); } catch (Exception e) { throw e; } }
public List <RegistroPersonal> ObtenerPersonal(SQLSentencia objsentencia) { List <RegistroPersonal> lstresultados = new List <RegistroPersonal>(); System.Data.DataTable dt = new System.Data.DataTable(); try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = objsentencia.PETICION; cmd.Connection = objconexion; cmd.CommandType = System.Data.CommandType.Text; if (objsentencia.LSTPARAMETROS != null) { cmd.Parameters.AddRange(objsentencia.LSTPARAMETROS.ToArray()); } SqlDataAdapter objcarga = new SqlDataAdapter(cmd); objcarga.Fill(dt); foreach (System.Data.DataRow item in dt.Rows) { RegistroPersonal RegPersonal = new RegistroPersonal(); RegPersonal.codEntrada = Convert.ToInt32(item.ItemArray[0].ToString()); RegPersonal.nombreEmpleado = item.ItemArray[1].ToString(); RegPersonal.identificacion = Convert.ToInt32(item.ItemArray[2].ToString()); RegPersonal.posicion = item.ItemArray[3].ToString(); RegPersonal.area = item.ItemArray[4].ToString(); RegPersonal.fechaEntrada = item.ItemArray[5].ToString(); //convertir a nvarchar en db RegPersonal.horaEntrada = item.ItemArray[6].ToString(); //crear item en db como nvarchar RegPersonal.fechaSalida = item.ItemArray[7].ToString(); RegPersonal.horaSalida = item.ItemArray[8].ToString(); //crear item en db como nvarchar lstresultados.Add(RegPersonal); } } catch (Exception ex) { throw ex; } finally { this.CERRAR(); } return(lstresultados); }
public static int ModificarHoraSalida(RegistroPersonal Regpersonal) { try { ArrayList lstparametros = new ArrayList(); //se define lista de valores SQLSentencia sentencia = new SQLSentencia(); sentencia.PETICION = @"UPDATE RegistroPersonal SET fechaSalida= @fechaSalida, horaSalida= @horaSalida WHERE codEntrada=@codEntrada"; #region Definicion de parametros SqlParameter codEntrada = new SqlParameter(); codEntrada.SqlDbType = System.Data.SqlDbType.Int; codEntrada.ParameterName = "@codEntrada"; codEntrada.Value = Regpersonal.codEntrada; SqlParameter fechaSalida = new SqlParameter(); fechaSalida.SqlDbType = System.Data.SqlDbType.NVarChar; fechaSalida.ParameterName = "@fechaSalida"; fechaSalida.Value = Regpersonal.fechaSalida; SqlParameter horaSalida = new SqlParameter(); horaSalida.SqlDbType = System.Data.SqlDbType.NVarChar; horaSalida.ParameterName = "@HoraSalida"; horaSalida.Value = Regpersonal.horaSalida; #endregion #region Agregando en la lista de valores lstparametros.Add(codEntrada); lstparametros.Add(fechaSalida); lstparametros.Add(horaSalida); #endregion //Asigna al atributo de la clase SQLSentencia la lista de valores sentencia.LSTPARAMETROS = lstparametros; Acceso objconexion = new Acceso(); return(objconexion.Ejecutar_TSQL(sentencia)); } catch (Exception ex) { throw ex; } }
private RegistroPersonal procesobase() { RegistroPersonal personal = new RegistroPersonal(); string hora, fecha; hora = DateTime.Now.ToString("hh:mm"); fecha = DateTime.Now.ToString("dd/MM/yyyy"); personal.codEntrada = Convert.ToInt32(txtCodigoEmpleado.Text.Trim()); personal.nombreEmpleado = txtNombre.Text.Trim(); personal.identificacion = Convert.ToInt32(txtIdEmpleado.Text.Trim()); personal.posicion = txtPosicion.Text.Trim(); personal.area = txtArea.Text.Trim(); personal.fechaEntrada = fecha; personal.horaEntrada = hora; personal.fechaSalida = fecha; personal.horaSalida = hora; return(personal); }
private void btnAdd_Click(object sender, EventArgs e) { try { RegistroPersonal personal = new RegistroPersonal(); personal.codEntrada = Convert.ToInt32(txtCodigoEmpleado.Text.Trim()); personal.nombreEmpleado = txtNombre.Text.Trim(); personal.identificacion = Convert.ToInt32(txtIdEmpleado.Text.Trim()); personal.posicion = txtPosicion.Text.Trim(); personal.area = txtArea.Text.Trim(); personal.fechaEntrada = ""; personal.horaEntrada = ""; personal.fechaSalida = ""; personal.horaSalida = ""; S02_02LogicaNegocio.Logica.AgregarPersonal(personal); CargarPersonal(); Limpiar(); } catch (Exception ex) { MessageBox.Show("Error \n" + ex.Message + "\nal Guardar Datos en Tabla RegistroPersonal"); } }
private void btn_modificarEmpleado_Click(object sender, EventArgs e) { RegistroPersonal actualizar = new RegistroPersonal(this, _personal); actualizar.Show(); }
private void btn_registrarEmpleado_Click(object sender, EventArgs e) { RegistroPersonal registro = new RegistroPersonal(this); registro.Show(); }
public static int ModificarPersonal(RegistroPersonal Regpersonal) { try { ArrayList lstparametros = new ArrayList(); //se define lista de valores SQLSentencia sentencia = new SQLSentencia(); sentencia.PETICION = @"UPDATE RegistroPersonal SET nombreEmpleado= @nombreEmpleado, identificacion= @identificacion, posicion= @posicion, area= @area WHERE codEntrada=@codEntrada"; //, //fechaEntrada = @fechaEntrada, horaEntrada = @horaEntrada, fechaSalida = @fechaSalida, horaSalida = @horaSalida #region Definicion de parametros SqlParameter codEntrada = new SqlParameter(); codEntrada.SqlDbType = System.Data.SqlDbType.Int; codEntrada.ParameterName = "@codEmpleado"; codEntrada.Value = Regpersonal.codEntrada; SqlParameter nombreEmpleado = new SqlParameter(); nombreEmpleado.SqlDbType = System.Data.SqlDbType.NVarChar; nombreEmpleado.ParameterName = "@nombreEmpleado"; nombreEmpleado.Value = Regpersonal.nombreEmpleado; SqlParameter identificacion = new SqlParameter(); identificacion.SqlDbType = System.Data.SqlDbType.NVarChar; identificacion.ParameterName = "@identificacion"; identificacion.Value = Regpersonal.identificacion; SqlParameter posicion = new SqlParameter(); posicion.SqlDbType = System.Data.SqlDbType.NVarChar; posicion.ParameterName = "@posicion"; posicion.Value = Regpersonal.posicion; SqlParameter area = new SqlParameter(); area.SqlDbType = System.Data.SqlDbType.NVarChar; area.ParameterName = "@area"; area.Value = Regpersonal.area; /*SqlParameter fechaEntrada = new SqlParameter(); * fechaEntrada.SqlDbType = System.Data.SqlDbType.NVarChar; * fechaEntrada.ParameterName = "--/--/--"; * fechaEntrada.Value = Regpersonal.fechaEntrada; * * SqlParameter horaEntrada = new SqlParameter(); * horaEntrada.SqlDbType = System.Data.SqlDbType.NVarChar; * horaEntrada.ParameterName = "--:--"; * horaEntrada.Value = Regpersonal.horaEntrada; * * SqlParameter fechaSalida = new SqlParameter(); * fechaSalida.SqlDbType = System.Data.SqlDbType.NVarChar; * fechaSalida.ParameterName = "--/--/--"; * fechaSalida.Value = Regpersonal.fechaSalida; * * SqlParameter horaSalida = new SqlParameter(); * horaSalida.SqlDbType = System.Data.SqlDbType.NVarChar; * horaSalida.ParameterName = "--:--"; * horaSalida.Value = Regpersonal.horaSalida;*/ #endregion #region Agregando en la lista de valores lstparametros.Add(codEntrada); lstparametros.Add(nombreEmpleado); lstparametros.Add(identificacion); lstparametros.Add(posicion); lstparametros.Add(area); /*lstparametros.Add(fechaEntrada); * lstparametros.Add(horaEntrada); * lstparametros.Add(fechaSalida); * lstparametros.Add(horaSalida);*/ #endregion //Asigna al atributo de la clase SQLSentencia la lista de valores sentencia.LSTPARAMETROS = lstparametros; Acceso objconexion = new Acceso(); return(objconexion.Ejecutar_TSQL(sentencia)); } catch (Exception ex) { throw ex; } }
public static int AgregarPersonal(RegistroPersonal Regpersonal) { try { ArrayList lstparametros = new ArrayList(); //se define lista de valores SQLSentencia sentencia = new SQLSentencia(); //Armo la peticion sentencia.PETICION = @"INSERT INTO RegistroPersonal VALUES (@nombreEmpleado, @identificacion, @posicion, @area, @fechaEntrada, @horaEntrada, @fechaSalida, @horaSalida)"; #region Definicion de parametros //SqlParameter codEmpleado = new SqlParameter(); //codEmpleado.SqlDbType = System.Data.SqlDbType.Int; //codEmpleado.ParameterName = "@codEmpleado"; //codEmpleado.Value = Regpersonal.codEmpleado; SqlParameter nombreEmpleado = new SqlParameter(); nombreEmpleado.SqlDbType = System.Data.SqlDbType.NVarChar; nombreEmpleado.ParameterName = "@nombreEmpleado"; nombreEmpleado.Value = Regpersonal.nombreEmpleado; SqlParameter identificacion = new SqlParameter(); identificacion.SqlDbType = System.Data.SqlDbType.NVarChar; identificacion.ParameterName = "@identificacion"; identificacion.Value = Regpersonal.identificacion; SqlParameter posicion = new SqlParameter(); posicion.SqlDbType = System.Data.SqlDbType.NVarChar; posicion.ParameterName = "@posicion"; posicion.Value = Regpersonal.posicion; SqlParameter area = new SqlParameter(); area.SqlDbType = System.Data.SqlDbType.NVarChar; area.ParameterName = "@area"; area.Value = Regpersonal.area; SqlParameter fechaEntrada = new SqlParameter(); fechaEntrada.SqlDbType = System.Data.SqlDbType.NVarChar; fechaEntrada.ParameterName = "@fechaEntrada"; fechaEntrada.Value = Regpersonal.fechaEntrada; SqlParameter horaEntrada = new SqlParameter(); horaEntrada.SqlDbType = System.Data.SqlDbType.NVarChar; horaEntrada.ParameterName = "@horaEntrada"; horaEntrada.Value = Regpersonal.horaEntrada; SqlParameter fechaSalida = new SqlParameter(); fechaSalida.SqlDbType = System.Data.SqlDbType.NVarChar; fechaSalida.ParameterName = "@fechaSalida"; fechaSalida.Value = Regpersonal.fechaSalida; SqlParameter horaSalida = new SqlParameter(); horaSalida.SqlDbType = System.Data.SqlDbType.NVarChar; horaSalida.ParameterName = "@horaSalida"; horaSalida.Value = Regpersonal.horaSalida; #endregion #region Agregando en la lista de valores //lstparametros.Add(codEmpleado); lstparametros.Add(nombreEmpleado); lstparametros.Add(identificacion); lstparametros.Add(posicion); lstparametros.Add(area); lstparametros.Add(fechaEntrada); lstparametros.Add(horaEntrada); lstparametros.Add(fechaSalida); lstparametros.Add(horaSalida); #endregion //Asigna al atributo de la clase SQLSentencia la lista de valores sentencia.LSTPARAMETROS = lstparametros; Acceso objconexion = new Acceso(); return(objconexion.Ejecutar_TSQL(sentencia)); } catch (Exception ex) { throw ex; } }