/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_Save_Click(object sender, EventArgs e) { Class cls = ClassAction.Classes.Where(p => p.ID.ToString() == ddl_Class.SelectedValue).FirstOrDefault(); DataEntities ent = new DataEntities(); int id=WS.RequestInt("id"); var images = from l in ent.ImageAlbum where l.ID == id select l; ImageAlbum imga =new ImageAlbum(); if(images.Count()>0) { imga=images.FirstOrDefault(); } imga.ClassID = ddl_Class.SelectedValue.ToInt32(); imga.Title = txt_Title.Text.TrimDbDangerousChar(); imga.AuthorID = ddl_Author.SelectedValue.ToInt32(); imga.Author = ddl_Author.SelectedItem.Text; imga.ClickCount = txt_ClickCount.Text.ToInt32(0); if (imga.ID <= 0) { imga.CreateTime = DateTime.Now; imga.Folder = DateTime.Now.ToString("yyyy-MM-dd"); } imga.Intro = txt_Intro.Text.TrimDbDangerousChar(); imga.KeyWords = txt_Keyword.Text.TrimDbDangerousChar(); imga.ReplyCount = txt_ReplyCount.Text.ToInt32(0); imga.SetTop = false; //imga.ShotCut = ""; //imga.Size = 0; imga.Title = txt_Title.Text; imga.UpdateTime = DateTime.Now; imga.ZtID = 0; if (images.Count()==0) { ent.AddToImageAlbum(imga); ent.SaveChanges(); } //保存单个图片设置 string[] t**s = WS.RequestString("tit[]").Split(','); string[] intrs = WS.RequestString("intro[]").Split(','); var imgs = //ImagesView.GetModelList(string.Format("AlbumID={0} order by id", imga.ID)); (from l in ent.Images where l.AlbumID==imga.ID select l).ToList(); for (int i = 0; i < imgs.Count; i++) { try { imgs[i].Title = t**s[i].ToS(); imgs[i].Intro = intrs[i].ToS(); } catch { } } ent.SaveChanges(); //生成页面 CreatePage.CreateContentPage(imga, cls); ImageAlbum pre = GetPreImage(imga, cls); if (pre != null) { CreatePage.CreateContentPage(pre, cls); } CreatePage.CreateListPage(cls, 1); Js.AlertAndChangUrl("保存成功!", url); }