/// <summary>
        /// 增加一条数据
        /// </summary>
        public static bool AddCompanyRelate(USER_SHARE_COMPANYRELATEMODEL model, USER_SHARE_LOGMODEL log)
        {
            bool          blSuccess = false;
            StringBuilder strSql    = new StringBuilder();

            strSql.Append("insert into USER_SHARE_COMPANYRELATE(");
            strSql.Append("CID,COMPANYTYPE,COMPANYNAME,COMPANYID,GROUPID,PRODUCTIDS,PROJECTIDS,COMPANYCODE,SHARECOMPANYID,ADMINID,CREATEDATE,STATUS,GROUPIDN)");

            strSql.Append(" values (");
            strSql.Append(":CID,:COMPANYTYPE,:COMPANYNAME,:COMPANYID,:GROUPID,:PRODUCTIDS,:PROJECTIDS,:COMPANYCODE,:SHARECOMPANYID,:ADMINID,:CREATEDATE,:STATUS,:GROUPIDN)");
            ParamList param = new ParamList();

            param["CID"]            = model.CID;
            param["COMPANYTYPE"]    = model.COMPANYTYPE;
            param["COMPANYNAME"]    = model.COMPANYNAME;
            param["COMPANYID"]      = model.COMPANYID;
            param["GROUPID"]        = model.GROUPID;
            param["PRODUCTIDS"]     = model.PRODUCTIDS;
            param["PROJECTIDS"]     = model.PROJECTIDS;
            param["COMPANYCODE"]    = model.COMPANYCODE;
            param["SHARECOMPANYID"] = model.SHARECOMPANYID;
            param["ADMINID"]        = model.ADMINID;
            param["CREATEDATE"]     = model.CREATEDATE;
            param["STATUS"]         = model.STATUS;
            param["ADMINID"]        = model.ADMINID;
            param["GROUPIDN"]       = model.GROUPIDN;
            //应用系统注册
            if (model.COMPANYTYPE == int.Parse(ShareEnum.CompanyType.ShareCompany.ToString("d")))
            {
                //user_share_company插入
                int nShareCompanyId = CommonBusiness.GetSeqID("S_USER_SHARE_COMPANY");
                model.SHARECOMPANYID    = nShareCompanyId;
                param["SHARECOMPANYID"] = nShareCompanyId;
            }

            string strSqlS = string.Format(@"SELECT M.* FROM USER_SHARE_PRODUCTFUN P INNER JOIN USER_SHARE_FUNMENU M 
                                             ON P.FUNID=M.FMID WHERE M.FMSTATUS={0} AND P.PRODUCTID IN ({1}) ",
                                           ShareEnum.FunMenuStatus.Normal.ToString("d"), model.PRODUCTIDS.TrimStart(',').TrimEnd(','));

            DataTable           dt         = StaticConnectionProvider.ExecuteDataTable(strSqlS);
            int                 nCfId      = 0;
            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

            try
            {
                using (connection)
                {
                    connection.BeginTranscation();

                    //公司关联信息
                    connection.ExecuteNonQuery(strSql.ToString(), param);
                    param.Clear();

                    if (model.COMPANYTYPE == int.Parse(ShareEnum.CompanyType.ShareCompany.ToString("d")))
                    {
                        strSqlS = "INSERT INTO USER_SHARE_COMPANY(COMPANYID,COMPANYNAME) VALUES({0},'{1}')";
                        connection.ExecuteNonQuery(string.Format(strSqlS, model.SHARECOMPANYID, model.COMPANYNAME));
                    }

                    //公司菜单初始化
                    foreach (DataRow dr in dt.Rows)
                    {
                        nCfId                  = CommonBusiness.GetSeqID("S_USER_SHARE_COMPANYFUN");
                        strSqlS                = string.Format(@"insert into USER_SHARE_COMPANYFUN(CFID,FMID,PROJECTID,COMPANYID,CFNAME,
                        CFANOTHERNAME,CFPAGEURL,CFPARENTID,CFSORTNUM,CFSTEP,CFISLAST,CFDESC,CFSTATUS) values (
                        :CFID,:FMID,:PROJECTID,:COMPANYID,:CFNAME,:CFANOTHERNAME,:CFPAGEURL,:CFPARENTID,:CFSORTNUM,
                        :CFSTEP,:CFISLAST,:CFDESC,:CFSTATUS)");
                        param["CFID"]          = nCfId;
                        param["FMID"]          = dr["FMID"];
                        param["PROJECTID"]     = dr["PROJECTID"];
                        param["COMPANYID"]     = model.COMPANYCODE;
                        param["CFNAME"]        = dr["FMNAME"];
                        param["CFANOTHERNAME"] = dr["FMNAME"];
                        param["CFPAGEURL"]     = CommonMethod.FinalString(dr["FMPAGEURL"]);
                        param["CFPARENTID"]    = CommonMethod.FinalString(dr["FMPARENTID"]);
                        param["CFSORTNUM"]     = dr["FMSORTNUM"];
                        param["CFSTEP"]        = CommonMethod.FinalString(dr["FMSTEP"]);
                        param["CFISLAST"]      = CommonMethod.FinalString(dr["FMISLAST"]);
                        param["CFDESC"]        = CommonMethod.FinalString(dr["FMDESC"]);
                        param["CFSTATUS"]      = ShareEnum.CompanyFunMenuStatus.Normal.ToString("d");
                        connection.ExecuteNonQuery(strSqlS, param);
                    }

                    param.Clear();

                    //操作日志
                    strSql = new StringBuilder();
                    strSql.Append("insert into USER_SHARE_LOG(");
                    strSql.Append("LOGID,OPERATETYPE,OPERATORID,PROJECTID,COMPANYID,OPERATECONTENT,OPERATEDATE)");
                    strSql.Append(" values (");
                    strSql.Append(":LOGID,:OPERATETYPE,:OPERATORID,:PROJECTID,:COMPANYID,:OPERATECONTENT,:OPERATEDATE)");

                    param["LOGID"]          = log.LOGID;
                    param["OPERATETYPE"]    = log.OPERATETYPE;
                    param["OPERATORID"]     = log.OPERATORID;
                    param["PROJECTID"]      = log.PROJECTID;
                    param["COMPANYID"]      = log.COMPANYID;
                    param["OPERATECONTENT"] = log.OPERATECONTENT;
                    param["OPERATEDATE"]    = log.OPERATEDATE;
                    connection.ExecuteNonQuery(strSql.ToString(), param);

                    connection.CommitTranscation();
                    blSuccess = true;
                }
            }
            catch (Exception ex)
            {
                connection.RollbackTranscation();
                LogHelper.WriteErr("注册公司时发生错误:公司名称-" + model.COMPANYNAME, ex);
            }

            return(blSuccess);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool UpdateCompanyRelate(USER_SHARE_COMPANYRELATEMODEL model, USER_SHARE_LOGMODEL log)
        {
            bool          blSuccess = false;
            StringBuilder strSql    = new StringBuilder();

            strSql.Append("update USER_SHARE_COMPANYRELATE set ");
            strSql.Append("COMPANYTYPE=:COMPANYTYPE,");
            strSql.Append("COMPANYNAME=:COMPANYNAME,");
            strSql.Append("COMPANYID=:COMPANYID,");
            strSql.Append("GROUPID=:GROUPID,");
            strSql.Append("PROJECTIDS=:PROJECTIDS,");
            strSql.Append("PRODUCTIDS=:PRODUCTIDS,");
            strSql.Append("COMPANYCODE=:COMPANYCODE,");
            strSql.Append("SHARECOMPANYID=:SHARECOMPANYID, ");
            strSql.Append("ADMINID=:ADMINID,");
            strSql.Append("GROUPIDN=:GROUPIDN ");
            strSql.Append(" where CID=:CID ");

            ParamList param = new ParamList();

            param["CID"]            = model.CID;
            param["COMPANYTYPE"]    = model.COMPANYTYPE;
            param["COMPANYNAME"]    = model.COMPANYNAME;
            param["COMPANYID"]      = model.COMPANYID;
            param["GROUPID"]        = model.GROUPID;
            param["PROJECTIDS"]     = model.PROJECTIDS;
            param["PRODUCTIDS"]     = model.PRODUCTIDS;
            param["COMPANYCODE"]    = model.COMPANYCODE;
            param["SHARECOMPANYID"] = model.SHARECOMPANYID;
            param["ADMINID"]        = model.ADMINID;
            param["GROUPIDN"]       = model.GROUPIDN;
            string strSqlS = string.Format(@"SELECT M.* FROM USER_SHARE_PRODUCTFUN P INNER JOIN USER_SHARE_FUNMENU M 
                                             ON P.FUNID=M.FMID WHERE M.FMSTATUS={0} AND P.PRODUCTID IN ({1}) AND P.FUNID
                                             NOT IN (SELECT FMID FROM USER_SHARE_COMPANYFUN WHERE COMPANYID={2}  )
                                             ", ShareEnum.FunMenuStatus.Normal.ToString("d"),
                                           model.PRODUCTIDS.TrimStart(',').TrimEnd(','),
                                           model.COMPANYCODE);

            DataTable dt = StaticConnectionProvider.ExecuteDataTable(strSqlS);

            //原来公司自己删除的菜单如果再次开通了要恢复
            strSqlS = string.Format(@"SELECT M.FMID FROM USER_SHARE_PRODUCTFUN P INNER JOIN USER_SHARE_FUNMENU M 
                                              ON P.FUNID=M.FMID WHERE M.FMSTATUS={0} AND P.PRODUCTID IN ({1}) AND P.FUNID
                                              IN (SELECT FMID FROM USER_SHARE_COMPANYFUN WHERE COMPANYID={2} AND CFSTATUS={3} )
                                             ", ShareEnum.FunMenuStatus.Normal.ToString("d"),
                                    model.PRODUCTIDS.TrimStart(',').TrimEnd(','),
                                    model.COMPANYCODE, ShareEnum.CompanyFunMenuStatus.StopUse.ToString("d"));
            DataTable dtStop = StaticConnectionProvider.ExecuteDataTable(strSqlS);
            int       nCfId  = 0;

            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

            try
            {
                using (connection)
                {
                    connection.CommitTranscation();

                    //增加项目信息
                    connection.ExecuteNonQuery(strSql.ToString(), param);
                    param.Clear();

                    //公司菜单初始化
                    foreach (DataRow dr in dt.Rows)
                    {
                        nCfId                  = CommonBusiness.GetSeqID("S_USER_SHARE_COMPANYFUN");
                        strSqlS                = string.Format(@"insert into USER_SHARE_COMPANYFUN(CFID,FMID,PROJECTID,COMPANYID,CFNAME,
                        CFANOTHERNAME,CFPAGEURL,CFPARENTID,CFSORTNUM,CFSTEP,CFISLAST,CFDESC,CFSTATUS) values (
                        :CFID,:FMID,:PROJECTID,:COMPANYID,:CFNAME,:CFANOTHERNAME,:CFPAGEURL,:CFPARENTID,:CFSORTNUM,
                        :CFSTEP,:CFISLAST,:CFDESC,:CFSTATUS)");
                        param["CFID"]          = nCfId;
                        param["FMID"]          = dr["FMID"];
                        param["PROJECTID"]     = dr["PROJECTID"];
                        param["COMPANYID"]     = model.COMPANYCODE;
                        param["CFNAME"]        = dr["FMNAME"];
                        param["CFANOTHERNAME"] = dr["FMNAME"];
                        param["CFPAGEURL"]     = CommonMethod.FinalString(dr["FMPAGEURL"]);
                        param["CFPARENTID"]    = CommonMethod.FinalString(dr["FMPARENTID"]);
                        param["CFSORTNUM"]     = dr["FMSORTNUM"];
                        param["CFSTEP"]        = CommonMethod.FinalString(dr["FMSTEP"]);
                        param["CFISLAST"]      = CommonMethod.FinalString(dr["FMISLAST"]);
                        param["CFDESC"]        = CommonMethod.FinalString(dr["FMDESC"]);
                        param["CFSTATUS"]      = ShareEnum.CompanyFunMenuStatus.Normal.ToString("d");
                        connection.ExecuteNonQuery(strSqlS, param);
                    }

                    //原来公司自己删除的菜单如果再次开通了要恢复
                    foreach (DataRow dr in dtStop.Rows)
                    {
                        strSqlS = "UPDATE USER_SHARE_COMPANYFUN SET CFSTATUS={0} WHERE COMPANYID={1} AND FMID={2} AND CFSTATUS={3}";
                        connection.ExecuteNonQuery(string.Format(strSqlS, ShareEnum.CompanyFunMenuStatus.Normal.ToString("d"),
                                                                 model.COMPANYCODE, dr["FMID"], ShareEnum.CompanyFunMenuStatus.StopUse.ToString("d")));
                    }

                    param.Clear();

                    //操作日志
                    strSql = new StringBuilder();
                    strSql.Append("insert into USER_SHARE_LOG(");
                    strSql.Append("LOGID,OPERATETYPE,OPERATORID,PROJECTID,COMPANYID,OPERATECONTENT,OPERATEDATE)");
                    strSql.Append(" values (");
                    strSql.Append(":LOGID,:OPERATETYPE,:OPERATORID,:PROJECTID,:COMPANYID,:OPERATECONTENT,:OPERATEDATE)");

                    param["LOGID"]          = log.LOGID;
                    param["OPERATETYPE"]    = log.OPERATETYPE;
                    param["OPERATORID"]     = log.OPERATORID;
                    param["PROJECTID"]      = log.PROJECTID;
                    param["COMPANYID"]      = log.COMPANYID;
                    param["OPERATECONTENT"] = log.OPERATECONTENT;
                    param["OPERATEDATE"]    = log.OPERATEDATE;
                    connection.ExecuteNonQuery(strSql.ToString(), param);

                    connection.CommitTranscation();
                    blSuccess = true;
                }
            }
            catch (Exception ex)
            {
                connection.RollbackTranscation();
                LogHelper.WriteErr("修改公司关联信息时发生错误:公司名称-" + model.COMPANYNAME, ex);
            }

            return(blSuccess);
        }