public ActionResult Create([Bind(Include = "TransactionID,CustomerName,Line_IG_Name,Necklace,Bracelet,Earring,Hairpin,Ring,Address,Datetobuy,TotalPrice,ProductState,Remark")] IwanttobuyTransaction iwanttobuyTransaction)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    string dString = Request["Datetobuy"].ToString();
                    iwanttobuyTransaction.Datetobuy = DateTime.Parse(dString);
                    //iwanttobuyTransaction.Datetobuy = DateTime.Parse(dString, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                    //iwanttobuyTransaction.Datetobuy = DateTime.Now.AddHours(7);
                    db.IwanttobuyTransactions.Add(iwanttobuyTransaction);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (Exception e)
                {
                    TempData["Message"] = e.Message;
                    if (e.Message == "An error occurred while updating the entries. See the inner exception for details.")
                    {
                        TempData["Message"] += " : กรอกวันที่ผิดรูปแบบ ตัวอย่าง dd/MM/yyyy HH:mm:ss";
                    }
                    TempData["Type"] = "error";
                    //throw;
                }
            }

            return(View(iwanttobuyTransaction));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            IwanttobuyTransaction iwanttobuyTransaction = db.IwanttobuyTransactions.Find(id);

            db.IwanttobuyTransactions.Remove(iwanttobuyTransaction);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: IwanttobuyTransactions/Create
        public ActionResult Create()
        {
            IwanttobuyTransaction iwanttobuyObj = new IwanttobuyTransaction();

            iwanttobuyObj.Datetobuy = DateTime.Now.AddHours(7);
            iwanttobuyObj.Earring   = 0;
            iwanttobuyObj.Bracelet  = 0;
            iwanttobuyObj.Hairpin   = 0;
            iwanttobuyObj.Ring      = 0;
            iwanttobuyObj.Necklace  = 0;
            return(View(iwanttobuyObj));
        }
        public ActionResult Search()
        {
            IwanttobuyTransaction iwanttobuyTransaction = new IwanttobuyTransaction();

            iwanttobuyTransaction.CustomerName = Request["txtSearch"].ToString();
            if (iwanttobuyTransaction.CustomerName == "")
            {
                return(View("Index", db.IwanttobuyTransactions.OrderByDescending(m => m.TransactionID).ToList()));
            }
            ModelState.Clear();
            return(View("Index", db.IwanttobuyTransactions.Where(m => m.CustomerName.Contains(iwanttobuyTransaction.CustomerName) || m.Line_IG_Name.Contains(iwanttobuyTransaction.CustomerName)).ToList()));
        }
 public ActionResult Edit([Bind(Include = "TransactionID,CustomerName,Line_IG_Name,Necklace,Bracelet,Earring,Hairpin,Ring,Address,Datetobuy,TotalPrice,ProductState,Remark")] IwanttobuyTransaction iwanttobuyTransaction)
 {
     if (ModelState.IsValid)
     {
         string   dString = Request["Datetobuy"].ToString();
         DateTime d       = DateTime.ParseExact(dString, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
         iwanttobuyTransaction.Datetobuy       = d;
         db.Entry(iwanttobuyTransaction).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(iwanttobuyTransaction));
 }
        // GET: IwanttobuyTransactions/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IwanttobuyTransaction iwanttobuyTransaction = db.IwanttobuyTransactions.Find(id);

            if (iwanttobuyTransaction == null)
            {
                return(HttpNotFound());
            }
            return(View(iwanttobuyTransaction));
        }
        // GET: IwanttobuyTransactions/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IwanttobuyTransaction iwanttobuyTransaction = db.IwanttobuyTransactions.Find(id);

            if (iwanttobuyTransaction == null)
            {
                return(HttpNotFound());
            }
            iwanttobuyTransaction.Datetobuy = new DateTime(iwanttobuyTransaction.Datetobuy.Year, iwanttobuyTransaction.Datetobuy.Month, iwanttobuyTransaction.Datetobuy.Day,
                                                           iwanttobuyTransaction.Datetobuy.Hour, iwanttobuyTransaction.Datetobuy.Minute, 0, 0);
            return(View(iwanttobuyTransaction));
        }