private void CargarDatos() { cls_TiposEmpleados_BLL Obj_Tipos_Empleados__BLL = new cls_TiposEmpleados_BLL(); string sMsjError = string.Empty; DataTable dtEstados = new DataTable(); if (txtFiltro.Text == string.Empty) { dtEstados = Obj_Tipos_Empleados__BLL.ListarTiposEmpleados(ref sMsjError); } else { dtEstados = Obj_Tipos_Empleados__BLL.FiltrarTiposEmpleados(ref sMsjError, txtFiltro.Text.Trim()); } if (sMsjError == string.Empty) { dgv_view.DataSource = null; dgv_view.DataSource = dtEstados; } else { dgv_view.DataSource = null; MessageBox.Show("Se Presentó un error : [ " + sMsjError + " ].", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_Eliminar_Click(object sender, EventArgs e) { cls_TiposEmpleados_BLL objBLL = new cls_TiposEmpleados_BLL(); string sMsjError = string.Empty; if (dgv_view.Rows.Count > 0) { if (MessageBox.Show("Realmente desea eliminar?", "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { objBLL.Eliminar_TipoEmpleado(ref sMsjError, dgv_view.SelectedRows[0].Cells[0].Value.ToString()); if (sMsjError != string.Empty) { MessageBox.Show("Se presento un error a la hora de listar : [ " + sMsjError + " ]", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Registro eliminado correctamente", "Listo", MessageBoxButtons.OK, MessageBoxIcon.Information); CargarDatos(); } txtFiltro.Text = string.Empty; } } else { MessageBox.Show("No hay registros para eliminar"); } }
private void btnGuardar_Click(object sender, EventArgs e) { if (cmb_IDEstado.SelectedValue.ToString() != "0" || txt_IDTipoEmpleado.Text != string.Empty || txt_desc.Text != string.Empty) { cls_TiposEmpleados_BLL obj_TipoEmpleado_BLL = new cls_TiposEmpleados_BLL(); string sMsjError = string.Empty; Obj_DAL_TipoEmpleado.SDescTipo = txt_desc.Text.Trim(); Obj_DAL_TipoEmpleado.CIdEstado = Convert.ToChar(cmb_IDEstado.SelectedValue.ToString().Trim()); if (Obj_DAL_TipoEmpleado.CBandAX == 'I') { obj_TipoEmpleado_BLL.Insertar_TipoEmpleado(ref sMsjError, ref Obj_DAL_TipoEmpleado); if (sMsjError == string.Empty) { MessageBox.Show("Se han ingresado los datos correctamente"); Obj_DAL_TipoEmpleado.CBandAX = 'U'; toolStripLabel3.Text = "Modificar"; } else { MessageBox.Show("Se presento un error al tratar de guardar el registro" + "[ " + sMsjError + " ]"); } } else { obj_TipoEmpleado_BLL.Modificar_TipoEmpleado(ref sMsjError, ref Obj_DAL_TipoEmpleado); if (sMsjError == string.Empty) { MessageBox.Show("Se modificó el registro exitosamente"); Obj_DAL_TipoEmpleado.CBandAX = 'U'; } else { MessageBox.Show("Se presento un error al tratar de guardar el registro" + "[ " + sMsjError + " ]"); } } } else { MessageBox.Show("Todos los cambios son obligatorios", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void CargarDatos() { if (Obj_Empleados_DAL != null) { string M_Error = string.Empty; #region Estados cls_Estados_BLL ObjEstados = new cls_Estados_BLL(); DataTable DT_Estados = new DataTable(); DT_Estados = ObjEstados.Listar_Estados(ref M_Error); cb_Estado.DataSource = DT_Estados; DT_Estados.Rows.Add("0", "-- Seleccione un valor --"); cb_Estado.DisplayMember = DT_Estados.Columns[1].ToString(); cb_Estado.ValueMember = DT_Estados.Columns[0].ToString(); cb_Estado.SelectedValue = "0"; #endregion #region ID Tipo Empleado cls_TiposEmpleados_BLL ObjTipoEmpleados = new cls_TiposEmpleados_BLL(); DataTable DT_TipoEmpleados = new DataTable(); DT_TipoEmpleados = ObjTipoEmpleados.ListarTiposEmpleados(ref M_Error); DT_TipoEmpleados.Rows.Add("0", "-- Seleccione un valor --"); cb_TipoEmpleado.DataSource = DT_TipoEmpleados; cb_TipoEmpleado.DisplayMember = DT_TipoEmpleados.Columns[1].ToString(); cb_TipoEmpleado.ValueMember = DT_TipoEmpleados.Columns[0].ToString(); cb_TipoEmpleado.SelectedValue = "0"; #endregion #region ID Aerolinea cls_Aerolineas_BLL ObjAerolinea = new cls_Aerolineas_BLL(); DataTable DT_Aerolinea = new DataTable(); DT_Aerolinea = ObjAerolinea.ListarAerolineas(ref M_Error); DT_Aerolinea.Rows.Add("0", "-- Seleccione un valor --"); cb_IdAerolinea.DataSource = DT_Aerolinea; cb_IdAerolinea.DisplayMember = DT_Aerolinea.Columns[1].ToString(); cb_IdAerolinea.ValueMember = DT_Aerolinea.Columns[0].ToString(); cb_IdAerolinea.SelectedValue = "0"; #endregion if (Obj_Empleados_DAL.cBandera == 'I') { txt_Direccion.Clear(); txt_Nombre.Clear(); txt_Apellidos.Clear(); txt_Edad.Clear(); txt_IdEmpleado.Clear(); txt_Salario.Clear(); txt_Cedula.Clear(); txt_Celular.Clear(); txt_TelCasa.Clear(); txt_TelRef.Clear(); } else { toolStripLabel1.Text = "Modificar"; txt_Direccion.Text = Obj_Empleados_DAL.sDireccion; txt_Nombre.Text = Obj_Empleados_DAL.sNombre; txt_Apellidos.Text = Obj_Empleados_DAL.sApellidos; txt_Edad.Text = Obj_Empleados_DAL.bEdad.ToString().Trim(); txt_IdEmpleado.Text = Obj_Empleados_DAL.sIdEmpleado.ToString().Trim(); txt_Salario.Text = Obj_Empleados_DAL.dSalario.ToString().Trim(); txt_Cedula.Text = Obj_Empleados_DAL.iCedula.ToString().Trim(); txt_Celular.Text = Obj_Empleados_DAL.iCelular.ToString().Trim(); txt_TelCasa.Text = Obj_Empleados_DAL.iTelCasa.ToString().Trim(); txt_TelRef.Text = Obj_Empleados_DAL.iTelRef.ToString().Trim(); cb_Estado.SelectedValue = Obj_Empleados_DAL.cIdEstado.ToString().Trim(); cb_IdAerolinea.SelectedValue = Obj_Empleados_DAL.iIdAerolinea.ToString().Trim(); cb_TipoEmpleado.SelectedValue = Obj_Empleados_DAL.iIdTipoEmpleado.ToString().Trim(); } } else { MessageBox.Show("Se presentó un error \nContacte al administrador", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }