예제 #1
0
        /// <summary>
        /// 页面初始化
        /// </summary>
        /// <param name="id">操作ID</param>
        protected void PageInit()
        {
            string txtNum      = Utils.GetQueryStringValue("txtNum");
            string txtName     = Utils.GetQueryStringValue("txtName");
            string sectionID   = Utils.GetQueryStringValue(this.SelectSection1.SelectIDClient);
            string sectionName = Utils.GetQueryStringValue(this.SelectSection1.SelectNameClient);

            this.SelectSection1.SectionName = sectionName;
            this.SelectSection1.SectionID   = sectionID;
            BAttendance BLL   = new BAttendance();
            MSearchInfo Model = new MSearchInfo();

            if (!string.IsNullOrEmpty(sectionID))
            {
                Model.DepartIds = sectionID;
            }
            Model.DepartName = sectionName;
            Model.FileNumber = txtNum;
            Model.Month      = month;
            Model.StaffName  = txtName;
            Model.Year       = year;
            IList <MGovAttendanceList> lst = BLL.GetList(this.SiteUserInfo.CompanyId, Model);

            if (null != lst && lst.Count > 0)
            {
                this.RepList.DataSource = lst;
                this.RepList.DataBind();
                this.ExporPageInfoSelect2.intRecordCount = lst.Count;
            }
        }
예제 #2
0
        /// <summary>
        /// 生成单元格(包括日期和考勤情况信息)
        /// </summary>
        /// <param name="i">当月几号</param>
        /// <returns></returns>
        protected string getUnit(int i)
        {
            Dictionary <EyouSoft.Model.EnumType.GovStructure.AttendanceType, string> dic = new Dictionary <EyouSoft.Model.EnumType.GovStructure.AttendanceType, string>();

            dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.迟到, "class=\"rl-red\"");
            dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.出差, "class=\"rl-perpel\"");
            dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.加班, "class=\"rl-blue\"");
            dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.旷工, "class=\"rl-yellow\"");
            dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.请假, "class=\"rl-gray\"");
            dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.停职, "class=\"rl-skyblue\"");
            dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.休假, "class=\"rl-lime\"");
            dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.早退, "class=\"rl-green\"");
            DateTime               dtCurrent = Convert.ToDateTime(string.Format("{0}{1}", string.Format("{0:yyyy-MM-}", dt), i < 10 ? "0" + i.ToString() : i.ToString()));
            BAttendance            BLL       = new BAttendance();
            IList <MGovAttendance> lst       = BLL.GetList(this.SiteUserInfo.CompanyId, Utils.GetQueryStringValue("id"), dtCurrent);
            string        classStr           = string.Empty;
            string        type    = string.Empty;
            StringBuilder strInfo = new StringBuilder();
            string        id      = Utils.GetQueryStringValue("id");

            if (null != lst && lst.Count > 0)
            {
                foreach (MGovAttendance m in lst)
                {
                    if (m.AttendanceType != AttendanceType.全勤)
                    {
                        classStr = dic[m.AttendanceType];
                    }
                    if (m.AttendanceType == AttendanceType.全勤)
                    {
                        strInfo.AppendFormat("<a href='AttDetail.aspx?doType=update&attID={0}&date={2}&sl={3}' data-class='attDetail'>{1}</a>", m.AttendanceId,
                                             m.AttendanceType.ToString(), string.Format("{0:yyyy-MM-dd}", dtCurrent), Utils.GetQueryStringValue("sl"));
                    }
                    else
                    {
                        bool flag = m.AttendanceType == EyouSoft.Model.EnumType.GovStructure.AttendanceType.加班;
                        strInfo.AppendFormat("<a href='AttDetail.aspx?doType=update&attID={1}&date={2}&sl={3}' class='attendBt' data-class='attDetail'>{0}</a>",
                                             m.AttendanceType.ToString(), m.AttendanceId,
                                             string.Format("{0:yyyy-MM-dd}", dtCurrent), Utils.GetQueryStringValue("sl"));
                        strInfo.AppendFormat("<div style='display: none'>");
                        strInfo.AppendFormat("<table cellspacing='0' cellpadding='0' border='0' width='100%'><tr>");
                        strInfo.AppendFormat("<td height='23' align='right'>考勤时间:</td>");
                        strInfo.AppendFormat("<td align='left'>{0}</td></tr>", string.Format("{0:yyyy-MM-dd}", m.AttendanceTime));
                        strInfo.AppendFormat("<tr><th align='right' valign='top'>考勤情况:</th>");
                        strInfo.AppendFormat("<td>{0}时间:{1}至{2}&nbsp;{0}{3}:",
                                             m.AttendanceType.ToString(),
                                             string.Format("{0:yyyy-MM-dd HH:mm}", m.StartTime),
                                             string.Format("{0:yyyy-MM-dd HH:mm}", m.EndTime),
                                             flag ? "时数" : "天数");
                        strInfo.AppendFormat("<strong class='fontred'>{0}{1}</strong>", string.Format("({0})", Math.Round(m.TimeCount, 1)),
                                             flag ? "小时" : "天");
                        strInfo.AppendFormat("&nbsp;<p>{0}原因:{1}</p></td></tr></table></div> ", m.AttendanceType.ToString(), m.Subject);
                    }
                }
            }
            return(string.Format("<li {0}><p>&nbsp;{1}&nbsp;</p><p>&nbsp;{2}&nbsp;</p></li>", classStr, i < 10 ? "0" + i.ToString() : i.ToString(), strInfo.ToString()));
        }
예제 #3
0
        /// <summary>
        /// 生成单元格(包括日期和考勤情况信息)
        /// </summary>
        /// <param name="i">当月几号</param>
        /// <returns></returns>
        protected string getUnit(int i)
        {
            int                    selYear   = Utils.GetInt(Utils.GetQueryStringValue("selYear"));  //年
            int                    selMonth  = Utils.GetInt(Utils.GetQueryStringValue("selMonth")); //月
            DateTime               dtCurrent = Convert.ToDateTime(String.Format("{0}-{1}-{2}", selYear, selMonth, i));
            BAttendance            BLL       = new BAttendance();
            IList <MGovAttendance> lst       = BLL.GetList(this.SiteUserInfo.CompanyId, Utils.GetQueryStringValue("id"), dtCurrent);
            String                 type      = String.Empty;
            StringBuilder          strInfo   = new StringBuilder();

            if (null != lst && lst.Count > 0)
            {
                foreach (MGovAttendance m in lst)
                {
                    strInfo.Append(m.AttendanceType);
                }
            }
            return(strInfo.ToString());
        }
예제 #4
0
        /// <summary>
        /// 导出
        /// </summary>
        void ToXls()
        {
            int toXlsRecordCount = UtilsCommons.GetToXlsRecordCount();

            if (toXlsRecordCount < 1)
            {
                ResponseToXls(string.Empty);
            }
            StringBuilder str         = new StringBuilder();
            string        txtNum      = Utils.GetQueryStringValue("txtNum");
            string        txtName     = Utils.GetQueryStringValue("txtName");
            string        sectionID   = Utils.GetQueryStringValue(this.SelectSection1.SelectIDClient);
            string        sectionName = Utils.GetQueryStringValue(this.SelectSection1.SelectNameClient);
            BAttendance   BLL         = new BAttendance();
            MSearchInfo   Model       = new MSearchInfo();

            if (!string.IsNullOrEmpty(sectionID))
            {
                Model.DepartIds = sectionID;
            }
            Model.DepartName = sectionName;
            Model.FileNumber = txtNum;
            Model.Month      = month;
            Model.StaffName  = txtName;
            Model.Year       = year;
            IList <MGovAttendanceList> data = BLL.GetList(this.SiteUserInfo.CompanyId, Model);

            //加载表头
            str.AppendFormat("<meta http-equiv=\"content-type\" content=\"application/ms-excel; charset=UTF-8\"/><table border='1' style='border-collapse:collapse;'><tr><th width='105'>员工编号" +
                             "</th><th width='105'>部门</th><th width='107'>姓名</th>");
            //循环读取当前月的天数
            int days = DateTime.DaysInMonth(year, month);

            for (int i = 0; i < days; i++)
            {
                str.AppendFormat("<th>{0}</th>", i + 1);
            }
            str.AppendFormat("</tr>");
            //查询出来的数据读取
            if (data != null && data.Count > 0)
            {
                Dictionary <EyouSoft.Model.EnumType.GovStructure.AttendanceType, string> dic = new Dictionary <EyouSoft.Model.EnumType.GovStructure.AttendanceType, string>();
                dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.迟到, "<font color='#FF0000'><strong>迟</strong></font>");
                dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.出差, "<font color='#800080'><strong>差</strong></font>");
                dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.加班, "<font color='#0000FF'><strong>加</strong></font>");
                dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.旷工, "<font color='#6600CC'><strong>旷</strong></font>");
                dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.请假, "<font color='#FFA500'><strong>请</strong></font>");
                dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.全勤, "<font color='#A9A9A9'>准</font>");
                dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.停职, "<font color='#00BFFF'><strong>停</strong></font>");
                dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.休假, "<font color='#00FF00'><strong>休</strong></font>");
                dic.Add(EyouSoft.Model.EnumType.GovStructure.AttendanceType.早退, "<font color='#008000'><strong>退</strong></font>");
                for (int i = 0; i < data.Count; i++)
                {
                    str.AppendFormat("<tr><td align='center' style='vnd.ms-excel.numberformat:@'>{0}</td><td align='center'>{1}</td><td align='center'>{2}</td>",
                                     data[i].FileNumber, data[i].DepartName, data[i].Name);
                    for (int j = 0; j < days; j++)
                    {
                        DateTime dtCurrent = Convert.ToDateTime(String.Format("{0}-{1}-{2}", year, month, j + 1));
                        if (data[i].AttendanceList != null && data[i].AttendanceList.Count > 0)
                        {
                            IList <MGovAttendance> list = data[i].AttendanceList.Where(a => (a.AttendanceTime.Value.Date == dtCurrent)).ToList();
                            if (list != null && list.Count > 0)
                            {
                                str.AppendFormat("<td>{0}</td>", dic[list.First().AttendanceType]);
                            }
                            else
                            {
                                str.Append("<td></td>");
                            }
                        }
                        else
                        {
                            str.Append("<td></td>");
                        }
                    }
                    str.Append("</tr>");
                }
            }
            str.AppendFormat("</table>");
            string browser  = this.Context.Request.UserAgent.ToUpper();
            String fileName = "考勤汇总信息.xls";

            if (browser.Contains("MS") && browser.Contains("IE"))
            {
                fileName = System.Web.HttpUtility.UrlEncode(fileName, Encoding.UTF8);
            }

            ResponseToXls(str.ToString(), Encoding.UTF8, fileName);
        }