Ejemplo n.º 1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(!PageValidate.IsNumber(txtsender_id.Text))
            {
                strErr+="送礼人格式错误!\\n";
            }
            if(!PageValidate.IsNumber(txtaccepter_id.Text))
            {
                strErr+="接受人格式错误!\\n";
            }
            if(!PageValidate.IsDateTime(txtsend_time.Text))
            {
                strErr+="送礼时间格式错误!\\n";
            }
            if(this.txtsendgift_comment.Text.Trim().Length==0)
            {
                strErr+="送礼说明不能为空!\\n";
            }
            if(this.txtsendgift_msg.Text.Trim().Length==0)
            {
                strErr+="送礼留言不能为空!\\n";
            }
            if(!PageValidate.IsNumber(txtsendgift_count.Text))
            {
                strErr+="送礼数量格式错误!\\n";
            }

            if(strErr!="")
            {
                MessageBox.Show(this,strErr);
                return;
            }
            int sendgift_ID=int.Parse(this.lblsendgift_ID.Text);
            int virtualgoods_ID=int.Parse(this.lblvirtualgoods_ID.Text);
            int sender_id=int.Parse(this.txtsender_id.Text);
            int accepter_id=int.Parse(this.txtaccepter_id.Text);
            DateTime send_time=DateTime.Parse(this.txtsend_time.Text);
            string sendgift_comment=this.txtsendgift_comment.Text;
            string sendgift_msg=this.txtsendgift_msg.Text;
            int sendgift_count=int.Parse(this.txtsendgift_count.Text);

            la.Model.sendgift model=new la.Model.sendgift();
            model.sendgift_ID=sendgift_ID;
            model.virtualgoods_ID=virtualgoods_ID;
            model.sender_id=sender_id;
            model.accepter_id=accepter_id;
            model.send_time=send_time;
            model.sendgift_comment=sendgift_comment;
            model.sendgift_msg=sendgift_msg;
            model.sendgift_count=sendgift_count;

            la.BLL.sendgift bll=new la.BLL.sendgift();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx");
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public la.Model.sendgift DataRowToModel(DataRow row)
 {
     la.Model.sendgift model=new la.Model.sendgift();
     if (row != null)
     {
         if(row["sendgift_ID"]!=null && row["sendgift_ID"].ToString()!="")
         {
             model.sendgift_ID=int.Parse(row["sendgift_ID"].ToString());
         }
         if(row["virtualgoods_ID"]!=null && row["virtualgoods_ID"].ToString()!="")
         {
             model.virtualgoods_ID=int.Parse(row["virtualgoods_ID"].ToString());
         }
         if(row["sender_id"]!=null && row["sender_id"].ToString()!="")
         {
             model.sender_id=int.Parse(row["sender_id"].ToString());
         }
         if(row["accepter_id"]!=null && row["accepter_id"].ToString()!="")
         {
             model.accepter_id=int.Parse(row["accepter_id"].ToString());
         }
         if(row["send_time"]!=null && row["send_time"].ToString()!="")
         {
             model.send_time=DateTime.Parse(row["send_time"].ToString());
         }
         if(row["sendgift_comment"]!=null)
         {
             model.sendgift_comment=row["sendgift_comment"].ToString();
         }
         if(row["sendgift_msg"]!=null)
         {
             model.sendgift_msg=row["sendgift_msg"].ToString();
         }
         if(row["sendgift_count"]!=null && row["sendgift_count"].ToString()!="")
         {
             model.sendgift_count=int.Parse(row["sendgift_count"].ToString());
         }
     }
     return model;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public la.Model.sendgift GetModel(int sendgift_ID,int virtualgoods_ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 sendgift_ID,virtualgoods_ID,sender_id,accepter_id,send_time,sendgift_comment,sendgift_msg,sendgift_count from sendgift ");
            strSql.Append(" where sendgift_ID=@sendgift_ID and virtualgoods_ID=@virtualgoods_ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@sendgift_ID", SqlDbType.Int,4),
                    new SqlParameter("@virtualgoods_ID", SqlDbType.Int,4)			};
            parameters[0].Value = sendgift_ID;
            parameters[1].Value = virtualgoods_ID;

            la.Model.sendgift model=new la.Model.sendgift();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }