///<summary>Converts parameters into sheetfield objects, and then saves those objects in the database. The parameters will never again enjoy full parameter status, but will just be read-only fields from here on out. It ignores PatNum parameters, since those are already part of the sheet itself.</summary> public static void SaveParameters(Sheet sheet) { //No need to check RemotingRole; no call to db List <SheetField> listFields = new List <SheetField>(); for (int i = 0; i < sheet.Parameters.Count; i++) { if (sheet.Parameters[i].ParamName.In("PatNum", //These types are not primitives so they cannot be saved to the database. "CompletedProcs", "toothChartImg")) { continue; } SheetField field = new SheetField(); field.IsNew = true; field.SheetNum = sheet.SheetNum; field.FieldType = SheetFieldType.Parameter; field.FieldName = sheet.Parameters[i].ParamName; field.FieldValue = sheet.Parameters[i].ParamValue.ToString(); //the object will be an int. Stored as a string. field.FontSize = 0; field.FontName = ""; field.FontIsBold = false; field.XPos = 0; field.YPos = 0; field.Width = 0; field.Height = 0; field.GrowthBehavior = GrowthBehaviorEnum.None; field.RadioButtonValue = ""; listFields.Add(field); } SheetFields.InsertMany(listFields); }
///<Summary>Supply the field that we are testing. All other fields which intersect with it will be moved down. Each time one (or maybe some) is moved down, this method is called recursively. The end result should be no intersections among fields near the original field that grew.</Summary> public static void MoveAllDownWhichIntersect(Sheet sheet,SheetField field,int amountOfGrowth) { //Phase 1 is to move everything that intersects with the field down. Phase 2 is to call this method on everything that was moved. //Phase 1: Move List<SheetField> affectedFields=new List<SheetField>(); foreach(SheetField field2 in sheet.SheetFields) { if(field2==field){ continue; } if(field2.YPos<field.YPos){//only fields which are below this one continue; } if(field2.FieldType==SheetFieldType.Drawing){ continue; //drawings do not get moved down. } if(field.Bounds.IntersectsWith(field2.Bounds)) { field2.YPos+=amountOfGrowth; affectedFields.Add(field2); } } //Phase 2: Recursion foreach(SheetField field2 in affectedFields) { //reuse the same amountOfGrowth again. MoveAllDownWhichIntersect(sheet,field2,amountOfGrowth); } }
///<summary></summary> public static long Insert(SheetField sheetField) { if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { sheetField.SheetFieldNum=Meth.GetLong(MethodBase.GetCurrentMethod(),sheetField); return sheetField.SheetFieldNum; } return Crud.SheetFieldCrud.Insert(sheetField); }
///<summary></summary> public static void Update(SheetField sheetField) { if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(),sheetField); return; } Crud.SheetFieldCrud.Update(sheetField); }
public static void MoveAllDownBelowThis(Sheet sheet,SheetField field,int amountOfGrowth){ foreach(SheetField field2 in sheet.SheetFields) { if(field2.YPos>field.YPos) {//for all fields that are below this one field2.YPos+=amountOfGrowth;//bump down by amount that this one grew } } }
///<summary>Converts parameters into sheetfield objects, and then saves those objects in the database. The parameters will never again enjoy full parameter status, but will just be read-only fields from here on out. It ignores PatNum parameters, since those are already part of the sheet itself.</summary> public static void SaveParameters(Sheet sheet) { //No need to check RemotingRole; no call to db SheetField field; for (int i = 0; i < sheet.Parameters.Count; i++) { if (sheet.Parameters[i].ParamName == "PatNum") { continue; } field = new SheetField(); field.IsNew = true; field.SheetNum = sheet.SheetNum; field.FieldType = SheetFieldType.Parameter; field.FieldName = sheet.Parameters[i].ParamName; field.FieldValue = sheet.Parameters[i].ParamValue.ToString(); //the object will be an int. Stored as a string. field.FontSize = 0; field.FontName = ""; field.FontIsBold = false; field.XPos = 0; field.YPos = 0; field.Width = 0; field.Height = 0; field.GrowthBehavior = GrowthBehaviorEnum.None; field.RadioButtonValue = ""; SheetFields.Insert(field); } }
///<Summary>This is normally done in FormSheetFillEdit, but if we bypass that window for some reason, we can also save a new sheet here. Signature ///fields are inserted as they are, so they must be keyed to the field values already. Saves the sheet and sheetfields exactly as they are. Used by ///webforms, for example, when a sheet is retrieved from the web server and the sheet signatures have already been keyed to the field values and ///need to be inserted as-is into the user's db.</Summary> public static void SaveNewSheet(Sheet sheet) { //This remoting role check is technically unnecessary but it significantly speeds up the retrieval process for Middle Tier users due to looping. if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), sheet); return; } if (!sheet.IsNew) { throw new ApplicationException("Only new sheets allowed"); } Insert(sheet); //insert 'blank' sheetfields to get sheetfieldnums assigned, then use ordered sheetfieldnums with actual field data to update 'blank' db fields List <long> listSheetFieldNums = sheet.SheetFields.Select(x => SheetFields.Insert(new SheetField() { SheetNum = sheet.SheetNum })) .OrderBy(x => x)//PKs of all sheet fields that were just inserted. Signatures require sheet fields be ordered by PK. .ToList(); if (listSheetFieldNums.Count != sheet.SheetFields.Count) //shouldn't be possible, just in case { Delete(sheet.SheetNum); //any blank inserted sheetfields will be linked to the sheet marked deleted throw new ApplicationException("Incorrect sheetfield count."); } //now that we have an ordered list of sheetfieldnums, update db blank fields with all field data from field in memory for (int i = 0; i < sheet.SheetFields.Count; i++) { SheetField fld = sheet.SheetFields[i]; fld.SheetFieldNum = listSheetFieldNums[i]; fld.SheetNum = sheet.SheetNum; SheetFields.Update(fld); } }
///<summary>Sorts fields in the order that they shoudl be drawn on top of eachother. First Images, then Drawings, Lines, Rectangles, Text, Check Boxes, and SigBoxes. In that order.</summary> public static int SortDrawingOrderLayers(SheetField f1, SheetField f2) { if (FieldTypeSortOrder(f1.FieldType) != FieldTypeSortOrder(f2.FieldType)) { return(FieldTypeSortOrder(f1.FieldType).CompareTo(FieldTypeSortOrder(f2.FieldType))); } return(f1.YPos.CompareTo(f2.YPos)); //return f1.SheetFieldNum.CompareTo(f2.SheetFieldNum); }
///<summary></summary> public static void Update(SheetField sheetField) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), sheetField); return; } Crud.SheetFieldCrud.Update(sheetField); }
///<summary></summary> public static long Insert(SheetField sheetField) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { sheetField.SheetFieldNum = Meth.GetLong(MethodBase.GetCurrentMethod(), sheetField); return(sheetField.SheetFieldNum); } return(Crud.SheetFieldCrud.Insert(sheetField)); }
///<summary>Draws the image to the graphics object passed in. Can throw an OutOfMemoryException when printing that will have a message that should be displayed and the print job should be cancelled.</summary> public static void drawFieldImage(SheetField field,Graphics g, XGraphics gx) { Bitmap bmpOriginal=null; string filePathAndName=""; #region Get the path for the image switch(field.FieldType) { case SheetFieldType.Image: filePathAndName=ODFileUtils.CombinePaths(SheetUtil.GetImagePath(),field.FieldName); break; case SheetFieldType.PatImage: if(field.FieldValue=="") { //There is no document object to use for display, but there may be a baked in image and that situation is dealt with below. filePathAndName=""; break; } Document patDoc=Documents.GetByNum(PIn.Long(field.FieldValue)); List<string> paths=Documents.GetPaths(new List<long> { patDoc.DocNum },ImageStore.GetPreferredAtoZpath()); if(paths.Count < 1) {//No path was found so we cannot draw the image. return; } filePathAndName=paths[0]; break; default: //not an image field return; } #endregion #region Load the image into bmpOriginal if(field.FieldName=="Patient Info.gif") { bmpOriginal=OpenDentBusiness.Properties.Resources.Patient_Info; } else if(File.Exists(filePathAndName)) { bmpOriginal=new Bitmap(filePathAndName); } else { return; } #endregion #region Calculate the image ratio and location, set values for imgDrawWidth and imgDrawHeight //inscribe image in field while maintaining aspect ratio. float imgRatio=(float)bmpOriginal.Width/(float)bmpOriginal.Height; float fieldRatio=(float)field.Width/(float)field.Height; float imgDrawHeight=field.Height;//drawn size of image float imgDrawWidth=field.Width;//drawn size of image int adjustY=0;//added to YPos int adjustX=0;//added to XPos //For patient images, we need to make sure the images will fit and can maintain aspect ratio. if(field.FieldType==SheetFieldType.PatImage && imgRatio>fieldRatio) {//image is too wide //X pos and width of field remain unchanged //Y pos and height must change imgDrawHeight=(float)bmpOriginal.Height*((float)field.Width/(float)bmpOriginal.Width);//img.Height*(width based scale) This also handles images that are too small. adjustY=(int)((field.Height-imgDrawHeight)/2f);//adjustY= half of the unused vertical field space } else if(field.FieldType==SheetFieldType.PatImage && imgRatio<fieldRatio) {//image is too tall //X pos and width must change //Y pos and height remain unchanged imgDrawWidth=(float)bmpOriginal.Width*((float)field.Height/(float)bmpOriginal.Height);//img.Height*(width based scale) This also handles images that are too small. adjustX=(int)((field.Width-imgDrawWidth)/2f);//adjustY= half of the unused horizontal field space } else {//image ratio == field ratio //do nothing } #endregion GC.Collect(); //We used to scale down bmpOriginal here to avoid memory exceptions. //Doing so was causing significant quality loss when printing or creating pdfs with very large images. if(gx==null) { try { //Always use the original BMP so that very large images can be scaled by the graphics class thus keeping a high quality image by using interpolation. g.DrawImage(bmpOriginal, new Rectangle(field.XPos+adjustX,field.YPos+adjustY-_yPosPrint,(int)imgDrawWidth,(int)imgDrawHeight), new Rectangle(0,0,bmpOriginal.Width,bmpOriginal.Height), GraphicsUnit.Pixel); } catch(OutOfMemoryException) { throw new OutOfMemoryException(Lan.g("Sheets","A static image on this sheet is too high in quality and cannot be printed.")+"\r\n" +Lan.g("Sheets","Try printing to a different printer or lower the quality of the static image")+":\r\n" +filePathAndName); } } else { MemoryStream ms=null; //For some reason PdfSharp's XImage cannot handle TIFF images. if(filePathAndName.ToLower().EndsWith(".tif") || filePathAndName.ToLower().EndsWith(".tiff")) { //Trick PdfSharp when we get a TIFF image into thinking it is a different image type. //Saving to BMP format will sometimes increase the file size dramatically. E.g. an 11MB JPG turned into a 240MB BMP. //Instead of using BMP, we will use JPG which should have little to no quality loss and should be more compressed than BMP. ms=new MemoryStream(); bmpOriginal.Save(ms,ImageFormat.Jpeg); bmpOriginal.Dispose(); bmpOriginal=new Bitmap(ms); } XImage xI=XImage.FromGdiPlusImage(bmpOriginal); gx.DrawImage(xI,p(field.XPos+adjustX),p(field.YPos-_yPosPrint+adjustY),p(imgDrawWidth),p(imgDrawHeight)); xI.Dispose(); xI=null; if(ms!=null) { ms.Dispose(); ms=null; } } if(bmpOriginal!=null) { bmpOriginal.Dispose(); bmpOriginal=null; } GC.Collect(); }
public static void drawFieldDrawing(SheetField field,Graphics g,XGraphics gx) { if(gx==null) { Pen pen=new Pen(Brushes.Black,2f); List<Point> points=new List<Point>(); string[] pairs=field.FieldValue.Split(new string[] { ";" },StringSplitOptions.RemoveEmptyEntries); foreach(string p in pairs) { points.Add(new Point(PIn.Int(p.Split(',')[0]),PIn.Int(p.Split(',')[1]))); } for(int i=1;i<points.Count;i++) { g.DrawLine(pen,points[i-1].X,points[i-1].Y-_yPosPrint,points[i].X,points[i].Y-_yPosPrint); } pen.Dispose(); pen=null; } else { XPen pen=new XPen(XColors.Black,p(2)); List<Point> points=new List<Point>(); string[] pairs=field.FieldValue.Split(new string[] { ";" },StringSplitOptions.RemoveEmptyEntries); foreach(string p2 in pairs) { points.Add(new Point(PIn.Int(p2.Split(',')[0]),PIn.Int(p2.Split(',')[1]))); } for(int i=1;i<points.Count;i++) { gx.DrawLine(pen,p(points[i-1].X),p(points[i-1].Y-_yPosPrint),p(points[i].X),p(points[i].Y-_yPosPrint)); } pen=null; } GC.Collect(); }
///<summary>Returns all checkboxes related to the inputMed passed in.</summary> private List<SheetField> GetRelatedMedicalCheckBoxes(List<SheetField> checkMedList,SheetField inputMed) { List<SheetField> checkBoxes=new List<SheetField>(); for(int i=0;i<checkMedList.Count;i++) { if(checkMedList[i].FieldName.Remove(0,8)==inputMed.FieldName.Remove(0,8)) { checkBoxes.Add(checkMedList[i]); } } return checkBoxes; }
public static void drawFieldGrid(SheetField field,Sheet sheet,Graphics g,XGraphics gx,Statement stmt=null,MedLab medLab=null) { _printMargin.Top=40; if(sheet.SheetType==SheetTypeEnum.MedLabResults) { _printMargin.Top=120; } UI.ODGrid odGrid=new UI.ODGrid();//Only used for measurements, also contains printing/drawing logic. odGrid.FontForSheets=new Font(field.FontName,field.FontSize,field.FontIsBold?FontStyle.Bold:FontStyle.Regular); int _yAdjCurRow=0;//used to adjust for Titles, Headers, Rows, and footers (all considered part of the same row). odGrid.Width=0; List<DisplayField> Columns=SheetUtil.GetGridColumnsAvailable(field.FieldName); foreach(DisplayField Col in Columns) { odGrid.Width+=Col.ColumnWidth; } odGrid.Height=field.Height; odGrid.HideScrollBars=true; odGrid.YPosField=field.YPos; odGrid.Title=field.FieldName; if(stmt!=null) { odGrid.Title+=(stmt.Intermingled?".Intermingled":".NotIntermingled");//Important for calculating heights. } odGrid.TopMargin=_printMargin.Top; odGrid.BottomMargin=_printMargin.Bottom; odGrid.PageHeight=sheet.HeightPage; DataTable Table=SheetUtil.GetDataTableForGridType(field.FieldName,stmt,medLab); #region Fill Grid, Set Text Alignment odGrid.BeginUpdate(); odGrid.Columns.Clear(); ODGridColumn col; for(int i=0;i<Columns.Count;i++) { col=new ODGridColumn(Columns[i].Description,Columns[i].ColumnWidth); switch(field.FieldName+"."+Columns[i].InternalName) {//Unusual switch statement to differentiate similar column names in different grids. case "StatementMain.charges": case "StatementMain.credits": case "StatementMain.balance": case "StatementPayPlan.charges": case "StatementPayPlan.credits": case "StatementPayPlan.balance": col.TextAlign=HorizontalAlignment.Right; break; case "StatementAging.Age00to30": case "StatementAging.Age31to60": case "StatementAging.Age61to90": case "StatementAging.Age90plus": case "StatementEnclosed.AmountDue": case "StatementEnclosed.DateDue": col.TextAlign=HorizontalAlignment.Center; break; default: col.TextAlign=HorizontalAlignment.Left; break; } odGrid.Columns.Add(col); } ODGridRow row; for(int i=0;i<Table.Rows.Count;i++) { row=new ODGridRow(); for(int c=0;c<Columns.Count;c++) {//Selectively fill columns from the dataTable into the odGrid. row.Cells.Add(Table.Rows[i][Columns[c].InternalName].ToString()); } if(Table.Columns.Contains("PatNum")) {//Used for statments to determine account splitting. row.Tag=Table.Rows[i]["PatNum"].ToString(); } odGrid.Rows.Add(row); } odGrid.EndUpdate(true);//Calls ComputeRows and ComputeColumns, meaning the RowHeights int[] has been filled. #endregion for(int i=0;i<odGrid.RowHeights.Length;i++) { if(_isPrinting && (odGrid.PrintRows[i].YPos-_printMargin.Top<_yPosPrint //rows at the end of previous page || odGrid.PrintRows[i].YPos-sheet.HeightPage+_printMargin.Bottom>_yPosPrint)) { continue;//continue because we do not want to draw rows from other pages. } _yAdjCurRow=0; //if(odGrid.PrintRows[i].YPos<_yPosPrint // || odGrid.PrintRows[i].YPos-_yPosPrint>sheet.HeightPage) { // continue;//skip rows on previous page and rows on next page. //} #region Draw Title if(odGrid.PrintRows[i].IsTitleRow) { switch(field.FieldName) {//Draw titles differently for different grids. case "StatementMain": Patient pat=Patients.GetPat(PIn.Long(Table.Rows[i]["PatNum"].ToString())); string patName=""; if(pat!=null) {//should always be true patName=pat.GetNameFLnoPref(); } if(gx==null) { g.FillRectangle(Brushes.White,field.XPos-10,odGrid.PrintRows[i].YPos-_yPosPrint,odGrid.Width,odGrid.TitleHeight); g.DrawString(patName,new Font("Arial",10,FontStyle.Bold),new SolidBrush(Color.Black),field.XPos-10,odGrid.PrintRows[i].YPos-_yPosPrint); } else { gx.DrawRectangle(Brushes.White,p(field.XPos-10),p(odGrid.PrintRows[i].YPos-_yPosPrint-1),p(odGrid.Width),p(odGrid.TitleHeight)); using(Font _font=new Font("Arial",10,FontStyle.Bold)) { GraphicsHelper.DrawStringX(gx,Graphics.FromImage(new Bitmap(100,100)),(double)((1d)/p(1)),patName,new XFont(_font.FontFamily.ToString(),_font.Size,XFontStyle.Bold),XBrushes.Black,new XRect(p(field.XPos-10),p(odGrid.PrintRows[i].YPos-_yPosPrint-1),p(300),p(100)),XStringAlignment.Near); //gx.DrawString(patName,new XFont(_font.FontFamily.ToString(),_font.Size,XFontStyle.Bold),new SolidBrush(Color.Black),field.XPos-10,yPosGrid); } } break; case "StatementPayPlan": SizeF sSize=new SizeF(); using(Graphics f= Graphics.FromImage(new Bitmap(100,100))) {//using graphics f because g is null when gx is not. sSize=f.MeasureString("Payment Plans",new Font("Arial",10,FontStyle.Bold)); } if(gx==null) { g.FillRectangle(Brushes.White,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint,odGrid.Width,odGrid.TitleHeight); g.DrawString("Payment Plans",new Font("Arial",10,FontStyle.Bold),new SolidBrush(Color.Black),field.XPos+(field.Width-sSize.Width)/2,odGrid.PrintRows[i].YPos-_yPosPrint); } else { gx.DrawRectangle(Brushes.White,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint-1,odGrid.Width,odGrid.TitleHeight); using(Font _font=new Font("Arial",10,FontStyle.Bold)) { GraphicsHelper.DrawStringX(gx,Graphics.FromImage(new Bitmap(100,100)),(double)((1d)/p(1)),"Payment Plans",new XFont(_font.FontFamily.ToString(),_font.Size,XFontStyle.Bold),XBrushes.Black,new XRect(p(field.XPos+field.Width/2),p(odGrid.PrintRows[i].YPos-_yPosPrint-1),p(300),p(100)),XStringAlignment.Center); //gx.DrawString("Payment Plans",new XFont(_font.FontFamily.ToString(),_font.Size,XFontStyle.Bold),new SolidBrush(Color.Black),field.XPos+(field.Width-sSize.Width)/2,yPosGrid); } } break; default: if(gx==null) { odGrid.PrintTitle(g,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint); } else { odGrid.PrintTitleX(gx,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint); } break; } _yAdjCurRow+=odGrid.TitleHeight; } #endregion #region Draw Header if(odGrid.PrintRows[i].IsHeaderRow) { if(gx==null) { odGrid.PrintHeader(g,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow); } else { odGrid.PrintHeaderX(gx,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow); } _yAdjCurRow+=odGrid.HeaderHeight; } #endregion #region Draw Row if(gx==null) { odGrid.PrintRow(i,g,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow,odGrid.PrintRows[i].IsBottomRow,true); } else { odGrid.PrintRowX(i,gx,field.XPos,odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow,odGrid.PrintRows[i].IsBottomRow,true); } _yAdjCurRow+=odGrid.RowHeights[i]; #endregion #region Draw Footer (rare) if(odGrid.PrintRows[i].IsFooterRow) { _yAdjCurRow+=2; switch(field.FieldName) { case "StatementPayPlan": DataTable tableMisc=AccountModules.GetStatementDataSet(stmt).Tables["misc"]; if(tableMisc==null) { tableMisc=new DataTable(); } Double payPlanDue=0; for(int m=0;m<tableMisc.Rows.Count;m++) { if(tableMisc.Rows[m]["descript"].ToString()=="payPlanDue") { payPlanDue=PIn.Double(tableMisc.Rows[m]["value"].ToString()); } } if(gx==null) { RectangleF rf=new RectangleF(sheet.Width-60-field.Width,odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow,field.Width,odGrid.TitleHeight); g.FillRectangle(Brushes.White,rf); StringFormat sf=new StringFormat(); sf.Alignment=StringAlignment.Far; g.DrawString("Payment Plan Amount Due: "+payPlanDue.ToString("c"),new Font("Arial",9,FontStyle.Bold),new SolidBrush(Color.Black),rf,sf); } else { gx.DrawRectangle(Brushes.White,p(sheet.Width-field.Width-60),p(odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow),p(field.Width),p(odGrid.TitleHeight)); using(Font _font=new Font("Arial",9,FontStyle.Bold)) { GraphicsHelper.DrawStringX(gx,Graphics.FromImage(new Bitmap(100,100)),(double)((1d)/p(1)),"Payment Plan Amount Due: "+payPlanDue.ToString("c"),new XFont(_font.FontFamily.ToString(),_font.Size,XFontStyle.Bold),XBrushes.Black,new XRect(p(sheet.Width-60),p(odGrid.PrintRows[i].YPos-_yPosPrint+_yAdjCurRow),p(field.Width),p(odGrid.TitleHeight)),XStringAlignment.Far); } } break; } } #endregion } }
/// <summary></summary> public static string RunAll() { string retVal=""; //GetString string strResult=WebServiceTests.GetString("Input"); if(strResult!="Input-Processed"){ throw new Exception("Should be Input-Processed"); } retVal+="GetString: Passed.\r\n"; strResult=WebServiceTests.GetStringNull("Input"); if(strResult!=null){ throw new Exception("Should be null"); } retVal+="GetStringNull: Passed.\r\n"; strResult=WebServiceTests.GetStringCarriageReturn("Carriage\r\nReturn"); if(strResult!="Carriage\r\nReturn-Processed") { throw new Exception("Should be Carriage\r\nReturn-Processed"); } retVal+="GetStringCarriageReturn: Passed.\r\n"; //GetInt int intResult=WebServiceTests.GetInt(1); if(intResult!=2){ throw new Exception("Should be 2"); } retVal+="GetInt: Passed.\r\n"; //GetLong long longResult=WebServiceTests.GetLong(1); if(longResult!=2){ throw new Exception("Should be 2"); } retVal+="GetLong: Passed.\r\n"; //GetVoid WebServiceTests.GetVoid(); retVal+="GetVoid: Passed.\r\n"; //GetBool bool boolResult=WebServiceTests.GetBool(); if(boolResult!=true){ throw new Exception("Should be true"); } retVal+="GetBool: Passed.\r\n"; //GetObject Patient pat=WebServiceTests.GetObjectPat(); if(pat.LName!="Smith"){ throw new Exception("Should be Smith"); } if(pat.FName!=null){ throw new Exception("Should be null"); } retVal+="GetObjectPat: Passed.\r\n"; //GetTable DataTable table=WebServiceTests.GetTable(); if(table.Rows[0][0].ToString()!="cell00"){ throw new Exception("Should be cell00"); } retVal+="GetTable: Passed.\r\n"; //GetTable with carriage return table=WebServiceTests.GetTableCarriageReturn(); if(table.Rows[0][0].ToString()!="cell\r\n00"){ throw new Exception("Should be cell\r\n00"); } retVal+="GetTableCarriageReturn: Passed.\r\n"; //GetDataSet DataSet ds=WebServiceTests.GetDataSet(); if(ds.Tables[0].TableName!="table0"){ throw new Exception("Should be table0"); } retVal+="GetDataSet: Passed.\r\n"; //GetList List<int> listInt=WebServiceTests.GetListInt(); if(listInt[0]!=2){ throw new Exception("Should be 2"); } retVal+="GetListInt: Passed.\r\n"; //GetArrayPatient Patient[] arrayPat=WebServiceTests.GetArrayPatient(); if(arrayPat[0].LName!="Jones"){ throw new Exception("Should be Jones"); } if(arrayPat[1]!=null){ throw new Exception("Should be null"); } retVal+="GetArrayPatient: Passed.\r\n"; //SendNullParam strResult=WebServiceTests.SendNullParam(null); if(strResult!="nullOK"){ throw new Exception("Should be nullOK"); } retVal+="SendNullParam: Passed.\r\n"; //GetObjectNull Patient pat2=WebServiceTests.GetObjectNull(); if(pat2!=null){ throw new Exception("Should be null"); } retVal+="GetObjectNull: Passed.\r\n"; //SendColorParam Color colorResult=WebServiceTests.SendColorParam(Color.Fuchsia); if(colorResult.ToArgb()!=Color.Green.ToArgb()) { throw new Exception("Should be green."); } retVal+="SendColorParam: Passed.\r\n"; //SendProviderColor Provider prov=new Provider(); prov.ProvColor=Color.Fuchsia; strResult=WebServiceTests.SendProviderColor(prov); if(strResult!="fuchsiaOK") { throw new Exception("Should be fuchsiaOK."); } retVal+="SendProviderColor: Passed.\r\n"; //SendSheetParameter SheetParameter sheetParam=new SheetParameter(false,"ParamNameOK"); strResult=WebServiceTests.SendSheetParameter(sheetParam); if(strResult!="paramNameOK") { throw new Exception("Should be paramNameOK."); } retVal+="SendSheetParameter: Passed.\r\n"; //SendSheetWithFields Sheet sheet=new Sheet(); sheet.SheetFields=new List<SheetField>(); sheet.Parameters=new List<SheetParameter>(); SheetField field=new SheetField(); field.FieldName="FieldNameGreen"; sheet.SheetFields.Add(field); strResult=WebServiceTests.SendSheetWithFields(sheet); if(strResult!="fieldOK") { throw new Exception("Should be fieldOK."); } retVal+="SendSheetWithFields: Passed.\r\n"; //SendSheetDefWithFields SheetDef sheetdef=new SheetDef(); sheetdef.SheetFieldDefs=new List<SheetFieldDef>(); sheetdef.Parameters=new List<SheetParameter>(); SheetFieldDef fielddef=new SheetFieldDef(); fielddef.FieldName="FieldNameTeal"; sheetdef.SheetFieldDefs.Add(fielddef); strResult=WebServiceTests.SendSheetDefWithFieldDefs(sheetdef); if(strResult!="fielddefOK") { throw new Exception("Should be fielddefOK."); } retVal+="SendSheetDefWithFieldDefs: Passed.\r\n"; //TimeSpanNeg TimeSpan tspan=WebServiceTests.GetTimeSpan(); if(tspan!=new TimeSpan(1,0,0)) { throw new Exception("Should be 1 hour."); } retVal+="GetTimeSpan: Passed.\r\n"; //GetStringContainingCR //fails, but we have a strategy to fix some day by putting serialization code into the crud layer. /* strResult=WebServiceTests.GetStringContainingCR(); strResult=strResult.Replace("\\r","\r"); if(strResult!="Line1\r\nLine2") { throw new Exception("Should be Line1\r\nLine2"); } retVal+="GetStringContainingCR: Passed.\r\n"; //GetListTasksContainingCR Task task=WebServiceTests.GetListTasksContainingCR()[0]; if(task.Descript!="Line1\r\nLine2") { throw new Exception("Should be Line1\r\nLine2"); } retVal+="GetListTasksContainingCR: Passed.\r\n";*/ return retVal; }
///<summary>Converts parameters into sheetfield objects, and then saves those objects in the database. The parameters will never again enjoy full parameter status, but will just be read-only fields from here on out. It ignores PatNum parameters, since those are already part of the sheet itself.</summary> public static void SaveParameters(Sheet sheet){ //No need to check RemotingRole; no call to db SheetField field; for(int i=0;i<sheet.Parameters.Count;i++){ if(sheet.Parameters[i].ParamName=="PatNum"){ continue; } field=new SheetField(); field.IsNew=true; field.SheetNum=sheet.SheetNum; field.FieldType=SheetFieldType.Parameter; field.FieldName=sheet.Parameters[i].ParamName; field.FieldValue=sheet.Parameters[i].ParamValue.ToString();//the object will be an int. Stored as a string. field.FontSize=0; field.FontName=""; field.FontIsBold=false; field.XPos=0; field.YPos=0; field.Width=0; field.Height=0; field.GrowthBehavior=GrowthBehaviorEnum.None; field.RadioButtonValue=""; SheetFields.Insert(field); } }
///<summary>Calculates height of grid taking into account page breaks, word wrapping, cell width, font size, and actual data to be used to fill this grid.</summary> private static int CalculateGridHeightHelper(SheetField field,Sheet sheet,Graphics g,Statement stmt,int topMargin,int bottomMargin,MedLab medLab) { UI.ODGrid odGrid=new UI.ODGrid(); odGrid.FontForSheets=new Font(field.FontName,field.FontSize,field.FontIsBold?FontStyle.Bold:FontStyle.Regular); odGrid.Width=field.Width; odGrid.HideScrollBars=true; odGrid.YPosField=field.YPos; odGrid.TopMargin=topMargin; odGrid.BottomMargin=bottomMargin; odGrid.PageHeight=sheet.HeightPage; odGrid.Title=field.FieldName; if(stmt!=null) { odGrid.Title+=(stmt.Intermingled?".Intermingled":".NotIntermingled");//Important for calculating heights. } DataTable Table=SheetUtil.GetDataTableForGridType(field.FieldName,stmt,medLab); List<DisplayField> Columns=SheetUtil.GetGridColumnsAvailable(field.FieldName); #region Fill Grid odGrid.BeginUpdate(); odGrid.Columns.Clear(); ODGridColumn col; for(int i=0;i<Columns.Count;i++) { col=new ODGridColumn(Columns[i].InternalName,Columns[i].ColumnWidth); odGrid.Columns.Add(col); } ODGridRow row; for(int i=0;i<Table.Rows.Count;i++) { row=new ODGridRow(); for(int c=0;c<Columns.Count;c++) {//Selectively fill columns from the dataTable into the odGrid. row.Cells.Add(Table.Rows[i][Columns[c].InternalName].ToString()); } if(Table.Columns.Contains("PatNum")) {//Used for statments to determine account splitting. row.Tag=Table.Rows[i]["PatNum"].ToString(); } odGrid.Rows.Add(row); } odGrid.EndUpdate(true);//Calls ComputeRows and ComputeColumns, meaning the RowHeights int[] has been filled. #endregion return odGrid.PrintHeight; }
private static void CalculateHeightsPageBreak(SheetField field,Sheet sheet,Graphics g) { double lineSpacingForPdf=1.01d; FontStyle fontstyle=FontStyle.Regular; if(field.FontIsBold) { fontstyle=FontStyle.Bold; } Font font=new Font(field.FontName,field.FontSize,fontstyle); //adjust the height of the text box to accomodate PDFs if the field has a growth behavior other than None double calcH=lineSpacingForPdf*GraphicsHelper.MeasureStringH(g,field.FieldValue,font,field.Width); if(field.GrowthBehavior!=GrowthBehaviorEnum.None && field.Height<Convert.ToInt32(Math.Ceiling(calcH))) { int amtGrowth=Convert.ToInt32(Math.Ceiling(calcH)-field.Height); field.Height+=amtGrowth; if(field.GrowthBehavior==GrowthBehaviorEnum.DownLocal) { MoveAllDownWhichIntersect(sheet,field,amtGrowth); } else if(field.GrowthBehavior==GrowthBehaviorEnum.DownGlobal) { MoveAllDownBelowThis(sheet,field,amtGrowth); } } int topMargin=40; if(sheet.SheetType==SheetTypeEnum.MedLabResults) { topMargin=120; } int pageCount; int bottomCurPage=SheetPrinting.bottomCurPage(field.YPos,sheet,out pageCount); //recursion base case, the field now fits on the current page, break out of recursion if(field.YPos+field.Height<=bottomCurPage) { return; } //field extends beyond the bottom of the current page, so we will split the text box in between lines, not through the middle of text string measureText="Any"; double calcHLine=lineSpacingForPdf*GraphicsHelper.MeasureStringH(g,measureText,font,field.Width);//calcHLine is height of single line of text //if the height of one line is greater than the printable height of the page, don't try to split between lines if(Convert.ToInt32(Math.Ceiling(calcHLine))>(sheet.HeightPage-60-topMargin)) { return; } if(Convert.ToInt32(Math.Ceiling(field.YPos+calcHLine))>bottomCurPage) {//if no lines of text will fit on current page, move the entire text box to the next page int moveAmount=bottomCurPage+1-field.YPos; field.Height+=moveAmount; MoveAllDownWhichIntersect(sheet,field,moveAmount); field.Height-=moveAmount; field.YPos+=moveAmount; //recursive call CalculateHeightsPageBreak(field,sheet,g); return; } calcH=0; int fieldH=0; measureText=""; //while YPos + calc height of the string <= the bottom of the current page, add a new line and the text Any to the string while(Convert.ToInt32(Math.Ceiling(field.YPos+calcH))<=bottomCurPage) { fieldH=Convert.ToInt32(Math.Ceiling(calcH)); if(measureText!="") { measureText+="\r\n"; } measureText+="Any";//add new line and another word to measure the height of an additional line of text calcH=lineSpacingForPdf*GraphicsHelper.MeasureStringH(g,measureText,font,field.Width); } //get ready to copy text from the current field to a copy of the field that will be moved down. SheetField fieldNew=new SheetField(); fieldNew=field.Copy(); field.Height=fieldH; fieldNew.Height-=fieldH;//reduce the size of the new text box by the height of the text removed fieldNew.YPos+=fieldH;//move the new field down the amount of the removed text to maintain the distance between all fields below //this is so all new line characters will be a single character, we will replace \n's with \r\n's after this for loop fieldNew.FieldValue=fieldNew.FieldValue.Replace("\r\n","\n"); int exponentN=Convert.ToInt32(Math.Ceiling(Math.Log(fieldNew.FieldValue.Length,2)))-1; int indexCur=Convert.ToInt32(Math.Pow((double)2,(double)exponentN)); int fieldHeightCur=0; while(exponentN>0) { exponentN--; if(indexCur>=fieldNew.FieldValue.Length || Convert.ToInt32(Math.Ceiling(lineSpacingForPdf*GraphicsHelper.MeasureStringH(g,fieldNew.FieldValue.Substring(0,indexCur+1), font,fieldNew.Width)))>field.Height) { indexCur-=Convert.ToInt32(Math.Pow((double)2,(double)exponentN)); } else { indexCur+=Convert.ToInt32(Math.Pow((double)2,(double)exponentN)); } } if(indexCur>=fieldNew.FieldValue.Length) {//just in case, set indexCur to the last character if it is larger than the size of the fieldValue indexCur=fieldNew.FieldValue.Length-1; } fieldHeightCur=Convert.ToInt32(Math.Ceiling(lineSpacingForPdf*GraphicsHelper.MeasureStringH(g,fieldNew.FieldValue.Substring(0,indexCur+1), font,fieldNew.Width))); while(fieldHeightCur>field.Height) { indexCur--; fieldHeightCur=Convert.ToInt32(Math.Ceiling(lineSpacingForPdf*GraphicsHelper.MeasureStringH(g,fieldNew.FieldValue.Substring(0,indexCur+1), font,fieldNew.Width))); } //add the new line character to the previous line so the next page doesn't start with a blank line if(fieldNew.FieldValue.Length>indexCur+1 && (fieldNew.FieldValue[indexCur+1]=='\r' || fieldNew.FieldValue[indexCur+1]=='\n')) { indexCur++; } field.FieldValue=fieldNew.FieldValue.Substring(0,indexCur+1); if(field.FieldValue[indexCur]=='\r' || field.FieldValue[indexCur]=='\n') { field.FieldValue=field.FieldValue.Substring(0,indexCur); } field.FieldValue=field.FieldValue.Replace("\n","\r\n"); if(fieldNew.FieldValue.Length>indexCur+1) { fieldNew.FieldValue=fieldNew.FieldValue.Substring(indexCur+1); fieldNew.FieldValue=fieldNew.FieldValue.Replace("\n","\r\n"); } else { //no text left for the field that would have been on the next page, done, break out of recursion return; } int moveAmountNew=bottomCurPage+1-fieldNew.YPos; fieldNew.Height+=moveAmountNew; MoveAllDownWhichIntersect(sheet,fieldNew,moveAmountNew); fieldNew.Height-=moveAmountNew; fieldNew.YPos+=moveAmountNew; sheet.SheetFields.Add(fieldNew); //recursive call CalculateHeightsPageBreak(fieldNew,sheet,g); }
private static void drawMedLabHeader(Sheet sheet,Graphics g,XGraphics gx) { SheetField fieldCur=new SheetField(); fieldCur.XPos=50; fieldCur.YPos=_yPosPrint+40;//top of the top rectangle fieldCur.Width=529; fieldCur.Height=40; drawFieldRectangle(fieldCur,g,gx); fieldCur.XPos=579; fieldCur.Width=221; drawFieldRectangle(fieldCur,g,gx); fieldCur.XPos=50; fieldCur.YPos+=40;//drop down an additional 40 pixels for second row of rectangles fieldCur.Width=100; drawFieldRectangle(fieldCur,g,gx); fieldCur.XPos=150; fieldCur.Width=140; drawFieldRectangle(fieldCur,g,gx); fieldCur.XPos=290; fieldCur.Width=100; drawFieldRectangle(fieldCur,g,gx); fieldCur.XPos=390; fieldCur.Width=145; drawFieldRectangle(fieldCur,g,gx); fieldCur.XPos=535; fieldCur.Width=100; drawFieldRectangle(fieldCur,g,gx); fieldCur.XPos=635; fieldCur.Width=65; drawFieldRectangle(fieldCur,g,gx); fieldCur.XPos=700; fieldCur.Width=100; drawFieldRectangle(fieldCur,g,gx); fieldCur.FieldValue="Patient Name"; fieldCur.FontSize=8.5f; fieldCur.FontName="Arial"; fieldCur.FontIsBold=false; fieldCur.XPos=54; fieldCur.YPos=_yPosPrint+44;//4 pixels down from the rectangle top for static text descriptions of text boxes in header fieldCur.Width=522; fieldCur.Height=15; fieldCur.TextAlign=HorizontalAlignment.Left; fieldCur.ItemColor=Color.FromKnownColor(KnownColor.GrayText); drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue="Specimen Number"; fieldCur.XPos=583; fieldCur.Width=214; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue="Account Number"; fieldCur.XPos=54; fieldCur.YPos+=40;//drop down an additional 40 pixels for second row of static text descriptions fieldCur.Width=93; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue="Patient ID"; fieldCur.XPos=154; fieldCur.Width=133; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue="Control Number"; fieldCur.XPos=294; fieldCur.Width=93; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue="Date & Time Collected"; fieldCur.XPos=394; fieldCur.Width=138; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue="Date Reported"; fieldCur.XPos=539; fieldCur.Width=93; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue="Gender"; fieldCur.XPos=639; fieldCur.Width=58; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue="Date of Birth"; fieldCur.XPos=704; fieldCur.Width=93; drawFieldText(fieldCur,sheet,g,gx); string patLName=""; string patFName=""; string patMiddleI=""; string specNum=""; string acctNum=""; string patId=""; string ctrlNum=""; string dateTCollected=""; string dateReported=""; string gender=""; string birthdate=""; foreach(SheetField sf in sheet.SheetFields) { switch(sf.FieldName) { case "patient.LName": patLName=sf.FieldValue; continue; case "patient.FName": patFName=sf.FieldValue; continue; case "patient.MiddleI": patMiddleI=sf.FieldValue; continue; case "medlab.PatIDLab": specNum=sf.FieldValue; continue; case "medlab.PatAccountNum": acctNum=sf.FieldValue; continue; case "medlab.PatIDAlt": patId=sf.FieldValue; continue; case "medlab.SpecimenIDAlt": ctrlNum=sf.FieldValue; continue; case "medlab.DateTimeCollected": dateTCollected=sf.FieldValue; continue; case "medlab.DateTimeReported": dateReported=PIn.DateT(sf.FieldValue).ToShortDateString(); if(dateReported==DateTime.MinValue.ToShortDateString()) { dateReported=""; } continue; case "patient.Gender": gender=sf.FieldValue; continue; case "patient.Birthdate": birthdate=sf.FieldValue; continue; } } fieldCur.FieldValue=patLName+", "+patFName+" "+patMiddleI; fieldCur.FontSize=9; fieldCur.FontName="Arial"; fieldCur.FontIsBold=false; fieldCur.XPos=53; fieldCur.YPos=_yPosPrint+62;//22 pixels down from the rectangle top (second row of text is 20 pixels below static text descriptions) fieldCur.Width=524; fieldCur.Height=17; fieldCur.TextAlign=HorizontalAlignment.Left; fieldCur.ItemColor=Color.FromKnownColor(KnownColor.Black); drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue=specNum; fieldCur.XPos=582; fieldCur.Width=216; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue=acctNum; fieldCur.XPos=53; fieldCur.YPos+=40;//drop down an additional 40 pixels for second row fieldCur.Width=95; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue=patId; fieldCur.XPos=153; fieldCur.Width=135; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue=ctrlNum; fieldCur.XPos=293; fieldCur.Width=95; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue=dateTCollected; fieldCur.XPos=393; fieldCur.Width=140; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue=dateReported; fieldCur.XPos=538; fieldCur.Width=95; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue=gender; fieldCur.XPos=638; fieldCur.Width=60; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue=birthdate; fieldCur.XPos=703; fieldCur.Width=95; drawFieldText(fieldCur,sheet,g,gx); }
private static void drawMedLabFooter(Sheet sheet,Graphics g,XGraphics gx) { SheetField fieldCur=new SheetField(); fieldCur.XPos=50; int pageCount; fieldCur.YPos=bottomCurPage(_yPosPrint+_printMargin.Bottom+_printMargin.Top+1,sheet,out pageCount)+1; fieldCur.Width=625; fieldCur.Height=20; drawFieldRectangle(fieldCur,g,gx); fieldCur.XPos=675; fieldCur.Width=125; drawFieldRectangle(fieldCur,g,gx); string patLName=""; string patFName=""; string patMiddleI=""; string specNum=""; foreach(SheetField sf in sheet.SheetFields) { switch(sf.FieldName) { case "patient.LName": patLName=sf.FieldValue; continue; case "patient.FName": patFName=sf.FieldValue; continue; case "patient.MiddleI": patMiddleI=sf.FieldValue; continue; case "medlab.PatIDLab": specNum=sf.FieldValue; continue; default: continue; } } fieldCur.FieldValue=patLName; if(patLName!="" && (patFName!="" || patMiddleI!="")) { fieldCur.FieldValue+=", "; } fieldCur.FieldValue+=patFName; if(fieldCur.FieldValue!="" && patMiddleI!="") { fieldCur.FieldValue+=" "; } fieldCur.FieldValue+=patMiddleI; fieldCur.FontSize=9; fieldCur.FontName="Arial"; fieldCur.FontIsBold=false; fieldCur.XPos=53; fieldCur.YPos+=1; fieldCur.Width=245; fieldCur.Height=17; fieldCur.TextAlign=HorizontalAlignment.Left; fieldCur.ItemColor=Color.FromKnownColor(KnownColor.Black); drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue=specNum; fieldCur.XPos=678; fieldCur.Width=120; fieldCur.TextAlign=HorizontalAlignment.Center; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue=DateTime.Now.ToString("MM/dd/yyyy hh:mm tt"); fieldCur.FontSize=8.5f; fieldCur.FontName=sheet.FontName; fieldCur.XPos=50;//position the field at 50 for left margin fieldCur.YPos+=19;//drop down 19 pixels from the top of the text in the rect (17 pixel height of text box + 1 pixel to bottom of rect + 1 pixel) fieldCur.Width=150; fieldCur.TextAlign=HorizontalAlignment.Left; drawFieldText(fieldCur,sheet,g,gx); fieldCur.FieldValue=String.Format("Page {0} of {1}",_pagesPrinted+1,Sheets.CalculatePageCount(sheet,_printMargin)); fieldCur.XPos=sheet.Width-200;//width of field is 150, with a right margin of 50 xPos is sheet width-150-50=width-200 fieldCur.TextAlign=HorizontalAlignment.Right; drawFieldText(fieldCur,sheet,g,gx); if(_medLab.IsPreliminaryResult) { fieldCur.FieldValue="Preliminary Report"; } else { fieldCur.FieldValue="Final Report"; } fieldCur.FontSize=10.0f; fieldCur.FontIsBold=true; //field will be centered on page, since page count is taking up 150 pixels plus page right margin of 50 pixels on the right side of page //and date printed is taking up 50 pixel left margin plus 150 pixel field width on the left side of page //field width will be sheet.Width-400 and XPos will be 200 fieldCur.XPos=200; fieldCur.YPos+=2; fieldCur.Width=sheet.Width-400;//sheet width-150 (date field width)-150 (page count field width)-50 (left margin)-50 (right margin) fieldCur.TextAlign=HorizontalAlignment.Center; drawFieldText(fieldCur,sheet,g,gx); }
public static void drawFieldSigBox(SheetField field,Sheet sheet,Graphics g,XGraphics gx) { SignatureBoxWrapper wrapper=new SignatureBoxWrapper(); wrapper.Width=field.Width; wrapper.Height=field.Height; if(field.FieldValue.Length>0) {//a signature is present bool sigIsTopaz=false; if(field.FieldValue[0]=='1') { sigIsTopaz=true; } string signature=""; if(field.FieldValue.Length>1) { signature=field.FieldValue.Substring(1); } string keyData=Sheets.GetSignatureKey(sheet); wrapper.FillSignature(sigIsTopaz,keyData,signature); } if(g!=null) { Bitmap sigBitmap=wrapper.GetSigImage(); g.DrawImage(sigBitmap,field.XPos,field.YPos-_yPosPrint,field.Width-2,field.Height-2); sigBitmap.Dispose(); sigBitmap=null; } else { XImage sigBitmap=XImage.FromGdiPlusImage(wrapper.GetSigImage()); gx.DrawImage(sigBitmap,p(field.XPos),p(field.YPos-_yPosPrint),p(field.Width-2),p(field.Height-2)); sigBitmap.Dispose(); sigBitmap=null; } }
public static void drawFieldCheckBox(SheetField field,Graphics g,XGraphics gx) { if(field.FieldValue!="X") { return; } if(gx==null) { Pen pen3=new Pen(Brushes.Black,1.6f); g.DrawLine(pen3,field.XPos,field.YPos-_yPosPrint,field.XPos+field.Width,field.YPos-_yPosPrint+field.Height); g.DrawLine(pen3,field.XPos+field.Width,field.YPos-_yPosPrint,field.XPos,field.YPos-_yPosPrint+field.Height); pen3.Dispose(); pen3=null; } else { XPen pen3=new XPen(XColors.Black,p(1.6f)); gx.DrawLine(pen3,p(field.XPos),p(field.YPos-_yPosPrint),p(field.XPos+field.Width),p(field.YPos-_yPosPrint+field.Height)); gx.DrawLine(pen3,p(field.XPos+field.Width),p(field.YPos-_yPosPrint),p(field.XPos),p(field.YPos-_yPosPrint+field.Height)); pen3=null; } GC.Collect(); }
public static void drawFieldText(SheetField field,Sheet sheet,Graphics g,XGraphics gx) { Bitmap doubleBuffer=new Bitmap(sheet.Width,sheet.Height);//IsLandscape?? Graphics gfx=Graphics.FromImage(doubleBuffer); Plugins.HookAddCode(null,"SheetPrinting.pd_PrintPage_drawFieldLoop",field); if(gx==null){ FontStyle fontstyle=(field.FontIsBold?FontStyle.Bold:FontStyle.Regular); Font font=new Font(field.FontName,field.FontSize,fontstyle); Rectangle bounds=new Rectangle(field.XPos,field.YPos-_yPosPrint,field.Width,field.Height);//Math.Min(field.Height,_yPosPrint+sheet.HeightPage-_printMargin.Bottom-field.YPos)); StringAlignment sa= StringAlignment.Near; switch(field.TextAlign) { case System.Windows.Forms.HorizontalAlignment.Left: sa=StringAlignment.Near; break; case System.Windows.Forms.HorizontalAlignment.Center: sa=StringAlignment.Center; break; case System.Windows.Forms.HorizontalAlignment.Right: sa=StringAlignment.Far; break; } GraphicsHelper.DrawString(g,gfx,field.FieldValue,font,(field.ItemColor==Color.FromArgb(0)?Brushes.Black:new SolidBrush(field.ItemColor)),bounds,sa); font.Dispose(); font=null; } else{ XFontStyle xfontstyle=(field.FontIsBold?XFontStyle.Bold:XFontStyle.Regular); XFont xfont=new XFont(field.FontName,field.FontSize,xfontstyle); XStringAlignment xsa= XStringAlignment.Near; int tempX=field.XPos; switch(field.TextAlign) { case System.Windows.Forms.HorizontalAlignment.Left: xsa=XStringAlignment.Near; break; case System.Windows.Forms.HorizontalAlignment.Center: xsa=XStringAlignment.Center; tempX+=field.Width/2; //field.XPos+=field.Width/2; break; case System.Windows.Forms.HorizontalAlignment.Right: xsa=XStringAlignment.Far; tempX+=field.Width; //field.XPos+=field.Width; break; } XRect xrect=new XRect(p(tempX),p(field.YPos-_yPosPrint),p(field.Width),p(field.Height)); GraphicsHelper.DrawStringX(gx,gfx,1d/p(1),field.FieldValue,xfont,(field.ItemColor==Color.FromArgb(0)?XBrushes.Black:new XSolidBrush(field.ItemColor)),xrect,xsa); //xfont.Dispose(); xfont=null; } doubleBuffer.Dispose(); doubleBuffer=null; gfx.Dispose(); gfx=null; GC.Collect(); }
///<summary>Takes a screening sheet that is associated to a patient and processes any corresponding ScreenCharts found. ///Processing will create treatment planned or completed procedures for the patient. ///Supply the sheet and then a bitwise enum of screen chart types to digest. ///listProcOrigVals, nulls are allowed, the first represents the fluoride field, second is assessment field, all others are other procs.</summary> public static void ProcessScreenChart(Sheet sheet, ScreenChartType chartTypes, long provNum, long sheetNum, List <SheetField> listChartOrigVals , List <SheetField> listProcOrigVals) { //No need to check RemotingRole; no call to db. if (sheet == null || sheet.PatNum == 0) { return; //An invalid screening sheet was passed in. } List <string> listToothVals = new List <string>(); List <string> listToothValsOld = new List <string>(); //Process treatment planned sealants. foreach (SheetField field in sheet.SheetFields) //Go through the supplied sheet's fields and find the field. { if (chartTypes.HasFlag(ScreenChartType.TP) && field.FieldType == SheetFieldType.ScreenChart && field.FieldName == "ChartSealantTreatment") { listToothVals = field.FieldValue.Split(';').ToList(); if (listToothVals[0] == "1") //Primary tooth chart { continue; //Skip primary tooth charts because we do not need to create any TP procedures for them. } listToothVals.RemoveAt(0); //Remove the toothchart type value if (listChartOrigVals[0] != null) //Shouldn't be null if ChartSealantTreatment exists { listToothValsOld = listChartOrigVals[0].FieldValue.Split(';').ToList(); listToothValsOld.RemoveAt(0); //Remove the toothchart type value } ScreenChartType chartType = ScreenChartType.TP; ProcessScreenChartHelper(sheet.PatNum, listToothVals, chartType, provNum, sheetNum, listToothValsOld); break; } } listToothVals = new List <string>(); //Clear out the tooth values for the next tooth chart. //Process completed sealants. foreach (SheetField field in sheet.SheetFields) //Go through the supplied sheet's fields and find the field. { if (chartTypes.HasFlag(ScreenChartType.C) && field.FieldType == SheetFieldType.ScreenChart && field.FieldName == "ChartSealantComplete") { listToothVals = field.FieldValue.Split(';').ToList(); if (listToothVals[0] == "1") //Primary tooth chart { continue; //Skip primary tooth charts because we do not need to create any TP procedures for them. } listToothVals.RemoveAt(0); //Remove the toothchart type value if (listChartOrigVals[1] != null) //Shouldn't be null if ChartSealantTreatment exists { listToothValsOld = listChartOrigVals[1].FieldValue.Split(';').ToList(); listToothValsOld.RemoveAt(0); //Remove the toothchart type value } ScreenChartType chartType = ScreenChartType.C; ProcessScreenChartHelper(sheet.PatNum, listToothVals, chartType, provNum, sheetNum, listToothValsOld); break; } } //Process if the user wants to TP fluoride and/or assessment procedures and/or other procedures. foreach (SheetField field in sheet.SheetFields) { if (field.FieldType != SheetFieldType.CheckBox) { continue; //Only care about check box types. } if (field.FieldName != "FluorideProc" && field.FieldName != "AssessmentProc" && !field.FieldName.StartsWith("Proc:")) { continue; //Field name must be one of the two hard coded values, or a FieldName that starts with "Proc". } //Make other proc with provNum and patNum SheetField sheetFieldOrig = listProcOrigVals.FirstOrDefault(x => x.FieldName == field.FieldName && x.FieldType == SheetFieldType.CheckBox); if (sheetFieldOrig == null || sheetFieldOrig.FieldValue != "" || field.FieldValue != "X") { //Either not found or field was previously checked (already charted proc) or field is not checked (do not chart). continue; } string strProcCode = ""; switch (field.FieldName) { case "FluorideProc": //Original value was blank, new value is "checked", make the D1206 (fluoride) proc. strProcCode = "D1206"; break; case "AssessmentProc": //Original value was blank, new value is "checked", make the D0191 (assessment) proc. strProcCode = "D0191"; break; default: //Original value was blank, new value is "checked", make the proc. strProcCode = field.FieldName.Substring(5); //Drop "Proc:" from FieldName. break; } Procedure proc = Procedures.CreateProcForPatNum(sheet.PatNum, ProcedureCodes.GetCodeNum(strProcCode), "", "", ProcStat.C, provNum); if (proc != null) { SecurityLogs.MakeLogEntry(Permissions.ProcEdit, sheet.PatNum, strProcCode + " " + Lans.g("Screens", "treatment planned during screening.")); } } }
///<summary>After taking a screening using a sheet, this method will import the sheet as a screen and insert it into the db. ///Returns null if the sheet passed in is not a Screening sheet type or if the sheet is missing the required ScreenGroupNum param. ///Optionally supply a screen if you want to preset some values. E.g. ScreenGroupOrder is often preset before calling this method.</summary> public static Screen CreateScreenFromSheet(Sheet sheet, Screen screen = null) { //No need to check RemotingRole; no call to db. //Make sure that the sheet passed in is a screening and contains the required ScreenGroupNum parameter. if (sheet.SheetType != SheetTypeEnum.Screening || SheetParameter.GetParamByName(sheet.Parameters, "ScreenGroupNum") == null) { return(null); } if (screen == null) { screen = new Screen(); screen.ScreenGroupNum = (long)SheetParameter.GetParamByName(sheet.Parameters, "ScreenGroupNum").ParamValue; } screen.SheetNum = sheet.SheetNum; foreach (SheetField field in sheet.SheetFields) { switch (field.FieldName) { case "Gender": if (field.FieldValue.Trim().ToLower().StartsWith("m")) { screen.Gender = PatientGender.Male; } else if (field.FieldValue.Trim().ToLower().StartsWith("f")) { screen.Gender = PatientGender.Female; } else { screen.Gender = PatientGender.Unknown; } break; case "Race/Ethnicity": PatientRaceOld patientRace = PatientRaceOld.Unknown; Enum.TryParse <PatientRaceOld>(field.FieldValue.Split(';')[0], out patientRace); screen.RaceOld = patientRace; break; case "GradeLevel": PatientGrade patientGrade = PatientGrade.Unknown; Enum.TryParse <PatientGrade>(field.FieldValue.Split(';')[0], out patientGrade); screen.GradeLevel = patientGrade; break; case "Age": if (screen.Age != 0) { break; //Already calculated via Birthdate. } byte age = 0; byte.TryParse(field.FieldValue, out age); screen.Age = age; break; case "Urgency": TreatmentUrgency treatmentUrgency = TreatmentUrgency.Unknown; Enum.TryParse <TreatmentUrgency>(field.FieldValue.Split(';')[0], out treatmentUrgency); screen.Urgency = treatmentUrgency; break; case "ChartSealantTreatment": //Only mark "carious" if TP chart has C marked for any tooth surface. if (field.FieldValue.Contains("C")) { screen.HasCaries = YN.Yes; //Caries is present in TP'd chart. Compl chart doesn't matter, it's only for sealant placement. } else { screen.HasCaries = YN.No; } //Only mark "needs sealants" if TP chart has S marked for any tooth surface. if (field.FieldValue.Contains("S")) { screen.NeedsSealants = YN.Yes; } else { screen.NeedsSealants = YN.No; } break; case "CariesExperience": screen.CariesExperience = field.FieldValue == "X" ? YN.Yes : YN.No; break; case "EarlyChildCaries": screen.EarlyChildCaries = field.FieldValue == "X" ? YN.Yes : YN.No; break; case "ExistingSealants": screen.ExistingSealants = field.FieldValue == "X" ? YN.Yes : YN.No; break; case "MissingAllTeeth": screen.MissingAllTeeth = field.FieldValue == "X" ? YN.Yes : YN.No; break; case "Birthdate": DateTime birthdate = new DateTime(1, 1, 1); DateTime.TryParse(field.FieldValue, out birthdate); screen.Birthdate = birthdate; //Check to see if the sheet has Age manually filled out. //If Age was not manually set, automatically calculate the age based on the birthdate entered. //This matches screening functionality. SheetField sheetFieldAge = sheet.SheetFields.FirstOrDefault(x => x.FieldName == "Age"); if (sheetFieldAge != null && string.IsNullOrEmpty(sheetFieldAge.FieldValue)) { screen.Age = PIn.Byte(Patients.DateToAge(birthdate).ToString()); } break; case "Comments": screen.Comments = field.FieldValue; break; } } if (screen.ScreenNum == 0) { Insert(screen); } else { Update(screen); } return(screen); }
///<summary>Sorts the sheet fields by SheetFieldNum. This is used when creating a signature key and is absolutely critical that it not change.</summary> public static int SortPrimaryKey(SheetField f1, SheetField f2) { return(f1.SheetFieldNum.CompareTo(f2.SheetFieldNum)); }
///<summary>Public accessor to the draw image function</summary> public static void drawImageHelper(SheetField field,Graphics g) { drawFieldImage(field,g,null); }
public static void drawFieldRectangle(SheetField field,Graphics g,XGraphics gx) { if(gx==null) { g.DrawRectangle(Pens.Black,field.XPos,field.YPos-_yPosPrint,field.Width,field.Height); } else { gx.DrawRectangle(XPens.Black,p(field.XPos),p(field.YPos-_yPosPrint),p(field.Width),p(field.Height)); } }
private static bool fieldOnCurPageHelper(SheetField field,Sheet sheet,Margins _printMargin,int _yPosPrint) { //Even though _printMargins and _yPosPrint are available in this context they are passed in so for future compatibility with webforms. if(field.YPos>(_yPosPrint+sheet.HeightPage)){ return false;//field is entirely on one of the next pages. } if(field.Bounds.Bottom<_yPosPrint && _pagesPrinted>0) { return false;//field is entirely on one of the previous pages. Unless we are on the first page, then it is in the top margin. } return true;//field is all or partially on current page. }
///<summary>Sorts the sheet fields by SheetFieldNum. This is used when creating a signature key and is absolutely critical that it not change.</summary> public static int SortPrimaryKey(SheetField f1,SheetField f2) { return f1.SheetFieldNum.CompareTo(f2.SheetFieldNum); }
/* ///<summary>After pulling a list of SheetFieldData objects from the database, we use this to convert it to a list of SheetFields as we create the Sheet.</summary> public static List<SheetField> CreateSheetFields(List<SheetFieldData> sheetFieldDataList){ List<SheetField> retVal=new List<SheetField>(); SheetField field; FontStyle style; for(int i=0;i<sheetFieldDataList.Count;i++){ style=FontStyle.Regular; if(sheetFieldDataList[i].FontIsBold){ style=FontStyle.Bold; } field=new SheetField(sheetFieldDataList[i].FieldType,sheetFieldDataList[i].FieldName,sheetFieldDataList[i].FieldValue, sheetFieldDataList[i].XPos,sheetFieldDataList[i].YPos,sheetFieldDataList[i].Width,sheetFieldDataList[i].Height, new Font(sheetFieldDataList[i].FontName,sheetFieldDataList[i].FontSize,style),sheetFieldDataList[i].GrowthBehavior); retVal.Add(field); } return retVal; }*/ ///<summary>Creates the initial fields from the sheetDef.FieldDefs.</summary> private static List<SheetField> CreateFieldList(List<SheetFieldDef> sheetFieldDefList,bool hidePaymentOptions=false){ List<SheetField> retVal=new List<SheetField>(); SheetField field; for(int i=0;i<sheetFieldDefList.Count;i++){ if(hidePaymentOptions && fieldIsPaymentOptionHelper(sheetFieldDefList[i])){ continue; } field=new SheetField(); field.IsNew=true; field.FieldName=sheetFieldDefList[i].FieldName; field.FieldType=sheetFieldDefList[i].FieldType; field.FieldValue=sheetFieldDefList[i].FieldValue; field.FontIsBold=sheetFieldDefList[i].FontIsBold; field.FontName=sheetFieldDefList[i].FontName; field.FontSize=sheetFieldDefList[i].FontSize; field.GrowthBehavior=sheetFieldDefList[i].GrowthBehavior; field.Height=sheetFieldDefList[i].Height; field.RadioButtonValue=sheetFieldDefList[i].RadioButtonValue; //field.SheetNum=sheetFieldList[i];//set later field.Width=sheetFieldDefList[i].Width; field.XPos=sheetFieldDefList[i].XPos; field.YPos=sheetFieldDefList[i].YPos; field.RadioButtonGroup=sheetFieldDefList[i].RadioButtonGroup; field.IsRequired=sheetFieldDefList[i].IsRequired; field.TabOrder=sheetFieldDefList[i].TabOrder; field.ReportableName=sheetFieldDefList[i].ReportableName; field.TextAlign=sheetFieldDefList[i].TextAlign; field.ItemColor=sheetFieldDefList[i].ItemColor; retVal.Add(field); } return retVal; }
public static void drawFieldLine(SheetField field,Graphics g,XGraphics gx) { if(gx==null) { g.DrawLine((field.ItemColor==Color.FromArgb(0)?Pens.Black:new Pen(field.ItemColor,1)), field.XPos,field.YPos-_yPosPrint, field.XPos+field.Width, field.YPos-_yPosPrint+field.Height); } else { gx.DrawLine((field.ItemColor==Color.FromArgb(0)?XPens.Black:new XPen(field.ItemColor,1)), p(field.XPos),p(field.YPos-_yPosPrint), p(field.XPos+field.Width), p(field.YPos-_yPosPrint+field.Height)); } GC.Collect(); }
/* ///<summary>After pulling a list of SheetFieldData objects from the database, we use this to convert it to a list of SheetFields as we create the Sheet.</summary> public static List<SheetField> CreateSheetFields(List<SheetFieldData> sheetFieldDataList){ List<SheetField> retVal=new List<SheetField>(); SheetField field; FontStyle style; for(int i=0;i<sheetFieldDataList.Count;i++){ style=FontStyle.Regular; if(sheetFieldDataList[i].FontIsBold){ style=FontStyle.Bold; } field=new SheetField(sheetFieldDataList[i].FieldType,sheetFieldDataList[i].FieldName,sheetFieldDataList[i].FieldValue, sheetFieldDataList[i].XPos,sheetFieldDataList[i].YPos,sheetFieldDataList[i].Width,sheetFieldDataList[i].Height, new Font(sheetFieldDataList[i].FontName,sheetFieldDataList[i].FontSize,style),sheetFieldDataList[i].GrowthBehavior); retVal.Add(field); } return retVal; }*/ ///<summary>Creates the initial fields from the sheetDef.FieldDefs.</summary> private static List<SheetField> CreateFieldList(List<SheetFieldDef> sheetFieldDefList){ List<SheetField> retVal=new List<SheetField>(); SheetField field; for(int i=0;i<sheetFieldDefList.Count;i++){ field=new SheetField(); field.IsNew=true; field.FieldName=sheetFieldDefList[i].FieldName; field.FieldType=sheetFieldDefList[i].FieldType; field.FieldValue=sheetFieldDefList[i].FieldValue; field.FontIsBold=sheetFieldDefList[i].FontIsBold; field.FontName=sheetFieldDefList[i].FontName; field.FontSize=sheetFieldDefList[i].FontSize; field.GrowthBehavior=sheetFieldDefList[i].GrowthBehavior; field.Height=sheetFieldDefList[i].Height; field.RadioButtonValue=sheetFieldDefList[i].RadioButtonValue; //field.SheetNum=sheetFieldList[i];//set later field.Width=sheetFieldDefList[i].Width; field.XPos=sheetFieldDefList[i].XPos; field.YPos=sheetFieldDefList[i].YPos; field.RadioButtonGroup=sheetFieldDefList[i].RadioButtonGroup; field.IsRequired=sheetFieldDefList[i].IsRequired; field.TabOrder=sheetFieldDefList[i].TabOrder; field.ReportableName=sheetFieldDefList[i].ReportableName; retVal.Add(field); } return retVal; }
public static Sheet CreateSheetFromSheetDef(SheetDef sheetDef, long patNum = 0, bool hidePaymentOptions = false) { bool FieldIsPaymentOptionHelper(SheetFieldDef sheetFieldDef) { if (sheetFieldDef.IsPaymentOption) { return(true); } switch (sheetFieldDef.FieldName) { case "StatementEnclosed": case "StatementAging": return(true); } return(false); } List <SheetField> CreateFieldList(List <SheetFieldDef> sheetFieldDefList) { List <SheetField> retVal = new List <SheetField>(); SheetField field; foreach (SheetFieldDef sheetFieldDef in sheetFieldDefList) { if (hidePaymentOptions && FieldIsPaymentOptionHelper(sheetFieldDef)) { continue; } field = new SheetField { IsNew = true, FieldName = sheetFieldDef.FieldName, FieldType = sheetFieldDef.FieldType, FieldValue = sheetFieldDef.FieldValue, FontIsBold = sheetFieldDef.FontIsBold, FontName = sheetFieldDef.FontName, FontSize = sheetFieldDef.FontSize, GrowthBehavior = sheetFieldDef.GrowthBehavior, Height = sheetFieldDef.Height, RadioButtonValue = sheetFieldDef.RadioButtonValue, //field.SheetNum=sheetFieldDef.SheetNum;//set later Width = sheetFieldDef.Width, XPos = sheetFieldDef.XPos, YPos = sheetFieldDef.YPos, RadioButtonGroup = sheetFieldDef.RadioButtonGroup, IsRequired = sheetFieldDef.IsRequired, TabOrder = sheetFieldDef.TabOrder, ReportableName = sheetFieldDef.ReportableName, TextAlign = sheetFieldDef.TextAlign, ItemColor = sheetFieldDef.ItemColor, IsLocked = sheetFieldDef.IsLocked, TabOrderMobile = sheetFieldDef.TabOrderMobile, UiLabelMobile = sheetFieldDef.UiLabelMobile, UiLabelMobileRadioButton = sheetFieldDef.UiLabelMobileRadioButton, }; retVal.Add(field); } return(retVal); } Sheet sheet = new Sheet { IsNew = true, DateTimeSheet = DateTime.Now, FontName = sheetDef.FontName, FontSize = sheetDef.FontSize, Height = sheetDef.Height, SheetType = sheetDef.SheetType, Width = sheetDef.Width, PatNum = patNum, Description = sheetDef.Description, IsLandscape = sheetDef.IsLandscape, IsMultiPage = sheetDef.IsMultiPage, SheetFields = CreateFieldList(sheetDef.SheetFieldDefs), //Blank fields with no values. Values filled later from SheetFiller.FillFields() Parameters = sheetDef.Parameters, SheetDefNum = sheetDef.SheetDefNum, HasMobileLayout = sheetDef.HasMobileLayout, }; return(sheet); }
/// <summary> /// </summary> private Sheet CreateSheet(long PatNum,WebSheets.SheetAndSheetField sAnds) { Sheet newSheet=null; try{ SheetDef sheetDef=new SheetDef((SheetTypeEnum)sAnds.web_sheet.SheetType); newSheet=SheetUtil.CreateSheet(sheetDef,PatNum); SheetParameter.SetParameter(newSheet,"PatNum",PatNum); newSheet.DateTimeSheet=sAnds.web_sheet.DateTimeSheet; newSheet.Description=sAnds.web_sheet.Description; newSheet.Height=sAnds.web_sheet.Height; newSheet.Width=sAnds.web_sheet.Width; newSheet.FontName=sAnds.web_sheet.FontName; newSheet.FontSize=sAnds.web_sheet.FontSize; newSheet.SheetType=(SheetTypeEnum)sAnds.web_sheet.SheetType; newSheet.IsLandscape=sAnds.web_sheet.IsLandscape==(sbyte)1?true:false; newSheet.InternalNote=""; newSheet.IsWebForm=true; //loop through each variable in a single sheetfield for(int i=0;i<sAnds.web_sheetfieldlist.Count();i++) { SheetField sheetfield=new SheetField(); sheetfield.FieldName=sAnds.web_sheetfieldlist[i].FieldName; sheetfield.FieldType=(SheetFieldType)sAnds.web_sheetfieldlist[i].FieldType; //sheetfield.FontIsBold=sAnds.web_sheetfieldlist[i].FontIsBold==(sbyte)1?true:false; if(sAnds.web_sheetfieldlist[i].FontIsBold==(sbyte)1) { sheetfield.FontIsBold=true; }else{ sheetfield.FontIsBold=false; } sheetfield.FontIsBold=sAnds.web_sheetfieldlist[i].FontIsBold==(sbyte)1?true:false; sheetfield.FontName=sAnds.web_sheetfieldlist[i].FontName; sheetfield.FontSize=sAnds.web_sheetfieldlist[i].FontSize; sheetfield.Height=sAnds.web_sheetfieldlist[i].Height; sheetfield.Width=sAnds.web_sheetfieldlist[i].Width; sheetfield.XPos=sAnds.web_sheetfieldlist[i].XPos; sheetfield.YPos=sAnds.web_sheetfieldlist[i].YPos; //sheetfield.IsRequired=sAnds.web_sheetfieldlist[i].IsRequired==(sbyte)1?true:false; if(sAnds.web_sheetfieldlist[i].IsRequired==(sbyte)1) { sheetfield.IsRequired=true; } else { sheetfield.IsRequired=false; } sheetfield.TabOrder=sAnds.web_sheetfieldlist[i].TabOrder; sheetfield.RadioButtonGroup=sAnds.web_sheetfieldlist[i].RadioButtonGroup; sheetfield.RadioButtonValue=sAnds.web_sheetfieldlist[i].RadioButtonValue; sheetfield.GrowthBehavior=(GrowthBehaviorEnum)sAnds.web_sheetfieldlist[i].GrowthBehavior; sheetfield.FieldValue=sAnds.web_sheetfieldlist[i].FieldValue; newSheet.SheetFields.Add(sheetfield); }// end of j loop Sheets.SaveNewSheet(newSheet); return newSheet; } catch(Exception e) { gridMain.EndUpdate(); MessageBox.Show(e.Message); } return newSheet; }
///<summary>Sorts fields in the order that they shoudl be drawn on top of eachother. First Images, then Drawings, Lines, Rectangles, Text, Check Boxes, and SigBoxes. In that order.</summary> public static int SortDrawingOrderLayers(SheetField f1,SheetField f2) { if(FieldTypeSortOrder(f1.FieldType)!=FieldTypeSortOrder(f2.FieldType)) { return FieldTypeSortOrder(f1.FieldType).CompareTo(FieldTypeSortOrder(f2.FieldType)); } return f1.YPos.CompareTo(f2.YPos); //return f1.SheetFieldNum.CompareTo(f2.SheetFieldNum); }
private void pictDraw_MouseUp(object sender,MouseEventArgs e) { mouseIsDown=false; if(checkErase.Checked){ return; } SheetField field=new SheetField(); field.FieldType=SheetFieldType.Drawing; field.FieldName=""; field.FieldValue=""; for(int i=0;i<PointList.Count;i++){ if(i>0){ field.FieldValue+=";"; } field.FieldValue+=(PointList[i].X+pictDraw.Left)+","+(PointList[i].Y+pictDraw.Top); } field.FontName=""; field.RadioButtonValue=""; SheetCur.SheetFields.Add(field); PointList.Clear(); RefreshPanel(); }
///<summary>Loops through the list passed in returns the opposite check box. Returns null if one is not found.</summary> private SheetField GetOppositeSheetFieldCheckBox(List<SheetField> sheetFieldList,SheetField sheetFieldCur) { for(int i=0;i<sheetFieldList.Count;i++) { if(sheetFieldList[i].SheetFieldNum==sheetFieldCur.SheetFieldNum) { continue; } //FieldName will be the same. Ex: allergy:Sudafed if(sheetFieldList[i].FieldName!=sheetFieldCur.FieldName) { continue; } //This has to be the opposite check box. return sheetFieldList[i]; } return null; }
/// <summary></summary> public static string RunAll() { string retVal=""; //GetString string strResult=WebServiceTests.GetString("Input"); if(strResult!="Input-Processed"){ throw new Exception("Should be Input-Processed"); } retVal+="GetString: Passed.\r\n"; strResult=WebServiceTests.GetStringNull("Input"); if(strResult!=null){ throw new Exception("Should be null"); } retVal+="GetStringNull: Passed.\r\n"; strResult=WebServiceTests.GetStringCarriageReturn("Carriage\r\nReturn"); if(strResult!="Carriage\r\nReturn-Processed") { throw new Exception("Should be Carriage\r\nReturn-Processed"); } retVal+="GetStringCarriageReturn: Passed.\r\n"; //GetInt int intResult=WebServiceTests.GetInt(1); if(intResult!=2){ throw new Exception("Should be 2"); } retVal+="GetInt: Passed.\r\n"; //GetLong long longResult=WebServiceTests.GetLong(1); if(longResult!=2){ throw new Exception("Should be 2"); } retVal+="GetLong: Passed.\r\n"; //GetVoid WebServiceTests.GetVoid(); retVal+="GetVoid: Passed.\r\n"; //GetBool bool boolResult=WebServiceTests.GetBool(); if(boolResult!=true){ throw new Exception("Should be true"); } retVal+="GetBool: Passed.\r\n"; //GetObject Patient pat=WebServiceTests.GetObjectPat(); if(pat.LName!="Smith"){ throw new Exception("Should be Smith"); } if(pat.FName!=null){ throw new Exception("Should be null"); } retVal+="GetObjectPat: Passed.\r\n"; //GetTable DataTable table=WebServiceTests.GetTable(); if(table.Rows[0][0].ToString()!="cell00"){ throw new Exception("Should be cell00"); } retVal+="GetTable: Passed.\r\n"; //GetTable with carriage return table=WebServiceTests.GetTableCarriageReturn(); if(table.Rows[0][0].ToString()!="cell\r\n00"){ throw new Exception("Should be cell\r\n00"); } retVal+="GetTableCarriageReturn: Passed.\r\n"; //Get2by3 table=WebServiceTests.GetTable2by3(); for(int i=0;i<table.Rows.Count;i++) { for(int j=0;j<table.Columns.Count;j++) { if(table.Rows[i][j].ToString()!="cell"+i.ToString()+j.ToString()) { throw new Exception("Should be cell"+i.ToString()+j.ToString()); } } } retVal+="GetTable2by3: Passed.\r\n"; //GetSpecialChars table=WebServiceTests.GetTableSpecialChars(); char[] chars={'|','<','>','&','\'','"','\\','/'}; for(int i=0;i<table.Rows.Count;i++) { for(int j=0;j<table.Columns.Count;j++) { if(table.Rows[i][j].ToString()!="cell"+i.ToString()+j.ToString()+chars[i*2+j].ToString()) { throw new Exception("Should be cell"+i.ToString()+j.ToString()+chars[i*2+j].ToString()); } } } retVal+="GetTableSpecialChars: Passed.\r\n"; //GetDataTypes table=WebServiceTests.GetTableDataTypes(); if(table.Rows[0][0].GetType()!=typeof(string)) { throw new Exception("Should be "+typeof(string).ToString()); } if(table.Rows[0][1].GetType()!=typeof(decimal)) { throw new Exception("Should be "+typeof(decimal).ToString()); } if(table.Rows[0][2].GetType()!=typeof(DateTime)) { throw new Exception("Should be "+typeof(DateTime).ToString()); } retVal+="GetTableDataTypes: Passed.\r\n"; //GetDataSet DataSet ds=WebServiceTests.GetDataSet(); if(ds.Tables[0].TableName!="table0"){ throw new Exception("Should be table0"); } retVal+="GetDataSet: Passed.\r\n"; //GetList List<int> listInt=WebServiceTests.GetListInt(); if(listInt[0]!=2){ throw new Exception("Should be 2"); } retVal+="GetListInt: Passed.\r\n"; //GetArrayPatient Patient[] arrayPat=WebServiceTests.GetArrayPatient(); if(arrayPat[0].LName!="Jones"){ throw new Exception("Should be Jones"); } if(arrayPat[1]!=null){ throw new Exception("Should be null"); } retVal+="GetArrayPatient: Passed.\r\n"; //SendNullParam strResult=WebServiceTests.SendNullParam(null); if(strResult!="nullOK"){ throw new Exception("Should be nullOK"); } retVal+="SendNullParam: Passed.\r\n"; //GetObjectNull Patient pat2=WebServiceTests.GetObjectNull(); if(pat2!=null){ throw new Exception("Should be null"); } retVal+="GetObjectNull: Passed.\r\n"; //SendColorParam Color colorResult=WebServiceTests.SendColorParam(Color.Fuchsia); if(colorResult.ToArgb()!=Color.Green.ToArgb()) { throw new Exception("Should be green."); } retVal+="SendColorParam: Passed.\r\n"; //SendProviderColor Provider prov=new Provider(); prov.ProvColor=Color.Fuchsia; strResult=WebServiceTests.SendProviderColor(prov); if(strResult!="fuchsiaOK") { throw new Exception("Should be fuchsiaOK."); } retVal+="SendProviderColor: Passed.\r\n"; //SendSheetParameter SheetParameter sheetParam=new SheetParameter(false,"ParamNameOK"); strResult=WebServiceTests.SendSheetParameter(sheetParam); if(strResult!="paramNameOK") { throw new Exception("Should be paramNameOK."); } retVal+="SendSheetParameter: Passed.\r\n"; //SendSheetWithFields Sheet sheet=new Sheet(); sheet.SheetFields=new List<SheetField>(); sheet.Parameters=new List<SheetParameter>(); SheetField field=new SheetField(); field.FieldName="FieldNameGreen"; sheet.SheetFields.Add(field); strResult=WebServiceTests.SendSheetWithFields(sheet); if(strResult!="fieldOK") { throw new Exception("Should be fieldOK."); } retVal+="SendSheetWithFields: Passed.\r\n"; //SendSheetDefWithFields SheetDef sheetdef=new SheetDef(); sheetdef.SheetFieldDefs=new List<SheetFieldDef>(); sheetdef.Parameters=new List<SheetParameter>(); SheetFieldDef fielddef=new SheetFieldDef(); fielddef.FieldName="FieldNameTeal"; sheetdef.SheetFieldDefs.Add(fielddef); strResult=WebServiceTests.SendSheetDefWithFieldDefs(sheetdef); if(strResult!="fielddefOK") { throw new Exception("Should be fielddefOK."); } retVal+="SendSheetDefWithFieldDefs: Passed.\r\n"; //TimeSpanNeg TimeSpan tspan=WebServiceTests.GetTimeSpan(); if(tspan!=new TimeSpan(1,0,0)) { throw new Exception("Should be 1 hour."); } retVal+="GetTimeSpan: Passed.\r\n"; //GetStringContainingCR strResult=WebServiceTests.GetStringContainingCR(); //strResult=strResult.Replace("\\r","\r"); if(strResult!="Line1\r\nLine2") { throw new Exception("Should be Line1\r\nLine2"); } retVal+="GetStringContainingCR: Passed.\r\n"; /* //GetListTasksContainingCR Task task=WebServiceTests.GetListTasksContainingCR()[0]; if(task.Descript!="Line1\r\nLine2") { throw new Exception("Should be Line1\r\nLine2"); } retVal+="GetListTasksContainingCR: Passed.\r\n";*/ return retVal; }
private static int CompareSheetFieldNames(SheetField input1,SheetField input2) { if(Convert.ToInt32(input1.FieldName.Remove(0,8)) < Convert.ToInt32(input2.FieldName.Remove(0,8))) { return -1; } if(Convert.ToInt32(input1.FieldName.Remove(0,8)) > Convert.ToInt32(input2.FieldName.Remove(0,8))) { return 1; } return 0; }