public ActionResult ShowPdfFile(long?d) { Documentm doc = null; long DocNum = 0; if (d != null) { DocNum = (long)d; } Patientm patm; if (Session["Patient"] == null) { return(RedirectToAction("Login")); } else { patm = (Patientm)Session["Patient"]; } if (DocNum != 0) { doc = Documentms.GetOne(patm.CustomerNum, DocNum); } if (doc == null || patm.PatNum != doc.PatNum) //make sure that the patient does not pass the another DocNum of another patient. { return(new EmptyResult()); //return a blank page todo: return page with proper message. } ContentDisposition cd = new ContentDisposition(); cd.Inline = true; //the browser will try and show the pdf inline i.e inside the browser window. If set to false it will force a download. Response.AppendHeader("Content-Disposition", cd.ToString()); return(File(Convert.FromBase64String(doc.RawBase64), "application/pdf", "Statement.pdf")); }
///<summary>Converts one Document object to its mobile equivalent. Warning! CustomerNum will always be 0.</summary> internal static Documentm ConvertToM(Document document) { Documentm documentm = new Documentm(); //CustomerNum cannot be set. Remains 0. documentm.DocNum = document.DocNum; documentm.PatNum = document.PatNum; documentm.RawBase64 = document.RawBase64; return(documentm); }
///<summary>Updates one Documentm in the database.</summary> internal static void Update(Documentm documentm){ string command="UPDATE documentm SET " +"PatNum = "+POut.Long (documentm.PatNum)+", " +"RawBase64 = "+DbHelper.ParamChar+"paramRawBase64 " +"WHERE CustomerNum = "+POut.Long(documentm.CustomerNum)+" AND DocNum = "+POut.Long(documentm.DocNum); if(documentm.RawBase64==null) { documentm.RawBase64=""; } OdSqlParameter paramRawBase64=new OdSqlParameter("paramRawBase64",OdDbType.Text,documentm.RawBase64); Db.NonQ(command,paramRawBase64); }
///<summary>Converts a DataTable to a list of objects.</summary> internal static List<Documentm> TableToList(DataTable table){ List<Documentm> retVal=new List<Documentm>(); Documentm documentm; for(int i=0;i<table.Rows.Count;i++) { documentm=new Documentm(); documentm.CustomerNum= PIn.Long (table.Rows[i]["CustomerNum"].ToString()); documentm.DocNum = PIn.Long (table.Rows[i]["DocNum"].ToString()); documentm.PatNum = PIn.Long (table.Rows[i]["PatNum"].ToString()); documentm.RawBase64 = PIn.String(table.Rows[i]["RawBase64"].ToString()); retVal.Add(documentm); } return retVal; }
///<summary>Updates one Documentm in the database.</summary> internal static void Update(Documentm documentm) { string command = "UPDATE documentm SET " + "PatNum = " + POut.Long(documentm.PatNum) + ", " + "RawBase64 = " + DbHelper.ParamChar + "paramRawBase64 " + "WHERE CustomerNum = " + POut.Long(documentm.CustomerNum) + " AND DocNum = " + POut.Long(documentm.DocNum); if (documentm.RawBase64 == null) { documentm.RawBase64 = ""; } OdSqlParameter paramRawBase64 = new OdSqlParameter("paramRawBase64", OdDbType.Text, documentm.RawBase64); Db.NonQ(command, paramRawBase64); }
///<summary>Converts a DataTable to a list of objects.</summary> internal static List <Documentm> TableToList(DataTable table) { List <Documentm> retVal = new List <Documentm>(); Documentm documentm; for (int i = 0; i < table.Rows.Count; i++) { documentm = new Documentm(); documentm.CustomerNum = PIn.Long(table.Rows[i]["CustomerNum"].ToString()); documentm.DocNum = PIn.Long(table.Rows[i]["DocNum"].ToString()); documentm.PatNum = PIn.Long(table.Rows[i]["PatNum"].ToString()); documentm.RawBase64 = PIn.String(table.Rows[i]["RawBase64"].ToString()); retVal.Add(documentm); } return(retVal); }
///<summary>Usually set useExistingPK=true. Inserts one Documentm into the database.</summary> internal static long Insert(Documentm documentm,bool useExistingPK){ if(!useExistingPK) { documentm.DocNum=ReplicationServers.GetKey("documentm","DocNum"); } string command="INSERT INTO documentm ("; command+="DocNum,"; command+="CustomerNum,PatNum,RawBase64) VALUES("; command+=POut.Long(documentm.DocNum)+","; command+= POut.Long (documentm.CustomerNum)+"," + POut.Long (documentm.PatNum)+"," +DbHelper.ParamChar+"paramRawBase64)"; if(documentm.RawBase64==null) { documentm.RawBase64=""; } OdSqlParameter paramRawBase64=new OdSqlParameter("paramRawBase64",OdDbType.Text,documentm.RawBase64); Db.NonQ(command,paramRawBase64);//There is no autoincrement in the mobile server. return documentm.DocNum; }
///<summary>Usually set useExistingPK=true. Inserts one Documentm into the database.</summary> internal static long Insert(Documentm documentm, bool useExistingPK) { if (!useExistingPK) { documentm.DocNum = ReplicationServers.GetKey("documentm", "DocNum"); } string command = "INSERT INTO documentm ("; command += "DocNum,"; command += "CustomerNum,PatNum,RawBase64) VALUES("; command += POut.Long(documentm.DocNum) + ","; command += POut.Long(documentm.CustomerNum) + "," + POut.Long(documentm.PatNum) + "," + DbHelper.ParamChar + "paramRawBase64)"; if (documentm.RawBase64 == null) { documentm.RawBase64 = ""; } OdSqlParameter paramRawBase64 = new OdSqlParameter("paramRawBase64", OdDbType.Text, documentm.RawBase64); Db.NonQ(command, paramRawBase64); //There is no autoincrement in the mobile server. return(documentm.DocNum); }
///<summary>Converts one Document object to its mobile equivalent. Warning! CustomerNum will always be 0.</summary> internal static Documentm ConvertToM(Document document){ Documentm documentm=new Documentm(); //CustomerNum cannot be set. Remains 0. documentm.DocNum =document.DocNum; documentm.PatNum =document.PatNum; documentm.RawBase64 =document.RawBase64; return documentm; }