private void ShowInfo()
 {
     NoName.NetShop.BLL.MessageModelBll bll   = new NoName.NetShop.BLL.MessageModelBll();
     NoName.NetShop.Model.MessageModel  model = bll.GetModel();
     this.txtUserId.Text     = model.UserId.ToString();
     this.txtMsgId.Text      = model.MsgId.ToString();
     this.txtMsgType.Text    = model.MsgType.ToString();
     this.txtSubject.Text    = model.Subject;
     this.txtContent.Text    = model.Content;
     this.txtSenderId.Text   = model.SenderId.ToString();
     this.txtInsertTime.Text = model.InsertTime.ToString();
     this.txtReadTime.Text   = model.ReadTime.ToString();
     this.txtStatus.Text     = model.Status.ToString();
 }
Beispiel #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public NoName.NetShop.Model.MessageModel GetModel()
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_imMessage_GetModel");

            NoName.NetShop.Model.MessageModel model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
Beispiel #3
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(NoName.NetShop.Model.MessageModel model)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("UP_imMessage_Update");

            db.AddInParameter(dbCommand, "UserId", DbType.Int32, model.UserId);
            db.AddInParameter(dbCommand, "MsgId", DbType.Int32, model.MsgId);
            db.AddInParameter(dbCommand, "MsgType", DbType.Byte, model.MsgType);
            db.AddInParameter(dbCommand, "Subject", DbType.AnsiString, model.Subject);
            db.AddInParameter(dbCommand, "Content", DbType.AnsiString, model.Content);
            db.AddInParameter(dbCommand, "SenderId", DbType.Int32, model.SenderId);
            db.AddInParameter(dbCommand, "InsertTime", DbType.DateTime, model.InsertTime);
            db.AddInParameter(dbCommand, "ReadTime", DbType.DateTime, model.ReadTime);
            db.AddInParameter(dbCommand, "Status", DbType.Int32, model.Status);
            db.ExecuteNonQuery(dbCommand);
        }
Beispiel #4
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public NoName.NetShop.Model.MessageModel ReaderBind(IDataReader dataReader)
        {
            NoName.NetShop.Model.MessageModel model = new NoName.NetShop.Model.MessageModel();
            object ojb;

            ojb = dataReader["UserId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.UserId = (int)ojb;
            }
            ojb = dataReader["MsgId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.MsgId = (int)ojb;
            }
            ojb = dataReader["MsgType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.MsgType = (int)ojb;
            }
            model.Subject = dataReader["Subject"].ToString();
            model.Content = dataReader["Content"].ToString();
            ojb           = dataReader["SenderId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.SenderId = (int)ojb;
            }
            ojb = dataReader["InsertTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.InsertTime = (DateTime)ojb;
            }
            ojb = dataReader["ReadTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ReadTime = (DateTime)ojb;
            }
            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = (int)ojb;
            }
            return(model);
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(!PageValidate.IsNumber(txtUserId.Text))
            {
            strErr+="UserId�������֣�\\n";
            }
            if(!PageValidate.IsNumber(txtMsgId.Text))
            {
            strErr+="MsgId�������֣�\\n";
            }
            if(!PageValidate.IsNumber(txtMsgType.Text))
            {
            strErr+="MsgType�������֣�\\n";
            }
            if(this.txtSubject.Text =="")
            {
            strErr+="Subject����Ϊ�գ�\\n";
            }
            if(this.txtContent.Text =="")
            {
            strErr+="Content����Ϊ�գ�\\n";
            }
            if(!PageValidate.IsNumber(txtSenderId.Text))
            {
            strErr+="SenderId�������֣�\\n";
            }
            if(!PageValidate.IsDateTime(txtInsertTime.Text))
            {
            strErr+="InsertTime����ʱ���ʽ��\\n";
            }
            if(!PageValidate.IsDateTime(txtReadTime.Text))
            {
            strErr+="ReadTime����ʱ���ʽ��\\n";
            }
            if(!PageValidate.IsNumber(txtStatus.Text))
            {
            strErr+="Status�������֣�\\n";
            }

            if(strErr!="")
            {
            MessageBox.Show(this,strErr);
            return;
            }
            int UserId=int.Parse(this.txtUserId.Text);
            int MsgId=int.Parse(this.txtMsgId.Text);
            int MsgType=int.Parse(this.txtMsgType.Text);
            string Subject=this.txtSubject.Text;
            string Content=this.txtContent.Text;
            int SenderId=int.Parse(this.txtSenderId.Text);
            DateTime InsertTime=DateTime.Parse(this.txtInsertTime.Text);
            DateTime ReadTime=DateTime.Parse(this.txtReadTime.Text);
            int Status=int.Parse(this.txtStatus.Text);

            NoName.NetShop.Model.MessageModel model=new NoName.NetShop.Model.MessageModel();
            model.UserId=UserId;
            model.MsgId=MsgId;
            model.MsgType=MsgType;
            model.Subject=Subject;
            model.Content=Content;
            model.SenderId=SenderId;
            model.InsertTime=InsertTime;
            model.ReadTime=ReadTime;
            model.Status=Status;

            NoName.NetShop.BLL.MessageModelBll bll=new NoName.NetShop.BLL.MessageModelBll();
            bll.Update(model);
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtUserId.Text))
            {
                strErr += "UserId不是数字!\\n";
            }
            if (!PageValidate.IsNumber(txtMsgId.Text))
            {
                strErr += "MsgId不是数字!\\n";
            }
            if (!PageValidate.IsNumber(txtMsgType.Text))
            {
                strErr += "MsgType不是数字!\\n";
            }
            if (this.txtSubject.Text == "")
            {
                strErr += "Subject不能为空!\\n";
            }
            if (this.txtContent.Text == "")
            {
                strErr += "Content不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtSenderId.Text))
            {
                strErr += "SenderId不是数字!\\n";
            }
            if (!PageValidate.IsDateTime(txtInsertTime.Text))
            {
                strErr += "InsertTime不是时间格式!\\n";
            }
            if (!PageValidate.IsDateTime(txtReadTime.Text))
            {
                strErr += "ReadTime不是时间格式!\\n";
            }
            if (!PageValidate.IsNumber(txtStatus.Text))
            {
                strErr += "Status不是数字!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      UserId     = int.Parse(this.txtUserId.Text);
            int      MsgId      = int.Parse(this.txtMsgId.Text);
            int      MsgType    = int.Parse(this.txtMsgType.Text);
            string   Subject    = this.txtSubject.Text;
            string   Content    = this.txtContent.Text;
            int      SenderId   = int.Parse(this.txtSenderId.Text);
            DateTime InsertTime = DateTime.Parse(this.txtInsertTime.Text);
            DateTime ReadTime   = DateTime.Parse(this.txtReadTime.Text);
            int      Status     = int.Parse(this.txtStatus.Text);


            NoName.NetShop.Model.MessageModel model = new NoName.NetShop.Model.MessageModel();
            model.UserId     = UserId;
            model.MsgId      = MsgId;
            model.MsgType    = MsgType;
            model.Subject    = Subject;
            model.Content    = Content;
            model.SenderId   = SenderId;
            model.InsertTime = InsertTime;
            model.ReadTime   = ReadTime;
            model.Status     = Status;

            NoName.NetShop.BLL.MessageModelBll bll = new NoName.NetShop.BLL.MessageModelBll();
            bll.Update(model);
        }
 /// <summary>
 /// ����ʵ�������
 /// </summary>
 public NoName.NetShop.Model.MessageModel ReaderBind(IDataReader dataReader)
 {
     NoName.NetShop.Model.MessageModel model=new NoName.NetShop.Model.MessageModel();
     object ojb;
     ojb = dataReader["UserId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.UserId=(int)ojb;
     }
     ojb = dataReader["MsgId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.MsgId=(int)ojb;
     }
     ojb = dataReader["MsgType"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.MsgType=(int)ojb;
     }
     model.Subject=dataReader["Subject"].ToString();
     model.Content=dataReader["Content"].ToString();
     ojb = dataReader["SenderId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.SenderId=(int)ojb;
     }
     ojb = dataReader["InsertTime"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.InsertTime=(DateTime)ojb;
     }
     ojb = dataReader["ReadTime"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.ReadTime=(DateTime)ojb;
     }
     ojb = dataReader["Status"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.Status=(int)ojb;
     }
     return model;
 }