public ActionResult DeleteConfirmed(int id)
        {
            DocRecord docRecord = db.DocRecordSet.Find(id);

            db.DocRecordSet.Remove(docRecord);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
        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));
 }
예제 #4
0
        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);
        }
예제 #5
0
 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));
        }
예제 #7
0
 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));
        }
예제 #9
0
        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);
        }
예제 #10
0
        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));
        }
예제 #11
0
        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);
            }
        }
예제 #12
0
        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"));
        }
예제 #14
0
        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);
            }
        }
예제 #15
0
 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);
     }
 }