/// <summary> /// 得到一个对象实体 /// </summary> public RuRo.Model.FP_UserFields DataRowToModel(DataRow row) { RuRo.Model.FP_UserFields model=new RuRo.Model.FP_UserFields(); if (row != null) { if(row["userFieldId"]!=null && row["userFieldId"].ToString()!="") { model.userFieldId=int.Parse(row["userFieldId"].ToString()); } if(row["id"]!=null && row["id"].ToString()!="") { model.id=int.Parse(row["id"].ToString()); } if(row["obj_id"]!=null && row["obj_id"].ToString()!="") { model.obj_id=int.Parse(row["obj_id"].ToString()); } if(row["display_name"]!=null) { model.display_name=row["display_name"].ToString(); } if(row["name"]!=null) { model.name=row["name"].ToString(); } if(row["type"]!=null) { model.type=row["type"].ToString(); } if(row["values"]!=null) { model.values=row["values"].ToString(); } if(row["show"]!=null) { model.show=row["show"].ToString(); } if(row["created_at"]!=null) { model.created_at=row["created_at"].ToString(); } if(row["updated_at"]!=null) { model.updated_at=row["updated_at"].ToString(); } if(row["inuse"]!=null) { model.inuse=row["inuse"].ToString(); } } return model; }
protected void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(!PageValidate.IsNumber(txtid.Text)) { strErr+="id格式错误!\\n"; } if(!PageValidate.IsNumber(txtobj_id.Text)) { strErr+="obj_id格式错误!\\n"; } if(this.txtdisplay_name.Text.Trim().Length==0) { strErr+="display_name不能为空!\\n"; } if(this.txtname.Text.Trim().Length==0) { strErr+="name不能为空!\\n"; } if(this.txttype.Text.Trim().Length==0) { strErr+="type不能为空!\\n"; } if(this.txtvalues.Text.Trim().Length==0) { strErr+="values不能为空!\\n"; } if(this.txtshow.Text.Trim().Length==0) { strErr+="show不能为空!\\n"; } if(this.txtcreated_at.Text.Trim().Length==0) { strErr+="created_at不能为空!\\n"; } if(this.txtupdated_at.Text.Trim().Length==0) { strErr+="updated_at不能为空!\\n"; } if(this.txtinuse.Text.Trim().Length==0) { strErr+="inuse不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int id=int.Parse(this.txtid.Text); int obj_id=int.Parse(this.txtobj_id.Text); string display_name=this.txtdisplay_name.Text; string name=this.txtname.Text; string type=this.txttype.Text; string values=this.txtvalues.Text; string show=this.txtshow.Text; string created_at=this.txtcreated_at.Text; string updated_at=this.txtupdated_at.Text; string inuse=this.txtinuse.Text; RuRo.Model.FP_UserFields model=new RuRo.Model.FP_UserFields(); model.id=id; model.obj_id=obj_id; model.display_name=display_name; model.name=name; model.type=type; model.values=values; model.show=show; model.created_at=created_at; model.updated_at=updated_at; model.inuse=inuse; RuRo.BLL.FP_UserFields bll=new RuRo.BLL.FP_UserFields(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public RuRo.Model.FP_UserFields GetModel(int userFieldId) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 userFieldId,id,obj_id,display_name,name,type,values,show,created_at,updated_at,inuse from FP_UserFields "); strSql.Append(" where userFieldId=@userFieldId"); SqlParameter[] parameters = { new SqlParameter("@userFieldId", SqlDbType.Int,4) }; parameters[0].Value = userFieldId; RuRo.Model.FP_UserFields model=new RuRo.Model.FP_UserFields(); DataSet ds=DbHelperSQL_SY.QuerySY(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }