// PINTAMOS EL VENDEDOR DE DICHA
 void Vendedor()
 {
     tb_cxc_vendorBL BL = new tb_cxc_vendorBL();
     tb_cxc_vendor BE = new tb_cxc_vendor();
     DataTable dt = new DataTable();
     BE.usuarweb = Session["ssUsuar"].ToString().Trim();
     dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
     if (dt.Rows.Count > 0)
     {
         txt_vendorid.Text = dt.Rows[0]["vendorid"].ToString();
         txt_vendorname.Text = dt.Rows[0]["vendorname"].ToString();
     }
 }
 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         switch (filtro)
         {
             case "PS":
                 tb_cxc_vendorBL PSBL = new tb_cxc_vendorBL();
                 tb_cxc_vendor PSBE = new tb_cxc_vendor();
                 DataTable PSDT = new DataTable();
                 PSBE.ddnni = GridView1.SelectedRow.Cells[2].Text;
                 PSDT = PSBL.GetAll(Session["ssEmpresaID"].ToString(), PSBE).Tables[0];
                 txt_vendorid.Text = PSDT.Rows[0]["vendorid"].ToString();
                 txt_vendorname.Text = PSDT.Rows[0]["vendorname"].ToString();
                 break;
             case "PR":
                  clienteBL BL = new clienteBL();
                  tb_cliente BE = new tb_cliente();
                  DataTable dt = new DataTable();
                  BE.ctacte = GridView1.SelectedRow.Cells[1].Text;
                  dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
                  txt_ctacte.Text = dt.Rows[0]["ctacte"].ToString();
                  txt_ctactename.Text = dt.Rows[0]["ctactename"].ToString();
                  txt_ruc.Text = dt.Rows[0]["nmruc"].ToString();
                  direc_entrega.Text = dt.Rows[0]["direc"].ToString();
                  break;
             case "PA":
                  txt_articidold.Text = GridView1.SelectedRow.Cells[1].Text;
                  MetodoCargarLineal();
                  break;
         }
         UpdatePanel2.Update();
         ModalPopupExtender2.Hide();
     }
     catch (Exception ex)
     {
         ClientMessage(ex.Message);
     }
 }
    private void data_gridVendedor()
    {
        tb_cxc_vendorBL BL = new tb_cxc_vendorBL();
        tb_cxc_vendor BE = new tb_cxc_vendor();

        switch (cbo_filtro.SelectedValue)
        {
            case "01":
                BE.vendorid = txt_filter.Text.Trim().ToUpper();
                break;
            case "02":
                BE.ddnni = txt_filter.Text.Trim().ToUpper();
                break;
            case "03":
                BE.vendorname = txt_filter.Text.Trim().ToUpper();
                break;
            default:
                //**
                break;
        }
        try
        {
            //Eliminar Columnas Actuales(Opcional):
            GridView1.Columns.Clear();
            GridView1.Width = 550;
            //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;
            GridView1.Columns.Add(image);

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

            BoundField APPAT;
            APPAT = new BoundField();
            APPAT.DataField = "ddnni";
            APPAT.HeaderText = "DNI";
            APPAT.ItemStyle.Width = 80;
            GridView1.Columns.Add(APPAT);

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

            GridView1.DataSource = BL.GetAll(Session["ssEmpresaID"].ToString(), BE);
            GridView1.DataBind();
            GridView1.Visible = true;
        }
        catch (Exception ex)
        {
            ClientMessage(ex.Message);
        }
    }
        private void form_cargar_datos(String posicion)
        {
            try
            {
                var BL = new tb_cxc_vendorBL();
                var BE = new tb_cxc_vendor();
                var dt = new DataTable();

                BE.vendorid = txtvendorid.Text.Trim().PadLeft(4, '0');
                BE.posicion = posicion.Trim();

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

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

                    txtvendorid.Text = dt.Rows[0]["grupoid"].ToString().Trim();
                    //gruponame.Text = dt.Rows[0]["gruponame"].ToString().Trim();
                    //ctacte.Text = dt.Rows[0]["ctacte"].ToString().Trim();
                    //ctactename.Text = dt.Rows[0]["ctactename"].ToString().Trim();

                    btn_editar.Enabled = true;
                    btn_eliminar.Enabled = true;
                    btn_imprimir.Enabled = true;

                    btn_log.Enabled = true;
                    btn_salir.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Update()
        {
            try
             {
                if (ValidaDatos())
                {
                    var BL = new tb_cxc_vendorBL();
                    var BE = new tb_cxc_vendor();
                    BE.vendorid = txtvendorid.Text.Trim();
                    BE.vendorname = txtNombrelargo.Text.ToUpper();
                    BE.ddnni = txtdni.Text.Trim();
                    BE.nmruc = txtruc.Text.Trim();
                    BE.telefono = txttelefono.Text.Trim();
                    BE.canalventaid = txtcanalvtaid.Text;
                    BE.direccion = txtdireccion.Text.ToUpper();
                    if (fIngreso.Checked)
                        BE.fech_ingre = Convert.ToDateTime(fIngreso.Text);
                    if (fCese.Checked)
                        BE.fech_cese = Convert.ToDateTime(fCese.Text);
                    BE.motivocese = txtmotcese.Text;
                    BE.usuarweb = txtusuarweb.Text.ToUpper();

                    if (BL.Update(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 Delete()
 {
     try
     {
         if (txtvendorid.Text.Trim().Length != 4)
         {
             MessageBox.Show("Falta Codigo Vendedor !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         else
         {
             var BL = new tb_cxc_vendorBL();
             var BE = new tb_cxc_vendor();
             BE.vendorid = txtvendorid.Text;
             if (BL.Delete(EmpresaID, BE))
             {
                 SEGURIDAD_LOG("E");
                 MessageBox.Show("Datos Eliminado Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 NIVEL_FORMS();
                 limpiar_documento();
                 form_bloqueado(false);
                 data_TablaVendedor();
                 btn_nuevo.Enabled = true;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void data_TablaVendedor()
        {
            if (TablaVendedor.Rows.Count > 0)
            {
                TablaVendedor.Rows.Clear();
            }
            var BL = new tb_cxc_vendorBL();
            var BE = new tb_cxc_vendor();

            BE.parameters = txtbusqueda.Text.Trim().ToUpper();
            TablaVendedor = BL.GetAll(EmpresaID, BE).Tables[0];
            if (TablaVendedor.Rows.Count > 0)
            {
                btn_imprimir.Enabled = true;
                dgb_vendedores.DataSource = TablaVendedor;
                dgb_vendedores.Rows[0].Selected = false;
            }
        }
 // VERIFICO COMO ESTOY INGRESANDO ( COMO QUE USUARIO ESTOY INGRESANDO )
 void ValIngreso()
 {
     String xusu = Session["ssUsuar"].ToString().Trim(); tb_cxc_vendorBL BL = new tb_cxc_vendorBL();
     tb_cxc_vendor BE = new tb_cxc_vendor();
     DataTable dt = new DataTable();
     BE.usuarweb = xusu;
     dt = BL.GetAll(Session["ssEmpresaID"].ToString(), BE).Tables[0];
     if (dt.Rows.Count > 0)
     {
         //txt_vendorname.Text = dt.Rows[0]["vendorname"].ToString();
         Response.Redirect("~/Comercial/Listados/Lst_PedidosPend.aspx");
     }
     else
     {
         //txt_vendorname.Text = "VENDEDOR SIN PEDIDOS";
         Response.Redirect("");
     }
 }
    protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            filtro = "PA";
            switch (filtro)
            {
                case "PS":
                    tb_cxc_vendorBL PSBL = new tb_cxc_vendorBL();
                    tb_cxc_vendor PSBE = new tb_cxc_vendor();
                    DataTable PSDT = new DataTable();
                    PSBE.ddnni = GridView1.SelectedRow.Cells[2].Text;
                    PSDT = PSBL.GetAll(Session["ssEmpresaID"].ToString(), PSBE).Tables[0];
                    txt_vendorid.Text = PSDT.Rows[0]["vendorid"].ToString();
                    txt_vendorname.Text = PSDT.Rows[0]["vendorname"].ToString();
                    break;
                case "PR":
                    String xctacte = GridView2.SelectedRow.Cells[1].Text;
                    ValidaCliente(xctacte);
                    break;
                case "PA":
                    txt_articidold.Text = GridView2.SelectedRow.Cells[1].Text;
                    MetodoCargarLineal(txt_articidold.Text);
                    break;
            }

        }
        catch (Exception ex)
        {
            //ClientMessage(ex.Message);
            Response.Redirect("ErrorPage/Frm_PaginaError_405.aspx");
        }

        GridView2.SelectedRowStyle.CssClass = "SeRoSty alert-success";
    }
 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         filtro = "PR";
         switch (filtro)
         {
             case "PS":
                 tb_cxc_vendorBL PSBL = new tb_cxc_vendorBL();
                 tb_cxc_vendor PSBE = new tb_cxc_vendor();
                 DataTable PSDT = new DataTable();
                 PSBE.ddnni = GridView1.SelectedRow.Cells[2].Text;
                 PSDT = PSBL.GetAll(Session["ssEmpresaID"].ToString(), PSBE).Tables[0];
                 txt_vendorid.Text = PSDT.Rows[0]["vendorid"].ToString();
                 txt_vendorname.Text = PSDT.Rows[0]["vendorname"].ToString();
                 break;
             case "PR":
                 String xctacte = GridView1.SelectedRow.Cells[1].Text;
                 ValidaCliente(xctacte);
                 break;
             case "PA":
                 txt_articidold.Text = GridView1.SelectedRow.Cells[1].Text;
                 MetodoCargarLineal("");
                 break;
         }
         //UpdatePanel2.Update();
         //ModalPopupExtender2.Hide();
         //data-dismiss="modal"
     }
     catch (Exception ex)
     {
         //ClientMessage(ex.Message);
         Response.Redirect("ErrorPage/Frm_PaginaError_405.aspx");
     }
 }