コード例 #1
0
ファイル: KKPController.cs プロジェクト: koecrit/SKD_Pinere
        public ActionResult Submit(PinereDataModel Model)
        {
            string errorMessage  = string.Empty;
            string UserName      = User.Identity.Name;
            string PasienId      = string.Empty;
            string DataAirlineId = Model.Pasien.DataAirlineId;

            try
            {
                var dc = new PinereDataContext(PinereConstant.PinereConnectionString);
                try
                {
                    dc.Connection.Open();
                    dc.Transaction           = dc.Connection.BeginTransaction();
                    dc.ObjectTrackingEnabled = true;

                    DataRepository.SavePasien(dc, UserName, int.Parse(Model.Pasien.DataAirlineId), Model.Pasien, out PasienId);
                    DataRepository.SaveDataKKP(dc, UserName, Model.KKP, int.Parse(PasienId));
                    DataRepository.UpdateKKPFlag(dc, int.Parse(DataAirlineId));
                    dc.Transaction.Commit();
                }
                catch (Exception e)

                {
                    dc.Transaction.Rollback();
                    throw new Exception(e.Message);
                }
                if (Model.KKP.RujukRS == "1" && (Model.KKP.HasilDiagnosa == "01EBL" || Model.KKP.HasilDiagnosa == "02MRS"))
                {
                    string email = string.Empty;
                    using (var dca = new PinereDataContext(PinereConstant.PinereConnectionString))
                    {
                        var resp = dca.GetEmailByNameAndResp(User.Identity.Name, Model.KKP.IdRS, "rs").SingleOrDefault();
                        if (resp != null)
                        {
                            email = resp.Email;
                        }
                    }
                    if (!email.IsNullOrEmpty())
                    {
                        SendEmail.SendMail(email, "[Pinere] Data Pasien Baru", "Ini adalah system notifikasi dari PINERE System.<br> Silahkan login dan buka di PINERE System.<br><br> Terimakasih<br>PinereSystem.");
                    }
                }
            }
            catch (Exception e)
            {
                return((ActionResult)this.RedirectToAction("Error", "Information", new { @Message = e.Message }));
            }
            return((ActionResult)this.RedirectToAction("SubmitKKP", "Information", new { @MainId = DataAirlineId }));
        }
コード例 #2
0
ファイル: KKPController.cs プロジェクト: koecrit/SKD_Pinere
        public ActionResult SubmitNew(PinereDataModel Model)
        {
            string errorMessage   = string.Empty;
            string UserName       = User.Identity.Name;
            string PasienId       = string.Empty;
            string DataAirlineId  = string.Empty;
            string AttachmentPath = string.Empty;
            string AttachmentDir  = string.Empty;
            string FileName       = string.Empty;

            try
            {
                var dc = new PinereDataContext(PinereConstant.PinereConnectionString);
                try
                {
                    dc.Connection.Open();
                    dc.Transaction           = dc.Connection.BeginTransaction();
                    dc.ObjectTrackingEnabled = true;

                    DataRepository.SaveDataAirline(dc, UserName, Model.DataAirline, out DataAirlineId);
                    DataRepository.SavePasien(dc, UserName, int.Parse(DataAirlineId), Model.Pasien, out PasienId);
                    DataRepository.SaveDataKKP(dc, UserName, Model.KKP, int.Parse(PasienId));
                    DataRepository.UpdateKKPFlag(dc, int.Parse(DataAirlineId));

                    dc.Transaction.Commit();

                    AttachmentPath = string.Format("{0}/{1}", PinereConstant.AttachmentUrl, DataAirlineId);
                    AttachmentDir  = Server.MapPath(AttachmentPath);
                    if (!Directory.Exists(AttachmentDir))
                    {
                        Directory.CreateDirectory(AttachmentDir);
                    }
                    foreach (string file in Request.Files)
                    {
                        HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase;
                        if (hpf.ContentLength == 0)
                        {
                            continue;
                        }
                        FileName      = Path.GetFileName(hpf.FileName);
                        AttachmentDir = AttachmentDir + "\\" + FileName;
                        hpf.SaveAs(AttachmentDir);
                    }
                }
                catch (Exception e)
                {
                    dc.Transaction.Rollback();
                    throw new Exception(e.Message);
                }
                if (Model.KKP.RujukRS == "1" && (Model.KKP.HasilDiagnosa == "01EBL" || Model.KKP.HasilDiagnosa == "02MRS"))
                {
                    string email = string.Empty;
                    using (var dca = new PinereDataContext(PinereConstant.PinereConnectionString))
                    {
                        var resp = dca.GetEmailByNameAndResp(User.Identity.Name, Model.KKP.IdRS, "rs").SingleOrDefault();
                        if (resp != null)
                        {
                            email = resp.Email;
                        }
                    }
                    if (!email.IsNullOrEmpty())
                    {
                        SendEmail.SendMail(email, "[Pinere] Data Pasien Baru", "Ini adalah system notifikasi dari PINERE System.<br> Silahkan login dan buka di PINERE System.<br><br> Terimakasih<br>PinereSystem.");
                    }
                }
            }
            catch (Exception e)
            {
                return((ActionResult)this.RedirectToAction("Error", "Information", new { @Message = e.Message }));
            }
            return((ActionResult)this.RedirectToAction("SubmitKKP", "Information", new { @MainId = DataAirlineId }));
        }