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


C# dbDataContext.SubmitChanges方法代码示例

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


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

示例1: SetUserWidgets

    /// <summary>
    /// This function adds the widgets for a user
    /// </summary>
    /// <param name="widgets"></param>
    /// <returns></returns>
    public bool SetUserWidgets(List<DashboardWidget> widgets)
    {
        if (widgets != null && widgets.Count > 0)
        {
            var context = new dbDataContext();
            var userId = widgets[0].UserId;

            //delete all the widgets for the user
            var foundWidgets = context.tbl_UserWidgets.Where(t => t.UserId == userId).Select(t => t).ToList();
            context.tbl_UserWidgets.DeleteAllOnSubmit(foundWidgets);
            context.SubmitChanges();

            //add widgets
            foreach (var wi in widgets)
            {
                if (string.IsNullOrEmpty(wi.WidgetName))
                {
                    continue;
                }

                var widget = new tbl_UserWidget
                {
                    Ordering = wi.Ordering,
                    UserId = wi.UserId,
                    WidgetName = wi.WidgetName,
                    WidgetTitle = wi.WidgetTitle,
                    Width = wi.Width
                };
                context.tbl_UserWidgets.InsertOnSubmit(widget);
            }
            context.SubmitChanges();
        }
        return true;
    }
开发者ID:NosDeveloper2,项目名称:RecruitGenie,代码行数:39,代码来源:DashboardWidgets.cs

示例2: Add

 public static void Add(dbDataContext db, string name, string email, string phone, int _sub_unit)
 {
     user newUser = new user();
     newUser.userName = name;
     newUser.email = email;
     newUser.phone = phone;
     newUser.sub_unit = _sub_unit;
     db.users.InsertOnSubmit(newUser);
     db.SubmitChanges();
     if (newUser.id == 1) newUser.is_admin = true;
     db.SubmitChanges();
 }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:12,代码来源:Users.cs

示例3: Add

 public static void Add(dbDataContext db, string unitName)
 {
     unit newUnit = new unit();
     newUnit.unit_name = unitName;
     db.units.InsertOnSubmit(newUnit);
     db.SubmitChanges();
 }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:7,代码来源:Groups.cs

示例4: Add

 public static void Add(dbDataContext db, string domain)
 {
     allowed_email_domain aed = new allowed_email_domain();
     aed.domain = domain;
     db.allowed_email_domains.InsertOnSubmit(aed);
     db.SubmitChanges();
 }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:7,代码来源:dbi.cs

示例5: Import

    public static string Import(Stream xmlFile)
    {
        string output = string.Empty;
        try
        {
            TextReader rdr = new StreamReader(xmlFile);
            XElement x = XElement.Load(rdr);
            var faqs = from p in x.Descendants("faq") select p;

            foreach (XElement xe in faqs)
            {
                dbDataContext db = new dbDataContext();
                faq f = new faq();
                f.title = xe.FirstAttribute.Value;
                f.body = xe.Value;
                db.faqs.InsertOnSubmit(f);
                try
                {
                    db.SubmitChanges(); //inefficient to submit each time, *but* this will tell which faqs got inserted and which didn't
                    output += "<div class='success'>-" + xe.FirstAttribute.Value + " " + Resources.Common.Updated + "</div>";
                }
                catch// (Exception ex)
                {
                    output += "<div class='error'>" + Resources.Common.Error + " " + xe.FirstAttribute.Value + "</div>";
                }
            }
        }
        catch (Exception ex)
        {
            output = "<div class='error'>" + Resources.Common.Error + ": <div class='sub_error'>" + ex.Message + "</div></div>";
        }
        return output;
    }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:33,代码来源:Faqs.cs

示例6: Edit

 public static void Edit(dbDataContext db, int id, string q, string a)
 {
     faq f = Get(db, id);
     f.title = q;
     f.body = a;
     db.SubmitChanges();
 }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:7,代码来源:Faqs.cs

示例7: Add

 public static void Add(dbDataContext db, string q, string a)
 {
     faq f = new faq();
     f.title = q;
     f.body = a;
     db.faqs.InsertOnSubmit(f);
     db.SubmitChanges();
 }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:8,代码来源:Faqs.cs

示例8: AddGroup

 public static void AddGroup(dbDataContext db, string ad_group, int access_level)
 {
     user_group ug = new user_group();
     ug.ad_group = ad_group;
     ug.security_level = access_level;
     db.user_groups.InsertOnSubmit(ug);
     db.SubmitChanges();
 }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:8,代码来源:Permissions.cs

示例9: DeleteClientNote

 /// <summary>
 /// Delete client notes
 /// </summary>
 /// <param name="clientNoteId"></param>
 /// <returns></returns>
 public bool DeleteClientNote(int clientNoteId)
 {
     var context = new dbDataContext();
     var clientNote = context.tbl_ClientNotes.FirstOrDefault(t => t.ClientNoteId == clientNoteId);
     if (clientNote == null) return false;
     context.tbl_ClientNotes.DeleteOnSubmit(clientNote);
     context.SubmitChanges();
     return true;
 }
开发者ID:NosDeveloper2,项目名称:RecruitGenie,代码行数:14,代码来源:ClientNotes.cs

示例10: Update

 public static void Update(dbDataContext db, string name, string email, string phone, int _sub_unit)
 {
     user thisUser = db.users.First(u => u.userName.Equals(name));
     thisUser.userName = name;
     thisUser.email = email;
     thisUser.phone = phone;
     thisUser.sub_unit = _sub_unit;
     db.SubmitChanges();
 }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:9,代码来源:Users.cs

示例11: Update

 public static ticket Update(dbDataContext db, int ticketID, int status, int _priority, int assigned_to_group)
 {
     ticket t = Get(db, ticketID);
     t.ticket_status = status;
     t.priority = _priority;
     t.assigned_to_group_last = t.assigned_to_group;
     t.assigned_to_group = assigned_to_group;
     if (status == 5) t.closed = DateTime.Now;
     t.last_action = DateTime.Now;
     db.SubmitChanges();
     return t;
 }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:12,代码来源:Tickets.cs

示例12: AddEventLocation

 /// <summary>
 /// Add/ edit event locations
 /// </summary>
 /// <param name="location"></param>
 /// <returns></returns>
 public int AddEventLocation(EventLocation location)
 {
     var context = new dbDataContext();
     var loc = context.tbl_EventLocations.FirstOrDefault(t => t.EventLocationId == location.EventLocationId) ?? new tbl_EventLocation();
     loc.Active = true;
     loc.EventLocation = location.Location;
     if (loc.EventLocationId <= 0)
     {
         context.tbl_EventLocations.InsertOnSubmit(loc);
     }
     context.SubmitChanges();
     return loc.EventLocationId;
 }
开发者ID:NosDeveloper2,项目名称:RecruitGenie,代码行数:18,代码来源:EventLocations.cs

示例13: DeleteEventLocation

 /// <summary>
 /// Delete event location
 /// </summary>
 /// <param name="eventLocationId"></param>
 /// <returns></returns>
 public bool DeleteEventLocation(int eventLocationId)
 {
     var context = new dbDataContext();
     // get the event location
     var eventLocItem = context.tbl_EventLocations.FirstOrDefault(t => t.EventLocationId == eventLocationId);
     if (eventLocItem != null)
     {
         context.tbl_EventLocations.DeleteOnSubmit(eventLocItem);
         context.SubmitChanges();
         return true;
     }
     return false;
 }
开发者ID:NosDeveloper2,项目名称:RecruitGenie,代码行数:18,代码来源:EventLocations.cs

示例14: btnSignUp_Click

    protected void btnSignUp_Click(object sender, EventArgs e)
    {
        dbDataContext db = new dbDataContext();
        tblUser user = new tblUser();

        user.password = txtpass1.Text;
        user.pkeid = txteid.Text;
        user.status = "unBlock";
        user.uname = txtuname.Text;

        db.tblUsers.InsertOnSubmit(user);
        db.SubmitChanges();
        Response.Redirect("SignIn.aspx");
    }
开发者ID:fenta07,项目名称:demotest,代码行数:14,代码来源:SignUp.aspx.cs

示例15: AddUpdateQualification

 /// <summary>
 /// This function adds/update qualification
 /// </summary>
 /// <param name="qualDetails"></param>
 /// <returns></returns>
 public int AddUpdateQualification(Qualification qualDetails)
 {
     var context = new dbDataContext();
     var qualification =
         context.tbl_Qualifications.FirstOrDefault(t => t.QualificationId == qualDetails.QualificationId) ??
         new tbl_Qualification();
     qualification.Qualification = qualDetails.QualificationText;
     qualification.Active = qualDetails.Active;
     // Add/Update qualification
     if (qualification.QualificationId <= 0)
         context.tbl_Qualifications.InsertOnSubmit(qualification);
     context.SubmitChanges();
     return qualification.QualificationId;
 }
开发者ID:NosDeveloper2,项目名称:RecruitGenie,代码行数:19,代码来源:Qualifications.cs


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