public Bitmap RealtimeMorningInfoStat_TeacherGraphPrint(string getDept, PanelControl pControl) { using (RealtimeInfo_TeacherDataAccess realTimeInfo_TeacherDataAccess = new RealtimeInfo_TeacherDataAccess()) { try { DataSet dsDutyID = realTimeInfo_TeacherDataAccess.GetDutyID(DateTime.Now.ToString("HH:mm:ss")); int teaAttOnTimeNumbersInDuty = 0; int teaAttNotOnTimeNumbersInDuty = 0; int teaAttNumbersInDuty = 0; if (dsDutyID.Tables[0] != null && dsDutyID.Tables[0].Rows.Count > 0) { foreach (DataRow dutyRow in dsDutyID.Tables[0].Rows) { teaAttNumbersInDuty += realTimeInfo_TeacherDataAccess.GetTeaNumbers(DateTime.Now.DayOfWeek.ToString(), dutyRow[0].ToString(), getDept); realTimeInfo_TeacherDataAccess.GetTeaWorkingNumbers(dutyRow[0].ToString(), ref teaAttOnTimeNumbersInDuty, ref teaAttNotOnTimeNumbersInDuty, getDept, DateTime.Now.Date); } } int noDutyTotal = 0; int noDutyAttend = 0; int noDutyLeave = 0; realTimeInfo_TeacherDataAccess.GetTeacherRealTimeInfoWithNoDuty(getDept, DateTime.Now.DayOfWeek.ToString(), ref noDutyTotal, ref noDutyAttend, ref noDutyLeave); teaAttNumbersInDuty += noDutyTotal; teaAttOnTimeNumbersInDuty += noDutyAttend; double onTimePer = (double)teaAttOnTimeNumbersInDuty / (double)teaAttNumbersInDuty; double notOnTimePer = (double)teaAttNotOnTimeNumbersInDuty / (double)teaAttNumbersInDuty; double absPer = 1 - (((double)teaAttOnTimeNumbersInDuty + (double)teaAttNotOnTimeNumbersInDuty) / (double)teaAttNumbersInDuty); zedGraph_RealtimeMorningInfoStatTeacher = new ZedGraphControl(); pControl.Controls.Clear(); pControl.Controls.Add(zedGraph_RealtimeMorningInfoStatTeacher); zedGraph_RealtimeMorningInfoStatTeacher.Dock = DockStyle.Fill; GraphPane myPane = zedGraph_RealtimeMorningInfoStatTeacher.GraphPane; if (getDept.Equals("")) { myPane.Title = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString() + "全体教职工上班情况实时统计图\n" + "统计日期: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } else { myPane.Title = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString() + getDept + "部教师上班情况实时统计图\n" + "统计日期: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } double[] statusVal = { onTimePer, notOnTimePer, absPer }; string[] statusLabel = { "准时", "迟到", "缺席" }; myPane.PaneFill = new Fill(Color.Cornsilk); myPane.AxisFill = new Fill(Color.Cornsilk); myPane.Legend.Position = LegendPos.Right; myPane.Legend.FontSpec.Size = 12; 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[2]).Displacement = .1; 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); zedGraph_RealtimeMorningInfoStatTeacher.IsShowContextMenu = false; zedGraph_RealtimeMorningInfoStatTeacher.IsEnableZoom = false; zedGraph_RealtimeMorningInfoStatTeacher.AxisChange(); return(myPane.Image); } catch (Exception e) { Util.WriteLog(e.Message, Util.EXCEPTION_LOG_TITLE); return(null); } } }
public DataSet BuildRealtimeMorningInfo(string getDept) { using (RealtimeInfo_TeacherDataAccess realTimeInfo_TeacherDataAccess = new RealtimeInfo_TeacherDataAccess()) { try { DataSet buildRealtimeTeacher = realTimeInfo_TeacherDataAccess.GetTeaDeptInfo(getDept); DataSet dsDutyID = realTimeInfo_TeacherDataAccess.GetDutyID(DateTime.Now.ToString("HH:mm:ss")); int teaAttNumbersInDutyAll = 0; int teaAttOnTimeNumbersInDutyAll = 0; int teaAttNotOnTimNumbersInDutyAll = 0; buildRealtimeTeacher.Tables[0].Columns.AddRange(new DataColumn[] { new DataColumn("info_onTime"), new DataColumn("info_notOnTime"), new DataColumn("info_shouldAtt"), new DataColumn("info_haveAtt"), new DataColumn("info_absence"), new DataColumn("info_attPer") }); for (int row = 0; row < buildRealtimeTeacher.Tables[0].Rows.Count; row++) { int teaAttNumbersInDuty = 0; int teaAttOnTimeNumbersInDuty = 0; int teaAttNotOnTimeNumbersInDuty = 0; if (dsDutyID.Tables[0] != null && dsDutyID.Tables[0].Rows.Count > 0) { foreach (DataRow dutyRow in dsDutyID.Tables[0].Rows) { teaAttNumbersInDuty += realTimeInfo_TeacherDataAccess.GetTeaNumbers(DateTime.Now.DayOfWeek.ToString(), dutyRow[0].ToString(), buildRealtimeTeacher.Tables[0].Rows[row][0].ToString()); realTimeInfo_TeacherDataAccess.GetTeaWorkingNumbers(dutyRow[0].ToString(), ref teaAttOnTimeNumbersInDuty, ref teaAttNotOnTimeNumbersInDuty, buildRealtimeTeacher.Tables[0].Rows[row][0].ToString(), DateTime.Now.Date); } int noDutyTotal = 0; int noDutyAttend = 0; int noDutyLeave = 0; realTimeInfo_TeacherDataAccess.GetTeacherRealTimeInfoWithNoDuty(buildRealtimeTeacher.Tables[0].Rows[row][0].ToString(), DateTime.Now.DayOfWeek.ToString(), ref noDutyTotal, ref noDutyAttend, ref noDutyLeave); // buildRealtimeTeacher.Tables[0].Rows[row][1] = attend; //准时 // buildRealtimeTeacher.Tables[0].Rows[row][2] = 0; //迟到 // buildRealtimeTeacher.Tables[0].Rows[row][3] = total; //应到 // buildRealtimeTeacher.Tables[0].Rows[row][4] = attend; //实到 // buildRealtimeTeacher.Tables[0].Rows[row][5] = total - attend; //缺席 // buildRealtimeTeacher.Tables[0].Rows[row][6] = total == 0 ? "0.00%" : ((double)attend/(double)total).ToString("0.00%"); //出勤率 teaAttNumbersInDuty += noDutyTotal; teaAttOnTimeNumbersInDuty += noDutyAttend; buildRealtimeTeacher.Tables[0].Rows[row][1] = teaAttOnTimeNumbersInDuty + " (" + ((double)teaAttOnTimeNumbersInDuty / (double)teaAttNumbersInDuty).ToString("0.00%") + ")"; buildRealtimeTeacher.Tables[0].Rows[row][2] = teaAttNotOnTimeNumbersInDuty + " (" + ((double)teaAttNotOnTimeNumbersInDuty / (double)teaAttNumbersInDuty).ToString("0.00%") + ")"; buildRealtimeTeacher.Tables[0].Rows[row][3] = teaAttNumbersInDuty; buildRealtimeTeacher.Tables[0].Rows[row][4] = (teaAttOnTimeNumbersInDuty + teaAttNotOnTimeNumbersInDuty); buildRealtimeTeacher.Tables[0].Rows[row][5] = (teaAttNumbersInDuty - teaAttOnTimeNumbersInDuty - teaAttNotOnTimeNumbersInDuty) + " (" + (1 - ((double)teaAttOnTimeNumbersInDuty + (double)teaAttNotOnTimeNumbersInDuty) / teaAttNumbersInDuty).ToString("0.00%") + ")"; buildRealtimeTeacher.Tables[0].Rows[row][6] = (((double)teaAttOnTimeNumbersInDuty + (double)teaAttNotOnTimeNumbersInDuty) / teaAttNumbersInDuty).ToString("0.00%"); buildRealtimeTeacher.Tables[0].Rows[row][1] = buildRealtimeTeacher.Tables[0].Rows[row][1].ToString().Replace("(非数字)", string.Empty); buildRealtimeTeacher.Tables[0].Rows[row][2] = buildRealtimeTeacher.Tables[0].Rows[row][2].ToString().Replace("(非数字)", string.Empty); buildRealtimeTeacher.Tables[0].Rows[row][3] = buildRealtimeTeacher.Tables[0].Rows[row][3].ToString().Replace("(非数字)", string.Empty); buildRealtimeTeacher.Tables[0].Rows[row][4] = buildRealtimeTeacher.Tables[0].Rows[row][4].ToString().Replace("(非数字)", string.Empty); buildRealtimeTeacher.Tables[0].Rows[row][5] = buildRealtimeTeacher.Tables[0].Rows[row][5].ToString().Replace("(非数字)", string.Empty); buildRealtimeTeacher.Tables[0].Rows[row][6] = buildRealtimeTeacher.Tables[0].Rows[row][6].ToString().Replace("非数字", "0.00%"); teaAttNumbersInDutyAll += teaAttNumbersInDuty; teaAttOnTimeNumbersInDutyAll += teaAttOnTimeNumbersInDuty; teaAttNotOnTimNumbersInDutyAll += teaAttNotOnTimeNumbersInDuty; } else { int noDutyTotal = 0; int noDutyAttend = 0; int noDutyLeave = 0; realTimeInfo_TeacherDataAccess.GetTeacherRealTimeInfoWithNoDuty(buildRealtimeTeacher.Tables[0].Rows[row][0].ToString(), DateTime.Now.DayOfWeek.ToString(), ref noDutyTotal, ref noDutyAttend, ref noDutyLeave); buildRealtimeTeacher.Tables[0].Rows[row][1] = noDutyAttend; //准时 buildRealtimeTeacher.Tables[0].Rows[row][2] = 0; //迟到 buildRealtimeTeacher.Tables[0].Rows[row][3] = noDutyTotal; //应到 buildRealtimeTeacher.Tables[0].Rows[row][4] = noDutyAttend; //实到 buildRealtimeTeacher.Tables[0].Rows[row][5] = noDutyTotal - noDutyAttend; //缺席 buildRealtimeTeacher.Tables[0].Rows[row][6] = noDutyTotal == 0 ? "0.00%" : ((double)noDutyAttend / (double)noDutyTotal).ToString("0.00%"); //出勤率 teaAttNumbersInDutyAll += noDutyTotal; teaAttOnTimeNumbersInDutyAll += noDutyAttend; teaAttNotOnTimNumbersInDutyAll = 0; } if (row == buildRealtimeTeacher.Tables[0].Rows.Count - 1) { DataRow newRow = buildRealtimeTeacher.Tables[0].NewRow(); newRow[0] = "[总计]"; if (teaAttNumbersInDutyAll == 0) { newRow[1] = "--"; newRow[2] = "--"; newRow[3] = "--"; newRow[4] = "--"; newRow[5] = "--"; newRow[6] = "--"; } else { newRow[1] = teaAttOnTimeNumbersInDutyAll + " (" + ((double)teaAttOnTimeNumbersInDutyAll / (double)teaAttNumbersInDutyAll).ToString("0.00%") + ")"; newRow[2] = teaAttNotOnTimNumbersInDutyAll + " (" + ((double)teaAttNotOnTimNumbersInDutyAll / (double)teaAttNumbersInDutyAll).ToString("0.00%") + ")"; newRow[3] = teaAttNumbersInDutyAll; newRow[4] = (teaAttOnTimeNumbersInDutyAll + teaAttNotOnTimNumbersInDutyAll); newRow[5] = (teaAttNumbersInDutyAll - teaAttOnTimeNumbersInDutyAll - teaAttNotOnTimNumbersInDutyAll) + " (" + (1 - ((double)teaAttOnTimeNumbersInDutyAll + (double)teaAttNotOnTimNumbersInDutyAll) / teaAttNumbersInDutyAll).ToString("0.00%") + ")"; newRow[6] = (((double)teaAttOnTimeNumbersInDutyAll + (double)teaAttNotOnTimNumbersInDutyAll) / teaAttNumbersInDutyAll).ToString("0.00%"); newRow[1] = newRow[1].ToString().Replace("(非数字)", string.Empty); newRow[2] = newRow[2].ToString().Replace("(非数字)", string.Empty); newRow[3] = newRow[3].ToString().Replace("(非数字)", string.Empty); newRow[4] = newRow[4].ToString().Replace("(非数字)", string.Empty); newRow[5] = newRow[5].ToString().Replace("(非数字)", string.Empty); newRow[6] = newRow[6].ToString().Replace("非数字", "0.00%"); } buildRealtimeTeacher.Tables[0].Rows.Add(newRow); break; } } return(buildRealtimeTeacher); } catch (Exception e) { Util.WriteLog(e.Message, Util.EXCEPTION_LOG_TITLE); return(null); } } }