public ActionResult Create([Bind(Include = "O_ID,O_Date,UserName,Do_Date,Tattoo_ID,Price,Description,Status")] OderMaster oderMaster)
        {
            if (Session["UserName"] != null)
            {
                if (oderMaster.O_Date == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    if (ModelState.IsValid)
                    {
                        oderMaster.Do_Date  = DateTime.Now;
                        oderMaster.UserName = Session["UserName"].ToString();
                        oderMaster.Status   = "ค้างชำระ";
                        db.OderMasters.Add(oderMaster);
                        db.SaveChanges();
                        return(RedirectToAction("Index", "OderMasters"));
                    }
                }
            }
            else
            {
                return(RedirectToAction("Index", "Login"));
            }

            ViewBag.UserName  = new SelectList(db.Members, "UserName", "FirstName", oderMaster.UserName);
            ViewBag.Tattoo_ID = new SelectList(db.Tattoos, "Tattoo_ID", "Tattoo_Name", oderMaster.Tattoo_ID);
            return(View(oderMaster));
        }
Esempio n. 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            OderMaster oderMaster = db.OderMasters.Find(id);

            db.OderMasters.Remove(oderMaster);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "O_ID,O_Date,UserName,Do_Date,Tattoo_ID,Price,Description,Status")] OderMaster oderMaster)
 {
     if (ModelState.IsValid)
     {
         db.Entry(oderMaster).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserName  = new SelectList(db.Members, "UserName", "FirstName", oderMaster.UserName);
     ViewBag.Tattoo_ID = new SelectList(db.Tattoos, "Tattoo_ID", "Tattoo_Name", oderMaster.Tattoo_ID);
     return(View(oderMaster));
 }
Esempio n. 4
0
        public ActionResult Edit([Bind(Include = "O_ID,O_Date,UserName,Do_Date,Tattoo_ID,Price,Description,Status")] OderMaster oderMaster)
        {
            var update = db.OderMasters.Where(x => x.O_ID == oderMaster.O_ID).ToList();

            if (update.Count() > 0)
            {
                update.ForEach(x => { x.Status = oderMaster.Status; });
                db.SaveChanges();
            }
            ViewBag.UserName  = new SelectList(db.Members, "UserName", "FirstName", oderMaster.UserName);
            ViewBag.Tattoo_ID = new SelectList(db.Tattoos, "Tattoo_ID", "Tattoo_Name", oderMaster.Tattoo_ID);
            return(RedirectToAction("Index"));
        }
Esempio n. 5
0
        // GET: AdminOder/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OderMaster oderMaster = db.OderMasters.Find(id);

            if (oderMaster == null)
            {
                return(HttpNotFound());
            }
            return(View(oderMaster));
        }
Esempio n. 6
0
        // GET: AdminOder/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OderMaster oderMaster = db.OderMasters.Find(id);

            if (oderMaster == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserName  = new SelectList(db.Members, "UserName", "FirstName", oderMaster.UserName);
            ViewBag.Tattoo_ID = new SelectList(db.Tattoos, "Tattoo_ID", "Tattoo_Name", oderMaster.Tattoo_ID);
            return(View(oderMaster));
        }