InicioCiencia EducacionRegistro de Personal en C#
Hola amigos aki les comparto este sistemita que te permite tener el contro de una planilla de empleados.





Codigo c#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace DemoRegistroDePersonal
{
public partial class Form1Loggin : Form
{
SqlConnection cnn = new SqlConnection(Properties.Settings.Default.strCnn);



public Form1Loggin()
{
InitializeComponent();
}

private void btncalcen_Click(object sender, EventArgs e)
{
this.Close();
}

private void btnLoggin_Click(object sender, EventArgs e)
{
cnn.Open();
SqlCommand sql = new SqlCommand(" select *from Usuarios where nombre = '" + txtUsuario.Text + "'and pass='" + txtPass.Text + "'", cnn);
SqlDataReader leer = sql.ExecuteReader();
if ((txtUsuario.Text == "" || (txtPass.Text == "")
{
MessageBox.Show("Debe llenar todos los campos...", "Faltan datos...";
cnn.Close();
clsB();
}
else
{
if (leer.Read() == true)
{
MessageBox.Show("Bienvenido " + txtUsuario.Text, "Aviso!";
this.Hide();
Form2Principal frmPrincipal = new Form2Principal();
frmPrincipal.Show();
}
else
{
MessageBox.Show("Error! Imposible conectar a la Base de Datos...", "Error!";
clsB();
cnn.Close();
}
}
}
private void clsB()
{
txtPass.Clear();
txtUsuario.Clear();
txtUsuario.Focus();
}

private void Form1Loggin_Load(object sender, EventArgs e)
{

}
}
}














Código C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;//Para sql

namespace DemoRegistroDePersonal
{
public partial class Form2Principal : Form
{
SqlConnection cnn = new SqlConnection(Properties.Settings.Default.strCnn);
public Form2Principal()
{
InitializeComponent();
}

private void btnSalir_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}

private void Form2Principal_Load(object sender, EventArgs e)
{
cargarInfo();

}
public void cargarInfo()
{
SqlCommand sql = new SqlCommand("Select *from Personal",cnn);
cnn.Open();
SqlDataReader leer = sql.ExecuteReader();
dgv.Rows.Clear();
int enter = 0;
while (leer .Read())
{
enter = dgv.Rows.Add();
dgv.Rows[enter].Cells["Id"].Value = leer.GetString(0);
dgv.Rows[enter].Cells["Nombres"].Value = leer.GetString(1);
dgv.Rows[enter].Cells["Apellidos"].Value = leer.GetString(2);
dgv.Rows[enter].Cells["Direccion"].Value = leer.GetString(3);
dgv.Rows[enter].Cells["Telefono"].Value = leer.GetString(4);
dgv.Rows[enter].Cells["Email"].Value = leer.GetString(5);
dgv.Rows[enter].Cells["Sexo"].Value = leer.GetInt32(6);
dgv.Rows[enter].Cells["Pais"].Value = leer.GetInt32(7);
dgv.Rows[enter].Cells["Departamento"].Value = leer.GetInt32(8);
dgv.Rows[enter].Cells["dui_pasaporte"].Value = leer.GetString(9);
}
cnn.Close();

}

private void btnAgregar_Click(object sender, EventArgs e)
{
this.Hide();
Form3Agregar frmAgregar = new Form3Agregar();
frmAgregar.Show();

}

private void btnEditar_Click(object sender, EventArgs e)
{
Form4Editar frmEditar = new Form4Editar();
string camposeleccionado=(string )dgv .CurrentRow .Cells ["Id"].Value ;
frmEditar.PersonaSeleccionada = camposeleccionado;
this.Hide();
frmEditar.MdiParent = this.MdiParent ;
frmEditar.Show();

}

private void dgv_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{

}

private void dgv_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
this.DialogResult = DialogResult.OK;

}


private void btnborrrar(object sender, EventArgs e)
{
DialogResult resp= MessageBox.Show("Seguro que de sea borrar este registro","Aviso",MessageBoxButtons .YesNo ,MessageBoxIcon .Question);

if (resp== DialogResult.No)
{
return;
}
else
{
MessageBox.Show("ai lo ases bien";
}
}

private void salirToolStripMenuItem_Click(object sender, EventArgs e)
{
DialogResult resp = MessageBox.Show("Seguro que de sea salir", "Aviso!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

if (resp == DialogResult.No)
{
return;
}
else
{
this.Close();
}
}

private void agregarToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Hide();
Form3Agregar frmAgregar = new Form3Agregar();
frmAgregar.Show();
}

private void editarToolStripMenuItem_Click(object sender, EventArgs e)
{
Form4Editar frmEditar = new Form4Editar();
string camposeleccionado = (string)dgv.CurrentRow.Cells["Id"].Value;
frmEditar.PersonaSeleccionada = camposeleccionado;
this.Hide();
frmEditar.MdiParent = this.MdiParent;
frmEditar.Show();
}

private void borrarToolStripMenuItem_Click(object sender, EventArgs e)
{
DialogResult resp = MessageBox.Show("Seguro que de sea borrar este registro", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

if (resp == DialogResult.No)
{
return;
}
else
{
MessageBox.Show("Registro Eliminado...";
}
}

private void verLaAyudaToolStripMenuItem_Click(object sender, EventArgs e)
{
Form5Ayuda frmayuda = new Form5Ayuda();
frmayuda.Show();

}

private void acercaToolStripMenuItem1_Click(object sender, EventArgs e)
{
MessageBox.Show(" Acerca de este soft.nHecho por: Asael M. nEmail: [email protected] nfacebook/jolmanAsael ","Acerca... v 1.0.0";
}
//

}
}








Código c#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace DemoRegistroDePersonal
{
public partial class Form3Agregar : Form
{
SqlConnection cnn = new SqlConnection(Properties.Settings.Default.strCnn);
public Form3Agregar()
{
InitializeComponent();
}

private void Form3Agregar_Load(object sender, EventArgs e)
{
// TODO: esta línea de código carga datos en la tabla 'dsReporte.dt_Sexo' Puede moverla o quitarla según sea necesario.
this.ta_Sexo.Fill(this.dsReporte.dt_Sexo);
cmdSexo.DataSource = dsReporte.dt_Sexo;
cmdSexo.DisplayMember = dsReporte.dt_Sexo.Columns[1].ToString();
cmdSexo.ValueMember = dsReporte.dt_Sexo.Columns[0].ToString();

// TODO: esta línea de código carga datos en la tabla 'dsReporte.dt_Departamentos' Puede moverla o quitarla según sea necesario.
this.ta_Departamentos.Fill(this.dsReporte.dt_Departamentos);
cmbDepa.DataSource = dsReporte.dt_Departamentos;
cmbDepa.DisplayMember = dsReporte.dt_Departamentos.Columns[1].ToString();
cmbDepa.ValueMember = dsReporte.dt_Departamentos.Columns[0].ToString();

// TODO: esta línea de código carga datos en la tabla 'dsReporte.dt_Paises' Puede moverla o quitarla según sea necesario.
this.ta_Paises.Fill(this.dsReporte.dt_Paises);
cmbPaises.DataSource = dsReporte.dt_Paises;
cmbPaises.DisplayMember =dsReporte.dt_Paises.Columns[1].ToString();
cmbPaises.ValueMember = dsReporte.dt_Paises.Columns[0].ToString();



}

private void btnSalir_Click(object sender, EventArgs e)
{
this.Close();
}

private void btnGuardar_Click(object sender, EventArgs e)
{
//Validamos los campo que creamos necesarios sean obligatorio llenarlos.
if (!validarAlgunosCampos())
return;
//
SqlCommand sqlcmd = new SqlCommand("Insert into Personal(id, Nombres, Apellidos, Direccion, Telefono,Email,Id_Sexo,id_pais,Id_Departamentos,dui_pasaporte) values(@id,@Nombres,@Apellidos,@Direccion,@Telefono,@Email,@Id_Sexo,@id_pais,@Id_Departamentos,@dui_pasaporte)", cnn);

sqlcmd.Parameters.AddWithValue("id", txtid.Text);
sqlcmd.Parameters.AddWithValue("Nombres", txtnombres.Text);
sqlcmd.Parameters.AddWithValue("Apellidos", txtapellidos.Text);
sqlcmd.Parameters.AddWithValue("Direccion", txtdir.Text);
sqlcmd.Parameters.AddWithValue("Telefono", txttel.Text);
sqlcmd.Parameters.AddWithValue("Email", txtemail.Text);
sqlcmd.Parameters.AddWithValue("Id_Sexo",cmdSexo .SelectedValue );
sqlcmd.Parameters.AddWithValue("id_pais", cmbPaises.SelectedValue);
sqlcmd.Parameters.AddWithValue("Id_Departamentos", cmbDepa .SelectedValue);
sqlcmd.Parameters.AddWithValue("dui_pasaporte", txtdui.Text);
cnn.Open();
sqlcmd.ExecuteNonQuery();
MessageBox.Show("Los datos de: "+txtnombres.Text +" "+txtapellidos.Text +" fueron guardados sastifacoriamente...","Aviso::Registro de Personal";
this.Hide();
Form2Principal frmprincipal = new Form2Principal();
frmprincipal.Show();
clsTextbox();
cnn.Close();
}
//Limpiamos los texbox
public void clsTextbox()
{
txtid.Clear();
txtnombres.Clear();
txtapellidos.Clear();
txtdir.Clear();
txttel.Clear();
txtemail.Clear();
txtdui.Clear();
}

private void btnRegresar_Click(object sender, EventArgs e)
{
Form2Principal frmprincipal = new Form2Principal();
frmprincipal.Show();
}
//Evento: solo acepta numeros en el campo id
private void txtid_KeyPress(object sender, KeyPressEventArgs e)
{

if (char.IsDigit(e.KeyChar))
{

e.Handled = false;
}
else if (char.IsControl(e.KeyChar))
{

e.Handled = false;

}
else
{

e.Handled = true;

}
}
//valdidamos algunos campos requeridos.
private bool validarAlgunosCampos()
{
bool resultado = true;
errorProvider1.Clear();
int cod=0;
if (!Int32.TryParse(txtid.Text,out cod ))
{
errorProvider1.SetError(txtid, "Debe ingresar la codigo";
resultado = false;
}
if (string.IsNullOrEmpty(txtnombres.Text))
{
errorProvider1.SetError(txtnombres ,"Debe Introducir el Nombre" );
resultado = false;
}
if (string.IsNullOrEmpty(txtapellidos.Text))
{
errorProvider1.SetError(txtapellidos, "Debe Introducir el/los Apellidos..";
resultado = false;
}
if (string.IsNullOrEmpty(txtdir.Text))
{
errorProvider1.SetError(txtdir, "Debe Introducir la direcion..";
resultado = false;
}
if (string.IsNullOrEmpty(txttel.Text))
{
errorProvider1.SetError(txttel, "Debe el numero telefonico..";
resultado = false;
}
if (string.IsNullOrEmpty(txtdui.Text))
{
errorProvider1.SetError(txtdui, "Debe el numero de DUI/PASAPORTE...";
resultado = false;
}

return resultado;
}
private void btnSalir_Click_1(object sender, EventArgs e)
{

this.Close();
}

private void groupBox1_Enter(object sender, EventArgs e)
{

}
}
}



Código c#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace DemoRegistroDePersonal
{
public partial class Form4Editar : Form
{
SqlConnection cnn = new SqlConnection(Properties.Settings.Default.strCnn);
public string PersonaSeleccionada;
public Form4Editar()
{
InitializeComponent();
}

private void Form4Editar_Load(object sender, EventArgs e)
{
cargarInfo();

}

void cargarInfo()
{
SqlCommand sql = new SqlCommand("select *from Personal where id=" + PersonaSeleccionada, cnn);
cnn.Open();
SqlDataReader leer = sql.ExecuteReader();
if (leer.Read())
{
txtid.Text = leer.GetString(0);
txtnombres.Text = leer.GetString(1);
txtapellidos.Text = leer.GetString(2);
txtdir.Text = leer.GetString(3);
txttel.Text = leer.GetString(4);
txtemail.Text = leer.GetString(5);
txtsexo.Text = leer.GetInt32 (6).ToString();
txtpais.Text = leer.GetInt32(7).ToString();
txtdepa.Text = leer.GetInt32(8).ToString();
txtdui.Text = leer.GetString(9);

}
cnn.Close();
}

private void btnRegresar_Click(object sender, EventArgs e)
{
this.Hide();
Form2Principal frmPrincipal = new Form2Principal();
frmPrincipal.Show();
}

private void btnGuardar_Click(object sender, EventArgs e)
{

SqlCommand sqlcomando = new SqlCommand("update Personal set [email protected] , [email protected] , [email protected] , [email protected] , [email protected] , [email protected] , [email protected] , [email protected] , [email protected] _pasaporte where [email protected] ", cnn);

sqlcomando.Parameters.AddWithValue("id", PersonaSeleccionada);
sqlcomando.Parameters.AddWithValue("Nombres", txtnombres.Text);
sqlcomando.Parameters.AddWithValue("Apellidos", txtapellidos.Text);
sqlcomando.Parameters.AddWithValue("Direccion", txtdir.Text);
sqlcomando.Parameters.AddWithValue("Telefono", txttel.Text);
sqlcomando.Parameters.AddWithValue("Email", txtemail.Text);
sqlcomando.Parameters.AddWithValue("Sexo", txtsexo.Text);
sqlcomando.Parameters.AddWithValue("Pais", txtpais.Text);
sqlcomando.Parameters.AddWithValue("Departamento", txtdepa.Text);
sqlcomando.Parameters.AddWithValue("dui_pasaporte", txtdui.Text);

cnn.Open();
sqlcomando.ExecuteNonQuery();
cnn.Close();

MessageBox.Show("Los Datos han sido actualizados correctamente";

this.Hide();
Form2Principal frmPrincipal = new Form2Principal();
frmPrincipal.Show();
}

private void btnSalir_Click(object sender, EventArgs e)
{
this.Close();
}

}
}




Código c#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DemoRegistroDePersonal
{
public partial class Form5Ayuda : Form
{
public Form5Ayuda()
{
InitializeComponent();
}

private void btnsalir_Click(object sender, EventArgs e)
{
this.Close();
}

private void label1_Click(object sender, EventArgs e)
{

}
}
}

































Sistema de Registro de personal.
Demostración por Asael M.

Codigoo




La base de datos quedaria asi




Datos archivados del Taringa! original
26puntos
2,223visitas
0comentarios
Actividad nueva en Posteamelo
0puntos
2visitas
0comentarios
Dar puntos:

Dejá tu comentario

0/2000

Autor del Post

j
jolmanAsael🇦🇷
Usuario
Puntos0
Posts4
Ver perfil →
PosteameloArchivo Histórico de Taringa! (2004-2017). Preservando la inteligencia colectiva de la internet hispanohablante.

CONTACTO

18 de Septiembre 455, Casilla 52

Chillán, Región de Ñuble, Chile

Solo correo postal

© 2026 Posteamelo.com. No afiliado con Taringa! ni sus sucesores.

Contenido preservado con fines históricos y culturales.