protected void btnSave_Click(object sender, EventArgs e) { CMS.Model.CMS_ProductClass model = new CMS.Model.CMS_ProductClass(); string classList = ""; int PID = int.Parse(this.hdfPid.Value); model.CMS_ClassName = this.txtCMS_ClassName.Text.Trim(); model.CMS_Memo = this.txtCMS_Memo.Text.Trim(); model.CMS_PID = PID; model.SortId = Int32.Parse(this.txtShort.Text.Trim()); model.CMS_ClassLayer = Int32.Parse(this.hdfClassLayer.Value); int id = dal.Add(model); if (PID > 0) { DataSet ds = dal.GetList(" id = "+PID+""); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; classList = dr["CMS_ClassIdList"].ToString().Trim() + id + ","; } } else { classList = "," + id + ","; } model.ID = id; model.CMS_ClassIdList = classList; dal.Update(model); string js = "window.location.href('ProductsTypeList.aspx');"; this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "js", "<script>alert('修改成功!');"+js+"</script>"); }
/// <summary> /// 得到一个对象实体 /// </summary> public CMS.Model.CMS_ProductClass GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" ID,CMS_ClassName,CMS_Memo,CMS_PID,CMS_ClassLayer,CMS_ClassIdList,SortId "); strSql.Append(" from CMS_ProductClass "); strSql.Append(" where ID=" + ID + " "); CMS.Model.CMS_ProductClass model = new CMS.Model.CMS_ProductClass(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } model.CMS_ClassName = ds.Tables[0].Rows[0]["CMS_ClassName"].ToString(); model.CMS_Memo = ds.Tables[0].Rows[0]["CMS_Memo"].ToString(); if (ds.Tables[0].Rows[0]["CMS_PID"].ToString() != "") { model.CMS_PID = int.Parse(ds.Tables[0].Rows[0]["CMS_PID"].ToString()); } if (ds.Tables[0].Rows[0]["CMS_ClassLayer"].ToString() != "") { model.CMS_ClassLayer = int.Parse(ds.Tables[0].Rows[0]["CMS_ClassLayer"].ToString()); } model.CMS_ClassIdList = ds.Tables[0].Rows[0]["CMS_ClassIdList"].ToString(); if (ds.Tables[0].Rows[0]["SortId"].ToString() != "") { model.SortId = int.Parse(ds.Tables[0].Rows[0]["SortId"].ToString()); } return model; } else { return null; } }