public void WeekDataLoad() { //获取本周全矿安全状况 string textWeek = @"<br /><b>本周安全动态:</b><br /><br />"; //var YHdataWeek = from c in dc.Yhview // where (c.Pctime.Value >= System.DateTime.Today.AddDays(1 - (int)System.DateTime.Today.DayOfWeek) && c.Pctime.Value <= System.DateTime.Today) && c.Maindeptid == SessionBox.GetUserSession().DeptNumber // group c by c.Levelname into g // orderby g.Key // select new // { // YHLevel = g.Key, // YHnum = g.Count() // }; //var SWdataWeek = from c in dc.Getsanwei // where (c.Pctime.Value >= System.DateTime.Today.AddDays(1 - (int)System.DateTime.Today.DayOfWeek) && c.Pctime.Value <= System.DateTime.Today) && c.Dwid == SessionBox.GetUserSession().DeptNumber // group c by c.Levelname into g // select new // { // SWLevel = g.Key, // SWnum = g.Count() // }; var YHdataWeek = GetSafeInfo.GetMainLeaderYH(System.DateTime.Today.AddDays(1 - (int)System.DateTime.Today.DayOfWeek), System.DateTime.Today, SessionBox.GetUserSession().DeptNumber).Tables[0]; //var SWdataWeek = GetSafeInfo.GetMainLeaderSW(System.DateTime.Today.AddDays(1 - (int)System.DateTime.Today.DayOfWeek), System.DateTime.Today, SessionBox.GetUserSession().DeptNumber).Tables[0]; var SWdataWeek = from s in dc.Getsanwei where s.Pctime >= System.DateTime.Today.AddDays(1 - (int)System.DateTime.Today.DayOfWeek) && s.Pctime <= System.DateTime.Today && s.Dwid == SessionBox.GetUserSession().DeptNumber group s by s.Levelname into g select new { g.Key, swnum = g.Count() }; if (YHdataWeek.Rows.Count <= 0 && SWdataWeek.Count() <= 0) { textWeek += " 本周无安全动态!"; } else { if (YHdataWeek.Rows.Count > 0) { textWeek += "全矿隐患信息:<br />"; for (int i = 0; i < YHdataWeek.Rows.Count; i++) { textWeek += string.Format(" <span align=left><font color={5}><b>{0}</b></font>级隐患:" + YHstr + "条</span> <br />", YHdataWeek.Rows[i]["LEVELNAME"].ToString().Trim(), Server.UrlEncode(YHdataWeek.Rows[i]["LEVELNAME"].ToString().Trim()), System.DateTime.Today.AddDays(1 - (int)System.DateTime.Today.DayOfWeek).ToString("yyyy-MM-dd"), System.DateTime.Today.ToString("yyyy-MM-dd"), YHdataWeek.Rows[i]["YHNUM"].ToString().Trim(), GetColor(YHdataWeek.Rows[i]["LEVELNAME"].ToString().Trim())); } } if (SWdataWeek.Count() > 0) { textWeek += "全矿三违信息:<br />"; foreach (var r in SWdataWeek) { textWeek += string.Format(" <span align=left><font color={5}><b>{0}</b></font>级别三违:" + SWstr + "条 </span><br />", r.Key, Server.UrlEncode(r.Key), System.DateTime.Today.AddDays(1 - (int)System.DateTime.Today.DayOfWeek).ToString("yyyy-MM-dd"), System.DateTime.Today.ToString("yyyy-MM-dd"), r.swnum, GetColor1(r.Key)); } } } this.WeekPanel.Html = textWeek; }
public void YearDataLoad() { //获取当年全矿安全状况 int date = System.DateTime.Today.Year; string textYear = @"<br /><b>" + date + "年全矿安全动态:</b><br /><br />"; //var YHdata = from c in dc.Yhview // where c.Pctime.Value.Year == System.DateTime.Today.Year && c.Maindeptid == SessionBox.GetUserSession().DeptNumber // group c by c.Levelname into g // orderby g.Key // select new // { // YHLevel = g.Key, // YHnum = g.Count() // }; //var SWdata = from c in dc.Getsanwei // where c.Pctime.Value.Year == System.DateTime.Today.Year && c.Dwid == SessionBox.GetUserSession().DeptNumber // group c by c.Levelname into g // select new // { // SWLevel = g.Key, // SWnum = g.Count() // }; DateTime daybegin = new DateTime(System.DateTime.Today.Year, 1, 1); DateTime dayend = new DateTime(System.DateTime.Today.Year, 12, 31); var YHdata = GetSafeInfo.GetMainLeaderYH(daybegin, dayend, SessionBox.GetUserSession().DeptNumber).Tables[0]; //var SWdata = GetSafeInfo.GetMainLeaderSW(daybegin, dayend, SessionBox.GetUserSession().DeptNumber).Tables[0]; var SWdata = from s in dc.Getsanwei where s.Pctime >= daybegin && s.Pctime <= dayend && s.Dwid == SessionBox.GetUserSession().DeptNumber group s by s.Levelname into g select new { g.Key, swnum = g.Count() }; if (YHdata.Rows.Count <= 0 && SWdata.Count() <= 0) { textYear += " 本年度无安全动态!"; } else { if (YHdata.Rows.Count > 0) { textYear += "全矿隐患信息:<br />"; for (int i = 0; i < YHdata.Rows.Count; i++) { textYear += string.Format(" <span align=left> <font color={2}><b>{0}</b></font>级隐患:{1}条 <br /></span>", YHdata.Rows[i]["LEVELNAME"].ToString().Trim(), YHdata.Rows[i]["YHNUM"].ToString().Trim(), GetColor(YHdata.Rows[i]["LEVELNAME"].ToString().Trim())); } } if (SWdata.Count() > 0) { textYear += "全矿三违信息:<br />"; foreach (var r in SWdata) { textYear += string.Format(" <span align=left><font color={5}><b>{0}</b></font>级别三违:" + SWstr + "条 </span><br />", r.Key, Server.UrlEncode(r.Key), daybegin, dayend, r.swnum, GetColor1(r.Key)); } } } this.YearPanel.Html = textYear; }
public void MonthDataLoad() { //获取当月全矿安全状况 DateTime start = new DateTime(System.DateTime.Today.Year, System.DateTime.Today.Month, 1); DateTime end = new DateTime(System.DateTime.Today.Year, System.DateTime.Today.Month, DateTime.DaysInMonth(System.DateTime.Today.Year, System.DateTime.Today.Month)); string textMonth = @"<br /><b>本月安全动态:</b><br /><br />"; //var YHdataMonth = from c in dc.Yhview // where (c.Pctime.Value >= start && c.Pctime.Value <= end) && c.Maindeptid == SessionBox.GetUserSession().DeptNumber // group c by c.Levelname into g // orderby g.Key // select new // { // YHLevel = g.Key, // YHnum = g.Count() // }; //var SWdataMonth = from c in dc.Getsanwei // where (c.Pctime.Value >= start && c.Pctime.Value <= end) && c.Dwid == SessionBox.GetUserSession().DeptNumber // group c by c.Levelname into g // select new // { // SWLevel = g.Key, // SWnum = g.Count() // }; var YHdataMonth = GetSafeInfo.GetMainLeaderYH(start, end, SessionBox.GetUserSession().DeptNumber).Tables[0]; //var SWdataMonth = GetSafeInfo.GetMainLeaderSW(start, end, SessionBox.GetUserSession().DeptNumber).Tables[0]; var SWdataMonth = from s in dc.Getsanwei where s.Pctime >= start && s.Pctime <= end && s.Dwid == SessionBox.GetUserSession().DeptNumber group s by s.Levelname into g select new { g.Key, swnum = g.Count() }; if (YHdataMonth.Rows.Count <= 0 && SWdataMonth.Count() <= 0) { textMonth += " 本月无安全动态!"; } else { if (YHdataMonth.Rows.Count > 0) { textMonth += "全矿隐患信息:<br />"; for (int i = 0; i < YHdataMonth.Rows.Count; i++) { textMonth += string.Format(" <span align=left><font color={5}><b>{0}</b></font>级隐患:" + YHstr + "条 </span><br />", YHdataMonth.Rows[i]["LEVELNAME"].ToString().Trim(), Server.UrlEncode(YHdataMonth.Rows[i]["LEVELNAME"].ToString().Trim()), System.DateTime.Today.AddDays(1 - System.DateTime.Today.Day).ToString("yyyy-MM-dd"), System.DateTime.Today.AddDays(1 - System.DateTime.Today.Day).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd"), YHdataMonth.Rows[i]["YHNUM"].ToString().Trim(), GetColor(YHdataMonth.Rows[i]["LEVELNAME"].ToString().Trim())); } } if (SWdataMonth.Count() > 0) { textMonth += "全矿三违信息:<br />"; foreach (var r in SWdataMonth) { textMonth += string.Format(" <span align=left><font color={5}><b>{0}</b></font>级别三违:" + SWstr + "条 </span><br />", r.Key, Server.UrlEncode(r.Key), start, end, r.swnum, GetColor1(r.Key)); } //for (int i = 0; i < SWdataMonth.Rows.Count;i++) //{ // textMonth += string.Format(" <span align=left><font color={5}>{0}</font>级别三违:" + SWstr + "条 </span><br />", SWdataMonth.Rows[i]["LEVELNAME"].ToString().Trim(), Server.UrlEncode(SWdataMonth.Rows[i]["LEVELNAME"].ToString().Trim()), System.DateTime.Today.AddDays(1 - System.DateTime.Today.Day).ToString("yyyy-MM-dd"), System.DateTime.Today.AddDays(1 - System.DateTime.Today.Day).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd"), SWdataMonth.Rows[i]["SWNUM"].ToString().Trim(), GetColor1(SWdataMonth.Rows[i]["LEVELNAME"].ToString().Trim())); //} } } this.MonthPanel.Html = textMonth; }