当前位置: 首页>>代码示例>>C#>>正文


C# DataEntities.SaveChanges方法代码示例

本文整理汇总了C#中Voodoo.Basement.DataEntities.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# DataEntities.SaveChanges方法的具体用法?C# DataEntities.SaveChanges怎么用?C# DataEntities.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Voodoo.Basement.DataEntities的用法示例。


在下文中一共展示了DataEntities.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btn_Save_Click

        protected void btn_Save_Click(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();

            var chapters = (from l in ent.BookChapter where l.ID == id select l).ToList();

            var chapter = new Voodoo.Basement.BookChapter();
            if (chapters.Count > 0)
            {
                chapter = chapters.FirstOrDefault();
            }
            chapter.Title = txt_Title.Text;
            chapter.IsVipChapter = chk_IsVip.Checked;
            chapter.Enable = chk_IsEnable.Checked;
            chapter.IsTemp = chk_IsTemp.Checked;
            chapter.IsFree = chk_IsFree.Checked;
            chapter.IsImageChapter = chk_IsImageChapter.Checked;
            if (chapters.Count== 0)
            {
                Voodoo.Basement.Book book = (from l in ent.Book where l.ID == bookid select l).FirstOrDefault();
                chapter.BookID = book.ID;
                chapter.BookTitle = book.Title;
                chapter.ClassID = book.ClassID;
                chapter.ClassName = book.ClassName;
                chapter.UpdateTime = DateTime.UtcNow.AddHours(8);

                ent.AddToBookChapter(chapter);
                ent.SaveChanges();

                book.LastChapterID = chapter.ID;
                book.LastChapterTitle = chapter.Title;
                book.UpdateTime = chapter.UpdateTime;
                if (SystemSetting.EnableStatic)
                {
                    CreatePage.CreateContentPage(book, book.GetClass());
                }
            }

            if (chapter.TxtPath.IsNullOrEmpty())
            {
                chapter.TxtPath = BasePage.GetChapterTxtStorePath(chapter, chapter.GetBook());
            }

            ent.SaveChanges();
            ent.Dispose();

            Voodoo.IO.File.Write(
                Server.MapPath(chapter.TxtPath),
                txt_Content.Text);
            //生成章节页面
            if (SystemSetting.EnableStatic)
            {
                CreatePage.CreateBookChapterPage(chapter, chapter.GetBook(), chapter.GetClass());
            }

            Response.Redirect(string.Format("ChapterList.aspx?bookid={0}",chapter.BookID));
        }
开发者ID:svn2github,项目名称:KCMS2,代码行数:57,代码来源:ChapterEdit.aspx.cs

示例2: btn_Save_Click

        protected void btn_Save_Click(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();
            var books = (from l in ent.Book where l.ID == id select l).ToList();

            Voodoo.Basement.Book book = new Voodoo.Basement.Book();
            if (books.Count > 0)
            {
                book = books.FirstOrDefault();
            }
            book.Title = txt_Title.Text;
            book.Author = txt_Author.Text;
            book.ClassID = ddl_CLass.SelectedValue.ToInt32();
            book.ClassName = ddl_CLass.SelectedItem.Text;
            book.ClickCount = txt_ClickCount.Text.ToInt32();
            book.CorpusID = 0;
            book.CorpusTitle = "";
            book.Enable = chk_Enable.Checked;
            //book.FaceImage=
            book.Intro = txt_Intro.Text;
            book.IsFirstPost = chk_IsFirstpost.Checked;
            book.IsVip = chk_IsVip.Checked;
            book.Length = txt_Length.Text.ToInt32();
            book.ReplyCount = txt_Replycount.Text.ToInt32();
            book.SaveCount = txt_SaveCount.Text.ToInt32();
            book.Status = ddl_Status.SelectedValue.ToByte();
            book.TjCount = txt_TjCount.Text.ToInt32();
            book.ZtID = 0;
            book.ZtName = "";

            if (books.Count == 0)
            {
                book.Addtime = DateTime.UtcNow.AddHours(8);
                book.UpdateTime = DateTime.UtcNow.AddHours(8);
                book.VipUpdateTime = DateTime.UtcNow.AddHours(8);
                ent.AddToBook(book);
                ent.SaveChanges();
            }

            //Deal Book face image
            if (file_Bookfacefile.FileName.IsNullOrEmpty() == false)
            {
                file_Bookfacefile.SaveAs(Server.MapPath("/Book/BookFace/" + book.ID + ".jpg"));
                book.FaceImage = "/Book/BookFace/" + book.ID + ".jpg";
                ent.SaveChanges();
            }

            CreatePage.CreateContentPage(book, book.GetClass());
            Response.Redirect("BookList.aspx?class=" + cls.ToS());
        }
开发者ID:kuibono,项目名称:KCMS2,代码行数:50,代码来源:BookEdit.aspx.cs

示例3: btn_Save_Click

        protected void btn_Save_Click(object sender, EventArgs e)
        {
            int id = WS.RequestInt("id");
            DataEntities ent = new DataEntities();
            TemplateList tl ;
            try
            {
                tl = (from l in ent.TemplateList where l.ID == id select l).First();
            }
            catch
            {
                tl = new TemplateList();
            }

            tl.TempName = txt_TempName.Text;
            tl.CutKeywords = txt_CutKeywords.Text.ToInt32();
            tl.CutTitle = txt_CutTitle.Text.ToInt32();
            tl.ShowRecordCount = txt_ShowRecordCount.Text.ToInt32();
            tl.TimeFormat = txt_TimeFormat.Text;
            tl.Content = txt_Content.Text.Replace("'", "''"); ;
            tl.ListVar = txt_Listvar.Text.Replace("'", "''"); ;
            tl.SysModel = ddl_SysModel.SelectedValue.ToInt32();
            if (tl.ID <= 0)
            {
                tl.GroupID = 1;
                tl.SysModel = 1;
                ent.AddToTemplateList(tl);
            }
            ent.SaveChanges();
            ent.Dispose();
            Js.AlertAndGoback("保存成功!");
        }
开发者ID:kuibono,项目名称:KCMS2,代码行数:32,代码来源:ListTemplateEdit.aspx.cs

示例4: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            string ClassName=WS.RequestString("class");
            int Model=WS.RequestInt("m",4);
            if (ClassName.Length == 0)
            {
                return;
            }

            Class cls = ClassAction.Classes.Where(p => p.ClassName == ClassName && p.ModelID == Model).FirstOrDefault();
            if (cls.ID <= 0)
            {
                //cls.ClassForder = PinyinHelper.GetPinyin(ClassName);
                cls.ClassForder = ClassName;
                cls.ClassKeywords = ClassName;
                cls.ClassName = ClassName;
                cls.ModelID = Model;
                cls.IsLeafClass = true;
                cls.ModelID = Model;
                cls.ShowInNav = true;
                using (DataEntities ent = new DataEntities())
                {
                    ent.AddToClass(cls);
                    ent.SaveChanges();
                    Voodoo.Cache.Cache.Clear("_NewClassList");
                }
            }
            Response.Clear();
            Response.Write(Voodoo.IO.XML.Serialize(cls));
        }
开发者ID:kuibono,项目名称:KCMS2,代码行数:30,代码来源:getClass.aspx.cs

示例5: btn_tree_new_Click

        protected void btn_tree_new_Click(object sender, EventArgs e)
        {
            int pnID = PanelTree.SelectedNode.Value.ToInt32(0);
            int parentID = 0;
            try
            {
                parentID=SubTree.SelectedNode.Value.ToInt32(0);
            }
            catch
            {

            }

            SysNavTree tree = new SysNavTree();
            tree.Group = cbl_tree_group.GetValues();
            tree.Icon = ddl_tree_icon.SelectedValue;
            tree.InnerHtml = txt_tree_html.Text;
            tree.OrderIndex = txt_tree_orderindex.Text.ToInt32();
            tree.PanelID = pnID;
            tree.ParentID = parentID;
            tree.Title = txt_tree_title.Text;
            tree.Url = txt_tree_url.Text;
            DataEntities ent = new DataEntities();
            ent.AddToSysNavTree(tree);
            ent.SaveChanges();
            ent.Dispose();
            Js.AlertAndChangUrl("新增成功", "SysmenuManagement.aspx");
        }
开发者ID:svn2github,项目名称:KCMS2,代码行数:28,代码来源:SysmenuManagement.aspx.cs

示例6: SaveMessage

        public Result SaveMessage()
        {
            Message msg = new Message();
            msg.Chat = WS.RequestString("chat");
            msg.Content = WS.RequestString("content");
            msg.Email = WS.RequestString("email");
            msg.MessageTime = DateTime.Now;
            msg.Tel = WS.RequestString("tel");
            msg.Title = WS.RequestString("title");
            msg.UserName = WS.RequestString("username");

            if (msg.Content.IsNullOrEmpty())
            {
                return new Result {  Success=true };
            }

            try
            {
                DataEntities ent = new DataEntities();
                ent.AddToMessage(msg);
                ent.SaveChanges();
                return new Result { Success = true };
            }
            catch
            {
                return new Result { Success = false };
            }
        }
开发者ID:kuibono,项目名称:KCMS2,代码行数:28,代码来源:MessageService.asmx.cs

示例7: btn_Save_Click

        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");
        }
开发者ID:kuibono,项目名称:KCMS2,代码行数:35,代码来源:VarTemplateEdit.aspx.cs

示例8: btn_Save_Click

        protected void btn_Save_Click(object sender, EventArgs e)
        {
            int id = WS.RequestInt("id");
            DataEntities ent = new DataEntities();

            Voodoo.Basement.AdGroup q = new Voodoo.Basement.AdGroup();
            if (id > 0)
            {
                q = (from l in ent.AdGroup where l.ID == id select l).FirstOrDefault();
            }
            q.Name = txt_Name.Text;
            q.height = txt_Height.Text.ToInt32();
            q.width = txt_Width.Text.ToInt32();

            if (id > 0 && q != null)
            {

            }
            else
            {
                //com.UserID = userid;
                ent.AddToAdGroup(q);
            }
            ent.SaveChanges();
            ent.Dispose();
            Js.AlertAndChangUrl("保存成功!", "List.aspx");
        }
开发者ID:kuibono,项目名称:KCMS2,代码行数:27,代码来源:Edit.aspx.cs

示例9: Btn_Save_Click

 protected void Btn_Save_Click(object sender, EventArgs e)
 {
     DataEntities ent = new DataEntities();
     int id = 0;
     try
     {
         id = Spe_Tree.SelectedNode.Value.ToInt32(0);
     }
     catch
     {
     }
     if (chk_Edit.Checked)
     {
         var q = (from l in ent.JobIndustry where l.ID == id select l).FirstOrDefault();
         q.Name = txt_Name.Text;
     }
     else
     {
         JobIndustry spe = new JobIndustry();
         spe.ParentID = id;
         spe.Name = txt_Name.Text;
         ent.AddToJobIndustry(spe);
     }
     ent.SaveChanges();
     ent.Dispose();
     Spe_Tree.Nodes.Clear();
     LoadTree();
 }
开发者ID:kuibono,项目名称:KCMS2,代码行数:28,代码来源:JobIndustryManagement.aspx.cs

示例10: btn_Save_Click

        protected void btn_Save_Click(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();
            int id = WS.RequestInt("id");
            UserGroup g = (from l in ent.UserGroup where l.ID == id select l).FirstOrDefault();
            if (g == null)
            {
                g = new UserGroup();
            }

            g.GroupName = txt_GroupName.Text;
            g.Grade = txt_grade.Text.ToInt32();
            g.MaxPost = txt_MaxPost.Text.ToInt32();
            g.PostAotuAudit = chk_PostAotuAudit.Checked;
            g.EnableReg = chk_EnableReg.Checked;
            g.RegAutoAudit = chk_RegAutoAudit.Checked;
            g.RegForm = ddl_RegForm.SelectedValue.ToInt32();

            if (g.ID <= 0)
            {
                ent.AddToUserGroup(g);
            }
            ent.SaveChanges();
            ent.Dispose();
            Js.AlertAndChangUrl("保存成功!", "GroupList.aspx");
        }
开发者ID:svn2github,项目名称:KCMS2,代码行数:26,代码来源:GroupEdit.aspx.cs

示例11: btn_Save_Click

        protected void btn_Save_Click(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();

            int id = WS.RequestInt("id");
            JobPost p = new JobPost();
            if (id > 0)
            {
                p = (from l in ent.JobPost where l.ID == id select l).FirstOrDefault();
            }

            p.CompanyID = ddl_Company.SelectedValue.ToInt32();
            p.Title = txt_Title.Text;
            p.Province = ddl_Province.SelectedValue.ToInt32();
            p.City = ddl_City.SelectedValue.ToInt32();
            p.Salary = ddl_Salary.SelectedValue.ToInt32();
            p.Expressions = ddl_Expressions.SelectedValue.ToInt32();
            p.Edu = ddl_Edu.SelectedValue.ToInt32();
            p.EmployNumber = txt_EmployNumber.Text.ToInt32();
            p.Intro = txt_Intro.Text;
            p.PostTime = DateTime.Now;
            p.IsSetTop = chk_Settop.Checked;
            p.SetTopTime = DateTime.Now;
            p.ExpireTime = txt_ExpireTime.Text.ToDateTime();

            //绑定教育
            List<JobPostEduAndEmployeeCount> edus = new List<JobPostEduAndEmployeeCount>();
            foreach (var ed in JobAction.Edu)
            {
                edus.Add(new JobPostEduAndEmployeeCount() { Checked = false, key = ed.Key, Number = 0, Text = ed.Value });
            }
            string[] chk = WS.RequestString("chk").Split(',');
            string[] nums = WS.RequestString("number").Split(',');
            for (int i = 0; i < chk.Length; i++)
            {
                edus[i].Checked = chk[i].ToBoolean();
                edus[i].Number = nums[i].ToInt32();
            }

            p.Ext1 = Voodoo.IO.XML.Serialize(edus);

            if (p.ID <= 0)
            {
                //处理城市热度
                try
                {
                    var ct = (from l in ent.City where l.id == p.City select l).FirstOrDefault();
                    ct.Hot += 1;
                }
                catch { }

                ent.AddToJobPost(p);
            }
            ent.SaveChanges();
            ent.Dispose();

            Js.AlertAndChangUrl("保存成功!", refer);
        }
开发者ID:kuibono,项目名称:KCMS2,代码行数:58,代码来源:Edit.aspx.cs

示例12: btn_Save_Click

        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();

            int clsid = ddl_Class.SelectedValue.ToInt32();
            int quID = WS.RequestInt("id");
            Class cls = ObjectExtents.Class(clsid);

            Question qu = (from l in ent.Question where l.ID == quID select l).FirstOrDefault();

            qu.ClassID = ddl_Class.SelectedValue.ToInt32();
            qu.Title = txt_Title.Text.TrimDbDangerousChar();

            try
            {
                qu.UserID = ddl_Author.SelectedValue.ToInt32();
                qu.UserName = ddl_Author.SelectedItem.Text;
            }
            catch
            {
                qu.UserID = 0;
                qu.UserName = "";
            }

            qu.ClickCount = txt_ClickCount.Text.ToInt32(0);
            if (qu.ID <= 0)
            {
                qu.AskTime = DateTime.Now;
            }
            qu.Content = txt_Content.Text.TrimDbDangerousChar();

            qu.Title = txt_Title.Text;
            qu.ZtID = 0;

            if (qu.ID <= 0)
            {
                ent.AddToQuestion(qu);
            }
            ent.SaveChanges();
            ent.Dispose();

            //生成页面
            try
            {
                CreatePage.CreateContentPage(qu, cls);

                Question pre = GetPreQuestion(qu, cls);
                if (pre != null)
                {
                    CreatePage.CreateContentPage(pre, cls);
                }
                CreatePage.CreateListPage(cls, 1);
            }
            catch { }

            Js.AlertAndChangUrl("保存成功!", url);
        }
开发者ID:svn2github,项目名称:KCMS2,代码行数:62,代码来源:QuestionEdit.aspx.cs

示例13: BookInsert

 public Book BookInsert(Book book)
 {
     using (DataEntities ent = new DataEntities())
     {
         ent.AddToBook(book);
         ent.SaveChanges();
         return book;
     }
 }
开发者ID:svn2github,项目名称:KCMS2,代码行数:9,代码来源:ClientService.svc.cs

示例14: BookUpdate

 public void BookUpdate(Book book)
 {
     using (DataEntities ent = new DataEntities())
     {
         var b = (from l in ent.Book where l.ID == book.ID select l).FirstOrDefault();
         b = book;
         ent.SaveChanges();
     }
 }
开发者ID:svn2github,项目名称:KCMS2,代码行数:9,代码来源:ClientService.svc.cs

示例15: btn_Save_Click

        protected void btn_Save_Click(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();

            long id = WS.RequestLong("id");

            JobResumeInfo
                r = (from l in ent.JobResumeInfo where l.UserID == UserAction.opuser.ID select l).FirstOrDefault();

            r.ChineseName = txt_ChineseName.Text;
            r.Birthday = new DateTime(ddl_Year.SelectedValue.ToInt32(),
                ddl_Month.SelectedValue.ToInt32(),
                ddl_Day.SelectedValue.ToInt32());
            r.IsMale = ckl_sex.SelectedValue == "1";
            r.Province = ddl_Province.SelectedValue.ToInt32();
            r.City = ddl_City.SelectedValue.ToInt32();
            r.WorkPlace = ddl_CityWork.SelectedValue.ToInt32();
            r.Mobile = txt_Mobile.Text;
            r.Email = txt_Email.Text;
            r.IsResumeOpen = ckl_Enable.SelectedValue == "1";
            r.Keywords = txt_Keywords.Text;

            if (r.ID <= 0)
            {
                ent.AddToJobResumeInfo(r);
            }
            ent.SaveChanges();

            if (file_Face.HasFile)
            {
                string path = string.Format("/u/ResumeFace/{0}.jpg", r.ID.ToS());
                var result = BasePage.UpLoadImage(file_Face.PostedFile, path, 96, 96);
                if (result.Success)
                {
                    r.Image = path;
                }
                ent.SaveChanges();
            }

            ent.Dispose();

            Js.AlertAndChangUrl("保存成功!", "Home.aspx");
        }
开发者ID:svn2github,项目名称:KCMS2,代码行数:43,代码来源:ResumeBasic.aspx.cs


注:本文中的Voodoo.Basement.DataEntities.SaveChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。