public void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(!PageValidate.IsNumber(txtproperty_count.Text)) { strErr+="财产数量格式错误!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int property_ID=int.Parse(this.lblproperty_ID.Text); int virtualgoods_ID=int.Parse(this.lblvirtualgoods_ID.Text); string user_telphone=this.lbluser_telphone.Text; int property_count=int.Parse(this.txtproperty_count.Text); la.Model.ownvirtualgoods model=new la.Model.ownvirtualgoods(); model.property_ID=property_ID; model.virtualgoods_ID=virtualgoods_ID; model.user_telphone=user_telphone; model.property_count=property_count; la.BLL.ownvirtualgoods bll=new la.BLL.ownvirtualgoods(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx"); }
protected void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(!PageValidate.IsNumber(txtproperty_ID.Text)) { strErr+="财产ID格式错误!\\n"; } if(!PageValidate.IsNumber(txtvirtualgoods_ID.Text)) { strErr+="虚拟物品ID格式错误!\\n"; } if(this.txtuser_telphone.Text.Trim().Length==0) { strErr+="用户Phone不能为空!\\n"; } if(!PageValidate.IsNumber(txtproperty_count.Text)) { strErr+="财产数量格式错误!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int property_ID=int.Parse(this.txtproperty_ID.Text); int virtualgoods_ID=int.Parse(this.txtvirtualgoods_ID.Text); string user_telphone=this.txtuser_telphone.Text; int property_count=int.Parse(this.txtproperty_count.Text); la.Model.ownvirtualgoods model=new la.Model.ownvirtualgoods(); model.property_ID=property_ID; model.virtualgoods_ID=virtualgoods_ID; model.user_telphone=user_telphone; model.property_count=property_count; la.BLL.ownvirtualgoods bll=new la.BLL.ownvirtualgoods(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public la.Model.ownvirtualgoods DataRowToModel(DataRow row) { la.Model.ownvirtualgoods model=new la.Model.ownvirtualgoods(); if (row != null) { if(row["property_ID"]!=null && row["property_ID"].ToString()!="") { model.property_ID=int.Parse(row["property_ID"].ToString()); } if(row["virtualgoods_ID"]!=null && row["virtualgoods_ID"].ToString()!="") { model.virtualgoods_ID=int.Parse(row["virtualgoods_ID"].ToString()); } if(row["user_telphone"]!=null) { model.user_telphone=row["user_telphone"].ToString(); } if(row["property_count"]!=null && row["property_count"].ToString()!="") { model.property_count=int.Parse(row["property_count"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public la.Model.ownvirtualgoods GetModel(int property_ID,int virtualgoods_ID,string user_telphone) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 property_ID,virtualgoods_ID,user_telphone,property_count from ownvirtualgoods "); strSql.Append(" where property_ID=@property_ID and virtualgoods_ID=@virtualgoods_ID and user_telphone=@user_telphone "); SqlParameter[] parameters = { new SqlParameter("@property_ID", SqlDbType.Int,4), new SqlParameter("@virtualgoods_ID", SqlDbType.Int,4), new SqlParameter("@user_telphone", SqlDbType.VarChar,20) }; parameters[0].Value = property_ID; parameters[1].Value = virtualgoods_ID; parameters[2].Value = user_telphone; la.Model.ownvirtualgoods model=new la.Model.ownvirtualgoods(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }