Ejemplo n.º 1
0
        public static void AddItem(APISalesOnlineItems postedItem)
        {
            APISalesOnlineItems item = postedItem;

            item.NumberOrder = GetData().Max(m => m.NumberOrder) + 1;
            SalesOnlineItemsList.GetData().Add(postedItem);
        }
Ejemplo n.º 2
0
        public static List <APISalesOnlineItems> GetData()
        {
            var key     = "5A2D44FF-339E-48E8-9470-FCCA2B90BA7E";
            var Session = HttpContext.Current.Session;

            if (Session[key] == null)
            {
                List <APISalesOnlineItems> listData = new List <APISalesOnlineItems>();
                var item = new APISalesOnlineItems();
                item.NumberOrder   = 1;
                item.Code          = "CFRX";
                item.Name          = "Bánh";
                item.Specification = "thùng";
                item.Weight        = 5M;
                item.Unit          = "gói";
                item.Quantity      = 30;
                item.Price         = 10000;
                item.Discount      = 10;
                item.Amount        = (item.Quantity * item.Price) / 100 * (100 - item.Discount);
                listData.Add(item);

                item               = new APISalesOnlineItems();
                item.NumberOrder   = 2;
                item.Code          = "GTCV";
                item.Name          = "Bia";
                item.Specification = "thùng";
                item.Weight        = 10M;
                item.Unit          = "lon";
                item.Quantity      = 24;
                item.Price         = 18000;
                item.Discount      = 0;
                item.Amount        = (item.Quantity * item.Price) / 100 * (100 - item.Discount);
                listData.Add(item);

                item               = new APISalesOnlineItems();
                item.NumberOrder   = 3;
                item.Code          = "NNCC";
                item.Name          = "Nước ngọt";
                item.Specification = "thùng";
                item.Weight        = 7M;
                item.Unit          = "chai";
                item.Quantity      = 6;
                item.Price         = 20000;
                item.Discount      = 2;
                item.Amount        = (item.Quantity * item.Price) / 100 * (100 - item.Discount);
                listData.Add(item);

                Session[key] = listData;
                listData     = null;
            }
            return((List <APISalesOnlineItems>)Session[key]);
        }
Ejemplo n.º 3
0
        public static void UpdateItem(APISalesOnlineItems postedItem)
        {
            var editedModel = SalesOnlineItemsList.GetData().First(i => i.NumberOrder == postedItem.NumberOrder);

            editedModel.NumberOrder   = postedItem.NumberOrder;
            editedModel.Code          = postedItem.Code;
            editedModel.Name          = postedItem.Name;
            editedModel.Specification = postedItem.Specification;
            editedModel.Weight        = postedItem.Weight;
            editedModel.Unit          = postedItem.Unit;
            editedModel.Quantity      = postedItem.Quantity;
            editedModel.Price         = postedItem.Price;
            editedModel.Discount      = postedItem.Discount;
            editedModel.Amount        = postedItem.Amount;
        }
Ejemplo n.º 4
0
        public ActionResult SalesOnlineItemsGridViewPartialUpdate(MVC.Areas.Sell.Models.APISalesOnlineItems item)
        {
            var model = SalesOnlineItemsList.GetData();

            if (ModelState.IsValid)
            {
                try
                {
                    SalesOnlineItemsList.UpdateItem(item);
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_SalesOnlineItemsGridViewPartial", model));
        }