Beispiel #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ShowShop.Model.Member.MailReceiver GetModelByID(int id)
 {
     ShowShop.Model.Member.MailReceiver model = new ShowShop.Model.Member.MailReceiver();
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select  top 1 [id],[receiverid],[receiver],[receiveTime],[stat],[isread],[title],[body],[sender] from yxs_mailreceiver ");
     strSql.Append(" where [id]=@id ");
     SqlParameter[] parameters = (SqlParameter[])this.ValueIDPara(id);
     using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString(), parameters))
     {
         if (reader.Read())
         {
             model.ID = reader.GetInt32(0);
             model.ReceiverId = reader.GetInt32(1);
             model.Receiver = reader.GetString(2);
             model.ReceiveTime = reader.GetDateTime(3);
             model.Stat = reader.GetInt32(4);
             model.IsRead = reader.GetInt32(5);
             model.Title = reader.GetString(6);
             model.Body = reader.GetString(7);
             model.Sender = reader.GetString(8);
         }
     }
     return model;
 }
 /// <summary>
 /// 发送短消息
 /// </summary>
 /// <param name="uid">用户自增ID</param>
 /// <param name="userid">用户账号</param>
 /// <param name="title">短消息标题</param>
 /// <param name="content">短消息内容</param>
 /// <param name="sender">发送人(管理员账号)</param>
 protected void SendMessage(int uid, string userid, string title, string content, string sender)
 {
     ShowShop.BLL.Member.MailReceiver ReceBll = new ShowShop.BLL.Member.MailReceiver();
     ShowShop.Model.Member.MailReceiver ReceModel = new ShowShop.Model.Member.MailReceiver();
     ShowShop.BLL.Member.MemberAccount bll = new ShowShop.BLL.Member.MemberAccount();
     if (!bll.Exists(userid))
     {
         this.ltlMsg.Text = "不存在用户:" + userid;
         this.pnlMsg.Visible = true;
         this.pnlMsg.CssClass = "actionErr";
         return;
     }
     ReceModel.ReceiverId = uid;
     ReceModel.Receiver = userid;
     ReceModel.ReceiveTime = DateTime.Now;
     ReceModel.Stat = 0;
     ReceModel.IsRead = 0;
     ReceModel.Title = title;
     ReceModel.Body = content;
     ReceModel.Sender = sender;
     ReceBll.Add(ReceModel);
 }
Beispiel #3
0
 /// <summary>
 /// 得到指定条件的所有短消息
 /// </summary>
 /// <param name="uid"></param>
 /// <returns></returns>
 public List<ShowShop.Model.Member.MailReceiver> GetAll(string strWhere)
 {
     List<ShowShop.Model.Member.MailReceiver> list = new List<ShowShop.Model.Member.MailReceiver>();
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select [id],[receiverid],[receiver],[receiveTime],[stat],[isread],[title],[body],[sender] from yxs_mailreceiver ");
     if (strWhere != null && strWhere != "")
     {
         strSql.Append("where " + strWhere + " ");
     }
     using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString()))
     {
         while (reader.Read())
         {
             ShowShop.Model.Member.MailReceiver model = new ShowShop.Model.Member.MailReceiver();
             model.ID = reader.GetInt32(0);
             model.ReceiverId = reader.GetInt32(1);
             model.Receiver = reader.GetString(2);
             model.ReceiveTime = reader.GetDateTime(3);
             model.Stat = reader.GetInt32(4);
             model.IsRead = reader.GetInt32(5);
             model.Title = reader.GetString(6);
             model.Body = reader.GetString(7);
             model.Sender = reader.GetString(8);
             list.Add(model);
         }
     }
     return list;
 }