コード例 #1
0
        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());
        }