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);
        }
Exemplo n.º 2
0
        private void BindCategoryData()
        {
            List<SolutionCategoryModel> Categories =  new SolutionCategoryBll().GetModelList("senceid = "+ScenceID);

            Literal_ScenceName.Text = new ScenceBll().GetModel(ScenceID).ScenceName;
            Literal_ScenceName1.Text = Literal_ScenceName.Text;

            //Repeater_ConfigCategory.DataSource = Categories;
            //Repeater_ConfigCategory.DataBind();
            //Repeater_Category.DataSource = Categories;
            //Repeater_Category.DataBind();
        }
        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;
            }
        }
        private string GetCategoryJson(int ScenceID)
        {
            StringBuilder result = new StringBuilder();
            StringWriter sw = new StringWriter(result);
            JsonWriter writer = new JsonWriter(sw);

            writer.Formatting = Formatting.Indented;

            List<SolutionCategoryModel> Categories = new SolutionCategoryBll().GetModelList("senceid = " + ScenceID);

            writer.WriteStartArray();

            foreach (SolutionCategoryModel model in Categories)
            {
                writer.WriteStartObject();

                WriteJsonKeyValue(writer, "categoryid", model.CateId.ToString());
                WriteJsonKeyValue(writer, "categoryname", model.Remark);

                writer.WritePropertyName("subcates");
                writer.WriteStartArray();
                DataTable subTable = new CategoryConditionBll().GetConditionSubCategory(ScenceID, model.CateId);
                if(subTable!=null)
                    foreach (DataRow row in subTable.Rows)
                    {
                        writer.WriteStartObject();

                        WriteJsonKeyValue(writer, "categoryid", row["cateid"].ToString());
                        WriteJsonKeyValue(writer, "categoryname", row["catename"].ToString());

                        writer.WriteEndObject();
                    }
                writer.WriteEndArray();

                writer.WriteEndObject();
            }

            writer.WriteEndArray();
            writer.Close();

            return result.ToString();
        }