Beispiel #1
0
        public ActionResult NewShelf(Shelf shelf)
        {
            using (CCV_Tables_Context db = new CCV_Tables_Context())
            {
                if (ModelState.IsValid)
                {
                    bool isAlreadyRegistered = db.Shelves.Any(c => c.Xposition == shelf.Xposition) &&
                                               db.Shelves.Any(c => c.Yposition == shelf.Yposition) &&
                                               db.Shelves.Any(c => c.RackId == shelf.RackId);
                    if (!isAlreadyRegistered)
                    {
                        shelf.RackId = (int)HttpContext.Session["RackID"];
                        db.Shelves.Add(shelf);
                        db.SaveChanges();
                        ModelState.Clear();
                        return(RedirectToAction("Index", new { iD = Session["RackID"] }));
                    }
                    else
                    {
                        TempData["AlreadyExist"] = "You can not create two shelves on the same position";
                    }
                }

                return(View());
            }
        }
        public ActionResult Register(UserAcount account)
        {
            if (ModelState.IsValid)
            {
                using (CCV_Tables_Context db = new CCV_Tables_Context())
                {
                    bool isAlreadyRegistered = db.UserAcounts.Any(c => c.Password == account.Password) && db.UserAcounts.Any(c => c.Username == account.Username);
                    if (!isAlreadyRegistered)
                    {
                        db.UserAcounts.Add(account);
                        db.SaveChanges();
                        ModelState.Clear();
                        TempData["WelcomeUser"] = account.LastName + " " + account.FirstName + " successfully registered";
                        return(RedirectToAction("Login"));
                    }
                    else
                    {
                        TempData["AlreadyExist"] = "Please change your password or username";
                    }
                }
                ViewBag.Message = account.LastName + " " + account.FirstName + " successfully registered";
            }

            return(View());
        }
Beispiel #3
0
 public ActionResult Delete(int id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         var rack = db.Racks.SingleOrDefault(c => c.RackId == id);
         db.Racks.Remove(rack);
         db.SaveChanges();
         return(RedirectToAction("Index", new { iD = Session["StoreHouseID"] }));
     }
 }
 public ActionResult Delete(int id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         var emp = db.UserAcounts.SingleOrDefault(c => c.UserId == id);
         db.UserAcounts.Remove(emp);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Beispiel #5
0
 public ActionResult Delete(int id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         var stHouse = db.StoreHouses.SingleOrDefault(c => c.StoreHouseId == id);
         db.StoreHouses.Remove(stHouse);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Beispiel #6
0
 public ActionResult Delete(int id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         var shelf = db.Shelves.SingleOrDefault(c => c.ShelfId == id);
         db.Shelves.Remove(shelf);
         db.SaveChanges();
         return(RedirectToAction("Index", new { iD = Session["RackID"] }));
     }
 }
 public ActionResult Edit(UserAcount account)
 {
     if (ModelState.IsValid)
     {
         using (CCV_Tables_Context db = new CCV_Tables_Context())
         {
             db.Entry(account).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     return(View());
 }
Beispiel #8
0
        public ActionResult Edit(Rack rack)
        {
            using (CCV_Tables_Context db = new CCV_Tables_Context())
            {
                if (ModelState.IsValid)
                {
                    rack.StoreHouseRefId = (int)HttpContext.Session["StoreHouseID"];
                    db.Entry(rack).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index", new{ iD = Session["StoreHouseID"] }));
                }

                return(View());
            }
        }
Beispiel #9
0
        public ActionResult Edit(Shelf shelf)
        {
            using (CCV_Tables_Context db = new CCV_Tables_Context())
            {
                if (ModelState.IsValid)
                {
                    shelf.RackId          = (int)HttpContext.Session["RackID"];
                    db.Entry(shelf).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index", new { iD = Session["RackID"] }));
                }

                return(View());
            }
        }
Beispiel #10
0
        public ActionResult Import(HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    if (upload.FileName.EndsWith(".csv"))
                    {
                        Stream    stream   = upload.InputStream;
                        DataTable csvTable = new DataTable();
                        using (CsvReader csvReader =
                                   new CsvReader(new StreamReader(stream), true))
                        {
                            csvTable.Load(csvReader);
                        }

                        using (CCV_Tables_Context db = new CCV_Tables_Context())
                        {
                            string[] words;
                            for (int i = 0; i < csvTable.Rows.Count; i++)
                            {
                                csvTable.Rows[i].ItemArray[0].ToString();
                                words = csvTable.Rows[i].ItemArray[0].ToString().Split(';');
                                Rack rack = new Rack();
                                rack.EAN             = Int32.Parse(words[0]);
                                rack.Xposition       = Int32.Parse(words[1]);
                                rack.Yposition       = Int32.Parse(words[2]);
                                rack.Activ           = Boolean.Parse(words[3]);
                                rack.StoreHouseRefId = (int)Session["StoreHouseID"];
                                db.Racks.Add(rack);
                                db.SaveChanges();
                            }
                        }
                        return(View(csvTable));
                    }
                    else
                    {
                        ModelState.AddModelError("File", "This file format is not supported");
                        return(View());
                    }
                }
                else
                {
                    ModelState.AddModelError("File", "Please Upload Your file");
                }
            }
            return(View());
        }
Beispiel #11
0
        public ActionResult Import(HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    if (upload.FileName.EndsWith(".csv"))
                    {
                        Stream    stream   = upload.InputStream;
                        DataTable csvTable = new DataTable();
                        using (CsvReader csvReader =
                                   new CsvReader(new StreamReader(stream), true))
                        {
                            csvTable.Load(csvReader);
                        }

                        using (CCV_Tables_Context db = new CCV_Tables_Context())
                        {
                            string[] words;
                            for (int i = 0; i < csvTable.Rows.Count; i++)
                            {
                                csvTable.Rows[i].ItemArray[0].ToString();
                                words = csvTable.Rows[i].ItemArray[0].ToString().Split(';');
                                StoreHouse storeHouse = new StoreHouse();
                                storeHouse.StoreHouseName = words[0];
                                StringToEnum myIntToEnum = new StringToEnum();
                                storeHouse.storeHouseType  = myIntToEnum.GetStoreHouseTypeFromString(words[1]);
                                storeHouse.StoreHouseActiv = Boolean.Parse(words[2]);
                                db.StoreHouses.Add(storeHouse);
                                db.SaveChanges();
                            }
                        }
                        return(View(csvTable));
                    }
                    else
                    {
                        ModelState.AddModelError("File", "This file format is not supported");
                        return(View());
                    }
                }
                else
                {
                    ModelState.AddModelError("File", "Please Upload Your file");
                }
            }
            return(View());
        }
Beispiel #12
0
 public ActionResult NewRack(Rack rack)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         if (ModelState.IsValid)
         {
             bool isAlreadyRegistered = db.Racks.Any(c => c.Xposition == rack.Xposition) && db.Racks.Any(c => c.Yposition == rack.Yposition) && db.Racks.Any(c => c.StoreHouseRefId == rack.StoreHouseRefId);
             if (!isAlreadyRegistered)
             {
                 rack.StoreHouseRefId = (int)HttpContext.Session["StoreHouseID"];
                 db.Racks.Add(rack);
                 db.SaveChanges();
                 ModelState.Clear();
                 return(RedirectToAction("Index", new { iD = Session["StoreHouseID"] }));
             }
             else
             {
                 TempData["AlreadyExist"] = "You can not have two rack on the same position";
             }
         }
         return(View());
     }
 }
Beispiel #13
0
        public ActionResult NewStoreHouse(StoreHouse storeHouse)
        {
            using (CCV_Tables_Context db = new CCV_Tables_Context())
            {
                bool isAlreadyRegistered = db.StoreHouses.Any(c => c.StoreHouseName == storeHouse.StoreHouseName);
                if (ModelState.IsValid)
                {
                    if (!isAlreadyRegistered)
                    {
                        db.StoreHouses.Add(storeHouse);
                        db.SaveChanges();
                        ModelState.Clear();
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        TempData["AlreadyExist"] = "There can not be two storehouses with same name";
                    }
                }

                return(View());
            }
        }