Example #1
0
        /// <summary>
        /// 保存Check_PauseNotice
        /// </summary>
        /// <param name="newItem">工程暂停令</param>
        /// <returns></returns>
        public static void SavePauseNotice(Model.PauseNoticeItem newItem)
        {
            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                Model.Check_PauseNotice newPauseNotice = new Model.Check_PauseNotice
                {
                    PauseNoticeId   = newItem.PauseNoticeId,
                    PauseNoticeCode = newItem.PauseNoticeCode,
                    ProjectId       = newItem.ProjectId,
                    UnitId          = newItem.UnitId,
                    ProjectPlace    = newItem.ProjectPlace,
                    WrongContent    = newItem.WrongContent,
                    PauseTime       = Funs.GetNewDateTime(newItem.PauseTime),
                    PauseContent    = newItem.PauseContent,
                    OneContent      = newItem.OneContent,
                    SecondContent   = newItem.SecondContent,
                    ThirdContent    = newItem.ThirdContent,
                    States          = Const.State_0,
                    PauseStates     = newItem.PauseStates,
                };

                var getUpdate = db.Check_PauseNotice.FirstOrDefault(x => x.PauseNoticeId == newItem.PauseNoticeId);
                if (getUpdate == null)
                {
                    newPauseNotice.CompileDate     = DateTime.Now;
                    newPauseNotice.PauseNoticeId   = SQLHelper.GetNewID();
                    newPauseNotice.PauseNoticeCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectPauseNoticeMenuId, newPauseNotice.ProjectId, newPauseNotice.UnitId);
                    db.Check_PauseNotice.InsertOnSubmit(newPauseNotice);
                    db.SubmitChanges();

                    CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectPauseNoticeMenuId, newPauseNotice.ProjectId, newPauseNotice.UnitId, newPauseNotice.PauseNoticeId, newPauseNotice.CompileDate);
                    //// 回写巡检记录表
                    if (!string.IsNullOrEmpty(newItem.HazardRegisterId))
                    {
                        List <string> listIds = Funs.GetStrListByStr(newItem.HazardRegisterId, ',');
                        foreach (var item in listIds)
                        {
                            var getHazardRegister = Funs.DB.HSSE_Hazard_HazardRegister.FirstOrDefault(x => x.HazardRegisterId == item);
                            if (getHazardRegister != null)
                            {
                                getHazardRegister.States      = "3";
                                getHazardRegister.HandleIdea += "已下发工程暂停令:" + newPauseNotice.PauseNoticeCode;
                                getHazardRegister.ResultId    = newPauseNotice.PauseNoticeId;
                                getHazardRegister.ResultType  = "3";
                                Funs.SubmitChanges();
                            }
                        }
                    }
                    //// 回写专项检查明细表
                    if (!string.IsNullOrEmpty(newItem.CheckSpecialDetailId))
                    {
                        List <string> listIds = Funs.GetStrListByStr(newItem.CheckSpecialDetailId, ',');
                        foreach (var item in listIds)
                        {
                            var getCheckSpecialDetail = db.Check_CheckSpecialDetail.FirstOrDefault(x => x.CheckSpecialDetailId == item);
                            if (getCheckSpecialDetail != null)
                            {
                                getCheckSpecialDetail.DataType = "3";
                                getCheckSpecialDetail.DataId   = newPauseNotice.PauseNoticeId;
                                db.SubmitChanges();
                            }
                        }
                    }
                }
                else
                {
                    newPauseNotice.PauseNoticeId = getUpdate.PauseNoticeId;
                    getUpdate.PauseStates        = newItem.PauseStates;
                    if (newPauseNotice.PauseStates == "0" || newPauseNotice.PauseStates == "1")  ////编制人 修改或提交
                    {
                        getUpdate.UnitId        = newPauseNotice.UnitId;
                        getUpdate.ProjectPlace  = newPauseNotice.ProjectPlace;
                        getUpdate.WrongContent  = newPauseNotice.WrongContent;
                        getUpdate.PauseTime     = newPauseNotice.PauseTime;
                        getUpdate.PauseContent  = newPauseNotice.PauseContent;
                        getUpdate.OneContent    = newPauseNotice.OneContent;
                        getUpdate.SecondContent = newPauseNotice.SecondContent;
                        getUpdate.ThirdContent  = newPauseNotice.ThirdContent;
                        if (newPauseNotice.PauseStates == "1" && !string.IsNullOrEmpty(newItem.SignManId))
                        {
                            getUpdate.SignManId = newItem.SignManId;
                        }
                        else
                        {
                            newPauseNotice.PauseStates = getUpdate.PauseStates = "0";
                        }
                    }
                    else if (newPauseNotice.PauseStates == "2") ////【签发】总包安全经理
                    {
                        /// 不同意 打回 同意抄送专业工程师、施工经理、相关施工分包单位并提交【批准】总包项目经理
                        if (newItem.IsAgree == false)
                        {
                            newPauseNotice.PauseStates = getUpdate.PauseStates = "0";
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(newItem.ProfessionalEngineerId))
                            {
                                getUpdate.ProfessionalEngineerId = newItem.ProfessionalEngineerId;
                            }
                            if (!string.IsNullOrEmpty(newItem.ConstructionManagerId))
                            {
                                getUpdate.ConstructionManagerId = newItem.ConstructionManagerId;
                            }
                            if (!string.IsNullOrEmpty(newItem.UnitHeadManId))
                            {
                                getUpdate.UnitHeadManId = newItem.UnitHeadManId;
                            }
                            if (!string.IsNullOrEmpty(newItem.SupervisorManId))
                            {
                                getUpdate.SupervisorManId = newItem.SupervisorManId;
                            }
                            if (!string.IsNullOrEmpty(newItem.OwnerId))
                            {
                                getUpdate.OwnerId = newItem.OwnerId;
                            }
                            if (!string.IsNullOrEmpty(newItem.ApproveManId))
                            {
                                getUpdate.ApproveManId = newItem.ApproveManId;
                                getUpdate.SignDate     = DateTime.Now;
                            }
                            else
                            {
                                newPauseNotice.PauseStates = getUpdate.States = "1";
                            }
                        }
                    }
                    else if (newPauseNotice.PauseStates == "3") ////【批准】总包项目经理
                    {
                        /// 不同意 打回 同意下发【回执】施工分包单位
                        if (newItem.IsAgree == false || string.IsNullOrEmpty(newItem.DutyPersonId))
                        {
                            newPauseNotice.PauseStates = getUpdate.PauseStates = "1";
                        }
                        else
                        {
                            getUpdate.DutyPersonId = newItem.DutyPersonId;
                            getUpdate.ApproveDate  = DateTime.Now;
                            getUpdate.IsConfirm    = true;
                        }
                    }
                    else if (newPauseNotice.PauseStates == "4") ////【批准】总包项目经理
                    {
                        getUpdate.DutyPersonDate = DateTime.Now;
                        getUpdate.States         = Const.State_2;
                    }

                    db.SubmitChanges();
                }

                if (newItem.PauseStates == Const.State_0 || newItem.PauseStates == Const.State_1)
                {     //// 通知单附件
                    UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(newItem.PauseNoticeAttachUrl, 10, null), newItem.PauseNoticeAttachUrl, Const.ProjectPauseNoticeMenuId, newPauseNotice.PauseNoticeId);
                }
                if (getUpdate != null && getUpdate.States == Const.State_2)
                {
                    CommonService.btnSaveData(newPauseNotice.ProjectId, Const.ProjectPauseNoticeMenuId, newPauseNotice.PauseNoticeId, newPauseNotice.CompileManId, true, newPauseNotice.PauseContent, "../Check/PauseNoticeView.aspx?PauseNoticeId={0}");

                    var getcheck = from x in db.Check_CheckSpecialDetail where x.DataId == getUpdate.PauseNoticeId select x;
                    if (getcheck.Count() > 0)
                    {
                        foreach (var item in getcheck)
                        {
                            item.CompleteStatus = true;
                            item.CompletedDate  = DateTime.Now;
                            db.SubmitChanges();
                        }
                    }
                }
            }
        }