Beispiel #1
0
        public ActionResult Create([Bind(Include = "ItemID,ItemName,ExpireDate,HighestBid")] Item item)
        {
            if (ModelState.IsValid)
            {
                db.Item.Add(item);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(item));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "ID,ProductName,Description,Price,Quantity")] Products products)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(products);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(products));
        }
        public ActionResult UpdateDatabase(FormCollection form)
        {
            var items = from m in db.Items
                        select m;

            foreach (var item in items)
            {
                // Confirmed the correct quantity
                if (form[("ConfirmCheckForItemId" + item.ID)] != null && form[("ConfirmCheckForItemId" + item.ID)].Equals("ConfirmedCorrect"))
                {
                    item.Confirmed       = true;
                    item.NewOnHand       = item.OnHand;
                    item.CounterInitials = this.counterInitials;
                }
                // Updated the quantity
                if ((form["NewQuantityForItemId" + item.ID] != "") && (form["NewQuantityForItemId" + item.ID] != null))
                {
                    item.NewOnHand       = Int32.Parse(form["NewQuantityForItemId" + item.ID].ToString());
                    item.CounterInitials = this.counterInitials;
                }

                // Updated the bin location

                if (form["NewBinLocationForItem" + item.ID] != item.BinLocation)
                {
                    if (form["NewBinLocationForItem" + item.ID] == "")
                    {
                        item.NewBinLocation = item.BinLocation;         // Set to default if it is blank
                    }
                    else
                    {
                        item.NewBinLocation  = form["NewBinLocationForItem" + item.ID].ToString();
                        item.CounterInitials = this.counterInitials;
                    }
                }

                // Updated the Notes
                if (form["NotesForItemId" + item.ID] != null && form["NotesForItemId" + item.ID] != "")
                {
                    item.Notes = form["NotesForItemId" + item.ID];
                }
            }
            db.SaveChanges();

            return(null);
        }
        public ActionResult Edit(int id, string name, string description)
        {
            ItemDB it = item.Items.Find(id);

            it.name        = name;
            it.description = description;
            item.SaveChanges();
            return(RedirectToAction("Detail", new { id = id }));
        }
        public ActionResult Init(string item_name, string item_description)
        {
            ItemDB it = new ItemDB();

            it.name        = item_name;
            it.description = item_description;
            item.Items.Add(it);
            item.SaveChanges();

            PersonDB stu = person.Persons.Find(User.Identity.Name);

            stu.item_now      = it.id;
            stu.item_original = it.id;
            person.SaveChanges();

            return(RedirectToAction("Index"));
        }
Beispiel #6
0
        private void CreateTransOnDB(List <IEnumerable <BankTran> > List)
        {
            //try
            //{
            using (ItemDBContext dbContext = new ItemDBContext())
            {
                foreach (var subList in List)
                {
                    //Batch batch = CreateBatch(subList);
                    Batch batch = BatchFactory.GetBatch("recovery", subList);

                    BatchDataEntry bde = CreateBatchDataEntry(batch.GlobalBatchID);

                    IEnumerable <Checks>          checks   = CreateChecks(subList, batch);
                    IEnumerable <ChecksDataEntry> checksDE = CreateChecksDataEntry(checks, batch, subList.ToList());
                    IEnumerable <Transactions>    trans    = CreateTransactions(checks, batch);

                    dbContext.Batch.Add((Batch)batch);
                    dbContext.BatchDataEntry.Add(bde);

                    foreach (var tran in trans)
                    {
                        dbContext.Transactions.Add(tran);
                    }

                    foreach (var check in checks)
                    {
                        dbContext.Checks.Add(check);
                    }

                    foreach (var cde in checksDE)
                    {
                        dbContext.ChecksDataEntry.Add(cde);
                    }

                    dbContext.SaveChanges();
                    //lblTrans.Text = dbContext.Database.Log.ToString();
                }
            }
            //}
            //catch
            //{
            //    throw;
            //}
        }
Beispiel #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (Session["swi"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (Session["swi"] != null && Session["isadmin"] == "yes")
            {
                return(RedirectToAction("Index", "Customers"));
            }

            Cust_ShopDBContext csd  = new Cust_ShopDBContext();
            Cust_Shop          csop = new Cust_Shop();
            var qwee = from o in csd.cust_shop where o.S_Id == id select o;
            int opq  = 0;

            foreach (var item in qwee)
            {
                opq  = item.Cust_Id;
                csop = item;
            }
            int swint = (int)Session["swi"];

            if (opq != swint)
            {
                return(RedirectToAction("Index", "Customers"));
            }
            csd.cust_shop.Remove(csop);
            csd.SaveChanges();

            var s = from a in sdb.shopit where a.S_Id == id select a;

            foreach (var q in s)
            {
                Shop_item x = new Shop_item();
                x = q;
                sdb.shopit.Remove(q);
                var result = from t in itdb.item
                             where t.T_Id == x.T_Id
                             orderby t.T_Id descending
                             select t;
                Items ti = result.First();
                itdb.item.Remove(ti);
                var q2 = from a in itp.item_val
                         where a.T_Id == x.T_Id
                         select a;
                foreach (var item in q2)
                {
                    itp.item_val.Remove(item);
                }
                var q3 = from a in ratdb.itrat where a.Id == ti.T_Id select a;
                foreach (var item in q3)
                {
                    ratdb.itrat.Remove(item);
                }
            }


            Shop shop = db.shop.Find(id);

            db.shop.Remove(shop);

            /*itdp.SaveChanges();
             * shopit.SaveChanges();
             * db.SaveChanges();
             * ratdb.SaveChanges();*/
            itp.SaveChanges();
            sdb.SaveChanges();
            itdb.SaveChanges();

            db.SaveChanges();
            ratdb.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #8
0
 public async Task <IActionResult> AddItem(ItemMaster itemMaster)
 {
     db.Add(itemMaster);
     db.SaveChanges();
     return(RedirectToAction("AllItem"));
 }
        public void GenerateDB(int WeekNumber, string Email, string Password)
        {
            // Generate partial shelf items
            PopulatePartial partialCreation = new PopulatePartial();
            List <int>      partialIds      = partialCreation.GenerateList(Email, Password);

            WeekToCycle RetrieveCodes = new WeekToCycle();
            List <int>  cycleCodes    = RetrieveCodes.DetermineCode(WeekNumber);

            if (cycleCodes != null)
            {
                for (int i = 0; i < 3; i++)
                {
                    // Query NetSuite
                    HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create("https://rest.netsuite.com/app/site/hosting/restlet.nl?script=128&deploy=1&cyclecountcode=" + cycleCodes[i]);
                    objRequest.Method      = "GET";
                    objRequest.ContentType = "application/json";
                    objRequest.Headers.Add(HttpRequestHeader.Authorization, "NLAuth nlauth_account=" + ConfigurationManager.AppSettings["NetSuiteAccountNumber"].ToString() + ", nlauth_email=" + Email + ", nlauth_signature=" + Password + "");
                    objRequest.Timeout = 500000;
                    HttpWebResponse objResponse = objRequest.GetResponse() as HttpWebResponse;

                    // Pull data off of NetSuite
                    using (Stream objResponseStream = objResponse.GetResponseStream())
                    {
                        StreamReader sr      = new StreamReader(objResponseStream);
                        string       rawData = sr.ReadToEnd();
                        JArray       rows    = JArray.Parse(rawData);

                        // List that will store all of the Count Items
                        List <Item> Items = new List <Item>();

                        // Parse Json and store values
                        foreach (JObject row in rows)
                        {
                            // Create new Count Item
                            Item item = new Item();

                            JToken cols                = row["columns"];
                            string Name                = cols["itemid"] == null ? null : cols["itemid"].Value <string>();
                            string BinLocation         = cols["custitem_bin_location"] == null ? null : cols["custitem_bin_location"].Value <string>();
                            string Description         = cols["salesdescription"] == null ? null : cols["salesdescription"].Value <string>();
                            int    OnHand              = cols["locationquantityonhand"] == null ? 0 : cols["locationquantityonhand"].Value <int>();
                            int    ID                  = cols["internalid"]["internalid"] == null ? 0 : cols["internalid"]["internalid"].Value <int>();
                            int    CycleCountCode      = cols["custitem2"] == null ? 0 : cols["custitem2"].Value <int>();
                            string VendorCode          = cols["vendorcode"] == null ? null : cols["vendorcode"].Value <string>();
                            string Brand               = cols["custitem_brand"] == null ? null : cols["custitem_brand"]["name"].Value <string>();
                            int    QuantityBackOrdered = cols["quantitybackordered"] == null ? 0 : cols["quantitybackordered"].Value <int>();
                            string Vendor              = cols["othervendor"] == null ? null : cols["othervendor"]["name"].Value <string>();
                            string PreferredVendor     = cols["vendor"] == null ? null : cols["vendor"]["name"].Value <string>();
                            int    WebID               = cols["custitem_web_product_id"] == null ? 0 : cols["custitem_web_product_id"].Value <int>();

                            if (Vendor == PreferredVendor || Vendor == null) // Some items have no vendor, but still need to be counted
                            {
                                // Create the items
                                item.Name                = Name;
                                item.BinLocation         = BinLocation;
                                item.Description         = Description;
                                item.OnHand              = OnHand;
                                item.ID                  = ID;
                                item.NewOnHand           = OnHand;
                                item.CycleCountCode      = CycleCountCode;
                                item.NewBinLocation      = BinLocation;
                                item.CounterInitials     = null;
                                item.VendorCode          = VendorCode;
                                item.Brand               = Brand;
                                item.QuantityBackOrdered = QuantityBackOrdered;
                                item.WebProductID        = WebID;
                                if (partialIds.Contains(item.ID))
                                {
                                    item.OnPartial = true;
                                }
                                // Add item to the Items list
                                db.Items.Add(item);
                            }
                        }
                        db.SaveChanges();
                    }
                }
            }
        }
        public void rm(int customer_id)
        {
            RRDBContext        ratedb      = new RRDBContext();
            ItemvalueDBContext itemvaluedb = new ItemvalueDBContext();
            ShopItemDBContext  shopitemdb  = new ShopItemDBContext();
            ItemDBContext      itemdb      = new ItemDBContext();
            Cust_ShopDBContext custshopdb  = new Cust_ShopDBContext();
            shopDBContext      shopdb      = new shopDBContext();
            //Cs_SuDBContext cssudb = new Cs_SuDBContext();
            //CustomersDBContext customerdb = new CustomersDBContext();

            int shop_id;
            var q1 = from a1 in custshopdb.cust_shop where a1.Cust_Id == customer_id select a1;

            foreach (var item1 in q1.ToList())
            {
                shop_id = item1.S_Id;
                var       q2 = from a2 in shopitemdb.shopit where a2.S_Id == shop_id select a2;
                int       item_id;
                Shop_item si;
                foreach (var item2 in q2.ToList())
                {
                    item_id = item2.T_Id;
                    var        q3 = from a3 in itemvaluedb.item_val where item_id == a3.T_Id select a3;
                    Item_value iv;
                    foreach (var item3 in q3.ToList())
                    {
                        iv = item3;
                        itemvaluedb.item_val.Remove(iv);
                        itemvaluedb.SaveChanges();
                    }
                    si = item2;
                    shopitemdb.shopit.Remove(si);
                    shopitemdb.SaveChanges();

                    var   q4 = from a4 in itemdb.item where a4.T_Id == item_id select a4;
                    Items it;
                    foreach (var item4 in q4.ToList())
                    {
                        it = item4;
                        itemdb.item.Remove(it);
                        itemdb.SaveChanges();

                        Item_rate r = ratedb.itrat.Find(it.T_Id);
                        ratedb.itrat.Remove(r);
                        ratedb.SaveChanges();
                    }
                }
                Cust_Shop cs = item1;
                custshopdb.cust_shop.Remove(cs);
                custshopdb.SaveChanges();

                Shop s;
                var  q5 = from a5 in shopdb.shop where a5.S_Id == shop_id select a5;
                foreach (var item5 in q5.ToList())
                {
                    s = item5;
                    shopdb.shop.Remove(s);
                    shopdb.SaveChanges();
                }
            }

            var   q6 = from a6 in db5.cs_su where a6.Customer == customer_id select a6;
            Cs_Su cssu;

            foreach (var item6 in q6.ToList())
            {
                cssu = item6;
                db5.cs_su.Remove(cssu);
                db5.SaveChanges();
            }

            Customers custome = db.customer.Find(customer_id);

            db.customer.Remove(custome);
            db.SaveChanges();
        }