Exemplo n.º 1
0
    public string cambiarCodigo(JObject codigos)
    {
        string viejoCodigo = codigos["codigo"].ToString();;
        string nuevoCodigo = codigos["nuevoCodigo"].ToString();

        if (!existeProducto(nuevoCodigo))
        {
            try
            {
                using (GestionEntities bd = new GestionEntities())
                {
                    bd.Database.ExecuteSqlCommand("exec CambioCodStk '" + viejoCodigo + "','" + nuevoCodigo + "'");
                }
                return("true");
            }
            catch (Exception e)
            {
                return("error");
            }
        }
        else
        {
            return("Existe");
        }
    }
Exemplo n.º 2
0
 internal stock getProductoCod(string codpro)
 {
     using (GestionEntities bd = new GestionEntities())
     {
         return(bd.Database.SqlQuery <stock>("select * from stock where codpro like '" + codpro + "'").Single());
     }
 }
 public List <ComprobanteAdeudado> getComprobantesAdeudados(int nrocli, int empresa)
 {
     using (GestionEntities bd = new GestionEntities())
     {
         return(bd.Database.SqlQuery <ComprobanteAdeudado>(
                    "select fecha, tipodoc, letra, punto, numero,simdoc mon,importe1 importe, importe2 adeudado, vence, simbolo, cotizacion " +
                    " from clictad " +
                    "where empresa = " + empresa + " and nrocli = " + nrocli).ToList());
     }
 }
Exemplo n.º 4
0
    public RequestHTTP getProductos(string value, int empid, int offset)
    {
        var req = new RequestHTTP();

        try
        {
            List <Producto> lista;
            using (GestionEntities bd = new GestionEntities())
            {
                bd.Database.CommandTimeout = 30;
                if (value == "0")
                {
                    lista = bd.Database.SqlQuery <Producto>(
                        "select pathfoto, stock.codpro, stock.descri, oferta, boniprod, incluido, ivaart.porcen1, envases.descri AS descriEnvase," +
                        " envases.codigo AS codEnvase, envases.simbolo AS simboloEnvase, isnull(stk.saldo,0) saldo " +
                        "FROM stock " +
                        "LEFT OUTER JOIN ivaart ON ivaart.codigo = stock.ivagrupo " +
                        "LEFT OUTER JOIN envases ON envases.id = stock.envase " +
                        "LEFT OUTER JOIN SaldoSTKALL(" + empid + ") AS stk ON stk.codpro = stock.codpro"
                        ).ToList();
                }
                else
                {
                    lista = bd.Database.SqlQuery <Producto>(
                        "select pathfoto, stock.id, stock.codpro, stock.descri, oferta, boniprod, incluido, ivaart.porcen1, envases.descri AS descriEnvase," +
                        " envases.codigo AS codEnvase, envases.simbolo AS simboloEnvase, isnull(stk.saldo,0) saldo " +
                        "FROM stock " +
                        "LEFT OUTER JOIN ivaart ON ivaart.codigo = stock.ivagrupo " +
                        "LEFT OUTER JOIN envases ON envases.id = stock.envase " +
                        "LEFT OUTER JOIN SaldoSTKALL(" + empid + ") AS stk ON stk.codpro = stock.codpro " +
                        "where stock.codpro like '%" + value + "%' or stock.descri like '%" + value + "%' " +
                        "order by descri " +
                        "offset " + offset + " rows fetch next 20 row only"
                        ).ToList();
                }
            }
            foreach (var prod in lista)
            {
                if (prod.pathfoto != "")
                {
                    prod.pathfoto = acortarPath(prod.pathfoto);
                }
                if (prod.pathfoto == "")
                {
                    prod.pathfoto = "empty";
                }
            }
            req.objeto = lista;
            return(req);
        } catch (Exception e)
        {
            return(req.falla(e));
        }
    }
Exemplo n.º 5
0
 public itemProducto(decimal cant, string descri, decimal precioVenta, decimal total, decimal bonif, decimal bonif1, decimal impint, string codpro, string[] artasoc)
 {
     this.cant        = cant;
     this.descri      = descri;
     this.precioVenta = precioVenta;
     this.total       = total;
     this.bonif       = bonif;
     this.bonif1      = bonif1;
     this.impint      = impint;
     this.codpro      = codpro;
     this.asociado    = artasoc;
     using (GestionEntities bd = new GestionEntities())
         this.codigo = bd.Database.SqlQuery <string>("select moneda from stock where codpro like '" + this.codpro + "'").First();
 }
Exemplo n.º 6
0
 public bool existeProducto(string codigo)
 {
     using (GestionEntities bd = new GestionEntities())
     {
         if (bd.stock.Where(a => a.codpro == codigo).Count() >= 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
 internal bool verificarComprobante(int idClicta, string usuario)
 {
     try
     {
         using (GestionEntities bd = new GestionEntities())
         {
             bd.Database.ExecuteSqlCommand("update clicta set verifi = 1, verifico = '" + usuario + "'  where id = " + idClicta);
             return(true);
         }
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Exemplo n.º 8
0
 public static bool comprobarToken(string miToken)
 {
     using (GestionEntities bd = new GestionEntities())
     {
         string token = bd.token.Single().token1;
         if (miToken == token)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 9
0
 internal RequestHTTP getDisponibles(string codpro, int empresa)
 {
     try
     {
         var req = new RequestHTTP();
         using (GestionEntities bd = new GestionEntities())
         {
             req.objeto = bd.Database.SqlQuery <ComprometidoProducto>("select * from ComprometidoporProducto(" + empresa + ") where Producto like '" + codpro + "'").Single();
             return(req);
         }
     }catch (Exception e)
     {
         return(new RequestHTTP().falla(e));
     }
 }
Exemplo n.º 10
0
 public bool productoUnico(string value, int empid)
 {
     try
     {
         using (GestionEntities bd = new GestionEntities())
         {
             if (bd.stocksF(empid).Where(a => a.codpro.Contains(value) || a.descri.Contains(value)).Count() == 1)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }catch (Exception e)
     {
         return(false);
     }
 }
Exemplo n.º 11
0
        internal List <PedidoDet> getPresupDLikePedido(int idPresup)
        {
            presupc          cabPresup;                     //cabecera presup
            List <presupd>   dPresup;                       //detalle de presup
            List <PedidoDet> dPed = new List <PedidoDet>(); // detalle de pedidod
            cliente          clien;
            decimal          bonifcliTotal = 0;

            using (GestionEntities bd = new GestionEntities())
            {
                cabPresup = bd.presupc.Single(cab => cab.id == idPresup);                 //busca la presupC para la moenda de factura
                dPresup   = bd.presupd.Where(det => det.cabeceraid == idPresup).ToList(); // busca la presupd
                clien     = bd.cliente.Single(cliente => cliente.nrocli == cabPresup.nrocli);
            }
            int i = 0;

            bonifcliTotal = 100 - ((clien.bonif * 100) / 100);
            bonifcliTotal = bonifcliTotal - ((clien.bonif1 * bonifcliTotal) / 100);
            bonifcliTotal = bonifcliTotal - ((clien.bonif2 * bonifcliTotal) / 100);
            bonifcliTotal = bonifcliTotal - ((clien.bonif3 * bonifcliTotal) / 100);
            bonifcliTotal = bonifcliTotal - ((clien.bonif4 * bonifcliTotal) / 100);
            bonifcliTotal = 100 - bonifcliTotal;
            stocks stock;
            var    pCab = new PedidoCab();

            pCab.monfac = cabPresup.monfac;
            pCab.id     = 1111111111;
            foreach (var pre in dPresup)// por cada articulo de presup agrega uno al pedido
            {
                i++;
                stock = new stocks(pre.cant, pre.precio, pre.bonif, pre.bonif1, pre.impint, pre.codpro,
                                   pre.asociado, bonifcliTotal, pre.fecha, pre.deta, cabPresup.empresa);
                dPed.Add(new PedidoDet(stock, pCab, i));
            }
            return(dPed);
        }
Exemplo n.º 12
0
    //usado en items pedidos
    public itemProducto getProducto(int idprod, int lista, int empid)
    {
        // try
        // {
        decimal        precioLista;
        List <artasoc> artaso;
        List <string>  arta           = new List <string>();
        var            prod           = inicializarProductos(empid);
        Dictionary <string, object> p = productos.FirstOrDefault(dic => Convert.ToInt32(dic.Single(elem => elem.Key == "id").Value) == idprod);
        string codpro = p.Single(a => a.Key == "codpro").Value.ToString();

        using (GestionEntities bd = new GestionEntities())
            artaso = bd.artasoc.Where(a => a.codpro == codpro).ToList();
        foreach (artasoc q in artaso)
        {
            arta.Add(q.componen);
        }

        switch (lista)
        {
        case 1:
            precioLista = (decimal)p.Single(a => a.Key == "precio1").Value;
            break;

        case 2:
            precioLista = (decimal)p.Single(a => a.Key == "precio2").Value;;
            break;

        case 3:
            precioLista = (decimal)p.Single(a => a.Key == "precio3").Value;;
            break;

        case 4:
            precioLista = (decimal)p.Single(a => a.Key == "precio4").Value;;
            break;

        case 5:
            precioLista = (decimal)p.Single(a => a.Key == "precio5").Value;;
            break;

        case 6:
            precioLista = (decimal)p.Single(a => a.Key == "precio6").Value;
            break;

        default:
            precioLista = (decimal)p.Single(a => a.Key == "costo").Value;
            break;
        }
        string       descri = p.Single(a => a.Key == "descri").Value.ToString();
        decimal      impint = (decimal)p.Single(a => a.Key == "impint").Value;
        itemProducto ip     = new itemProducto(1, descri, precioLista, 0, 0, 0, impint, codpro, arta.ToArray());

        return(ip);

        /*   }
         * catch (Exception)
         * {
         *   var p = new itemProducto();
         *   p.codpro = "no existe";
         *   return p;
         * }*/
    }