Ejemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "id,email,password,fullname,phone,gender,dayOfBirth,address,avatar,idCounty,activated,status,createdDate,modifyDate,modifyBy,roleId")] Customer customer,
                                 HttpPostedFileBase avatar)
        {
            if (ModelState.IsValid)
            {
                string path = Server.MapPath("/Assets/Admin/resources/customer");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (customer.avatar != null)
                {
                    avatar.SaveAs(path + "/" + avatar.FileName);
                    customer.avatar = "Assets/Admin/resources/customer/" + avatar.FileName;
                }
                else
                {
                    customer.avatar = "Assets/Admin/resources/customer/" + "customerDefault.jpg";
                }

                customer.modifyDate      = DateTime.Now;
                customer.modifyBy        = Session["username"].ToString();
                customer.password        = EncryptPassword.EncryptForPassword(customer.password);
                db.Entry(customer).State = EntityState.Modified;
                db.SaveChanges();
                return(new RedirectResult(url: "/Admin/Customers/Index?message=update_success"));
            }
            ViewBag.idCounty = new SelectList(db.Counties, "id", "name", customer.idCounty);
            ViewBag.roleId   = new SelectList(db.Roles, "id", "name", customer.roleId);
            return(View(customer));
        }
        public ActionResult Edit([Bind(Include = "id,productName,categoryId,description,image,viewCount,discount,createdDate,createdBy,modifyDate,modifyBy,type,price,status")] Product product,
                                 HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                string path = Server.MapPath("/Assets/Admin/resources/product");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (product.image != null)
                {
                    image.SaveAs(path + "/" + image.FileName);
                    product.image = "Assets/Admin/resources/product/" + image.FileName;
                }
                else
                {
                    product.image = "Assets/Admin/resources/product/" + "defaultProduct.jpg";
                }

                product.modifyDate      = DateTime.Now;
                product.modifyBy        = Session["username_Employee"].ToString();
                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                return(new RedirectResult(url: "/Admin/Products/Index?message=update_success"));
            }
            ViewBag.categoryId = new SelectList(db.Categories, "id", "categoryName", product.categoryId);
            return(View(product));
        }
        public ActionResult Edit([Bind(Include = "id,email,password,fullname,phone,gender,dayOfBirth,address,avatar,dateStart,dateEnd,contractSalary,unitSalary,workTime,schedule,createdDate,createdBy,modifyDate,modifyBy,status,activated")] Employee employee,
                                 HttpPostedFileBase avatar, string role)
        {
            if (ModelState.IsValid)
            {
                string path = Server.MapPath("/Assets/Admin/resources/image");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (employee.avatar != null)
                {
                    avatar.SaveAs(path + "/" + avatar.FileName);
                    employee.avatar = "Assets/Admin/resources/image/" + avatar.FileName;
                }
                else
                {
                    employee.avatar = "Assets/Admin/resources/image/" + "userDefault.jpg";
                }

                AccountRole account = new AccountRole();
                account.employeeId  = employee.id;
                account.roleId      = Convert.ToInt32(role);
                employee.modifyDate = DateTime.Now;
                employee.modifyBy   = Session["username_Employee"].ToString();
                employee.password   = EncryptPassword.EncryptForPassword(employee.password);
                db.AccountRoles.Add(account);
                db.Entry(employee).State = EntityState.Modified;
                db.SaveChanges();
                return(new RedirectResult(url: "/Admin/Employees/Index?message=update_success"));
            }
            return(View(employee));
        }
Ejemplo n.º 4
0
        public ActionResult EditProfile([Bind(Include = "id,email,password,fullname,phone,gender,dayOfBirth,address,avatar,idCounty,activated,status,createdDate,modifyDate,modifyBy,roleId")] Customer customer,
                                        HttpPostedFileBase avatar)
        {
            LAUNDRY_PROJECTEntities db = new LAUNDRY_PROJECTEntities();

            if (ModelState.IsValid)
            {
                string path = Server.MapPath("/Assets/Client/resources/image");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (customer.avatar != null)
                {
                    avatar.SaveAs(path + "/" + avatar.FileName);
                    customer.avatar = "Assets/Client/resources/image/" + avatar.FileName;
                }
                else
                {
                    customer.avatar = "Assets/Client/resources/image/" + "customerDefault.jpg";
                }

                customer.modifyDate      = DateTime.Now;
                customer.modifyBy        = Session["username_Customer"].ToString();
                db.Entry(customer).State = EntityState.Modified;
                db.SaveChanges();
                return(new RedirectResult(url: "/Account/infoProfile/" + customer.id + "?message=update_success"));
            }
            ViewBag.idCounty = new SelectList(db.Counties, "id", "name", customer.idCounty);
            return(View(customer));
        }
 public ActionResult Edit([Bind(Include = "id,name")] County county)
 {
     if (ModelState.IsValid)
     {
         db.Entry(county).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(county));
 }
 public ActionResult Edit([Bind(Include = "id,workerName,phone,address,gender,dayOfBirth,avatar,status,dateStart,dateEnd,contactSalary,unitSalary,workTime,schedule")] Worker worker)
 {
     if (ModelState.IsValid)
     {
         db.Entry(worker).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(worker));
 }
 public ActionResult Edit([Bind(Include = "id,statusName,color")] Status status)
 {
     if (ModelState.IsValid)
     {
         db.Entry(status).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(status));
 }
Ejemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "id,addressName,price")] ShippingAdress shippingAdress)
 {
     if (ModelState.IsValid)
     {
         db.Entry(shippingAdress).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(shippingAdress));
 }
 public ActionResult Edit([Bind(Include = "id,categoryName,categoryCode,description,createdDate,createdBy,modifyDate,modifyBy,status")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Ejemplo n.º 10
0
 public ActionResult Edit([Bind(Include = "id,providerName,phone,address,email,status")] Provider provider)
 {
     if (ModelState.IsValid)
     {
         db.Entry(provider).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(provider));
 }
 public ActionResult Edit([Bind(Include = "id,paymentName")] PayMentMethod payMentMethod)
 {
     if (ModelState.IsValid)
     {
         db.Entry(payMentMethod).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(payMentMethod));
 }
Ejemplo n.º 12
0
 public ActionResult Edit([Bind(Include = "id,title,thumbnail,shortDescription,content,categoryPostId,createdDate,createdBy,modifyDate,modifyBy,status")] News news)
 {
     if (ModelState.IsValid)
     {
         db.Entry(news).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.categoryPostId = new SelectList(db.PostCategories, "id", "categoryNamePost", news.categoryPostId);
     return(View(news));
 }
 public ActionResult Edit([Bind(Include = "id,month,employeeId,dayOff,dayWork,hourOfDay,salaryToMonth,unitSalary,fromDate,toDate,standardWorkDay,totalWorkDay,baseSalary,mainSalary,subsidySalary,totalOverTime,overtimePay,totalSalary,description")] PayRollsEmployee payRollsEmployee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(payRollsEmployee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.employeeId = new SelectList(db.Employees, "id", "email", payRollsEmployee.employeeId);
     return(View(payRollsEmployee));
 }
 public ActionResult Edit([Bind(Include = "id,orderId,codeName,createdDate,createdBy")] Barcode barcode)
 {
     if (ModelState.IsValid)
     {
         db.Entry(barcode).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.orderId = new SelectList(db.Orders, "id", "address", barcode.orderId);
     return(View(barcode));
 }
 public ActionResult Edit([Bind(Include = "id,productName,categoryId,description,image,viewCount,discount,createdDate,createdBy,modifyDate,modifyBy,pieceType,pricePiece,kgType,priceKg,status")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.categoryId = new SelectList(db.Categories, "id", "categoryName", product.categoryId);
     return(View(product));
 }
Ejemplo n.º 16
0
 public ActionResult Edit([Bind(Include = "id,workerId,dateStart,dateEnd,title,status")] Work work)
 {
     if (ModelState.IsValid)
     {
         db.Entry(work).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.workerId = new SelectList(db.Workers, "id", "workerName", work.workerId);
     return(View(work));
 }
 public ActionResult Edit([Bind(Include = "id,customerId,orderId,totalDebt,fromDate,toDate,description,status")] DuePayment duePayment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(duePayment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.customerId = new SelectList(db.Customers, "id", "email", duePayment.customerId);
     ViewBag.orderId    = new SelectList(db.Orders, "id", "address", duePayment.orderId);
     return(View(duePayment));
 }
Ejemplo n.º 18
0
 public ActionResult Edit([Bind(Include = "id,orderId,productId,discount,price,type,status")] OrderDetail orderDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orderDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.orderId   = new SelectList(db.Orders, "id", "address", orderDetail.orderId);
     ViewBag.productId = new SelectList(db.Products, "id", "productName", orderDetail.productId);
     return(View(orderDetail));
 }
Ejemplo n.º 19
0
 public ActionResult Edit([Bind(Include = "id,employeeId,roleId")] AccountRole accountRole)
 {
     if (ModelState.IsValid)
     {
         db.Entry(accountRole).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.employeeId = new SelectList(db.Employees, "id", "email", accountRole.employeeId);
     ViewBag.roleId     = new SelectList(db.Roles, "id", "name", accountRole.roleId);
     return(View(accountRole));
 }
Ejemplo n.º 20
0
 public ActionResult Edit([Bind(Include = "id,content,customerId,newId,createdDate,createdBy,modifyDate,modifyBy,status")] Comment comment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(comment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.customerId = new SelectList(db.Customers, "id", "email", comment.customerId);
     ViewBag.newId      = new SelectList(db.News, "id", "title", comment.newId);
     return(View(comment));
 }
Ejemplo n.º 21
0
 public ActionResult Edit([Bind(Include = "id,providerId,price,amount,description,createdDate,createdBy,modifyDate,modifyBy,available,materialName")] Material material)
 {
     if (ModelState.IsValid)
     {
         material.modifyDate      = DateTime.Now;
         material.modifyBy        = Session["username"].ToString();
         db.Entry(material).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.providerId = new SelectList(db.Providers, "id", "providerName", material.providerId);
     return(View(material));
 }
 public ActionResult Edit([Bind(Include = "id,customerId,orderDate,endDate,address,paymentMethodId,paymentStatus,amount,description,statusId,createdBy,shippingId,employeeIdConfirm,employeeIdShipping,totalDebt,totalOrder,status")] Order order)
 {
     if (ModelState.IsValid)
     {
         if (order.paymentStatus == "done")
         {
             order.endDate = DateTime.Now;
         }
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.customerId         = new SelectList(db.Customers, "id", "email", order.customerId);
     ViewBag.paymentMethodId    = new SelectList(db.PayMentMethods, "id", "paymentName", order.paymentMethodId);
     ViewBag.shippingId         = new SelectList(db.ShippingAdresses, "id", "addressName", order.shippingId);
     ViewBag.statusId           = new SelectList(db.Status, "id", "statusName", order.statusId);
     ViewBag.employeeIdConfirm  = new SelectList(db.Employees, "id", "email", order.employeeIdConfirm);
     ViewBag.employeeIdShipping = new SelectList(db.Employees, "id", "email", order.employeeIdShipping);
     return(View(order));
 }