예제 #1
0
        public string AplicarPromosDescuentos(int idproducto, string cantidad)
        {
            List <PromocionesDescuentos> promocionesDescuentos = new List <PromocionesDescuentos>();
            ConsultasTablas dbuser = new ConsultasTablas();

            promocionesDescuentos = dbuser.VerPromocionesDescuentosCant(idproducto, int.Parse(cantidad));

            double porcdesc = 0, actualVal = 0, maxVal = 0;

            if (promocionesDescuentos.Count() == 0)
            {
                return("1");
            }
            else
            {
                for (int i = 0; i <= promocionesDescuentos.Count() - 1; i++)
                {
                    actualVal = double.Parse(promocionesDescuentos[i].compra_min);
                    if (actualVal > maxVal)
                    {
                        maxVal   = actualVal;
                        porcdesc = (double.Parse(promocionesDescuentos[i].descuento_porc) + 100) / 100;
                    }
                }
                return(porcdesc.ToString());
            }
        }