public static void AddNewIp(AppIp source) { var ruleDate = DateTime.Now.Date; var obj = new IpForm { MartialStatus = source.MartialStatus, DateTime = DateTime.Now, Name = source.Name, OpdId = source.OpdId, PatientNo = source.PatientNo, Phone = source.Phone, GuardianName = source.GuardianName, Gender = source.Gender, DoctorId = source.DoctorId, Caste = source.Caste, CNIC = source.CNIC, Age = source.Age, BloodGroup = source.BloodGroup, Address = source.Address, AdvanceAmount = source.AdvanceAmount, }; using (var dbcontext = new HMSEntities()) { try { if (string.IsNullOrEmpty(obj.PatientNo)) { obj.PatientNo = DateTime.Now.Year + "" + DateTime.Now.Month + "-" + DateTime.Now.Day + (dbcontext.OPDs.Count(form => EntityFunctions.TruncateTime(form.DateTime) == ruleDate) + 1) + ""; } dbcontext.IpForms.Add(obj); var room = dbcontext.WardsRooms.FirstOrDefault(war => war.Id == source.RoomId); room.Booked = true; dbcontext.SaveChanges(); } catch (Exception dcdf) { } } }
public ActionResult CreateIpForm(string opdId) { var opd = new AppIp { BloodGroup = "B+" }; if (!string.IsNullOrEmpty(opdId)) { opd = OpdService.ConvertToIp(opdId); opd.DateTime = DateTime.Now.ToLongTimeString(); } var dataModel = new IpPageModel { DoctorList = DocService.GetAllDocsForDd(), WardsList = IpFormService.GetWards(), GeneralData = opd }; return(View(dataModel)); }
public JsonResult CreateFormAjax(AppIp data) { IpFormService.AddNewIp(data); return(Json(true, JsonRequestBehavior.AllowGet)); }