コード例 #1
0
ファイル: VarTemplateEdit.aspx.cs プロジェクト: kuibono/KCMS2
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();
            int id = WS.RequestInt("id");
            TemplateVar tl = new TemplateVar();
            try
            {
                tl = (from l in ent.TemplateVar where l.ID == id select l).First();
            }
            catch { }

            tl.VarName = txt_VarName.Text;
            tl.Content = txt_Content.Text.Replace("'", "''");

            if (tl.ID==null||tl.ID <= 0)
            {
                ent.AddToTemplateVar(tl);
            }
            ent.SaveChanges();

            var pages = (from l in ent.TemplatePage where l.CreateWith == 5 select l).ToList();
            TemplateHelper th = new TemplateHelper();
            foreach (var p in pages)
            {
                try
                {
                    string html = th.GetStatisPage(p.id);
                    Voodoo.IO.File.Write(Server.MapPath(p.FileName), html);
                }
                catch { }
            }

            ent.Dispose();
            Js.AlertAndChangUrl("保存成功!", "VarTemplateList.aspx");
        }