public ActionResult SubmitCheck(DailyWorkReportModel model, string id)
        {
            //model.OperationID = id;
            //bool flag = model.SubmitCheck();
            //X.Msg.Alert("页面消息", flag ? "审核操作成功!" : "审核操作失败!", flag ? "parent.App.win.close();" : null).Show();
            //if (flag)
            //{
            //    X.AddScript("parent.App.storedata.reload();");
            //}
            //return this.Direct();

            try
            {
                model.OperationID = id;
                bool flag      = model.SubmitCheck();
                bool newwindow = false;
                if (Session["NewWindow"] != null)
                {
                    newwindow = Convert.ToBoolean(Session["NewWindow"]);
                }
                X.Msg.Alert("页面消息", flag ? "审核操作成功!" : "审核操作失败!", flag ? (newwindow ? "parent.App.win.close();" : "history.go(-1);") : null).Show();
                if (flag)
                {
                    X.AddScript("parent.App.storedata.reload();");
                }
                return(this.Direct());
            }
            catch (Exception e)
            {
                return(this.Direct(false, e.Message));
            }
        }
        public ActionResult Detail(string id)
        {
            var result = new DailyWorkReportModel().GetDetailReport(id);

            if (result == null)
            {
                return(View("Error"));
            }
            return(View(result));
        }
        public ActionResult Submit(DailyWorkReportModel model)
        {
            string chongfu = Chongfu(model.WorkHourses);

            if (chongfu != "-11111")
            {
                var staff = from o in entities.T_HR_Staff
                            where o.StaffID == chongfu
                            select o;
                chongfu = "工号:" + chongfu + ",姓名:" + staff.First().Name;
                X.Msg.Alert("警告", "具有重复员工!<\br>" + chongfu).Show();
                return(this.Direct());
            }

            string chongfudb = ChongfuComDB(model);

            if (chongfudb != "-11111")
            {
                X.Msg.Alert("警告", chongfudb).Show();
                return(this.Direct());
            }

            FileUtility attachFile = new FileUtility();

            FileUploadField upload = this.GetCmp <FileUploadField>("AnnetPath");

            attachFile.File = upload.PostedFile;

            if (upload.HasFile)
            {
                model.AttachFile = string.Format("~/AttachFile/DailyWorkReport/{0}/{1}.{2}", DateTime.Now.Date.ToString("yyyy-MM-dd"), Guid.NewGuid(),
                                                 Path.GetExtension(attachFile.File.FileName));
                attachFile.FilePath = model.AttachFile;
                attachFile.SavePath = Server.MapPath(attachFile.FilePath);
                attachFile.FileType = attachFile.File.ContentType;
            }

            bool flag = model.Save(this, attachFile);

            X.Msg.Alert("页面消息", flag ? "工作日报提交成功!" : "工作日报提交失败!", flag?"parent.App.win.close();":null).Show();
            if (flag)
            {
                X.AddScript("parent.App.storedata.reload();");
            }
            return(this.Direct());
        }
        public ActionResult Check(string id)
        {
            var checkObject = new DailyWorkReportModel().GetChechReport(id);

            if (checkObject == null)
            {
                return(View("Expire"));
            }
            ViewBag.id = checkObject.OperationID;
            string staffid = "";

            foreach (var item in checkObject.WorkHourses)
            {
                staffid += item.EmployeeID + ",";
            }
            staffid = staffid.Substring(0, staffid.Length - 1);
            Session["xgw_dailyreport_staffid"] = staffid;
            Session["xgw_dailyreport_date"]    = checkObject.Date;
            return(View(checkObject));
        }
        public string ChongfuComDB(DailyWorkReportModel model)
        {
            string  flag = "-11111";
            decimal dhs, ehs;
            string  q;

            foreach (var item in model.WorkHourses)
            {
                dhs = 0;
                ehs = 0;
                //q = entities.V_US_WorkReportWithHours.Where(o => o.EmployeeID == item.EmployeeID).Where(o => o.Date == model.Date).Sum(o => o.DutyHours).ToString();
                //if (String.IsNullOrEmpty(q))
                //    dhs = 0;
                var list = from o in entities.V_US_WorkReportWithHours
                           where o.EmployeeID == item.EmployeeID && o.Date == model.Date
                           select o;
                if (list.Any())
                {
                    foreach (var li in list)
                    {
                        dhs += li.DutyHours;
                        ehs += li.ExtraHours;
                    }
                }

                if (dhs + item.DutyHours > 8)
                {
                    flag = "具有员工该天正班工时将超过8小时,禁止添加!<br />工号:" + item.EmployeeID + ",姓名:" + item.EmployeeName + ",已有正班工时:" + dhs.ToString() + "计划添加工时:" + item.DutyHours.ToString();
                    break;
                }
                if (ehs + item.ExtraHours > 16)
                {
                    flag = "具有员工该天加班工时将超过16小时,禁止添加!<br />工号:" + item.EmployeeID + ",姓名:" + item.EmployeeName + ",已有加班工时:" + ehs.ToString() + "计划添加工时:" + item.ExtraHours.ToString();
                    break;
                }
            }
            return(flag);
        }
        public ActionResult Fiter(StoreRequestParameters parameters, string name = "", string date = "")
        {
            var list = new DailyWorkReportModel().Select(name, date);

            return(this.Store(list.GetPage(parameters)));
        }