public ActionResult DeleteConfirmed(int id) { DocRecord docRecord = db.DocRecordSet.Find(id); db.DocRecordSet.Remove(docRecord); db.SaveChanges(); return(RedirectToAction("Index")); }
protected override void Print() { string path = Properties.Settings.Default.DocFollowTemplate; if (string.IsNullOrEmpty(path)) { string msg = "يجب تحديد مسار تقرير المتابعة"; Helper.ShowMessage(msg); return; } try { DocRecord currentDoc = null; using (IUnitOfWork unit = new UnitOfWork()) { currentDoc = unit.DocRecords.GetById(DocId); } if (currentDoc != null) { List <DocFollowsReport> source = new List <DocFollowsReport>(); if (currentDoc.DocRecordFollows.Count > 0) { var follows = currentDoc.DocRecordFollows.OrderBy(x => x.FollowDate); foreach (var follow in follows) { DocFollowsReport row = new DocFollowsReport(); row.DocId = currentDoc.Id; row.DocDate = currentDoc.DocDate; row.Destination = currentDoc.Destination.Description; row.Subject = currentDoc.Subject; row.DocStatus = currentDoc.DocStatus; row.FollowDate = follow.FollowDate; row.FollowContent = follow.FollowContent; source.Add(row); } } else { DocFollowsReport header = new DocFollowsReport(); header.DocId = currentDoc.Id; header.DocDate = currentDoc.DocDate; header.Destination = currentDoc.Destination.Description; header.Subject = currentDoc.Subject; header.DocStatus = currentDoc.DocStatus; source.Add(header); } ExcelProperties excelProp = new ExcelProperties(2, 1, false); DocRecordFollowPrintReport report = new DocRecordFollowPrintReport(source, path, excelProp); report.Print(); } } catch (Exception ex) { Helper.LogShowError(ex); } }
public ActionResult Edit([Bind(Include = "Id")] DocRecord docRecord) { if (ModelState.IsValid) { db.Entry(docRecord).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(docRecord)); }
private void ShowDocRecord(DocRecord docRecord) { DocId = docRecord.Id; RefId = docRecord.RefId; DocDate = docRecord.DocDate; Subject = docRecord.Subject; var sortedFollows = docRecord.DocRecordFollows.OrderBy(x => x.FollowDate); DocFollows = new ObservableCollection <DocRecordFollow>(sortedFollows); }
void ShowDocRecord(DocRecord docRecord) { Id = docRecord.Id; RefId = docRecord.RefId; DocDate = docRecord.DocDate; Subject = docRecord.Subject; Destination = docRecord.Destination; DocPath = docRecord.DocPath; SelectedDocStatus = DocStatuses.SingleOrDefault(x => x.Key == docRecord.DocStatus); }
public ActionResult Create([Bind(Include = "Id")] DocRecord docRecord) { if (ModelState.IsValid) { db.DocRecordSet.Add(docRecord); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(docRecord)); }
void UpdateDocRecord(DocRecord docRecord) { docRecord.Id = Id; docRecord.RefId = RefId; docRecord.DocDate = DocDate; docRecord.Subject = Subject; docRecord.DestId = Destination.Id; docRecord.DocPath = DocPath; docRecord.DocStatus = SelectedDocStatus.Key; docRecord.SecurityLevel = 0; }
// GET: DocRecords/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DocRecord docRecord = db.DocRecordSet.Find(id); if (docRecord == null) { return(HttpNotFound()); } return(View(docRecord)); }
DocRecord CreateNewDocRecord() { DocRecord docRecord = new DocRecord(); docRecord.Id = Id; docRecord.RefId = RefId; docRecord.DocDate = DocDate; docRecord.Subject = Subject; docRecord.DestId = Destination.Id; docRecord.DocPath = DocPath; docRecord.DocStatus = SelectedDocStatus.Key; docRecord.SecurityLevel = 0; return(docRecord); }
public ActionResult DeleteRecord(int patientId, int id) { Patient patient = db.PatientSet.Find(patientId); DocRecord record = db.DocRecordSet.Find(id); if (ModelState.IsValid) { db.DocRecordSet.Remove(record); db.SaveChanges(); return(RedirectToAction("Edit", patient)); } return(View(patient)); }
protected override void Search() { if (string.IsNullOrEmpty(IdSearchTerm) && string.IsNullOrEmpty(RefSearchTerm)) { return; } var criteria = BuildCriteria(); DocRecord resultDoc = Find(criteria); if (resultDoc != null) { ShowDocRecord(resultDoc); ControlState(ControllerStates.Saved); } }
public ActionResult AddRecord(int patientId, int doctorId, [Bind(Include = "Id, Diagnos, RecordDate")] DocRecord record) { Patient patient = db.PatientSet.Find(patientId); Doctor doctor = db.DoctorSet.Find(doctorId); record.Doctor = doctor; if (ModelState.IsValid) { patient.MedCard.DocRecord.Add(record); db.Entry(patient).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Edit", patient)); } return(View()); }
public ActionResult AddRecord(int patientId, int doctorId, string Diagnos) { ApplicationUserManager userManager = HttpContext.GetOwinContext() .GetUserManager <ApplicationUserManager>(); var user = userManager.FindById(User.Identity.GetUserId()); Doctor doctor = db.DoctorSet.Find(user.PersonId); Patient patient = db.PatientSet.Find(patientId); DocRecord record = new DocRecord(); record.Diagnos = Diagnos; record.RecordDate = DateTime.Today; record.Doctor = doctor; record.MedCard = patient.MedCard; patient.MedCard.DocRecord.Add(record); db.SaveChanges(); return(View("Index")); }
protected override void Search() { if (string.IsNullOrEmpty(IdSearchTerm) && string.IsNullOrEmpty(RefSearchTerm)) { return; } var criteria = BuildCriteria(); DocRecord resultDoc = null; using (IUnitOfWork unit = new UnitOfWork()) { var result = unit.DocRecords.Query(criteria); resultDoc = result.FirstOrDefault(); } if (resultDoc != null) { ShowDocRecord(resultDoc); ControlState(ControllerStates.Saved); } }
protected override void Save() { if (!IsValid()) { string msg = string.Empty; foreach (var error in Errors) { msg += error.Value?.FirstOrDefault() ?? ""; msg += "\n"; } Helper.ShowMessage(msg); return; } try { using (IUnitOfWork unit = new UnitOfWork()) { DocRecord record = unit.DocRecords.GetById(Id); if (record == null) { record = CreateNewDocRecord(); unit.DocRecords.Add(record); } else { UpdateDocRecord(record); } unit.Save(); ControlState(ControllerStates.Saved); } } catch (Exception ex) { Helper.LogShowError(ex); } }