예제 #1
0
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            long id = WS.RequestLong("id");

            using (DataEntities ent = new DataEntities())
            {
                Voodoo.Basement.Ad ad = new Voodoo.Basement.Ad();
                try
                {
                    ad = (from l in ent.Ad where l.ID == id select l).First();
                }
                catch { }

                ad.GroupID = ddl_Group.SelectedValue.ToInt32();
                ad.Title   = txt_Title.Text;
                ad.Url     = txt_Url.Text;

                var adgroup = (from l in ent.AdGroup where l.ID == ad.GroupID select l).FirstOrDefault();
                ad.width  = adgroup.width;
                ad.height = adgroup.height;

                if (ad.ID <= 0)
                {
                    ent.AddToAd(ad);
                }
                ent.SaveChanges();

                if (FileUpload1.HasFile)
                {
                    string fileName = string.Format("/u/Ad/{0}.jpg", ad.ID.ToS());
                    BasePage.UpLoadImage(FileUpload1.PostedFile, fileName, ad.width.ToInt32(), ad.height.ToInt32());
                    ad.Image = fileName;
                    ent.SaveChanges();
                }
            }

            Js.AlertAndChangUrl("保存成功!", "List.aspx");
        }
예제 #2
0
파일: Edit.aspx.cs 프로젝트: kuibono/KCMS2
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            long id = WS.RequestLong("id");
            using (DataEntities ent = new DataEntities())
            {
                Voodoo.Basement.Ad ad = new Voodoo.Basement.Ad();
                try
                {
                    ad = (from l in ent.Ad where l.ID == id select l).First();
                }
                catch { }

                ad.GroupID = ddl_Group.SelectedValue.ToInt32();
                ad.Title = txt_Title.Text;
                ad.Url = txt_Url.Text;

                var adgroup = (from l in ent.AdGroup where l.ID == ad.GroupID select l).FirstOrDefault();
                ad.width = adgroup.width;
                ad.height = adgroup.height;

                if (ad.ID <= 0)
                {
                    ent.AddToAd(ad);
                }
                ent.SaveChanges();

                if (FileUpload1.HasFile)
                {
                    string fileName = string.Format("/u/Ad/{0}.jpg", ad.ID.ToS());
                    BasePage.UpLoadImage(FileUpload1.PostedFile, fileName, ad.width.ToInt32(), ad.height.ToInt32());
                    ad.Image = fileName;
                    ent.SaveChanges();
                }

            }

            Js.AlertAndChangUrl("保存成功!", "List.aspx");
        }