public ActionResult Edit1([Bind(Include = "ItemId, CategoryId,Name,Description,Price,Quantity,ImageFile")] ItemsDetail itemsDetail)
        {
            if (ModelState.IsValid)
            {
                if (itemsDetail.ImageFile != null)
                {
                    string fileName  = Path.GetFileNameWithoutExtension(itemsDetail.ImageFile.FileName);
                    string extension = Path.GetExtension(itemsDetail.ImageFile.FileName);
                    fileName          = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                    itemsDetail.Image = "~/Images/" + fileName;
                    //var supportedType = new[] { "jpg", "jpeg", "png" };

                    fileName = Path.Combine(Server.MapPath("~/Images/"), fileName);
                    db.Entry(itemsDetail).State = EntityState.Modified;
                    if (db.SaveChanges() > 0)
                    {
                        itemsDetail.ImageFile.SaveAs(fileName);
                        return(RedirectToAction("ViewItems", new { id = itemsDetail.CategoryId }));
                    }
                }

                else
                {
                    itemsDetail.Image           = Session["imagepath"].ToString();
                    db.Entry(itemsDetail).State = EntityState.Modified;
                    if (db.SaveChanges() > 0)
                    {
                        return(RedirectToAction("ViewItems", new { id = itemsDetail.CategoryId }));
                    }
                }
            }
            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", itemsDetail.CategoryId);
            return(View(itemsDetail));
        }
Beispiel #2
0
        public object GetItemsDetail(int page, int limit, string id)
        {
            List <Sys_ItemsDetail> _ItemsDetail = new List <Sys_ItemsDetail>();
            var list = ItemsDetail.Query().Result;

            foreach (var item in list)
            {
                Sys_ItemsDetail sys_Items = new Sys_ItemsDetail();
                if (item.F_ItemId == id)
                {
                    sys_Items.F_Id          = item.F_Id;
                    sys_Items.F_ItemId      = item.F_ItemId;
                    sys_Items.F_ItemCode    = item.F_ItemCode;
                    sys_Items.F_ItemName    = item.F_ItemName;
                    sys_Items.F_SortCode    = item.F_SortCode;
                    sys_Items.F_CreatorTime = item.F_CreatorTime;
                    sys_Items.F_EnabledMark = item.F_EnabledMark;

                    _ItemsDetail.Add(sys_Items);
                }
            }
            var data = new { code = 0, msg = "", data = _ItemsDetail, count = _ItemsDetail.Count };

            return(data.ToJson());
        }
Beispiel #3
0
        public ActionResult Create1([Bind(Include = "CategoryId,Name,Description,Price,Quantity,ImageFile")] ItemsDetail itemsDetail)
        {
            if (ModelState.IsValid)
            {
                string fileName  = Path.GetFileNameWithoutExtension(itemsDetail.ImageFile.FileName);
                string extension = Path.GetExtension(itemsDetail.ImageFile.FileName);
                fileName          = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                itemsDetail.Image = "~/Images/" + fileName;
                var supportedType = new[] { "jpg", "jpeg", "png" };
                if (!supportedType.Contains(extension))
                {
                    fileName = Path.Combine(Server.MapPath("~/Images/"), fileName);
                    itemsDetail.ImageFile.SaveAs(fileName);

                    db.ItemsDetails.Add(itemsDetail);
                    db.SaveChanges();
                    return(RedirectToAction("ViewItems", new { id = itemsDetail.CategoryId }));
                }
                else
                {
                    ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", itemsDetail.CategoryId);
                    return(View(itemsDetail));
                }
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", itemsDetail.CategoryId);
            return(View(itemsDetail));
        }
Beispiel #4
0
 public void OnItemSelected2(object o, ItemTappedEventArgs e)
 {
     eDetail                = (ItemsDetail)e.Item;
     SecoundLabel.Text      = eDetail.Name;
     SecoundLabelShort.Text = eDetail.ShortName;
     SecoundEntry.Text      = (eDetail.Cost).ToString();
 }
        public ActionResult DeleteConfirmed(int id)
        {
            ItemsDetail itemsDetail = db.ItemsDetails.Find(id);

            db.ItemsDetails.Remove(itemsDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed1(int id)
        {
            int         cati;
            ItemsDetail itemsDetail = db.ItemsDetails.Find(id);

            cati = itemsDetail.CategoryId;
            db.ItemsDetails.Remove(itemsDetail);
            db.SaveChanges();
            return(RedirectToAction("ViewItems", new { id = cati }));
        }
 public ActionResult Edit([Bind(Include = "ItemId,CategoryId,Name,Description,Price,Quantity,Image")] ItemsDetail itemsDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(itemsDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", itemsDetail.CategoryId);
     return(View(itemsDetail));
 }
        public ActionResult Delete1(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ItemsDetail itemsDetail = db.ItemsDetails.Find(id);

            if (itemsDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(itemsDetail));
        }
Beispiel #9
0
        public object ItemsDetailUpdate(Itemsdetail itemsModel)
        {
            var list = new Sys_ItemsDetail {
                F_ItemName    = itemsModel.F_ItemName,
                F_CreatorTime = DateTime.Now,
                F_Id          = itemsModel.F_Id,
                F_ItemId      = itemsModel.F_ItemId,
                F_ItemCode    = itemsModel.F_ItemCode,
                F_SortCode    = int.Parse(itemsModel.F_SortCode),
                F_EnabledMark = true
            };
            var ret = ItemsDetail.Update(list).Result;

            return(ret);
        }
        // GET: ItemsDetails1/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ItemsDetail itemsDetail = db.ItemsDetails.Find(id);

            if (itemsDetail == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", itemsDetail.CategoryId);
            return(View(itemsDetail));
        }
Beispiel #11
0
        public ActionResult Addcart(int?id)
        {
            ItemsDetail cat = db.ItemsDetails.Find(id);
            PlaceOrder  po  = new PlaceOrder();

            po.OrderId  = Convert.ToInt32(TempData["id"]);
            po.ItemId   = cat.ItemId;
            po.quantity = 1;
            int bb = (po.quantity * cat.Price);

            bill    = bill + (po.quantity * cat.Price);
            po.Bill = bb;
            db.PlaceOrders.Add(po);
            db.SaveChanges();
            return(RedirectToAction("ViewItems", new { id = cat.CategoryId }));
        }
Beispiel #12
0
        public object ItemsDetailAdd([FromBody] Itemsdetail itemsModel)
        {
            var list = new Sys_ItemsDetail
            {
                F_ItemName    = itemsModel.F_ItemName,
                F_CreatorTime = DateTime.Now,
                F_Id          = Common.GuId(),
                F_ItemId      = itemsModel.F_ItemId,
                F_ItemCode    = itemsModel.F_ItemCode,
                F_SortCode    = int.Parse(itemsModel.F_SortCode),
                F_EnabledMark = true
            };
            var ret = ItemsDetail.Add(list).Result;

            return(ret);
        }
        public ActionResult Edit1(int?id, int?idd)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Category    cat         = db.Categories.Find(idd);
            ItemsDetail itemsDetail = db.ItemsDetails.Find(id);

            Session["imagepath"]   = itemsDetail.Image;
            itemsDetail.CategoryId = cat.CategoryId;
            if (itemsDetail == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", itemsDetail.CategoryId);
            return(View(itemsDetail));
        }
        public ActionResult Create1(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Category    cat = db.Categories.Find(id);
            ItemsDetail it  = new ItemsDetail();

            it.CategoryId = cat.CategoryId;
            if (cat == null)
            {
                return(HttpNotFound());
            }


            return(View(it));
        }
Beispiel #15
0
        public object ItemsDetailDelete(string id)
        {
            var ret = ItemsDetail.DeleteById(id).Result;

            return(ret.ToJson());
        }