/// <summary> /// 对象实体绑定数据 /// </summary> public SolutionCategoryModel ReaderBind(IDataReader dataReader) { SolutionCategoryModel model = new SolutionCategoryModel(); object ojb; ojb = dataReader["SenceId"]; if (ojb != null && ojb != DBNull.Value) { model.SenceId = (int)ojb; } ojb = dataReader["CateId"]; if (ojb != null && ojb != DBNull.Value) { model.CateId = (int)ojb; } model.CateImage = dataReader["CateImage"].ToString(); model.Remark = dataReader["Remark"].ToString(); model.Position = dataReader["Position"].ToString(); model.CateName = dataReader["catename"].ToString(); ojb = dataReader["IsShow"]; if (ojb != null && ojb != DBNull.Value) { model.IsShow = (bool)ojb; } return(model); }
protected void btnUpdate_Click(object sender, EventArgs e) { SolutionCategoryBll scbll = new SolutionCategoryBll(); int scenceId = int.Parse(lblSenceId.Text); int cateId = int.Parse(lblCateId.Text); SolutionCategoryModel scmodel = scbll.GetModel(scenceId, cateId); if (scmodel == null) { scmodel = new SolutionCategoryModel(); scmodel.CateId = cateId; scmodel.SenceId = scenceId; } scmodel.IsShow = chkIsShow.Checked; scmodel.Remark = txtRemark.Text.Trim(); scmodel.Position = txtPosition.Text.Trim(); string fullurl, shorturl, message; if (CommonImageUpload.Upload(this.fulImage, out fullurl, out shorturl, out message)) { scmodel.CateImage = shorturl; } scbll.Save(scmodel); SaveCateConditions(); Response.Redirect("ShowClassicalScence.aspx?id=" + scenceId, true); }
/// <summary> /// 增加一条数据 /// </summary> public void Save(SolutionCategoryModel model) { DbCommand dbCommand = dbw.GetStoredProcCommand("UP_slCategory_Save"); dbw.AddInParameter(dbCommand, "SenceId", DbType.Int32, model.SenceId); dbw.AddInParameter(dbCommand, "CateId", DbType.Int32, model.CateId); dbw.AddInParameter(dbCommand, "CateImage", DbType.AnsiString, model.CateImage); dbw.AddInParameter(dbCommand, "Remark", DbType.AnsiString, model.Remark); dbw.AddInParameter(dbCommand, "Position", DbType.AnsiString, model.Position); dbw.AddInParameter(dbCommand, "IsShow", DbType.Boolean, model.IsShow); dbw.ExecuteNonQuery(dbCommand); }
/// <summary> /// 得到一个对象实体 /// </summary> public SolutionCategoryModel GetModel(int SenceId, int CateId) { DbCommand dbCommand = dbr.GetStoredProcCommand("UP_slCategory_GetModel"); dbr.AddInParameter(dbCommand, "SenceId", DbType.Int32, SenceId); dbr.AddInParameter(dbCommand, "CateId", DbType.Int32, CateId); SolutionCategoryModel model = null; using (IDataReader dataReader = dbr.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
private void ShowInfo(int scenceId, int cateId) { SolutionCategoryBll scbll = new SolutionCategoryBll(); SolutionCategoryModel scmodel = scbll.GetModel(scenceId, cateId); CategoryModelBll cbll = new CategoryModelBll(); CategoryModel cmodel = cbll.GetModel(cateId); if (cmodel == null) { throw new NoName.NetShop.Common.ShopException("分类不存在", true); } InitConditionItems(cateId); if (scmodel != null) { lblCateId.Text = scmodel.CateId.ToString(); lblSenceId.Text = scmodel.SenceId.ToString(); chkIsShow.Checked = scmodel.IsShow; txtRemark.Text = scmodel.Remark; txtPosition.Text = scmodel.Position; if (!String.IsNullOrEmpty(scmodel.CateImage)) { this.imgCate.Visible = true; this.imgCate.ImageUrl = Common.CommonImageUpload.GetCommonImageFullUrl(scmodel.CateImage); } else { this.imgCate.Visible = false; } PresetConditionItems(scenceId, cateId); } else { lblCateId.Text = cmodel.CateId.ToString(); lblSenceId.Text = scenceId.ToString(); txtRemark.Text = cmodel.CateName; } }
/// <summary> /// 增加一条数据 /// </summary> public void Save(SolutionCategoryModel model) { dal.Save(model); }