/// <summary>
 /// 添加安全综合检查
 /// </summary>
 /// <param name="checkColligation"></param>
 public static void AddCheckColligation(Model.Check_CheckColligation checkColligation)
 {
     Model.SUBHSSEDB db = Funs.DB;
     Model.Check_CheckColligation newCheckColligation = new Model.Check_CheckColligation
     {
         CheckColligationId   = checkColligation.CheckColligationId,
         CheckColligationCode = checkColligation.CheckColligationCode,
         ProjectId            = checkColligation.ProjectId,
         CheckType            = checkColligation.CheckType,
         CheckPerson          = checkColligation.CheckPerson,
         CheckTime            = checkColligation.CheckTime,
         ScanUrl           = checkColligation.ScanUrl,
         DaySummary        = checkColligation.DaySummary,
         PartInUnits       = checkColligation.PartInUnits,
         PartInPersons     = checkColligation.PartInPersons,
         PartInPersonIds   = checkColligation.PartInPersonIds,
         PartInPersonNames = checkColligation.PartInPersonNames,
         CheckAreas        = checkColligation.CheckAreas,
         States            = checkColligation.States,
         CompileMan        = checkColligation.CompileMan
     };
     db.Check_CheckColligation.InsertOnSubmit(newCheckColligation);
     db.SubmitChanges();
     ////增加一条编码记录
     BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(BLL.Const.ProjectCheckColligationMenuId, checkColligation.ProjectId, null, checkColligation.CheckColligationId, checkColligation.CheckTime);
 }
        private void SaveNew()
        {
            if (string.IsNullOrEmpty(this.CheckColligationId))
            {
                Model.Check_CheckColligation checkColligation = new Model.Check_CheckColligation
                {
                    CheckColligationId   = SQLHelper.GetNewID(typeof(Model.Check_CheckColligation)),
                    CheckColligationCode = this.txtCheckColligationCode.Text.Trim(),
                    ProjectId            = this.ProjectId
                };
                if (this.drpCheckType.SelectedValue != BLL.Const._Null)
                {
                    checkColligation.CheckType = this.drpCheckType.SelectedValue;
                }
                //参与单位
                string unitIds = string.Empty;
                foreach (var item in this.drpUnit.SelectedValueArray)
                {
                    unitIds += item + ",";
                }
                if (!string.IsNullOrEmpty(unitIds))
                {
                    unitIds = unitIds.Substring(0, unitIds.LastIndexOf(","));
                }
                checkColligation.PartInUnits = unitIds;
                if (this.drpCheckPerson.SelectedValue != BLL.Const._Null)
                {
                    checkColligation.CheckPerson = this.drpCheckPerson.SelectedValue;
                }

                ///组成员
                string partInPersonIds = string.Empty;
                string partInPersons   = string.Empty;
                foreach (var item in this.drpPartInPersons.SelectedValueArray)
                {
                    var user = BLL.UserService.GetUserByUserId(item);
                    if (user != null)
                    {
                        partInPersonIds += user.UserId + ",";
                        partInPersons   += user.UserName + ",";
                    }
                }
                if (!string.IsNullOrEmpty(partInPersonIds))
                {
                    checkColligation.PartInPersonIds = partInPersonIds.Substring(0, partInPersonIds.LastIndexOf(","));
                    checkColligation.PartInPersons   = partInPersons.Substring(0, partInPersons.LastIndexOf(","));
                }
                checkColligation.PartInPersonNames = this.txtPartInPersonNames.Text.Trim();

                checkColligation.CheckTime  = Funs.GetNewDateTime(this.txtCheckDate.Text.Trim());
                checkColligation.DaySummary = HttpUtility.HtmlEncode(this.txtDaySummary.Text.Trim());
                ////单据状态
                checkColligation.States     = BLL.Const.State_0;
                this.CheckColligationId     = checkColligation.CheckColligationId;
                checkColligation.CompileMan = this.CurrUser.UserId;
                BLL.Check_CheckColligationService.AddCheckColligation(checkColligation);
                BLL.LogService.AddSys_Log(this.CurrUser, checkColligation.CheckColligationCode, checkColligation.CheckColligationId, BLL.Const.ProjectCheckColligationMenuId, BLL.Const.BtnAdd);
            }
        }
 /// <summary>
 /// 修改安全综合检查
 /// </summary>
 /// <param name="checkColligation"></param>
 public static void UpdateCheckColligation(Model.Check_CheckColligation checkColligation)
 {
     Model.SUBHSSEDB db = Funs.DB;
     Model.Check_CheckColligation newCheckColligation = db.Check_CheckColligation.FirstOrDefault(e => e.CheckColligationId == checkColligation.CheckColligationId);
     if (newCheckColligation != null)
     {
         newCheckColligation.CheckColligationCode = checkColligation.CheckColligationCode;
         //newCheckColligation.ProjectId = checkColligation.ProjectId;
         newCheckColligation.CheckType         = checkColligation.CheckType;
         newCheckColligation.CheckPerson       = checkColligation.CheckPerson;
         newCheckColligation.CheckTime         = checkColligation.CheckTime;
         newCheckColligation.ScanUrl           = checkColligation.ScanUrl;
         newCheckColligation.DaySummary        = checkColligation.DaySummary;
         newCheckColligation.PartInUnits       = checkColligation.PartInUnits;
         newCheckColligation.PartInPersons     = checkColligation.PartInPersons;
         newCheckColligation.PartInPersonNames = checkColligation.PartInPersonNames;
         newCheckColligation.PartInPersonIds   = checkColligation.PartInPersonIds;
         newCheckColligation.CheckAreas        = checkColligation.CheckAreas;
         newCheckColligation.States            = checkColligation.States;
         db.SubmitChanges();
     }
 }
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="type"></param>
        private void SaveData(string type)
        {
            Model.Check_CheckColligation checkColligation = new Model.Check_CheckColligation
            {
                CheckColligationCode = this.txtCheckColligationCode.Text.Trim(),
                ProjectId            = this.ProjectId
            };
            if (this.drpCheckType.SelectedValue != BLL.Const._Null)
            {
                checkColligation.CheckType = this.drpCheckType.SelectedValue;
            }
            //参与单位
            string unitIds = string.Empty;

            foreach (var item in this.drpUnit.SelectedValueArray)
            {
                unitIds += item + ",";
            }
            if (!string.IsNullOrEmpty(unitIds))
            {
                unitIds = unitIds.Substring(0, unitIds.LastIndexOf(","));
            }
            checkColligation.PartInUnits = unitIds;
            if (this.drpCheckPerson.SelectedValue != BLL.Const._Null)
            {
                checkColligation.CheckPerson = this.drpCheckPerson.SelectedValue;
            }
            ///组成员
            string partInPersonIds = string.Empty;
            string partInPersons   = string.Empty;

            foreach (var item in this.drpPartInPersons.SelectedValueArray)
            {
                var user = BLL.UserService.GetUserByUserId(item);
                if (user != null)
                {
                    partInPersonIds += user.UserId + ",";
                    partInPersons   += user.UserName + ",";
                }
            }
            if (!string.IsNullOrEmpty(partInPersonIds))
            {
                checkColligation.PartInPersonIds = partInPersonIds.Substring(0, partInPersonIds.LastIndexOf(","));
                checkColligation.PartInPersons   = partInPersons.Substring(0, partInPersons.LastIndexOf(","));
            }

            checkColligation.PartInPersonNames = this.txtPartInPersonNames.Text.Trim();

            //检查区域
            //string workAreaIds = string.Empty;
            //foreach (var item in this.drpCheckAreas.SelectedValueArray)
            //{
            //    workAreaIds += item + ",";
            //}
            //if (!string.IsNullOrEmpty(workAreaIds))
            //{
            //    workAreaIds = workAreaIds.Substring(0, workAreaIds.LastIndexOf(","));
            //}
            //checkColligation.CheckAreas = workAreaIds;
            checkColligation.CheckTime  = Funs.GetNewDateTime(this.txtCheckDate.Text.Trim());
            checkColligation.DaySummary = HttpUtility.HtmlEncode(this.txtDaySummary.Text.Trim());
            ////单据状态
            checkColligation.States = BLL.Const.State_0;
            if (type == BLL.Const.BtnSubmit)
            {
                checkColligation.States = this.ctlAuditFlow.NextStep;
            }
            if (!string.IsNullOrEmpty(this.CheckColligationId))
            {
                checkColligation.CheckColligationId = this.CheckColligationId;
                BLL.Check_CheckColligationService.UpdateCheckColligation(checkColligation);
                BLL.LogService.AddSys_Log(this.CurrUser, checkColligation.CheckColligationCode, checkColligation.CheckColligationId, BLL.Const.ProjectCheckColligationMenuId, BLL.Const.BtnModify);
            }
            else
            {
                checkColligation.CheckColligationId = SQLHelper.GetNewID(typeof(Model.Check_CheckColligation));
                this.CheckColligationId             = checkColligation.CheckColligationId;
                checkColligation.CompileMan         = this.CurrUser.UserId;
                BLL.Check_CheckColligationService.AddCheckColligation(checkColligation);
                BLL.LogService.AddSys_Log(this.CurrUser, checkColligation.CheckColligationCode, checkColligation.CheckColligationId, BLL.Const.ProjectCheckColligationMenuId, BLL.Const.BtnAdd);
            }
            ////保存流程审核数据
            this.ctlAuditFlow.btnSaveData(this.ProjectId, BLL.Const.ProjectCheckColligationMenuId, this.CheckColligationId, (type == BLL.Const.BtnSubmit ? true : false), this.txtCheckDate.Text.Trim(), "../Check/CheckColligationView.aspx?CheckColligationId={0}");
        }