Ejemplo n.º 1
0
		public QueryObject AddQuery(DataTable query,string title,string columnNameToSplitOn,SplitByKind splitByKind,int queryGroup,bool isCentered,Dictionary<long,string> dictDefNames,Font font) {
			QueryObject queryObj=new QueryObject(query,title,columnNameToSplitOn,splitByKind,queryGroup,isCentered,null,dictDefNames,font);
			_reportObjects.Add(queryObj);
			return queryObj;
		}
Ejemplo n.º 2
0
		public QueryObject DeepCopyQueryObject() {
			QueryObject queryObj=new QueryObject();
			queryObj.Name=this.Name;//Doesn't need to be a deep copy.
			queryObj.SectionName=this.SectionName;//Doesn't need to be a deep copy.
			queryObj.ReportObjectKind=this.ReportObjectKind;//Doesn't need to be a deep copy.
			queryObj._sections=this._sections;//Doesn't need to be a deep copy.
			queryObj._arrDataFields=this._arrDataFields;//Doesn't need to be a deep copy.
			queryObj._queryGroupValue=this._queryGroupValue;//Doesn't need to be a deep copy.
			queryObj._isCentered=this._isCentered;//Doesn't need to be a deep copy.
			queryObj._queryWidth=this._queryWidth;//Doesn't need to be a deep copy.
			queryObj._suppressHeaders=this._suppressHeaders;//Doesn't need to be a deep copy.
			queryObj._columnNameToSplitOn=this._columnNameToSplitOn;//Doesn't need to be a deep copy.
			queryObj._splitByKind=this._splitByKind;//Doesn't need to be a deep copy.
			queryObj.IsPrinted=this.IsPrinted;//Doesn't need to be a deep copy.
			queryObj.SummaryOrientation=this.SummaryOrientation;//Doesn't need to be a deep copy.
			queryObj.SummaryGroups=this.SummaryGroups;//Doesn't need to be a deep copy.
			queryObj._isLastSplit=this._isLastSplit;//Doesn't need to be a deep copy.
			queryObj._rowHeightValues=new List<int>();
			queryObj._isNegativeSummary=this._isNegativeSummary;
			for(int i=0;i<this._rowHeightValues.Count;i++) {
				queryObj._rowHeightValues.Add(this._rowHeightValues[i]);
			}
			ReportObjectCollection reportObjectsNew=new ReportObjectCollection();
			for(int i=0;i<this._reportObjects.Count;i++) {
				reportObjectsNew.Add(_reportObjects[i].DeepCopyReportObject());
			}
			queryObj._reportObjects=reportObjectsNew;
			//queryObj._query=this._query;
			queryObj._reportTable=new DataTable();
			//We only care about column headers at this point.  There is no easy way to copy an entire DataTable.
			for(int i=0;i<this.ReportTable.Columns.Count;i++) {
				queryObj._reportTable.Columns.Add(new DataColumn(this.ReportTable.Columns[i].ColumnName));
			}
			queryObj._exportTable=new DataTable();
			//We only care about column headers at this point.  There is no easy way to copy an entire DataTable.
			for(int i=0;i<this._exportTable.Columns.Count;i++) {
				queryObj._exportTable.Columns.Add(new DataColumn(this._exportTable.Columns[i].ColumnName));
			}
			List<string> enumNamesNew=new List<string>();
			if(this._listEnumNames!=null) {
				for(int i=0;i<this._listEnumNames.Count;i++) {
					enumNamesNew.Add(this._listEnumNames[i]);
				}
			}
			queryObj._listEnumNames=enumNamesNew;
			Dictionary<long,string> defNamesNew=new Dictionary<long,string>();
			if(this._dictDefNames!=null) {
				foreach(long defNum in _dictDefNames.Keys) {
					defNamesNew.Add(defNum,this._dictDefNames[defNum]);
				}
			}
			queryObj._dictDefNames=defNamesNew;
			return queryObj;
		}
Ejemplo n.º 3
0
		public QueryObject AddQuery(DataTable query,string title,string columnNameToSplitOn,SplitByKind splitByKind,int queryGroup,bool isCentered,List<string> enumNames,Font font) {
			QueryObject queryObj=new QueryObject(query,title,columnNameToSplitOn,splitByKind,queryGroup,isCentered,enumNames,null,font);
			_reportObjects.Add(queryObj);
			return queryObj;
		}
Ejemplo n.º 4
0
		public QueryObject AddQuery(DataTable query,string title,string columnNameToSplitOn,SplitByKind splitByKind,int queryGroup,bool isCentered) {
			QueryObject queryObj=new QueryObject(query,title,columnNameToSplitOn,splitByKind,queryGroup,isCentered);
			_reportObjects.Add(queryObj);
			return queryObj;
		}
Ejemplo n.º 5
0
		///<summary>Prints sections inside a QueryObject</summary>
		private void PrintQueryObjectSection(QueryObject queryObj,Graphics g,Section section,int xPos,int yPos) {
			section.Height=0;
			ReportObject textObject;
			ReportObject fieldObject;
			ReportObject lineObject;
			ReportObject boxObject;
			string rawText="";//the raw text for a given field as taken from the database
			string displayText="";//The formatted text to print
			string prevDisplayText="";//The formatted text of the previous row. Used to test suppress dupl.	
			StringFormat strFormat;//used each time text is drawn to handle alignment issues
			int yPosAdd=0;
			if(queryObj.SuppressIfDuplicate
				&& section.Kind==AreaSectionKind.GroupTitle && rowsPrinted>0) 
			{
				return;//Only print the group title for each query object once.
			}
			//loop through each row in the table and make sure that the row can fit.  If it can fit, print it.  Otherwise go to next page.
			for(int i=rowsPrinted;i<queryObj.ReportTable.Rows.Count;i++) {
				//Figure out the current row height
				if(section.Name=="Detail" && queryObj.RowHeightValues[i]>_heightRemaining) {
					_heightRemaining=0;
					return;
				}
				//Find the Group Header height to see if printing at least one row is possible.
				if(section.Name=="Group Title") {
					int titleHeight=0;
					int headerHeight=0;
					foreach(ReportObject reportObject in queryObj.ReportObjects) {
						if(reportObject.SectionName=="Group Title") {
							titleHeight+=reportObject.Size.Height;
						}
						else if(reportObject.SectionName=="Group Header" && reportObject.Size.Height>headerHeight) {
							headerHeight=reportObject.Size.Height;
						}
					}
					//This is a new table and we want to know if we can print the first row
					if(titleHeight+headerHeight+queryObj.RowHeightValues[0]>_heightRemaining) {
						_heightRemaining=0;
						return;
					}
				}
				//Find the Group Footer height to see if printing the last row should happen on another page.
				if(section.Name=="Detail" && rowsPrinted==queryObj.ReportTable.Rows.Count-1) {
					int groupFooterHeight=0;
					foreach(ReportObject reportObject in queryObj.ReportObjects) {
						if(reportObject.SectionName=="Group Footer" && reportObject.Name.Contains("GroupSummaryText")) {
							groupFooterHeight+=reportObject.Size.Height+reportObject.OffSetY;
						}
						if(reportObject.SectionName=="Group Footer" && reportObject.Name.Contains("GroupSummaryLabel") 
							&& (reportObject.SummaryOrientation==SummaryOrientation.North || reportObject.SummaryOrientation==SummaryOrientation.South)) {
							groupFooterHeight+=reportObject.Size.Height;
						}
					}
					//See if we can print the Group Footer and the Last row
					if(groupFooterHeight+queryObj.RowHeightValues[queryObj.ReportTable.Rows.Count-1]>_heightRemaining) {
						_heightRemaining=0;
						return;
					}
				}
				int greatestObjectHeight=0;
				int groupTitleHeight=0;
				//Now figure out if anything in the header, footer, or title sections can still fit on the page
				foreach(ReportObject reportObject in queryObj.ReportObjects) {
					if(reportObject.SectionName!=section.Name) {
						continue;
					}
					if(reportObject.Size.Height>_heightRemaining) {
						_heightRemaining=0;
						return;
					}
					if(reportObject.SectionName=="Group Footer" && reportObject.Name.Contains("GroupSummary")) {
						if(!queryObj.IsLastSplit) {
							continue;
						}
						if(reportObject.Name.Contains("GroupSummaryLabel")) {
							yPos+=reportObject.OffSetY;
						}
						if(reportObject.Name.Contains("GroupSummaryText")) {
							if(reportObject.SummaryOperation==SummaryOperation.Sum) {
								reportObject.StaticText=GetGroupSummaryValue(reportObject.DataField,reportObject.SummaryGroups,reportObject.SummaryOperation).ToString("c");
							}
							else if(reportObject.SummaryOperation==SummaryOperation.Count) {
								reportObject.StaticText=GetGroupSummaryValue(reportObject.DataField,reportObject.SummaryGroups,reportObject.SummaryOperation).ToString();
							}
							int width=(int)g.MeasureString(reportObject.StaticText,reportObject.Font).Width+2;
							int height=(int)g.MeasureString(reportObject.StaticText,reportObject.Font).Height+2;
							if(width<queryObj.GetObjectByName(reportObject.SummarizedField+"Header").Size.Width) {
								width=queryObj.GetObjectByName(reportObject.SummarizedField+"Header").Size.Width;
							}
							reportObject.Size=new Size(width,height);
						}
					}
					if(section.Name=="Group Title" && rowsPrinted>0 && reportObject.Name=="Initial Group Title") {
						continue;
					}
					if(section.Name=="Group Footer" && reportObject.SummaryOrientation==SummaryOrientation.South) {
						ReportObject summaryField=queryObj.GetObjectByName(reportObject.DataField+"Footer");
						yPos+=summaryField.Size.Height;
					}
					if(reportObject.ReportObjectKind==ReportObjectKind.TextObject) {
						textObject=reportObject;
						strFormat=ReportObject.GetStringFormatAlignment(textObject.ContentAlignment);
						RectangleF layoutRect=new RectangleF(xPos+textObject.Location.X+textObject.OffSetX
							,yPos+textObject.Location.Y+textObject.OffSetY
							,textObject.Size.Width,textObject.Size.Height);
						if(textObject.IsUnderlined) {
							g.DrawString(textObject.StaticText,new Font(textObject.Font.FontFamily,textObject.Font.Size,textObject.Font.Style|FontStyle.Underline),Brushes.Black,layoutRect,strFormat);
						}
						else {
							g.DrawString(textObject.StaticText,textObject.Font,Brushes.Black,layoutRect,strFormat);
						}
						if(greatestObjectHeight<textObject.Size.Height) {
							greatestObjectHeight=textObject.Size.Height;
						}
						groupTitleHeight+=textObject.Size.Height;
						if(section.Name=="Group Title") {
							yPos+=textObject.Size.Height;
						}
						if(section.Name=="Group Footer" 
							&& ((reportObject.SummaryOrientation==SummaryOrientation.North || reportObject.SummaryOrientation==SummaryOrientation.South)
								|| (reportObject.Name.Contains("GroupSummaryText")))) 
						{
							yPosAdd+=textObject.Size.Height;
							yPos+=textObject.Size.Height;
						}
					}
					else if(reportObject.ReportObjectKind==ReportObjectKind.BoxObject) {
						boxObject=reportObject;
						int x1=xPos+boxObject.OffSetX;
						int x2=xPos-boxObject.OffSetX;
						int y1=yPos+boxObject.OffSetY;
						int y2=yPos-boxObject.OffSetY;
						int maxHorizontalLength=1100;
						if(!MyReport.IsLandscape) {
							maxHorizontalLength=850;
						}
						x2+=maxHorizontalLength;
						y2+=queryObj.GetSectionHeight(boxObject.SectionName);
						g.DrawRectangle(new Pen(boxObject.ForeColor,boxObject.FloatLineThickness),x1,y1,x2-x1,y2-y1);
						if(greatestObjectHeight<boxObject.Size.Height) {
							greatestObjectHeight=boxObject.Size.Height;
						}
						groupTitleHeight+=boxObject.Size.Height;
					}
					else if(reportObject.ReportObjectKind==ReportObjectKind.LineObject) {
						lineObject=reportObject;
						int length;
						int x=lineObject.OffSetX;
						int y=yPos+lineObject.OffSetY;
						int maxHorizontalLength=1100;
						if(!MyReport.IsLandscape) {
							maxHorizontalLength=850;
						}
						if(lineObject.LineOrientation==LineOrientation.Horizontal) {
							length=maxHorizontalLength*lineObject.IntLinePercent/100;
							if(lineObject.LinePosition==LinePosition.Bottom) {
								y+=queryObj.GetSectionHeight(lineObject.SectionName);
							}
							else if(lineObject.LinePosition==LinePosition.Top) {
								//Do Nothing Here
							}
							else if(lineObject.LinePosition==LinePosition.Center) {
								y+=(queryObj.GetSectionHeight(lineObject.SectionName)/2);
							}
							else {
								continue;
							}
							x+=(maxHorizontalLength/2)-(length/2);
							g.DrawLine(new Pen(reportObject.ForeColor,reportObject.FloatLineThickness),x,y,x+length,y);
						}
						else if(lineObject.LineOrientation==LineOrientation.Vertical) {
							length=queryObj.GetSectionHeight(lineObject.SectionName)*lineObject.IntLinePercent/100;
							if(lineObject.LinePosition==LinePosition.Left) {
								//Do Nothing Here
							}
							else if(lineObject.LinePosition==LinePosition.Right) {
								x+=maxHorizontalLength;
							}
							else if(lineObject.LinePosition==LinePosition.Center) {
								x+=maxHorizontalLength/2;
							}
							else {
								continue;
							}
							y+=(queryObj.GetSectionHeight(lineObject.SectionName)/2)-(length/2);
							g.DrawLine(new Pen(reportObject.ForeColor,reportObject.FloatLineThickness),x,y,x,y+length);
						}
						if(greatestObjectHeight<lineObject.Size.Height) {
							greatestObjectHeight=lineObject.Size.Height;
						}
						groupTitleHeight+=lineObject.Size.Height;
					}
					else if(reportObject.ReportObjectKind==ReportObjectKind.FieldObject) {
						fieldObject=reportObject;
						RectangleF layoutRect;
						strFormat=ReportObject.GetStringFormatAlignment(fieldObject.ContentAlignment);
						if(fieldObject.FieldDefKind==FieldDefKind.DataTableField) {
							layoutRect=new RectangleF(xPos+fieldObject.Location.X,yPos+fieldObject.Location.Y,fieldObject.Size.Width,queryObj.RowHeightValues[i]);
							if(MyReport.HasGridLines()) {
								g.DrawRectangle(new Pen(Brushes.LightGray),Rectangle.Round(layoutRect));
							}
							rawText=queryObj.ReportTable.Rows
								[i][queryObj.ArrDataFields.IndexOf(fieldObject.DataField)].ToString();
							displayText=rawText;
							List<string> listString=GetDisplayString(displayText,prevDisplayText,fieldObject,i,queryObj);
							displayText=listString[0];
							prevDisplayText=listString[1];
							//suppress if duplicate:
							if(i>0 && fieldObject.SuppressIfDuplicate && displayText==prevDisplayText) {
								displayText="";
							}
						}
						else {
							layoutRect=new RectangleF(xPos+fieldObject.Location.X,yPos+fieldObject.Location.Y,fieldObject.Size.Width,fieldObject.Size.Height);
							displayText=fieldObject.GetSummaryValue(queryObj.ReportTable,queryObj.ArrDataFields.IndexOf(fieldObject.SummarizedField)).ToString(fieldObject.StringFormat);
						}
						g.DrawString(displayText,fieldObject.Font
						,new SolidBrush(fieldObject.ForeColor),new RectangleF(layoutRect.X+1,layoutRect.Y+1,layoutRect.Width-1,layoutRect.Height-1),strFormat);
						yPosAdd=(int)layoutRect.Height;
					}
				}
				if(section.Kind==AreaSectionKind.GroupFooter) {
					yPosAdd+=20;//Added to give a buffer between split tables.
					section.Height+=yPosAdd;
					_heightRemaining-=section.Height;
					yPos+=yPosAdd;
					break;
				}
				else if(section.Kind==AreaSectionKind.GroupTitle) {
					section.Height+=groupTitleHeight;
					_heightRemaining-=section.Height;
					break;
				}
				else if(section.Kind==AreaSectionKind.GroupHeader) {
					section.Height=greatestObjectHeight;
					_heightRemaining-=section.Height;
					break;
				}
				if(section.Kind==AreaSectionKind.Detail) {
					rowsPrinted++;
					yPos+=yPosAdd;
					_heightRemaining-=yPosAdd;
					section.Height+=yPosAdd;
				}
			}
			if(rowsPrinted==queryObj.ReportTable.Rows.Count) {
				rowsPrinted=0;
				queryObj.IsPrinted=true;
			}
		}
Ejemplo n.º 6
0
		private List<string> GetDisplayString(string rawText,string prevDisplayText,ReportObject reportObject,int i,QueryObject queryObj,bool isExport) {
			string displayText="";
			List<string> retVals=new List<string>();
			DataTable dt=queryObj.ReportTable;
			//For exporting, we need to use the ExportTable which is the data that is visible to the user.  Using ReportTable would show raw query data (potentially different than what the user sees).
			if(isExport) {
				dt=queryObj.ExportTable;
			}
			if(reportObject.FieldValueType==FieldValueType.Age) {
				displayText=Patients.AgeToString(Patients.DateToAge(PIn.Date(rawText)));//(fieldObject.FormatString);
			}
			else if(reportObject.FieldValueType==FieldValueType.Boolean) {
				if(PIn.Bool(dt.Rows[i][queryObj.ArrDataFields.IndexOf(reportObject.DataField)].ToString())) {
					displayText="X";
				}
				else {
					displayText="";
				}
				if(i>0 && reportObject.SuppressIfDuplicate) {
					prevDisplayText=PIn.Bool(dt.Rows[i-1][queryObj.ArrDataFields.IndexOf(reportObject.DataField)].ToString()).ToString();
				}
			}
			else if(reportObject.FieldValueType==FieldValueType.Date) {
				displayText=PIn.DateT(dt.Rows[i][queryObj.ArrDataFields.IndexOf(reportObject.DataField)].ToString()).ToString(reportObject.StringFormat);
				if(i>0 && reportObject.SuppressIfDuplicate) {
					prevDisplayText=PIn.DateT(dt.Rows[i-1][queryObj.ArrDataFields.IndexOf(reportObject.DataField)].ToString()).ToString(reportObject.StringFormat);
				}
			}
			else if(reportObject.FieldValueType==FieldValueType.Integer) {
				displayText=PIn.Long(dt.Rows[i][queryObj.ArrDataFields.IndexOf(reportObject.DataField)].ToString()).ToString(reportObject.StringFormat);
				if(i>0 && reportObject.SuppressIfDuplicate) {
					prevDisplayText=PIn.Long(dt.Rows[i-1][queryObj.ArrDataFields.IndexOf(reportObject.DataField)].ToString()).ToString(reportObject.StringFormat);
				}
			}
			else if(reportObject.FieldValueType==FieldValueType.Number) {
				displayText=PIn.Double(dt.Rows[i][queryObj.ArrDataFields.IndexOf(reportObject.DataField)].ToString()).ToString(reportObject.StringFormat);
				if(i>0 && reportObject.SuppressIfDuplicate) {
					prevDisplayText=PIn.Double(dt.Rows[i-1][queryObj.ArrDataFields.IndexOf(reportObject.DataField)].ToString()).ToString(reportObject.StringFormat);
				}
			}
			else if(reportObject.FieldValueType==FieldValueType.String) {
				displayText=rawText;
				if(i>0 && reportObject.SuppressIfDuplicate) {
					prevDisplayText=dt.Rows[i-1][queryObj.ArrDataFields.IndexOf(reportObject.DataField)].ToString();
				}
			}
			retVals.Add(displayText);
			retVals.Add(prevDisplayText);
			return retVals;
		}
Ejemplo n.º 7
0
		private List<string> GetDisplayString(string rawText,string prevDisplayText,ReportObject reportObject,int i,QueryObject queryObj) {
			return GetDisplayString(rawText,prevDisplayText,reportObject,i,queryObj,false);
		}