// GET: InvCarGateControls/Create
        public ActionResult Create(int?control)
        {
            InvCarGateControl invcar = new InvCarGateControl();

            if (control == null)
            {
                invcar.In_Out_flag = 1; //gate out
            }
            else
            {
                invcar.In_Out_flag = (int)control;
            }

            invcar.dtControl = DateTime.Now;

            var invItems = db.InvItems.Where(s => s.ViewLabel == "UNIT").Select(
                s => new SelectListItem
            {
                Value = s.Id.ToString(),
                Text  = s.ItemCode.ToString() + " - " + s.Description
            }
                );

            ViewBag.recordType = invcar.In_Out_flag == 1 ? "Out" : "In";
            ViewBag.InvItemId  = new SelectList(invItems, "Value", "Text");
            return(View(invcar));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            InvCarGateControl invCarGateControl = db.InvCarGateControls.Find(id);

            db.InvCarGateControls.Remove(invCarGateControl);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,InvItemId,In_Out_flag,Odometer,dtControl,Remarks,Driver,Inspector")] InvCarGateControl invCarGateControl)
 {
     if (ModelState.IsValid)
     {
         db.Entry(invCarGateControl).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.InvItemId = new SelectList(db.InvItems, "Id", "ItemCode", invCarGateControl.InvItemId);
     return(View(invCarGateControl));
 }
        // GET: InvCarGateControls/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            InvCarGateControl invCarGateControl = db.InvCarGateControls.Find(id);

            if (invCarGateControl == null)
            {
                return(HttpNotFound());
            }
            return(View(invCarGateControl));
        }
        // GET: InvCarGateControls/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            InvCarGateControl invCarGateControl = db.InvCarGateControls.Find(id);

            if (invCarGateControl == null)
            {
                return(HttpNotFound());
            }
            ViewBag.InvItemId = new SelectList(db.InvItems, "Id", "ItemCode", invCarGateControl.InvItemId);
            return(View(invCarGateControl));
        }