public Bitmap Pie_InfoStat(string getGrade,string getClass,GroupControl gControl) { using ( StudentAttendCalcDataAccess stuAttCalcDataAccess = new StudentAttendCalcDataAccess() ) { try { stuAttCalcDataAccess.DoAttendCalcForClass(getGrade,getClass,BegDate.ToString("yyyy-MM-dd"),EndDate.ToString("yyyy-MM-dd"),"健康"); double healthPer = (double)stuAttCalcDataAccess.StateAmount/((double)stuAttCalcDataAccess.StuAmount*SetAttendDays())*100; stuAttCalcDataAccess.DoAttendCalcForClass(getGrade,getClass,BegDate.ToString("yyyy-MM-dd"),EndDate.ToString("yyyy-MM-dd"),"服药"); double illPer = (double)stuAttCalcDataAccess.StateAmount/((double)stuAttCalcDataAccess.StuAmount*SetAttendDays())*100; stuAttCalcDataAccess.DoAttendCalcForClass(getGrade,getClass,BegDate.ToString("yyyy-MM-dd"),EndDate.ToString("yyyy-MM-dd"),"观察"); double watchPer = (double)stuAttCalcDataAccess.StateAmount/((double)stuAttCalcDataAccess.StuAmount*SetAttendDays())*100; // stuAttCalcDataAccess.DoAttendCalcForClass(getGrade,getClass,BegDate.ToString("yyyy-MM-dd"),EndDate.ToString("yyyy-MM-dd"),"缺席"); // double absPer = (double)stuAttCalcDataAccess.StateAmount/((double)stuAttCalcDataAccess.StuAmount*SetAttendDays())*100; double absPer = 100-healthPer-illPer-watchPer; // Graphics gra = gControl.CreateGraphics(); // GraphPane myPane = new GraphPane( new Rectangle( 0, 0, gControl.Width, gControl.Height ), // "11", "11", "11" ); zedGraph_StuPiePrint = new ZedGraphControl(); gControl.Controls.Clear(); gControl.Controls.Add(zedGraph_StuPiePrint); zedGraph_StuPiePrint.Dock = DockStyle.Fill; GraphPane myPane = zedGraph_StuPiePrint.GraphPane; if ( getGrade.Equals("") ) myPane.Title = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString() + "全年级晨检信息统计图\n"+"统计日期: " + BegDate.ToString("yyyy.MM.dd") + " 至 " + EndDate.ToString("yyyy.MM.dd"); else if ( getClass.Equals("") ) myPane.Title = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString() + new StuInfoDataAccess().GetGradeList("",getGrade).Tables[0].Rows[0][1].ToString() + "晨检信息统计图\n"+"统计日期: " + BegDate.ToString("yyyy.MM.dd") + " 至 " + EndDate.ToString("yyyy.MM.dd"); else myPane.Title = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString() + new RealtimeInfoDataAccess().setClassList("",getClass,getGrade).Tables[0].Rows[0][1].ToString() + "晨检信息统计图\n"+"统计日期: " + BegDate.ToString("yyyy.MM.dd") + " 至 " + EndDate.ToString("yyyy.MM.dd"); double[] statusVal = { healthPer, watchPer, absPer, illPer }; string[] statusLabel = { "健康", "观察", "缺席", "服药" }; myPane.PaneFill = new Fill( Color.Cornsilk ); myPane.AxisFill = new Fill( Color.Cornsilk ); myPane.Legend.Position = LegendPos.Right ; myPane.Legend.FontSpec.Size = 14; PieItem [] slices = new PieItem[statusVal.Length] ; slices = myPane.AddPieSlices ( statusVal, statusLabel ) ; ((PieItem)slices[0]).LabelType = PieLabelType.Percent ; ((PieItem)slices[0]).LabelDetail.FontSpec.Size = 14; ((PieItem)slices[1]).LabelType = PieLabelType.Percent ; ((PieItem)slices[1]).LabelDetail.FontSpec.Size = 14; ((PieItem)slices[2]).LabelType = PieLabelType.Percent ; ((PieItem)slices[2]).LabelDetail.FontSpec.Size = 14; ((PieItem)slices[3]).LabelType = PieLabelType.Percent ; ((PieItem)slices[3]).LabelDetail.FontSpec.Size = 14; ((PieItem)slices[1]).Displacement = .2 ; ((PieItem)slices[2]).Displacement = .2 ; BoxItem box = new BoxItem( new RectangleF( 0F, 0F, 1F, 1F ), Color.Empty, Color.PeachPuff ); box.Location.CoordinateFrame = CoordType.AxisFraction; box.Border.IsVisible = false; box.Location.AlignH = AlignH.Left; box.Location.AlignV = AlignV.Top; box.ZOrder = ZOrder.E_BehindAxis; myPane.GraphItemList.Add( box ); // myPane.AxisChange(gra); // myPane.Draw(gra); // myPane.ReSize(gra,new RectangleF(150, 300, 800,600)); zedGraph_StuPiePrint.IsShowContextMenu = false; zedGraph_StuPiePrint.IsEnableZoom = false; zedGraph_StuPiePrint.AxisChange(); return myPane.Image; } catch(Exception e) { Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE); return null; } } }
//DataAccess的数据访问 public void SetStuAttendCalcForClass(string getGrade,string getClass,string getBegTime, string getEndTime,string getState) { BegDate = Convert.ToDateTime(getBegTime); EndDate = Convert.ToDateTime(getEndTime); using (StudentAttendCalcDataAccess stuAttendCalcDataAccess = new StudentAttendCalcDataAccess()) { stuAttendCalcDataAccess.DoAttendCalcForClass(getGrade,getClass,getBegTime,getEndTime,getState); StateAmountInDays = stuAttendCalcDataAccess.StateAmount; AllStateAmountInDays = stuAttendCalcDataAccess.AllStateAmount; StuAttendAmountInDays = stuAttendCalcDataAccess.StuAmount * SetAttendDays(); } }