public ActionResult DeleteConfirmed(string id)
        {
            tbCounter tbCounter = db.tbCounter.Find(id);

            db.tbCounter.Remove(tbCounter);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: Configcounter/Edit/5
        public ActionResult Edit(string id, string ServID, string ServID1, string ServID2)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbCounter tbCounter = db.tbCounter.Find(id);

            if (tbCounter == null)
            {
                return(HttpNotFound());
            }
            List <SelectListItem> tc = CS.tbService
                                       .Select(a => new SelectListItem
            {
                Value    = a.ServID.ToString(),
                Text     = a.ServID.ToString() + "." + a.ServiveName,
                Selected = (a.ServID.ToString() == ServID ? true : false)
            }).ToList();

            tc.Insert(0, new SelectListItem()
            {
                Value = "0", Text = "-- ไม่เลือกประเภทบริการ --"
            });
            ViewBag.ServID      = tc;
            ViewBag.CounterName = db.tbCounter.Find(id).CounterName.ToString();

            List <SelectListItem> tc1 = CS.tbService
                                        .Select(b => new SelectListItem
            {
                Value    = b.ServID.ToString(),
                Text     = b.ServID.ToString() + "." + b.ServiveName,
                Selected = (b.ServID.ToString() == ServID1 ? true : false)
            }).ToList();

            tc1.Insert(0, new SelectListItem()
            {
                Value = "0", Text = "-- ไม่เลือกประเภทบริการ --"
            });
            ViewBag.ServID1 = tc1;

            List <SelectListItem> tc2 = CS.tbService
                                        .Select(c => new SelectListItem
            {
                Value    = c.ServID.ToString(),
                Text     = c.ServID.ToString() + "." + c.ServiveName,
                Selected = (c.ServID.ToString() == ServID2 ? true : false)
            }).ToList();

            tc2.Insert(0, new SelectListItem()
            {
                Value = "0", Text = "-- ไม่เลือกประเภทบริการ --"
            });
            ViewBag.ServID2 = tc2;


            return(View(tbCounter));
        }
 public ActionResult Edit([Bind(Include = "CounterNo,CounterName,ServID,ID,ServID1,ServID2,Summary,CallNum,CGroup,CallCounter,Announce,Status,Process,CPos")] tbCounter tbCounter)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbCounter).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbCounter));
 }
        // GET: Configcounter/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbCounter tbCounter = db.tbCounter.Find(id);

            if (tbCounter == null)
            {
                return(HttpNotFound());
            }
            return(View(tbCounter));
        }
        // GET: Configcounter/Details/5
        public ActionResult Details(string id)
        {
            tbCounter tbCouter = db.tbCounter.Find(id);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbCounter tbCounter = db.tbCounter.Find(id);

            if (tbCounter == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CounterName = tbCounter.CounterName.ToString();
            return(View(tbCounter));
        }