public bool DeleteItem(string empresaid, tb_cxc_pedidodet BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTb60Tienda_DELETE_Item", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 //cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 //cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                 //cmd.Parameters.Add("@tiendalist", SqlDbType.Int).Value = BE.tiendalist;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public DataSet GetAll(string empresaid, tb_cxc_pedidodet BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbMePedidoDet_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@tipdoc", SqlDbType.Char, 2).Value = BE.tipdoc;
                 cmd.Parameters.Add("@serdoc", SqlDbType.Char, 4).Value = BE.serdoc;
                 cmd.Parameters.Add("@numdoc", SqlDbType.Char, 10).Value = BE.numdoc;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public DataSet GetAll_paginacion(string empresaid, tb_cxc_pedidodet BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTb60Tienda_SEARCH_paginacion", cnx))
         {
             DataSet ds = new DataSet();
             {
                 //cmd.CommandType = CommandType.StoredProcedure;
                 //cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 //cmd.Parameters.Add("@tiendalist", SqlDbType.Int).Value = BE.tiendalist;
                 //cmd.Parameters.Add("@posicion", SqlDbType.VarChar, 10).Value = BE.posicion;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public DataSet GetAllSerdoc(string empresaid, tb_cxc_pedidodet BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCxcDocseries_Nuevonumero", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 //cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 //cmd.Parameters.Add("@tipdoc", SqlDbType.Char, 2).Value = BE.tipdoc;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
    protected void LkBPrint_Click(object sender, EventArgs e)
    {
        //string val = LblIdSer.Text;
        string val = HdFPrintItem.Value.ToString();
        Session["xtipdoc"] = val.ToString().Substring(0, 2);
        Session["xserdoc"] = val.ToString().Substring(3, 4);
        Session["xnumdoc"] = (val.ToString().Substring(8, 4)).PadLeft(10, '0');
        /*Llamada documento pdf*/
        tb_cxc_cronoPagosBL BL = new tb_cxc_cronoPagosBL();
        tb_cxc_cronoPagos BE = new tb_cxc_cronoPagos();
        DataTable dt = new DataTable();
        BE.tipdoc = Session["xtipdoc"].ToString();
        BE.serdoc = Session["xserdoc"].ToString();
        BE.numdoc = Session["xnumdoc"].ToString();
        dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        if (dt.Rows.Count > 0)
            Session["Tabla01"] = dt;

        tb_cxc_pedidodetBL BL2 = new tb_cxc_pedidodetBL();
        tb_cxc_pedidodet BE2 = new tb_cxc_pedidodet();
        DataTable dt2 = new DataTable();
        BE2.tipdoc = Session["xtipdoc"].ToString();
        BE2.serdoc = Session["xserdoc"].ToString();
        BE2.numdoc = Session["xnumdoc"].ToString();
        dt2 = BL2.GetAll(Session["ssEmpresaID"].ToString(), BE2).Tables[0];
        if (dt2.Rows.Count > 0)
            Session["Tabla02"] = dt2;
        //string pagina = "Rpt_Proforma.aspx";
        string pagina = "Rpt_Pedido.aspx";
        reporte_pdf(pagina);
    }
    protected void LkBSearch_Click(object sender, EventArgs e)
    {
        string val = Request["HdFNumdoc"].ToString();
        string xtipdoc = Equivalencias.Left(val.ToString().Trim(), 2);
        string xserdoc = HdFSerdoc.Value.ToString();
        string xnumdoc = Equivalencias.Right(val.ToString().Trim(), 10);

        Session["xtipdoc"] = xtipdoc;
        Session["xserdoc"] = xserdoc;
        Session["xnumdoc"] = xnumdoc;

        /*Llamada documento pdf*/
        tb_cxc_cronoPagosBL BL = new tb_cxc_cronoPagosBL();
        tb_cxc_cronoPagos BE = new tb_cxc_cronoPagos();
        DataTable dt = new DataTable();
        BE.tipdoc = Session["xtipdoc"].ToString();
        BE.serdoc = Session["xserdoc"].ToString();
        BE.numdoc = Session["xnumdoc"].ToString();
        dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        if (dt.Rows.Count > 0)
            Session["Tabla01"] = dt;

        tb_cxc_pedidodetBL BL2 = new tb_cxc_pedidodetBL();
        tb_cxc_pedidodet BE2 = new tb_cxc_pedidodet();
        DataTable dt2 = new DataTable();
        BE2.tipdoc = Session["xtipdoc"].ToString();
        BE2.serdoc = Session["xserdoc"].ToString();
        BE2.numdoc = Session["xnumdoc"].ToString();
        dt2 = BL2.GetAll(Session["ssEmpresaID"].ToString(), BE2).Tables[0];
        if (dt2.Rows.Count > 0)
            Session["Tabla02"] = dt2;
        //string pagina = "Rpt_Proforma.aspx";
        string pagina = "Rpt_Pedido.aspx";
        reporte_pdf(pagina);

        /**/
    }

    protected void LkBUpdate_Click(object sender, EventArgs e)
    {
        //string val = LblIdUpd.Text;
        string val = Request["HdFIdUpd"].ToString();
        string xtipdoc = Equivalencias.Left(val.ToString(), 2);
        string xserdoc = HdFSerdoc.Value.ToString();
        string xnumdoc = Equivalencias.Right(val.ToString(), 10);

        Session["xtipdoc"] = xtipdoc;
        Session["xserdoc"] = xserdoc;
        Session["xnumdoc"] = xnumdoc;

        /*Llamada documento pdf*/
        tb_cxc_cronoPagosBL BL = new tb_cxc_cronoPagosBL();
        tb_cxc_cronoPagos BE = new tb_cxc_cronoPagos();
        DataTable dt = new DataTable();
        BE.tipdoc = xtipdoc;
        BE.serdoc = xserdoc;
        BE.numdoc = xnumdoc;
        dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        if (dt.Rows.Count > 0)
            Session["Tabla01"] = dt;

        tb_cxc_pedidodetBL BL2 = new tb_cxc_pedidodetBL();
        tb_cxc_pedidodet BE2 = new tb_cxc_pedidodet();
        DataTable dt2 = new DataTable();
        BE2.tipdoc = xtipdoc;
        BE2.serdoc = xserdoc;
        BE2.numdoc = xnumdoc;
        dt2 = BL2.GetAll(Session["ssEmpresaID"].ToString(), BE2).Tables[0];
        if (dt2.Rows.Count > 0)
            Session["Tabla02"] = dt2;
        string pagina = "Rpt_EvalCrediticia.aspx";
        reporte_pdf(pagina);
    }
 public DataSet GetAllSerdoc(string empresaid, tb_cxc_pedidodet BE)
 {
     return tablaDA.GetAllSerdoc(empresaid, BE);
 }
 public bool Update(string empresaid, tb_cxc_pedidodet BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTb60Tienda_UPDATE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 //cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 //cmd.Parameters.Add("@tiendalist", SqlDbType.Int).Value = BE.tiendalist;
                 //cmd.Parameters.Add("@tiendaname", SqlDbType.Char, 100).Value = BE.tiendaname;
                 //cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status;
                 //cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
    protected void btn_Imprimir_Click(object sender, ImageClickEventArgs e)
    {
        // PROVAMOS EL REPORTE AHORA EN PDF

        Session["xtipdoc"] = txt_tipdoc2.Text.ToUpper();
        Session["xserdoc"] = txt_serdoc2.Text;
        Session["xnumdoc"] = txt_numdoc2.Text;

        tb_cxc_cronoPagosBL BL = new tb_cxc_cronoPagosBL();
        tb_cxc_cronoPagos BE = new tb_cxc_cronoPagos();
        DataTable dt = new DataTable();
        BE.tipdoc = Session["xtipdoc"].ToString();
        BE.serdoc = Session["xserdoc"].ToString();
        BE.numdoc = Session["xnumdoc"].ToString();
        dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        if (dt.Rows.Count > 0)
            Session["Tabla01"] = dt;

        tb_cxc_pedidodetBL BL2 = new tb_cxc_pedidodetBL();
        tb_cxc_pedidodet BE2 = new tb_cxc_pedidodet();
        DataTable dt2 = new DataTable();
        BE2.tipdoc = Session["xtipdoc"].ToString();
        BE2.serdoc = Session["xserdoc"].ToString();
        BE2.numdoc = Session["xnumdoc"].ToString();
        dt2 = BL2.GetAll(Session["ssEmpresaID"].ToString(), BE2).Tables[0];
        if (dt2.Rows.Count > 0)
            Session["Tabla02"] = dt2;

        string pagina = "Rpt_Proforma.aspx";
        reporte_pdf(pagina);

        //btn_Imprimir_ClickExtracted();
        //reemplazarvaloresWORD();
        // Reporte de Tablas en Word
        #region Temporal Bloqueado
        //Word.Application app = new Word.Application();
        //Word.Document doc = CreateTableWord(app, (DataTable)(Session["TablaCronoPagos"]));

        //if (((doc != null))) {
        //    var _with1 = doc;
        //    _with1.SaveAs(@"C:\ReporteWeb\Prueba_Tabla.docx");
        //    _with1.Close();
        //}

        //// Cerramos Word y liberamos los recursos asociados.
        ////
        //app.Quit();
        //app = null;
        #endregion
    }
    protected void btn_Imprimir2_Click(object sender, ImageClickEventArgs e)
    {
        Session["xtipdoc"] = txt_tipdoc2.Text.ToUpper();
        Session["xserdoc"] = txt_serdoc2.Text;
        Session["xnumdoc"] = txt_numdoc2.Text;

        tb_cxc_cronoPagosBL BL = new tb_cxc_cronoPagosBL();
        tb_cxc_cronoPagos BE = new tb_cxc_cronoPagos();
        DataTable dt = new DataTable();
        BE.tipdoc = Session["xtipdoc"].ToString();
        BE.serdoc = Session["xserdoc"].ToString();
        BE.numdoc = Session["xnumdoc"].ToString();
        dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        if (dt.Rows.Count > 0)
            Session["Tabla01"] = dt;

        tb_cxc_pedidodetBL BL2 = new tb_cxc_pedidodetBL();
        tb_cxc_pedidodet BE2 = new tb_cxc_pedidodet();
        DataTable dt2 = new DataTable();
        BE2.tipdoc = Session["xtipdoc"].ToString();
        BE2.serdoc = Session["xserdoc"].ToString();
        BE2.numdoc = Session["xnumdoc"].ToString();
        dt2 = BL2.GetAll(Session["ssEmpresaID"].ToString(), BE2).Tables[0];
        if (dt2.Rows.Count > 0)
            Session["Tabla02"] = dt2;

        string pagina = "Rpt_Pedido.aspx";
        reporte_pdf2(pagina);
    }
 private void CargarDetalleProfor(String xtip, String xser, String xnum)
 {
     tb_cxc_pedidodetBL BL = new tb_cxc_pedidodetBL();
     tb_cxc_pedidodet BE = new tb_cxc_pedidodet();
     BE.tipdoc = xtip.ToString();
     BE.serdoc = xser.ToString();
     BE.numdoc = xnum.ToString();
     TablaDetalle = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
     griddetalle.DataSource = TablaDetalle;
     griddetalle.DataBind();
     Session["TablaDetalle"] = TablaDetalle;
 }
 public DataSet Upload_row(string empresaid, tb_cxc_pedidodet BE)
 {
     return tablaDA.Upload_row(empresaid, BE);
 }
 public bool Update(string empresaid, tb_cxc_pedidodet BE)
 {
     return tablaDA.Update(empresaid, BE);
 }
 public bool Insert(string empresaid, tb_cxc_pedidodet BE)
 {
     return tablaDA.Insert(empresaid, BE);
 }
        public bool Insert(string empresaid, tb_cxc_pedidodet BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("", cnx))
                {
                    cmd.CommandTimeout = 0;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@tipdoc", SqlDbType.Char, 2).Value = BE.tipdoc;
                    cmd.Parameters.Add("@serdoc", SqlDbType.Char, 4).Value = BE.serdoc;
                    cmd.Parameters.Add("@numdoc", SqlDbType.Char, 10).Value = BE.numdoc;
                    //cmd.Parameters.Add("@canalventaid", SqlDbType.Char, 3).Value = BE.canalventaid;
                    //cmd.Parameters.Add("@tipventaid", SqlDbType.Char, 2).Value = BE.tipventaid;
                    //cmd.Parameters.Add("@fechdoc", SqlDbType.DateTime).Value = BE.fechdoc;
                    //cmd.Parameters.Add("@fechentrega", SqlDbType.DateTime).Value = BE.fechentrega;
                    //cmd.Parameters.Add("@vendorid", SqlDbType.Char, 4).Value = BE.vendorid;
                    //cmd.Parameters.Add("@ctacte", SqlDbType.Char, 7).Value = BE.ctacte;
                    //cmd.Parameters.Add("@replegal_dni", SqlDbType.Char, 8).Value = BE.replegal_dni;
                    //cmd.Parameters.Add("@replegal_name", SqlDbType.VarChar, 100).Value = BE.replegal_name;
                    //cmd.Parameters.Add("@direc_entrega", SqlDbType.VarChar, 100).Value = BE.direc_entrega;
                    //cmd.Parameters.Add("@condventaid", SqlDbType.Char, 2).Value = BE.condventaid;
                    //cmd.Parameters.Add("@plazoday", SqlDbType.Int).Value = BE.plazoday;
                    //cmd.Parameters.Add("@impobruto", SqlDbType.Decimal).Value = BE.impobruto;
                    //cmd.Parameters.Add("@rangoid", SqlDbType.Char, 2).Value = BE.rangoid;
                    //cmd.Parameters.Add("@tasadescto", SqlDbType.Decimal).Value = BE.tasadescto;
                    //cmd.Parameters.Add("@imponeto", SqlDbType.Decimal).Value = BE.imponeto;
                    //cmd.Parameters.Add("@moneda", SqlDbType.Char, 1).Value = BE.moneda;
                    //cmd.Parameters.Add("@incluye_igv", SqlDbType.Bit).Value = BE.incluye_igv;
                    //cmd.Parameters.Add("@mediopagoid", SqlDbType.Char, 3).Value = BE.mediopagoid;
                    //cmd.Parameters.Add("@numdocs", SqlDbType.Int).Value = BE.numdocs;
                    //cmd.Parameters.Add("@aprob_status", SqlDbType.Char, 1).Value = BE.aprob_status;
                    //cmd.Parameters.Add("@aprob_obser", SqlDbType.VarChar, 100).Value = BE.aprob_obser;
                    //cmd.Parameters.Add("@aprob_fech", SqlDbType.DateTime).Value = BE.aprob_fech;
                    //cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;
                    //cmd.Parameters.Add("@XML", SqlDbType.Xml).Value = BE.GetItemXML();
                    //cmd.Parameters.Add("@XMLC", SqlDbType.Xml).Value = BE.GetCronoXML();

                    try
                    {
                        cnx.Open();
                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
        public bool Insert_Item(string empresaid, tb_cxc_pedidodet BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTb60Tienda_INSERT_Item", cnx))
                {

                    cmd.CommandType = CommandType.StoredProcedure;
                    //cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                    //cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status;
                    //cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;
                    //cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;

                    try
                    {
                        cnx.Open();
                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
    protected void LkBSearch_Click(object sender, EventArgs e)
    {
        //string val = LblIdSer.Text;
        string val = HdFIdSer.Value.ToString();

        Session["xtipdoc"] = val.ToString().Substring(0, 2);
        Session["xserdoc"] = val.ToString().Substring(3, 4);
        Session["xnumdoc"] = (val.ToString().Substring(8, 5)).PadLeft(10, '0');
        /*Llamada documento pdf*/
        tb_cxc_cronoPagosBL BL = new tb_cxc_cronoPagosBL();
        tb_cxc_cronoPagos BE = new tb_cxc_cronoPagos();
        DataTable dt = new DataTable();
        BE.tipdoc = Session["xtipdoc"].ToString();
        BE.serdoc = Session["xserdoc"].ToString();
        BE.numdoc = Session["xnumdoc"].ToString();
        dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        if (dt.Rows.Count > 0)
            Session["Tabla01"] = dt;

        tb_cxc_pedidodetBL BL2 = new tb_cxc_pedidodetBL();
        tb_cxc_pedidodet BE2 = new tb_cxc_pedidodet();
        DataTable dt2 = new DataTable();
        BE2.tipdoc = Session["xtipdoc"].ToString();
        BE2.serdoc = Session["xserdoc"].ToString();
        BE2.numdoc = Session["xnumdoc"].ToString();
        dt2 = BL2.GetAll(Session["ssEmpresaID"].ToString(), BE2).Tables[0];
        if (dt2.Rows.Count > 0)
            Session["Tabla02"] = dt2;
        string pagina = "Rpt_Proforma.aspx";
        reporte_pdf(pagina);

        /**/
    }

    protected void LkBStatus_Click(object sender, EventArgs e)
    {
        if (RBL1.SelectedValue == "0")
        {
            HdF1.Value = "0";
        }
        else if (RBL1.SelectedValue == "1")
        {
            HdF1.Value = "1";
        }
        else
        {
            HdF1.Value = "2";
        }

        //lanzarProgress(HdF1.Value.ToString(), HdF2.Value.ToString());
        UpdatePendAprob(HdF1.Value.ToString(), HdF2.Value.ToString());
        System.Threading.Thread.Sleep(2000);
        cargar_grilla();
    }

    protected void LkBUpdate_Click(object sender, EventArgs e)
    {
        // PRIMERO VERIFICAMOS QUE LOS PEDIDOS SEAN PENDIENTE PARA PODER MODIFICARLOS
        String xstatu = HdFStatus.Value.ToString();
        if (xstatu.Equals("11")) // 11 = PENDIENTE/NUEVO/EN EDICION
        {
            string val = HdFUpdateItem.Value.ToString();
            Session["xtipdoc"] = Equivalencias.Left(val.ToString().Trim(), 2);
            Session["xserdoc"] = HdFSerdoc.Value.ToString();
            Session["xnumdoc"] = Equivalencias.Right(val.ToString().Trim(), 10);

            Session["ssModo"] = "EDI";
            Response.Redirect("~/Comercial/Frm_Proformas.aspx#registro");
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ValIngreso();
            bloqueo("01", false);
            bloqueo("02", false);
            bloqueo("03", false);
            cargarComboEstado();
            cargar_grilla();
            //cargar_grilla();
        }
    }

    void bloqueo(String btn, Boolean var)
    {
        // Div Cliente
        if (btn.Equals("01"))
        {
            txt_ctactename.Enabled = var;
            //btn_buscaCliente.CssClass = css;
            btn_buscaCliente.Visible = var;
        }

        // Div Vendedor
        if (btn.Equals("02"))
        {
            txt_vendorname.Enabled = var;
            //btn_buscaVendor.CssClass = css;
            btn_buscaVendor.Visible = var;
        }

        // Div Estado
        if (btn.Equals("03"))
        {
            cmbestado.Enabled = var;
        }
    }

    void cargarComboEstado()
    {
        // CARGAMOS COMBOS PARA LA VISTA DE VENDEDORES
        tb_cxc_evalcredBL BL = new tb_cxc_evalcredBL();
        tb_cxc_evalcred BE = new tb_cxc_evalcred();
        DataTable dt = new DataTable();
        BE.canalventaid = Session["ssCanalVentaId"].ToString();
        BE.filtro = "";
        dt = BL.GetAll_Estados(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        cmbestado.DataSource = dt;
        cmbestado.DataValueField = "aprob_status";
        cmbestado.DataTextField = "descripcion";
        cmbestado.DataBind();
    }

    void CargarPedido()
    {
        tb_cxc_evalcredBL BL = new tb_cxc_evalcredBL();
        tb_cxc_evalcred BE = new tb_cxc_evalcred();
        DataTable dt = new DataTable();
        BE.ctacte = txt_ctacte.Value.ToString();
        BE.vendorid = txt_vendorid.Value.ToString();
        BE.aprob_gerencial = cmbestado.SelectedValue.ToString();
        BE.filtro = "2";
        dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        GridView.DataSource = dt;
        GridView.DataBind();
    }

    void cargar_grilla()
    {
        tb_cxc_evalcredBL BL = new tb_cxc_evalcredBL();
        tb_cxc_evalcred BE = new tb_cxc_evalcred();

        BE.ctacte = txt_ctacte.Value.ToString();

        if (Equivalencias.Right(Session["ssPerfil"].ToString(), 4) != "0000")
            BE.vendorid = txt_vendorid.Value.ToString();

        if(chk_estado.Checked)
            BE.aprob_gerencial = cmbestado.SelectedValue.ToString();
        BE.filtro = "2";
        TablaPendAprob = BL.GetAll_PendAprob(Session["ssEmpresaID"].ToString(), BE).Tables[0];

        DataTable dtDatos = new DataTable();
        if (TablaPendAprob.Rows.Count > 0)
        {
            dtDatos.Columns.Add("nmruc");
            dtDatos.Columns.Add("ctactename");
            dtDatos.Columns.Add("serdoc");
            dtDatos.Columns.Add("numdoc");
            dtDatos.Columns.Add("fecre");
            dtDatos.Columns.Add("aprob_status");
            dtDatos.Columns.Add("estado");
            dtDatos.Columns.Add("aprob_obser");
            for (int i = 0; i < TablaPendAprob.Rows.Count; i++)
            {
                DataRow dtRow = dtDatos.NewRow();
                dtRow["nmruc"] = TablaPendAprob.Rows[i]["nmruc"].ToString();
                dtRow["ctactename"] = TablaPendAprob.Rows[i]["ctactename"].ToString();
                dtRow["serdoc"] = TablaPendAprob.Rows[i]["serdoc"].ToString();
                dtRow["numdoc"] = TablaPendAprob.Rows[i]["numdoc"].ToString();
                dtRow["fecre"] = TablaPendAprob.Rows[i]["fecre"].ToString();
                dtRow["aprob_status"] = TablaPendAprob.Rows[i]["aprob_status"].ToString();
                dtRow["estado"] = TablaPendAprob.Rows[i]["estado"].ToString();
                dtRow["aprob_obser"] = TablaPendAprob.Rows[i]["aprob_obser"].ToString();
                dtDatos.Rows.Add(dtRow);
            }
            GridView.DataSource = dtDatos;
            GridView.DataBind();
        }
        else {
            GridView.DataSource = TablaPendAprob;
            GridView.DataBind();
        }
    }

    // CLIENTES
    private void data_gridCliente()
    {
        tb_cxc_evalcredBL BL = new tb_cxc_evalcredBL();
        tb_cxc_evalcred BE = new tb_cxc_evalcred();
        DataTable dt = new DataTable();

        switch (cmbcliente.SelectedValue)
        {
            case "01":
                BE.ctacte = txt_buscar.Text.Trim().ToUpper();
                break;
            case "02":
                BE.ctactename = txt_buscar.Text.Trim().ToUpper();
                break;
            //case "03":
            //    BE.nmruc = txt_buscar.Text.Trim().ToUpper();
            //    break;
            default:
                //**
                break;
        }
        try
        {
            //Eliminar Columnas Actuales(Opcional):
            dgb_cliente.Columns.Clear();
            dgb_cliente.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_cliente.Columns.Add(image);

            BoundField DDNNI;
            DDNNI = new BoundField();
            DDNNI.DataField = "ctacte";
            DDNNI.HeaderText = "CODIGO";
            DDNNI.ItemStyle.Width = 50;
            dgb_cliente.Columns.Add(DDNNI);

            BoundField NOMBR;
            NOMBR = new BoundField();
            NOMBR.DataField = "ctactename";
            NOMBR.HeaderText = "NOMBRES";
            NOMBR.ItemStyle.Width = 250;
            dgb_cliente.Columns.Add(NOMBR);
            BE.filtro = "1";
            BE.vendorid = txt_vendorid.Value.ToString();
            dt = BL.GetAll_Filtro(Session["ssEmpresaID"].ToString(), BE).Tables[0];
            if (dt.Rows.Count > 0)
            {
                dgb_cliente.DataSource = dt;
                dgb_cliente.DataBind();
                dgb_cliente.Visible = true;
            }
        }
        catch (Exception ex)
        {
            throw ex;// ClientMessage(ex.Message);
        }
    }

    // VENDEDOR
    private void data_gridVendedor()
    {
        tb_cxc_evalcredBL BL = new tb_cxc_evalcredBL();
        tb_cxc_evalcred BE = new tb_cxc_evalcred();
        DataTable dt = new DataTable();
        switch (cmbvendedor.SelectedValue)
        {
            case "01":
                BE.vendorid = txt_busqueda02.Text.Trim().ToUpper();
                break;
            case "02":
                BE.vendorname = txt_busqueda02.Text.Trim().ToUpper();
                break;
            default:
                //**
                break;
        }
        try
        {
            //Eliminar Columnas Actuales(Opcional):
            dgb_vendedor.Columns.Clear();
            dgb_vendedor.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_vendedor.Columns.Add(image);

            BoundField DDNNI;
            DDNNI = new BoundField();
            DDNNI.DataField = "vendorid";
            DDNNI.HeaderText = "CODIGO";
            DDNNI.ItemStyle.Width = 50;
            dgb_vendedor.Columns.Add(DDNNI);

            BoundField NOMBR;
            NOMBR = new BoundField();
            NOMBR.DataField = "vendorname";
            NOMBR.HeaderText = "VENDEDOR";
            NOMBR.ItemStyle.Width = 250;
            dgb_vendedor.Columns.Add(NOMBR);

            BE.filtro = "2";

            dt = BL.GetAll_Filtro(Session["ssEmpresaID"].ToString(), BE).Tables[0];
            if (dt.Rows.Count > 0)
            {
                dgb_vendedor.DataSource = dt;
                dgb_vendedor.DataBind();
                dgb_vendedor.Visible = true;
            }
        }
        catch (Exception ex)
        {
            throw ex;// ClientMessage(ex.Message);
        }
    }

    private void reporte_pdf(string pagina)
    {
        try
        {
            string strURL = "";
            //string strCifrado = funcript.EncryptData(strURL);
            string cifrado = funcript.EncryptToString(strURL);
            //ClientMessage(cifrado);
            Literal li = new Literal();
            StringBuilder sbMensaje = new StringBuilder();
            sbMensaje.Append("<script type='text/javascript'>");
            /*sbMensaje.Append("window.open('ve_rpt_docs.aspx?data=" + cifrado + "', 'mywindow','location=0,status=0,scrollbars=0,resizable=0,menubar=0,channelmode=0,directories=0,fullscreen=0,titlebar=0,toolbar=0')");*/
            sbMensaje.Append("window.open('Reportes/"+ pagina.ToString() +"?data=" + cifrado + "', 'mywindow','location=0,status=0,scrollbars=0,resizable=1,menubar=0,toolbar=0')");
            sbMensaje.Append("</script>");
            //Agremamos el texto del stringbuilder al literal
            li.Text = sbMensaje.ToString();

            //Agregamos el literal a la pagina
            Page.Controls.Add(li);
        }
 public DataSet Upload_row(string empresaid, tb_cxc_pedidodet BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCmLiqConceptos_SELECT", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 //cmd.Parameters.Add("@filtro", SqlDbType.Char, 1).Value = BE.filtro;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
    protected void dgb_evalcred_SelectedIndexChanged(object sender, EventArgs e)
    {
        String xtipdoc = dgb_evalcred.SelectedRow.Cells[2].Text;
        string[] parts = xtipdoc.Split('-');
        String numdoc = parts[2].PadLeft(10, '0');

        Session["xtipdoc"] = parts[0];
        Session["xserdoc"] = parts[1];
        Session["xnumdoc"] = parts[2].PadLeft(10, '0');

        tb_cxc_cronoPagosBL BL = new tb_cxc_cronoPagosBL();
        tb_cxc_cronoPagos BE = new tb_cxc_cronoPagos();
        DataTable dt = new DataTable();
        BE.tipdoc = parts[0];
        BE.serdoc = parts[1];
        BE.numdoc = parts[2].PadLeft(10, '0');
        dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        if (dt.Rows.Count > 0)
            Session["Tabla01"] = dt;

        tb_cxc_pedidodetBL BL2 = new tb_cxc_pedidodetBL();
        tb_cxc_pedidodet BE2 = new tb_cxc_pedidodet();
        DataTable dt2 = new DataTable();
        BE2.tipdoc = parts[0];
        BE2.serdoc = parts[1];
        BE2.numdoc = parts[2].PadLeft(10, '0');
        dt2 = BL2.GetAll(Session["ssEmpresaID"].ToString(), BE2).Tables[0];
        if (dt2.Rows.Count > 0)
            Session["Tabla02"] = dt2;

        //reporte_pdf();
    }
    protected void LkBAceptar_Click(object sender, EventArgs e)
    {
        string val = Request["hfnumdoc"].ToString();
        string xtipdoc = Equivalencias.Left(val.ToString(), 2);
        string xserdoc = val.ToString().Substring(3, 4);
        string xnumdoc = (Equivalencias.Right(val.ToString(), 5)).PadLeft(10, '0');

        Session["xtipdoc"] = xtipdoc;
        Session["xserdoc"] = xserdoc;
        Session["xnumdoc"] = xnumdoc;

        tb_cxc_cronoPagosBL BL = new tb_cxc_cronoPagosBL();
        tb_cxc_cronoPagos BE = new tb_cxc_cronoPagos();
        DataTable dt = new DataTable();
        BE.tipdoc = xtipdoc;
        BE.serdoc = xserdoc;
        BE.numdoc = xnumdoc;
        dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        if (dt.Rows.Count > 0)
            Session["Tabla01"] = dt;

        tb_cxc_pedidodetBL BL2 = new tb_cxc_pedidodetBL();
        tb_cxc_pedidodet BE2 = new tb_cxc_pedidodet();
        DataTable dt2 = new DataTable();
        BE2.tipdoc = xtipdoc;
        BE2.serdoc = xserdoc;
        BE2.numdoc = xnumdoc;
        dt2 = BL2.GetAll(Session["ssEmpresaID"].ToString(), BE2).Tables[0];
        if (dt2.Rows.Count > 0)
            Session["Tabla02"] = dt2;
        //reporte_pdf();
    }
    protected void LkBSearch_Click(object sender, EventArgs e)
    {
        //string val = LblIdSer.Text;
        string val = HdFIdSer.Value.ToString();
        Session["xtipdoc"] = Equivalencias.Left(val.ToString().Trim(), 2);
        Session["xserdoc"] = HdFSerdoc.Value.ToString();
        Session["xnumdoc"] = Equivalencias.Right(val.ToString().Trim(), 10);
        /*Llamada documento pdf*/
        tb_cxc_cronoPagosBL BL = new tb_cxc_cronoPagosBL();
        tb_cxc_cronoPagos BE = new tb_cxc_cronoPagos();
        DataTable dt = new DataTable();
        BE.tipdoc = Session["xtipdoc"].ToString();
        BE.serdoc = Session["xserdoc"].ToString();
        BE.numdoc = Session["xnumdoc"].ToString();
        dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        if (dt.Rows.Count > 0)
            Session["Tabla01"] = dt;

        tb_cxc_pedidodetBL BL2 = new tb_cxc_pedidodetBL();
        tb_cxc_pedidodet BE2 = new tb_cxc_pedidodet();
        DataTable dt2 = new DataTable();
        BE2.tipdoc = Session["xtipdoc"].ToString();
        BE2.serdoc = Session["xserdoc"].ToString();
        BE2.numdoc = Session["xnumdoc"].ToString();
        dt2 = BL2.GetAll(Session["ssEmpresaID"].ToString(), BE2).Tables[0];
        if (dt2.Rows.Count > 0)
            Session["Tabla02"] = dt2;
        //string pagina = "Rpt_Proforma.aspx";
        string pagina = "Rpt_Pedido.aspx";
        reporte_pdf(pagina);

        /**/
    }

    protected void LkBStatus_Click(object sender, EventArgs e)
    {
        //if (cmbestados.SelectedValue == "0")
        //{
        //    HdF1.Value = "0";
        //}
        //else if (cmbestados.SelectedValue == "1")
        //{
        //    HdF1.Value = "1";
        //}
        //else
        //{
        //    HdF1.Value = "2";
        //}

        //lanzarProgress(HdF1.Value.ToString(), HdF2.Value.ToString());

        String xvalor = HdF1.Value.ToString();

        UpdatePendAprob(xvalor.ToString(), HdF2.Value.ToString()); // ('ESTADO','NUMDOC')
        System.Threading.Thread.Sleep(2000);
        cargar_grilla();
        //ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "searchPopclick();", true);
    }

    protected void LkBUpdate_Click(object sender, EventArgs e)
    {
        //string val = LblIdUpd.Text;
        string val = HdFIdUpd.Value.ToString();

        Session["xtipdoc"] = Equivalencias.Left(val.ToString().Trim(), 2);
        Session["xserdoc"] = HdFSerdoc.Value.ToString();
        Session["xnumdoc"] = Equivalencias.Right(val.ToString().Trim(), 10);
        /*Llamada documento pdf*/
        tb_cxc_cronoPagosBL BL = new tb_cxc_cronoPagosBL();
        tb_cxc_cronoPagos BE = new tb_cxc_cronoPagos();
        DataTable dt = new DataTable();
        BE.tipdoc = Session["xtipdoc"].ToString();
        BE.serdoc = Session["xserdoc"].ToString();
        BE.numdoc = Session["xnumdoc"].ToString();
        dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        if (dt.Rows.Count > 0)
            Session["Tabla01"] = dt;

        tb_cxc_pedidodetBL BL2 = new tb_cxc_pedidodetBL();
        tb_cxc_pedidodet BE2 = new tb_cxc_pedidodet();
        DataTable dt2 = new DataTable();
        BE2.tipdoc = Session["xtipdoc"].ToString();
        BE2.serdoc = Session["xserdoc"].ToString();
        BE2.numdoc = Session["xnumdoc"].ToString();
        dt2 = BL2.GetAll(Session["ssEmpresaID"].ToString(), BE2).Tables[0];
        if (dt2.Rows.Count > 0)
            Session["Tabla02"] = dt2;
        string pagina = "Rpt_EvalCrediticia.aspx";
        reporte_pdf(pagina);

        /**/
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bloqueo("01", false);
            bloqueo("02", false);
            bloqueo("03", false);
            Cargar_ComboEstado();
            Cargar_ComboEstado2();
            cargar_grilla();
            ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "searchPopclick();", true);
        }
    }

    void bloqueo(String btn, Boolean var)
    {
        // Div Cliente
        if (btn.Equals("01"))
        {
            txt_ctactename.Enabled = var;
            //btn_buscaCliente.CssClass = css;
            btn_buscaCliente.Visible = var;
        }

        // Div Vendedor
        if (btn.Equals("02"))
        {
            txt_vendorname.Enabled = var;
            //btn_buscaVendor.CssClass = css;
            btn_buscaVendor.Visible = var;
        }

        // Div Estado
        if (btn.Equals("03"))
        {
            cmbestado.Enabled = var;
        }
    }

    void Cargar_ComboEstado()
    {
        // CARGAMOS COMBOS PARA LA VISTA DE GERENCIA
        tb_cxc_evalcredBL BL = new tb_cxc_evalcredBL();
        tb_cxc_evalcred BE = new tb_cxc_evalcred();
        DataTable dt = new DataTable();
        BE.canalventaid = Session["ssCanalVentaId"].ToString();
        BE.filtro = "1";
        dt = BL.GetAll_Estados(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        Cmb_Estados.DataSource = dt;
        Cmb_Estados.DataValueField = "aprob_status";
        Cmb_Estados.DataTextField = "descripcion";
        Cmb_Estados.DataBind();
    }

    void Cargar_ComboEstado2()
    {
        // CARGAMOS COMBOS PARA LA VISTA DE GERENCIA
        tb_cxc_evalcredBL BL = new tb_cxc_evalcredBL();
        tb_cxc_evalcred BE = new tb_cxc_evalcred();
        DataTable dt = new DataTable();
        BE.canalventaid = Session["ssCanalVentaId"].ToString();
        BE.filtro = "1";
        dt = BL.GetAll_Estados(Session["ssEmpresaID"].ToString(), BE).Tables[0];
        cmbestado.DataSource = dt;
        cmbestado.DataValueField = "aprob_status";
        cmbestado.DataTextField = "descripcion";
        cmbestado.DataBind();
    }

    void cargar_grilla()
    {
        tb_cxc_evalcredBL BL = new tb_cxc_evalcredBL();
        tb_cxc_evalcred BE = new tb_cxc_evalcred();

        BE.ctacte = txt_ctacte.Value.ToString();
        BE.vendorid = txt_vendorid.Value.ToString();
        if (chk_estado.Checked)
            BE.aprob_gerencial = cmbestado.SelectedValue.ToString();
        BE.filtro = "3"; // PEDIDOS QUE HAYAN SIDO APROBADOS POR CUE/COB O RECHAZADOS O APROB POR GERENCIA
        TablaPendAprob = BL.GetAll_PendAprob(Session["ssEmpresaID"].ToString(), BE).Tables[0];

        DataTable dtDatos = new DataTable();
        if (TablaPendAprob.Rows.Count>0)
        {
            dtDatos.Columns.Add("nmruc");
            dtDatos.Columns.Add("ctactename");
            dtDatos.Columns.Add("serdoc");
            dtDatos.Columns.Add("numdoc");
            dtDatos.Columns.Add("vendorname");
            dtDatos.Columns.Add("imgEstado");
            dtDatos.Columns.Add("condicion");
            dtDatos.Columns.Add("status");
            dtDatos.Columns.Add("aprob_obser");
            string estado = "";
            for (int i = 0; i < TablaPendAprob.Rows.Count; i++)
            {
                DataRow dtRow = dtDatos.NewRow();
                estado = TablaPendAprob.Rows[i]["aprob_status"].ToString();
                dtRow["nmruc"] = TablaPendAprob.Rows[i]["nmruc"].ToString();
                dtRow["ctactename"] = TablaPendAprob.Rows[i]["ctactename"].ToString();
                dtRow["serdoc"] = TablaPendAprob.Rows[i]["serdoc"].ToString();
                dtRow["numdoc"] = TablaPendAprob.Rows[i]["numdoc"].ToString();
                dtRow["vendorname"] = TablaPendAprob.Rows[i]["vendorname"].ToString();
                dtRow["imgEstado"] = "~/Comercial/Listados/assets/table/IMG_PNG/" + estado.ToString() + ".png";
                dtRow["condicion"] = TablaPendAprob.Rows[i]["estado"].ToString();
                dtRow["status"] = TablaPendAprob.Rows[i]["aprob_status"].ToString();
                dtRow["aprob_obser"] = TablaPendAprob.Rows[i]["aprob_obser"].ToString();
                //dtRow["observacion"] = dt.lista_Proforma().Rows[i]["observacion"].ToString();
                dtDatos.Rows.Add(dtRow);
            }
            GridViewProd.DataSource = dtDatos;
            GridViewProd.DataBind();
        }
    }

    private void data_gridCliente()
    {
        tb_cxc_evalcredBL BL = new tb_cxc_evalcredBL();
        tb_cxc_evalcred BE = new tb_cxc_evalcred();
        DataTable dt = new DataTable();

        switch (cmbcliente.SelectedValue)
        {
            case "01":
                BE.ctacte = txt_buscar.Text.Trim().ToUpper();
                break;
            case "02":
                BE.ctactename = txt_buscar.Text.Trim().ToUpper();
                break;
            //case "03":
            //    BE.nmruc = txt_buscar.Text.Trim().ToUpper();
            //    break;
            default:
                //**
                break;
        }
        try
        {
            //Eliminar Columnas Actuales(Opcional):
            dgb_cliente.Columns.Clear();
            dgb_cliente.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_cliente.Columns.Add(image);

            BoundField DDNNI;
            DDNNI = new BoundField();
            DDNNI.DataField = "ctacte";
            DDNNI.HeaderText = "CODIGO";
            DDNNI.ItemStyle.Width = 50;
            dgb_cliente.Columns.Add(DDNNI);

            BoundField NOMBR;
            NOMBR = new BoundField();
            NOMBR.DataField = "ctactename";
            NOMBR.HeaderText = "NOMBRES";
            NOMBR.ItemStyle.Width = 250;
            dgb_cliente.Columns.Add(NOMBR);
            BE.filtro = "1";
            dt = BL.GetAll_Filtro(Session["ssEmpresaID"].ToString(), BE).Tables[0];
            if (dt.Rows.Count > 0)
            {
                dgb_cliente.DataSource = dt;
                dgb_cliente.DataBind();
                dgb_cliente.Visible = true;
            }
        }
        catch (Exception ex)
        {
            throw ex;// ClientMessage(ex.Message);
        }
    }

    private void data_gridVendedor()
    {
        tb_cxc_evalcredBL BL = new tb_cxc_evalcredBL();
        tb_cxc_evalcred BE = new tb_cxc_evalcred();
        DataTable dt = new DataTable();
        switch (cmbvendedor.SelectedValue)
        {
            case "01":
                BE.vendorid = txt_busqueda02.Text.Trim().ToUpper();
                break;
            case "02":
                BE.vendorname = txt_busqueda02.Text.Trim().ToUpper();
                break;
            default:
                //**
                break;
        }
        try
        {
            //Eliminar Columnas Actuales(Opcional):
            dgb_vendedor.Columns.Clear();
            dgb_vendedor.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_vendedor.Columns.Add(image);

            BoundField DDNNI;
            DDNNI = new BoundField();
            DDNNI.DataField = "vendorid";
            DDNNI.HeaderText = "CODIGO";
            DDNNI.ItemStyle.Width = 50;
            dgb_vendedor.Columns.Add(DDNNI);

            BoundField NOMBR;
            NOMBR = new BoundField();
            NOMBR.DataField = "vendorname";
            NOMBR.HeaderText = "VENDEDOR";
            NOMBR.ItemStyle.Width = 250;
            dgb_vendedor.Columns.Add(NOMBR);

            BE.filtro = "2";

            dt = BL.GetAll_Filtro(Session["ssEmpresaID"].ToString(), BE).Tables[0];
            if (dt.Rows.Count > 0)
            {
                dgb_vendedor.DataSource = dt;
                dgb_vendedor.DataBind();
                dgb_vendedor.Visible = true;
            }
        }
        catch (Exception ex)
        {
            throw ex;// ClientMessage(ex.Message);
        }
    }

    private void reporte_pdf(string pagina)
    {
        try
        {
            string strURL = "";
            //string strCifrado = funcript.EncryptData(strURL);
            string cifrado = funcript.EncryptToString(strURL);
            //ClientMessage(cifrado);
            Literal li = new Literal();
            StringBuilder sbMensaje = new StringBuilder();
            sbMensaje.Append("<script type='text/javascript'>");
            /*sbMensaje.Append("window.open('ve_rpt_docs.aspx?data=" + cifrado + "', 'mywindow','location=0,status=0,scrollbars=0,resizable=0,menubar=0,channelmode=0,directories=0,fullscreen=0,titlebar=0,toolbar=0')");*/
            sbMensaje.Append("window.open('Reportes/"+ pagina.ToString() +"?data=" + cifrado + "', 'mywindow','location=0,status=0,scrollbars=0,resizable=1,menubar=0,toolbar=0')");
            sbMensaje.Append("</script>");
            //Agremamos el texto del stringbuilder al literal
            li.Text = sbMensaje.ToString();

            //Agregamos el literal a la pagina
            Page.Controls.Add(li);
        }