示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WeiXinPF.Model.wx_link_module model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_link_module(");
            strSql.Append("lName,moduleName,moduleCode,moduleType,urlRule,urlNeedReplace,tableName,isGlobal,isMore,sortId,remark,idColumn,nameColumn)");
            strSql.Append(" values (");
            strSql.Append("@lName,@moduleName,@moduleCode,@moduleType,@urlRule,@urlNeedReplace,@tableName,@isGlobal,@isMore,@sortId,@remark,@idColumn,@nameColumn)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@lName",          SqlDbType.VarChar,  100),
                new SqlParameter("@moduleName",     SqlDbType.VarChar,  100),
                new SqlParameter("@moduleCode",     SqlDbType.VarChar,   30),
                new SqlParameter("@moduleType",     SqlDbType.Int,        4),
                new SqlParameter("@urlRule",        SqlDbType.VarChar, 1200),
                new SqlParameter("@urlNeedReplace", SqlDbType.Bit,        1),
                new SqlParameter("@tableName",      SqlDbType.VarChar,   50),
                new SqlParameter("@isGlobal",       SqlDbType.Bit,        1),
                new SqlParameter("@isMore",         SqlDbType.Bit,        1),
                new SqlParameter("@sortId",         SqlDbType.Int,        4),
                new SqlParameter("@remark",         SqlDbType.VarChar, 1500),
                new SqlParameter("@idColumn",       SqlDbType.VarChar,   30),
                new SqlParameter("@nameColumn",     SqlDbType.VarChar, 30)
            };
            parameters[0].Value  = model.lName;
            parameters[1].Value  = model.moduleName;
            parameters[2].Value  = model.moduleCode;
            parameters[3].Value  = model.moduleType;
            parameters[4].Value  = model.urlRule;
            parameters[5].Value  = model.urlNeedReplace;
            parameters[6].Value  = model.tableName;
            parameters[7].Value  = model.isGlobal;
            parameters[8].Value  = model.isMore;
            parameters[9].Value  = model.sortId;
            parameters[10].Value = model.remark;
            parameters[11].Value = model.idColumn;
            parameters[12].Value = model.nameColumn;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WeiXinPF.Model.wx_link_module GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,lName,moduleName,moduleCode,moduleType,urlRule,urlNeedReplace,tableName,isGlobal,isMore,sortId,remark,idColumn,nameColumn from wx_link_module ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            WeiXinPF.Model.wx_link_module model = new WeiXinPF.Model.wx_link_module();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WeiXinPF.Model.wx_link_module DataRowToModel(DataRow row)
 {
     WeiXinPF.Model.wx_link_module model = new WeiXinPF.Model.wx_link_module();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["lName"] != null)
         {
             model.lName = row["lName"].ToString();
         }
         if (row["moduleName"] != null)
         {
             model.moduleName = row["moduleName"].ToString();
         }
         if (row["moduleCode"] != null)
         {
             model.moduleCode = row["moduleCode"].ToString();
         }
         if (row["moduleType"] != null && row["moduleType"].ToString() != "")
         {
             model.moduleType = int.Parse(row["moduleType"].ToString());
         }
         if (row["urlRule"] != null)
         {
             model.urlRule = row["urlRule"].ToString();
         }
         if (row["urlNeedReplace"] != null && row["urlNeedReplace"].ToString() != "")
         {
             if ((row["urlNeedReplace"].ToString() == "1") || (row["urlNeedReplace"].ToString().ToLower() == "true"))
             {
                 model.urlNeedReplace = true;
             }
             else
             {
                 model.urlNeedReplace = false;
             }
         }
         if (row["tableName"] != null)
         {
             model.tableName = row["tableName"].ToString();
         }
         if (row["isGlobal"] != null && row["isGlobal"].ToString() != "")
         {
             if ((row["isGlobal"].ToString() == "1") || (row["isGlobal"].ToString().ToLower() == "true"))
             {
                 model.isGlobal = true;
             }
             else
             {
                 model.isGlobal = false;
             }
         }
         if (row["isMore"] != null && row["isMore"].ToString() != "")
         {
             if ((row["isMore"].ToString() == "1") || (row["isMore"].ToString().ToLower() == "true"))
             {
                 model.isMore = true;
             }
             else
             {
                 model.isMore = false;
             }
         }
         if (row["sortId"] != null && row["sortId"].ToString() != "")
         {
             model.sortId = int.Parse(row["sortId"].ToString());
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
         if (row["idColumn"] != null)
         {
             model.idColumn = row["idColumn"].ToString();
         }
         if (row["nameColumn"] != null)
         {
             model.nameColumn = row["nameColumn"].ToString();
         }
     }
     return(model);
 }
示例#4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WeiXinPF.Model.wx_link_module model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_link_module set ");
            strSql.Append("lName=@lName,");
            strSql.Append("moduleName=@moduleName,");
            strSql.Append("moduleCode=@moduleCode,");
            strSql.Append("moduleType=@moduleType,");
            strSql.Append("urlRule=@urlRule,");
            strSql.Append("urlNeedReplace=@urlNeedReplace,");
            strSql.Append("tableName=@tableName,");
            strSql.Append("isGlobal=@isGlobal,");
            strSql.Append("isMore=@isMore,");
            strSql.Append("sortId=@sortId,");
            strSql.Append("remark=@remark,");
            strSql.Append("idColumn=@idColumn,");
            strSql.Append("nameColumn=@nameColumn");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@lName",          SqlDbType.VarChar,  100),
                new SqlParameter("@moduleName",     SqlDbType.VarChar,  100),
                new SqlParameter("@moduleCode",     SqlDbType.VarChar,   30),
                new SqlParameter("@moduleType",     SqlDbType.Int,        4),
                new SqlParameter("@urlRule",        SqlDbType.VarChar, 1200),
                new SqlParameter("@urlNeedReplace", SqlDbType.Bit,        1),
                new SqlParameter("@tableName",      SqlDbType.VarChar,   50),
                new SqlParameter("@isGlobal",       SqlDbType.Bit,        1),
                new SqlParameter("@isMore",         SqlDbType.Bit,        1),
                new SqlParameter("@sortId",         SqlDbType.Int,        4),
                new SqlParameter("@remark",         SqlDbType.VarChar, 1500),
                new SqlParameter("@idColumn",       SqlDbType.VarChar,   30),
                new SqlParameter("@nameColumn",     SqlDbType.VarChar,   30),
                new SqlParameter("@id",             SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.lName;
            parameters[1].Value  = model.moduleName;
            parameters[2].Value  = model.moduleCode;
            parameters[3].Value  = model.moduleType;
            parameters[4].Value  = model.urlRule;
            parameters[5].Value  = model.urlNeedReplace;
            parameters[6].Value  = model.tableName;
            parameters[7].Value  = model.isGlobal;
            parameters[8].Value  = model.isMore;
            parameters[9].Value  = model.sortId;
            parameters[10].Value = model.remark;
            parameters[11].Value = model.idColumn;
            parameters[12].Value = model.nameColumn;
            parameters[13].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }