protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } HtmlGenericControl lblServiceArea = (HtmlGenericControl)FindPatient.FindControl("lblServiceArea"); lblServiceArea.InnerText = Request.QueryString["srvNm"]; if (Convert.ToInt32(Session["Paperless"]) != 1)//waiting list is available only in paperless mode { btnWaitingList.Visible = false; } Session["HIVPatientStatus"] = 0; Session["PMTCTPatientStatus"] = 0; //SetEnrollmentCombo(); Session["PatientId"] = 0; SessionManager.PatientId = 0; Session["TechnicalAreaName"] = Request.QueryString["srvNm"]; Session["TechnicalAreaId"] = Request.QueryString["mod"]; base.Session["TechIdentifier"] = null; string urlParam = string.Format("../Queue/WaitingListView.aspx?srvNM={0}&mod={1}", Request.QueryString["srvNm"], Request.QueryString["mod"]); btnWaitingList.OnClientClick = string.Format("javascript:window.location='{0}'; return false;", urlParam); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HtmlGenericControl lblServiceArea = (HtmlGenericControl)FindPatient.FindControl("lblServiceArea"); lblServiceArea.InnerText = "Ward Admission"; if (!this.CanAdmit) { Response.Redirect("~/Admission/frmAdmissionHome.aspx", true); Response.End(); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["AppLocation"] == null || Session.Count == 0 || Session["AppUserID"].ToString() == "") { IQCareMsgBox.Show("SessionExpired", this); Response.Redirect("~/frmlogin.aspx", true); } if (IsPostBack) { return; } HtmlGenericControl lblServiceArea = (HtmlGenericControl)FindPatient.FindControl("lblServiceArea"); lblServiceArea.InnerText = Request.QueryString["srvNm"]; Session["HIVPatientStatus"] = 0; Session["PMTCTPatientStatus"] = 0; //SetEnrollmentCombo(); Session["PatientId"] = 0; Session["TechnicalAreaName"] = Request.QueryString["srvNm"]; Session["TechnicalAreaId"] = Request.QueryString["mod"]; }
protected void Page_Load(object sender, EventArgs e) { if (Session["AppLocation"] == null || Session.Count == 0 || Session["AppUserID"].ToString() == "") { IQCareMsgBox.Show("SessionExpired", this); Response.Redirect("~/frmlogin.aspx", true); } if (IsPostBack) { return; } try { HtmlGenericControl lblServiceArea = (HtmlGenericControl)FindPatient.FindControl("lblServiceArea"); lblServiceArea.InnerText = Request.QueryString["srvNm"]; if (Convert.ToInt32(Session["Paperless"]) != 1)//waiting list is available only in paperless mode { btnWaitingList.Visible = false; } Session["HIVPatientStatus"] = 0; Session["PMTCTPatientStatus"] = 0; //SetEnrollmentCombo(); Session["PatientId"] = 0; Session["TechnicalAreaName"] = Request.QueryString["srvNm"]; Session["TechnicalAreaId"] = Request.QueryString["mod"]; string urlParam = String.Format("openWaitingList('./frmWaitingList.aspx?mod={0}');return false;", Session["TechnicalAreaId"]); btnWaitingList.OnClientClick = urlParam; if (Request.QueryString["srvNm"] == "Pharmacy Dispense") //&& Request.QueryString["mod"] == "206" { ((Button)FindPatient.FindControl("btnAdd")).Enabled = false; (FindPatient.FindControl("ddCareEndedStatus") as DropDownList).Visible = false; (FindPatient.FindControl("lblCareendedstatus") as HtmlGenericControl).Visible = false; (Master.FindControl("levelTwoNavigationUserControl1").FindControl("UserControl_Alerts1") as UserControl).Visible = false; (Master.FindControl("levelTwoNavigationUserControl1").FindControl("PanelPatiInfo") as Panel).Visible = false; //(Master.FindControl("patientBanner") as Control).Visible = false; (Master.FindControl("level2Navigation") as Control).Visible = false; //(Master.FindControl("imageFlipLevel2") as Control).Visible = false; } } catch (Exception ex) { CLogger.WriteLog(ELogLevel.ERROR, ex.ToString()); if (Session["PatientId"] == null || Convert.ToInt32(Session["PatientId"]) != 0) { IQCareMsgBox.NotifyAction("Application has an issue, Please contact Administrator!", "Application Error", true, this, "window.location.href='../frmFindAddCustom.aspx?srvNm=" + Session["TechnicalAreaName"] + "&mod=0'"); //Response.Write("<script>alert('Application has an issue, Please contact Administrator!') ; window.location.href='../frmFindAddCustom.aspx?srvNm=" + Session["TechnicalAreaName"] + "&mod=0'</script>"); } else { if (Session["TechnicalAreaId"] != null || Convert.ToInt16(Session["TechnicalAreaId"]) != 0) { IQCareMsgBox.NotifyAction("Application has an issue, Please contact Administrator!", "Application Error", true, this, "window.location.href='../frmFacilityHome.aspx';"); //Response.Write("<script>alert('Application has an issue, Please contact Administrator!') ; window.location.href='../frmFacilityHome.aspx'</script>"); } else { IQCareMsgBox.NotifyAction("Application has an issue, Please contact Administrator!", "Application Error", true, this, "window.location.href='../frmLogin.aspx';"); //Response.Write("<script>alert('Application has an issue, Please contact Administrator!') ; window.location.href='../frmLogin.aspx'</script>"); } } ex = null; } }
public JsonResult UploadFile(IFormFile attachFile) { ReturnMessage returnMessage = new ReturnMessage(); FindPatient fnPatient = new FindPatient(); if (attachFile == null) { fnPatient.RetCode = 0; fnPatient.RetMessage = "Please select one file!"; return(Json(fnPatient)); } try { List <FtpServer> lstFtpServer = new FtpServerDao().GetAllFtpServerList().ToList(); if (lstFtpServer == null || lstFtpServer.Count < 1) { fnPatient.RetCode = 0; fnPatient.RetMessage = "Can not connect FTP Server!"; return(Json(fnPatient)); } string serverAddress = lstFtpServer[0].ServerAddress; string userName = lstFtpServer[0].UserName; string password = lstFtpServer[0].Password; var ftpRequest = (FtpWebRequest)FtpWebRequest.Create(serverAddress + "FTPTEST.txt"); ftpRequest.Credentials = new NetworkCredential(userName, password); ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile; var ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); var ftpStream = ftpResponse.GetResponseStream(); Attachments attachment = new Attachments(); attachment.FileCode = ""; attachment.FileName = attachFile.FileName; int dotIndex = attachFile.FileName.LastIndexOf('.'); attachment.FileType = attachFile.FileName.Substring(dotIndex + 1); //User user = (User)Session["AppUser"]; attachment.AttachedBy = 1; //List<Attachments> lstAttachments = (List<Attachments>)Session["lstAttachments"]; List <Attachments> lstAttachments = new List <Attachments>(); returnMessage = new AttachmentDao().Create(attachment); if (returnMessage.RetCode > 0) { var attachFileName = returnMessage.RetMessage + "." + attachment.FileType; //var reader = new StreamReader(); Stream streamObj = attachFile.OpenReadStream(); byte[] buffer = new byte[attachFile.Length]; streamObj.Read(buffer, 0, buffer.Length); streamObj.Close(); streamObj = null; string ftpurl = String.Format("{0}/{1}", serverAddress, attachFileName); var requestObj = FtpWebRequest.Create(ftpurl) as FtpWebRequest; requestObj.Method = WebRequestMethods.Ftp.UploadFile; requestObj.Credentials = new NetworkCredential(userName, password); var requestStream = requestObj.GetRequestStream(); requestStream.Write(buffer, 0, buffer.Length); requestStream.Flush(); requestStream.Close(); requestObj = null; attachment.Id = returnMessage.RetCode; attachment.FileCode = returnMessage.RetMessage; fnPatient.RetCode = 1; lstAttachments.Add(attachment); } HttpContext.Session.SetObjectAsJson("lstAttachments", lstAttachments); fnPatient.AttachmentsList = lstAttachments; return(Json(fnPatient)); } catch (Exception ex) { fnPatient.RetCode = 0; fnPatient.RetMessage = "Error in file attachment"; return(Json(fnPatient)); } }
public async Task <JsonResult> ImportExcel(IFormFile files) { FindPatient fnPatient = new FindPatient(); try { string folderName = "wwwroot/ExcleUpload/"; if (files.Length == 0) { fnPatient.RetCode = 0; fnPatient.RetMessage = "Please select an excel file!"; return(Json(fnPatient)); } else { string fileName = ContentDispositionHeaderValue.Parse(files.ContentDisposition).FileName.Trim('"'); string name = Path.GetFileNameWithoutExtension(fileName); string fileExt = Path.GetExtension(fileName); string fullPath = Path.Combine(folderName, fileName); if (fileExt != ".xls" && fileExt != ".xlsx") { fnPatient.RetCode = 0; fnPatient.RetMessage = "Error in excel file importing!"; return(Json(fnPatient)); } if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } using (var stream = new FileStream(fullPath, FileMode.Create)) { files.CopyTo(stream); } FileInfo fi = new FileInfo(fullPath); using (ExcelPackage excelPackage = new ExcelPackage(fi)) { ExcelWorksheets wkb = excelPackage.Workbook.Worksheets; ExcelWorksheet wks = wkb["Sheet1"]; List <Patient> lstPatient = new List <Patient>(); for (int i = wks.Dimension.Start.Row; i <= wks.Dimension.End.Row; i++) { Patient patient = new Patient(); patient.PatientCode = (wks.Cells[i, 1]).Text; patient.PatientName = (wks.Cells[i, 2]).Text; patient.GenderName = (wks.Cells[i, 3]).Text; patient.Address = (wks.Cells[i, 4]).Text; lstPatient.Add(patient); } ViewBag.PatientList = lstPatient; HttpContext.Session.SetObjectAsJson("patient", lstPatient); System.IO.File.Delete(fullPath); fnPatient.RetCode = 1; fnPatient.RetMessage = "Success import an excel file!"; fnPatient.PatientList = lstPatient; //string sJSONResponse = JsonConvert.SerializeObject(fnPatient); return(Json(fnPatient)); } } } catch (Exception ex) { fnPatient.RetCode = 0; fnPatient.RetMessage = ex.Message; return(Json(new { fnPatient })); } }