示例#1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_industry_defaultModule DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_industry_defaultModule model = new MxWeiXinPF.Model.wx_industry_defaultModule();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["role_id"] != null && row["role_id"].ToString() != "")
         {
             model.role_id = int.Parse(row["role_id"].ToString());
         }
         if (row["typeName"] != null)
         {
             model.typeName = row["typeName"].ToString();
         }
         if (row["mName"] != null)
         {
             model.mName = row["mName"].ToString();
         }
         if (row["isArticle"] != null && row["isArticle"].ToString() != "")
         {
             if ((row["isArticle"].ToString() == "1") || (row["isArticle"].ToString().ToLower() == "true"))
             {
                 model.isArticle = true;
             }
             else
             {
                 model.isArticle = false;
             }
         }
         if (row["url"] != null)
         {
             model.url = row["url"].ToString();
         }
         if (row["sort_id"] != null && row["sort_id"].ToString() != "")
         {
             model.sort_id = int.Parse(row["sort_id"].ToString());
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
     }
     return(model);
 }
示例#2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MxWeiXinPF.Model.wx_industry_defaultModule model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_industry_defaultModule set ");
            strSql.Append("role_id=@role_id,");
            strSql.Append("typeName=@typeName,");
            strSql.Append("mName=@mName,");
            strSql.Append("isArticle=@isArticle,");
            strSql.Append("url=@url,");
            strSql.Append("sort_id=@sort_id,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("remark=@remark");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@role_id",    SqlDbType.Int,          4),
                new SqlParameter("@typeName",   SqlDbType.VarChar,    100),
                new SqlParameter("@mName",      SqlDbType.VarChar,    500),
                new SqlParameter("@isArticle",  SqlDbType.Bit,          1),
                new SqlParameter("@url",        SqlDbType.VarChar,   1000),
                new SqlParameter("@sort_id",    SqlDbType.Int,          4),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@remark",     SqlDbType.VarChar,   2000),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.role_id;
            parameters[1].Value = model.typeName;
            parameters[2].Value = model.mName;
            parameters[3].Value = model.isArticle;
            parameters[4].Value = model.url;
            parameters[5].Value = model.sort_id;
            parameters[6].Value = model.createDate;
            parameters[7].Value = model.remark;
            parameters[8].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MxWeiXinPF.Model.wx_industry_defaultModule model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_industry_defaultModule(");
            strSql.Append("role_id,typeName,mName,isArticle,url,sort_id,createDate,remark)");
            strSql.Append(" values (");
            strSql.Append("@role_id,@typeName,@mName,@isArticle,@url,@sort_id,@createDate,@remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@role_id",    SqlDbType.Int,          4),
                new SqlParameter("@typeName",   SqlDbType.VarChar,    100),
                new SqlParameter("@mName",      SqlDbType.VarChar,    500),
                new SqlParameter("@isArticle",  SqlDbType.Bit,          1),
                new SqlParameter("@url",        SqlDbType.VarChar,   1000),
                new SqlParameter("@sort_id",    SqlDbType.Int,          4),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@remark",     SqlDbType.VarChar, 2000)
            };
            parameters[0].Value = model.role_id;
            parameters[1].Value = model.typeName;
            parameters[2].Value = model.mName;
            parameters[3].Value = model.isArticle;
            parameters[4].Value = model.url;
            parameters[5].Value = model.sort_id;
            parameters[6].Value = model.createDate;
            parameters[7].Value = model.remark;

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

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

            strSql.Append("select  top 1 id,role_id,typeName,mName,isArticle,url,sort_id,createDate,remark from wx_industry_defaultModule ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }