Beispiel #1
0
        private void loadExistingItemAttributes()
        {
            txtItemName.Text        = myItem.name;
            txtItemDescription.Text = myItem.description;
            nudItemPrice.Value      = myItem.price;
            itemtype item = null;

            foreach (var choice in cmbItemType.Items)
            {
                if (((itemtype)choice).id == myItem.ItemType_id)
                {
                    item = (itemtype)choice;
                }
            }
            if (item != null)
            {
                cmbItemType.SelectedItem = item;
            }
            if (myItem.image_path != null)
            {
                try
                {
                    itemImage         = Image.FromFile(myItem.image_path);
                    pbItemImage.Image = itemImage;
                    imagePath         = myItem.image_path;
                }
                catch { }
            }
        }
Beispiel #2
0
        public async Task <bool> UpdateItemType(itemtype model)
        {
            try
            {
                using (var uow = _unitOfWorkFactory.Create())
                {
                    var result = await FindItemTypeById(model.ItemTypeId);

                    if (result != null)
                    {
                        uow.ItemTypeRepository.Update(model);
                        await uow.SaveChangesAsync();

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #3
0
        public async Task <JsonResult> SaveItemType(itemtype itemtype)
        {
            try
            {
                itemtype itemTypeModel = null;

                bool   success = false;
                string message = "";

                if (string.IsNullOrEmpty(itemtype.ItemTypeId.ToString()) || itemtype.ItemTypeId.ToString() == "0")
                {
                    itemTypeModel              = new itemtype();
                    itemTypeModel.ItemTypeId   = itemtype.ItemTypeId;
                    itemTypeModel.ItemTypeName = itemtype.ItemTypeName;
                    itemTypeModel.CreatedBy    = "";
                    itemTypeModel.CreatedAt    = DateTime.Now;

                    var result = await _referenceService.SaveItemType(itemTypeModel);

                    success = result;
                    if (result)
                    {
                        message = "Successfully saved.";
                    }
                    else
                    {
                        message = "Error saving data. Please contact administrator.";
                    }
                }
                else
                {
                    itemTypeModel = await _referenceService.FindItemTypeById(itemtype.ItemTypeId);

                    itemTypeModel.ItemTypeId   = itemtype.ItemTypeId;
                    itemTypeModel.ItemTypeName = itemtype.ItemTypeName;
                    itemTypeModel.CreatedBy    = "";
                    itemTypeModel.CreatedAt    = DateTime.Now;

                    var result = await _referenceService.UpdateItemType(itemTypeModel);

                    success = result;
                    if (result)
                    {
                        message = "Successfully updated.";
                    }
                    else
                    {
                        message = "Error saving data. Please contact administrator.";
                    }
                }

                return(Json(new { success = success, message = message }));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #4
0
 //构造函数
 public Item(itemtype color, Point top, int size, int flag)
 {
     _color = color;
     _top   = top;
     _size  = size;
     _flag  = flag;
     for (int i = 0; i <= 6; i++)
     {
         //Console.WriteLine("Image\\" + ((itemtype)i).ToString() + ".jpg");
         _picture[i] = new Bitmap("Image\\" + ((itemtype)i).ToString() + ".jpg");
         //_picture[i] = new Bitmap(Resource1.((itemtype)i).toString()+".jpg");
     }
     //_picture[0] = new Bitmap(Resource1.cat);
     //
     for (int i = 1; i <= 6; i++)
     {
         _pickpic[i] = new Bitmap("Image\\" + ((itemtype)i).ToString() + "2.jpg");
     }
     _nowpic = _picture[(int)_color];
 }
Beispiel #5
0
 public TreeItem(string data)
 {
     ittype = itemtype.data;
     Data   = data;
 }
Beispiel #6
0
 public TreeItem(char opt)
 {
     ittype = itemtype.opt;
     Opt    = opt;
 }
 public void Update(itemtype obj)
 {
     _context.itemtype.AddOrUpdate();
 }
 public void Insert(itemtype obj)
 {
     _context.itemtype.Add(obj);
 }
        public ActionResult AddItem(ItemVM model, int?id)
        {
            var SessionControl = Convert.ToInt32(HttpContext.Session["RoleID"]);

            if (SessionControl != 5)
            {
                return(HttpNotFound());
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ViewBag.ITEMTYPE = new SelectList(db.itemtype, "ID", "Item_Type");
            ViewBag.ITEM     = new SelectList(db.item, "ID", "ITEM_NAME");
            int locid = id ?? 0;
            var query = (from l in db.location
                         join lc in db.location_has_item on l.ID equals lc.location_ID
                         join i in db.item on lc.item_ID equals i.ID
                         where l.ID == id
                         orderby(i.ITEM_NAME)
                         select new LocationItemVM
            {
                ID = l.ID,
                iID = lc.item_ID,
                ITEM_NAME = i.ITEM_NAME,
                ITEMQUANTITY = lc.ItemQuantity
            }).ToList();
            //var lcd = db.location_has_item.Where(x => x.location_ID == id);
            var locationitems = db.location.Where(x => x.ID == id);

            try
            {
                model.LocationID = locid;
                if (model != null)
                {
                    item              items              = new item();
                    itemtype          itemtypes          = new itemtype();
                    location_has_item location_has_items = new location_has_item();
                    if (db.location_has_item.Any(x => x.location_ID == id && x.item_ID == items.ID))
                    {
                        TempData["info"] = "This location already have that item " + locationitems.Select(x => x.ROOM_ID);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        location_has_items.location_ID  = locid;
                        location_has_items.item_ID      = Convert.ToInt32(model.ItemName);
                        location_has_items.ItemQuantity = model.ItemQuantity;
                        db.location_has_item.Add(location_has_items);
                        db.SaveChanges();
                        TempData["info"] = "Adding Item Succesfull ";
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                TempData["info"] = ex.Message;
                return(RedirectToAction("Index", "Location"));
            }
            TempData["info"] = "Adding Item Succesfull";
            ViewBag.ITEMTYPE = new SelectList(db.itemtype, "ID", "Item_Type");
            return(View("Index", "Location"));
        }