/// <summary> /// 得到一个对象实体 /// </summary> public la.Model.travleapply DataRowToModel(DataRow row) { la.Model.travleapply model=new la.Model.travleapply(); if (row != null) { if(row["travleapply_ID"]!=null && row["travleapply_ID"].ToString()!="") { model.travleapply_ID=int.Parse(row["travleapply_ID"].ToString()); } if(row["travle_ID"]!=null && row["travle_ID"].ToString()!="") { model.travle_ID=int.Parse(row["travle_ID"].ToString()); } if(row["applyer_ID"]!=null && row["applyer_ID"].ToString()!="") { model.applyer_ID=int.Parse(row["applyer_ID"].ToString()); } if(row["apply_time"]!=null && row["apply_time"].ToString()!="") { model.apply_time=DateTime.Parse(row["apply_time"].ToString()); } if(row["apply_state"]!=null) { model.apply_state=row["apply_state"].ToString(); } if(row["apply_msg"]!=null) { model.apply_msg=row["apply_msg"].ToString(); } } return model; }
protected void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(!PageValidate.IsNumber(txttravleapply_ID.Text)) { strErr+="申请ID格式错误!\\n"; } if(!PageValidate.IsNumber(txttravle_ID.Text)) { strErr+="旅行ID格式错误!\\n"; } if(!PageValidate.IsNumber(txtapplyer_ID.Text)) { strErr+="申请人ID格式错误!\\n"; } if(!PageValidate.IsDateTime(txtapply_time.Text)) { strErr+="申请时间格式错误!\\n"; } if(this.txtapply_state.Text.Trim().Length==0) { strErr+="匹配状态不能为空!\\n"; } if(this.txtapply_msg.Text.Trim().Length==0) { strErr+="申请留言不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int travleapply_ID=int.Parse(this.txttravleapply_ID.Text); int travle_ID=int.Parse(this.txttravle_ID.Text); int applyer_ID=int.Parse(this.txtapplyer_ID.Text); DateTime apply_time=DateTime.Parse(this.txtapply_time.Text); string apply_state=this.txtapply_state.Text; string apply_msg=this.txtapply_msg.Text; la.Model.travleapply model=new la.Model.travleapply(); model.travleapply_ID=travleapply_ID; model.travle_ID=travle_ID; model.applyer_ID=applyer_ID; model.apply_time=apply_time; model.apply_state=apply_state; model.apply_msg=apply_msg; la.BLL.travleapply bll=new la.BLL.travleapply(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public la.Model.travleapply GetModel(int travleapply_ID,int travle_ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 travleapply_ID,travle_ID,applyer_ID,apply_time,apply_state,apply_msg from travleapply "); strSql.Append(" where travleapply_ID=@travleapply_ID and travle_ID=@travle_ID "); SqlParameter[] parameters = { new SqlParameter("@travleapply_ID", SqlDbType.Int,4), new SqlParameter("@travle_ID", SqlDbType.Int,4) }; parameters[0].Value = travleapply_ID; parameters[1].Value = travle_ID; la.Model.travleapply model=new la.Model.travleapply(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }