Exemplo n.º 1
0
        /// <summary>
        /// 执行导入EXCEL数据
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="fieldNames"></param>
        /// <returns></returns>
        public bool ImportDataByExcel(DataTable dataTable, Dictionary <string, string> fieldNames, string loginUser)
        {
            List <TwdCounterInfo> twdCounterExcelInfos = CommonDAL.DatatableConvertToList <TwdCounterInfo>(dataTable).ToList();

            if (twdCounterExcelInfos.Count == 0)
            {
                throw new Exception("MC:1x00000043");///数据格式不符合导入规范
            }
            List <TwdCounterInfo> twdCounterInfos = dal.GetList("" +
                                                                "[PART_BOX_CODE] in ('" + string.Join("','", twdCounterExcelInfos.Select(d => d.PartBoxCode).ToArray()) + "') and " +
                                                                "[PART_NO] in ('" + string.Join("','", twdCounterExcelInfos.Select(d => d.PartNo).ToArray()) + "') and " +
                                                                "[PACKAGE_MODEL] in ('" + string.Join("','", twdCounterExcelInfos.Select(d => d.PackageModel).ToArray()) + "')", string.Empty);

            List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandardInfos = new MaintainInhouseLogisticStandardDAL().GetList("" +
                                                                                                                                               "[INHOUSE_SYSTEM_MODE] = N'" + (int)PullModeConstants.Twd + "' and " +
                                                                                                                                               "[INHOUSE_PART_CLASS] in ('" + string.Join("','", twdCounterExcelInfos.Select(d => d.PartBoxCode).ToArray()) + "') and " +
                                                                                                                                               "[PART_NO] in ('" + string.Join("','", twdCounterExcelInfos.Select(d => d.PartNo).ToArray()) + "')", string.Empty);

            ///获取零件类信息
            List <TwdPartBoxInfo> twdPartBoxInfos = new TwdPartBoxDAL().GetList("" +
                                                                                "[PART_BOX_CODE] in ('" + string.Join("','", twdCounterExcelInfos.Select(d => d.PartBoxCode).ToArray()) + "')", string.Empty);


            StringBuilder @string = new StringBuilder();

            foreach (TwdCounterInfo twdCounterExcelInfo in twdCounterExcelInfos)
            {
                /// 零件类代码②、工厂③车间⑤生产线⑥工段⑬工位⑭、物料号⑩、物料版本⑫、包装容器⑰为联合主键,差异数量DiffQty作为累加当前计数⑮的依据,备注直接更新
                TwdCounterInfo twdCounterInfo = twdCounterInfos.FirstOrDefault(d =>
                                                                               d.PartBoxCode == twdCounterExcelInfo.PartBoxCode &&
                                                                               d.PartNo == twdCounterExcelInfo.PartNo &&
                                                                               d.PackageModel == twdCounterExcelInfo.PackageModel &&
                                                                               d.Plant == twdCounterExcelInfo.Plant &&
                                                                               d.Workshop == twdCounterExcelInfo.Workshop &&
                                                                               d.AssemblyLine == twdCounterExcelInfo.AssemblyLine &&
                                                                               d.WorkshopSection == twdCounterExcelInfo.WorkshopSection &&
                                                                               d.Location == twdCounterExcelInfo.Location &&
                                                                               d.PartVersion == twdCounterExcelInfo.PartVersion);

                #region 逐步减低维度处理
                if (twdCounterInfo == null)
                {
                    twdCounterInfo = twdCounterInfos.FirstOrDefault(d =>
                                                                    d.PartBoxCode == twdCounterExcelInfo.PartBoxCode &&
                                                                    d.PartNo == twdCounterExcelInfo.PartNo &&
                                                                    d.PackageModel == twdCounterExcelInfo.PackageModel &&
                                                                    d.Plant == twdCounterExcelInfo.Plant &&
                                                                    d.Workshop == twdCounterExcelInfo.Workshop &&
                                                                    d.AssemblyLine == twdCounterExcelInfo.AssemblyLine &&
                                                                    d.WorkshopSection == twdCounterExcelInfo.WorkshopSection &&
                                                                    d.Location == twdCounterExcelInfo.Location);
                }
                if (twdCounterInfo == null)
                {
                    twdCounterInfo = twdCounterInfos.FirstOrDefault(d =>
                                                                    d.PartBoxCode == twdCounterExcelInfo.PartBoxCode &&
                                                                    d.PartNo == twdCounterExcelInfo.PartNo &&
                                                                    d.PackageModel == twdCounterExcelInfo.PackageModel &&
                                                                    d.Plant == twdCounterExcelInfo.Plant &&
                                                                    d.Workshop == twdCounterExcelInfo.Workshop &&
                                                                    d.AssemblyLine == twdCounterExcelInfo.AssemblyLine &&
                                                                    d.WorkshopSection == twdCounterExcelInfo.WorkshopSection);
                }
                if (twdCounterInfo == null)
                {
                    twdCounterInfo = twdCounterInfos.FirstOrDefault(d =>
                                                                    d.PartBoxCode == twdCounterExcelInfo.PartBoxCode &&
                                                                    d.PartNo == twdCounterExcelInfo.PartNo &&
                                                                    d.PackageModel == twdCounterExcelInfo.PackageModel &&
                                                                    d.Plant == twdCounterExcelInfo.Plant &&
                                                                    d.Workshop == twdCounterExcelInfo.Workshop &&
                                                                    d.AssemblyLine == twdCounterExcelInfo.AssemblyLine);
                }
                if (twdCounterInfo == null)
                {
                    twdCounterInfo = twdCounterInfos.FirstOrDefault(d =>
                                                                    d.PartBoxCode == twdCounterExcelInfo.PartBoxCode &&
                                                                    d.PartNo == twdCounterExcelInfo.PartNo &&
                                                                    d.PackageModel == twdCounterExcelInfo.PackageModel &&
                                                                    d.Plant == twdCounterExcelInfo.Plant &&
                                                                    d.Workshop == twdCounterExcelInfo.Workshop);
                }
                if (twdCounterInfo == null)
                {
                    twdCounterInfo = twdCounterInfos.FirstOrDefault(d =>
                                                                    d.PartBoxCode == twdCounterExcelInfo.PartBoxCode &&
                                                                    d.PartNo == twdCounterExcelInfo.PartNo &&
                                                                    d.PackageModel == twdCounterExcelInfo.PackageModel &&
                                                                    d.Plant == twdCounterExcelInfo.Plant);
                }
                if (twdCounterInfo == null)
                {
                    twdCounterInfo = twdCounterInfos.FirstOrDefault(d =>
                                                                    d.PartBoxCode == twdCounterExcelInfo.PartBoxCode &&
                                                                    d.PartNo == twdCounterExcelInfo.PartNo &&
                                                                    d.PackageModel == twdCounterExcelInfo.PackageModel);
                }
                if (twdCounterInfo == null)
                {
                    twdCounterInfo = twdCounterInfos.FirstOrDefault(d =>
                                                                    d.PartBoxCode == twdCounterExcelInfo.PartBoxCode &&
                                                                    d.PartNo == twdCounterExcelInfo.PartNo);
                }
                if (twdCounterInfo == null)
                {
                    throw new Exception("MC:0x00000255");///数据格式不符合导入规范
                }
                #endregion

                if (twdCounterInfo.Status.GetValueOrDefault() == (int)BasicDataStatusConstants.Disabled)
                {
                    throw new Exception("MC:0x00000455");///计数器已作废不能修改数量
                }
                @string.AppendLine("update [LES].[TT_MPM_TWD_COUNTER] set " +
                                   "[CURRENT_QTY] = isnull([CURRENT_QTY],0) + " + twdCounterExcelInfo.DiffQty + "," +
                                   "[MODIFY_USER] = N'" + loginUser + "'," +
                                   "[MODIFY_DATE] = GETDATE() where " +
                                   "[ID] = " + twdCounterInfo.Id + ";");

                ///根据计数器的物料拉动信息外键获取物料拉动信息
                MaintainInhouseLogisticStandardInfo maintainInhouseLogisticStandardInfo = maintainInhouseLogisticStandardInfos.FirstOrDefault(d => d.Fid == twdCounterInfo.PartPullFid.GetValueOrDefault());
                if (maintainInhouseLogisticStandardInfo == null)
                {
                    throw new Exception("MC:0x00000213");///物料拉动信息数据错误
                }
                if (maintainInhouseLogisticStandardInfo.Status.GetValueOrDefault() != (int)BasicDataStatusConstants.Enable)
                {
                    throw new Exception("MC:0x00000233");///没有已启用的物料拉动信息
                }
                ///获取零件类信息
                TwdPartBoxInfo twdPartBoxInfo = twdPartBoxInfos.FirstOrDefault(d => d.PartBoxCode == maintainInhouseLogisticStandardInfo.InhousePartClass);
                ///未能成功获取零件类信息
                if (twdPartBoxInfo == null)
                {
                    throw new Exception("MC:0x00000225");///拉动零件类数据错误
                }
                ///零件类未启用
                if (twdPartBoxInfo.Status.GetValueOrDefault() != (int)BasicDataStatusConstants.Enable)
                {
                    throw new Exception("MC:0x00000456");///零件类未启用
                }
                ///创建计数器日志
                TwdCounterLogInfo twdCounterLogInfo = TwdCounterLogBLL.CreateTwdCounterLogInfo(twdCounterInfo.Fid.GetValueOrDefault(), loginUser);
                ///以物料拉动信息填充计数器日志
                TwdCounterLogBLL.GetTwdCounterLogInfo(maintainInhouseLogisticStandardInfo, ref twdCounterLogInfo);
                ///以零件类信息填充计数器日志
                TwdCounterLogBLL.GetTwdCounterLogInfo(twdPartBoxInfo, ref twdCounterLogInfo);
                ///PART_QTY
                twdCounterLogInfo.PartQty = twdCounterExcelInfo.DiffQty;
                ///SOURCE_DATA_FID
                twdCounterLogInfo.SourceDataFid = twdCounterInfo.Fid;
                ///SOURCE_DATA_TYPE
                twdCounterLogInfo.SourceDataType = (int)TwdCounterSourceDataTypeConstants.Manual;
                ///SOURCE_DATA
                twdCounterLogInfo.SourceData = twdCounterInfo.PartBoxCode;
                ///Comments
                twdCounterLogInfo.Comments = twdCounterExcelInfo.Comments;
                ///
                @string.AppendLine(TwdCounterLogDAL.GetInsertSql(twdCounterLogInfo));

                ///触发层级拉动
                @string.AppendLine(LevelPullRequirementCounter(
                                       maintainInhouseLogisticStandardInfo,
                                       twdCounterExcelInfo.DiffQty,
                                       loginUser,
                                       twdCounterInfo.Fid.GetValueOrDefault(),
                                       twdCounterInfo.PartBoxCode));
            }
            ///执行
            using (var trans = new TransactionScope())
            {
                if (@string.Length == 0)
                {
                    throw new Exception("MC:0x00000283");///没有可导入更新的数据
                }
                CommonDAL.ExecuteNonQueryBySql(@string.ToString());
                trans.Complete();
            }
            ///
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 执行导入EXCEL数据
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="fieldNames"></param>
        /// <returns></returns>
        public bool ImportDataByExcel(DataTable dataTable, Dictionary <string, string> fieldNames, string loginUser)
        {
            DateTime dtDate;

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                if (!DateTime.TryParse(dataTable.Rows[i]["WorkDay"].ToString(), out dtDate))
                {
                    throw new Exception("MC:0x00000393");///日期格式不正确
                }
                if (!DateTime.TryParse(dataTable.Rows[i]["WindowTime"].ToString(), out dtDate))
                {
                    throw new Exception("MC:0x00000393");///日期格式不正确
                }
            }

            ///导入数据
            List <TwdWindowTimeInfo> twdWindows = CommonDAL.DatatableConvertToList <TwdWindowTimeInfo>(dataTable).ToList();

            if (twdWindows.Count == 0)
            {
                throw new Exception("MC:1x00000043");///数据格式不符合导入规范
            }
            ///比对数据
            List <TwdWindowTimeInfo> timeInfos = dal.GetList("[PART_BOX_CODE] in ('" + string.Join("','", twdWindows.Select(d => d.PartBoxCode).ToArray()) + "') and [WORK_DAY] in ('" + string.Join("','", twdWindows.Select(d => d.WorkDay).ToArray()) + "') and [WINDOW_TIME] in ('" + string.Join("','", twdWindows.Select(d => d.WindowTime).ToArray()) + "')", string.Empty).ToList();
            ///零件类数据
            List <TwdPartBoxInfo> twdParts = new TwdPartBoxDAL().GetList("[PART_BOX_CODE] in ('" + string.Join("','", twdWindows.Select(d => d.PartBoxCode).ToArray()) + "')", string.Empty).ToList();

            if (twdParts.Count() != twdWindows.Count())
            {
                throw new Exception("MC:0x00000225");///拉动零件类数据错误
            }
            List <string> fields        = new List <string>(fieldNames.Keys);
            StringBuilder stringBuilder = new StringBuilder();

            foreach (var item in twdWindows)
            {
                TwdWindowTimeInfo timeInfo = timeInfos.FirstOrDefault(d => d.PartBoxCode == item.PartBoxCode && d.WorkDay == item.WorkDay && d.WindowTime == item.WindowTime);

                TwdPartBoxInfo boxInfo = twdParts.FirstOrDefault(d => d.PartBoxCode == item.PartBoxCode);
                ///发单时间 = 工作日年月日 + 窗口时间时分秒 - 提前时间
                int advanceTime = boxInfo.RequirementAccumulateTime.GetValueOrDefault() + ///需求累积时间
                                  boxInfo.LoadTime.GetValueOrDefault() +                  ///装货时间
                                  boxInfo.TransportTime.GetValueOrDefault() +             ///运输时间
                                  boxInfo.UnloadTime.GetValueOrDefault();                 ///卸货时间
                item.SendTime = item.WindowTime.GetValueOrDefault().AddMinutes(-advanceTime);
                if (timeInfo == null)
                {
                    if (item.WindowTime == null || item.WorkDay == null || item.PartBoxCode == null)
                    {
                        throw new Exception("MC:0x00000510");///零件类工作日窗口时间不可为空
                    }
                    stringBuilder.Append("insert into [LES].[TT_MPM_TWD_WINDOW_TIME]([FID],[PART_BOX_FID],[PART_BOX_CODE],[PART_BOX_NAME],[PLANT],[WORKSHOP],[ASSEMBLY_LINE],[SUPPLIER_NUM],[WORK_DAY],[SEND_TIME],[WINDOW_TIME],[SEND_TIME_STATUS],[TIME_ZONE],[COMMENTS],[VALID_FLAG],[CREATE_DATE],[CREATE_USER])values(");
                    stringBuilder.Append("newid(),N'" + boxInfo.Fid + "',N'" + item.PartBoxCode + "',N'" + boxInfo.PartBoxName + "',N'" + boxInfo.Plant + "',N'" + boxInfo.Workshop + "',N'" + boxInfo.AssemblyLine + "',N'" + boxInfo.SupplierNum + "',N'" + item.WorkDay + "',N'" + item.SendTime + "',N'" + item.WindowTime + "'," + (int)SendTimeStatusConstants.NoSend + ",N'" + item.TimeZone + "',N'" + item.Comments + "',1,GETDATE(),N'" + loginUser + "'");
                    stringBuilder.Append(");");
                    timeInfos.Add(item);
                    continue;
                }

                if (timeInfo.SendTimeStatus != (int)SendTimeStatusConstants.NoSend)
                {
                    throw new Exception("MC:0x00000311");///发单状态⑪为10未发单才允许被修改
                }
                if (item.WindowTime == null || item.WorkDay == null || item.PartBoxCode == null)
                {
                    throw new Exception("MC:0x00000510");///零件类工作日窗口时间不可为空
                }
                stringBuilder.Append("update [LES].[TT_MPM_TWD_WINDOW_TIME] set [PLANT] = N'" + boxInfo.Plant + "',[WORKSHOP] = N'" + boxInfo.Workshop + "',[ASSEMBLY_LINE] = N'" + boxInfo.AssemblyLine + "',[SUPPLIER_NUM] = N'" + boxInfo.SupplierNum + "',[SEND_TIME] = N'" + item.SendTime + "',[COMMENTS] = N'" + item.Comments + "',[MODIFY_DATE] = GETDATE(),[MODIFY_USER] = N'" + loginUser + "' where [ID] = " + timeInfo.Id + ";");
            }

            if (string.IsNullOrEmpty(stringBuilder.ToString()))
            {
                throw new Exception("MC:0x00000283");///没有可导入更新的数据
            }
            return(CommonDAL.ExecuteNonQueryBySql(stringBuilder.ToString()));
        }
        /// <summary>
        /// 执行导入EXCEL数据
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="fieldNames"></param>
        /// <returns></returns>
        public bool ImportDataByExcel(DataTable dataTable, Dictionary <string, string> fieldNames, string loginUser)
        {
            List <TwdPartBoxInfo> twdPartBoxExcelInfos = CommonDAL.DatatableConvertToList <TwdPartBoxInfo>(dataTable).ToList();

            if (twdPartBoxExcelInfos.Count == 0)
            {
                throw new Exception("MC:1x00000043");///数据格式不符合导入规范
            }
            ///获取业务表中要变更的数据集合,准备对比
            List <TwdPartBoxInfo> twdPartBoxInfos = new TwdPartBoxDAL().GetList("[PART_BOX_CODE] in ('" + string.Join("', '", twdPartBoxExcelInfos.Select(d => d.PartBoxCode).ToList().ToArray()) + "')", "");

            ///执行的SQL语句
            StringBuilder @string = new StringBuilder();
            List <string> fields  = new List <string>(fieldNames.Keys);

            ///逐条处理中间表数据
            foreach (var twdPartBoxExcelInfo in twdPartBoxExcelInfos)
            {
                TwdPartBoxInfo twdPartBoxInfo = twdPartBoxInfos.FirstOrDefault(d => d.PartBoxCode == twdPartBoxExcelInfo.PartBoxCode);
                ///需要新增
                if (twdPartBoxInfo == null)
                {
                    ///校验
                    ValidTwdPartBoxInfo(twdPartBoxExcelInfo);
                    ///字段
                    string insertFieldString = string.Empty;
                    ///值
                    string insertValueString = string.Empty;

                    for (int i = 0; i < fields.Count; i++)
                    {
                        string valueStr = CommonDAL.GetFieldValueForSql <TwdPartBoxInfo>(twdPartBoxExcelInfo, fields[i]);
                        if (string.IsNullOrEmpty(valueStr))
                        {
                            throw new Exception("MC:1x00000043");///数据格式不符合导入规范
                        }
                        insertFieldString += "[" + fieldNames[fields[i]] + "],";
                        insertValueString += valueStr + ",";
                    }
                    ///判断业务主键是否重复,以防止EXCEL中有重复数据,适用于基础数据导入
                    @string.AppendLine("if not exists (select * from LES.TM_MPM_TWD_PART_BOX with(nolock) " +
                                       "where [PART_BOX_CODE] = N'" + twdPartBoxExcelInfo.PartBoxCode + "' and [VALID_FLAG] = 1)"
                                       + " insert into [LES].[TM_MPM_TWD_PART_BOX] ("
                                       + "[FID],"
                                       + insertFieldString
                                       + "[STATUS],"
                                       + "[CREATE_USER],"
                                       + "[CREATE_DATE],"
                                       + "[VALID_FLAG]"
                                       + ") values ("
                                       + "NEWID(),"///FID
                                       + insertValueString
                                       + (int)BasicDataStatusConstants.Created + ","
                                       + "N'" + loginUser + "'," ///CREATE_USER
                                       + "GETDATE(),"            ///CREATE_DATE
                                       + "1"                     ///VALID_FLAG
                                       + ");");
                    ///防止EXCEL中有重复项
                    twdPartBoxInfos.Add(twdPartBoxExcelInfo);
                    continue;
                }
                ///
                if (twdPartBoxInfo.Status.GetValueOrDefault() == (int)BasicDataStatusConstants.Disabled)
                {
                    continue;
                }
                ///
                twdPartBoxExcelInfo.Id = twdPartBoxInfo.Id;
                ///校验
                ValidTwdPartBoxInfo(twdPartBoxExcelInfo);
                ///是否更新了拉动模式,需要同步更新物料拉动信息中的拉动模式
                if (twdPartBoxInfo.TwdPullMode.GetValueOrDefault() != twdPartBoxExcelInfo.TwdPullMode.GetValueOrDefault())
                {
                    @string.AppendLine("update [LES].[TM_BAS_MAINTAIN_INHOUSE_LOGISTIC_STANDARD] " +
                                       "set [INHOUSE_SYSTEM_MODE] = N'" + twdPartBoxExcelInfo.TwdPullMode.GetValueOrDefault() + "'," +
                                       "[MODIFY_USER] = N'" + loginUser + "'," +
                                       "[MODIFY_DATE] = GETDATE() " +
                                       "where [INHOUSE_SYSTEM_MODE] = N'" + twdPartBoxInfo.TwdPullMode.GetValueOrDefault() + "' and " +
                                       "[INHOUSE_PART_CLASS] = N'" + twdPartBoxExcelInfo.PartBoxCode + "' and " +
                                       "[VALID_FLAG] = 1;");
                }
                ///已创建状态的数据可以全信息更新
                if (twdPartBoxInfo.Status.GetValueOrDefault() == (int)BasicDataStatusConstants.Created)
                {
                    ///值
                    string valueString = string.Empty;
                    for (int i = 0; i < fields.Count; i++)
                    {
                        string valueStr = CommonDAL.GetFieldValueForSql <TwdPartBoxInfo>(twdPartBoxExcelInfo, fields[i]);
                        if (string.IsNullOrEmpty(valueStr))
                        {
                            throw new Exception("MC:1x00000043");///数据格式不符合导入规范
                        }
                        valueString += "[" + fieldNames[fields[i]] + "] = " + valueStr + ",";
                    }
                    @string.AppendLine("update [LES].[TM_MPM_TWD_PART_BOX] set "
                                       + valueString
                                       + "[MODIFY_USER] = N'" + loginUser + "',"
                                       + "[MODIFY_DATE] = GETDATE() "
                                       + "where [ID] = " + twdPartBoxInfo.Id + ";");
                    continue;
                }
                ///
                @string.AppendLine("update [LES].[TM_MPM_TWD_PART_BOX] " +
                                   "set [PART_BOX_NAME] = N'" + twdPartBoxExcelInfo.PartBoxName + "'," +
                                   "[REQUIREMENT_ACCUMULATE_TIME] = " + (twdPartBoxExcelInfo.RequirementAccumulateTime == null ? "NULL" : "" + twdPartBoxExcelInfo.RequirementAccumulateTime.GetValueOrDefault() + "") + "," +
                                   "[LOAD_TIME] = " + (twdPartBoxExcelInfo.LoadTime == null ? "NULL" : "" + twdPartBoxExcelInfo.LoadTime.GetValueOrDefault() + "") + "," +
                                   "[TRANSPORT_TIME] = " + (twdPartBoxExcelInfo.TransportTime == null ? "NULL" : "" + twdPartBoxExcelInfo.TransportTime.GetValueOrDefault() + "") + "," +
                                   "[UNLOAD_TIME] = " + (twdPartBoxExcelInfo.UnloadTime == null ? "NULL" : "" + twdPartBoxExcelInfo.UnloadTime.GetValueOrDefault() + "") + "," +
                                   "[DELAY_TIME] = " + (twdPartBoxExcelInfo.DelayTime == null ? "NULL" : "" + twdPartBoxExcelInfo.DelayTime.GetValueOrDefault() + "") + "," +
                                   "[ONLINE_TIME] = " + (twdPartBoxExcelInfo.OnlineTime == null ? "NULL" : "" + twdPartBoxExcelInfo.OnlineTime.GetValueOrDefault() + "") + "," +
                                   "[REQUIREMENT_ACCUMULATE_MODE] = " + twdPartBoxExcelInfo.RequirementAccumulateMode.GetValueOrDefault() + "," +
                                   "[STATUS_POINT_CODE] = N'" + twdPartBoxExcelInfo.StatusPointCode + "'," +
                                   "[ROUNDNESS_MODE] = " + twdPartBoxExcelInfo.RoundnessMode.GetValueOrDefault() + "," +
                                   "[MODIFY_USER] = N'" + loginUser + "'," +
                                   "[MODIFY_DATE] = GETDATE() " +
                                   "where [ID] = " + twdPartBoxInfo.Id + ";");
            }
            ///执行
            using (TransactionScope trans = new TransactionScope())
            {
                if (@string.Length > 0)
                {
                    CommonDAL.ExecuteNonQueryBySql(@string.ToString());
                }
                trans.Complete();
            }
            return(true);
        }