Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(lgk.Model.tb_message model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_message set ");
            strSql.Append("Userid=@Userid,");
            strSql.Append("MobileNum=@MobileNum,");
            strSql.Append("Mcontent=@Mcontent,");
            strSql.Append("Flag=@Flag");
            strSql.Append(" where MID=@MID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Userid",    SqlDbType.Int,       4),
                new SqlParameter("@MobileNum", SqlDbType.VarChar,  50),
                new SqlParameter("@Mcontent",  SqlDbType.VarChar, 500),
                new SqlParameter("@Flag",      SqlDbType.VarChar,  50),
                new SqlParameter("@MID",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Userid;
            parameters[1].Value = model.MobileNum;
            parameters[2].Value = model.Mcontent;
            parameters[3].Value = model.Flag;
            parameters[4].Value = model.MID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(lgk.Model.tb_message model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_message(");
            strSql.Append("Userid,MobileNum,Mcontent,Flag)");
            strSql.Append(" values (");
            strSql.Append("@Userid,@MobileNum,@Mcontent,@Flag)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Userid",    SqlDbType.Int,       4),
                new SqlParameter("@MobileNum", SqlDbType.VarChar,  50),
                new SqlParameter("@Mcontent",  SqlDbType.VarChar, 500),
                new SqlParameter("@Flag",      SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.Userid;
            parameters[1].Value = model.MobileNum;
            parameters[2].Value = model.Mcontent;
            parameters[3].Value = model.Flag;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public lgk.Model.tb_message DataRowToModel(DataRow row)
 {
     lgk.Model.tb_message model = new lgk.Model.tb_message();
     if (row != null)
     {
         if (row["MID"] != null && row["MID"].ToString() != "")
         {
             model.MID = int.Parse(row["MID"].ToString());
         }
         if (row["Userid"] != null && row["Userid"].ToString() != "")
         {
             model.Userid = int.Parse(row["Userid"].ToString());
         }
         if (row["MobileNum"] != null)
         {
             model.MobileNum = row["MobileNum"].ToString();
         }
         if (row["Mcontent"] != null)
         {
             model.Mcontent = row["Mcontent"].ToString();
         }
         if (row["Flag"] != null && row["Flag"].ToString() != "")
         {
             model.Flag = row["Flag"].ToString();
         }
     }
     return(model);
 }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public lgk.Model.tb_message GetModel(int MID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 MID,Userid,MobileNum,Mcontent,Flag from tb_message ");
            strSql.Append(" where MID=@MID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MID", SqlDbType.Int, 4)
            };
            parameters[0].Value = MID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(lgk.Model.tb_message model)
 {
     return(dal.Update(model));
 }
Esempio n. 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(lgk.Model.tb_message model)
 {
     return(dal.Add(model));
 }