コード例 #1
0
        public ActionResult Create(JournalVFormatModel model)
        {
            if (ModelState.IsValid)
            {
                EHMSEntities ent  = new EHMSEntities();
                var          data = ent.JornalVFormats.Where(m => m.JVFormat == model.JVFormat).Select(m => m.JVId).ToList();
                //var dataa = ent.SetupBlock.Where(m => m.BlockName == model.BlockName).Count();
                if (data.Count == 0)
                {
                    int i = JVFPro.Insert(model);
                    if (i != null)
                    {
                        TempData["success"] = HospitalManagementSystem.UtilityMessage.save;
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        TempData["success"] = HospitalManagementSystem.UtilityMessage.savefailed;
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    TempData["success"] = HospitalManagementSystem.UtilityMessage.AlreadyExist;
                    return(RedirectToAction("Index"));
                }
            }


            return(View());
        }
コード例 #2
0
        public int Update(JournalVFormatModel model)
        {
            int i = 0;

            using (EHMSEntities ent = new EHMSEntities())
            {
                var objToEdit = ent.JornalVFormats.Where(x => x.JVId == model.JVId).FirstOrDefault();
                AutoMapper.Mapper.Map(model, objToEdit);

                objToEdit.JVFormat = objToEdit.Prefix + "-" + objToEdit.FiscalYear + "-" + objToEdit.Postfix;

                ent.Entry(objToEdit).State = System.Data.EntityState.Modified;
                i = ent.SaveChanges();
            }
            return(i);
        }
コード例 #3
0
 public ActionResult Edit(int id, JournalVFormatModel model)
 {
     if (ModelState.IsValid)
     {
         int i = JVFPro.Update(model);
         if (i != null)
         {
             TempData["success"] = HospitalManagementSystem.UtilityMessage.edit;
             return(RedirectToAction("Index"));
         }
         else
         {
             TempData["success"] = HospitalManagementSystem.UtilityMessage.editfailed;
             return(RedirectToAction("Index"));
         }
         //return View(model);
     }
     return(View(model));
 }
コード例 #4
0
        public int Insert(JournalVFormatModel model)
        {
            int i = 0;

            using (EHMSEntities ent = new EHMSEntities())
            {
                var objList = ent.JornalVFormats.ToList();
                foreach (var item in objList)
                {
                    item.IsCurrent        = "N";
                    ent.Entry(item).State = System.Data.EntityState.Modified;
                    ent.SaveChanges();
                }
                var objToSave = AutoMapper.Mapper.Map <JournalVFormatModel, JornalVFormat>(model);
                objToSave.IsCurrent = "Y";
                objToSave.JVFormat  = objToSave.Prefix + "-" + objToSave.FiscalYear + "-" + objToSave.Postfix;
                ent.JornalVFormats.Add(objToSave);
                i = ent.SaveChanges();
            }
            return(i);
        }
コード例 #5
0
 public ActionResult Edit(int id)
 {
     model = JVFPro.GetList().Where(x => x.JVId == id).FirstOrDefault();
     return(View(model));
 }