コード例 #1
0
        public ActionResult Edit([Bind(Include = "ID,CustomerName,OrderNumber,Date,Description")] Customer customer)
        {
            if (Session["type"] == null || Session["type"].ToString() == "")
            {
                Session["DefaultView"]     = "Edit";
                Session["DefaultControll"] = "Customer";
                return(RedirectToAction("Login", "Employee"));
            }

            if (ModelState.IsValid)
            {
                db.Entry(customer).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(customer));
        }
コード例 #2
0
        public ActionResult Edit([Bind(Include = "ID,BrandName,Origin")] Brand brand)
        {
            if (Session["type"] == null || Session["type"].ToString() == "")
            {
                Session["DefaultView"]     = "Edit";
                Session["DefaultControll"] = "Brand";
                return(RedirectToAction("Login", "Employee"));
            }

            if (ModelState.IsValid)
            {
                db.Entry(brand).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(brand));
        }
コード例 #3
0
        public ActionResult Edit([Bind(Include = "ID,UnitName,UnitDescription,UnitPrimaryQty")] Unit unit)
        {
            if (Session["type"] == null || Session["type"].ToString() == "")
            {
                Session["DefaultView"]     = "Edit";
                Session["DefaultControll"] = "Unit";
                return(RedirectToAction("Login", "Employee"));
            }

            if (ModelState.IsValid)
            {
                db.Entry(unit).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(unit));
        }
コード例 #4
0
        public ActionResult Edit([Bind(Include = "ID,ProductID,ProductPrice1")] ProductPrice productPrice)
        {
            if (Session["type"] == null || Session["type"].ToString() == "")
            {
                Session["DefaultView"]     = "Edit";
                Session["DefaultControll"] = "ProductPrice";
                return(RedirectToAction("Login", "Employee"));
            }

            if (ModelState.IsValid)
            {
                db.Entry(productPrice).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.ProductID = new SelectList(db.Products, "ID", "ProductName", productPrice.ProductID);
            return(View(productPrice));
        }
コード例 #5
0
        public ActionResult Edit([Bind(Include = "EmployeeID")] EmployeeAdmin employeeAdmin)
        {
            if (Session["type"] == null || Session["type"].ToString() == "")
            {
                Session["DefaultView"]     = "Edit";
                Session["DefaultControll"] = "EmployeeAdmin";
                return(RedirectToAction("Login", "Employee"));
            }

            if (ModelState.IsValid)
            {
                db.Entry(employeeAdmin).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.EmployeeID = new SelectList(db.Employees, "ID", "EmployeeName", employeeAdmin.EmployeeID);
            return(View(employeeAdmin));
        }
コード例 #6
0
        public ActionResult Edit([Bind(Include = "ID,CityName,CountryID")] City city)
        {
            if (Session["type"] == null || Session["type"].ToString() == "")
            {
                Session["DefaultView"]     = "Edit";
                Session["DefaultControll"] = "City";
                return(RedirectToAction("Login", "Employee"));
            }

            if (ModelState.IsValid)
            {
                db.Entry(city).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CountryID = new SelectList(db.Countries, "ID", "CountryName", city.CountryID);
            return(View(city));
        }
コード例 #7
0
        public ActionResult Edit([Bind(Include = "ID,ProductName,ProductCode,ProductQuentity,ProductDescription,ProductPosition,CategoryID,BrandID")] Product product)
        {
            if (Session["type"] == null || Session["type"].ToString() == "")
            {
                Session["DefaultView"]     = "Edit";
                Session["DefaultControll"] = "Product";
                return(RedirectToAction("Login", "Employee"));
            }

            if (ModelState.IsValid)
            {
                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.BrandID    = new SelectList(db.Brands, "ID", "BrandName", product.BrandID);
            ViewBag.CategoryID = new SelectList(db.Categories, "ID", "CategoryName", product.CategoryID);
            return(View(product));
        }
コード例 #8
0
        public ActionResult Edit(ProductImage productImage, HttpPostedFileBase PI)
        {
            if (Session["type"] == null || Session["type"].ToString() == "")
            {
                Session["DefaultView"]     = "Edit";
                Session["DefaultControll"] = "ProductImage";
                return(RedirectToAction("Login", "Employee"));
            }

            productImage.ProductImage1 = System.IO.Path.GetFileName(PI.FileName);

            if (ModelState.IsValid)
            {
                db.Entry(productImage).State = EntityState.Modified;
                db.SaveChanges();
                PI.SaveAs(Server.MapPath("../Images/ProductImage/UpdateProductImage/" + productImage.ID.ToString() + "_" + productImage.ProductImage1));
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductID = new SelectList(db.Products, "ID", "ProductName", productImage.ProductID);
            return(View(productImage));
        }
コード例 #9
0
        public ActionResult Edit(Employee employee, HttpPostedFileBase EP)
        {
            if (Session["type"] == null || Session["type"].ToString() == "")
            {
                Session["DefaultView"]     = "Edit";
                Session["DefaultControll"] = "Employee";
                return(RedirectToAction("Login"));
            }

            employee.EmployeeJoinDate = DateTime.Now;
            employee.EmployeePicture  = System.IO.Path.GetFileName(EP.FileName);

            if (ModelState.IsValid)
            {
                db.Entry(employee).State = EntityState.Modified;
                db.SaveChanges();
                EP.SaveAs(Server.MapPath("../Images/Uploads/" + employee.ID.ToString() + "_" + employee.EmployeePicture));
                return(RedirectToAction("Index"));
            }
            ViewBag.EmployeeCityID = new SelectList(db.Cities, "ID", "CityName", employee.EmployeeCityID);
            ViewBag.ID             = new SelectList(db.EmployeeAdmins, "EmployeeID", "EmployeeID", employee.ID);
            return(View(employee));
        }