private void btnActualizar_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count > 0) { if (dataGridView1.SelectedRows.Count > 0) { Form frm = Application.OpenForms.Cast <Form>().FirstOrDefault(x => x is FrmRegistrarEmpleados); if (frm != null) { //si la instancia existe la pongo en primer plano frm.BringToFront(); return; } else { FrmRegistrarEmpleados E = new FrmRegistrarEmpleados(); E.txtIdE.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString(); Program.IdCargo = Convert.ToInt32(dataGridView1.CurrentRow.Cells[1].Value.ToString()); E.txtDni.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString(); E.txtApellidos.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString(); E.txtNombres.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString(); if (dataGridView1.CurrentRow.Cells[5].Value.ToString() == "M") { E.rbnMasculino.Checked = true; } else { E.rbnFemenino.Checked = true; } E.dateTimePicker1.Value = Convert.ToDateTime(dataGridView1.CurrentRow.Cells[6].Value.ToString()); E.txtDireccion.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString(); if (dataGridView1.CurrentRow.Cells[8].Value.ToString() == "S") { E.cbxEstadoCivil.SelectedIndex = 1; } else if (dataGridView1.CurrentRow.Cells[8].Value.ToString() == "C") { E.cbxEstadoCivil.SelectedIndex = 2; } else if (dataGridView1.CurrentRow.Cells[8].Value.ToString() == "D") { E.cbxEstadoCivil.SelectedIndex = 3; } else { E.cbxEstadoCivil.SelectedIndex = 4; } E.Show(); } } else { DevComponents.DotNetBar.MessageBoxEx.Show("Seleccione un empleado para modificar.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } dataGridView1.ClearSelection(); timer1.Start(); } }
private void Empleados_Click(object sender, EventArgs e) { FrmRegistrarEmpleados E = new FrmRegistrarEmpleados(); E.MdiParent = this; E.Show(); }
private void btnNuevo_Click(object sender, EventArgs e) { FrmRegistrarEmpleados E = new FrmRegistrarEmpleados(); E.txtIdE.Text = "0"; Program.IdCargo = 0; E.Show(); dataGridView1.ClearSelection(); }
private void btnActualizar_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count > 0) { if (dataGridView1.SelectedRows.Count > 0) { FrmRegistrarEmpleados E = new FrmRegistrarEmpleados(); E.txtIdE.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString(); Program.IdCargo = Convert.ToInt32(dataGridView1.CurrentRow.Cells[1].Value.ToString()); E.txtDni.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString(); E.txtApellidos.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString(); E.txtNombres.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString(); E.label11.Text = "Actualizar Empleado"; E.btnGrabar.Text = "Actualizar"; if (dataGridView1.CurrentRow.Cells[5].Value.ToString() == "M") { E.rbnMasculino.Checked = true; } else { E.rbnFemenino.Checked = true; } E.dateTimePicker1.Value = Convert.ToDateTime(dataGridView1.CurrentRow.Cells[6].Value.ToString()); E.txtDireccion.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString(); if (dataGridView1.CurrentRow.Cells[8].Value.ToString() == "S") { E.cbxEstadoCivil.SelectedIndex = 1; } else if (dataGridView1.CurrentRow.Cells[8].Value.ToString() == "C") { E.cbxEstadoCivil.SelectedIndex = 2; } else if (dataGridView1.CurrentRow.Cells[8].Value.ToString() == "D") { E.cbxEstadoCivil.SelectedIndex = 3; } else { E.cbxEstadoCivil.SelectedIndex = 4; } E.Show(); } dataGridView1.ClearSelection(); } }
private void btnNuevo_Click(object sender, EventArgs e) { FrmRegistrarEmpleados E = new FrmRegistrarEmpleados(); //E.txtIdE.Text = "0"; //CDA05 Program.IdCargo = 0; Form frm = Application.OpenForms.Cast <Form>().FirstOrDefault(x => x is FrmRegistrarEmpleados); if (frm != null) { //si la instancia existe la pongo en primer plano frm.BringToFront(); return; } //sino existe la instancia se crea una nueva frm = new FrmRegistrarEmpleados(); frm.Show(); //E.Show(); dataGridView1.ClearSelection(); MostrarListadoEmpleados(); }