protected void btn_excel_Click(object sender, EventArgs e)
        {
            Response.Clear();

            Response.AddHeader("content-disposition", "attachment;filename=SOPRODI_VEND_CLIE_" + DateTime.Now.ToShortDateString() + ".xls");

            Response.Charset = "";

            // If you want the option to open the Excel file without saving than

            // comment out the line below

            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            Response.ContentType = "application/vnd.xls";

            System.IO.StringWriter stringWrite = new System.IO.StringWriter();

            System.Web.UI.HtmlTextWriter htmlWrite =
                new HtmlTextWriter(stringWrite);

            G_INFORME_TOTAL_VENDEDOR.RenderControl(htmlWrite);

            Response.Write(stringWrite.ToString());

            Response.End();
        }
Ejemplo n.º 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string produc = agregra_comillas(l_vendedores.Text);
            string desde  = txt_desde.Text;
            string hasta  = txt_hasta.Text;

            string where3 = " where cod >= 1000 and cod <= 9000 ";

            if (desde != "")
            {
                where3 += " and convert(datetime, u.[F.Recib], 103)  >= convert(datetime, '" + desde + "', 103) ";
            }

            if (hasta != "")
            {
                where3 += " and convert(datetime, u.[F.Recib], 103)  <= convert(datetime, '" + hasta + "', 103) ";
            }
            if (produc != "")
            {
                where3 += " and  u.cod in (" + produc + ")";
            }

            div_report.Visible = true;

            DataTable dt2 = ReporteRNegocio.lista_costosimpot(where3);

            sub_dolar = 0;
            G_INFORME_TOTAL_VENDEDOR.DataSource = dt2;
            G_INFORME_TOTAL_VENDEDOR.DataBind();
            JQ_Datatable();
        }
Ejemplo n.º 3
0
        protected void btn_informe_Click(object sender, EventArgs e)
        {
            div_report.Visible = true;
            G_INFORME_TOTAL_VENDEDOR.Visible    = true;
            G_INFORME_TOTAL_VENDEDOR.DataSource = ReporteRNegocio.trae_log_fich_();
            G_INFORME_TOTAL_VENDEDOR.DataBind();

            ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeee", "<script> new Tablesort(document.getElementById('ContentPlaceHolder_Contenido_G_INFORME_TOTAL_VENDEDOR')); </script>", false);
        }
Ejemplo n.º 4
0
        protected void btn_informe_Click(object sender, EventArgs e)
        {
            string bodega    = agregra_comillas(l_grupos.Text);
            string productos = agregra_comillas(l_vendedores.Text);

            string where = " and 1=1";

            if (bodega != "")
            {
                where += " and bodega in (" + agregra_comillas(bodega) + ")";
            }

            if (productos != "")
            {
                where += " and producto in (" + agregra_comillas(productos) + ") ";
            }


            div_report.Visible = true;
            G_INFORME_TOTAL_VENDEDOR.Visible    = true;
            G_INFORME_TOTAL_VENDEDOR.DataSource = ReporteRNegocio.productos_compras(where);
            G_INFORME_TOTAL_VENDEDOR.DataBind();

            string where2 = " and 1=1";

            if (l_grupos.Text != "")
            {
                where2 += " and siteid in (" + agregra_comillas(l_grupos.Text) + ")";
            }
            DataTable dt = new DataTable();

            try
            {
                dt = ReporteRNegocio.listar_ALL_productos_stock(where2, HttpContext.Current.Session["clase"].ToString());
                //dt.Rows.Add(new Object[] { "-1", "-- Todos --" });
                DataView dv3 = dt.DefaultView;
                dv3.Sort = "descr";
                dt       = dv3.ToTable();
                d_producto.DataSource     = dt;
                d_producto.DataTextField  = "descr";
                d_producto.DataValueField = "invtid";
                d_producto.DataBind();


                foreach (ListItem item in d_producto.Items)
                {
                    if (l_vendedores.Text.Contains(item.Value.ToString()))
                    {
                        item.Selected = true;
                    }
                }
            }
            catch { }

            ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeees", "<script> new Tablesort(document.getElementById('ContentPlaceHolder_Contenido_G_INFORME_TOTAL_VENDEDOR')); </script>", false);
        }
        protected void btn_informe_Click(object sender, EventArgs e)
        {
            //string vendedores = agregra_comillas(l_vendedores.Text);
            //string clientes = agregra_comillas(l_clientes.Text);


            //div_report.Visible = true;

            if (Txt_num_doc.Text != "")
            {
                string where = " where númfactura in (" + agregra_comillas(Txt_num_doc.Text) + ")";

                string es_vendedor = ReporteRNegocio.esvendedor(USER);

                if (es_vendedor == "2")
                {
                    where += " and codvendedor in ('" + USER + "')";
                }

                string grupos_del_usuario = agregra_comillas(ReporteRNegocio.grupos_usuario(User.Identity.Name.ToString()));

                if (grupos_del_usuario == "")
                {
                    grupos_del_usuario = agregra_comillas(ReporteRNegocio.grupos_usuario_v_report(User.Identity.Name.ToString()));
                }



                where += " and user1 in (" + grupos_del_usuario + ")";

                div_report.Visible = true;
                G_INFORME_TOTAL_VENDEDOR.Visible    = true;
                G_INFORME_TOTAL_VENDEDOR.DataSource = ReporteRNegocio.busca_factura(where);
                G_INFORME_TOTAL_VENDEDOR.DataBind();
            }


            ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeee", "<script> new Tablesort(document.getElementById('ContentPlaceHolder_Contenido_G_INFORME_TOTAL_VENDEDOR')); </script>", false);
        }
Ejemplo n.º 6
0
        protected void btn_excel_Click(object sender, EventArgs e)
        {
            Response.Clear();

            Response.AddHeader("content-disposition", "attachment;filename=SOPRODI_VEND_CLIE_" + DateTime.Now.ToShortDateString() + ".xls");

            Response.Charset = "";

            // If you want the option to open the Excel file without saving than

            // comment out the line below

            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            Response.ContentType = "application/vnd.xls";

            System.IO.StringWriter stringWrite = new System.IO.StringWriter();

            System.Web.UI.HtmlTextWriter htmlWrite =
                new HtmlTextWriter(stringWrite);


            string HTML_EXCEL = "<label> TASA CAMBIO: " + tx_dolar.Text + " </label>    -   <label> " + CB_TIPO_DOC_GRILLA.SelectedItem.ToString() + "  </label>  <label> " + TX_AÑO.Text + " </label>";

            HTML_EXCEL += "";
            //HTML += "</div>";

            R_Excel_1.InnerHtml = HTML_EXCEL;

            R_Excel_1.RenderControl(htmlWrite);

            G_INFORME_TOTAL_VENDEDOR.RenderControl(htmlWrite);

            Response.Write(stringWrite.ToString());

            Response.End();
        }
Ejemplo n.º 7
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            string okey = ReporteRNegocio.guardar_usd_cobro(CB_TIPO_DOC_GRILLA.SelectedValue, TX_AÑO.Text, tx_dolar.Text, tx_valor_mensual.Text);


            string desde_1 = "";
            string desde_2 = "";

            string where = "";
            string fecha_compra = "";

            string bodega       = agregra_comillas(l_grupos.Text);
            string productos    = agregra_comillas(l_vendedores.Text);
            string bodega2      = agregra_comillas(lb_bodegas2.Text);
            string where_bodega = "";

            if (productos != "")
            {
                where += " and invtid in (" + productos + ")";
            }
            if (bodega2 != "")
            {
                where        += " and siteid in (" + bodega2 + ")";
                where_bodega += " and siteid in (" + bodega2 + ")";
            }

            div_report.Visible = true;
            G_INFORME_TOTAL_VENDEDOR.Visible = true;

            DataTable dt2_cobro = crear_cobro_(ReporteRNegocio.costo_sobrealmacenaje(where, CB_TIPO_DOC_GRILLA.SelectedValue, TX_AÑO.Text, where_bodega));
            DataTable dt2       = dt2_cobro;

            total_rows = dt2.Rows.Count;
            G_INFORME_TOTAL_VENDEDOR.DataSource = dt2;
            G_INFORME_TOTAL_VENDEDOR.DataBind();
            JQ_Datatable();
        }
Ejemplo n.º 8
0
        protected void btn_informe_Click(object sender, EventArgs e)
        {
            string bodega    = agregra_comillas(l_grupos.Text);
            string productos = agregra_comillas(l_vendedores.Text);

            string where = " and 1=1";

            if (bodega != "")
            {
                where += " and bodega in (" + agregra_comillas(bodega) + ")";
            }

            if (productos != "")
            {
                where += " and producto in (" + agregra_comillas(productos) + ") ";
            }


            div_report.Visible = true;
            G_INFORME_TOTAL_VENDEDOR.Visible    = true;
            G_INFORME_TOTAL_VENDEDOR.DataSource = ReporteRNegocio.productos_compras(where);
            G_INFORME_TOTAL_VENDEDOR.DataBind();

            string where2 = " and 1=1";

            if (l_grupos.Text != "")
            {
                where2 += " and siteid in (" + agregra_comillas(l_grupos.Text) + ")";
            }
            DataTable dt = new DataTable();

            try
            {
                string grupos_del_usuario = agregra_comillas(ReporteRNegocio.grupos_usuario(User.Identity.Name.ToString()));

                if (grupos_del_usuario == "")
                {
                    grupos_del_usuario = agregra_comillas(ReporteRNegocio.grupos_usuario_v_report(User.Identity.Name.ToString()));
                }

                List <string> grupos = grupos_del_usuario.Split(',').ToList();


                string clase = " ";

                if (grupos.Count == 4)
                {
                }
                else
                {
                    if (grupos_del_usuario.ToUpper().Replace("'", "").Trim() == "GRANOS")
                    {
                        clase += " where b.glclassid in ('INSU', 'CANI')  ";
                    }
                    else if (grupos_del_usuario.Contains("Abarrotes") || grupos_del_usuario.Contains("CMQuillota") || grupos_del_usuario.Contains("MayoristasLV"))
                    {
                        clase += " where b.glclassid in ('ABAR', 'MANI') ";
                    }
                }



                dt = ReporteRNegocio.listar_ALL_productos_stock(where2, clase);
                //dt.Rows.Add(new Object[] { "-1", "-- Todos --" });
                DataView dv3 = dt.DefaultView;
                dv3.Sort = "descr";
                dt       = dv3.ToTable();
                d_producto.DataSource     = dt;
                d_producto.DataTextField  = "descr";
                d_producto.DataValueField = "invtid";
                d_producto.DataBind();


                foreach (ListItem item in d_producto.Items)
                {
                    if (l_vendedores.Text.Contains(item.Value.ToString()))
                    {
                        item.Selected = true;
                    }
                }
            }
            catch { }

            ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeees", "<script> new Tablesort(document.getElementById('ContentPlaceHolder_Contenido_G_INFORME_TOTAL_VENDEDOR')); </script>", false);
        }
Ejemplo n.º 9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            tx_valor_mensual.Text = "";
            tx_dolar.Text         = "";
            DataTable dt = ReporteRNegocio.traer_usd_cobro(CB_TIPO_DOC_GRILLA.SelectedValue, TX_AÑO.Text);

            foreach (DataRow r in dt.Rows)
            {
                tx_dolar.Text         = r[3].ToString();
                tx_valor_mensual.Text = r[4].ToString();
            }


            string desde_1 = "";
            string desde_2 = "";

            string where = "";
            string fecha_compra = "";

            string bodega       = agregra_comillas(l_grupos.Text);
            string productos    = agregra_comillas(l_vendedores.Text);
            string bodega2      = agregra_comillas(lb_bodegas2.Text);
            string where_bodega = "";

            if (productos != "")
            {
                where += " and invtid in (" + productos + ")";
            }
            if (bodega2 != "")
            {
                where        += " and siteid in (" + bodega2 + ")";
                where_bodega += " and siteid in (" + bodega2 + ")";
            }

            div_report.Visible = true;
            G_INFORME_TOTAL_VENDEDOR.Visible = true;

            string clase = "";

            if (rd_humano.Checked)
            {
                where += " and  glclassid in ('ABAR', 'MANI') and invtid > '1000' and invtid <> '9918' ";
            }
            else
            {
                where += " and  glclassid <> 'ABAR' and glclassid <>  'MANI'  and invtid <> '9905'  and invtid <> '9999'  and invtid <> '9907'   ";
            }


            DataTable dt2_cobro = crear_cobro_(ReporteRNegocio.costo_sobrealmacenaje(where, CB_TIPO_DOC_GRILLA.SelectedValue, TX_AÑO.Text, where_bodega));



            DataTable dt2 = dt2_cobro;

            total_rows = dt2.Rows.Count;
            G_INFORME_TOTAL_VENDEDOR.DataSource = dt2;
            G_INFORME_TOTAL_VENDEDOR.DataBind();
            JQ_Datatable();


            ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeees", "<script> CARGANDO_CLOSE(); </script>", false);



            if (rd_humano.Checked)
            {
                clase = "  b.glclassid in ('ABAR', 'MANI') and b.invtid > '1000' and b.invtid <> '9918' ";
            }
            else
            {
                clase = "  b.glclassid <> 'ABAR' and b.glclassid <>  'MANI'  and b.invtid <> '9905'  and b.invtid <> '9999'  and b.invtid <> '9907'   ";
            }

            try
            {
                DataView dtv = new DataView();

                cargar_combo_producto(ReporteRNegocio.listar_ALL_productos_stock_guion_2("", clase), dtv);


                foreach (ListItem item in d_producto.Items)
                {
                    if (l_vendedores.Text.Contains(item.Value.ToString()))
                    {
                        item.Selected = true;
                    }
                }
            }
            catch { }
        }
Ejemplo n.º 10
0
        protected void btn_informe_Click(object sender, EventArgs e)
        {
            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeee", "<script> new Tablesort(document.getElementById('ContentPlaceHolder_Contenido_G_PRODUCTOS')); </script>", false);

            //if (l_vendedores.Text != "" && l_clientes.Text != "" && txt_desde.Text != "" && txt_hasta.Text != "" && l_grupos.Text != "")
            //{
            string vendedores = agregra_comillas(l_vendedores.Text);
            string clientes   = agregra_comillas(l_clientes.Text);
            string desde      = txt_desde.Text;
            string hasta      = txt_hasta.Text;
            string grupos     = agregra_comillas(l_grupos.Text);;

            string grupos_del_usuario = agregra_comillas(ReporteRNegocio.grupos_usuario(User.Identity.Name.ToString()));

            if (grupos_del_usuario == "")
            {
                grupos_del_usuario = agregra_comillas(ReporteRNegocio.grupos_usuario_v_report(User.Identity.Name.ToString()));
            }


            DataTable dt2; DataView dtv = new DataView();

            dt2 = ReporteRNegocio.carga_grupos(txt_desde.Text, txt_hasta.Text, grupos_del_usuario);
            if (dt2.Rows.Count <= 0)
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeee", "<script language='javascript'>NO_GRUPOS();</script>", false);
            }
            else
            {
                string es_vendedor = ReporteRNegocio.esvendedor(USER);
                string where = " where FechaFactura >= CONVERT(datetime,'" + desde + "', 103)  and FechaFactura <= CONVERT(datetime,'" + hasta + "',103) ";
                if (grupos != "")
                {
                    where = where + " and user1 in (" + grupos + ") ";
                }
                else if (es_vendedor != "2")
                {
                    where = where + " and user1 in (" + agregra_comillas(ReporteRNegocio.grupos_usuario(USER)) + ")";
                }
                else if (es_vendedor == "2")
                {
                    where = where + " and user1 in (" + agregra_comillas(ReporteRNegocio.grupos_usuario_v_report(USER)) + ")";
                }

                if (clientes != "")
                {
                    where = where + " and rutcliente in (" + clientes + ") ";
                }
                if (vendedores != "")
                {
                    where = where + " and codvendedor in (" + vendedores + ") ";
                }
                if (es_vendedor == "2")
                {
                    where += " and codvendedor in ('" + USER + "')";
                }
                div_report.Visible               = true;
                cont_periodos                    = 0;
                G_INFORME_VENDEDOR.Visible       = false;
                G_INFORME_TOTAL_VENDEDOR.Visible = true;
                string periodos = ReporteRNegocio.listar_periodos_(where);
                //aux = ReporteRNegocio.listar_resumen_periodo(where + " and periodo in ("+agregra_comillas(periodos)+")");
                totales = new DataTable();

                List <string> periodos_list = periodos.Split(',').ToList();

                totales.Columns.Add("FACTORES/Periodos");
                int colum = periodos_list.Count;

                foreach (string r in periodos_list)
                {
                    totales.Columns.Add(r);
                }
                DataRow       row;
                List <string> nombre_factores = get_factores();

                // CAPI
                //totales.Columns.Add("Total general");

                for (int i = 0; i <= 6; i++)
                {
                    row = totales.NewRow();
                    if (nombre_factores[i].ToString().Contains("Percentil "))
                    {
                        row["FACTORES/Periodos"] = nombre_factores[i] + t_percentil.Text + "%";
                    }
                    else
                    {
                        row["FACTORES/Periodos"] = nombre_factores[i];
                    }
                    totales.Rows.Add(row);

                    // CAPI
                    for (int y = 0; y < colum; y++)
                    {
                        if (i == 0)
                        {
                            if (y == colum)
                            {
                                // CAPI
                                // totales.Rows[i][y + 1] = ReporteRNegocio.Facturación_Mes(agregra_comillas(periodos), where).ToString("N0");
                            }
                            else
                            {
                                string periodo = totales.Columns[y + 1].ColumnName;
                                totales.Rows[i][y + 1] = ReporteRNegocio.Facturación_Mes(periodo, where).ToString("N0");
                            }
                        }
                        if (i == 1)
                        {
                            if (y == colum)
                            {
                                // CAPI
                                //totales.Rows[i][y + 1] = ReporteRNegocio._cltes_con_vta(agregra_comillas(periodos), where).ToString("N0");
                            }
                            else
                            {
                                string periodo = totales.Columns[y + 1].ColumnName;
                                totales.Rows[i][y + 1] = ReporteRNegocio._cltes_con_vta(periodo, where).ToString("N0");
                            }
                        }
                        if (i == 2)
                        {
                            totales.Rows[i][y + 1] = (+(Double.Parse(totales.Rows[0][y + 1].ToString().Replace(".", ""))) / (Double.Parse(totales.Rows[1][y + 1].ToString().Replace(".", "")))).ToString("N0");
                        }
                        if (i == 3)
                        {
                            if (y == colum)
                            {
                                // CAPI
                                //List<int> percen = (ReporteRNegocio.Datos_para_percentil(agregra_comillas(periodos), where)).ToList();
                                //if (percen.Count == 0) { totales.Rows[i][y + 1] = "0"; }
                                //else
                                //{
                                //    Double por_percentil;
                                //    if (t_percentil.Text == "") { por_percentil = 0.5; }
                                //    else
                                //    {
                                //        por_percentil = Math.Round(Double.Parse(t_percentil.Text) / 100, 2);
                                //    }
                                //    totales.Rows[i][y + 1] = Math.Round(Percentile(percen.ToArray(), por_percentil)).ToString("N0");
                                //}
                            }
                            else
                            {
                                string      periodo = totales.Columns[y + 1].ColumnName;
                                List <long> percen  = ReporteRNegocio.Datos_para_percentil(periodo, where);
                                if (percen.Count == 0)
                                {
                                    totales.Rows[i][y + 1] = "0";
                                }
                                else
                                {
                                    Double por_percentil;
                                    if (t_percentil.Text == "")
                                    {
                                        por_percentil = 0.5;
                                    }
                                    else
                                    {
                                        por_percentil = Math.Round(Double.Parse(t_percentil.Text) / 100, 2);
                                    }
                                    totales.Rows[i][y + 1] = Math.Round(Percentile(percen.ToArray(), por_percentil)).ToString("N0");
                                }
                            }
                        }

                        if (i == 4)
                        {
                            if (y == colum)
                            {
                                // CAPI
                                //totales.Rows[i][y + 1] = ReporteRNegocio.sum_sobre_este_percentil(agregra_comillas(periodos), where, Double.Parse(totales.Rows[3][y + 1].ToString().Replace(".", ""))).ToString("N0");
                            }
                            else
                            {
                                string periodo = totales.Columns[y + 1].ColumnName;
                                totales.Rows[i][y + 1] = ReporteRNegocio.sum_sobre_este_percentil(periodo, where, Double.Parse(totales.Rows[3][y + 1].ToString().Replace(".", ""))).ToString("N0");
                            }
                        }

                        if (i == 5)
                        {
                            Double sumatoria             = (Double.Parse(totales.Rows[0][y + 1].ToString().Replace(".", "")));
                            Double sum_vent_sobre_percen = (Double.Parse(totales.Rows[4][y + 1].ToString().Replace(".", "")));
                            totales.Rows[i][y + 1] = Math.Round((sum_vent_sobre_percen / sumatoria * 100)).ToString() + " %";
                        }

                        if (i == 6)
                        {
                            if (y <= colum - 2)
                            {
                                Double sum_mes          = (Double.Parse(totales.Rows[0][y + 1].ToString().Replace(".", "")));
                                Double sum_mes_anterior = (Double.Parse(totales.Rows[0][y + 2].ToString().Replace(".", "")));
                                totales.Rows[i][y + 1] = (Math.Round((sum_mes * 100 / sum_mes_anterior)) - 100).ToString() + " %";
                            }
                        }
                    }
                }

                G_INFORME_TOTAL_VENDEDOR.DataSource = totales;
                G_INFORME_TOTAL_VENDEDOR.DataBind();

                //VOLVER A CARGAR LOS MULTISELECT

                DataTable dt = new DataTable();

                try
                {
                    dt = ReporteRNegocio.carga_grupos(desde, hasta, grupos_del_usuario);
                    //dt.Rows.Add(new Object[] { "-1", "-- Todos --" });
                    DataView dv2 = dt.DefaultView;
                    dv2.Sort = "user1";
                    dt       = dv2.ToTable();
                    d_grupos_usuario.DataSource     = dt;
                    d_grupos_usuario.DataTextField  = "user1";
                    d_grupos_usuario.DataValueField = "user1";
                    //d_vendedor_.SelectedIndex = -1;
                    d_grupos_usuario.DataBind();


                    foreach (ListItem item in d_grupos_usuario.Items)
                    {
                        if (l_grupos.Text.Contains(item.Value.ToString()))
                        {
                            item.Selected = true;
                        }
                    }
                }
                catch { }

                string where2 = " where FechaFactura >= CONVERT(datetime,'" + desde + "', 103) " +
                                " and FechaFactura <= CONVERT(datetime,'" + hasta + "',103) ";

                if (grupos != "")
                {
                    where2 = where2 + " and user1 in (" + grupos + ") ";
                }
                else if (es_vendedor != "2")
                {
                    where2 = where2 + " and user1 in (" + agregra_comillas(ReporteRNegocio.grupos_usuario(USER)) + ")";
                }
                else if (es_vendedor == "2")
                {
                    where2 = where2 + " and user1 in (" + agregra_comillas(ReporteRNegocio.grupos_usuario_v_report(USER)) + ")";
                }

                if (es_vendedor == "2")
                {
                    where2 += " and codvendedor in ('" + USER + "')";
                }

                try
                {
                    dt = ReporteRNegocio.listar_ALL_vendedores(where2);
                    //dt.Rows.Add(new Object[] { "-1", "-- Todos --" });
                    DataView dv2 = dt.DefaultView;
                    dv2.Sort = "cod_vend";
                    dt       = dv2.ToTable();
                    d_vendedor_.DataSource     = dt;
                    d_vendedor_.DataTextField  = "nom_vend";
                    d_vendedor_.DataValueField = "cod_vend";
                    //d_vendedor_.SelectedIndex = -1;
                    d_vendedor_.DataBind();


                    foreach (ListItem item in d_vendedor_.Items)
                    {
                        if (l_vendedores.Text.Contains(item.Value.ToString()))
                        {
                            item.Selected = true;
                        }
                    }
                }
                catch { }
                where2 = "";
                where2 = " where FechaFactura >= CONVERT(datetime,'" + desde + "', 103) " +
                         " and FechaFactura <= CONVERT(datetime,'" + hasta + "',103) ";

                if (grupos != "")
                {
                    where2 = where2 + " and user1 in (" + grupos + ") ";
                }
                else if (es_vendedor != "2")
                {
                    where2 = where2 + " and user1 in (" + agregra_comillas(ReporteRNegocio.grupos_usuario(USER)) + ")";
                }
                else if (es_vendedor == "2")
                {
                    where2 = where2 + " and user1 in (" + agregra_comillas(ReporteRNegocio.grupos_usuario_v_report(USER)) + ")";
                }
                if (vendedores != "")
                {
                    where2 += " and codvendedor in (" + vendedores + ")";
                }
                if (es_vendedor == "2")
                {
                    where2 += " and codvendedor in ('" + USER + "')";
                }

                try
                {
                    dt = ReporteRNegocio.listar_ALL_cliente2(where2);
                    //dt.Rows.Add(new Object[] { "-1", "-- Todos --" });
                    DataView dv3 = dt.DefaultView;
                    dv3.Sort                 = "nom_cliente";
                    dt                       = dv3.ToTable();
                    d_cliente.DataSource     = dt;
                    d_cliente.DataTextField  = "nom_cliente";
                    d_cliente.DataValueField = "rut_cliente";
                    //d_vendedor_.SelectedIndex = -1;
                    d_cliente.DataBind();


                    foreach (ListItem item in d_cliente.Items)
                    {
                        if (l_clientes.Text.Contains(item.Value.ToString()))
                        {
                            item.Selected = true;
                        }
                    }
                }
                catch { }
            }
            ScriptManager.RegisterStartupScript(Page, this.GetType(), "teeee", "<script> new Tablesort(document.getElementById('ContentPlaceHolder_Contenido_G_PRODUCTOS')); </script>", false);
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string desde = txt_desde.Text;
            string hasta = txt_hasta.Text;
            string grupos_del_usuario = agregra_comillas(ReporteRNegocio.grupos_usuario(User.Identity.Name.ToString()));

            if (grupos_del_usuario == "")
            {
                grupos_del_usuario = agregra_comillas(ReporteRNegocio.grupos_usuario_v_report(User.Identity.Name.ToString()));
            }
            List <string> grupos = grupos_del_usuario.Split(',').ToList();
            string        where3 = "";

            if (grupos.Count == 4)
            {
                where3 += "  where  1=1 ";
            }
            else
            {
                if (grupos_del_usuario.ToUpper().Replace("'", "").Trim() == "GRANOS")
                {
                    where3 += "  where  b.DescEmisor = 'Granos' ";
                }
                else if (grupos_del_usuario.Contains("Abarrotes") || grupos_del_usuario.Contains("CMQuillota") || grupos_del_usuario.Contains("MayoristasLV"))
                {
                    where3 += " where  b.DescEmisor <> 'Granos' ";
                }
            }
            //select * from[VPEDIDOCABECERA] where FechaEmision >= CONVERT(datetime, '21/07/2017', 103)
            if (desde != "")
            {
                where3 += " and convert(datetime,b.FechaEmision ,103)  >= convert(datetime, '" + desde + "', 103) ";
            }
            if (hasta != "")
            {
                where3 += " and convert(datetime,b.FechaEmision ,103)   <= convert(datetime, '" + hasta + "', 103) ";
            }
            //if (clientes != "")
            //{

            //    where3 += " and b.rut in (" + clientes + ")";
            //}
            if (txt_sp.Text != "")
            {
                where3 += " and b.CodDocumento in (" + agregra_comillas(txt_sp.Text) + ")";
            }

            //SPSP
            DataTable dt2 = ReporteRNegocio.VM_listar_sp(where3);

            string cod_aux      = "";
            string facturas_aux = "";

            DataTable sp_malas = new DataTable();

            sp_malas.Columns.Add("sp");
            sp_malas.Columns.Add("facturas");
            sp_malas.Columns.Add("estado");


            DataTable sp_for = new DataTable();

            sp_for.Columns.Add("sp");
            sp_for.Columns.Add("estado");
            sp_for.Columns.Add("facturas");
            string facturas_x_sps = "";

            foreach (DataRow r in dt2.Rows)
            {
                //20 -- OK
                //10S -- SinFactura
                //10P -- Cantidad Distintas

                //0  coddoc //24 cod //25 cant

                if (r[13].ToString() == "Aprobado" && r[28].ToString() == "no")
                {
                    if (cod_aux == "")
                    {
                        cod_aux = r[0].ToString();
                        sp_for  = new DataTable();
                        sp_for.Columns.Add("sp");
                        sp_for.Columns.Add("estado");
                        sp_for.Columns.Add("facturas");
                    }

                    DataTable procesado = ReporteRNegocio.SP_Marcelo(r[0].ToString().Trim(), r[26].ToString().Trim(), r[27].ToString().Trim());
                    DataRow   row       = procesado.Rows[0];

                    if (r[0].ToString() == cod_aux)
                    {
                        //if (row["estado"].ToString().Substring(0, 3) == "10P")
                        //{
                        facturas_aux = row["facturas"].ToString();

                        if (facturas_aux.Trim() != "")
                        {
                            facturas_x_sps += row["facturas"].ToString() + ", ";
                            r[14]           = facturas_x_sps.Substring(0, facturas_x_sps.Length - 3);
                        }
                        DataRow row_sp1 = sp_for.NewRow();
                        row_sp1["sp"]     = cod_aux;
                        row_sp1["estado"] = row["estado"].ToString().Substring(0, 3);
                        string aux_aca = "";
                        try
                        {
                            aux_aca = facturas_x_sps.Substring(0, facturas_x_sps.Length - 2);
                        }
                        catch
                        {
                        }
                        row_sp1["facturas"] = aux_aca;
                        sp_for.Rows.Add(row_sp1);
                    }
                    else
                    {
                        string estado_univ = "";
                        foreach (DataRow r2 in sp_for.Rows)
                        {
                            if (r2[1].ToString() == "10P")
                            {
                                estado_univ = r2[1].ToString();
                                DataRow row_sp = sp_malas.NewRow();
                                row_sp["sp"]       = cod_aux;
                                row_sp["facturas"] = facturas_x_sps.Substring(0, facturas_x_sps.Length - 3);
                                row_sp["estado"]   = estado_univ;
                                sp_malas.Rows.Add(row_sp);
                                break;
                            }
                            else
                            {
                                estado_univ = r2[1].ToString();
                                DataRow row_sp = sp_malas.NewRow();
                                row_sp["sp"] = cod_aux;
                                try
                                {
                                    row_sp["facturas"] = facturas_x_sps.Substring(0, facturas_x_sps.Length - 2);
                                }
                                catch
                                {
                                    row_sp["facturas"] = "";
                                }
                                row_sp["estado"] = estado_univ;
                                sp_malas.Rows.Add(row_sp);
                            }
                        }

                        cod_aux = r[0].ToString();
                        sp_for  = new DataTable();
                        sp_for.Columns.Add("sp");
                        sp_for.Columns.Add("estado");
                        sp_for.Columns.Add("facturas");
                        facturas_x_sps = "";

                        facturas_x_sps += row["facturas"].ToString() + ", ";
                        r[14]           = facturas_x_sps.Substring(0, facturas_x_sps.Length - 2);

                        DataRow row_sp1 = sp_for.NewRow();
                        row_sp1["sp"]       = cod_aux;
                        row_sp1["estado"]   = row["estado"].ToString().Substring(0, 3);
                        row_sp1["facturas"] = facturas_x_sps.Substring(0, facturas_x_sps.Length - 2);
                        sp_for.Rows.Add(row_sp1);
                    }
                }
                else if (r[13].ToString() == "Aprobado")
                {
                    DataTable procesado = ReporteRNegocio.SP_Marcelo(r[0].ToString().Trim(), r[26].ToString().Trim(), r[27].ToString().Trim());
                    DataRow   row       = procesado.Rows[0];
                    r[14] = row["facturas"].ToString();
                }
            }

            string estado_univ1 = "";

            foreach (DataRow r2 in sp_for.Rows)
            {
                if (r2[1].ToString() == "10P")
                {
                    estado_univ1 = r2[1].ToString();
                    DataRow row_sp = sp_malas.NewRow();
                    row_sp["sp"]       = cod_aux;
                    row_sp["facturas"] = r2[2].ToString();
                    row_sp["estado"]   = estado_univ1;
                    sp_malas.Rows.Add(row_sp);
                    break;
                }
                else
                {
                    estado_univ1 = r2[1].ToString();
                    DataRow row_sp = sp_malas.NewRow();
                    row_sp["sp"]       = cod_aux;
                    row_sp["facturas"] = r2[2].ToString();
                    row_sp["estado"]   = estado_univ1;
                    sp_malas.Rows.Add(row_sp);
                }
            }


            foreach (DataRow r in dt2.Rows)
            {
                if (r[13].ToString() == "Aprobado")
                {
                    foreach (DataRow r2 in sp_malas.Rows)
                    {
                        if (r[0].ToString() == r2[0].ToString())
                        {
                            string cad = r2[1].ToString();
                            Dictionary <string, int> contador = new Dictionary <string, int>();

                            foreach (string item in cad.Split(new char[] { ',' }))
                            {
                                if (contador.ContainsKey(item.Trim()))
                                {
                                    contador[item.Trim()] = contador[item.Trim()] + 1;
                                }
                                else
                                {
                                    contador.Add(item.Trim(), 1);
                                }
                            }
                            string resultado = "";
                            foreach (KeyValuePair <string, int> item in contador)
                            {
                                if (item.Value >= 1)
                                {
                                    resultado = string.Format("{0},{1}", resultado, item.Key);
                                }
                            }
                            string cadd = resultado.Remove(0, 1);

                            if (r2[2].ToString() == "10S" && cadd.Trim() != "")
                            {
                                r[14] = cadd;
                                r[25] = "10P";
                            }
                            else
                            {
                                r[14] = cadd;
                                r[25] = r2[2].ToString();
                            }
                        }
                    }
                }
                r[14] = r[14].ToString().Replace(",", ", ");
            }
            if (dt2.Rows.Count > 0)
            {
                dt2 = dt2.AsEnumerable()
                      .GroupBy(r => new { Col1 = r["CodDocumento"] })
                      .Select(g => g.OrderBy(r => r["CodDocumento"]).First())
                      .CopyToDataTable();
            }
            G_INFORME_TOTAL_VENDEDOR.DataSource = dt2;
            G_INFORME_TOTAL_VENDEDOR.DataBind();
            JQ_Datatable();
            DIV_LISTADO.Visible = true;
        }
Ejemplo n.º 12
0
 private void CARGAR_DIARIO1()
 {
     G_INFORME_TOTAL_VENDEDOR.Visible    = true;
     G_INFORME_TOTAL_VENDEDOR.DataSource = ReporteRNegocio.listar_diario1(USER);
     G_INFORME_TOTAL_VENDEDOR.DataBind();
 }
Ejemplo n.º 13
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string desde_1 = "";
            string desde_2 = "";

            string where = "";
            string fecha_compra = "";

            if (txt_desde.Text != "")
            {
                desde_1 += " and r.trandate <= convert(date, '" + txt_desde.Text + "',103)";

                desde_2      = " and f.fecha <= convert(date, '" + txt_desde.Text + "', 103) ";
                fecha_compra = " and x.RcptDate  <= convert(datetime, '" + txt_desde.Text + "', 103) ";
                where       += " and fechafactura >= convert(date, '" + txt_desde.Text + "',103)";



                string bodega    = agregra_comillas(l_grupos.Text);
                string productos = agregra_comillas(l_vendedores.Text);
                string bodega2   = agregra_comillas(lb_bodegas2.Text);


                if (productos != "")
                {
                    where += " and t.producto in (" + productos + ")";
                }
                if (bodega != "")
                {
                    where += " and t.rutcliente in (" + bodega + ")";
                }
                if (bodega2 != "")
                {
                    where += " and t.bodega in (" + bodega2 + ")";
                }
            }
            else
            {
            }


            if (txt_hasta.Text != "")
            {
                desde_1 += " and r.trandate <= convert(date, '" + txt_hasta.Text + "',103)";

                desde_2      = " and f.fecha <= convert(date, t.fechafactura, 103) ";
                fecha_compra = " and x.RcptDate  <= convert(datetime, '" + txt_hasta.Text + "', 103) ";
                where       += " and fechafactura <= convert(date, '" + txt_hasta.Text + "',103)";


                sub_peso    = 0;
                sub_dolar   = 0;
                total_rows  = 0;
                cont_row    = 0;
                cost_excel  = 0;
                cost_impot  = 0;
                cost_compra = 0;

                utilidad_exce   = 0;
                utilidad_compra = 0;

                div_report.Visible = true;
                G_INFORME_TOTAL_VENDEDOR.Visible = true;

                DataTable dt2 = ReporteRNegocio.stock_facturado(desde_1, desde_2, where, fecha_compra);
                total_rows = dt2.Rows.Count;
                G_INFORME_TOTAL_VENDEDOR.DataSource = dt2;
                G_INFORME_TOTAL_VENDEDOR.DataBind();
                JQ_Datatable();
            }
        }
Ejemplo n.º 14
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string produc = agregra_comillas(l_vendedores.Text);
            string desde  = txt_desde.Text;
            string hasta  = txt_hasta.Text;

            string where3  = " where 1=1 ";
            string desde_2 = "";

            if (desde != "")
            {
                where3 += " and convert(datetime, u.[F.Recib], 103)  >= convert(datetime, '" + desde + "', 103) ";
            }

            if (hasta != "")
            {
                where3 += " and convert(datetime, u.[F.Recib], 103)  <= convert(datetime, '" + hasta + "', 103) ";
            }
            if (produc != "")
            {
                where3 += " and  u.cod in (" + produc + ")";
            }

            div_report.Visible = true;

            if (Session["comexx"].ToString() == "si")
            {
                btn_excel.Visible  = true;
                btn_excel2.Visible = false;
            }
            else
            {
                btn_excel2.Visible = true;
                btn_excel.Visible  = false;
            }

            if (tx_oc.Text != "")
            {
                where3 += " and  u.nbr in (" + agregra_comillas(tx_oc.Text) + ")";
            }
            if (tx_di.Text != "")
            {
                where3 += " and  u.NBR in ( select ponbr from V_COMPRA_SYS_OBSER where detalle = '" + tx_di.Text + "')";
            }



            string grups = ReporteRNegocio.grupos_usuario(User.Identity.Name);

            if (!grups.Contains("Granos"))
            {
                where3 += " and  u.cod >= 1000 ";
            }

            Session["where_excel"] = where3;

            where3 += " order by  CONVERT(datetime,u.[F.Recib],103) desc";



            DataTable dt2 = ReporteRNegocio.lista_compras(where3);

            monto_cos    = 0;
            monto_import = 0;
            monto_total  = 0;
            G_INFORME_TOTAL_VENDEDOR.DataSource = dt2;
            G_INFORME_TOTAL_VENDEDOR.DataBind();
            JQ_Datatable();
        }