Beispiel #1
0
        // GET: Home
        public ActionResult Index()
        {
            if (Session["ID"] != null)
            {
                if (Session["type"].Equals(2))
                {
                    var ID          = Convert.ToInt32(Session["ID"]);
                    var proList_pro = new ListPro()
                    {
                        ListProject = db.project.Where(p => p.pStatus == 0),
                        project     = new projects(),
                        user        = db.users.SingleOrDefault(u => u.Id == ID)
                    };
                    return(View("Customer", proList_pro));
                }
                ViewBag.projects = db.project.Where(x => x.pStatus == 1).ToList();
                return(View("Users"));
            }
            else
            {
                users us = new users();
                ViewBag.User_Types = db.userType.Where(x => x.userTypeId > 1).ToList();

                return(View(us));
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ListPro listPro = db.ListProes.Find(id);

            db.ListProes.Remove(listPro);
            db.SaveChanges();
            return(RedirectToAction("Create"));
        }
 public ActionResult Edit([Bind(Include = "id,idList,doc")] ListPro listPro)
 {
     if (ModelState.IsValid)
     {
         db.Entry(listPro).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idList = new SelectList(db.Products, "id", "name", listPro.idList);
     return(View(listPro));
 }
        public ActionResult Create([Bind(Include = "id,idList,doc")] ListPro listPro)
        {
            if (ModelState.IsValid)
            {
                db.ListProes.Add(listPro);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.idList = new SelectList(db.Products, "id", "name", listPro.idList);
            return(View(listPro));
        }
        // GET: Admin/ListProes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ListPro listPro = db.ListProes.Find(id);

            if (listPro == null)
            {
                return(HttpNotFound());
            }
            return(View(listPro));
        }
        // GET: Admin/ListProes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ListPro listPro = db.ListProes.Find(id);

            if (listPro == null)
            {
                return(HttpNotFound());
            }
            ViewBag.idList = new SelectList(db.Products, "id", "name", listPro.idList);
            return(View(listPro));
        }
Beispiel #7
0
 private async void InsertIntoCart(int?obj)
 {
     try
     {
         if (obj != null)
         {
             var item = ListPro.SingleOrDefault(t => t.ProductID == (int)obj);
             if (item != null)
             {
                 if (!string.IsNullOrEmpty(Qty) && Qty.IsNum())
                 {
                     if (ListOD.SingleOrDefault(t => t.ProductID == (int)obj) == null)
                     {
                         if (Convert.ToInt32(Qty) <= RestQty && RestQty >= 0)
                         {
                             var ProOD = new ProductODModel()
                             {
                                 ProductID = _selectedPro.ProductID,
                                 Name      = _selectedPro.Name,
                             };
                             ProOD.OrderQty  = Convert.ToInt32(Qty);
                             ProOD.UnitPrice = (double)_selectedPro.UnitOnOrder;
                             ProOD.StoreID   = SelectedSto.StoreID;
                             Subtotal       += (double)_selectedPro.UnitOnOrder * Convert.ToInt32(Qty);
                             ListOD.Add(ProOD);
                         }
                         else
                         {
                             MessageBox.Show("số lượng phải nhỏ hơn hoặc bằng số lượng hiện tại", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                         }
                     }
                     else
                     {
                         MessageBox.Show("Đã Tồn Tại Trong Giỏ Hàng", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                     }
                 }
                 else
                 {
                     MessageBox.Show("Có Lỗi - Số Lượng Phải Là Số", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                 }
             }
         }
     }
     catch
     {
         MessageBox.Show("Có Lỗi", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }