Exemplo n.º 1
0
        private void Cargar()
        {
            cls_Empleados_BLL ObjBLL  = new cls_Empleados_BLL();
            string            M_Error = string.Empty;
            DataTable         DT      = new DataTable();

            if (tls_txt_Filtro.Text == string.Empty)
            {
                DT = ObjBLL.Listar_Empleados(ref M_Error);
            }
            else
            {
                DT = ObjBLL.Filtrar_Empleados(ref M_Error, tls_txt_Filtro.Text.Trim());
            }

            if (M_Error == string.Empty)
            {
                dgv_Empleados.DataSource = null;
                dgv_Empleados.DataSource = DT;
            }
            else
            {
                dgv_Empleados.DataSource = null;

                MessageBox.Show("Se presentó un error a la hora de listar los empleados.\n\nDetalle Error : " + M_Error,
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void CargarDatos()
        {
            #region Combo
            string            sMsjError        = string.Empty;
            cls_Estados_BLL   obj_Estado_BLL   = new cls_Estados_BLL();
            cls_Empleados_BLL obj_Empleado_BLL = new cls_Empleados_BLL();

            DataTable DTUe  = new DataTable();
            DataTable DTUEm = new DataTable();

            DTUe  = obj_Estado_BLL.Listar_Estados(ref sMsjError);
            DTUEm = obj_Empleado_BLL.Listar_Empleados(ref sMsjError);

            DTUe.Rows.Add("0", "--- Selecione un Estado ---");
            DTUEm.Rows.Add("0", "--- Selecione un Nombre ---");

            cmb_IdEstado.DataSource   = DTUe;
            cmb_IdEmpleado.DataSource = DTUEm;

            cmb_IdEstado.DisplayMember = DTUe.Columns[1].ToString();
            cmb_IdEstado.ValueMember   = DTUe.Columns[0].ToString();

            cmb_IdEmpleado.DisplayMember = DTUEm.Columns[2].ToString();
            cmb_IdEmpleado.ValueMember   = DTUEm.Columns[0].ToString();

            cmb_IdEmpleado.SelectedValue = "0";
            cmb_IdEstado.SelectedValue   = "0";
            #endregion


            if (Obj_Usuarios_Dal != null)
            {
                if (Obj_Usuarios_Dal.cBandAX == 'I')
                {
                    txt_Username.Enabled       = true;
                    Obj_Usuarios_Dal.sUsername = string.Empty;
                    Obj_Usuarios_Dal.sPassword = string.Empty;
                }
                else
                {
                    txt_Username.Text            = Obj_Usuarios_Dal.sUsername.ToString().Trim();
                    txt_Username.Enabled         = false;
                    txt_Password.Text            = Obj_Usuarios_Dal.sPassword.ToString().Trim();
                    cmb_IdEmpleado.SelectedValue = Obj_Usuarios_Dal.sIdEmpleado.ToString().Trim();
                    cmb_IdEstado.SelectedValue   = Obj_Usuarios_Dal.cIdEstado.ToString().Trim();
                }
            }
            else
            {
                MessageBox.Show("Se presentó un error de capa 8 de programador. \n\nFavor Contactar a soporte técnico", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                this.Close();
            }
        }
Exemplo n.º 3
0
        private void tlsbtn_Guardar_Click(object sender, EventArgs e)
        {
            cls_Empleados_BLL Obj_Empleados_BLL = new cls_Empleados_BLL();
            string            M_Error           = string.Empty;

            Obj_Empleados_DAL.sNombre         = txt_Nombre.Text;
            Obj_Empleados_DAL.sApellidos      = txt_Apellidos.Text;
            Obj_Empleados_DAL.bEdad           = Convert.ToByte(txt_Edad.Text);
            Obj_Empleados_DAL.sDireccion      = txt_Direccion.Text;
            Obj_Empleados_DAL.iCedula         = Convert.ToInt32(txt_Cedula.Text);
            Obj_Empleados_DAL.iCelular        = Convert.ToInt32(txt_Celular.Text);
            Obj_Empleados_DAL.iTelCasa        = Convert.ToInt32(txt_TelCasa.Text);
            Obj_Empleados_DAL.iTelRef         = Convert.ToInt32(txt_TelRef.Text);
            Obj_Empleados_DAL.sIdEmpleado     = cb_TipoEmpleado.Text.ToUpper().Substring(0, 3) + "-" + Convert.ToUInt16(txt_IdEmpleado.Text);
            Obj_Empleados_DAL.dSalario        = Convert.ToDouble(txt_Salario.Text);
            Obj_Empleados_DAL.cIdEstado       = Convert.ToChar(cb_Estado.SelectedValue.ToString().Trim());
            Obj_Empleados_DAL.iIdTipoEmpleado = Convert.ToInt32(cb_TipoEmpleado.SelectedValue.ToString().Trim());
            Obj_Empleados_DAL.iIdAerolinea    = Convert.ToInt32(cb_IdAerolinea.SelectedValue.ToString().Trim());

            if (Obj_Empleados_DAL.cBandera == 'I')
            {
                Obj_Empleados_BLL.Insertar_Empleados(ref M_Error, ref Obj_Empleados_DAL);
                if (M_Error == string.Empty)
                {
                    MessageBox.Show("Se han ingresado los datos correctamente", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Obj_Empleados_DAL.cBandera = 'U';
                    txt_IdEmpleado.Enabled     = false;
                    toolStripLabel1.Text       = "Modificar";
                }
                else
                {
                    MessageBox.Show("Se ha presentado un error al guardar" + "[ " + M_Error + " ]");
                }
            }
            else
            {
                Obj_Empleados_BLL.Modificar_Empleados(ref M_Error, ref Obj_Empleados_DAL);
                if (M_Error == string.Empty)
                {
                    Obj_Empleados_DAL.cBandera = 'U';
                    MessageBox.Show("Se ha realizado el cambio exitosamente");
                    txt_IdEmpleado.Enabled = false;
                }
                else
                {
                    MessageBox.Show("Se ha presentado un error al guardar");
                }
            }
        }
Exemplo n.º 4
0
        private void tls_btn_Eliminar_Click(object sender, EventArgs e)
        {
            string           sMsjError    = string.Empty;
            cls_Usuarios_BLL obj_User_BLL = new cls_Usuarios_BLL();
            DataTable        DT           = new DataTable();

            DT = obj_User_BLL.ListarUsuarios(ref sMsjError);
            cls_Empleados_BLL objBLL = new cls_Empleados_BLL();

            if (dgv_Empleados.Rows.Count > 0)
            {
                if (DT.Rows[0][2].ToString() == dgv_Empleados.SelectedRows[0].Cells[0].Value.ToString())
                {
                    MessageBox.Show("Este usuario es el administrador, no se puede eliminar.\nContacte con soporte para eliminarlo ");
                }
                else
                {
                    if (MessageBox.Show("Realmente desea eliminar?", "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        objBLL.Eliminar_Empleados(ref sMsjError, dgv_Empleados.SelectedRows[0].Cells[0].Value.ToString());
                        if (sMsjError != string.Empty)
                        {
                            MessageBox.Show("Se presento un error a la hora de eliminar : [ " + sMsjError + " ]", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Registro eliminado correctamente", "Listo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Cargar();
                        }
                        tls_txt_Filtro.Text = string.Empty;
                    }
                }
            }

            else
            {
                MessageBox.Show("No hay registros para eliminar");
            }
        }