public ActionResult CreateEdit(ItemViewModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (ItemDataAccess.Update(model))
             {
                 return(Json(new { success = true, message = "berhasil" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { success = false, mesage = ItemDataAccess.Message }, JsonRequestBehavior.AllowGet));
             }
         }
         else
         {
             return(Json(new { succes = false, message = "Please full fill required fields!" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemple #2
0
 public ItemService()
 {
     if (ItemService.itemDataAccess == null)
     {
         ItemService.itemDataAccess = new ItemDataAccess();
     }
 }
Exemple #3
0
        public void Move(ConsoleKey keyDirection)
        {
            var itemsData = new ItemDataAccess();
            var webpage   = new Webpage();

            int сursorPosition = Console.CursorTop;

            switch (keyDirection)
            {
            case ConsoleKey.UpArrow:
                if (Console.CursorTop > 0)
                {
                    Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop - 1);
                }
                else if (Console.CursorTop == 0)
                {
                    Console.SetCursorPosition(0, 0);
                }
                break;

            case ConsoleKey.DownArrow:
                if (Console.CursorTop < Console.BufferHeight)
                {
                    Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop + 1);
                }
                break;

            case ConsoleKey.Enter:
                ProductChoice = itemsData.SelectItemChoice(List, сursorPosition);
                break;

            case ConsoleKey.Tab:
                webpage.DrawPurchase(ProductChoice);
                break;

            case ConsoleKey.Escape:
                webpage.Menu();
                break;

            case ConsoleKey.R:
                List = itemsData.SelectByRaiting();
                break;

            case ConsoleKey.RightArrow:
                ++CurrentPage;
                Console.SetCursorPosition(0, 1);
                List = itemsData.SelectAllItems(CurrentPage, сursorPosition);
                break;

            case ConsoleKey.LeftArrow:
                --CurrentPage;
                Console.SetCursorPosition(0, 1);
                List = itemsData.SelectAllItems(CurrentPage, сursorPosition);
                break;

            default:
                break;
            }
        }
Exemple #4
0
        public ActionResult Create()
        {
            ViewBag.CategoryList = new SelectList(CategoryDataAccess.GetAll(), "CategoryCode", "CategoryName");

            ViewBag.ItemList = new SelectList(ItemDataAccess.GetByCategory(""), "ItemCode", "ItemName");

            return(View());
        }
Exemple #5
0
        public ActionResult Edit(int id)
        {
            VarianViewModel model = VarianDataAccess.GetById(id);

            ViewBag.CategoryList = new SelectList(CategoryDataAccess.GetAll(), "CategoryCode", "CategoryName");

            ViewBag.ItemList = new SelectList(ItemDataAccess.GetByCategory(model.CategoryCode), "ItemCode", "ItemName");

            return(View(model));
        }
 public ActionResult DeleteConfirm(int id)
 {
     if (ItemDataAccess.Delete(id))
     {
         return(Json(new { success = true, message = "Sukses" }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(new { success = false, message = ItemDataAccess.Message }, JsonRequestBehavior.AllowGet));
     }
 }
        public ActionResult GetById(int id) // for select item
        {
            ItemViewModel model = ItemDataAccess.GetById(id);

            if (model != null)
            {
                return(Json(new { success = true, data = model, message = "Success" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { success = false, data = model, message = "Not found!" }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #8
0
        private void deleteItemBtn_Click(object sender, EventArgs e)
        {
            string curName, reCurName, query;

            try
            {
                ItemDataAccess ob = new ItemDataAccess();
                curName   = deleteItemCinTbox.Text.ToString().ToUpper();
                reCurName = deleteItemRcinTbox.Text.ToString().ToUpper();
                if (curName.CompareTo("") != 0 && reCurName.CompareTo("") != 0)
                {
                    if (curName.CompareTo(reCurName) == 0)
                    {
                        query = "Delete From Item Where Name='" + curName + "'";
                        int rowCount = ob.editItem(query);
                        if (rowCount > 0)
                        {
                            MetroFramework.MetroMessageBox.Show(this, "Item Deleted Successfully");
                            itemCategoryComboboxFill();
                            itemListCategoryComboboxDefaultSelect();
                            autoCompleteItemCategoryTbox();
                            autoCompleteItemNameTbox();
                        }
                        else
                        {
                            MetroFramework.MetroMessageBox.Show(this, "Current Item Name Not Found ");
                        }
                    }
                    else
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Wrong Input: Both Names Are Not Same.\nType Both Names Again.");
                    }
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "Error: Input Can't be Blank");
                }
                deleteItemCinTbox.Text  = "";
                deleteItemRcinTbox.Text = "";
            }

            catch (FormatException)
            {
                MetroFramework.MetroMessageBox.Show(this, "Error: Wrong Input");
            }

            catch (Exception exc)
            {
                MetroFramework.MetroMessageBox.Show(this, exc.ToString());
            }
        }
        public ActionResult AddItem(Item item)
        {
            var list = new ItemDataAccess().FindAll <Item>();

            item.Id          = list.Count == 0 ? 1 : list.Last().Id + 1;
            item.Name        = Request.Form["Name"];
            item.Description = Request.Form["Description"];
            item.Cost        = double.Parse(Request.Form["Cost"]);
            item.NT          = int.Parse(Request.Form["NT"]);
            item.Weight      = double.Parse(Request.Form["Weight"]);
            item.Formula     = Request.Form["Formula"];
            new ItemDataAccess().InsertOne(item);
            return(RedirectToAction("Main", "Admin"));
        }
Exemple #10
0
        private void addItemBtn_Click(object sender, EventArgs e)
        {
            string name, category;
            double unitPrice;

            try
            {
                ItemDataAccess ob = new ItemDataAccess();
                name     = addItemName.Text.ToString().ToUpper();
                category = addCategoryName.Text.ToString().ToUpper();
                if (name.CompareTo("") != 0 && category.CompareTo("") != 0 && addPrice.Text.ToString().CompareTo("") != 0)
                {
                    unitPrice = Convert.ToDouble(addPrice.Text);
                    int rowCount = ob.addItem(name, category, unitPrice);
                    if (rowCount <= 0)
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Item Added");
                        itemCategoryComboboxFill();
                        itemListCategoryComboboxDefaultSelect();
                        autoCompleteItemNameTbox();
                        autoCompleteItemCategoryTbox();
                    }
                    else
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Error: An Item Is Already Registered With This Name");
                    }
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "Error: Input Can't be Blank");
                }
                addItemName.Text     = "";
                addCategoryName.Text = "";
                addPrice.Text        = "";
            }

            catch (FormatException)
            {
                MetroFramework.MetroMessageBox.Show(this, "Error: Wrong Input");
            }

            catch (Exception exc)
            {
                MetroFramework.MetroMessageBox.Show(this, exc.ToString());
            }
        }
Exemple #11
0
        private void editItemPriceBtn_Click(object sender, EventArgs e)
        {
            string curName, query;
            double newPrice;

            try
            {
                ItemDataAccess ob = new ItemDataAccess();
                curName = editItemPriceCin.Text.ToString().ToUpper();

                if (curName.CompareTo("") != 0 && editItemPriceNip.Text.ToString().CompareTo("") != 0)
                {
                    newPrice = Convert.ToDouble(editItemPriceNip.Text.ToString());
                    query    = "UPDATE ITEM Set Price=" + newPrice + " WHERE Name='" + curName + "'";
                    int rowCount = ob.editItem(query);
                    if (rowCount > 0)
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Item Price Edited Successfully");
                        itemCategoryComboboxFill();
                        itemListCategoryComboboxDefaultSelect();
                    }
                    else
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Current Item Name Not Found ");
                    }
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "Error: Input Can't be Blank");
                }
                editItemPriceCin.Text = "";
                editItemPriceNip.Text = "";
            }

            catch (FormatException)
            {
                MetroFramework.MetroMessageBox.Show(this, "Error: Wrong Input");
            }

            catch (Exception exc)
            {
                MetroFramework.MetroMessageBox.Show(this, exc.ToString());
            }
        }
Exemple #12
0
        private void editCategoryNameBtn_Click(object sender, EventArgs e)
        {
            string curName, newCategory, query;

            try
            {
                ItemDataAccess ob = new ItemDataAccess();
                curName     = editCategoryNameCin.Text.ToString().ToUpper();
                newCategory = editCategoryNameNcn.Text.ToString().ToUpper();
                if (curName.CompareTo("") != 0 && newCategory.CompareTo("") != 0)
                {
                    query = "UPDATE ITEM Set Category='" + newCategory + "' WHERE Name='" + curName + "'";
                    int rowCount = ob.editItem(query);
                    if (rowCount > 0)
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Item Category Edited Successfully");
                        itemCategoryComboboxFill();
                        itemListCategoryComboboxDefaultSelect();
                        autoCompleteItemCategoryTbox();
                    }
                    else
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Current Item Name Not Found ");
                    }
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "Error: Input Can't be Blank");
                }
                editCategoryNameCin.Text = "";
                editCategoryNameNcn.Text = "";
            }

            catch (FormatException)
            {
                MetroFramework.MetroMessageBox.Show(this, "Error: Wrong Input");
            }

            catch (Exception exc)
            {
                MetroFramework.MetroMessageBox.Show(this, exc.ToString());
            }
        }
        public int NextId(string type)
        {
            int id = 1;

            if (type == "consumable" || type == "other")
            {
                var items = new ItemDataAccess().FindAll <Item>();
                if (items.Count != 0)
                {
                    id = items.OrderBy(x => x.Id).Last().Id + 1;
                }
            }
            else
            {
                var equipments = new EquipmentDataAccess().FindAll <Equipment>();
                if (equipments.Count != 0)
                {
                    id = equipments.OrderBy(x => x.Id).Last().Id + 1;
                }
            }
            return(id);
        }
 public ActionResult Delete(int id)
 {
     return(View(ItemDataAccess.GetById(id)));
 }
 public ActionResult Edit(int id)
 {
     ViewBag.CategoryList = new SelectList(CategoryDataAccess.GetAll(), "CategoryCode", "CategoryName");
     return(View(ItemDataAccess.GetById(id)));
 }
 public ActionResult List()
 {
     return(View(ItemDataAccess.GetAll()));
 }
 public ActionResult GetByCategory(string categoryCode)
 {
     return(View(ItemDataAccess.GetByCategory(categoryCode)));
 }
 public ActionResult ExceptionList(List <string> exceptionList) // display item by exception and show selling price
 {
     return(View(ItemDataAccess.GetByException(exceptionList)));
 }
Exemple #19
0
        private void placeOrderAddItemBtn_Click(object sender, EventArgs e)
        {
            if (placeOrderItemNameCbox.Text.ToString().CompareTo("") != 0)
            {
                try
                {
                    ItemDataAccess      itemOb  = new ItemDataAccess();
                    OrderInfoDataAccess orderOb = new OrderInfoDataAccess();
                    string itemName             = placeOrderItemNameCbox.Text.ToString();
                    double itemUnitPrice        = itemOb.getItemUnitPrice(itemName);
                    int    qty = Convert.ToInt32(placeOrderQtyUpDown.Value);
                    int    orderId;

                    if (placeOrderIdLabel.Text.ToString().CompareTo("") == 0)
                    {
                        string sql = "Insert into ORDERINFO (ID,STATUS) VALUES(order_orderid_seq.NEXTVAL,'FALSE')";
                        orderOb.addOrderDetails(sql);
                        orderId = orderOb.getCurrentOrderId();
                        placeOrderIdLabel.Text       = Convert.ToString(orderId);
                        placeOrder_orderTotal.Text   = "0.0";
                        placeOrder_vatTotal.Text     = "0.0";
                        placeOrder_netTotal.Text     = "0.0";
                        placeOrder_discountTbox.Text = "0.0";
                    }
                    orderId = Convert.ToInt32(placeOrderIdLabel.Text.ToString());
                    string addOrderdItemSql = "Insert into ORDEREDITEM VALUES(" + orderId + "," + qty + "," + itemUnitPrice + ",'" + itemName + "')";
                    orderOb.addOrderDetails(addOrderdItemSql);


                    string           connStr = "Data Source=localhost; User Id= Tokee; Password=12345";
                    OracleConnection conn    = new OracleConnection(connStr);

                    string orderedItemListSql = "select ITEMNAME, ITEMUNITPRICE, ITEMQTY from ORDEREDITEM where ORDERID =" + orderId + "";


                    OracleDataAdapter adapter = new OracleDataAdapter(orderedItemListSql, conn);
                    DataTable         dt      = new DataTable();
                    adapter.Fill(dt);
                    placeOrderItemList.DataSource = dt;


                    orderTotal = orderTotal + (itemUnitPrice * qty);
                    vatTotal   = orderTotal * 0.15;
                    netTotal   = orderTotal + vatTotal;
                    placeOrder_orderTotal.Text = Convert.ToString(orderTotal);
                    placeOrder_vatTotal.Text   = Convert.ToString(vatTotal);
                    placeOrder_netTotal.Text   = Convert.ToString(netTotal);

                    placeOrderItemNameCbox.Items.Clear();
                    placeOrderItemCategoryCbox.Items.Clear();
                    itemCategoryComboboxFill();
                    itemListCategoryComboboxDefaultSelect();
                    placeOrderQtyUpDown.Value = placeOrderQtyUpDown.Minimum;
                }

                catch (Exception exc)
                {
                    MetroFramework.MetroMessageBox.Show(this, exc.ToString());
                }
            }
            else
            {
                MetroFramework.MetroMessageBox.Show(this, "No Item Selected");
            }
        }
Exemple #20
0
        public bool Update([FromBody] JObject content)
        {
            try
            {
                dynamic data      = JsonConvert.DeserializeObject <dynamic>(content.ToString());
                int     id        = (int)data.id;
                var     character = new CharacterDataAccess().FindOne <Character>(id);
                character.Resources = data.resources;
                character.Status["MaxLifePoints"]        = (int)data.max_life_points;
                character.Status["CurrentLifePoints"]    = (int)data.current_life_points;
                character.Status["MaxFatiguePoints"]     = (int)data.max_fatigue_points;
                character.Status["CurrentFatiguePoints"] = (int)data.current_fatigue_points;
                character.Status["MaxCarryWeight"]       = (int)data.max_carry_weight;
                character.Status["CurrentCarryWeight"]   = (int)data.current_carry_weight;

                character.Inventory = new Inventory();
                foreach (var equipment in data.inventory.one_hand_weapons)
                {
                    Equipment equipmentDatabase = new EquipmentDataAccess().FindOne <Equipment>((int)equipment.id);
                    equipmentDatabase.Equipped = equipment.equipped;
                    equipmentDatabase.Bought   = (bool)equipment.bought;
                    character.Inventory.OneHandWeapons.Add(equipmentDatabase);
                }
                foreach (var equipment in data.inventory.two_hand_weapons)
                {
                    Equipment equipmentDatabase = new EquipmentDataAccess().FindOne <Equipment>((int)equipment.id);
                    equipmentDatabase.Equipped = equipment.equipped;
                    equipmentDatabase.Bought   = (bool)equipment.bought;
                    character.Inventory.TwoHandWeapons.Add(equipmentDatabase);
                }
                foreach (var equipment in data.inventory.shields)
                {
                    Equipment equipmentDatabase = new EquipmentDataAccess().FindOne <Equipment>((int)equipment.id);
                    equipmentDatabase.Equipped = equipment.equipped;
                    equipmentDatabase.Bought   = (bool)equipment.bought;
                    character.Inventory.Shields.Add(equipmentDatabase);
                }
                foreach (var equipment in data.inventory.armors)
                {
                    Equipment equipmentDatabase = new EquipmentDataAccess().FindOne <Equipment>((int)equipment.id);
                    equipmentDatabase.Equipped = equipment.equipped;
                    equipmentDatabase.Bought   = (bool)equipment.bought;
                    character.Inventory.Armors.Add(equipmentDatabase);
                }
                foreach (var item in data.inventory.consumables)
                {
                    Item itemDatabase = new ItemDataAccess().FindOne <Item>((int)item.id);
                    itemDatabase.Bought   = (bool)item.bought;
                    itemDatabase.Quantity = item.quantity;
                    character.Inventory.Consumables.Add(itemDatabase);
                }
                foreach (var item in data.inventory.others)
                {
                    Item itemDatabase = new ItemDataAccess().FindOne <Item>((int)item.id);
                    itemDatabase.Bought   = (bool)item.bought;
                    itemDatabase.Quantity = item.quantity;
                    character.Inventory.Others.Add(itemDatabase);
                }
                new CharacterDataAccess().Update <Character>(character.Id, character);
            }
            catch
            {
                return(false);
            }
            return(true);
        }
 public ActionResult ExceptionListMax(List <string> exceptionListMax) // show purchasing price
 {
     return(View(ItemDataAccess.GetByExceptionMax(exceptionListMax)));
 }
 public ItemManager()
 {
     itemDataAccess        = new ItemDataAccess();
     transactionDataAccess = new TransactionDataAccess();
 }