/// <summary> /// 得到一个对象实体 /// </summary> public CMS.Model.CMS_Advertising DataRowToModel(DataRow row) { CMS.Model.CMS_Advertising model = new CMS.Model.CMS_Advertising(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["Title"] != null) { model.Title = row["Title"].ToString(); } if (row["AdType"] != null && row["AdType"].ToString() != "") { model.AdType = int.Parse(row["AdType"].ToString()); } if (row["AdRemark"] != null) { model.AdRemark = row["AdRemark"].ToString(); } if (row["AdWidth"] != null && row["AdWidth"].ToString() != "") { model.AdWidth = int.Parse(row["AdWidth"].ToString()); } if (row["AdHeight"] != null && row["AdHeight"].ToString() != "") { model.AdHeight = int.Parse(row["AdHeight"].ToString()); } } return model; }
protected void btnSave_Click(object sender, EventArgs e) { string Title = this.txtTitle.Text; int AdType = int.Parse(this.rblAdType.SelectedValue); string AdRemark = this.txtAdRemark.Text; int AdWidth = int.Parse(this.txtAdWidth.Text); int AdHeight = int.Parse(this.txtAdHeight.Text); CMS.Model.CMS_Advertising model = new CMS.Model.CMS_Advertising(); model.Title = Title; model.AdType = AdType; model.AdRemark = AdRemark; model.AdWidth = AdWidth; model.AdHeight = AdHeight; CMS.DAL.CMS_Advertising bll = new CMS.DAL.CMS_Advertising(); bll.Add(model); JscriptPrint("广告位增加成功啦!", "AdvList.aspx", "Success"); }
/// <summary> /// 得到一个对象实体 /// </summary> public CMS.Model.CMS_Advertising GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" ID,Title,AdType,AdRemark,AdWidth,AdHeight "); strSql.Append(" from CMS_Advertising "); strSql.Append(" where ID=" + ID + ""); CMS.Model.CMS_Advertising model = new CMS.Model.CMS_Advertising(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }