private void Button_Click(object sender, RoutedEventArgs e) { //try { if (Item == null) { ProfileBankAccount ba = new ProfileBankAccount(); //ba.account = da.GetAccount(AccountID); int BankID = (edtBank.SelectedItem as bank).id; ba.bank = da.BankGet(BankID); ba.BankAccount = edtBankAccount.Text; ba.Description = edtDescription.Text; ba.IsMain = edtIsMain.IsChecked.Value ? 1 : 0; //AccountID = da.BankAccountCreate(ba).id; da.ProfileBankAccountCreate(ba); } else { int BankID = (edtBank.SelectedItem as bank).id; Item.bank = da.BankGet(BankID); Item.BankAccount = edtBankAccount.Text; Item.Description = edtDescription.Text; Item.IsMain = 0; if (edtIsMain.IsChecked.HasValue) if (edtIsMain.IsChecked.Value) Item.IsMain = 1; //AccountID = da.BankAccountCreate(ba).id; da.ProfileBankAccountEdit(Item); } } //catch (Exception) { } Close(); }
public ProfileBankAccountDialog(int BankAccountID) { InitializeComponent(); Item = da.ProfileBankAccountGet(BankAccountID); }
/// <summary> /// Deprecated Method for adding a new object to the ProfileBankAccounts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProfileBankAccounts(ProfileBankAccount profileBankAccount) { base.AddObject("ProfileBankAccounts", profileBankAccount); }
/// <summary> /// Create a new ProfileBankAccount object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="bankAccount">Initial value of the BankAccount property.</param> public static ProfileBankAccount CreateProfileBankAccount(global::System.Int32 id, global::System.String bankAccount) { ProfileBankAccount profileBankAccount = new ProfileBankAccount(); profileBankAccount.id = id; profileBankAccount.BankAccount = bankAccount; return profileBankAccount; }
public void ProfileBankAccountEdit(ProfileBankAccount a) { ProfileBankAccount o = objDataContext.ProfileBankAccounts.FirstOrDefault(i => i.id == a.id); o.bank = a.bank; o.Description = a.Description; if (a.IsMain == 1) // если это новый основной, остальные обнулим { UndoMainBankAccounts(); o.IsMain = 1; } else o.IsMain = a.IsMain; //o.ProfileID objDataContext.SaveChanges(); }
public void ProfileBankAccountCreate(ProfileBankAccount a) { if (a.IsMain == 1) // если это новый основной, остальные обнулим UndoMainBankAccounts(); objDataContext.AddToProfileBankAccounts(a); objDataContext.SaveChanges(); }