Example #1
0
 public GuardaSucursal(List <Models.SucPolanco> pedido, string suc, string usu, string coment, string cadena)
 {
     ConnectionString = cadena;
     sql.SetConnection(ConnectionString);
     sucursal      = suc;
     usuario       = usu;
     observaciones = coment;
     ped           = new List <Models.SucPolanco>(pedido);
     // descargaPedido(pedido,suc,usu,observaciones);
 }
        public ActionResult GuardaMaximos(Models.AdministracionModels v)
        {
            connectionString = CadenaConexion.getStringConnection();
            sql.SetConnection(connectionString);
            string sResult = "";

            v.estaTodobien = false;

            string maximoXarticulo = Request.Params["maximoXarticulo"];
            string maximoXSucursal = Request.Params["maximoXSucursal"];
            string maximoTotal     = Request.Params["maximoTotal"];

            string navegar = Request.Params["navegar"];
            string buscar  = Request.Params["buscar"];


            if (navegar != null || buscar != null)
            {
                return(RedirectToAction("Maximos", "Administracion", v));
            }

            //string str = "";//( maximoXarticulo.Trim().Length <= 0 || maximoXarticulo == null ) ? ( ( maximoXSucursal.Trim().Length <= 0 || maximoXSucursal == null ) ? (  maximoTotal.Trim().Length <= 0 || (maximoTotal == null  ) ? "Error" : maximoTotal.Trim() ): maximoXSucursal.Trim() ) : maximoXarticulo.Trim();
            string str = (maximoXarticulo == null || maximoXarticulo.Trim().Length <= 0) ? ((maximoXSucursal == null || maximoXSucursal.Trim().Length <= 0)? ((maximoTotal == null || maximoTotal.Trim().Length <= 0) ? "Error" : maximoTotal.Trim()): maximoXSucursal.Trim()) : maximoXarticulo.Trim();

            GuardarMaximos gm = new GuardarMaximos(v.maximos, connectionString);

            if (maximoXarticulo == null || maximoXarticulo.Trim().Length <= 0)
            {
                if (maximoXSucursal == null || maximoXSucursal.Trim().Length <= 0)
                {
                    if (maximoTotal == null || maximoTotal.Trim().Length <= 0)
                    {
                        str = "Error";
                    }
                    else
                    {
                        sResult = gm.guardarTodo();
                    }
                }
                else
                {
                    sResult = gm.guardarSucursal(maximoXSucursal.Trim());
                }
            }
            else
            {
                sResult = gm.guardarArticulo(maximoXarticulo.Trim());
            }


            connectionString = CadenaConexion.getStringConnection();
            sql.SetConnection(connectionString);


            //string s = "" + v.sucursal + "<br>" + v.usuario + "<br>";
            //GuardaSucursal gs = new GuardaSucursal(v.SucPolanco, v.sucursal, v.usuario, connectionString);


            //v.estaTodobien = gs.estaTodoBien();
            //v.nPedido = gs.cualPedidoEs();
            //  Response.Write("<h1>[query2]<br>" + sResult + " " + "</h1>");
            //return View(v);
            return(RedirectToAction("Maximos", "Administracion", v));
        }
Example #3
0
 // GET: GuardarMaximos
 public GuardarMaximos(List <Models.Maximos> max, string cadena)
 {
     ConnectionString = cadena;
     sql.SetConnection(ConnectionString);
     maximos = new List <Models.Maximos>(max);
 }
Example #4
0
        public Models.SucursalesModels llenaTablaCarrito(Models.SucursalesModels v)
        {
            connectionString = CadenaConexion.getStringConnection();
            sql.SetConnection(connectionString);
            v.contador = 0;
            string sucursal = v.sucursal.Trim();
            string skus     = v.sku == null || v.sku.Trim().Length <= 0 ? "%%" : v.sku.Trim();
            int    contador = v.contador == null || v.contador <= 0 ? 0 : v.contador;

            try
            {
                string s1 = "";
                string s2 = "";

                v.SucPolanco = new List <SucPolanco>();


                s1  = " select distinct  ltrim(rtrim(pr.LINEA)) as Linea, ltrim(rtrim(pr.ARTICULO)) as sku, ltrim(rtrim(pr.Descrip)) as Descrip, ";
                s1 += " isnull(cp.inventario,0)  as 'Inv', ";
                if (sucursal.Trim().ToUpper().Equals("CUAUHTEMOC"))
                {
                    s1 += " MaxC1 as 'MAX', ";
                }
                else if (sucursal.Trim().ToUpper().Equals("CONDESA"))
                {
                    s1 += " MaxC2 as 'MAX', ";
                }
                else if (sucursal.Trim().ToUpper().Equals("ROMA"))
                {
                    s1 += " MaxC3 as 'MAX', ";
                }
                else if (sucursal.Trim().ToUpper().Equals("POLANCO"))
                {
                    s1 += " MaxC4 as 'MAX', ";
                }
                else if (sucursal.Trim().ToUpper().Equals("CASADEFUEGO"))
                {
                    s1 += " MaxCF as 'MAX', ";
                }
                s1 += " isnull(cp.cantidad,0) as 'C4', ";
                s1 += " '' as 'happy' ";
                s1 += " from prods pr inner join carritoPedidos cp on ltrim(rtrim(pr.articulo))=ltrim(rtrim(cp.articulo)) and ltrim(rtrim(cp.sucursal))= '" + sucursal.Trim() + "'";
                s1 += " ";
                s1 += " where  ltrim(rtrim(pr.linea))<>'BAKE' and ltrim(rtrim(pr.descrip)) like '%" + skus.Trim() + "%' ";
                s1 += " order by ltrim(rtrim(pr.LINEA)), ltrim(rtrim(pr.ARTICULO)), ltrim(rtrim(pr.Descrip)) ";
                //s1 += " OFFSET iif(" + (contador - 1) + " < 0, 0, " + (contador - 1) + ")  ROWS FETCH NEXT 10 ROWS ONLY";

                // s1 = "with disp as (select distinct dispositivo,sucursal, count(distinct almacen) as cant from existenciadispositivolocal where ltrim(rtrim(dispositivo)) like '"+sucursal+"' group by dispositivo)select * from disp where cant>0 group by dispositivo order by dispositivo";
                // Response.Write("<h1>[query1]" + sucursal + " " + "</h1>");
                DataTable t1 = default(DataTable);
                sql.Reset();
                t1 = sql.SQLTable(s1, connectionString);
                v.SucPolanco.Clear();


                for (int ix = 0; ix < t1.Rows.Count; ix++)
                {
                    SucPolanco SucurPolanco = new SucPolanco();
                    SucurPolanco.linea   = t1.Rows[ix]["linea"].ToString().Trim();
                    SucurPolanco.sku     = t1.Rows[ix]["sku"].ToString().Trim();
                    SucurPolanco.descrip = t1.Rows[ix]["descrip"].ToString().Trim();
                    SucurPolanco.Inv     = (t1.Rows[ix]["Inv"].ToString().Trim());
                    SucurPolanco.Max     = (t1.Rows[ix]["MAX"].ToString().Trim());
                    SucurPolanco.C4      = (t1.Rows[ix]["C4"].ToString().Trim());
                    SucurPolanco.Happy   = (t1.Rows[ix]["happy"].ToString().Trim());

                    contador++;
                    SucurPolanco.fila = "" + contador;
                    v.SucPolanco.Add(SucurPolanco);
                }
                s2  = " with total as ( ";
                s2 += " select distinct  ltrim(rtrim(pr.LINEA)) as Linea, ltrim(rtrim(pr.ARTICULO)) as sku, ltrim(rtrim(pr.Descrip)) as Descrip, ";
                s2 += " pr.EXISTENCIA as 'Inv', ";
                if (sucursal.Trim().ToUpper().Equals("CUAUHTEMOC"))
                {
                    s2 += " MaxC1 as 'MAX', ";
                }
                else if (sucursal.Trim().ToUpper().Equals("CONDESA"))
                {
                    s2 += " MaxC2 as 'MAX', ";
                }
                else if (sucursal.Trim().ToUpper().Equals("ROMA"))
                {
                    s2 += " MaxC3 as 'MAX', ";
                }
                else if (sucursal.Trim().ToUpper().Equals("POLANCO"))
                {
                    s2 += " MaxC4 as 'MAX', ";
                }
                else if (sucursal.Trim().ToUpper().Equals("CASADEFUEGO"))
                {
                    s2 += " MaxCF as 'MAX', ";
                }
                s2 += " '' as 'C4', ";
                s2 += " '' as 'happy' ";
                s2 += " from prods pr inner join carritoPedidos cp on ltrim(rtrim(pr.articulo))=ltrim(rtrim(cp.articulo)) and ltrim(rtrim(cp.sucursal))= '" + sucursal.Trim() + "'";
                s2 += "  ";
                s2 += " where  ltrim(rtrim(pr.linea))<>'BAKE' and ltrim(rtrim(pr.descrip)) like '%" + skus.Trim() + "%'  ";
                s2 += " ) ";
                s2 += " select count(sku) as totalArticulos, ";
                s2 += " sum(Inv) as Talm11, sum(MAX) as Talm12 from total";

                // Response.Write("<h1>[query2]" + s2 + " " + "</h1>");
                DataTable t2 = default(DataTable);

                t2 = sql.SQLTable(s2, connectionString);

                if (t2.Rows.Count > 0)
                {
                    v.totalTickets = t2.Rows[0]["totalArticulos"].ToString().Trim();
                    v.TotInv       = t2.Rows[0]["Talm11"].ToString().Trim();
                    v.TotMax       = t2.Rows[0]["Talm12"].ToString().Trim();
                }
                sql.Reset();
                DataTable carritoContador = sql.SQLTable("SELECT * FROM carritoPedidos WHERE ltrim(rtrim(sucursal)) = '" + sucursal.Trim() + "' and ltrim(rtrim(usuario)) = '" + v.usuario.Trim() + "'", connectionString);
                v.tamCarrito = carritoContador == null ? 0 : carritoContador.Rows.Count;
                v.enCarrito  = true;
                return(v);
            }
            catch
            {
                return(v);
            }
        }