public ActionResult Create([Bind(Include = "ProductId,ProductName,ProductDetails,ProductStatus,ProductUpdate,ProductQty,ProductSold,ProductsOldPrice,SupplierId,CategoryId")] Product product)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.Products.Add(product);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", product.CategoryId);
            ViewBag.SupplierId = new SelectList(db.Suppliers, "SupplierId", "CompanyName", product.SupplierId);
            return(View(product));
        }
        public ActionResult Create([Bind(Include = "NewsId,NewTitles,NewsDetails,NewsBy,NewsDate,EmployeeCode")] News news)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.News.Add(news);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeCode = new SelectList(db.Employees, "EmployeeCode", "FirstName", news.EmployeeCode);
            return(View(news));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "EmployeeCode,EmployeePass,LastName,FirstName,Title,TitleOfCourtesy,BirthDate,HireDate,Address,PostalCode,HomePhone,Extension,Notes,RoleId")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    employee.EmployeePass = Encrypt.MD5_Encode(employee.EmployeePass);
                    db.Employees.Add(employee);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.RoleId = new SelectList(db.Roles, "Id", "RoleName", employee.RoleId);
            return(View(employee));
        }
        public ActionResult Create([Bind(Include = "CategoryId,CategoryName,CategoryDetails")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Example #5
0
        public ActionResult Create([Bind(Include = "Id,RoleName,RoleDescription")] Role role)
        {
            if (ModelState.IsValid)
            {
                db.Roles.Add(role);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(role));
        }
        public ActionResult Create([Bind(Include = "ContactId,CompanyName,ContactName,Address,Region,PostalCode,Phone,ContactsTitle,Fax,Status")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                db.Contacts.Add(contact);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(contact));
        }
Example #7
0
        public ActionResult Create([Bind(Include = "SupplierId,CompanyName,ContactName,ContactTitle,Address,Phone,Fax,HomePage")] Supplier supplier)
        {
            if (ModelState.IsValid)
            {
                db.Suppliers.Add(supplier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(supplier));
        }
        public ActionResult Create([Bind(Include = "PromotionId,PromotionName,PromotionDetails,PromotionDiscount,PromotionStatus,PromotionOpen,PromotionClose")] Promotion promotion)
        {
            if (ModelState.IsValid)
            {
                db.Promotions.Add(promotion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(promotion));
        }
Example #9
0
        public ActionResult Create([Bind(Include = "BranchId,BranchName,BranchDetails,EmployeeCode")] Branch branch)
        {
            if (ModelState.IsValid)
            {
                db.Branches.Add(branch);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeCode = new SelectList(db.Employees, "EmployeeCode", "EmployeePass", branch.EmployeeCode);
            return(View(branch));
        }
Example #10
0
        public ActionResult Create([Bind(Include = "DeliveryId,DeliveryTitle,DeliveryDetails,DeliveryQuestion,EmployeeCode")] Delivery delivery)
        {
            if (ModelState.IsValid)
            {
                db.Deliveries.Add(delivery);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeCode = new SelectList(db.Employees, "EmployeeCode", "FirstName", delivery.EmployeeCode);
            return(View(delivery));
        }
        public ActionResult Create([Bind(Include = "AboutId,AboutUs,AboutImg,AboutDetails,EmployeeCode")] About about)
        {
            if (ModelState.IsValid)
            {
                db.Abouts.Add(about);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeCode = new SelectList(db.Employees, "EmployeeCode", "LastName", about.EmployeeCode);
            return(View(about));
        }
Example #12
0
        public ActionResult Create([Bind(Include = "PromotionId,ProductId,Gift")] Product_Promotion product_Promotion)
        {
            if (ModelState.IsValid)
            {
                db.Product_Promotion.Add(product_Promotion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductId = new SelectList(db.Products, "ProductId", "ProductName", product_Promotion.ProductId);
            ViewBag.ProductId = new SelectList(db.Promotions, "PromotionId", "PromotionName", product_Promotion.ProductId);
            return(View(product_Promotion));
        }