コード例 #1
0
        public ActionResult CreateBusiness(int?userid)
        {
            GetProjectType();
            CreateOrgBusinessRequest createOrgBusinessRequest = new CreateOrgBusinessRequest {
                UserId = userid ?? 0
            };

            return(View(createOrgBusinessRequest));
        }
コード例 #2
0
        public ActionResult CreateBusiness(CreateOrgBusinessRequest request)
        {
            if (!ModelState.IsValid)
            {
                GetProjectType();
                return(View());
            }

            if (request == null)
            {
                ModelState.AddModelError("", "参数不能为空");
                GetProjectType();
                return(View());
            }


            if (Request.Files.Count < 3)
            {
                ModelState.AddModelError("", "请上传制定的附件");
                GetProjectType();
                return(View());
            }

            string contract = string.Empty;
            string report   = string.Empty;
            string price    = string.Empty;
            string other    = string.Empty;
            string path     = Server.MapPath("~/upload");


            if (!string.IsNullOrEmpty(Request.Files[0].FileName))
            {
                contract = Guid.NewGuid().ToString();
                Request.Files[0].SaveAs(path + "/" + contract + ".doc");
            }

            if (!string.IsNullOrEmpty(Request.Files[1].FileName))
            {
                report = Guid.NewGuid().ToString();
                Request.Files[1].SaveAs(path + "/" + report + ".doc");
            }

            if (!string.IsNullOrEmpty(Request.Files[2].FileName))
            {
                price = Guid.NewGuid().ToString();
                Request.Files[2].SaveAs(path + "/" + price + ".doc");
            }

            if (!string.IsNullOrEmpty(Request.Files[3].FileName))
            {
                other = Guid.NewGuid().ToString();
                Request.Files[3].SaveAs(path + "/" + other + ".doc");
            }

            UserInfoDto user = null;

            if (request.UserId.HasValue && request.UserId.Value != 0)
            {
                user = generateService.GetUserById(request.UserId.Value);
            }
            else
            {
                user = UserInfo;
            }

            Org_BusinessDto business = new Org_BusinessDto
            {
                auditunit      = request.auditunit,
                buildunit      = request.buildunit,
                compileunit    = request.compileunit,
                createtime     = DateTime.Now,
                creator        = UserInfo?.LoginName,
                creatorid      = UserInfo?.LoginID,
                orgname        = UserInfo?.OrgName ?? string.Empty,
                projectname    = request.projectname ?? string.Empty,
                projectsummary = request.projectsummary ?? string.Empty,
                projecttype    = request.projecttype ?? string.Empty,
                statues        = 0,
                updatetime     = DateTime.Now,
                contract       = contract,
                other          = other,
                price          = price,
                report         = report
            };

            generateService.CreateBusiness(business);
            if (request.UserId.HasValue && request.UserId.Value != 0)
            {
                return(Redirect("/sys/OperationResult?returnurl=/Admin/getBusiness?loginid=" + user.LoginID));
            }
            else
            {
                return(Redirect("/sys/OperationResult?returnurl=/Admin/getBusiness"));
            }
        }