private void BtnActualizar_Click(object sender, EventArgs e) { try { string Rpta = ""; if (TxtNombreDepto.Text == string.Empty || CboRol.Text == string.Empty || CboContrato.Text == string.Empty) { this.MensajeError("Se deben rellenar todos los datos obligatorios, seran remarcados."); ErrorIcono.SetError(TxtNombreDepto, "Ingrese un departamento."); ErrorIcono.SetError(CboRol, "Ingrese un Rol"); ErrorIcono.SetError(CboContrato, "Ingrese un Contrato"); } else { Rpta = NDepartamento.Actualizar(Convert.ToInt32(txtId.Text.Trim()), this.nomAnterior, TxtNombreDepto.Text.Trim(), Convert.ToInt32(CboRol.SelectedValue), Convert.ToInt32(CboContrato.SelectedValue)); if (Rpta.Equals("OK")) { this.MensajeOk("Se actualizó de forma correcta el registro"); this.Limpiar(); this.Listar(); } else { this.MensajeError(Rpta); } } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
void CargarDepartamento() { NDepartamento n = new NDepartamento(); List <EDepartamentos> d = n.ListaDepartamento(); cbmDepartmento.DataSource = d; cbmDepartmento.DisplayMember = "Departamento"; cbmDepartmento.ValueMember = "DepartamentoID"; cbmDepartmento.Text = "Seleccione un Departamento"; }
private void DgvListado_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == DgvListado.Columns["Seleccionar"].Index) { DataGridViewCheckBoxCell Chkeliminar = (DataGridViewCheckBoxCell)DgvListado.Rows[e.RowIndex].Cells["Seleccionar"]; Chkeliminar.Value = !Convert.ToBoolean(Chkeliminar.Value); } //Cell content click para el icono de eliminar if (e.ColumnIndex == DgvListado.Columns["Eliminar"].Index) { try { DialogResult opcion; opcion = MessageBox.Show("Realmente deseas eliminar el registro?", "Control de Tareas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (opcion == DialogResult.OK) { int codigo; string Rpta = ""; codigo = Convert.ToInt32(DgvListado.CurrentRow.Cells[3].Value.ToString()); Rpta = NDepartamento.Eliminar(codigo); if (Rpta.Equals("OK")) { this.MensajeOk("Se elimino el registro: " + Convert.ToString(DgvListado.CurrentRow.Cells[4].Value)); } else { this.MensajeError(Rpta); } this.Listar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } } //Cell Content Click para el icono de editar if (e.ColumnIndex == DgvListado.Columns["Editar"].Index) { this.Limpiar(); BtnActualizar.Visible = true; BtnInsertar.Visible = false; txtId.Text = Convert.ToString(DgvListado.CurrentRow.Cells["id"].Value); this.nomAnterior = Convert.ToString(DgvListado.CurrentRow.Cells["nombre"].Value); TxtNombreDepto.Text = Convert.ToString(DgvListado.CurrentRow.Cells["nombre"].Value); CboRol.Text = Convert.ToString(DgvListado.CurrentRow.Cells["rol"].Value); CboContrato.Text = Convert.ToString(DgvListado.CurrentRow.Cells["contrato"].Value); TabGeneral.SelectedIndex = 1; } }
private void CargarDepaBuscar() { try { CboBuscarDepa.DataSource = NDepartamento.Listar(); CboBuscarDepa.ValueMember = "id"; CboBuscarDepa.DisplayMember = "nombre"; } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void BtnBuscar_Click(object sender, EventArgs e) { try { DgvListado.DataSource = NDepartamento.Buscar(TxtBuscar.Text); this.Limpiar(); LblTotal.Text = "Total Registros: " + Convert.ToString(DgvListado.Rows.Count); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
//Cargar Lista de Departamento void CargarDepartamento() { try { NDepartamento n = new NDepartamento(); List <EDepartamentos> d = n.ListaDepartamento(); dataGridView1.DataSource = d; dataGridView1.Columns[0].Visible = false; } catch (Exception ex) { throw ex; } }
private void btnGuardar_Click_1(object sender, EventArgs e) { try { string rpta = ""; if (this.txtNombre.Text == string.Empty) { MensajeError("Falta ingresar algunos datos, serán remarcados"); errorIcono.SetError(txtNombre, "Ingrese un Nombre"); } else { if (this.IsNuevo) { rpta = NDepartamento.Insertar(this.txtNombre.Text, this.txtDes.Text); } else { rpta = NDepartamento.Editar(Convert.ToInt32(this.txtIdDepartamento.Text), this.txtNombre.Text, this.txtDes.Text); } if (rpta.Equals("OK")) { if (this.IsNuevo) { this.MensajeOk("Se Insertó de forma correcta el registro"); } else { this.MensajeOk("Se Actualizó de forma correcta el registro"); } } else { this.MensajeError(rpta); } this.Mostrar(); this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void CargarRolDepto() { try { try { CboRol.DataSource = NDepartamento.CargarRolDepto(); CboRol.ValueMember = "id_rol"; CboRol.DisplayMember = "nombre"; } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void Listar() { try { DgvListado.DataSource = NDepartamento.Listar(); this.Limpiar(); LblTotal.Text = "Total Registros: " + Convert.ToString(DgvListado.Rows.Count); //if (DgvListado.Columns[row.Count].Name == "Departamento TI") //{ // LblTotal.Text = "Total Registros: " + Convert.ToString(DgvListado.Rows.Count); //} //e.ColumnIndex == DgvListado.Columns["Editar"].Index //Convert.ToBoolean(row.Cells["ID"].Value) } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void eliminarToolStripMenuItem_Click(object sender, EventArgs e) { try { EDepartamentos d = new EDepartamentos(); NDepartamento n = new NDepartamento(); d.DepartamentoID = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["DepartamentoID"].Value.ToString()); var Departamento = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["Departamento"].Value.ToString(); DialogResult o = MessageBox.Show("¿Eliminar el Departamento " + Departamento + " ?", "SGA", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (o == DialogResult.OK) { n.EliminarDepartamento(d); MessageBox.Show("Departamento Eliminado con exito", "SGA", MessageBoxButtons.OK, MessageBoxIcon.Information); CargarDepartamento(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnguardar_Click(object sender, EventArgs e) { try { //Veerificamos si guarda o Moficica si la Bandera = 0 Guarda, si es 1 Modifica if (Bandera == 0) { EDepartamentos d = new EDepartamentos(); NDepartamento n = new NDepartamento(); d.Departamento = txtdepartamento.Text; n.IngresarDepartamento(d); //MessageBox.Show("Departamento Ingresado con exito", "SGA", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(); CargarDepartamento(); } if (Bandera == 1) { if (chkeditar.Checked) { EDepartamentos d = new EDepartamentos(); NDepartamento n = new NDepartamento(); d.DepartamentoID = Convert.ToInt32(txtdepartamento.Tag); d.Departamento = txtdepartamento.Text; n.ModificarDepartamento(d); MessageBox.Show("Departamento Modificado con exito", "SGA", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(); CargarDepartamento(); } else { MessageBox.Show("Si desea editar el dato, por favor vuelve a marca la casila EDITAR", "SGA", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "SGA", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnElimnar_Click_1(object sender, EventArgs e) { try { DialogResult Opcion; Opcion = MessageBox.Show("Realmente Desea Eliminar los Registros", "SEGURIDAD DEL SISTEMA", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (Opcion == DialogResult.OK) { string Codigo; string Rpta = ""; foreach (DataGridViewRow row in dataListado.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { Codigo = Convert.ToString(row.Cells[1].Value); Rpta = NDepartamento.Eliminar(Convert.ToInt32(Codigo)); if (Rpta.Equals("OK")) { this.MensajeOk("Se Eliminó Correctamente el registro"); } else { this.MensajeError(Rpta); } } } this.Mostrar(); this.Limpiar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void BtnEliminar_Click(object sender, EventArgs e) { try { DialogResult opcion; opcion = MessageBox.Show("Realmente deseas eliminar el(los) registro(s)?", "Control de Tareas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (opcion == DialogResult.OK) { int codigo; string Rpta = ""; foreach (DataGridViewRow row in DgvListado.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { codigo = Convert.ToInt32(row.Cells[3].Value); Rpta = NDepartamento.Eliminar(codigo); if (Rpta.Equals("OK")) { this.MensajeOk("Se elimino el registro: " + Convert.ToString(row.Cells[4].Value)); } else { this.MensajeError(Rpta); } } } this.Listar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void BuscarNombre() { this.dataListado.DataSource = NDepartamento.BuscarNombre(this.txtBuscar.Text); this.OcultarColumnas(); lblTotal.Text = "Total de Registros: " + Convert.ToString(dataListado.Rows.Count); }
private void Mostrar() { this.dataListado.DataSource = NDepartamento.Mostrar(); this.OcultarColumnas(); lblTotal.Text = "Total de Registros: " + Convert.ToString(dataListado.Rows.Count); }
private void LlenarComboDepartamento() { cbIdDepartamento.DataSource = NDepartamento.Mostrar(); cbIdDepartamento.ValueMember = "Id_Departamento"; cbIdDepartamento.DisplayMember = "Nombre_Dep"; }