public ActionResult Create(ReplacementItem replaceItem)
 {
     if (replaceItem.existingItm_Num == null || replaceItem.existingItm_Num.Length == 0)
     {
         ModelState.AddModelError("existingItm_Num", "Please enter replacement item number");
     }
     else if (replaceItem.existingItm_Num.Length != 7)
     {
         ModelState.AddModelError("existingItm_Num", "Replacement item number must be 7 digits.");
     }
     if (replaceItem.replacementCode == null)
     {
         ModelState.AddModelError("replacementCode", "Please select replacement code.");
     }
     if (ModelState.IsValid)
     {
         replaceItem.replacementCreateDate = DateTime.Now;
         db.ReplacementItems.Add(replaceItem);
         db.SaveChanges();
         return(RedirectToAction("Index", "ReplacementItem", new { id = replaceItem.ItmId })); // View("Index", new { id = replaceItem.ItmId });
     }
     else
     {
         ViewBag.ReplacementCodes = new SelectList(db.ReplacementItemCodes, "replacementCode", "replacementCodeDesc");
         return(View(replaceItem));
     }
 }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Exclude = "WareHouse_id")] WareHouse_Lookup warehouse_lookup)
        {
            if (ModelState.IsValid)
            {
                db.WareHouse_Lookup.Add(warehouse_lookup);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(warehouse_lookup));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Exclude = "CategoryAttribute_Id")] CategoryAttribute categoryattribute)
        {
            if (ModelState.IsValid)
            {
                db.CategoryAttributes.Add(categoryattribute);
                int userid = int.Parse(Session.Contents["UserID"].ToString());
                categoryattribute.ModifiedBy   = userid;
                categoryattribute.ModifiedDate = DateTime.Now;
                if (categoryattribute.SubClassCode_Id == 0)
                {
                    categoryattribute.SubClassCode_Id = null;
                }
                if (categoryattribute.FineLineCode_Id == 0)
                {
                    categoryattribute.FineLineCode_Id = null;
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AttributeType_Id = new SelectList(db.AttributeTypes, "AttributeType_Id", "AttributeType1", categoryattribute.AttributeType_Id);
            var CategoryClass = db.CategoryClasses.Select(c => new
            {
                CategoryClass_Id = c.CategoryClass_Id,
                Description      = c.Category_Id + " - " + c.CategoryName
            })
                                .ToList();

            ViewBag.CategoryClass = new SelectList(CategoryClass, "CategoryClass_Id", "Description", categoryattribute.CategoryClass_Id);
            var SubClass = db.SubClasses.Select(s => new
            {
                SubClassCode_Id = s.SubClassCode_Id,
                Description     = s.SubClass_Id + " - " + s.SubClassName
            })
                           .ToList();

            ViewBag.SubClass = new SelectList(SubClass, "SubClassCode_Id", "Description", categoryattribute.SubClassCode_Id);
            var FineLineClass = db.FineLineClasses.Select(f => new
            {
                FineLineCode_Id = f.FineLineCode_Id,
                Description     = f.FineLine_Id + " - " + f.FinelineName
            })
                                .ToList();

            ViewBag.FineLineClass = new SelectList(FineLineClass, "FineLineCode_Id", "Description", categoryattribute.FineLineCode_Id);


            //            ViewBag.CategoryClass_Id = new SelectList(db.CategoryClasses, "CategoryClass_Id", "Category_Id", categoryattribute.CategoryClass_Id);
            return(View(categoryattribute));
        }
        public ActionResult Create([Bind(Exclude = "Freight_Id")] Freight_Lookup freight_lookup)
        {
            if (ModelState.IsValid)
            {
                db.Freight_Lookup.Add(freight_lookup);
                int userid = int.Parse(Session.Contents["UserID"].ToString());
                freight_lookup.ModifiedBy   = userid;
                freight_lookup.ModifiedDate = DateTime.Now;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(freight_lookup));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Exclude = "AttributeType_Id")] AttributeType attributetype)
        {
            if (ModelState.IsValid)
            {
                db.AttributeTypes.Add(attributetype);
                int userid = int.Parse(Session.Contents["UserID"].ToString());
                attributetype.ModifiedBy   = userid;
                attributetype.ModifiedDate = DateTime.Now;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(attributetype));
        }
Ejemplo n.º 6
0
        public ActionResult Create([Bind(Exclude = "ItemDescriptionOrder_Id")] ItemDescriptionOrder itemdescriptionorder)
        {
            if (ModelState.IsValid)
            {
                db.ItemDescriptionOrders.Add(itemdescriptionorder);
                int userid = int.Parse(Session.Contents["UserID"].ToString());
                itemdescriptionorder.ModifiedBy   = userid;
                itemdescriptionorder.ModifiedDate = DateTime.Now;
                if (itemdescriptionorder.SubClassCode_Id == 0)
                {
                    itemdescriptionorder.SubClassCode_Id = null;
                }
                if (itemdescriptionorder.FineLineCode_Id == 0)
                {
                    itemdescriptionorder.FineLineCode_Id = null;
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.AttributeType_Id = new SelectList(db.AttributeTypes, "AttributeType_Id", "AttributeType1");
            var CategoryClass = db.CategoryClasses.Select(c => new
            {
                CategoryClass_Id = c.CategoryClass_Id,
                Description      = c.Category_Id + " - " + c.CategoryName
            })
                                .ToList();

            ViewBag.CategoryClass = new SelectList(CategoryClass, "CategoryClass_Id", "Description");
            var SubClass = db.SubClasses.Select(s => new
            {
                SubClassCode_Id = s.SubClassCode_Id,
                Description     = s.SubClass_Id + " - " + s.SubClassName
            })
                           .ToList();

            ViewBag.SubClass = new SelectList(SubClass, "SubClassCode_Id", "Description");
            var FineLineClass = db.FineLineClasses.Select(f => new
            {
                FineLineCode_Id = f.FineLineCode_Id,
                Description     = f.FineLine_Id + " - " + f.FinelineName
            })
                                .ToList();

            ViewBag.FineLineClass    = new SelectList(FineLineClass, "FineLineCode_Id", "Description");
            ViewBag.SystemType       = LoadSystemType("");
            ViewBag.DescriptionField = LoadDescription("");
            return(View(itemdescriptionorder));
        }
Ejemplo n.º 7
0
        public ActionResult Create([Bind(Exclude = "User_Id")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                int userid = int.Parse(Session.Contents["UserID"].ToString());
                user.ModifiedBy   = userid;
                user.ModifiedDate = DateTime.Now;
                user.EncryptPwd   = GetSHA1(user.UserName, user.Password);
                user.Password     = RandomString(16);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserType_Id = new SelectList(db.UserTypes, "UserType_id", "UserTypeDescription", user.UserType_Id);
            return(View(user));
        }
Ejemplo n.º 8
0
        public ActionResult SaveUpload(UploadFile model, HttpPostedFileBase file)
        {
            List <string> fTypes = GetAllowedFileTypes();

            if (FileIsValid(file, fTypes))
            {
                int    userid     = int.Parse(Session.Contents["UserId"].ToString());
                int    usertypeid = int.Parse(Session.Contents["UserTypeId"].ToString());
                string path0      = Server.MapPath("~/Uploads/");
                if (!Directory.Exists(path0))
                {
                    Directory.CreateDirectory(path0);
                }
                string path = Server.MapPath("~/Uploads/" + userid.ToString() + "/");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                string fileAndPath = Path.Combine(Server.MapPath("~/Uploads/"), userid.ToString() + "/" + Path.GetFileName(file.FileName));
                if (System.IO.File.Exists(fileAndPath))
                {
                    System.IO.File.Delete(fileAndPath);
                }
                file.SaveAs(path + Path.GetFileName(file.FileName));
                UploadFile m = new UploadFile();
                m.UserId = userid;
                if (model.UploadNote != null && model.UploadNote.Length > 255)
                {
                    m.UploadNote = model.UploadNote.Substring(0, 254);
                }
                else
                {
                    m.UploadNote = model.UploadNote;
                }
                m.FileName = Path.GetFileName(file.FileName);
                m.LoadDate = DateTime.Now;
                db.UploadFiles.Add(m);
                db.SaveChanges();
                var user = db.Users.Where(u => u.User_id == m.UserId).FirstOrDefault();
                if (user != null)
                {
                    m.UserName = user.FirstName + " " + user.LastName;
                }
                SendEmailto(m);
                return(RedirectToAction("Index"));
            }
            else
            {
                string errorMessage = GetFileErrorMessage(file, fTypes);
                ModelState.AddModelError("FileName", errorMessage);
                return(View("Upload"));
            }
        }
        public ActionResult Create([Bind(Exclude = "AttributeLookup_Id")] Attribute_Lookup attribute_lookup)
        {
            if (ModelState.IsValid)
            {
                int userid = int.Parse(Session.Contents["UserID"].ToString());
                db.Attribute_Lookup.Add(attribute_lookup);
                attribute_lookup.AttributeType_Id = attribute_lookup.AttributeType_Id;
                attribute_lookup.ModifiedBy       = userid;
                attribute_lookup.ModifiedDate     = DateTime.Now;
                db.SaveChanges();
                int attributetype_id = attribute_lookup.AttributeType_Id;//db.ItemAttributes.Where(ia => ia.ItemAttribute_Id == id).Select(ia => ia.Item_Id).Single();
                var attributelookup  = db.Attribute_Lookup.Where(al => al.AttributeType_Id == attributetype_id && al.Active == true).OrderBy(al => al.APlusAttributeValue);
                ViewBag.AttributeType    = db.AttributeTypes.Where(at => at.AttributeType_Id == attributetype_id).Select(at => at.AttributeType1).Single();
                ViewBag.AttributeType_Id = attributetype_id;

                return(RedirectToAction("Index", new { id = attribute_lookup.AttributeType_Id }));
            }

            ViewBag.AttributeType_Id = new SelectList(db.AttributeTypes, "AttributeType_Id", "AttributeType1", attribute_lookup.AttributeType_Id);
            return(View(attribute_lookup));
        }
        public ActionResult Create([Bind(Exclude = "ItemAttribute_Id")] ItemAttribute itemattribute)
        {
            string at = Request.Form["AttributeType_Id"];

            if (at == "" || at == null)
            {
                at = "0";
            }
            int atid = int.Parse(at);

            if ((itemattribute.AttributeLookup_Id == 0 || itemattribute.AttributeLookup_Id == null) && atid != 0)
            {
                int alid = db.Attribute_Lookup.Where(al => (al.AttributeType_Id == atid) && (al.WebsiteAttributeValue == "Not Selected")).Select(al => al.AttributeLookup_Id).Single();
                itemattribute.AttributeLookup_Id = alid;
            }
            int id                         = int.Parse(Session["ItemID"].ToString());
            var itemAttributes             = db.ItemAttributes.Include(i => i.Attribute_Lookup.AttributeType).Include(i => i.Item).Where(i => i.Item_Id == id);
            List <Attribute_Lookup> allALs = new List <Attribute_Lookup>();

            foreach (var ia in itemAttributes)
            {
                allALs.Add(db.Attribute_Lookup.Where(a => a.AttributeLookup_Id == ia.AttributeLookup_Id).FirstOrDefault());
            }
            allALs.Add(db.Attribute_Lookup.Where(a => a.AttributeLookup_Id == itemattribute.AttributeLookup_Id).FirstOrDefault());
            var duplicate        = allALs.GroupBy(i => i.AttributeType_Id).Select(i => new { Attrbute = i.Key, Count = i.Count() }).Where(i => i.Count > 1);
            var attributeLook_up = db.Attribute_Lookup.Where(a => a.AttributeLookup_Id == itemattribute.AttributeLookup_Id).FirstOrDefault();
            var attributeType    = db.AttributeTypes.Where(a => a.AttributeType_Id == attributeLook_up.AttributeType_Id).FirstOrDefault();

            if (duplicate != null && duplicate.Count() > 0)
            {
                ModelState.AddModelError("AttributeLookup_Id", "Duplicate item attribute!");
                Session["CreateError"] = "Attribute " + attributeType.AttributeType1 + " trying to added is a duplicate";
            }
            if (ModelState.IsValid)
            {
                int usertypeid = int.Parse(Session.Contents["UserTypeId"].ToString());
                db.ItemAttributes.Add(itemattribute);
                itemattribute.AddedBy   = usertypeid;
                itemattribute.AddedDate = DateTime.Now;

                if (atid != 0)
                {
                    db.SaveChanges();
                }
                int item_id = itemattribute.Item_Id.Value;//db.ItemAttributes.Where(ia => ia.ItemAttribute_Id == id).Select(ia => ia.Item_Id).Single();
                ViewBag.Itm_num           = db.Items.Where(i => i.Item_id == item_id).Select(i => i.Itm_Num).Single();
                ViewBag.ItemDescription   = db.Items.Where(i => i.Item_id == item_id).Select(i => i.Item_Description).Single();
                ViewBag.SFItemDescription = db.Items.Where(i => i.Item_id == item_id).Select(i => i.SF_Item_Description).Single();

                var dbItems = db.Items.FirstOrDefault(i => i.Item_id == itemattribute.Item_Id);
                if (dbItems == null)
                {
                    return(HttpNotFound());
                }

                GetCategoryClass(item_id);
                if (ViewBag.CategoryClass == "Y")
                {
                    GetItemDescription(item_id);
                }
                //return RedirectToAction("Index", new { id = itemattribute.Item_Id });
            }
            return(RedirectToAction("Index", new { id = itemattribute.Item_Id })); //View(itemattribute);
        }