Ejemplo n.º 1
0
        public ActionResult Create(PayMent payment, HttpPostedFileBase ImageUrl, string nameCus)
        {
            if (this.Session["Account"] == null)
            {
                return Redirect("/Login");
            }
            if(nameCus==null){
                TempData["a"] = "Xin chọn khách hàng";
                return View();
            }
            if (ModelState.IsValid)
            {
                PayMent newP = new PayMent();
                newP.UserId = Convert.ToInt32(this.Session["ID"]);
                newP.DatePay = DateTime.Now;
                newP.Cash = payment.Cash;
                newP.Invisible = false;
                newP.CustomerId = Convert.ToInt32(nameCus);

                if (ImageUrl != null)
                {

                    ImageUrl.SaveAs(HttpContext.Server.MapPath("~/img/") + ImageUrl.FileName);
                    newP.ImageUrl = ImageUrl.FileName;
                }
                db.PayMents.Add(newP);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View();
        }
Ejemplo n.º 2
0
 public ActionResult Edit(PayMent payment, HttpPostedFileBase fileImage)
 {
     if (this.Session["Account"] == null)
     {
         return Redirect("/Login");
     }
     if (ModelState.IsValid)
     {
         if (fileImage != null)
         {
             fileImage.SaveAs(HttpContext.Server.MapPath("~/img/") + fileImage.FileName);
             payment.ImageUrl = fileImage.FileName;
         }
         db.Entry(payment).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.CustomerId = new SelectList(db.Customers, "Id", "Name", payment.CustomerId);
     ViewBag.UserId = new SelectList(db.Staffs, "Id", "StaffName", payment.UserId);
     return View(payment);
 }
Ejemplo n.º 3
0
 public ActionResult CreatePayment( PayMent payment)
 {
     if (this.Session["Account"] == null)
     {
         return Redirect("/Login");
     }
     db.PayMents.Add(payment);
     db.SaveChanges();
     return View();
 }