public DataSet BuildRealtimeBackInfo(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 teaShouldLeaveAll = 0; int teaLeaveOnTimeNumbersInDutyAll = 0; int teaLeaveNotOnTimeNumbersInDutyAll = 0; buildRealtimeTeacher.Tables[0].Columns.AddRange(new DataColumn[]{new DataColumn("info_leaveOnTime"),new DataColumn("info_leaveNotOnTime"), new DataColumn("info_shouldLeave"),new DataColumn("info_remain"), new DataColumn("info_leavePer")}); for ( int row=0; row<buildRealtimeTeacher.Tables[0].Rows.Count; row++ ) { // int teaAttNumbersInDuty = 0; int teaAttOnTimeNumbersInDuty = 0; int teaAttNotOnTimeNumbersInDuty = 0; int teaLeaveOnTimeNumbersInDuty = 0; int teaLeaveNotOnTimeNumbersInDuty = 0; int teaShouldLeaveInDuty = 0; if ( 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); realTimeInfo_TeacherDataAccess.GetTeaLeaveNumbers(dutyRow[0].ToString(),ref teaLeaveOnTimeNumbersInDuty,ref teaLeaveNotOnTimeNumbersInDuty,buildRealtimeTeacher.Tables[0].Rows[row][0].ToString(),DateTime.Now.Date); } teaShouldLeaveInDuty = teaAttOnTimeNumbersInDuty + teaAttNotOnTimeNumbersInDuty; 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] = leave; //离开 // buildRealtimeTeacher.Tables[0].Rows[row][2] = 0; //早退 // buildRealtimeTeacher.Tables[0].Rows[row][3] = attend; //应离开 // buildRealtimeTeacher.Tables[0].Rows[row][4] = attend - leave; //剩余 // buildRealtimeTeacher.Tables[0].Rows[row][5] = attend == 0 ? "0.00%" : ((double)leave/(double)leave).ToString("0.00%"); //离开率 teaLeaveOnTimeNumbersInDuty += noDutyLeave; teaShouldLeaveInDuty += noDutyAttend; buildRealtimeTeacher.Tables[0].Rows[row][1] = teaLeaveOnTimeNumbersInDuty+" ("+((double)teaLeaveOnTimeNumbersInDuty/(double)teaShouldLeaveInDuty).ToString("0.00%")+")"; buildRealtimeTeacher.Tables[0].Rows[row][2] = teaLeaveNotOnTimeNumbersInDuty+" ("+((double)teaLeaveNotOnTimeNumbersInDuty/(double)teaShouldLeaveInDuty).ToString("0.00%")+")"; buildRealtimeTeacher.Tables[0].Rows[row][3] = teaShouldLeaveInDuty; //teaAttNumbersInDuty; buildRealtimeTeacher.Tables[0].Rows[row][4] = (teaShouldLeaveInDuty - teaLeaveOnTimeNumbersInDuty - teaLeaveNotOnTimeNumbersInDuty)+ " (" +(1-((double)teaLeaveOnTimeNumbersInDuty+(double)teaLeaveNotOnTimeNumbersInDuty)/(double)teaShouldLeaveInDuty).ToString("0.00%")+")"; buildRealtimeTeacher.Tables[0].Rows[row][5] = (((double)teaLeaveOnTimeNumbersInDuty + (double)teaLeaveNotOnTimeNumbersInDuty)/(double)teaShouldLeaveInDuty).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("非数字", "0.00%"); teaShouldLeaveAll += teaShouldLeaveInDuty; teaLeaveOnTimeNumbersInDutyAll += teaLeaveOnTimeNumbersInDuty; teaLeaveNotOnTimeNumbersInDutyAll += teaLeaveNotOnTimeNumbersInDuty; } 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] = noDutyLeave; //离开 buildRealtimeTeacher.Tables[0].Rows[row][2] = 0; //早退 buildRealtimeTeacher.Tables[0].Rows[row][3] = noDutyAttend; //应离开 buildRealtimeTeacher.Tables[0].Rows[row][4] = noDutyAttend - noDutyLeave; //剩余 buildRealtimeTeacher.Tables[0].Rows[row][5] = noDutyAttend == 0 ? "100%" : ((double)noDutyLeave/(double)noDutyAttend).ToString("0.00%"); //离开率 teaLeaveOnTimeNumbersInDutyAll += noDutyLeave; teaLeaveNotOnTimeNumbersInDutyAll = 0; teaShouldLeaveAll += noDutyAttend; } if ( row == buildRealtimeTeacher.Tables[0].Rows.Count - 1 ) { DataRow newRow = buildRealtimeTeacher.Tables[0].NewRow(); newRow[0] = "[总计]"; if ( teaShouldLeaveAll == 0 ) { newRow[1] = 0; newRow[2] = 0; newRow[3] = 0; newRow[4] = 0; newRow[5] = 0; } else { newRow[1] = teaLeaveOnTimeNumbersInDutyAll+" ("+((double)teaLeaveOnTimeNumbersInDutyAll/(double)teaShouldLeaveAll).ToString("0.00%")+")"; newRow[2] = teaLeaveNotOnTimeNumbersInDutyAll+" ("+((double)teaLeaveNotOnTimeNumbersInDutyAll/(double)teaShouldLeaveAll).ToString("0.00%")+")"; newRow[3] = teaShouldLeaveAll; newRow[4] = (teaShouldLeaveAll - teaLeaveOnTimeNumbersInDutyAll - teaLeaveNotOnTimeNumbersInDutyAll)+ " (" +(1-((double)teaLeaveOnTimeNumbersInDutyAll+(double)teaLeaveNotOnTimeNumbersInDutyAll)/(double)teaShouldLeaveAll).ToString("0.00%")+")"; newRow[5] = (((double)teaLeaveOnTimeNumbersInDutyAll+(double)teaLeaveNotOnTimeNumbersInDutyAll)/(double)teaShouldLeaveAll).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("非数字", "0.00%"); } buildRealtimeTeacher.Tables[0].Rows.Add(newRow); break; } } return buildRealtimeTeacher; } 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; } } }
public Bitmap RealtimeBackInfoStat_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 teaLeaveOnTimeNumbersInDuty = 0; int teaLeaveNotOnTimeNumbersInDuty = 0; int teaShouldLeaveInDuty = 0; if ( 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); realTimeInfo_TeacherDataAccess.GetTeaLeaveNumbers(dutyRow[0].ToString(),ref teaLeaveOnTimeNumbersInDuty,ref teaLeaveNotOnTimeNumbersInDuty,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); teaLeaveOnTimeNumbersInDuty += noDutyLeave; teaShouldLeaveInDuty = teaAttOnTimeNumbersInDuty + teaAttNotOnTimeNumbersInDuty + noDutyAttend; double onTimePer = (double)teaLeaveOnTimeNumbersInDuty/(double)teaShouldLeaveInDuty; double notOnTimePer = (double)teaLeaveNotOnTimeNumbersInDuty/(double)teaShouldLeaveInDuty; double remainPer = 1-(((double)teaLeaveOnTimeNumbersInDuty+(double)teaLeaveNotOnTimeNumbersInDuty)/(double)teaShouldLeaveInDuty); 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,remainPer }; 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[1]).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; } } }