public ActionResult DeleteConfirmed(int id)
        {
            byehora byehora = db.byehoras.Find(id);

            db.byehoras.Remove(byehora);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Create(List <byehora> byehoras)
 {
     try
     {
         if (ModelState.IsValid)
         {
             foreach (var item in byehoras)
             {
                 if (item.hisabNo == null)
                 {
                     byehora objByehora = new byehora();
                     objByehora.byehoraName = TrimText(item.byehoraName);
                     objByehora.hisabNo     = TrimText(item.hisabNo);
                     objByehora.remarks     = TrimText(item.remarks);
                     objByehora.khaSiNaId   = null;
                     db.byehoras.Add(objByehora);
                     db.SaveChanges();
                 }
                 else
                 {
                     string hisabNo    = TrimText(item.hisabNo);
                     var    objKhaSiNa = db.khaSiNas.FirstOrDefault(m => m.khaSiNo == hisabNo);
                     if (objKhaSiNa == null)
                     {
                         byehora objByehora = new byehora();
                         objByehora.byehoraName = TrimText(item.byehoraName);
                         objByehora.hisabNo     = TrimText(item.hisabNo);
                         objByehora.remarks     = TrimText(item.remarks);
                         objByehora.khaSiNaId   = null;
                         db.byehoras.Add(objByehora);
                         db.SaveChanges();
                     }
                     else
                     {
                         byehora objByehora = new byehora();
                         objByehora.byehoraName = TrimText(item.byehoraName);
                         objByehora.hisabNo     = TrimText(item.hisabNo);
                         objByehora.remarks     = TrimText(item.remarks);
                         objByehora.khaSiNaId   = objKhaSiNa.khaSiNaId;
                         db.byehoras.Add(objByehora);
                         db.SaveChanges();
                     }
                 }
             }
         }
         ViewBag.Message = "Record Inserted Successfully";
         return(RedirectToAction("index", "Byehora"));
     }
     catch
     {
         ViewBag.ErrorMessage = "Error! Please Try Again";
         return(View(byehoras));
     }
 }
        // GET: /Byehora/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            byehora byehora = db.byehoras.Find(id);

            if (byehora == null)
            {
                return(HttpNotFound());
            }
            return(View(byehora));
        }
 public ActionResult Edit([Bind(Include = "byehoraId,byehoraName,hisabNo,khaSiNaId,remarks")] byehora byehora)
 {
     if (ModelState.IsValid)
     {
         var objByehora = db.byehoras.Find(byehora.byehoraId);
         objByehora.byehoraName = TrimText(byehora.byehoraName);
         objByehora.hisabNo     = TrimText(byehora.hisabNo);
         objByehora.remarks     = TrimText(byehora.remarks);
         objByehora.khaSiNaId   = byehora.khaSiNaId;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.khaSiNaId = new SelectList(db.khaSiNas, "khaSiNaId", "khaSirsak", byehora.khaSiNaId);
     return(View(byehora));
 }
        // GET: /Byehora/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            byehora byehora = db.byehoras.Find(id);

            if (byehora == null)
            {
                return(HttpNotFound());
            }
            ViewBag.khaSiNaId = new SelectList(db.khaSiNas, "khaSiNaId", "khaSirsak", byehora.khaSiNaId);
            return(View(byehora));
        }