예제 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(LingLong.Admin.Model.t_message model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_message(");
            strSql.Append("MessageType,StoreId,SendUserId,SendOpenId,AcceptUserId,AcceptOpenId,Content,SendTime,State,IsDeleted,DeleterUserId,LastModificationTime,LastModifierUserId,CreationTime,CreatorUserId)");
            strSql.Append(" values (");
            strSql.Append("@MessageType,@StoreId,@SendUserId,@SendOpenId,@AcceptUserId,@AcceptOpenId,@Content,@SendTime,@State,@IsDeleted,@DeleterUserId,@LastModificationTime,@LastModifierUserId,@CreationTime,@CreatorUserId)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@MessageType",          MySqlDbType.Int16,      4),
                new MySqlParameter("@StoreId",              MySqlDbType.Int32,     11),
                new MySqlParameter("@SendUserId",           MySqlDbType.Int32,     11),
                new MySqlParameter("@SendOpenId",           MySqlDbType.LongText),
                new MySqlParameter("@AcceptUserId",         MySqlDbType.Int32,     11),
                new MySqlParameter("@AcceptOpenId",         MySqlDbType.LongText),
                new MySqlParameter("@Content",              MySqlDbType.LongText),
                new MySqlParameter("@SendTime",             MySqlDbType.DateTime),
                new MySqlParameter("@State",                MySqlDbType.Int16,      4),
                new MySqlParameter("@IsDeleted",            MySqlDbType.Int16,      4),
                new MySqlParameter("@DeleterUserId",        MySqlDbType.Int64,     20),
                new MySqlParameter("@LastModificationTime", MySqlDbType.DateTime),
                new MySqlParameter("@LastModifierUserId",   MySqlDbType.Int64,     20),
                new MySqlParameter("@CreationTime",         MySqlDbType.DateTime),
                new MySqlParameter("@CreatorUserId",        MySqlDbType.Int64, 20)
            };
            parameters[0].Value  = model.MessageType;
            parameters[1].Value  = model.StoreId;
            parameters[2].Value  = model.SendUserId;
            parameters[3].Value  = model.SendOpenId;
            parameters[4].Value  = model.AcceptUserId;
            parameters[5].Value  = model.AcceptOpenId;
            parameters[6].Value  = model.Content;
            parameters[7].Value  = model.SendTime;
            parameters[8].Value  = model.State;
            parameters[9].Value  = model.IsDeleted;
            parameters[10].Value = model.DeleterUserId;
            parameters[11].Value = model.LastModificationTime;
            parameters[12].Value = model.LastModifierUserId;
            parameters[13].Value = model.CreationTime;
            parameters[14].Value = model.CreatorUserId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LingLong.Admin.Model.t_message GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,MessageType,StoreId,SendUserId,SendOpenId,AcceptUserId,AcceptOpenId,Content,SendTime,State,IsDeleted,DeleterUserId,LastModificationTime,LastModifierUserId,CreationTime,CreatorUserId from t_message ");
            strSql.Append(" where ID=@ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ID", MySqlDbType.Int32)
            };
            parameters[0].Value = ID;

            LingLong.Admin.Model.t_message model = new LingLong.Admin.Model.t_message();
            DataSet ds = DbHelperMySql.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 LingLong.Admin.Model.t_message DataRowToModel(DataRow row)
 {
     LingLong.Admin.Model.t_message model = new LingLong.Admin.Model.t_message();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["MessageType"] != null && row["MessageType"].ToString() != "")
         {
             model.MessageType = int.Parse(row["MessageType"].ToString());
         }
         if (row["StoreId"] != null && row["StoreId"].ToString() != "")
         {
             model.StoreId = int.Parse(row["StoreId"].ToString());
         }
         if (row["SendUserId"] != null && row["SendUserId"].ToString() != "")
         {
             model.SendUserId = int.Parse(row["SendUserId"].ToString());
         }
         if (row["SendOpenId"] != null)
         {
             model.SendOpenId = row["SendOpenId"].ToString();
         }
         if (row["AcceptUserId"] != null && row["AcceptUserId"].ToString() != "")
         {
             model.AcceptUserId = int.Parse(row["AcceptUserId"].ToString());
         }
         if (row["AcceptOpenId"] != null)
         {
             model.AcceptOpenId = row["AcceptOpenId"].ToString();
         }
         if (row["Content"] != null)
         {
             model.Content = row["Content"].ToString();
         }
         if (row["SendTime"] != null && row["SendTime"].ToString() != "")
         {
             model.SendTime = DateTime.Parse(row["SendTime"].ToString());
         }
         if (row["State"] != null && row["State"].ToString() != "")
         {
             model.State = int.Parse(row["State"].ToString());
         }
         if (row["IsDeleted"] != null && row["IsDeleted"].ToString() != "")
         {
             model.IsDeleted = int.Parse(row["IsDeleted"].ToString());
         }
         if (row["DeleterUserId"] != null && row["DeleterUserId"].ToString() != "")
         {
             model.DeleterUserId = long.Parse(row["DeleterUserId"].ToString());
         }
         if (row["LastModificationTime"] != null && row["LastModificationTime"].ToString() != "")
         {
             model.LastModificationTime = DateTime.Parse(row["LastModificationTime"].ToString());
         }
         if (row["LastModifierUserId"] != null && row["LastModifierUserId"].ToString() != "")
         {
             model.LastModifierUserId = long.Parse(row["LastModifierUserId"].ToString());
         }
         if (row["CreationTime"] != null && row["CreationTime"].ToString() != "")
         {
             model.CreationTime = DateTime.Parse(row["CreationTime"].ToString());
         }
         if (row["CreatorUserId"] != null && row["CreatorUserId"].ToString() != "")
         {
             model.CreatorUserId = long.Parse(row["CreatorUserId"].ToString());
         }
     }
     return(model);
 }
예제 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LingLong.Admin.Model.t_message model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_message set ");
            strSql.Append("MessageType=@MessageType,");
            strSql.Append("StoreId=@StoreId,");
            strSql.Append("SendUserId=@SendUserId,");
            strSql.Append("SendOpenId=@SendOpenId,");
            strSql.Append("AcceptUserId=@AcceptUserId,");
            strSql.Append("AcceptOpenId=@AcceptOpenId,");
            strSql.Append("Content=@Content,");
            strSql.Append("SendTime=@SendTime,");
            strSql.Append("State=@State,");
            strSql.Append("IsDeleted=@IsDeleted,");
            strSql.Append("DeleterUserId=@DeleterUserId,");
            strSql.Append("LastModificationTime=@LastModificationTime,");
            strSql.Append("LastModifierUserId=@LastModifierUserId,");
            strSql.Append("CreationTime=@CreationTime,");
            strSql.Append("CreatorUserId=@CreatorUserId");
            strSql.Append(" where ID=@ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@MessageType",          MySqlDbType.Int16,      4),
                new MySqlParameter("@StoreId",              MySqlDbType.Int32,     11),
                new MySqlParameter("@SendUserId",           MySqlDbType.Int32,     11),
                new MySqlParameter("@SendOpenId",           MySqlDbType.LongText),
                new MySqlParameter("@AcceptUserId",         MySqlDbType.Int32,     11),
                new MySqlParameter("@AcceptOpenId",         MySqlDbType.LongText),
                new MySqlParameter("@Content",              MySqlDbType.LongText),
                new MySqlParameter("@SendTime",             MySqlDbType.DateTime),
                new MySqlParameter("@State",                MySqlDbType.Int16,      4),
                new MySqlParameter("@IsDeleted",            MySqlDbType.Int16,      4),
                new MySqlParameter("@DeleterUserId",        MySqlDbType.Int64,     20),
                new MySqlParameter("@LastModificationTime", MySqlDbType.DateTime),
                new MySqlParameter("@LastModifierUserId",   MySqlDbType.Int64,     20),
                new MySqlParameter("@CreationTime",         MySqlDbType.DateTime),
                new MySqlParameter("@CreatorUserId",        MySqlDbType.Int64,     20),
                new MySqlParameter("@ID",                   MySqlDbType.Int32, 11)
            };
            parameters[0].Value  = model.MessageType;
            parameters[1].Value  = model.StoreId;
            parameters[2].Value  = model.SendUserId;
            parameters[3].Value  = model.SendOpenId;
            parameters[4].Value  = model.AcceptUserId;
            parameters[5].Value  = model.AcceptOpenId;
            parameters[6].Value  = model.Content;
            parameters[7].Value  = model.SendTime;
            parameters[8].Value  = model.State;
            parameters[9].Value  = model.IsDeleted;
            parameters[10].Value = model.DeleterUserId;
            parameters[11].Value = model.LastModificationTime;
            parameters[12].Value = model.LastModifierUserId;
            parameters[13].Value = model.CreationTime;
            parameters[14].Value = model.CreatorUserId;
            parameters[15].Value = model.ID;

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

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