예제 #1
0
    private void AddFunc()
    {
        AboutList pl = new AboutList();

        pl.title      = txt_title.Text;
        pl.img        = txt_img.Text;
        pl.mainstyle  = txt_mainstyle.Text;
        pl.memo       = txt_memo.Text;
        pl.pagetype   = ddl_pagetype.SelectedValue;
        pl.titlestyle = txt_titlestyle.Text;


        string           jpath = @"\json\about.json";
        List <AboutList> pll   = GetJsonToObject <List <AboutList> >(jpath);

        pl.id = pll.Count + 1;
        pll.Add(pl);
        //保存修改
        string s1 = JsonSerializer <List <AboutList> >(pll);

        Write(CurrentPath + "\\" + jpath, s1);

        Product product = new Product();

        product.id = pll.Count;
        string jpath2 = @"\json\abouts\about" + product.id + ".json";

        product.date    = DateTime.Now.ToLongDateString();
        product.content = txt_content.Text;
        string s2 = JsonSerializer <List <Product> >(new List <Product>()
        {
            product
        });

        Write(CurrentPath + "\\" + jpath2, s2);
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>successCallback('添加成功!');</script>");
        // Alert("添加成功!");
    }
예제 #2
0
    private void AddFunc()
    {
        AboutList pl = new AboutList();
        pl.title = txt_title.Text;
        pl.img = txt_img.Text;
        pl.mainstyle = txt_mainstyle.Text;
        pl.memo = txt_memo.Text;
        pl.pagetype = ddl_pagetype.SelectedValue;
        pl.titlestyle = txt_titlestyle.Text;

        string jpath = @"\json\about.json";
        List<AboutList> pll = GetJsonToObject<List<AboutList>>(jpath);
        pl.id = pll.Count + 1;
        pll.Add(pl);
        //保存修改
        string s1 = JsonSerializer<List<AboutList>>(pll);
        Write(CurrentPath + "\\" + jpath, s1);

        Product product = new Product();
        product.id = pll.Count;
        string jpath2 = @"\json\abouts\about" + product.id + ".json";
        product.date = DateTime.Now.ToLongDateString();
        product.content = txt_content.Text;
        string s2 = JsonSerializer<List<Product>>(new List<Product>() { product });
        Write(CurrentPath + "\\" + jpath2, s2);
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>successCallback('添加成功!');</script>");
           // Alert("添加成功!");
    }