Example #1
0
 public ActionResult PONoModify(T_GM_Project am)
 {
     am.AgentMan    = user.EmployeeId;
     am.OfferStatus = string.IsNullOrEmpty(am.CustomerNo)?"否": "是";
     DB.T_GM_Project.Attach(am);
     DB.Entry(am).State = EntityState.Modified;
     DB.SaveChanges();
     return(this.Direct());
 }
Example #2
0
        public ActionResult PONoAdd(string prono, T_GM_Project am)
        {
            am.UID         = Guid.NewGuid().ToString();
            am.BudgetGID   = DB.V_GM_DetailBudget.Where(w => w.ProjectNo == prono).Where(w => w.Description == "审核通过").Where(w => w.BudgetStatus == null).ToList().FirstOrDefault().GID;
            am.AgentMan    = user.EmployeeId;
            am.AgentDate   = DateTime.Now;
            am.OfferStatus = string.IsNullOrEmpty(am.CustomerNo) ? "否" : "是";
            var budget = DB.T_GM_Budget.Find(am.BudgetGID);

            budget.BudgetStatus = "未开工";
            DB.T_GM_Budget.Attach(budget);
            DB.Entry(budget).State = EntityState.Modified;
            var    uploadfile  = this.GetCmp <FileUploadField>("AttachmentPath");
            int    filesize    = uploadfile.PostedFile.ContentLength;
            string fileoldname = uploadfile.FileName;

            if (filesize > 20 * 1024 * 1024)
            {
                X.Msg.Alert("提示", "上传文件过大,大小必须低于20M").Show();
                return(this.Direct());
            }
            if (uploadfile.HasFile)
            {
                string filenewname = Guid.NewGuid().ToString() + Path.GetExtension(fileoldname);
                string logicpath   = "~/AttachFile/ProjectPONo/" + filenewname;
                string filepath    = Server.MapPath(logicpath);
                am.AttachmentPath = logicpath;
                uploadfile.PostedFile.SaveAs(filepath);
            }

            DB.T_GM_Project.Add(am);

            var material_list = DB.T_GM_DM.Where(w => w.Remark == am.BudgetGID).ToList();

            foreach (var item in material_list)
            {
                var detail = new T_GM_DM();
                detail.Remark = am.UID;
                detail.MFlID  = item.MFlID;
                detail.NO     = item.NO;
                detail.Num    = item.Num;
                detail.Price  = item.Price;
                detail.Type   = "FPM";
                DB.T_GM_DM.Add(detail);
            }
            DB.SaveChanges();
            DirectResult result = new DirectResult();

            result.IsUpload = true;
            return(result);
        }