/// <summary>
        /// 增加一条数据
        /// </summary>
        public static bool Add(TableExtFields tableExtFields, out string strMsg)
        {
            int EFIndex = GetEFIndex(tableExtFields);//索引
            bool isSucc = false;//是否成功
            if (EFIndex != 0)
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into officedba.TableExtFields(");
                strSql.Append("TabName,CompanyCD,EFIndex,EFDesc,EFType,EFValueList)");
                strSql.Append(" values (");
                strSql.Append("'officedba.CustInfo',@CompanyCD,@EFIndex,@EFDesc,@EFType,@EFValueList)");
                tableExtFields.EFIndex = EFIndex;
                SqlParameter[] parameters = {			
					new SqlParameter("@CompanyCD", SqlDbType.VarChar,8),
					new SqlParameter("@EFIndex", SqlDbType.Int,4),
					new SqlParameter("@EFDesc", SqlDbType.VarChar,20),
					new SqlParameter("@EFType", SqlDbType.Char,1),
					new SqlParameter("@EFValueList", SqlDbType.VarChar,256)};
               
                parameters[0].Value = tableExtFields.CompanyCD;
                parameters[1].Value = tableExtFields.EFIndex;
                parameters[2].Value = tableExtFields.EFDesc;
                parameters[3].Value = tableExtFields.EFType;
                parameters[4].Value = tableExtFields.EFValueList;
                foreach (SqlParameter para in parameters)
                {
                    if (para.Value == null)
                    {
                        para.Value = DBNull.Value;
                    }
                }

                try
                {
                    SqlHelper.ExecuteTransSql(strSql.ToString(), parameters);
                    isSucc = SqlHelper.Result.OprateCount > 0 ? true : false;
                    strMsg = "保存成功!";
                }
                catch(Exception ex)
                {
                    strMsg = "保存失败,请联系系统管理员!";
                    isSucc = false;
                    throw ex;
                }
            }
            else
            {
                strMsg = "已达最大数量,您不能添加新的客户特性!";
            }
            return isSucc;
        }
 /// <summary>
 /// 获取索引
 /// </summary>
 /// <returns></returns>
 private static int GetEFIndex(TableExtFields tableExtFields)
 {
     int EFIndex = 0;//索引
     int iCount = 0;//使用字段合计
     string strSql = string.Empty;
     strSql = "select count(1) as EFIndex from officedba.TableExtFields where CompanyCD=@CompanyCD and TabName='officedba.CustInfo'";
     SqlParameter[] parameters = { 
                                     new SqlParameter("@CompanyCD",tableExtFields.CompanyCD)
                                 };
     iCount = Convert.ToInt32(SqlHelper.ExecuteScalar(strSql, parameters));
     //总使用扩展字段小于三十,获取索引,等于三十时不可添加新扩展字段
     if (iCount < 30)
     {
         strSql = "select isnull(max(EFIndex),0) as EFIndex from officedba.TableExtFields where CompanyCD=@CompanyCD and TabName='officedba.CustInfo'";
         SqlParameter[] parameters1 = { 
                                     new SqlParameter("@CompanyCD",tableExtFields.CompanyCD)
                                 };
         EFIndex = Convert.ToInt32(SqlHelper.ExecuteScalar(strSql, parameters1));
         //最大索引未到三十就使用最大索引+1作为当前索引
         if (EFIndex < 30)
         {
             EFIndex += 1;
         }
         //当最大索引为三十时,查找小于三十的未被使用的索引
         if (EFIndex == 30)
         {
             for (int i = 1; i < 30; i++)
             {
                 strSql = "select count(1) as EFIndex from officedba.TableExtFields where CompanyCD=@CompanyCD and TabName='officedba.CustInfo' and EFIndex=@EFIndex";
                 SqlParameter[] paras = { 
                                     new SqlParameter("@CompanyCD",tableExtFields.CompanyCD),
                                     new SqlParameter("@EFIndex",i)
                                 };
                 iCount = Convert.ToInt32(SqlHelper.ExecuteScalar(strSql, paras));
                 if (iCount == 0)
                 {
                     EFIndex = i;
                     break;
                 }
             }
         }
     }
     return EFIndex;
 }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        //public static bool Add(TableExtFields tableExtFields, out string strMsg, string CustomValues)
        //{
        //    int EFIndex = GetEFIndex(tableExtFields);//索引
        //    bool isSucc = false;//是否成功
        //    if (EFIndex != 0)
        //    {
        //        StringBuilder strSql = new StringBuilder();
        //        strSql.Append("insert into officedba.TableExtFields(");
        //        strSql.Append("TabName,CompanyCD,EFIndex,EFDesc,EFType,EFValueList)");
        //        strSql.Append(" values (");
        //        strSql.Append("'officedba.ProductInfo',@CompanyCD,@EFIndex,@EFDesc,@EFType,@EFValueList)");
        //        tableExtFields.EFIndex = EFIndex;
        //        SqlParameter[] parameters = {			
        //            new SqlParameter("@CompanyCD", SqlDbType.VarChar,8),
        //            new SqlParameter("@EFIndex", SqlDbType.Int,4),
        //            new SqlParameter("@EFDesc", SqlDbType.VarChar,20),
        //            new SqlParameter("@EFType", SqlDbType.Char,1),
        //            new SqlParameter("@EFValueList", SqlDbType.VarChar,256)};

        //        parameters[0].Value = tableExtFields.CompanyCD;
        //        parameters[1].Value = tableExtFields.EFIndex;
        //        parameters[2].Value = tableExtFields.EFDesc;
        //        parameters[3].Value = tableExtFields.EFType;
        //        parameters[4].Value = tableExtFields.EFValueList;
        //        foreach (SqlParameter para in parameters)
        //        {
        //            if (para.Value == null)
        //            {
        //                para.Value = DBNull.Value;
        //            }
        //        }

        //        try
        //        {
        //            SqlHelper.ExecuteTransSql(strSql.ToString(), parameters);
        //            isSucc = SqlHelper.Result.OprateCount > 0 ? true : false;
        //            strMsg = "保存成功!";
        //        }
        //        catch(Exception ex)
        //        {
        //            strMsg = "保存失败,请联系系统管理员!";
        //            isSucc = false;
        //            throw ex;
        //        }
        //    }
        //    else
        //    {
        //        strMsg = "已达最大数量,您不能添加新的商品特性!";
        //    }
        //    return isSucc;
        //}

        public static bool Add(TableExtFields tableExtFields, out string strMsg, string CustomValues)
        {
            try
            {
                bool result = false;
                SqlCommand cmd = null;
                StringBuilder sql = null;
                ArrayList cmdlist = new ArrayList();
                string[] CustomValuesArray = CustomValues.Split('$');
                if (CustomValuesArray.Length > 0)
                {
                    for (int i = 0; i < CustomValuesArray.Length; i++)
                    {
                        cmd = new SqlCommand();
                        sql = new StringBuilder();

                        sql.AppendLine("insert into officedba.TableExtFields( ");
                        sql.AppendLine("FunctionModule,ModelNo,TabName,CompanyCD,EFIndex,EFDesc,EFType) ");
                        sql.AppendLine(" values ( ");
                        sql.AppendLine("@FunctionModule,@ModelNo,@TableName,@CompanyCD,@EFIndex,@EFDesc,'1')");

                        cmd.Parameters.AddWithValue("@FunctionModule", SqlDbType.VarChar).Value = tableExtFields.FunctionModule;
                        cmd.Parameters.AddWithValue("@ModelNo", SqlDbType.VarChar).Value = tableExtFields.ModelNo;
                        cmd.Parameters.AddWithValue("@TableName", SqlDbType.VarChar).Value = tableExtFields.TabName;
                        cmd.Parameters.AddWithValue("@CompanyCD", SqlDbType.VarChar).Value = tableExtFields.CompanyCD;
                        //cmd.Parameters.AddWithValue("@BranchID", SqlDbType.Int).Value = Convert.ToInt32(tableExtFields.BranchID);
                        cmd.Parameters.AddWithValue("@EFIndex", SqlDbType.Int).Value = (i + 1);
                        cmd.Parameters.AddWithValue("@EFDesc", SqlDbType.VarChar).Value = CustomValuesArray[i].ToString();

                        cmd.CommandText = sql.ToString();
                        cmdlist.Add(cmd);
                    }
                }
                result = SqlHelper.ExecuteTransWithArrayList(cmdlist);
                strMsg = "保存成功";
                return result;
            }
            catch
            {
                strMsg = "保存失败";
                return false;
            }
        }
        public static bool Update(TableExtFields tableExtFields, out string strMsg)
        {
            bool isSuc = false;
            string remark = string.Empty;
            strMsg = "";
            try
            {
                isSuc = PorductExtListDBHelper.Update(tableExtFields, out strMsg);
                //设置操作成功标识
                remark = "成功";

            }
            catch (Exception ex)
            {
                //输出日志
                SellLogCommon.WriteSystemLog(ex, LogInfo.LogType.SYSTEM, LogInfo.SystemLogKind.SYSTEM_ERROR, "2081306");
                //设置操作成功标识 
                remark = ConstUtil.LOG_PROCESS_FAILED;
                strMsg = "保存失败,请联系系统管理员!";
            }
            SellLogCommon.InsertLog(tableExtFields.EFDesc, "2081306", "officedba.TableExtFields", remark, "更新");
            return isSuc;
        }
 public static bool Update(TableExtFields tableExtFields, out string strMsg)
 {
     bool isSuc = false;
     string remark = string.Empty;
     strMsg = "";
     try
     {
         isSuc = TableExtFieldsDBHelper.Update(tableExtFields, out strMsg);
         //设置操作成功标识
         remark = "成功";
        
     }
     catch (Exception ex)
     {
         //输出日志
         WriteSystemLog(ex, LogInfo.LogType.SYSTEM, LogInfo.SystemLogKind.SYSTEM_ERROR, ConstUtil.MODULEID_CUSTINFO_ExtAttribute);
         //设置操作成功标识 
         remark = ConstUtil.LOG_PROCESS_FAILED;
         strMsg = "保存失败,请联系系统管理员!";
     }
     InsertLog(tableExtFields.EFDesc, ConstUtil.MODULEID_CUSTINFO_ExtAttribute, "officedba.TableExtFields", remark, "更新");
     return isSuc;
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static  bool Update(TableExtFields tableExtFields, out string strMsg)
        {
            bool isSucc = false;//是否成功
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update officedba.TableExtFields set ");
            strSql.Append("EFIndex=@EFIndex,");
            strSql.Append("EFDesc=@EFDesc,");
            strSql.Append("EFType=@EFType,");
            strSql.Append("EFValueList=@EFValueList");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
                      new SqlParameter("@ID", SqlDbType.Int,4),
                      new SqlParameter("@EFIndex", SqlDbType.Int,4),
                      new SqlParameter("@EFDesc", SqlDbType.VarChar,20),
                      new SqlParameter("@EFType", SqlDbType.Char,1),
                      new SqlParameter("@EFValueList", SqlDbType.VarChar,256)};
            parameters[0].Value = tableExtFields.ID;
            parameters[1].Value = tableExtFields.EFIndex;
            parameters[2].Value = tableExtFields.EFDesc;
            parameters[3].Value = tableExtFields.EFType;
            parameters[4].Value = tableExtFields.EFValueList;
            foreach (SqlParameter para in parameters)
            {
                if (para.Value == null)
                {
                    para.Value = DBNull.Value;
                }
            }

            try
            {
                SqlHelper.ExecuteTransSql(strSql.ToString(), parameters);
                isSucc = SqlHelper.Result.OprateCount > 0 ? true : false;
                strMsg = "保存成功!";
            }
            catch (Exception ex)
            {
                strMsg = "保存失败,请联系系统管理员!";
                isSucc = false;
                throw ex;
            }

            return isSucc;
        }