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


C# DataClasses1DataContext.SubmitChanges方法代码示例

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


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

示例1: bSaveClick

 protected void bSaveClick(object sender, EventArgs e)
 {
     ResetErrorLabels();
     if (checkFields() == true)
     {
         DataClasses1DataContext dbContext = new DataClasses1DataContext(((Guid)Session["CurrentUserId"]));
         try
         {
             var createUser = KVSCommon.Database.User.CreateUser(txbUserLogin.Text, txbUserPassword1.Text, txbUserNachname.Text, txbUserVorname.Text, txbUserTitle.Text, dbContext);
             if (hasContactData() == true)
             {
                 var createContact = Contact.CreateContact(txbUserPhone.Text, txbUserFax.Text, txbUserMobile.Text, txbUserEmail.Text, dbContext);
                 createUser.Contact = createContact;
             }
             dbContext.SubmitChanges();
             RadWindowManagerCreateUser.RadAlert("Der Benutzer wurde erfolgreich angelegt!", 380, 180, "Info", "");
             txbUserLogin.Text=""; txbUserPassword1.Text=""; txbUserNachname.Text="";
             txbUserVorname.Text = ""; txbUserTitle.Text = "";
             txbUserPhone.Text = ""; txbUserFax.Text = ""; txbUserMobile.Text = ""; txbUserEmail.Text = "";
         }
         catch (Exception ex)
         {
             RadWindowManagerCreateUser.RadAlert(Server.HtmlEncode(ex.Message).RemoveLineEndings(), 380, 180, "Fehler", "");
             try
             {
                 dbContext.WriteLogItem("Create User Error " + ex.Message, LogTypes.ERROR, "User");
                 dbContext.SubmitChanges();
             }
             catch { }
         }
     }
 }
开发者ID:HedinRakot,项目名称:KVS,代码行数:32,代码来源:CreateUser.aspx.cs

示例2: CreateAccount

 public static void CreateAccount(Guid? AccountNumber, Price _object, DataClasses1DataContext dbContext, bool withLocation = false)
 {
     if (AccountNumber != null)
        {
        IQueryable<PriceAccount> myAccount = null;
        if (withLocation == false)
        {
            myAccount = dbContext.PriceAccount.Where(q => q.PriceId == _object.Id && q.Price.LocationId == null);
        }
        else
        {
            myAccount = dbContext.PriceAccount.Where(q => q.PriceId == _object.Id && q.Price.LocationId == _object.LocationId);
        }
        if (myAccount.Count() > 0)
        {
            dbContext.PriceAccount.DeleteAllOnSubmit<PriceAccount>(myAccount);
            dbContext.SubmitChanges();
        }
        if (myAccount.Count() == 0)
        {
            var myNewAccount = new PriceAccount
            {
                PriceId = _object.Id,
                AccountId = AccountNumber.Value
            };
            dbContext.PriceAccount.InsertOnSubmit(myNewAccount);
            dbContext.SubmitChanges();
        }
        }
 }
开发者ID:HedinRakot,项目名称:KVS,代码行数:30,代码来源:PriceAccountHelper.cs

示例3: ChangeSaveBtn_Click

 protected void ChangeSaveBtn_Click(object sender, EventArgs e)
 {
     DataClasses1DataContext dbContext = new DataClasses1DataContext(Int32.Parse(Session["CurrentUserId"].ToString())); // hier kommt die Loggingid
     try
     {
         if (txbNewPassword.Text == txbRepeatPWD.Text)
         {
             var thisUser = dbContext.User.SingleOrDefault(q => q.Id == Int32.Parse(Session["CurrentUserId"].ToString()));
             if (thisUser != null)
             {
                 thisUser.ChangePassword(txbNewPassword.Text, txbOldPWD.Text, dbContext);
                 dbContext.SubmitChanges();
                 RadWindowManagerChangePassword.RadAlert("Das Passwort wurde erfolgreich geändert", 380, 180, "Info", "");
             }
             else
             {
                 Response.Redirect("../login.aspx");
             }
         }
         else
         {
             FailureText.Text = "Die neuen Passwörter stimmen nicht überein";
         }
     }
     catch (Exception ex)
     {
         FailureText.Text = ex.Message;
         dbContext.WriteLogItem("ChangePassowrd Error:  " + ex.Message, LogTypes.ERROR, "User");
     }
 }
开发者ID:HedinRakot,项目名称:KVS,代码行数:30,代码来源:ChangePassword.aspx.cs

示例4: CreateSmallCustomer

        /// <summary>
        /// Erstellt einen Laufkunden.
        /// </summary>
        /// <param name="name">Name des Kunden.</param>
        /// <param name="firstName">Vorname des Kunden.</param>
        /// <param name="title">Anrede.</param>
        /// <param name="gender">Geschlecht.</param>
        /// <param name="street">Straße.</param>
        /// <param name="streetnumber">Hausnummer.</param>
        /// <param name="zipcode">Postleitzahl.</param>
        /// <param name="city">Straße.</param>
        /// <param name="country">Land.</param>
        /// <param name="phone">Telefonnummer.</param>
        /// <param name="fax">Faxnummer.</param>
        /// <param name="mobilephone">Mobiltelefonnummer.</param>
        /// <param name="email">Emailaddresse.</param>
        /// <param name="vat">Mehrwersteuersatz für den Kunden.</param>
        /// <param name="termOfCredit">Zahlungsziel (in Tagen).</param>
        /// <param name="customerNumber">Kundennummer.</param>
        /// <param name="dbContext">Datenbankkontext für die Transaktion.</param>
        /// <returns>Den neuen Laufkunden.</returns>
        public static SmallCustomer CreateSmallCustomer(string name, string firstName, string title, string gender, string street, string streetnumber, string zipcode, string city, 
            string country, string phone, string fax, string mobilephone, string email, decimal vat, int? termOfCredit, string customerNumber, DataClasses1DataContext dbContext)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("Der Name darf nicht leer sein.");
            }

            var customer = Customer.CreateCustomer(name, street, streetnumber, zipcode, city, country, phone, fax, mobilephone, email, vat, termOfCredit, customerNumber);
            customer._dbContext = dbContext;
            var person = new Person()
            {
                FirstName = firstName,
                Name = name,
                Gender = gender,
                Title = title
            };

            var smallCustomer = new SmallCustomer()
            {
                Customer = customer,
                Person = person
            };

            dbContext.SmallCustomer.InsertOnSubmit(smallCustomer);
            dbContext.SubmitChanges();
            dbContext.WriteLogItem("Kunde " + firstName + " " + name + " wurde angelegt.", LogTypes.INSERT, customer.Id, "SmallCustomer");

            return smallCustomer;
        }
开发者ID:HedinRakot,项目名称:KVS,代码行数:51,代码来源:SmallCustomer.cs

示例5: CreateAccounts

        /// <summary>
        /// Erstelle zu der jeweiligen Rechnung ein neues Erlöskonto
        /// </summary>
        /// <param name="dbContext">DB Kontext</param>
        /// <param name="inv">Rechnungsobjekt</param>
        public static void CreateAccounts(DataClasses1DataContext dbContext, Invoice inv)
        {
            List<_Accounts> acc = null;
             acc = Accounts.generateAccountNumber(dbContext,inv.Id).ToList();

             if (acc != null && acc.Count() == inv.InvoiceItem.Count)
             {
                 foreach (var thisItems in acc)
                 {
                     var myAccount = new InvoiceItemAccountItem
                     {
                         InvoiceItemId = thisItems.InvoiceItemId,
                         RevenueAccountText = thisItems.AccountNumber
                     };
                     var contains = dbContext.InvoiceItemAccountItem.FirstOrDefault(q => q.InvoiceItemId ==
                         thisItems.InvoiceItemId && q.RevenueAccountText == thisItems.AccountNumber.Trim());
                     if (contains != null)
                     {
                         contains.RevenueAccountText = thisItems.AccountNumber.Trim();
                     }
                     else
                     {
                         dbContext.InvoiceItemAccountItem.InsertOnSubmit(myAccount);
                     }
                     dbContext.SubmitChanges();
                 }
             }
             else
             {
                 throw new Exception("Die Rechnung konnte nicht gedruckt werden, da nicht alle Dienstleistungen ein Erlöskonto haben! Sie können die Erlöskonten im Reiter 'Rechnung erstellen' zuweisen und die Rechnung erneut drucken.");
             }
        }
开发者ID:HedinRakot,项目名称:KVS,代码行数:37,代码来源:InvoiceHelper.cs

示例6: CreatePrice

        /// <summary>
        /// Erstellt einen neuen Preis.
        /// </summary>
        /// <param name="amount">Der Betrag des Preises.</param>
        /// <param name="authorativeCharge">Die behoerdliche Gebuehr.</param>
        /// <param name="productId">Id des Produkts, für den der Preis gilt.</param>
        /// <param name="locationId">Id des Standorts, falls benoetigt. </param>
        /// <param name="dbContext">Datenbankkontext für die Transaktion.</param>
        /// <returns>Den neuen Preis.</returns>
        public static Price CreatePrice(decimal amount, decimal? authorativeCharge, int productId, int? locationId, int? accountId, DataClasses1DataContext dbContext)
        {
            if (dbContext.Price.Any(q => q.ProductId == productId && q.LocationId == locationId))
            {
                throw new Exception("Für dieses Produkt und diesen Standort ist bereits ein Preis eingetragen.");
            }

            var productName = dbContext.Product.Single(q => q.Id == productId).Name;
            string standortText = string.Empty;
            if (locationId.HasValue)
            {
                standortText = " und Standort " + dbContext.Location.Single(q => q.Id == locationId).Name;
            }

            var price = new Price()
            {
                Amount = amount,
                AuthorativeCharge = authorativeCharge,
                LocationId = locationId,
                ProductId = productId,

            };

            dbContext.Price.InsertOnSubmit(price);
            dbContext.SubmitChanges();
            dbContext.WriteLogItem("Preis für Produkt " + productName + standortText + " eingetragen.", LogTypes.INSERT, price.Id, "Price");

            if (accountId.HasValue)
            {

                var account = new PriceAccount()
                {
                    Price = price,
                    AccountId =accountId.Value

                };
                dbContext.PriceAccount.InsertOnSubmit(account);
                dbContext.SubmitChanges();
                dbContext.WriteLogItem("Account für Produkt " + productName + standortText + " eingetragen.", LogTypes.INSERT, price.Id, "Price");
            }

            return price;
        }
开发者ID:HedinRakot,项目名称:KVS,代码行数:52,代码来源:Price.cs

示例7: btnSaveRequired_Click

 protected void btnSaveRequired_Click(object sender, EventArgs e)
 {
     DataClasses1DataContext dbContext = new DataClasses1DataContext(((Guid)Session["CurrentUserId"]));
     try
     {
         RadListBoxItemCollection AddedRequired = ((RadListBox)((RadButton)sender).Parent.FindControl("CustomerRequired")).Items;
         RadListBoxItemCollection AllRequired = ((RadListBox)((RadButton)sender).Parent.FindControl("AllRequired")).Items;
         Guid customerId = new Guid(((RadButton)sender).CommandArgument.ToString());
         var myCustomer = dbContext.LargeCustomer.SingleOrDefault(q => q.CustomerId== customerId);
         if (myCustomer != null)
         {
             foreach (RadListBoxItem required in AllRequired)
             {
                 if (myCustomer.LargeCustomerRequiredField.SingleOrDefault(q => q.RequiredFieldId == new Guid(required.Value)) != null)
                 {
                     myCustomer.RemoveRequiredField(new Guid(required.Value), dbContext);
                 }
             }
             foreach (RadListBoxItem addItem in AddedRequired)
             {
                 if (myCustomer.LargeCustomerRequiredField.SingleOrDefault(q => q.RequiredFieldId == new Guid(addItem.Value)) == null)
                 {
                     myCustomer.AddRequiredField(new Guid(addItem.Value), dbContext);
                 }
             }
             dbContext.SubmitChanges();
         }
         getAllCustomerRequired.EditIndexes.Clear();
         getAllCustomerRequired.MasterTableView.IsItemInserted = false;
         getAllCustomerRequired.MasterTableView.Rebind();
     }
     catch (Exception ex)
     {
         RadWindowManagerLargeCustomerRequired.RadAlert(Server.HtmlEncode(ex.Message).RemoveLineEndings(), 380, 180, "Fehler", "");
         try
         {
             dbContext.WriteLogItem("LargeCustomerRequiredField Error " + ex.Message, LogTypes.ERROR, "LargeCustomerRequiredField");
             dbContext.SubmitChanges();
         }
         catch { }
     }
 }
开发者ID:HedinRakot,项目名称:KVS,代码行数:42,代码来源:RequiredField_Details.aspx.cs

示例8: getAllPermission_EditCommand

 protected void getAllPermission_EditCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
 {
     DataClasses1DataContext dbContext = new DataClasses1DataContext(((Guid)Session["CurrentUserId"]));
     Hashtable newValues = new Hashtable();
     ((GridEditableItem)e.Item).ExtractValues(newValues);
     try
     {
         var checkThisPermission = dbContext.Permission.SingleOrDefault(q => q.Id == new Guid(newValues["Id"].ToString()));
         if (checkThisPermission != null)
         {
             if (newValues["Description"] == null)
             {
                 throw new Exception("Die Rechtebeschreibung darf nicht leer sein!");
             }
             checkThisPermission.LogDBContext = dbContext;
             checkThisPermission.Description = newValues["Description"].ToString();
             dbContext.SubmitChanges();
         }
         else
         {
             throw new Exception("Das Bearbeiten ist nicht möglich!");
         }
     }
     catch (Exception ex)
     {
         RadWindowManagerAllPermission.RadAlert(Server.HtmlEncode(ex.Message).RemoveLineEndings(), 380, 180, "Fehler", "");
         try
         {
             dbContext.WriteLogItem("Permission Error " + ex.Message, LogTypes.ERROR, "Permission");
             dbContext.SubmitChanges();
         }
         catch { }
     }
     finally
     {
         getAllPermission.EditIndexes.Clear();
         getAllPermission.MasterTableView.IsItemInserted = false;
         getAllPermission.MasterTableView.Rebind();
     }
 }
开发者ID:HedinRakot,项目名称:KVS,代码行数:40,代码来源:AllPermission.ascx.cs

示例9: DeleteAccount

 /// <summary>
 /// Lösche ein bestehendes Erlöskonto
 /// </summary>
 /// <param name="CustomerId">Kundenid</param>
 /// <param name="AccountNumber">Kontonummer</param>
 /// <param name="dbContext">Datenbank Kontext</param>
 public static void DeleteAccount(int CustomerId, string AccountNumber, DataClasses1DataContext dbContext)
 {
     var myAcount = dbContext.Accounts.FirstOrDefault(q => q.CustomerId == CustomerId && q.AccountNumber == AccountNumber);
        if (myAcount == null)
        {
        throw new Exception("Dieses Buchungskonto wurde im System nicht gefunden.");
        }
        else
        {
        dbContext.Accounts.DeleteOnSubmit(myAcount);
        dbContext.SubmitChanges();
        }
 }
开发者ID:HedinRakot,项目名称:KVS,代码行数:19,代码来源:Accounts.cs

示例10: CreateProductCategory

        /// <summary>
        /// Erstellt eine neue Produktkategorie mit uebergebenem Namen.
        /// </summary>
        /// <param name="name">Name der Kategorie.</param>
        /// <param name="dbContext">Datenbankkontext, mit dem die Kategorie erstellt wird.</param>
        /// <returns>Die neu erstellte Produktkategorie.</returns>
        public static ProductCategory CreateProductCategory(string name, DataClasses1DataContext dbContext)
        {
            var item = new ProductCategory()
            {
                LogDBContext = dbContext,
                Name = name
            };

            dbContext.ProductCategory.InsertOnSubmit(item);
            dbContext.SubmitChanges();
            dbContext.WriteLogItem("Produktkategorie " + item.Name + " angelegt.", LogTypes.INSERT, item.Id, "ProductCategory");
            return item;
        }
开发者ID:HedinRakot,项目名称:KVS,代码行数:19,代码来源:ProductCategory.cs

示例11: AddInvoiceType_Click

        protected void AddInvoiceType_Click(object sender, EventArgs e)
        {
            bool insertUpdateOk = true;
            using (TransactionScope ts = new TransactionScope())
            {
                DataClasses1DataContext dbContext = new DataClasses1DataContext();

                try
                {
                    RadButton AddInvoiceType = ((RadButton)sender);
                    GridDataItem myItem = AddInvoiceType.Parent.Parent.Parent.Parent as GridDataItem;
                    RadComboBox cmbSelectedType = AddInvoiceType.Parent.FindControl("cmbInvoiceTypes") as RadComboBox;

                    if (myItem != null && myItem["Id"].Text != string.Empty && !String.IsNullOrEmpty(myItem["Id"].Text) && cmbSelectedType != null
                        && cmbSelectedType.SelectedValue != string.Empty && !String.IsNullOrEmpty(cmbSelectedType.SelectedValue))
                    {
                        var customer = dbContext.LargeCustomer.FirstOrDefault(q => q.CustomerId == Int32.Parse(myItem["Id"].Text));
                        if (customer != null)
                        {
                            customer.InvoiceTypesID = Int32.Parse(cmbSelectedType.SelectedValue);
                            dbContext.SubmitChanges();
                        }
                        ts.Complete();

                    }
                }
                catch (Exception ex)
                {
                    insertUpdateOk = false;
                    if (ts != null)
                        ts.Dispose();
                    RadWindowManagerLargeCustomer.RadAlert(Server.HtmlEncode(ex.Message).RemoveLineEndings(), 380, 180, "Fehler", "");
                    try
                    {
                        dbContext = new DataClasses1DataContext(Int32.Parse(Session["CurrentUserId"].ToString()));
                        dbContext.WriteLogItem("AddInvoiceType_Click Error " + ex.Message, LogTypes.ERROR, "Customer");
                        dbContext.SubmitChanges();
                    }
                    catch { }
                }

            }
            if (insertUpdateOk)
            {
                getAllCustomer.EditIndexes.Clear();
                getAllCustomer.MasterTableView.IsItemInserted = false;
                getAllCustomer.MasterTableView.Rebind();
            }
        }
开发者ID:HedinRakot,项目名称:KVS,代码行数:49,代码来源:LargeCustomerDetails.ascx.cs

示例12: CreateContact

        /// <summary>
        /// Erstelle einene neuen Kontakt 
        /// </summary>
        /// <param name="phone">Telefon</param>
        /// <param name="fax">Fax</param>
        /// <param name="mobilePhone">Mobil</param>
        /// <param name="email">Mail</param>
        /// <param name="dbContext">Datenbankkontext</param>
        /// <returns>Den neue erstellten Kontakt</returns>
        public static Contact CreateContact(string phone, string fax, string mobilePhone, string email, DataClasses1DataContext dbContext)
        {
            Contact contact = new Contact()
            {
                Phone = phone,
                Fax = fax,
                MobilePhone = mobilePhone,
                Email = email
            };

            dbContext.Contact.InsertOnSubmit(contact);
            dbContext.SubmitChanges();
            dbContext.WriteLogItem("Kontakt angelegt.", LogTypes.INSERT, contact.Id, "Contact");
            return contact;
        }
开发者ID:HedinRakot,项目名称:KVS,代码行数:24,代码来源:Contact.cs

示例13: CreateAccount

 /// <summary>
 /// Erstelle ein neues Erloeskonte
 /// </summary>
 /// <param name="CustomerId">Kundenid</param>
 /// <param name="AccountNumber">Kontonummer</param>
 /// <param name="dbContext">Datenbank Kontext</param>
 /// <returns>Erloeskonto</returns>
 public static Accounts CreateAccount(int? CustomerId, string AccountNumber, DataClasses1DataContext dbContext)
 {
     if (dbContext.Accounts.Any(q => q.CustomerId == CustomerId && q.AccountNumber == AccountNumber))
        {
        throw new Exception("Für diesen Kunden ist bereits dieses Konto eingetragen");
        }
        var account = new Accounts
        {
        AccountNumber = AccountNumber,
        CustomerId = CustomerId
        };
        dbContext.Accounts.InsertOnSubmit(account);
        dbContext.SubmitChanges();
        return account;
 }
开发者ID:HedinRakot,项目名称:KVS,代码行数:22,代码来源:Accounts.cs

示例14: CreateAdress

        /// <summary>
        /// Erstellt eine neue Adresse.
        /// </summary>
        /// <param name="street">Straße.</param>
        /// <param name="streetNumber">Hausnummer.</param>
        /// <param name="zipcode">Postleitzahl.</param>
        /// <param name="city">Ort.</param>
        /// <param name="country">Land.</param>
        /// <param name="dbContext">Datenbankkontext für die Transaktion.</param>
        /// <returns>Die neue Adresse.</returns>
        public static Adress CreateAdress(string street, string streetNumber, string zipcode, string city, string country, DataClasses1DataContext dbContext)
        {
            Adress adress = new Adress()
            {
                Street = street,
                StreetNumber = streetNumber,
                Zipcode = zipcode,
                City = city,
                Country = country
            };

            dbContext.Adress.InsertOnSubmit(adress);
            dbContext.SubmitChanges();
            dbContext.WriteLogItem("Adresse angelegt.", LogTypes.INSERT, adress.Id, "Adress");
            return adress;
        }
开发者ID:HedinRakot,项目名称:KVS,代码行数:26,代码来源:Adress.cs

示例15: CreateCopy

        /// <summary>
        /// Erstelle eine Kopie der Adress
        /// </summary>
        /// <param name="adress">Zu kopierende Adress</param>
        /// <param name="dbContext">Datenbank Kontext</param>
        /// <returns>Adress</returns>
        public static Adress CreateCopy(Adress adress, DataClasses1DataContext dbContext)
        {
            Adress copy = new Adress()
            {
                Street = adress.Street,
                StreetNumber = adress.StreetNumber,
                Zipcode = adress.Zipcode,
                City = adress.City,
                Country = adress.Country
            };

            dbContext.Adress.InsertOnSubmit(copy);
            dbContext.SubmitChanges();
            dbContext.WriteLogItem("Adresse kopiert.", LogTypes.INSERT, copy.Id, "Adress", adress.Id);
            return copy;
        }
开发者ID:HedinRakot,项目名称:KVS,代码行数:22,代码来源:Adress.cs


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