Esempio n. 1
0
        public JsonResult Getproductdata(string pro)
        {
            var cero = 0;

            if (pro == "0")
            {
                return(Json(cero, JsonRequestBehavior.AllowGet));
            }
            AlfredoContext db = new AlfredoContext();
            //IEnumerable<int> query = (from c in db.Products
            //                          where c.ProductDescription == pro
            //                          select c.IdProduct);


            //int id = query.ElementAt(0);
            //Product productdata = db.Products.Find(id);

            var proid = Int32.Parse(pro);


            Product productdata = db.Products.ToList().Find(u => u.IdProduct == proid);


            var midato = productdata.WholeSalePrice.ToString();

            return(Json(midato, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public JsonResult Getproviderdata(string prov)
        {
            var            provid       = Int32.Parse(prov);
            AlfredoContext db           = new AlfredoContext();
            var            providerdata = db.Providers.ToList().Find(u => u.IdProvider == provid).ProviderAddress;

            if (providerdata == null)
            {
                providerdata = String.Empty;
            }

            return(Json(providerdata, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public JsonResult Getcustomerdata(string cus)
        {
            if (cus == "0")
            {
                Customer customerdata2 = new Customer();
                customerdata2.CustomerAddress = "XXXXXXXXXX";
                customerdata2.CuitCuil        = "XX-XXXXXXXX-XX";
                return(Json(customerdata2, JsonRequestBehavior.AllowGet));
            }
            var            cusid        = Int32.Parse(cus);
            AlfredoContext db           = new AlfredoContext();
            Customer       customerdata = db.Customers.ToList().Find(u => u.IdCustomer == cusid);


            return(Json(customerdata, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        protected void Application_Start()
        {
            AlfredoContext       db = new AlfredoContext();
            ApplicationDbContext dc = new ApplicationDbContext();

            if (dc.Users == null /* | dc.Users.Count() == 0*/)
            {
                CreateRoles(dc);
                CreateSuperuser(dc);
                AddPermisionsToSuperuser(dc);
            }
            dc.Dispose();
            //Mapper.Initialize(c => c.AddProfile<MappingProfile>());
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
Esempio n. 5
0
        public JsonResult Getproductstock(string pro)
        {
            var cero = 0;

            if (pro == "0")
            {
                return(Json(cero, JsonRequestBehavior.AllowGet));
            }
            AlfredoContext db = new AlfredoContext();

            var proid = Int32.Parse(pro);


            Product productdata = db.Products.ToList().Find(u => u.IdProduct == proid);


            var midato = productdata.ParcialStock.ToString();

            return(Json(midato, JsonRequestBehavior.AllowGet));
        }
Esempio n. 6
0
        public JsonResult FinalizeSale(string misale)
        {
            var            saleid   = Int32.Parse(misale);
            AlfredoContext db       = new AlfredoContext();
            Sale           saledata = db.Sales.ToList().Find(u => u.IdSale == saleid);

            foreach (var item in saledata.SaleLines)
            {
                Product prod = new Product();
                prod                 = db.Products.Find(item.IdProduct);
                prod.Stock           = prod.Stock - item.LineQuantity;
                db.Entry(prod).State = EntityState.Modified;
                db.SaveChanges();
            }
            saledata.SaleState       = SaleState.Finalizada;
            db.Entry(saledata).State = EntityState.Modified;
            db.SaveChanges();

            var midato = "Ok";

            return(Json(midato, JsonRequestBehavior.AllowGet));
        }
Esempio n. 7
0
        public JsonResult Getcustomerdata(string cus)
        {
            if (cus == "0")
            {
                Customer customerdata2 = new Customer();
                customerdata2.CustomerAddress = "";
                customerdata2.CuitCuil        = "";
                return(Json(customerdata2, JsonRequestBehavior.AllowGet));
            }

            var            cusid         = Int32.Parse(cus);
            AlfredoContext db            = new AlfredoContext();
            Customer       customerdata  = db.Customers.ToList().Find(u => u.IdCustomer == cusid);
            Customer       customerdata3 = new Customer();

            if (customerdata.CustomerAddress != null)
            {
                customerdata3.CustomerAddress = customerdata.CustomerAddress.ToString();
            }
            else
            {
                customerdata3.CustomerAddress = "";
            }

            if (customerdata.CuitCuil != null)
            {
                customerdata3.CuitCuil = customerdata.CuitCuil.ToString();
            }
            else
            {
                customerdata3.CuitCuil = "";
            }



            return(Json(customerdata3, JsonRequestBehavior.AllowGet));
        }