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

            strSql.Append("update wx_ucard_udegree set ");
            strSql.Append("wid=@wid,");
            strSql.Append("degreeNum=@degreeNum,");
            strSql.Append("callName=@callName,");
            strSql.Append("score_min=@score_min,");
            strSql.Append("score_max=@score_max,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("sId=@sId");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",        SqlDbType.Int,        4),
                new SqlParameter("@degreeNum",  SqlDbType.Int,        4),
                new SqlParameter("@callName",   SqlDbType.VarChar,   30),
                new SqlParameter("@score_min",  SqlDbType.Int,        4),
                new SqlParameter("@score_max",  SqlDbType.Int,        4),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@sId",        SqlDbType.Int,        4),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.degreeNum;
            parameters[2].Value = model.callName;
            parameters[3].Value = model.score_min;
            parameters[4].Value = model.score_max;
            parameters[5].Value = model.createDate;
            parameters[6].Value = model.sId;
            parameters[7].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WeiXinPF.Model.wx_ucard_udegree DataRowToModel(DataRow row)
 {
     WeiXinPF.Model.wx_ucard_udegree model = new WeiXinPF.Model.wx_ucard_udegree();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["wid"] != null && row["wid"].ToString() != "")
         {
             model.wid = int.Parse(row["wid"].ToString());
         }
         if (row["degreeNum"] != null && row["degreeNum"].ToString() != "")
         {
             model.degreeNum = int.Parse(row["degreeNum"].ToString());
         }
         if (row["callName"] != null)
         {
             model.callName = row["callName"].ToString();
         }
         if (row["score_min"] != null && row["score_min"].ToString() != "")
         {
             model.score_min = int.Parse(row["score_min"].ToString());
         }
         if (row["score_max"] != null && row["score_max"].ToString() != "")
         {
             model.score_max = int.Parse(row["score_max"].ToString());
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
         if (row["sId"] != null && row["sId"].ToString() != "")
         {
             model.sId = int.Parse(row["sId"].ToString());
         }
     }
     return(model);
 }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WeiXinPF.Model.wx_ucard_udegree model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_ucard_udegree(");
            strSql.Append("wid,degreeNum,callName,score_min,score_max,createDate,sId)");
            strSql.Append(" values (");
            strSql.Append("@wid,@degreeNum,@callName,@score_min,@score_max,@createDate,@sId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",        SqlDbType.Int,        4),
                new SqlParameter("@degreeNum",  SqlDbType.Int,        4),
                new SqlParameter("@callName",   SqlDbType.VarChar,   30),
                new SqlParameter("@score_min",  SqlDbType.Int,        4),
                new SqlParameter("@score_max",  SqlDbType.Int,        4),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@sId",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.wid;
            parameters[1].Value = model.degreeNum;
            parameters[2].Value = model.callName;
            parameters[3].Value = model.score_min;
            parameters[4].Value = model.score_max;
            parameters[5].Value = model.createDate;
            parameters[6].Value = model.sId;

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

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

            strSql.Append("select  top 1 id,wid,degreeNum,callName,score_min,score_max,createDate,sId from wx_ucard_udegree ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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