protected void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(!PageValidate.IsNumber(txtpersonphoto_id.Text)) { strErr+="相片ID格式错误!\\n"; } if(!PageValidate.IsNumber(txtalbum_id.Text)) { strErr+="相册_id格式错误!\\n"; } if(this.txtpersonphoto_path.Text.Trim().Length==0) { strErr+="相片路径不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int personphoto_id=int.Parse(this.txtpersonphoto_id.Text); int album_id=int.Parse(this.txtalbum_id.Text); string personphoto_path=this.txtpersonphoto_path.Text; la.Model.personphoto model=new la.Model.personphoto(); model.personphoto_id=personphoto_id; model.album_id=album_id; model.personphoto_path=personphoto_path; la.BLL.personphoto bll=new la.BLL.personphoto(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx"); }
public void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(this.txtpersonphoto_path.Text.Trim().Length==0) { strErr+="相片路径不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int personphoto_id=int.Parse(this.lblpersonphoto_id.Text); int album_id=int.Parse(this.lblalbum_id.Text); string personphoto_path=this.txtpersonphoto_path.Text; la.Model.personphoto model=new la.Model.personphoto(); model.personphoto_id=personphoto_id; model.album_id=album_id; model.personphoto_path=personphoto_path; la.BLL.personphoto bll=new la.BLL.personphoto(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public la.Model.personphoto DataRowToModel(DataRow row) { la.Model.personphoto model=new la.Model.personphoto(); if (row != null) { if(row["personphoto_id"]!=null && row["personphoto_id"].ToString()!="") { model.personphoto_id=int.Parse(row["personphoto_id"].ToString()); } if(row["album_id"]!=null && row["album_id"].ToString()!="") { model.album_id=int.Parse(row["album_id"].ToString()); } if(row["personphoto_path"]!=null) { model.personphoto_path=row["personphoto_path"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public la.Model.personphoto GetModel(int personphoto_id,int album_id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 personphoto_id,album_id,personphoto_path from personphoto "); strSql.Append(" where personphoto_id=@personphoto_id and album_id=@album_id "); SqlParameter[] parameters = { new SqlParameter("@personphoto_id", SqlDbType.Int,4), new SqlParameter("@album_id", SqlDbType.Int,4) }; parameters[0].Value = personphoto_id; parameters[1].Value = album_id; la.Model.personphoto model=new la.Model.personphoto(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }