protected void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(!PageValidate.IsNumber(txtLocalTagID.Text)) { strErr+="LocalTagID格式错误!\\n"; } if(this.txtTagName.Text.Trim().Length==0) { strErr+="TagName不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int LocalTagID=int.Parse(this.txtLocalTagID.Text); string TagName=this.txtTagName.Text; Maticsoft.Model.CityLocalTag model=new Maticsoft.Model.CityLocalTag(); model.LocalTagID=LocalTagID; model.TagName=TagName; Maticsoft.BLL.CityLocalTag bll=new Maticsoft.BLL.CityLocalTag(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx"); }
public void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(this.txtTagName.Text.Trim().Length==0) { strErr+="TagName不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int LocalTagID=int.Parse(this.lblLocalTagID.Text); string TagName=this.txtTagName.Text; Maticsoft.Model.CityLocalTag model=new Maticsoft.Model.CityLocalTag(); model.LocalTagID=LocalTagID; model.TagName=TagName; Maticsoft.BLL.CityLocalTag bll=new Maticsoft.BLL.CityLocalTag(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.CityLocalTag DataRowToModel(DataRow row) { Maticsoft.Model.CityLocalTag model=new Maticsoft.Model.CityLocalTag(); if (row != null) { if(row["LocalTagID"]!=null) { model.LocalTagID=row["LocalTagID"].ToString(); } if(row["TagName"]!=null) { model.TagName=row["TagName"].ToString(); } if(row["Circleid"]!=null) { model.Circleid=row["Circleid"].ToString(); } if(row["CityID"]!=null) { model.CityID=row["CityID"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.CityLocalTag GetModel(string LocalTagID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 LocalTagID,TagName,Circleid,CityID from CityLocalTag "); strSql.Append(" where LocalTagID=@LocalTagID "); SqlParameter[] parameters = { new SqlParameter("@LocalTagID", SqlDbType.NVarChar,50) }; parameters[0].Value = LocalTagID; Maticsoft.Model.CityLocalTag model=new Maticsoft.Model.CityLocalTag(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }