예제 #1
0
        /// <summary>
        /// 更新项目信息
        /// </summary>
        /// <param name="model"></param>
        /// <param name="log"></param>
        /// <returns></returns>
        public static bool UpdateProject(USER_SHARE_PROJECTMODEL model, USER_SHARE_LOGMODEL log)
        {
            bool          blSuccess = false;
            StringBuilder strSql    = new StringBuilder();

            strSql.Append("update USER_SHARE_PROJECT set ");
            strSql.Append("PROJECTNAME=:PROJECTNAME,");
            strSql.Append("APISERVICEKEY=:APISERVICEKEY,");
            strSql.Append("CREATEDATE=:CREATEDATE,");
            strSql.Append("PROJECTREMARK=:PROJECTREMARK,");
            strSql.Append("STATUS=:STATUS");
            strSql.Append(" where PROJECTID=:PROJECTID ");
            ParamList param = new ParamList();

            param["PROJECTID"]     = model.PROJECTID;
            param["PROJECTNAME"]   = model.PROJECTNAME;
            param["APISERVICEKEY"] = model.APISERVICEKEY;
            param["CREATEDATE"]    = model.CREATEDATE;
            param["PROJECTREMARK"] = model.PROJECTREMARK;
            param["STATUS"]        = model.STATUS;

            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

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

                    //增加项目信息
                    connection.ExecuteNonQuery(strSql.ToString(), 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("修改项目信息时发生错误:项目ID" + model.PROJECTID, ex);
            }

            return(blSuccess);
        }
        /// <summary>
        ///  停用功能菜单
        /// </summary>
        /// <param name="nFmId"></param>
        /// <param name="log"></param>
        /// <returns></returns>
        public static bool SetFunStop(int nFmId, int nCompanyId, USER_SHARE_LOGMODEL log)
        {
            bool blResult = false;

            string strSqls = "UPDATE USER_SHARE_COMPANYFUN SET CFSTATUS=:CFSTATUS WHERE FMID=:FMID AND COMPANYID=:COMPANYID ";

            ParamList param = new ParamList();

            param["FMID"]      = nFmId;
            param["COMPANYID"] = nCompanyId;
            param["CFSTATUS"]  = ShareEnum.FunMenuStatus.StopUse.ToString("d");

            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

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

                    //更改状态
                    connection.ExecuteNonQuery(strSqls, param);
                    param.Clear();
                    //操作日志
                    StringBuilder 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();
                    blResult = true;
                }
            }
            catch (Exception ex)
            {
                connection.RollbackTranscation();
                LogHelper.WriteErr("将公司功能菜单设置为无效时出现异常,Id:" + nFmId, ex);
            }
            return(blResult);
        }
예제 #3
0
        /// <summary>
        /// 删除角色信息
        /// </summary>
        /// <param name="strAccountId"></param>
        /// <param name="strStatus"></param>
        /// <returns></returns>
        public static bool DelRole(string strRoleId, USER_SHARE_LOGMODEL log)
        {
            bool          blSuccess = false;
            StringBuilder strSql    = new StringBuilder("UPDATE USER_SHARE_ROLES SET STATUS=:STATUS WHERE ROLEID=:ROLEID");
            ParamList     param     = new ParamList();

            param["ROLEID"] = strRoleId;
            param["STATUS"] = ShareEnum.RoleStatus.Del.ToString("d");
            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

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

                    //更新项目状态
                    connection.ExecuteNonQuery(strSql.ToString(), param);

                    //日志记录
                    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.Clear();
                    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("删除角色信息时发生错误:" + ex.Message + ",角色Id:" + strRoleId, ex);
            }
            return(blSuccess);
        }
예제 #4
0
        /// <summary>
        /// 更新产品状态
        /// </summary>
        /// <param name="strProductId"></param>
        /// <param name="strStatus"></param>
        /// <returns></returns>
        public static bool UpdateProductStatus(string strProductId, string strStatus, USER_SHARE_LOGMODEL log)
        {
            bool          blSuccess = false;
            StringBuilder strSql    = new StringBuilder("UPDATE USER_SHARE_PRODUCT SET PRODUCTFLAG=:PRODUCTFLAG WHERE PRODUCTID=:PRODUCTID");
            ParamList     param     = new ParamList();

            param["PRODUCTID"]   = strProductId;
            param["PRODUCTFLAG"] = strStatus;
            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

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

                    //更新项目状态
                    connection.ExecuteNonQuery(strSql.ToString(), param);

                    //日志记录
                    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.Clear();
                    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("更新产品状态时发生错误:" + ex.Message + ",产品Id:" + strProductId, ex);
            }
            return(blSuccess);
        }
예제 #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool UpdateProjectFun(USER_SHARE_FUNMENUMODEL model, USER_SHARE_LOGMODEL log)
        {
            bool blResult = false;

            StringBuilder strSql = new StringBuilder();

            strSql.Append("update USER_SHARE_FUNMENU set ");
            strSql.Append("PROJECTID=:PROJECTID,");
            strSql.Append("FMNAME=:FMNAME,");
            strSql.Append("FMPAGEURL=:FMPAGEURL,");
            strSql.Append("FMPARENTID=:FMPARENTID,");
            strSql.Append("FMSORTNUM=:FMSORTNUM,");
            strSql.Append("FMSTEP=:FMSTEP,");
            strSql.Append("FMISLAST=:FMISLAST,");
            strSql.Append("FMDESC=:FMDESC,");
            strSql.Append("FMSTATUS=:FMSTATUS");
            strSql.Append(" where FMID=:FMID ");

            ParamList param = new ParamList();

            param["FMID"]       = model.FMID;
            param["PROJECTID"]  = model.PROJECTID;
            param["FMNAME"]     = model.FMNAME;
            param["FMPAGEURL"]  = model.FMPAGEURL;
            param["FMPARENTID"] = model.FMPARENTID;
            param["FMSORTNUM"]  = model.FMSORTNUM;
            param["FMSTEP"]     = model.FMSTEP;
            param["FMISLAST"]   = model.FMISLAST;
            param["FMDESC"]     = model.FMDESC;
            param["FMSTATUS"]   = model.FMSTATUS;

            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

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

                    //增加项目信息
                    connection.ExecuteNonQuery(strSql.ToString(), param);
                    param.Clear();
                    //链接地址改动,更新公司菜单表的链接地址
                    strSql             = new StringBuilder("UPDATE USER_SHARE_COMPANYFUN SET CFPAGEURL=:CFPAGEURL WHERE CFPAGEURL!=:CFPAGEURL AND  FMID=:FMID  ");
                    param["FMID"]      = model.FMID;
                    param["CFPAGEURL"] = model.FMPAGEURL;
                    connection.ExecuteNonQuery(strSql.ToString(), 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();
                    blResult = true;
                }
            }
            catch (Exception ex)
            {
                connection.RollbackTranscation();
                LogHelper.WriteErr("修改项目功能菜单时出现异常,Id:" + model.FMID, ex);
            }

            return(blResult);
        }
예제 #6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static bool AddProjectFun(USER_SHARE_FUNMENUMODEL model, USER_SHARE_LOGMODEL log)
        {
            bool          blResult = false;
            StringBuilder strSql   = new StringBuilder();

            strSql.Append("insert into USER_SHARE_FUNMENU(");
            strSql.Append("FMID,PROJECTID,FMNAME,FMPAGEURL,FMPARENTID,FMSORTNUM,FMSTEP,FMISLAST,FMDESC,FMSTATUS)");
            strSql.Append(" values (");
            strSql.Append(":FMID,:PROJECTID,:FMNAME,:FMPAGEURL,:FMPARENTID,:FMSORTNUM,:FMSTEP,:FMISLAST,:FMDESC,:FMSTATUS)");

            ParamList param = new ParamList();

            param["FMID"]       = model.FMID;
            param["PROJECTID"]  = model.PROJECTID;
            param["FMNAME"]     = model.FMNAME;
            param["FMPAGEURL"]  = model.FMPAGEURL;
            param["FMPARENTID"] = model.FMPARENTID;
            param["FMSORTNUM"]  = model.FMSORTNUM;
            param["FMSTEP"]     = model.FMSTEP;
            param["FMISLAST"]   = model.FMISLAST;
            param["FMDESC"]     = model.FMDESC;
            param["FMSTATUS"]   = model.FMSTATUS;

            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

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

                    //增加项目信息
                    connection.ExecuteNonQuery(strSql.ToString(), 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();
                    blResult = true;
                }
            }
            catch (Exception ex)
            {
                connection.RollbackTranscation();
                LogHelper.WriteErr("新增项目功能菜单时出现异常,项目Id:" + model.PROJECTID, ex);
            }

            return(blResult);
        }
예제 #7
0
        /// <summary>
        /// 修改公司分组信息
        /// </summary>
        /// <param name="groupModel"></param>
        /// <returns></returns>
        public static bool EditCompanyGroup(USER_SHARE_GROUPMODEL groupModel, List <USER_SHARE_VEHICLE_GROUPMODEL> lstVgModel, USER_SHARE_LOGMODEL log)
        {
            bool blSuccess = false;

            StringBuilder strSql = new StringBuilder();

            strSql.Append("update USER_SHARE_GROUP set ");
            strSql.Append("COMPANYCODE=:COMPANYCODE,");
            strSql.Append("GROUPNAME=:GROUPNAME,");
            strSql.Append("PARENTID=:PARENTID,");
            strSql.Append("STATE=:STATE,");
            strSql.Append("GRADE=:GRADE,");
            strSql.Append("VEHICLENUM=:VEHICLENUM,");
            strSql.Append("GROUPDESC=:GROUPDESC");
            strSql.Append(" where ID=:ID ");

            ParamList param = new ParamList();

            param["ID"]          = groupModel.ID;
            param["COMPANYCODE"] = groupModel.COMPANYCODE;
            param["GROUPNAME"]   = groupModel.GROUPNAME;
            param["PARENTID"]    = groupModel.PARENTID;
            param["STATE"]       = groupModel.STATE;
            param["GRADE"]       = groupModel.GRADE;
            param["VEHICLENUM"]  = groupModel.VEHICLENUM;
            param["GROUPDESC"]   = groupModel.GROUPDESC;

            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

            try
            {
                using (connection)
                {
                    connection.BeginTranscation();
                    //修改公司分组信息
                    connection.ExecuteNonQuery(strSql.ToString(), param);
                    param.Clear();

                    //删除原来分组下的车辆信息
                    string strSqlFun = "DELETE FROM USER_SHARE_VEHICLE_GROUP WHERE SHAREGROUPID=" + groupModel.ID;
                    StaticConnectionProvider.ExecuteNonQuery(strSqlFun);

                    //分组车辆信息添加
                    foreach (USER_SHARE_VEHICLE_GROUPMODEL vgModel in lstVgModel)
                    {
                        strSqlFun = @"insert into USER_SHARE_VEHICLE_GROUP(SHAREGROUPID,TARGETID,MACID)
                                       values (:SHAREGROUPID,:TARGETID,:MACID)";
                        param.Clear();
                        param["SHAREGROUPID"] = groupModel.ID;
                        param["TARGETID"]     = vgModel.TARGETID;
                        param["MACID"]        = vgModel.MACID;
                        connection.ExecuteNonQuery(strSqlFun, 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("修改公司分组信息时发生错误,分组Id:" + groupModel.ID, ex);
            }

            return(blSuccess);
        }
예제 #8
0
        /// <summary>
        /// 新增公司分组信息
        /// </summary>
        /// <param name="groupModel"></param>
        /// <returns></returns>
        public static bool AddCompanyGroup(USER_SHARE_GROUPMODEL groupModel, List <USER_SHARE_VEHICLE_GROUPMODEL> lstVgModel, USER_SHARE_LOGMODEL log)
        {
            bool          blSuccess = false;
            StringBuilder strSql    = new StringBuilder();

            strSql.Append("insert into USER_SHARE_GROUP(");
            strSql.Append("ID,COMPANYCODE,GROUPNAME,PARENTID,STATE,GRADE,VEHICLENUM,GROUPDESC)");
            strSql.Append(" values (");
            strSql.Append(":ID,:COMPANYCODE,:GROUPNAME,:PARENTID,:STATE,:GRADE,:VEHICLENUM,:GROUPDESC)");
            ParamList param = new ParamList();

            param["ID"]          = groupModel.ID;
            param["COMPANYCODE"] = groupModel.COMPANYCODE;
            param["GROUPNAME"]   = groupModel.GROUPNAME;
            param["PARENTID"]    = groupModel.PARENTID;
            param["STATE"]       = groupModel.STATE;
            param["GRADE"]       = groupModel.GRADE;
            param["VEHICLENUM"]  = groupModel.VEHICLENUM;
            param["GROUPDESC"]   = groupModel.GROUPDESC;
            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

            try
            {
                using (connection)
                {
                    connection.BeginTranscation();
                    //增加分组信息
                    connection.ExecuteNonQuery(strSql.ToString(), param);
                    param.Clear();

                    string strSqlFun = string.Empty;

                    //分组车辆

                    foreach (USER_SHARE_VEHICLE_GROUPMODEL vgModel in lstVgModel)
                    {
                        strSqlFun = string.Format("insert into USER_SHARE_VEHICLE_GROUP(SHAREGROUPID,TARGETID,MACID)values(:SHAREGROUPID,:TARGETID,:MACID)");
                        param.Clear();
                        param["SHAREGROUPID"] = groupModel.ID;
                        param["TARGETID"]     = vgModel.TARGETID;
                        param["MACID"]        = vgModel.MACID;
                        connection.ExecuteNonQuery(strSqlFun, param);
                    }

                    //操作日志
                    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.Clear();

                    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("新增公司车辆分组信息时发生错误,分组名称:" + groupModel.GROUPNAME, ex);
            }

            return(blSuccess);
        }
예제 #9
0
        /// <summary>
        /// 新增角色信息
        /// </summary>
        /// <param name="roleModel"></param>
        /// <returns></returns>
        public static bool AddARole(USER_SHARE_ROLESMODEL roleModel, string strFunIds, string strGroupIds, List <RoleAccountModel> lstRaModel, USER_SHARE_LOGMODEL log)
        {
            bool          blSuccess = false;
            StringBuilder strSql    = new StringBuilder();

            strSql.Append("insert into USER_SHARE_ROLES(");
            strSql.Append("ROLEID,ROLENAME,ROLEDESC,PROJECTID,COMPANYID,STATUS,CREATORID,CREATEDATE)");
            strSql.Append(" values (");
            strSql.Append(":ROLEID,:ROLENAME,:ROLEDESC,:PROJECTID,:COMPANYID,:STATUS,:CREATORID,:CREATEDATE)");
            ParamList param = new ParamList();

            param["ROLEID"]     = roleModel.ROLEID;
            param["ROLENAME"]   = roleModel.ROLENAME;
            param["ROLEDESC"]   = roleModel.ROLEDESC;
            param["PROJECTID"]  = roleModel.PROJECTID;
            param["COMPANYID"]  = roleModel.COMPANYID;
            param["STATUS"]     = roleModel.STATUS;
            param["CREATORID"]  = roleModel.CreatorId;
            param["CREATEDATE"] = roleModel.CreateDate;

            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

            try
            {
                using (connection)
                {
                    connection.BeginTranscation();
                    //增加角色信息
                    connection.ExecuteNonQuery(strSql.ToString(), param);
                    param.Clear();

                    string strSqlFun = string.Empty;

                    //角色功能
                    if (strFunIds.Trim().Length > 0)
                    {
                        string[] funId = strFunIds.Split(',');

                        foreach (string str in funId)
                        {
                            if (str.Trim().Length > 0)
                            {
                                strSqlFun = string.Format("INSERT INTO USER_SHARE_ROLEFUN(ROLEID,FUNID) VALUES({0},{1}) ", roleModel.ROLEID, str);
                                connection.ExecuteNonQuery(strSqlFun);
                            }
                        }
                    }

                    //角色下的账号更新
                    foreach (RoleAccountModel raModel in lstRaModel)
                    {
                        //新增时选中的账号,角色更新,未选中的不用做处理
                        if (raModel.IsChecked)
                        {
                            strSqlFun = string.Format("UPDATE USER_SHARE_ACCOUNT SET ROLEIDS=(ROLEIDS||(CASE WHEN ROLEIDS IS NULL THEN ',{0},' ELSE '{0},' END )) WHERE ACCOUNTID={1} ", roleModel.ROLEID, raModel.AccountId);
                            connection.ExecuteNonQuery(strSqlFun);
                        }
                    }

                    //拥有权限的车辆分组
                    if (strGroupIds.Trim().Length > 0)
                    {
                        string[] funId = strGroupIds.Split(',');

                        foreach (string str in funId)
                        {
                            if (str.Trim().Length > 0)
                            {
                                strSqlFun = string.Format("INSERT INTO USER_SHARE_ROLE_GROUP(ROLEID,SHAREGROUPID) VALUES({0},{1}) ", roleModel.ROLEID, str);
                                connection.ExecuteNonQuery(strSqlFun);
                            }
                        }
                    }

                    //操作日志
                    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("新增角色信息时发生错误,角色名称:" + roleModel.ROLENAME, ex);
            }

            return(blSuccess);
        }
예제 #10
0
        /// <summary>
        /// 修改角色信息
        /// </summary>
        /// <param name="roleModel"></param>
        /// <returns></returns>
        public static bool EditRole(USER_SHARE_ROLESMODEL roleModel, string strFunIds, string strGroupIds, List <RoleAccountModel> lstRaModel, USER_SHARE_LOGMODEL log)
        {
            bool blSuccess = false;

            StringBuilder strSql = new StringBuilder();

            strSql.Append("update USER_SHARE_ROLES set ");
            strSql.Append("ROLENAME=:ROLENAME,");
            strSql.Append("ROLEDESC=:ROLEDESC,");
            strSql.Append("PROJECTID=:PROJECTID,");
            strSql.Append("COMPANYID=:COMPANYID,");
            strSql.Append("STATUS=:STATUS");
            strSql.Append(" where ROLEID=:ROLEID ");

            ParamList param = new ParamList();

            param["ROLEID"]    = roleModel.ROLEID;
            param["ROLENAME"]  = roleModel.ROLENAME;
            param["ROLEDESC"]  = roleModel.ROLEDESC;
            param["PROJECTID"] = roleModel.PROJECTID;
            param["COMPANYID"] = roleModel.COMPANYID;
            param["STATUS"]    = roleModel.STATUS;

            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

            try
            {
                using (connection)
                {
                    connection.BeginTranscation();
                    //修改账号信息
                    connection.ExecuteNonQuery(strSql.ToString(), param);
                    param.Clear();

                    //角色功能

                    //删除旧的信息
                    string strSqlFun = "DELETE FROM USER_SHARE_ROLEFUN WHERE ROLEID=" + roleModel.ROLEID;
                    connection.ExecuteNonQuery(strSqlFun);

                    //新的信息插入
                    if (strFunIds.Trim().Length > 0)
                    {
                        string[] funId = strFunIds.Split(',');

                        foreach (string str in funId)
                        {
                            if (str.Trim().Length > 0)
                            {
                                strSqlFun = string.Format("INSERT INTO USER_SHARE_ROLEFUN(ROLEID,FUNID) VALUES({0},{1}) ", roleModel.ROLEID, str);
                                connection.ExecuteNonQuery(strSqlFun);
                            }
                        }
                    }

                    //角色下的账号更新
                    foreach (RoleAccountModel raModel in lstRaModel)
                    {
                        //修改时账号角色更新
                        if (raModel.IsChecked)
                        {
                            strSqlFun = string.Format(@"UPDATE USER_SHARE_ACCOUNT SET ROLEIDS=(CASE WHEN REPLACE(ROLEIDS,',{0},',',')=',' OR ROLEIDS  IS NULL 
                                                        THEN ',{0},' ELSE REPLACE(ROLEIDS,',{0},',',')||'{0},'  end) WHERE ACCOUNTID={1} ", roleModel.ROLEID, raModel.AccountId);
                        }
                        else
                        {
                            strSqlFun = string.Format(@"UPDATE USER_SHARE_ACCOUNT SET ROLEIDS=(CASE WHEN REPLACE(ROLEIDS,',{0},',',')=',' OR ROLEIDS  IS NULL 
                                                        THEN '' ELSE REPLACE(ROLEIDS,',{0},',',')  end) WHERE ACCOUNTID={1} ", roleModel.ROLEID, raModel.AccountId);
                        }

                        connection.ExecuteNonQuery(strSqlFun);
                    }


                    //车辆分组

                    //删除旧的信息
                    strSqlFun = "DELETE FROM USER_SHARE_ROLE_GROUP WHERE ROLEID=" + roleModel.ROLEID;
                    connection.ExecuteNonQuery(strSqlFun);

                    //新的信息插入
                    if (strGroupIds.Trim().Length > 0)
                    {
                        string[] funId = strGroupIds.Split(',');

                        foreach (string str in funId)
                        {
                            if (str.Trim().Length > 0)
                            {
                                strSqlFun = string.Format("INSERT INTO USER_SHARE_ROLE_GROUP(ROLEID,SHAREGROUPID) VALUES({0},{1}) ", roleModel.ROLEID, str);
                                connection.ExecuteNonQuery(strSqlFun);
                            }
                        }
                    }

                    //操作日志
                    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("修改角色信息时发生错误,角色Id:" + roleModel.ROLEID, ex);
            }

            return(blSuccess);
        }
예제 #11
0
        /// <summary>
        /// 新增账号信息
        /// </summary>
        /// <param name="AccountModel"></param>
        /// <returns></returns>
        public static bool AddAccount(USER_SHARE_ACCOUNTMODEL AccountModel, USER_SHARE_LOGMODEL log)
        {
            bool blSuccess = false;

            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into USER_SHARE_ACCOUNT(");
            strSql.Append("ACCOUNTID,ACCOUNTNAME,COMPANYID,ACCOUNTPWD,ORIGNALPWD,REALNAME,EMAIL,ROLEIDS,LINKPHONE,CREATEDATE,CREATORID,ISADMIN,STATUS)");
            strSql.Append(" values (");
            strSql.Append(":ACCOUNTID,:ACCOUNTNAME,:COMPANYID,:ACCOUNTPWD,:ORIGNALPWD,:REALNAME,:EMAIL,:ROLEIDS,:LINKPHONE,:CREATEDATE,:CREATORID,:ISADMIN,:STATUS)");
            ParamList param = new ParamList();

            param["ACCOUNTID"]   = AccountModel.ACCOUNTID;
            param["ACCOUNTNAME"] = AccountModel.ACCOUNTNAME;
            param["COMPANYID"]   = AccountModel.COMPANYID;
            param["ACCOUNTPWD"]  = AccountModel.ACCOUNTPWD;
            param["ORIGNALPWD"]  = AccountModel.ORIGNALPWD;
            param["REALNAME"]    = AccountModel.REALNAME;
            param["EMAIL"]       = AccountModel.EMAIL;
            param["ROLEIDS"]     = AccountModel.ROLEIDS;
            param["LINKPHONE"]   = AccountModel.LINKPHONE;
            param["CREATEDATE"]  = AccountModel.CREATEDATE;
            param["CREATORID"]   = AccountModel.CREATORID;
            param["ISADMIN"]     = AccountModel.ISADMIN;
            param["STATUS"]      = AccountModel.STATUS;

            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

            try
            {
                using (connection)
                {
                    connection.BeginTranscation();
                    //增加账号信息
                    connection.ExecuteNonQuery(strSql.ToString(), param);
                    param.Clear();

                    if (AccountModel.ISADMIN == 1)//初始账号时更新公司关联信息表
                    {
                        string strUpSql = string.Format("UPDATE USER_SHARE_COMPANYRELATE SET ADMINID={0} WHERE COMPANYCODE={1} ",
                                                        AccountModel.ACCOUNTID, AccountModel.COMPANYID);
                        connection.ExecuteNonQuery(strUpSql);
                    }

                    //操作日志
                    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("新增账号信息时发生错误,账号名称:" + AccountModel.ACCOUNTNAME, ex);
            }

            return(blSuccess);
        }
예제 #12
0
        /// <summary>
        /// 修改账号信息
        /// </summary>
        /// <param name="AccountModel"></param>
        /// <returns></returns>
        public static bool EditAccount(USER_SHARE_ACCOUNTMODEL AccountModel, USER_SHARE_LOGMODEL log)
        {
            bool blSuccess = false;

            StringBuilder strSql = new StringBuilder();

            strSql.Append("update USER_SHARE_ACCOUNT set ");
            strSql.Append("ACCOUNTNAME=:ACCOUNTNAME,");
            strSql.Append("COMPANYID=:COMPANYID,");
            strSql.Append("ACCOUNTPWD=:ACCOUNTPWD,");
            strSql.Append("ORIGNALPWD=:ORIGNALPWD,");
            strSql.Append("REALNAME=:REALNAME,");
            strSql.Append("EMAIL=:EMAIL,");
            strSql.Append("ROLEIDS=:ROLEIDS,");
            strSql.Append("LINKPHONE=:LINKPHONE,");
            strSql.Append("CREATEDATE=:CREATEDATE,");
            strSql.Append("CREATORID=:CREATORID,");
            strSql.Append("ISADMIN=:ISADMIN,");
            strSql.Append("STATUS=:STATUS");
            strSql.Append(" where ACCOUNTID=:ACCOUNTID ");
            ParamList param = new ParamList();

            param["ACCOUNTID"]   = AccountModel.ACCOUNTID;
            param["ACCOUNTNAME"] = AccountModel.ACCOUNTNAME;
            param["COMPANYID"]   = AccountModel.COMPANYID;
            param["ACCOUNTPWD"]  = AccountModel.ACCOUNTPWD;
            param["ORIGNALPWD"]  = AccountModel.ORIGNALPWD;
            param["REALNAME"]    = AccountModel.REALNAME;
            param["EMAIL"]       = AccountModel.EMAIL;
            param["ROLEIDS"]     = AccountModel.ROLEIDS;
            param["LINKPHONE"]   = AccountModel.LINKPHONE;
            param["CREATEDATE"]  = AccountModel.CREATEDATE;
            param["CREATORID"]   = AccountModel.CREATORID;
            param["ISADMIN"]     = AccountModel.ISADMIN;
            param["STATUS"]      = AccountModel.STATUS;

            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

            try
            {
                using (connection)
                {
                    connection.BeginTranscation();
                    //修改账号信息
                    connection.ExecuteNonQuery(strSql.ToString(), 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("修改账号信息时发生错误,账号名称:" + AccountModel.ACCOUNTNAME, ex);
            }

            return(blSuccess);
        }
예제 #13
0
        /// <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);
        }
예제 #14
0
        /// <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);
        }
예제 #15
0
        /// <summary>
        /// 修改一条数据
        /// </summary>
        public static bool EditProduct(USER_SHARE_PRODUCTMODEL model, List <USER_SHARE_PRODUCTFUNMODEL> lstFunModel, USER_SHARE_LOGMODEL log)
        {
            bool blSuccess = false;

            StringBuilder strSql = new StringBuilder();

            strSql.Append("update USER_SHARE_PRODUCT set ");
            strSql.Append("PROJECTID=:PROJECTID,");
            strSql.Append("PRODUCTNAME=:PRODUCTNAME,");
            strSql.Append("PRODUCTDESC=:PRODUCTDESC");
            strSql.Append(" where PRODUCTID=:PRODUCTID ");
            ParamList param = new ParamList();

            param["PRODUCTID"]   = model.PRODUCTID;
            param["PROJECTID"]   = model.PROJECTID;
            param["PRODUCTNAME"] = model.PRODUCTNAME;
            param["PRODUCTDESC"] = model.PRODUCTDESC;


            IConnectionProvider connection = ConnectionProviderBuilder.CreateConnectionProvider();

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

                    //增加产品基础信息
                    connection.ExecuteNonQuery(strSql.ToString(), param);
                    param.Clear();

                    //产品功能信息

                    //删除原来的
                    connection.ExecuteNonQuery("DELETE FROM USER_SHARE_PRODUCTFUN WHERE PRODUCTID=" + model.PRODUCTID);
                    //增加现在的
                    foreach (USER_SHARE_PRODUCTFUNMODEL funmodel in lstFunModel)
                    {
                        strSql = new StringBuilder();
                        strSql.Append("insert into USER_SHARE_PRODUCTFUN(");
                        strSql.Append("PRODUCTID,FUNID)");
                        strSql.Append(" values (");
                        strSql.Append(":PRODUCTID,:FUNID)");

                        param["PRODUCTID"] = funmodel.PROCUTID;
                        param["FUNID"]     = funmodel.FUNID;

                        connection.ExecuteNonQuery(strSql.ToString(), 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.PRODUCTNAME, ex);
            }

            return(blSuccess);
        }