首页 > 代码库 > 节假日设置
节假日设置
using System; using System.Data; using System.Text; using System.Threading; using CMSC.Class; using CMSC.Class.CsSubs; using CMSC.OA.Web.Com.Class; using CMSC.OA.Dal.Day; namespace CMSC.OA.Web.Day.Time { public partial class Set : CsPageLayer { private D_Day_Time_Set dal = new D_Day_Time_Set(); private int currYear = DateTime.Now.Year; private int currMonth = DateTime.Now.Month; private int currDay = DateTime.Now.Day; private int prevYear = DateTime.Now.Year; private int prevMonth = DateTime.Now.Month - 1; private int nextYear = DateTime.Now.Year; private int nextMonth = DateTime.Now.Month + 1; private bool isHoliday = false; protected void Page_Load(object sender, EventArgs e) { try { this.PagePermit = "Day_Time_Set_View"; this.AppendPermit(1, "Day_Time_Set_Edit"); this.LoginUser = Com_Sys.GetLoginUser(PageCookie); this.PageLoadData(); this.BigTitle = true; this.TitleBar.TitleName = "公休日"; this.TitleBar.SubTitleName = "公休日设置"; this.TitleBar.PageUrl = "Set.aspx"; this.TitleBar.ShowMenu = false; this.TitleBar.ShowCloseButton("DayTimeSet"); this.AddScriptFile("form.js"); this.CreatePage(); } catch (ThreadAbortException) { } catch (Exception ex) { LoadTip.TipText = ex.Message; LoadTip.CloseLayer("DayTimeSet"); this.TipHtml = LoadTip.SetScriptHtml(); this.CreateTipPage(); } } #region 页面加载 private void PageLoadData() { #region PageLoadData if (Request["toyear"] != null && Request["toyear"].ToString().Trim() != "") currYear = Convert.ToInt16(Request["toyear"].ToString().Trim()); if (Request["tomonth"] != null && Request["tomonth"].ToString().Trim() != "") currMonth = Convert.ToInt16(Request["tomonth"].ToString().Trim()); if (Request["today"] != null && Request["today"].ToString().Trim() != "") currDay = Convert.ToInt16(Request["today"].ToString().Trim()); prevYear = currYear; prevMonth = currMonth - 1; if (prevMonth == 0) { prevYear = currYear - 1; prevMonth = 12; } nextYear = currYear; nextMonth = currMonth + 1; if (nextMonth == 13) { nextYear = currYear + 1; nextMonth = 1; } #endregion } protected override StringBuilder SetHtml() { #region SetHtml StringBuilder html = new StringBuilder(); html.Append(@" <div id=""toptitle""> <div class=""textrow""> <div class=""fr link""> <a href=""Set.aspx?toyear=" + prevYear + @"&tomonth=" + prevMonth + @"&today=1""><<</a> <span>" + currYear + @"年" + currMonth + @"月</span> <a href=""Set.aspx?toyear=" + nextYear + @"&tomonth=" + nextMonth + @"&today=1"">>></a> </div> <div class=""clear""></div> </div> <div class=""dotline""></div> </div> <div id=""datalist""> <table width=""100%"" cellpadding=""0"" cellspacing=""1"" border=""0"" bgcolor=""#a6c1f7""> <tr height=""20"" align=""center""> <td bgcolor=""#d8e5ff"">周一</td> <td bgcolor=""#d8e5ff"">周二</td> <td bgcolor=""#d8e5ff"">周三</td> <td bgcolor=""#d8e5ff"">周四</td> <td bgcolor=""#d8e5ff"">周五</td> <td bgcolor=""#d8e5ff"">周六</td> <td bgcolor=""#d8e5ff"">周日</td> </tr> "); int MaxDay = 31; if (currMonth == 4) MaxDay = 30; if (currMonth == 6) MaxDay = 30; if (currMonth == 9) MaxDay = 30; if (currMonth == 11) MaxDay = 30; if (currMonth == 2) MaxDay = 28; if (currMonth == 2 && currYear % 4 == 0) MaxDay = 29; string currWeek = Convert.ToDateTime(currYear + "-" + currMonth + "-1").DayOfWeek.ToString().Trim(); int week = 0; switch (currWeek) { case "Monday": week = 1; break; case "Tuesday": week = 2; break; case "Wednesday": week = 3; break; case "Thursday": week = 4; break; case "Friday": week = 5; break; case "Saturday": week = 6; break; case "Sunday": week = 7; break; } int loopDay = week - 1; int showDay = 1; int loopWeek = 1; for (int i = 0; i < 42; i++) { if ((i == 0) || (i == 7) || (i == 14) || (i == 21) || (i == 28) || (i == 35)) { html.Append(@"<tr height=""30"" align=""center"">"); } if (i >= loopDay && showDay <= MaxDay) { string bgcolor = "#ffffff"; if (showDay == currDay) bgcolor = "#d8e5ff"; DateTime currDate = Convert.ToDateTime(currYear + "-" + currMonth + "-" + showDay); isHoliday = dal.GetCount(currDate.ToString("yyyy-MM-dd"), true) > 0; if (loopWeek == 6 || loopWeek == 7) { html.Append(@"<td bgcolor=""" + bgcolor + @""" onm ouseover=""overday(this);"" onm ouseout=""outday(this);"" onclick=""clickday(‘" + currDate.ToString("yyyy-MM-dd") + @"‘,‘" + (isHoliday ? "1" : "0") + @"‘);"">"); html.Append(@"<span><font color=red>" + showDay + @"</font></span>"); } else { html.Append(@"<td bgcolor=""" + bgcolor + @""" onm ouseover=""overday(this);"" onm ouseout=""outday(this);"" onclick=""clickday(‘" + currDate.ToString("yyyy-MM-dd") + @"‘,‘" + (isHoliday ? "1" : "0") + @"‘);"">"); html.Append(@"<span>" + showDay + @"</span>"); } if (isHoliday) html.Append(@"休"); html.Append(@"<br></td>"); showDay++; } else { html.Append(@"<td bgcolor=""#ffffff""> </td>"); } if ((i == 6) || (i == 13) || (i == 20) || (i == 27) || (i == 34) || (i == 41)) { html.Append(@"</tr>"); } loopWeek++; if (loopWeek == 8) loopWeek = 1; } html.Append(@" "); html.Append(@" </table> </div> "); return html; #endregion } protected override StringBuilder SetPageStyle() { #region SetPageStyle StringBuilder style = new StringBuilder(); style.Append(@" #toptitle .textrow {height:20px; overflow:hidden;} #toptitle .link {padding-top:4px;padding-right:100px;color:#333;} #toptitle .link span {font-weight:bold; color:#333;} #toptitle .link a {color:#0000ff;} #datalist {height:200px; padding-top:5px;} #datalist td {width:48px; color:#999;} #datalist td span {font-size:18px; font-family:黑体; color:#000;} "); return style; #endregion } protected override StringBuilder SetEndHtml() { #region SetEndHtml StringBuilder html = new StringBuilder(); HiddenForm hf = new HiddenForm(1, "PostBackForm", "post"); hf.Action = "Set.aspx"; hf.Target = "HiddenFrame"; hf.AddFormItem("day", ""); hf.AddFormItem("isHoliday", ""); html.Append(hf.BoxHtml()); return html; #endregion } protected override StringBuilder EndScript() { #region EndScript StringBuilder js = new StringBuilder(); js.Append(@"function overday(src) {"); js.Append(@"src.style.cursor = ""pointer"";"); js.Append(@"src.style.backgroundColor = ""#ffff66"";"); js.Append(@"}"); js.Append(@"function outday(src) {"); js.Append(@"src.style.cursor = """";"); js.Append(@"src.style.backgroundColor = """";"); js.Append(@"}"); js.Append(@"function clickday(daystr,isHoliday) {"); js.Append(@"var str ="""";"); js.Append(@"if(isHoliday==1) str=""取消"";"); js.Append(@"if(confirm(""确认要""+str+""设置为公休日吗?"")){"); js.Append(@"var subform = CMSC.$$(""PostBackForm"");"); js.Append(@"subform.subflag.value = http://www.mamicode.com/1;"); js.Append(@"subform.day.value = http://www.mamicode.com/daystr;"); js.Append(@"subform.isHoliday.value = http://www.mamicode.com/isHoliday;"); js.Append(@"subform.submit();"); js.Append(@"}"); js.Append(@"}"); return js; #endregion } #endregion #region 回调函数 protected override string PostCheckInput(int subflag) { #region PostCheckInput if (!CsClass.CheckParame(new string[] { Request.Form["day"] })) { return "在接收的数据中检测到异常的空值!"; } else { //数据合法性检测 return ""; } #endregion } protected override SaveResult PostSave(int subflag) { #region PostSave string day = Request.Form["day"].ToString().Trim(); string isHoliday = Request.Form["isHoliday"].ToString().Trim(); if (dal.GetCount(day, false) == 0) { if (dal.AddDay(day) > 0 ? true : false) { SaveTip.IsOk = true; SaveTip.TipText = "已成功设置公休日!"; SaveTip.RefuseFrame("DayTimeSetFrame"); return SaveTip; } else { SaveTip.IsOk = false; SaveTip.TipText = "设置公休日出现异常失败!"; return SaveTip; } } else { if (dal.EditDay(day) > 0 ? true : false) { SaveTip.IsOk = true; SaveTip.TipText = "已成功" + (isHoliday == "1" ? "取消" : "") + "设置公休日设置!"; SaveTip.RefuseFrame("DayTimeSetFrame"); return SaveTip; } else { SaveTip.IsOk = false; SaveTip.TipText = (isHoliday == "1" ? "取消" : "") + "设置公休日出现异常失败!"; return SaveTip; } } #endregion } #endregion } }
节假日设置
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。