// LINEAS
    private void data_gridLinea()
    {
        tb_pt_lineaBL BL = new tb_pt_lineaBL();
        tb_pt_linea BE = new tb_pt_linea();
        DataTable dt = new DataTable();

        switch (cmb_lineas.SelectedValue)
        {
            case "01":
                BE.lineaid = txt_buscar3.Text.Trim().ToUpper();
                break;
            case "02":
                BE.lineaname = txt_buscar3.Text.Trim().ToUpper();
                break;
            default:
                //**
                break;
        }
        try
        {
            //Eliminar Columnas Actuales(Opcional):
            dgb_linea.Columns.Clear();
            dgb_linea.Width = 535;
            //Objeto Columna:
            CommandField image;
            //Crear Columna:
            image = new CommandField();
            image.ButtonType = ButtonType.Image;
            image.SelectImageUrl = "~/Images/go-search.png";
            image.ShowSelectButton = true;
            image.ItemStyle.Width = 10;
            image.ItemStyle.Wrap = true;
            dgb_linea.Columns.Add(image);

            BoundField LINEAID;
            LINEAID = new BoundField();
            LINEAID.DataField = "lineaid";
            LINEAID.HeaderText = "CODIGO";
            LINEAID.ItemStyle.Width = 50;
            dgb_linea.Columns.Add(LINEAID);

            BoundField LINEANAME;
            LINEANAME = new BoundField();
            LINEANAME.DataField = "lineaname";
            LINEANAME.HeaderText = "LINEA";
            LINEANAME.ItemStyle.Width = 250;
            dgb_linea.Columns.Add(LINEANAME);

            dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
            if (dt.Rows.Count > 0)
            {
                dgb_linea.DataSource = dt;
                dgb_linea.DataBind();
                dgb_linea.Visible = true;
            }
        }
        catch (Exception ex)
        {
            throw ex;// ClientMessage(ex.Message);
        }
    }
 void CargarCmbLinea()
 {
     tb_pt_lineaBL BL = new tb_pt_lineaBL();
     tb_pt_linea BE = new tb_pt_linea();
     DataTable dt = new DataTable();
     dt = BL.GetAll(EmpresaID, BE).Tables[0];
     if (dt.Rows.Count > 0)
     {
         cmb_linea01.DataSource = dt;
         cmb_linea01.ValueMember = "lineaid";
         cmb_linea01.DisplayMember = "lineaname";
         cmb_linea01.SelectedIndex = -1;
     }
 }
        private void Valida_Linea(String xcod)
        {
            var BE2 = new tb_pt_linea();
            var BL2 = new tb_pt_lineaBL();
            var dt2 = new DataTable();
            BE2.lineaid = xcod.Trim();
            dt2 = BL2.GetAll(EmpresaID, BE2).Tables[0];
            if (dt2.Rows.Count > 0)
            {
                if (dt2.Rows[0]["lineadescort"].ToString().Trim() != string.Empty)
                {
                    _xlineadescort = dt2.Rows[0]["lineadescort"].ToString();
                }
                else
                {
                    _xlineadescort = dt2.Rows[0]["lineaname"].ToString();
                }

                lineaid.Text = dt2.Rows[0]["lineaid"].ToString();
                lineaname.Text = dt2.Rows[0]["lineaname"].ToString();
                _xlineaidold = dt2.Rows[0]["lineaidold"].ToString();
            }
            else
            {
                _xlineadescort = string.Empty;
                lineaid.Text = string.Empty;
                lineaname.Text = string.Empty;
                _xlineaidold = string.Empty;
            }
        }
        private void btn_editar_Click(object sender, EventArgs e)
        {
            if (XNIVEL == "0" || XNIVEL == "1")
            {
                ssModo = "EDIT";
                form_bloqueado(true);
                articname.Focus();

                btn_cancelar.Enabled = true;
                btn_grabar.Enabled = true;
                btn_foto.Enabled = true;
                btnVer.Enabled = true;

                var BE = new tb_pt_marca();
                var BL = new tb_pt_marcaBL();
                var dt = new DataTable();
                BE.marcaid = marcaid.Text.Trim();
                dt = BL.GetAll(EmpresaID, BE).Tables[0];
                foreach (DataRow row in dt.Rows)
                {
                    _xmarcadescort = row["marcadescort"].ToString();
                }

                var BE2 = new tb_pt_linea();
                var BL2 = new tb_pt_lineaBL();
                var dt2 = new DataTable();
                BE2.lineaid = lineaid.Text.Trim();
                dt2 = BL2.GetAll(EmpresaID, BE2).Tables[0];
                foreach (DataRow row in dt2.Rows)
                {
                    _xlineadescort = row["lineadescort"].ToString();
                }

                var BE3 = new tb_pt_modelo();
                var BL3 = new tb_pt_modeloBL();
                var dt3 = new DataTable();
                BE3.modeloid = modeloid.Text.Trim();
                dt3 = BL3.GetAll(EmpresaID, BE3).Tables[0];
                foreach (DataRow row in dt3.Rows)
                {
                    _xmodelodescort = row["modelodescort"].ToString();
                }

                if (XNIVEL == "1")
                {
                    bloqueo_paneles(false);
                    pnl_01.Enabled = true;
                    pnl_03.Enabled = true;
                }
                else
                {
                    bloqueo_paneles(true);
                    pnl_02.Enabled = false;
                    pnl_05.Enabled = false;
                    pnl_06.Enabled = false;
                    pnl_03.Enabled = true;
                }
            }
        }
        private void Insert()
        {
            try
            {
                if (lineaid.Text.Trim().Length != 2)
                {
                    MessageBox.Show("Falta Codigo linea !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (lineaname.Text.Trim().Length == 0)
                    {
                        MessageBox.Show("Ingrese nombre de línea", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        var BL = new tb_pt_lineaBL();
                        var BE = new tb_pt_linea();

                        BE.lineaid = lineaid.Text.Trim().PadLeft(2, '0');
                        BE.lineaname = lineaname.Text.ToUpper().ToUpper();
                        BE.lineaidold = lineaidold.Text.ToUpper();
                        BE.lineadescort = lineadescort.Text.ToUpper();
                        BE.usuar = VariablesPublicas.Usuar.Trim();

                        if (BL.Insert(EmpresaID, BE))
                        {
                            MessageBox.Show("Datos grabados correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            procesado = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Update_dbf()
        {
            try
            {
                if (lineaidold.Text.Trim().Length != 3)
                {
                    MessageBox.Show("Falta Codigo_DBF Linea !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (lineaname.Text.Trim().Length == 0)
                    {
                        MessageBox.Show("Ingrese Nombre de Línea", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        var BL = new tb_pt_lineaBL();
                        var BE = new tb_pt_linea();

                        BE.lineaname = lineaname.Text.ToUpper().ToUpper().Trim();
                        BE.lineaidold = lineaidold.Text.ToUpper().Trim();
                        BE.usuar = VariablesPublicas.Usuar.Trim();

                        if (BL.Update_dbf(EmpresaID, BE))
                        {
                            SEGURIDAD_LOG("M");
                            MessageBox.Show("Datos Modificado Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            procesado = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void GetAll_CODdbf()
 {
     var BL = new tb_pt_lineaBL();
     var BE = new tb_pt_linea();
     var dt = new DataTable();
     dt = BL.GetAll_CODdbf(EmpresaID, BE).Tables[0];
     if (dt.Rows.Count > 0)
     {
         var num = Convert.ToInt32(dt.Rows[0]["lineaidold"].ToString());
         lineaidold.Text = (num + 1).ToString().PadLeft(3, '0');
     }
     else
     {
         lineaidold.Text = string.Empty;
     }
 }
        private void form_cargar_datos(String posicion)
        {
            try
            {
                var BL = new tb_pt_lineaBL();
                var BE = new tb_pt_linea();
                var dt = new DataTable();
                if (lineaid.Text.Trim().Length > 0)
                {
                    BE.lineaid = lineaid.Text.Trim().PadLeft(2, '0');
                }
                BE.posicion = posicion.Trim();

                dt = BL.GetAll_paginacion(EmpresaID, BE).Tables[0];

                if (dt.Rows.Count > 0)
                {
                    limpiar_documento();
                    ssModo = "EDIT";

                    lineaid.Text = dt.Rows[0]["lineaid"].ToString().Trim();
                    lineaname.Text = dt.Rows[0]["lineaname"].ToString().Trim();
                    lineaidold.Text = dt.Rows[0]["lineaidold"].ToString().Trim();
                    lineadescort.Text = dt.Rows[0]["lineadescort"].ToString().Trim();

                    btn_editar.Enabled = true;
                    btn_eliminar.Enabled = true;
                    btn_excel.Enabled = true;

                    btn_primero.Enabled = true;
                    btn_anterior.Enabled = true;
                    btn_siguiente.Enabled = true;
                    btn_ultimo.Enabled = true;

                    btn_log.Enabled = true;
                    btn_salir.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Delete_dbf()
        {
            try
            {
                if (lineaidold.Text.Trim().Length != 3)
                {
                    MessageBox.Show("Falta Codigo_DBF Linea !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    var BL = new tb_pt_lineaBL();
                    var BE = new tb_pt_linea();

                    BE.lineaname = lineaname.Text.ToUpper().ToUpper();
                    BE.lineaidold = lineaidold.Text.ToUpper();
                    BE.usuar = VariablesPublicas.Usuar.Trim();

                    if (BL.Delete_dbf(EmpresaID, BE))
                    {
                        SEGURIDAD_LOG("E");
                        MessageBox.Show("Dato Anulado Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        NIVEL_FORMS();
                        form_bloqueado(false);
                        data_Tablalinea();
                        btn_nuevo.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Delete()
        {
            try
            {
                if (lineaid.Text.Trim().Length != 2)
                {
                    MessageBox.Show("Falta Codigo linea !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    var BL = new tb_pt_lineaBL();
                    var BE = new tb_pt_linea();
                    BE.lineaid = lineaid.Text.Trim().PadLeft(2, '0');

                    if (BL.Delete(EmpresaID, BE))
                    {
                        SEGURIDAD_LOG("E");
                        MessageBox.Show("Datos eliminados correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        NIVEL_FORMS();
                        form_bloqueado(false);
                        data_Tablalinea();
                        btn_nuevo.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void data_Tablalinea()
        {
            try
            {
                if (Tablalinea.Rows.Count > 0)
                {
                    Tablalinea.Rows.Clear();
                }
                var BL = new tb_pt_lineaBL();
                var BE = new tb_pt_linea();

                BE.lineaname = txt_criterio.Text.Trim().ToUpper();

                Tablalinea = BL.GetAll(EmpresaID, BE).Tables[0];
                if (Tablalinea.Rows.Count > 0)
                {
                    btn_excel.Enabled = true;
                    gridlinea.DataSource = Tablalinea;
                    gridlinea.Rows[0].Selected = false;
                    gridlinea.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }