/// <summary> /// 初始化日历日期 /// </summary> /// <param name="year"></param> /// <param name="month"></param> private void initCalendar(int year, int month, bool isManager) { DateTime selectDay = new DateTime(year, month, 1); CNDate selectDateTool = new CNDate(selectDay); CNDate beforeDateTool = new CNDate(month == 1 ? new DateTime(year - 1, 12, 1) : new DateTime(year, month - 1, 1)); switch (selectDay.DayOfWeek) { case DayOfWeek.Sunday: initDayOfCalendar(0, selectDateTool.GetDayNumOfMonth(), beforeDateTool.GetDayNumOfMonth(), isManager); break; case DayOfWeek.Monday: initDayOfCalendar(1, selectDateTool.GetDayNumOfMonth(), beforeDateTool.GetDayNumOfMonth(), isManager); break; case DayOfWeek.Tuesday: initDayOfCalendar(2, selectDateTool.GetDayNumOfMonth(), beforeDateTool.GetDayNumOfMonth(), isManager); break; case DayOfWeek.Wednesday: initDayOfCalendar(3, selectDateTool.GetDayNumOfMonth(), beforeDateTool.GetDayNumOfMonth(), isManager); break; case DayOfWeek.Thursday: initDayOfCalendar(4, selectDateTool.GetDayNumOfMonth(), beforeDateTool.GetDayNumOfMonth(), isManager); break; case DayOfWeek.Friday: initDayOfCalendar(5, selectDateTool.GetDayNumOfMonth(), beforeDateTool.GetDayNumOfMonth(), isManager); break; case DayOfWeek.Saturday: initDayOfCalendar(6, selectDateTool.GetDayNumOfMonth(), beforeDateTool.GetDayNumOfMonth(), isManager); break; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //this.lblSignIn.Text = this.currentUser.empNm; } //获取当前登陆用户角色名称 string roleName = ""; DataSet ds = new DataSet(); PUserRoleBB userRoleBB = new PUserRoleBB(); try { ds = userRoleBB.GetVList("empId=" + this.currentUser.empId.ToString()); if (ds.Tables[0].Rows.Count > 0) { roleName = ds.Tables[0].Rows[0]["roleName"].ToString(); } } finally { userRoleBB.Dispose(); } //显示欢迎信息 this.labWelcome.Text = "" + this.currentUser.empNo + " " + this.currentUser.empNm; //显示日期信息 CNDate cNDate = new CNDate(); DateTime today = DateTime.Today; string lunarToday = cNDate.ToLunarCald(today); this.date_area.Text = today.Month.ToString() + "月" + today.Day.ToString() + "日" + " 农历 " + cNDate.GetLunarHolDay(); }
private void initScheduleList(IList scList) { if (scList != null && scList.Count > 0) { schedule_listView.Items.Clear(); foreach (StaffSchedule s in scList) { ListViewItem item = new ListViewItem(); item.Font = new Font(schedule_listView.Font.FontFamily, 9, FontStyle.Regular); ListViewItem.ListViewSubItem time = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem content = new ListViewItem.ListViewSubItem(); time.Text = CNDate.getTimeByTimeTicks(new DateTime(s.ScheduleTime).TimeOfDay.Ticks); content.Text = s.Content; ListViewItem.ListViewSubItem check = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem number = new ListViewItem.ListViewSubItem(); number.Text = "1"; //item.SubItems.Add(number); 多余的代码 item.SubItems.Add(time); item.SubItems.Add(content); schedule_listView.Items.Add(item); } } }
/// <summary> /// 获取农历 /// </summary> /// <param name="dt"></param> /// <returns></returns> public static CNDate getChinaDate(DateTime dt) { CNDate cd = new CNDate(); int year = dt.Year; int month = dt.Month; int date = dt.Day; long[] l = calElement(year, month, date); cd.cnIntYear = (int)l[0]; cd.cnIntMonth = (int)l[1]; cd.cnIntDay = (int)l[2]; cd.cnStrYear = cyclical(year); cd.cnAnm = AnimalsYear(year); cd.cnStrMonth = nStr1[(int)l[1]]; cd.cnStrDay = getChinaDate((int)(l[2])); string smd = dt.ToString("MMdd"); string lmd = FormatDate(cd.cnIntMonth, cd.cnIntDay); for (int i = 0; i < solarTerm.Length; i++) { string s1 = sTerm(dt.Year, i).ToString("MMdd"); if (s1.Equals(dt.ToString("MMdd"))) { cd.cnSolarTerm = solarTerm[i]; break; } } foreach (string s in sFtv) { string s1 = s.Substring(0, 4); if (s1.Equals(smd)) { cd.cnFtvs = s.Substring(4, s.Length - 4); break; } } foreach (string s in lFtv) { string s1 = s.Substring(0, 4); if (s1.Equals(lmd)) { cd.cnFtvl = s.Substring(4, s.Length - 4); break; } } dt = dt.AddDays(1); year = dt.Year; month = dt.Month; date = dt.Day; l = calElement(year, month, date); lmd = FormatDate((int)l[1], (int)l[2]); if (lmd.Equals("0101")) { cd.cnFtvl = "除夕"; } return(cd); }
protected void clShowTime_DayRender(object sender, DayRenderEventArgs e) { User user = (User)Session["Login"]; //自定义显示内容 CalendarDay calDay = e.Day; //获取表示呈现在空间中的单元格 TableCell tc = e.Cell; CNDate dt = ChinaDate.getChinaDate(calDay.Date);//农历转换对象 if (calDay.IsOtherMonth) { tc.Controls.Clear(); } else { try { HyperLink ahyperLink = new HyperLink(); ahyperLink.ImageUrl = "~/Images/add_Schedule.gif"; ahyperLink.ToolTip = "新增个人日程"; ahyperLink.NavigateUrl = "SaveMySchedule.aspx?today=" + calDay.Date.ToShortDateString(); tc.Controls.Add(new LiteralControl(" " + " " + " ")); tc.Controls.Add(ahyperLink); tc.Controls.Add(new LiteralControl("<br>" + dt.cnStrMonth + "月" + dt.cnStrDay)); //添加农历日期 tc.Controls.Add(new LiteralControl("<br>" + dt.cnSolarTerm)); //添加农历节气 tc.Controls.Add(new LiteralControl(dt.cnFtvl)); //添加节日 e.Cell.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#FFCCFF';cursor='hand';"; e.Cell.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#ffffff';"; IList <Schedule> schedules = ScheduleManager.SearchSchedule(calDay.Date.ToShortDateString(), -1, user.UserName, false); if (schedules != null) { string str = null; foreach (Schedule schedule in schedules) { HtmlAnchor ha = new HtmlAnchor(); ha.HRef = "SaveMySchedule.aspx?userId=" + user.UserId + "&today=" + calDay.Date.ToShortDateString(); try { str = schedule.Title.Substring(0, 3); } catch (Exception ex) { str = schedule.Title; } ha.InnerText = "@ " + schedule.BeginTime.Hour + ":" + schedule.BeginTime.Minute + str + "..."; //tc.Controls.Add(new LiteralControl(" "+" "+" ")); //tc.Controls.Add(new LiteralControl("<br>")); tc.Controls.Add(ha); } } } catch (Exception ex) { e.Cell.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#fff7ce';cursor='hand';"; e.Cell.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#ffffff';"; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //this.lblSignIn.Text = this.currentUser.empNm; } //获取当前登陆用户角色名称 string roleName = ""; DataSet ds = new DataSet(); PUserRoleBB userRoleBB = new PUserRoleBB(); try { ds = userRoleBB.GetVList("empId=" + this.currentUser.empId.ToString()); if (ds.Tables[0].Rows.Count > 0) { roleName = ds.Tables[0].Rows[0]["roleName"].ToString(); } } finally { userRoleBB.Dispose(); } //显示欢迎信息 this.labWelcome.Text = "欢迎您:" + this.currentUser.empNm + " " + roleName; //显示日期信息 CNDate cNDate = new CNDate(); DateTime today = DateTime.Today; string lunarToday = cNDate.ToLunarCald(today); //this.date_area.Text = today.ToLongDateString() + " " + cNDate.GetWeekChi(today) + " 农历 " // + cNDate.GetLunarHolDay(); this.date_area.Text = today.Month.ToString() + "月" + today.Day.ToString() + "日" + " 农历 " + cNDate.GetLunarHolDay(); //注册客户端脚步,更新时间区域 //if (!this.ClientScript.IsStartupScriptRegistered("RefreshTime")) //{ // StringBuilder refreshTimeBuilder = new StringBuilder(); // DateTime now = DateTime.Now; // refreshTimeBuilder.Append(" <script type=\"text/javascript\" language=\"javascript\">\r\n"); // refreshTimeBuilder.Append(" var OA_TIME = new Date(" + now.Year.ToString() + "," + now.Month.ToString() + "," // + now.Day.ToString() + "," + now.Hour.ToString() + "," + now.Minute.ToString() + "," + now.Second.ToString() + ");\r\n"); // refreshTimeBuilder.Append(" function timeview()\r\n"); // refreshTimeBuilder.Append(" {\r\n"); // refreshTimeBuilder.Append(" timestr=OA_TIME.toLocaleString();\r\n"); // refreshTimeBuilder.Append(" timestr=timestr.substr(timestr.indexOf(\":\")-2);\r\n"); // refreshTimeBuilder.Append(" document.getElementById(\"time_area\").innerHTML = timestr;\r\n"); // refreshTimeBuilder.Append(" OA_TIME.setSeconds(OA_TIME.getSeconds()+1);\r\n"); // refreshTimeBuilder.Append(" window.setTimeout(\"timeview()\", 1000 );\r\n"); // refreshTimeBuilder.Append(" }\r\n"); // refreshTimeBuilder.Append(" </script>\r\n"); // this.ClientScript.RegisterStartupScript(this.GetType(), "RefreshTime", refreshTimeBuilder.ToString()); //} this.ShowMenuInfo(); }
public void UT_GetChinaDate_V1() { try { CNDate result = ChinaDate.GetChinaDate(DateTime.Now); Assert.IsTrue(result == null ? false : true); } catch (Exception ex) { Assert.Fail(ex.Message); } }
private void button1_Click(object sender, EventArgs e)//查询时操作 { leaveDayNum = 0; int lateDayNum = 0; int earlyDayNum = 0; int noneAttNum = 0; //初始化数据 this.initCalendar(dateTimePicker5.Value.Year, dateTimePicker5.Value.Month); initPanelDate(); initAttendanceDate(); //更新数据 updatePanel(); updateLabel(); #region 出勤统计数据初始化 List <object> staticsList = new List <object>(); DateTime startTime = new DateTime(dateTimePicker5.Value.Year, dateTimePicker5.Value.Month, 1); DateTime endTime = startTime.AddMonths(1);//new DateTime(dateTimePicker5.Value.Year, dateTimePicker5.Value.Month, CNDate.GetDayNumOfMonth(new DateTime(dateTimePicker5.Value.Year, dateTimePicker5.Value.Month, 1))); IList staticAttendanceList = baseService.loadEntityList("select att from Attendance att left join att.User u left join u.Kdid dept where dept.KdName='" + dept_comboBox.Text.Trim() + "' and att.State=" + (int)IEntity.stateEnum.Normal + " and u.KuName='" + comboBox2.Text.Trim() + "' and att.SignDate>=" + startTime.Date.Ticks + " and att.SignDate<=" + endTime.Date.Ticks); noneAttNum = CNDate.getWorkDayNum(startTime.Date, endTime.Date).Count - staticAttendanceList.Count; staticsList.Add(staticAttendanceList.Count); if (staticAttendanceList != null && staticAttendanceList.Count > 0) { foreach (Attendance att in staticAttendanceList) { if (att.LateOrLeaveEarly.Equals((int)Attendance.lateOrLeaveEarlyEnum.Early)) { earlyDayNum++; } else if (att.LateOrLeaveEarly.Equals((int)Attendance.lateOrLeaveEarlyEnum.Late)) { lateDayNum++; } else if (att.LateOrLeaveEarly.Equals((int)Attendance.lateOrLeaveEarlyEnum.LateAndEarly)) { lateDayNum++; earlyDayNum++; } } } staticsList.Add(lateDayNum); staticsList.Add(earlyDayNum); staticsList.Add(noneAttNum); staticsList.Add(leaveDayNum); #endregion listView2.Items.Clear(); initListView2(listView2, staticsList); }
private void label_MouseHover(object sender, EventArgs e) { Label label = (Label)sender; if (label.Tag != null) { String tip = ""; List <StaffSchedule> ssList = (List <StaffSchedule>)label.Tag; foreach (StaffSchedule s in ssList) { DateTime dateTime = new DateTime(s.ScheduleTime); tip += CNDate.getTimeByTimeTicks(dateTime.TimeOfDay.Ticks) + Environment.NewLine; tip += s.Content + Environment.NewLine; } this.toolTip1.SetToolTip(label, tip); } }
void update_days(bool flag) { GameObject days_obj = transform.FindChild("days").gameObject; GameObject select = null; int maxDays = DateTime.DaysInMonth(_year, _month); DateTime fisrt = new DateTime(_year, _month, 1); DayOfWeek week = fisrt.DayOfWeek; int start = MyUtilTools.GetWeekDays(week);//这个月的第一天 int preMonth = _month - 1; int preYear = _year; if (preMonth == 0) { preMonth = 12; preYear--; } int stand = start == 0 ? 1 : 0; int temp = start == 0 ? 7 : start; int preLastDay = DateTime.DaysInMonth(preYear, preMonth); int dayIndex = preLastDay - temp + 1; int dayCount = 0; int nextMonth = _month; int nextYear = _year; bool nextMonthStart = false; bool thisMonthStart = false; for (int i = 0; i < 6; i++) { GameObject row_obj = days_obj.transform.FindChild("row" + i).gameObject; if (i <= stand) { for (int j = 0; j < 7; j++) { GameObject day = row_obj.transform.FindChild("col" + j).gameObject; if (flag) { UIButton button = day.GetComponent <UIButton>(); EventDelegate event_select = new EventDelegate(this, "doSelect"); event_select.parameters[0] = new EventDelegate.Parameter(); event_select.parameters[0].obj = day; button.onClick.Add(event_select); } if (dayIndex < preLastDay - 1 && !thisMonthStart) { day.SetActive(false); } else { if (!thisMonthStart && dayIndex > preLastDay) { thisMonthStart = true; dayIndex = 1; preMonth++; if (preMonth > 12) { preMonth = 1; preYear++; } } day.SetActive(true); UILabel label = day.transform.FindChild("gl").GetComponent <UILabel>(); label.text = dayIndex + ""; label = day.transform.FindChild("nl").GetComponent <UILabel>(); if (dayIndex == DateTime.Now.Day && preMonth == DateTime.Now.Month && preYear == DateTime.Now.Year) { label.text = "今天"; } else { DateTime dateTime = DateTime.Parse(preYear + "-" + MyUtilTools.numToString(preMonth) + "-" + MyUtilTools.numToString(dayIndex) + " 00:00:00"); CNDate cnDate = ChinaDate.getChinaDate(dateTime); if (!cnDate.cnFtvl.Equals("")) { label.text = cnDate.cnFtvl; } else if (!cnDate.cnFtvs.Equals("")) { label.text = cnDate.cnFtvs; } else if (!cnDate.cnSolarTerm.Equals("")) { label.text = cnDate.cnSolarTerm; } else { label.text = cnDate.cnStrDay; } } if (selectIndex == -1 && _day == dayIndex && nextMonth == _month && nextYear == _year) { selectIndex = dayCount; } } CalendarData cd = day.GetComponent <CalendarData>(); cd.Value = MyUtilTools.numToString(preYear) + "-" + MyUtilTools.numToString(preMonth) + "-" + MyUtilTools.numToString(dayIndex); cd.Index = dayCount; dayIndex++; dayCount++; } } else { for (int j = 0; j < 7; j++) { GameObject day = row_obj.transform.FindChild("col" + j).gameObject; if (flag) { UIButton button = day.GetComponent <UIButton>(); EventDelegate event_select = new EventDelegate(this, "doSelect"); event_select.parameters[0] = new EventDelegate.Parameter(); event_select.parameters[0].obj = day; button.onClick.Add(event_select); } if (nextMonthStart) { day.SetActive(false); } else { day.SetActive(true); UILabel label = day.transform.FindChild("gl").GetComponent <UILabel>(); label.text = dayIndex + ""; label = day.transform.FindChild("nl").GetComponent <UILabel>(); if (dayIndex == DateTime.Now.Day && nextMonth == DateTime.Now.Month && nextYear == DateTime.Now.Year) { label.text = "今天"; } else { DateTime dateTime = DateTime.Parse(nextYear + "-" + MyUtilTools.numToString(nextMonth) + "-" + MyUtilTools.numToString(dayIndex) + " 00:00:00"); CNDate cnDate = ChinaDate.getChinaDate(dateTime); if (!cnDate.cnFtvl.Equals("")) { label.text = cnDate.cnFtvl; } else if (!cnDate.cnFtvs.Equals("")) { label.text = cnDate.cnFtvs; } else if (!cnDate.cnSolarTerm.Equals("")) { label.text = cnDate.cnSolarTerm; } else { label.text = cnDate.cnStrDay; } } if (selectIndex == -1 && _day == dayIndex && nextMonth == _month && nextYear == _year) { selectIndex = dayCount; } CalendarData cd = day.GetComponent <CalendarData>(); cd.Value = MyUtilTools.numToString(nextYear) + "-" + MyUtilTools.numToString(nextMonth) + "-" + MyUtilTools.numToString(dayIndex); cd.Index = dayCount; dayIndex++; if (dayIndex > maxDays) {//下一个月的天数 nextMonthStart = true; dayIndex = 1; nextMonth++; if (nextMonth > 12) { nextMonth = 1; nextYear++; } } } dayCount++; } } } int row = selectIndex / 7; int col = selectIndex % 7; select = days_obj.transform.FindChild("row" + row).FindChild("col" + col).gameObject; if (flag) { selectIndex = -1; } doSelect(select); }
/// <summary> /// ��ȡũ�� /// </summary> public static CNDate getChinaDate(DateTime dt) { CNDate cd = new CNDate(); int year = dt.Year; int month = dt.Month; int date = dt.Day; long[] l = calElement(year, month, date); cd.cnIntYear = (int)l[0]; cd.cnIntMonth = (int)l[1]; cd.cnIntDay = (int)l[2]; cd.cnStrYear = cyclical(year); cd.cnAnm = AnimalsYear(year); cd.cnStrMonth = nStr1[(int)l[1]]; cd.cnStrDay = getChinaDate((int)(l[2])); string smd = dt.ToString("MMdd"); string lmd = FormatDate(cd.cnIntMonth, cd.cnIntDay); for (int i = 0; i < solarTerm.Length; i++) { string s1 = sTerm(dt.Year, i).ToString("MMdd"); if (s1.Equals(dt.ToString("MMdd"))) { cd.cnSolarTerm = solarTerm[i]; break; } } foreach (string s in sFtv) { string s1 = s.Substring(0, 4); if (s1.Equals(smd)) { cd.cnFtvs = s.Substring(4, s.Length - 4); break; } } foreach (string s in lFtv) { string s1 = s.Substring(0, 4); if (s1.Equals(lmd)) { cd.cnFtvl = s.Substring(4, s.Length - 4); break; } } dt = dt.AddDays(1); year = dt.Year; month = dt.Month; date = dt.Day; l = calElement(year, month, date); lmd = FormatDate((int)l[1], (int)l[2]); if (lmd.Equals("0101")) cd.cnFtvl = "��Ϧ"; return cd; }
void LoadData() { Hashtable ht = new Hashtable(); IList all_day = baseService.loadEntityList("select u from WkTUser u left join u.Kdid dept left join u.UserRole r where r.KrDESC='" + CommonClass.CommonStaticParameter.RoleDesc + "' and u.KuName like '%" + textBox2.Text.Trim() + "%' and dept.KdName like '%" + (comboBox1.Text.Trim() != "选择全部……" ? comboBox1.Text.Trim() : "") + "%'"); int allDay = CNDate.getWorkDayNum(dateTimePicker1.Value.Date, dateTimePicker2.Value.Date).Count; if (all_day != null && all_day.Count > 0) { foreach (WkTUser u in all_day) { List <object> dayNum = new List <object>(); dayNum.Add(u.KuName); dayNum.Add(allDay); dayNum.Add(0); dayNum.Add(0); dayNum.Add(0); dayNum.Add(0); dayNum.Add(u.Kdid.KdName.Trim()); ht.Add(u.Id, dayNum); } } string sql = "select u.Ku_Id,count(attend.id) from LOG_T_ATTENDANCE attend left join WK_T_USER u on u.ku_id=attend.WkTUserId,WK_T_DEPT dept,Wk_T_UseRole ur,Wk_T_Role r where u.KU_ID=ur.KU_ID and ur.KR_ID=r.KR_ID and r.KR_DESC='" + CommonClass.CommonStaticParameter.RoleDesc + "' and dept.kd_id=u.kd_id and dept.kd_name like '%" + (comboBox1.Text.Trim() != "选择全部……" ? comboBox1.Text.Trim() : "") + "%' and u.ku_Name like '%" + textBox2.Text.Trim() + "%' and attend.SignDate>=" + dateTimePicker1.Value.Date.Ticks + " and attend.SignDate<=" + dateTimePicker2.Value.Date.Ticks + "group by u.ku_id"; IList chu_qin = baseService.ExecuteSQL(sql); if (chu_qin != null && chu_qin.Count > 0) { foreach (Object[] o in chu_qin) { try { List <object> dayNum = (List <object>)ht[Convert.ToInt64(o[0])]; dayNum[2] = (int)o[1]; ht[Convert.ToInt64(o[0])] = dayNum; } catch { return; } } } ///////////////////////////////////////////////////////////////////////////////////////// //加班天数 //string jb_sql = "select u.Ku_Id,sum(case when attend.STARTTIME>" + dateTimePicker1.Value.Date.Ticks + " then (case when attend.ENDTIME<" + dateTimePicker2.Value.Date.Ticks + " then " + new DateTime(1, 1, 2).Date.Ticks + "+attend.ENDTIME-attend.STARTTIME else " + new DateTime(1, 1, 2).Date.Ticks + "+" + dateTimePicker2.Value.Date.Ticks + "-attend.STARTTIME end) else (case when attend.ENDTIME<" + dateTimePicker2.Value.Date.Ticks + " then " + new DateTime(1, 1, 2).Date.Ticks + "+attend.ENDTIME-" + dateTimePicker1.Value.Date.Ticks + " else " + new DateTime(1, 1, 2).Date.Ticks + "+" + dateTimePicker2.Value.Date.Ticks + "-" + dateTimePicker1.Value.Date.Ticks + " end) end) from LOG_T_WORKOVERTIME attend left join WORKOVERTIME_M_WkTUser mu on mu.WORKMAN_ID=attend.id left join WK_T_USER u on mu.ku_id=u.KU_ID,WK_T_DEPT dept,Wk_T_UseRole ur,Wk_T_Role r where u.KU_ID=ur.KU_ID and ur.KR_ID=r.KR_ID and r.KR_DESC='" + CommonClass.CommonStaticParameter.RoleDesc + "' and dept.kd_id=u.kd_id and dept.kd_name like '%" + (comboBox1.Text.Trim() != "选择全部……" ? comboBox1.Text.Trim() : "") + "%' and u.ku_Name like '%" + textBox2.Text.Trim() + "%' and ((attend.STARTTIME<=" + dateTimePicker1.Value.Date.Ticks + " and attend.ENDTIME>=" + dateTimePicker1.Value.Date.Ticks + ") or (attend.STARTTIME>=" + dateTimePicker1.Value.Date.Ticks + " and attend.ENDTIME<=" + dateTimePicker2.Value.Date.Ticks + ") or (attend.STARTTIME<=" + dateTimePicker2.Value.Date.Ticks + " and attend.ENDTIME>=" + dateTimePicker2.Value.Date.Ticks + ")) group by u.ku_id"; //IList jia_ban = baseService.ExecuteSQL(jb_sql); //if (jia_ban != null && jia_ban.Count > 0) //{ // foreach (Object[] o in jia_ban) // { // List<object> dayNum = (List<object>)ht[Convert.ToInt64(o[0])]; // dayNum[3] = Convert.ToInt64(o[1]) / 864000000000; // ht[Convert.ToInt64(o[0])] = dayNum; // } //} //值班天数 //string zb_sql = "select u.Ku_Id,count(attend.id) from LOG_T_ONDUTY attend left join ONDUTYTIME_M_WkTUser mu on mu.ONDUTY_STAFFID=attend.id left join WK_T_USER u on u.ku_id=mu.KU_ID,WK_T_DEPT dept,Wk_T_UseRole ur,Wk_T_Role r where u.KU_ID=ur.KU_ID and ur.KR_ID=r.KR_ID and r.KR_DESC='" + CommonClass.CommonStaticParameter.RoleDesc + "' and dept.kd_id=u.kd_id and dept.kd_name like '%" + (comboBox1.Text.Trim() != "选择全部……" ? comboBox1.Text.Trim() : "") + "%' and u.ku_Name like '%" + textBox2.Text.Trim() + "%' and attend.ONDUTY_TIME>=" + dateTimePicker1.Value.Date.Ticks + " and attend.ONDUTY_TIME<=" + dateTimePicker2.Value.Date.Ticks + "group by u.ku_id"; //IList zhi_ban = baseService.ExecuteSQL(zb_sql); //if (zhi_ban != null && zhi_ban.Count > 0) //{ // foreach (Object[] o in zhi_ban) // { // List<object> dayNum = (List<object>)ht[Convert.ToInt64(o[0])]; // dayNum[4] = (int)o[1]; // ht[Convert.ToInt64(o[0])] = dayNum; // } //} //请假天数 string qj_sql = "select u.Ku_Id,sum(case when attend.LEAVE_STARTTIME>" + dateTimePicker1.Value.Date.Ticks + " then (case when attend.LEAVE_ENDTIME<" + dateTimePicker2.Value.Date.Ticks + " then " + new DateTime(1, 1, 2).Date.Ticks + "+attend.LEAVE_ENDTIME-attend.LEAVE_STARTTIME else " + new DateTime(1, 1, 2).Date.Ticks + "+" + dateTimePicker2.Value.Date.Ticks + "-attend.LEAVE_STARTTIME end) else (case when attend.LEAVE_ENDTIME<" + dateTimePicker2.Value.Date.Ticks + " then " + new DateTime(1, 1, 2).Date.Ticks + "+attend.LEAVE_ENDTIME-" + dateTimePicker1.Value.Date.Ticks + " else " + new DateTime(1, 1, 2).Date.Ticks + "+" + dateTimePicker2.Value.Date.Ticks + "-" + dateTimePicker1.Value.Date.Ticks + " end) end) from LOG_T_LEAVE attend left join WK_T_USER u on u.ku_id=attend.KU_ID,WK_T_DEPT dept,Wk_T_UseRole ur,Wk_T_Role r where attend.State=" + (int)Attendance.stateEnum.Normal + " and u.KU_ID=ur.KU_ID and ur.KR_ID=r.KR_ID and r.KR_DESC='" + CommonClass.CommonStaticParameter.RoleDesc + "' and dept.kd_id=u.kd_id and dept.kd_name like '%" + (comboBox1.Text.Trim() != "选择全部……" ? comboBox1.Text.Trim() : "") + "%' and u.ku_Name like '%" + textBox2.Text.Trim() + "%' and ((attend.LEAVE_STARTTIME<=" + dateTimePicker1.Value.Date.Ticks + " and attend.LEAVE_ENDTIME>=" + dateTimePicker1.Value.Date.Ticks + ") or (attend.LEAVE_STARTTIME>=" + dateTimePicker1.Value.Date.Ticks + " and attend.LEAVE_ENDTIME<=" + dateTimePicker2.Value.Date.Ticks + ") or (attend.LEAVE_STARTTIME<=" + dateTimePicker2.Value.Date.Ticks + " and attend.LEAVE_ENDTIME>=" + dateTimePicker2.Value.Date.Ticks + ")) group by u.ku_id"; IList qing_jia = baseService.ExecuteSQL(qj_sql); if (qing_jia != null && qing_jia.Count > 0) { foreach (Object[] o in qing_jia) { List <object> dayNum = (List <object>)ht[Convert.ToInt64(o[0])]; dayNum[5] = Convert.ToInt64(o[1]) / 864000000000; ht[Convert.ToInt64(o[0])] = dayNum; } } dataGridView1.Rows.Clear(); initListView(dataGridView1, ht); }
/// <summary> /// 更新label,显示考勤信息attendanceList /// </summary> /// <param name="label"></param> private void attendenceLabel_Paint(Label label) { label.Text = ""; label.ForeColor = label.Parent.ForeColor; if (label.Parent.Tag == null) { return; } DateTime date = (DateTime)label.Parent.Tag; if (attendanceList != null) { foreach (Attendance a in attendanceList) { if (a.SignDate == date.Date.Ticks) { label.Text += a.SignStartTime != 0 && a.SignStartTime <= usuallyDay.WorkTimeStart ? CNDate.getTimeByTimeTicks(a.SignStartTime) : "迟到"; label.Text += "~"; label.Text += a.SignEndTime != 0 && a.SignEndTime >= usuallyDay.WorkTimeEnd ? CNDate.getTimeByTimeTicks(a.SignEndTime) : "早退"; if (a.SignStartTime != 0 || a.SignStartTime <= usuallyDay.WorkTimeStart || a.SignEndTime != 0 || a.SignEndTime >= usuallyDay.WorkTimeEnd) { label.ForeColor = Color.Red; } attendanceList.Remove(a); return; } } if (date.Ticks > DateTime.Now.Ticks) { label.Text = "未考勤"; } else { label.Text += "缺勤"; label.ForeColor = Color.Red; } } }
void _update() { if (list_container == null) { list_container = needshow[0].transform.FindChild("list").FindChild("body").FindChild("container"); texture1 = Resources.Load <Texture>("pic/time-event1"); texture2 = Resources.Load <Texture>("pic/time-event2"); texture3 = Resources.Load <Texture>("pic/time-event3"); texture4 = Resources.Load <Texture>("pic/time-event4"); TimeLineRefresh refresh = needshow[0].AddComponent <TimeLineRefresh>(); refresh.timeEvent = this; } if (Calendar.selectTexture == null) { Calendar.selectTexture = Resources.Load <Texture>("pic/time-sb"); } list_container.parent.GetComponent <UIPanel>().clipOffset = Vector2.zero; list_container.parent.localPosition = new Vector3(0, 0, 0); UILabel year_label = list_container.FindChild("up").GetComponent <UILabel>(); year_label.text = MyUtilTools.numToString(_year) + "年" + MyUtilTools.numToString(_month) + "月"; Transform days_trans = list_container.FindChild("days"); int maxDays = DateTime.DaysInMonth(_year, _month); DateTime fisrt = new DateTime(_year, _month, 1); DayOfWeek week = fisrt.DayOfWeek; int start = MyUtilTools.GetWeekDays(week);//这个月的第一天 int preMonth = _month - 1; int preYear = _year; if (preMonth == 0) { preMonth = 12; preYear--; } int stand = start == 0 ? 1 : 0; int temp = start == 0 ? 7 : start; int preLastDay = DateTime.DaysInMonth(preYear, preMonth); int dayIndex = preLastDay - temp + 1; int dayCount = 0; int nextMonth = _month; int nextYear = _year; bool nextMonthStart = false; bool thisMonthStart = false; for (int i = 0; i < 6; i++) { GameObject row_obj = days_trans.FindChild("row" + i).gameObject; if (i <= stand) { for (int j = 0; j < 7; j++) { GameObject day = row_obj.transform.FindChild("col" + j).gameObject; UIButton button = day.GetComponent <UIButton>(); if (button.onClick.Count == 0) { EventDelegate event_select = new EventDelegate(this, "doSelect"); event_select.parameters[0] = new EventDelegate.Parameter(); event_select.parameters[0].obj = day; button.onClick.Add(event_select); } if (dayIndex < preLastDay - 1 && !thisMonthStart) { day.SetActive(false); } else { if (!thisMonthStart && dayIndex > preLastDay) { thisMonthStart = true; dayIndex = 1; preMonth++; if (preMonth > 12) { preMonth = 1; preYear++; } } day.SetActive(true); UILabel label = day.transform.FindChild("gl").GetComponent <UILabel>(); label.text = dayIndex + ""; label = day.transform.FindChild("nl").GetComponent <UILabel>(); if (dayIndex == DateTime.Now.Day && preMonth == DateTime.Now.Month && preYear == DateTime.Now.Year) { label.text = "今天"; } else { DateTime dateTime = DateTime.Parse(preYear + "-" + MyUtilTools.numToString(preMonth) + "-" + MyUtilTools.numToString(dayIndex) + " 00:00:00"); CNDate cnDate = ChinaDate.getChinaDate(dateTime); if (!cnDate.cnFtvl.Equals("")) { label.text = cnDate.cnFtvl; } else if (!cnDate.cnFtvs.Equals("")) { label.text = cnDate.cnFtvs; } else if (!cnDate.cnSolarTerm.Equals("")) { label.text = cnDate.cnSolarTerm; } else { label.text = cnDate.cnStrDay; } } if (selectIndex == -1 && _day == dayIndex && nextMonth == _month && nextYear == _year) { selectIndex = dayCount; } } _update_flags(day, preYear, preMonth, dayIndex); CalendarData cd = day.GetComponent <CalendarData>(); cd.Value = MyUtilTools.numToString(preYear) + "-" + MyUtilTools.numToString(preMonth) + "-" + MyUtilTools.numToString(dayIndex); cd.Index = dayCount; dayIndex++; dayCount++; } } else { for (int j = 0; j < 7; j++) { GameObject day = row_obj.transform.FindChild("col" + j).gameObject; UIButton button = day.GetComponent <UIButton>(); if (button.onClick.Count == 0) { EventDelegate event_select = new EventDelegate(this, "doSelect"); event_select.parameters[0] = new EventDelegate.Parameter(); event_select.parameters[0].obj = day; button.onClick.Add(event_select); } if (nextMonthStart) { day.SetActive(false); } else { day.SetActive(true); UILabel label = day.transform.FindChild("gl").GetComponent <UILabel>(); label.text = dayIndex + ""; label = day.transform.FindChild("nl").GetComponent <UILabel>(); if (dayIndex == DateTime.Now.Day && nextMonth == DateTime.Now.Month && nextYear == DateTime.Now.Year) { label.text = "今天"; } else { DateTime dateTime = DateTime.Parse(nextYear + "-" + MyUtilTools.numToString(nextMonth) + "-" + MyUtilTools.numToString(dayIndex) + " 00:00:00"); CNDate cnDate = ChinaDate.getChinaDate(dateTime); if (!cnDate.cnFtvl.Equals("")) { label.text = cnDate.cnFtvl; } else if (!cnDate.cnFtvs.Equals("")) { label.text = cnDate.cnFtvs; } else if (!cnDate.cnSolarTerm.Equals("")) { label.text = cnDate.cnSolarTerm; } else { label.text = cnDate.cnStrDay; } } if (selectIndex == -1 && _day == dayIndex && nextMonth == _month && nextYear == _year) { selectIndex = dayCount; } _update_flags(day, nextYear, nextMonth, dayIndex); CalendarData cd = day.GetComponent <CalendarData>(); cd.Value = MyUtilTools.numToString(nextYear) + "-" + MyUtilTools.numToString(nextMonth) + "-" + MyUtilTools.numToString(dayIndex); cd.Index = dayCount; dayIndex++; if (dayIndex > maxDays) {//下一个月的天数 nextMonthStart = true; dayIndex = 1; nextMonth++; if (nextMonth > 12) { nextMonth = 1; nextYear++; } } } dayCount++; } } } int row = selectIndex / 7; int col = selectIndex % 7; GameObject select = days_trans.FindChild("row" + row).FindChild("col" + col).gameObject; doSelect(select); }