Example #1
0
        public ActionResult Update(ProfileTemporaryDTO update)
        {
            if (Const.IsNullOrEmpty(update.Project_Code))
            {
                return Json(new
                {
                    success = false,
                    errors = "B001",
                    message = "项目编码必须填写."
                }, "text/html", JsonRequestBehavior.AllowGet);
            }

            if (Const.IsNullOrEmpty(update.Project_Code))
            {
                return Json(new
                {
                    success = false,
                    errors = "B002",
                    message = "项目名称必须填写."
                }, "text/html", JsonRequestBehavior.AllowGet);
            }

            if (Const.IsNullOrEmpty(update.Project_Stage))
            {
                return Json(new
                {
                    success = false,
                    errors = "B003",
                    message = "项目阶段必须填写."
                }, "text/html", JsonRequestBehavior.AllowGet);
            }

            if (Const.IsNullOrEmpty(update.Project_Subject))
            {
                return Json(new
                {
                    success = false,
                    errors = "B004",
                    message = "项目专业必须填写."
                }, "text/html", JsonRequestBehavior.AllowGet);
            }

            using (DataClassesDataContext data = new DataClassesDataContext())
            {
                List<ProfileTemporaryDTO> items = data.ProfileTemporaryDTO
                    .Where(u => u.Barcode == update.Barcode)
                    .ToList();

                if (items.Count > 0)
                {
                    ProfileTemporaryDTO entity = items.First();

                    entity.Diagram_Name = update.Diagram_Name;
                    entity.Diagram_Code = update.Diagram_Code;
                    entity.Diagram_Version = update.Diagram_Version;
                    entity.Diagram_Scale = update.Diagram_Scale;

                    entity.Project_Code = update.Project_Code;
                    entity.Project_Name = update.Project_Name;
                    entity.Project_Stage = update.Project_Stage.Replace(" ", "");
                    entity.Project_Subject = update.Project_Subject.Replace(" ", "");
                    entity.Project_Date = Const.StripSubfix(update.Project_Code);

                    entity.Business_Owner = update.Business_Owner;
                    entity.File_Name = update.File_Name;
                    data.SubmitChanges();
                }
                else
                {
                    return Json(new
                    {
                        success = true,
                        errors = "B008",
                        message = "无预备归档记录."
                    }, "text/html", JsonRequestBehavior.AllowGet);
                }
            }

            return Json(new
            {
                success = true,
                errors = "B000",
                message = "操作已成功."
            }, "text/html", JsonRequestBehavior.AllowGet);
        }
 partial void UpdateProfileTemporaryDTO(ProfileTemporaryDTO instance);
 partial void DeleteProfileTemporaryDTO(ProfileTemporaryDTO instance);
 partial void InsertProfileTemporaryDTO(ProfileTemporaryDTO instance);