0% found this document useful (0 votes)
29 views2 pages

Using Using Using Using Namespace Public Partial Class Public

The document describes code for a form used to update employee information. It initializes dropdown lists for gender, marital status, and operator when the form loads. It populates department, province, and district dropdowns based on previous selection, querying a Ubigeo class. It adds new phone numbers to a datagrid if the number doesn't already exist, calling a method to populate the row.

Uploaded by

RONALDO
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views2 pages

Using Using Using Using Namespace Public Partial Class Public

The document describes code for a form used to update employee information. It initializes dropdown lists for gender, marital status, and operator when the form loads. It populates department, province, and district dropdowns based on previous selection, querying a Ubigeo class. It adds new phone numbers to a datagrid if the number doesn't already exist, calling a method to populate the row.

Uploaded by

RONALDO
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

using

using
using
using

System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;

namespace Proyecto_Csharp.Vistas.Empleados
{
public partial class FormActualizar : Form
{
public FormActualizar()
{
InitializeComponent();
}
private void FormActualizar_Load(object sender, EventArgs e)
{
cbo_genero.SelectedIndex = 0;
cbo_estado_civil.SelectedIndex = 0;
cbo_operador.SelectedIndex = 0;
// INSTANCIAR LA CLASE UBIGEO
var ubigeo = new Clases.Ubigeo();
var tabla = ubigeo.ListarDepartamentos(); ;

if (tabla.Rows.Count > 0)
{
cbo_departamento.DataSource = tabla;
cbo_departamento.DisplayMember = "NOMBRE_DEPARTAMENTO";
cbo_departamento.ValueMember = "DEPARTAMENTO_ID";
}

private void cbo_departamento_SelectedValueChanged(object sender, EventArgs e)


{
// INSTANCIAR LA CLASE UBIGEO
var ubigeo = new Clases.Ubigeo();
var departamentoId = cbo_departamento.SelectedValue.ToString();
var tabla = ubigeo.ListarProvinciasPorDepartamentoId(departamentoId);
if (tabla.Rows.Count > 0)
{
cbo_provincia.DataSource = tabla;
cbo_provincia.DisplayMember = "NOMBRE_PROVINCIA";
cbo_provincia.ValueMember = "PROVINCIA_ID";
}
}
private void cbo_provincia_SelectedValueChanged(object sender, EventArgs e)
{
// INSTANCIAR LA CLASE UBIGEO
var ubigeo = new Clases.Ubigeo();
var provinciaId = cbo_provincia.SelectedValue.ToString();
var tabla = ubigeo.ListarDistritosPorProvinciaId(provinciaId);
if (tabla.Rows.Count > 0)
{

cbo_distrito.DataSource = tabla;
cbo_distrito.DisplayMember = "NOMBRE_DISTRITO";
cbo_distrito.ValueMember = "DISTRITO_ID";
}

private void btn_agregar_Click(object sender, EventArgs e)


{
int numero_filas = dgv_telefonos.Rows.Count;
if (numero_filas == 0)
{
AgregarTelefonos();
}
else
{
bool existe = false;
string numero = txt_numero.Text;
for (int i = 0; i < numero_filas; i++)
{
if (numero.Equals(dgv_telefonos.Rows[i].Cells[1].Value.ToString()))
{
existe = true;
break;
}
}
if (existe)
{
MessageBox.Show("Este telefono ya fue agregado");
}
else
{
AgregarTelefonos();
}
}
}

}
}

private void AgregarTelefonos()


{
string operador = cbo_operador.Text;
string numero = txt_numero.Text;
dgv_telefonos.Rows.Add(operador, numero, "Eliminar");
}

You might also like