コード例 #1
0
        public ActionResult Create(Store store)
        {
            if (this.Session["Account"] == null || this.Session["ID"]==null)
            {
                Redirect("/Login");
            }
            var stores = db.Stores.Where(s => s.Invisible == false);
            ViewBag.list = stores.ToList();
            var b = store.ProductPrice;
            var c = Convert.ToDouble(b);
            store.ProductPrice = c;
            if (ModelState.IsValid)
            {
                if (store.Note.Contains("Tờ")) {
                    if (store.Width == null || store.Height == null || store.Square == null) { return View(); }
                }
                store.State = 0;
                store.Invisible = false;
                store.CreatorId = Convert.ToInt32(this.Session["ID"]);

                db.Stores.Add(store);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(store);
        }
コード例 #2
0
        public void Import(string Name, string Quantity, string Note, string Date,string Supplier, string Price )
        {
            if (this.Session["Account"] == null || this.Session["ID"] == null)
            {
                 Redirect("/Login");
            }
            Store store = new Store();
            store.ProductName = Name;
            store.CurrentQ = Convert.ToInt32(Quantity);
            store.Note = Note;
            store.ProductPrice = Convert.ToDouble(Price);
            store.Time = DateTime.Now;
            store.SupplierName = Supplier;
            store.State = 0;
            store.Invisible = false;
            store.CreatorId = Convert.ToInt32(this.Session["ID"]);

            db.Stores.Add(store);
            db.SaveChanges();
        }
コード例 #3
0
 public void Export(string Export, string ID,  string VL)
 {
     if (this.Session["Account"] == null || this.Session["ID"] == null)
     {
          Redirect("/Login");
     }
     var store = db.Stores.Find(Convert.ToInt32(ID));
     var rest = store.CurrentQ - Convert.ToInt32(Export);
     if (rest >= 0) {
         var newStore = new Store();
         newStore.ProductName = store.ProductName;
         newStore.ProductPrice = store.ProductPrice;
         newStore.SupplierName = store.SupplierName;
         newStore.CurrentQ = rest;
         newStore.InputQ = store.CurrentQ;
         newStore.OutputQ = Convert.ToInt32(Export);
         newStore.Invisible = false;
         newStore.Note = store.Note;
         newStore.Time = DateTime.Now;
         newStore.CreatorId = Convert.ToInt32(this.Session["ID"]);
         newStore.Width = store.Width;
         newStore.Height = store.Height;
         newStore.Square = store.Square;
         store.Invisible = true;
         store.OutputQ = 0;
         db.Stores.Add(newStore);
         db.SaveChanges();
     }
 }
コード例 #4
0
        public void ExportS(string Export, string ID, string ProcessId)
        {
            if (this.Session["Account"] == null)
            {
                Redirect("/Login");
            }
            var store = db.Stores.Find(Convert.ToInt32(ID));
            var rest = store.CurrentQ - Convert.ToInt32(Export);
            if (rest >= 0)
            {
                var newStore = new Store();
                newStore.ProductName = store.ProductName;
                newStore.ProductPrice = store.ProductPrice;
                newStore.SupplierName = store.SupplierName;
                newStore.CurrentQ = rest;
                newStore.InputQ = store.CurrentQ;
                newStore.OutputQ = Convert.ToInt32(Export);
                newStore.Invisible = false;
                newStore.Note = store.Note;
                newStore.Time = DateTime.Now;
                newStore.CreatorId = Convert.ToInt32(this.Session["ID"]);
                newStore.Width = store.Width;
                newStore.Height = store.Height;
                newStore.Square = store.Square;
                store.Invisible = true;
                store.OutputQ = 0;
                db.Stores.Add(newStore);
                ///them moi
                var PID = Convert.ToInt32(ProcessId);
                var newProcess = db.Processes.Where(s => s.Id == PID).FirstOrDefault();
                newProcess.OutPutQ = Convert.ToInt32(Export);
                newProcess.Height = store.Height;
                newProcess.Width = store.Width;
                newProcess.Square = store.Square;
                ///
                db.SaveChanges();

            }
        }
コード例 #5
0
 public ActionResult Edit(Store store)
 {
     if (this.Session["Account"] == null)
     {
         return Redirect("/Login");
     }
     if (ModelState.IsValid)
     {
         db.Entry(store).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.CustomerId = new SelectList(db.Customers, "Id", "Name", store.CustomerId);
     ViewBag.CreatorId = new SelectList(db.Staffs, "Id", "StaffName", store.CreatorId);
     return View(store);
 }