Exemplo n.º 1
0
        /// <summary>
        /// 初始化
        /// </summary>
        private void DataInit()
        {
            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.SectionID   = sectionID;
            this.SelectSection1.SectionName = sectionName;
            //获取分页参数并强转
            pageIndex = Utils.GetInt(Utils.GetQueryStringValue("page"), 1);
            EyouSoft.BLL.GovStructure.BAttendance BLL = new EyouSoft.BLL.GovStructure.BAttendance();
            IList <EyouSoft.Model.GovStructure.MAttendanceAbout> lst = BLL.GetList(txtNum, txtName, sectionID, sectionName, this.SiteUserInfo.CompanyId, this.pageSize, this.pageIndex, ref this.recordCount);

            if (null != lst && lst.Count > 0)
            {
                this.RepList.DataSource = lst;
                this.RepList.DataBind();
                if (recordCount <= pageSize)
                {
                    this.ExporPageInfoSelect1.Visible = false;
                }
                else
                {
                    BindPage();
                }
            }
            else
            {
                this.RepList.Controls.Add(new Label()
                {
                    Text = "<tr><td colspan='7' align='center'>对不起,没有相关数据!</td></tr>"
                });
                this.ExporPageInfoSelect1.Visible = false;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 保存按钮点击事件执行方法
        /// </summary>
        protected void PageSave(string id)
        {
            //数据验证开始
            StringBuilder strMsg = new StringBuilder();

            if (String.IsNullOrEmpty(this.txtTime.Value))
            {
                strMsg.Append("考勤时间不能为空!\\n");
            }
            if (!this.ckChiDao.Checked && !this.ckKuangGong.Checked && !this.ckZaoTui.Checked && !this.ckZuiDian.Checked && !this.ckLeave.Checked && !this.ckAdd.Checked)
            {
                strMsg.Append("考勤类型必须选择!\\n");
            }
            if (this.ckLeave.Checked)
            {
                if (String.IsNullOrEmpty(this.txtLeaveStartTime.Value) || String.IsNullOrEmpty(this.txtLeaveEndTime.Value))
                {
                    strMsg.Append("请假时间不能为空!\\n");
                }
                else
                {
                    if (Convert.ToDateTime(this.txtLeaveEndTime.Value).Subtract(Convert.ToDateTime(this.txtLeaveStartTime.Value)).Ticks < 0)
                    {
                        strMsg.Append("请假结束时间不能早于开始时间!\\n");
                    }
                }
            }
            if (this.ckAdd.Checked)
            {
                if (String.IsNullOrEmpty(this.txtAddEndTime.Value) || String.IsNullOrEmpty(this.txtAddStartTime.Value))
                {
                    strMsg.Append("加班时间不能为空!\\n");
                }
                else
                {
                    if (Convert.ToDateTime(this.txtAddEndTime.Value).Subtract(Convert.ToDateTime(this.txtAddStartTime.Value)).Ticks < 0)
                    {
                        strMsg.Append("加班结束时间不能早于开始时间!\\n");
                    }
                }
            }
            if (strMsg.Length > 0)
            {
                MessageBox.ResponseScript(this, String.Format("alert('{0}');", strMsg));
                return;
            }
            //数据验证结束
            EyouSoft.BLL.GovStructure.BAttendance             BLL = new EyouSoft.BLL.GovStructure.BAttendance();
            List <EyouSoft.Model.GovStructure.MGovAttendance> lst = new List <EyouSoft.Model.GovStructure.MGovAttendance>();
            String workStart = "08:00"; //工作时间(始)
            String workEnd   = "18:00"; //工作时间(终)

            foreach (Control c in this.form1.Controls)
            {
                if (c.GetType().ToString().Equals("System.Web.UI.HtmlControls.HtmlInputCheckBox"))
                {
                    System.Web.UI.HtmlControls.HtmlInputCheckBox ck = (System.Web.UI.HtmlControls.HtmlInputCheckBox)c;
                    if (ck.Checked)
                    {
                        if (ck == this.ckLeave)//请假
                        {
                            DateTime?leaveStartTime = Utils.GetDateTimeNullable(this.txtLeaveStartTime.Value);
                            DateTime?leaveEndTime   = Utils.GetDateTimeNullable(this.txtLeaveEndTime.Value);
                            if (null != leaveStartTime && null != leaveEndTime)
                            {
                                this.getDays(leaveStartTime.ToString(), leaveEndTime.ToString(), workStart, workEnd, lst, ck, id);
                            }
                        }
                        else if (ck == this.ckAdd)//加班
                        {
                            DateTime?addStartTime = Utils.GetDateTimeNullable(this.txtAddStartTime.Value);
                            DateTime?addEndTime   = Utils.GetDateTimeNullable(this.txtAddEndTime.Value);
                            if (null != addStartTime && null != addEndTime)
                            {
                                this.getDays(addStartTime.ToString(), addEndTime.ToString(), workStart, workEnd, lst, ck, id);
                            }
                        }
                        else
                        {
                            //检查是否已经登记过考勤
                            if (BLL.ExistsNum(this.SiteUserInfo.CompanyId, id, Convert.ToDateTime(this.txtTime.Value), (AttendanceType)Utils.GetInt(ck.Value), ""))
                            {
                                MessageBox.ResponseScript(this, "alert('抱歉, 该用户的考勤已经登记过了!');");
                                return;
                            }
                            MGovAttendance Model = new MGovAttendance();
                            this.commonModel(Model, id, ck, Convert.ToDateTime(this.txtTime.Value));
                            lst.Add(Model);
                        }
                    }
                }
            }
            bool result = BLL.AddAllGovAttendanceList(lst);

            if (result)
            {
                Utils.ShowMsgAndCloseBoxy("登记成功!", Utils.GetQueryStringValue("IframeId"), true);
            }
            else
            {
                EyouSoft.Common.Function.MessageBox.ResponseScript(this, "alert('登记失败!');");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 保存
        /// </summary>
        protected void PageSave()
        {
            #region 表单取值
            string atttype   = Utils.GetFormValue(attType.UniqueID);
            string stime     = Utils.GetFormValue(tbStime.UniqueID);
            string etime     = Utils.GetFormValue(tbEtime.UniqueID);
            string sub       = Utils.GetFormValue(subject.UniqueID);
            string ids       = Utils.GetFormValue(hdattenIds.UniqueID);
            string names     = Utils.GetFormValue(hdattenNames.UniqueID);
            string depts     = Utils.GetFormValue(hdattenDepts.UniqueID);
            string timecount = Utils.GetFormValue(timeCount.UniqueID);
            #endregion

            #region 表单验证
            string msg = string.Empty;
            if (string.IsNullOrEmpty(stime))
            {
                msg += "请选择考勤开始时间!";
            }
            if (string.IsNullOrEmpty(etime))
            {
                msg += "请选择考勤结束时间!";
            }
            if (string.IsNullOrEmpty(sub) && Utils.GetInt(atttype, 0) > 0)
            {
                msg += "请输入原因!";
            }
            if (!string.IsNullOrEmpty(msg))
            {
                Response.Clear();
                Response.Write(UtilsCommons.AjaxReturnJson("0", msg));
                Response.End();
            }
            #endregion

            #region 实体赋值
            //时间
            TimeSpan ts    = new TimeSpan(Utils.GetDateTime(stime).Ticks);
            TimeSpan te    = new TimeSpan(Utils.GetDateTime(etime).Ticks);
            TimeSpan total = ts.Subtract(te).Duration();
            IList <MGovAttendance> list = new List <MGovAttendance>();
            string[] arryIds            = ids.Split(',');
            string[] arryNames          = names.Split('、');
            string[] arryDepts          = depts.Split(',');
            if (arryIds.Length == arryNames.Length && arryIds.Length == arryDepts.Length)
            {
                //小于一天
                if (total.Days == 0)
                {
                    for (int i = 0; i < arryIds.Length; i++)
                    {
                        MGovAttendance model = new MGovAttendance();
                        model.StaffId        = arryIds[i];
                        model.CompanyId      = this.SiteUserInfo.CompanyId;
                        model.DeptId         = Utils.GetInt(arryDepts[i]);
                        model.OperatorId     = this.SiteUserInfo.UserId;
                        model.AttendanceType = (AttendanceType)(Utils.GetInt(atttype));
                        model.StartTime      = Utils.GetDateTimeNullable(stime);
                        model.AttendanceTime = Utils.GetDateTimeNullable(stime);
                        model.EndTime        = Utils.GetDateTimeNullable(etime);
                        model.Subject        = sub;
                        model.TimeCount      = string.IsNullOrEmpty(timecount) ? 1 : Utils.GetDecimal(timecount);;
                        model.IssueTime      = DateTime.Now;
                        model.OperatorId     = this.SiteUserInfo.UserId;
                        list.Add(model);
                    }
                }
                else
                {
                    //大于一天
                    for (int j = 0; j < total.Days; j++)
                    {
                        for (int i = 0; i < arryIds.Length; i++)
                        {
                            MGovAttendance model = new MGovAttendance();
                            model.StaffId        = arryIds[i];
                            model.CompanyId      = this.SiteUserInfo.CompanyId;
                            model.DeptId         = Utils.GetInt(arryDepts[i]);
                            model.OperatorId     = this.SiteUserInfo.UserId;
                            model.AttendanceType = (AttendanceType)(Utils.GetInt(atttype));
                            model.AttendanceTime = Utils.GetDateTime(stime).AddDays(j);
                            model.StartTime      = Utils.GetDateTime(stime).AddDays(j);
                            model.EndTime        = Utils.GetDateTime(etime).AddDays(-total.Days + j);
                            model.Subject        = sub;
                            model.TimeCount      = (AttendanceType)(Utils.GetInt(atttype, 0)) == AttendanceType.加班 ? Utils.GetDecimal(timecount) : 1;;
                            model.IssueTime      = DateTime.Now;
                            model.OperatorId     = this.SiteUserInfo.UserId;
                            list.Add(model);
                        }
                    }
                    //多出的小时数
                    if (total.Hours > 0)
                    {
                        for (int i = 0; i < arryIds.Length; i++)
                        {
                            MGovAttendance model = new MGovAttendance();
                            model.StaffId        = arryIds[i];
                            model.CompanyId      = this.SiteUserInfo.CompanyId;
                            model.DeptId         = Utils.GetInt(arryDepts[i]);
                            model.OperatorId     = this.SiteUserInfo.UserId;
                            model.AttendanceType = (AttendanceType)(Utils.GetInt(atttype));
                            model.AttendanceTime = Utils.GetDateTime(stime).AddDays(total.Days);
                            model.StartTime      = Utils.GetDateTime(stime).AddDays(total.Days);
                            model.EndTime        = Utils.GetDateTimeNullable(etime);
                            model.Subject        = sub;
                            model.TimeCount      = (AttendanceType)(Utils.GetInt(atttype, 0)) == AttendanceType.加班 ? Utils.GetDecimal(timecount) : 1;;
                            model.IssueTime      = DateTime.Now;
                            model.OperatorId     = this.SiteUserInfo.UserId;
                            list.Add(model);
                        }
                    }
                }
            }
            #endregion

            #region 提交验证
            EyouSoft.BLL.GovStructure.BAttendance BLL = new EyouSoft.BLL.GovStructure.BAttendance();
            bool result = BLL.AddAllGovAttendanceList(list);
            msg = result ? "批量考勤成功!" : "批量考勤失败!";
            Response.Clear();
            Response.Write(UtilsCommons.AjaxReturnJson(result ? "1" : "0", msg));
            Response.End();
            #endregion
        }