Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WeiXinPF.Model.wx_wsite_modulebase model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_wsite_modulebase set ");
            strSql.Append("mName=@mName,");
            strSql.Append("mCode=@mCode,");
            strSql.Append("mValueInt=@mValueInt,");
            strSql.Append("mValue=@mValue,");
            strSql.Append("mType=@mType,");
            strSql.Append("mTypeName=@mTypeName,");
            strSql.Append("picUrl=@picUrl,");
            strSql.Append("remark=@remark,");
            strSql.Append("seq=@seq,");
            strSql.Append("createDate=@createDate");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@mName",      SqlDbType.VarChar,   1000),
                new SqlParameter("@mCode",      SqlDbType.VarChar,    100),
                new SqlParameter("@mValueInt",  SqlDbType.Int,          4),
                new SqlParameter("@mValue",     SqlDbType.VarChar,   2000),
                new SqlParameter("@mType",      SqlDbType.VarChar,    100),
                new SqlParameter("@mTypeName",  SqlDbType.VarChar,    150),
                new SqlParameter("@picUrl",     SqlDbType.NVarChar,  1000),
                new SqlParameter("@remark",     SqlDbType.VarChar,   1000),
                new SqlParameter("@seq",        SqlDbType.Int,          4),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.mName;
            parameters[1].Value  = model.mCode;
            parameters[2].Value  = model.mValueInt;
            parameters[3].Value  = model.mValue;
            parameters[4].Value  = model.mType;
            parameters[5].Value  = model.mTypeName;
            parameters[6].Value  = model.picUrl;
            parameters[7].Value  = model.remark;
            parameters[8].Value  = model.seq;
            parameters[9].Value  = model.createDate;
            parameters[10].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WeiXinPF.Model.wx_wsite_modulebase DataRowToModel(DataRow row)
 {
     WeiXinPF.Model.wx_wsite_modulebase model = new WeiXinPF.Model.wx_wsite_modulebase();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["mName"] != null)
         {
             model.mName = row["mName"].ToString();
         }
         if (row["mCode"] != null)
         {
             model.mCode = row["mCode"].ToString();
         }
         if (row["mValueInt"] != null && row["mValueInt"].ToString() != "")
         {
             model.mValueInt = int.Parse(row["mValueInt"].ToString());
         }
         if (row["mValue"] != null)
         {
             model.mValue = row["mValue"].ToString();
         }
         if (row["mType"] != null)
         {
             model.mType = row["mType"].ToString();
         }
         if (row["mTypeName"] != null)
         {
             model.mTypeName = row["mTypeName"].ToString();
         }
         if (row["picUrl"] != null)
         {
             model.picUrl = row["picUrl"].ToString();
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
         if (row["seq"] != null && row["seq"].ToString() != "")
         {
             model.seq = int.Parse(row["seq"].ToString());
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
     }
     return(model);
 }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WeiXinPF.Model.wx_wsite_modulebase model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_wsite_modulebase(");
            strSql.Append("mName,mCode,mValueInt,mValue,mType,mTypeName,picUrl,remark,seq,createDate)");
            strSql.Append(" values (");
            strSql.Append("@mName,@mCode,@mValueInt,@mValue,@mType,@mTypeName,@picUrl,@remark,@seq,@createDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@mName",      SqlDbType.VarChar,  1000),
                new SqlParameter("@mCode",      SqlDbType.VarChar,   100),
                new SqlParameter("@mValueInt",  SqlDbType.Int,         4),
                new SqlParameter("@mValue",     SqlDbType.VarChar,  2000),
                new SqlParameter("@mType",      SqlDbType.VarChar,   100),
                new SqlParameter("@mTypeName",  SqlDbType.VarChar,   150),
                new SqlParameter("@picUrl",     SqlDbType.NVarChar, 1000),
                new SqlParameter("@remark",     SqlDbType.VarChar,  1000),
                new SqlParameter("@seq",        SqlDbType.Int,         4),
                new SqlParameter("@createDate", SqlDbType.DateTime)
            };
            parameters[0].Value = model.mName;
            parameters[1].Value = model.mCode;
            parameters[2].Value = model.mValueInt;
            parameters[3].Value = model.mValue;
            parameters[4].Value = model.mType;
            parameters[5].Value = model.mTypeName;
            parameters[6].Value = model.picUrl;
            parameters[7].Value = model.remark;
            parameters[8].Value = model.seq;
            parameters[9].Value = model.createDate;

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

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

            strSql.Append("select  top 1 id,mName,mCode,mValueInt,mValue,mType,mTypeName,picUrl,remark,seq,createDate from wx_wsite_modulebase ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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