protected void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(!PageValidate.IsNumber(txtrecharge_ID.Text)) { strErr+="充值ID格式错误!\\n"; } if(this.txtuser_telphone.Text.Trim().Length==0) { strErr+="用户Phone不能为空!\\n"; } if(this.txtrecharge_plat.Text.Trim().Length==0) { strErr+="充值平台不能为空!\\n"; } if(!PageValidate.IsDecimal(txtrecharge_money.Text)) { strErr+="充值金额格式错误!\\n"; } if(!PageValidate.IsDateTime(txtrecharge_time.Text)) { strErr+="充值时间格式错误!\\n"; } if(this.txtrecharge_code.Text.Trim().Length==0) { strErr+="交易编码不能为空!\\n"; } if(this.txtrecharge_comment.Text.Trim().Length==0) { strErr+="充值说明不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int recharge_ID=int.Parse(this.txtrecharge_ID.Text); string user_telphone=this.txtuser_telphone.Text; string recharge_plat=this.txtrecharge_plat.Text; decimal recharge_money=decimal.Parse(this.txtrecharge_money.Text); DateTime recharge_time=DateTime.Parse(this.txtrecharge_time.Text); string recharge_code=this.txtrecharge_code.Text; string recharge_comment=this.txtrecharge_comment.Text; la.Model.recharge model=new la.Model.recharge(); model.recharge_ID=recharge_ID; model.user_telphone=user_telphone; model.recharge_plat=recharge_plat; model.recharge_money=recharge_money; model.recharge_time=recharge_time; model.recharge_code=recharge_code; model.recharge_comment=recharge_comment; la.BLL.recharge bll=new la.BLL.recharge(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public la.Model.recharge DataRowToModel(DataRow row) { la.Model.recharge model=new la.Model.recharge(); if (row != null) { if(row["recharge_ID"]!=null && row["recharge_ID"].ToString()!="") { model.recharge_ID=int.Parse(row["recharge_ID"].ToString()); } if(row["user_telphone"]!=null) { model.user_telphone=row["user_telphone"].ToString(); } if(row["recharge_plat"]!=null) { model.recharge_plat=row["recharge_plat"].ToString(); } if(row["recharge_money"]!=null && row["recharge_money"].ToString()!="") { model.recharge_money=decimal.Parse(row["recharge_money"].ToString()); } if(row["recharge_time"]!=null && row["recharge_time"].ToString()!="") { model.recharge_time=DateTime.Parse(row["recharge_time"].ToString()); } if(row["recharge_code"]!=null) { model.recharge_code=row["recharge_code"].ToString(); } if(row["recharge_comment"]!=null) { model.recharge_comment=row["recharge_comment"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public la.Model.recharge GetModel(int recharge_ID,string user_telphone) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 recharge_ID,user_telphone,recharge_plat,recharge_money,recharge_time,recharge_code,recharge_comment from recharge "); strSql.Append(" where recharge_ID=@recharge_ID and user_telphone=@user_telphone "); SqlParameter[] parameters = { new SqlParameter("@recharge_ID", SqlDbType.Int,4), new SqlParameter("@user_telphone", SqlDbType.VarChar,20) }; parameters[0].Value = recharge_ID; parameters[1].Value = user_telphone; la.Model.recharge model=new la.Model.recharge(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }