//Add new entry button private void addEntryBtn_Click(object sender, RoutedEventArgs e) { //new entry is created Entry tempEntry = new Entry(); //clear any warnings, if necessary warningTB.Visibility = Visibility.Hidden; warningAT.Visibility = Visibility.Hidden; warningAN.Visibility = Visibility.Hidden; //populates new entry object with user data given try { //process account names to make sure no quotation marks are entered if (account1TB.Text.Contains("'") || account2TB.Text.Contains("'")) { throw new Exception("quotation"); } // Check for account types. if (type1CB.SelectedItem == null || type2CB.SelectedItem == null) { throw new Exception("null_account_types"); } // Check for blank account names. if (account1TB.Text.Replace(" ", "") == string.Empty || account2TB.Text.Replace(" ", "") == string.Empty) { throw new Exception("blank_account_names"); } tempEntry.Account1 = account1TB.Text; tempEntry.Account2 = " " + account2TB.Text; tempEntry.Debit = Double.Parse(debitTB.Text); tempEntry.Credit = Double.Parse(creditTB.Text); tempEntry.Type1 = type1CB.Text; tempEntry.Type2 = type2CB.Text; //add entry into entryGrid entryGrid.Items.Add(tempEntry); //separate entry into two t-accounts List <Entry_tacc> tempAccounts = T_Accounts.get_taccs(tempEntry); //process t-accounts T_Accounts.add_taccs(tempAccounts); //<<-------------inserting data to the database-------------------->> LeapLogDBManager sqlTables = new LeapLogDBManager(); //<<------- this chooses the table where the data will be added to-------->> string tableName = user_Input.Text.Replace(" ", ""); //**********insert into journal table************ sqlTables.WriteData("INSERT INTO " + tableName + " VALUES ('" + DateTime.Now + "','" + account1TB.Text + "','" + account2TB.Text + "','" + type1CB.Text + "','" + type2CB.Text + "','" + double.Parse(debitTB.Text) + "','" + double.Parse(creditTB.Text) + "')"); } catch (Exception error) { switch (error.Message) { case "quotation": //if incorrect data entered, warning given //and entry not saved warningTB.Visibility = Visibility.Visible; break; case "null_account_types": // if the account types are null, display a warning. warningAT.Visibility = Visibility.Visible; break; case "blank_account_names": // if account names are blank display warning. warningAN.Visibility = Visibility.Visible; break; } } //clear textboxes account1TB.Text = ""; account2TB.Text = ""; debitTB.Text = ""; creditTB.Text = ""; type1CB.SelectedItem = null; type2CB.SelectedItem = null; account1TB.Focus(); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: #line 12 "..\..\..\MainWindow.xaml" ((LeapLog.MainWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.Window_Closing_1); #line default #line hidden return; case 2: #line 15 "..\..\..\MainWindow.xaml" ((System.Windows.Controls.Grid)(target)).MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.Grid_MouseDown); #line default #line hidden return; case 3: this.MinimizeButton = ((System.Windows.Controls.Button)(target)); #line 21 "..\..\..\MainWindow.xaml" this.MinimizeButton.Click += new System.Windows.RoutedEventHandler(this.MinimizeButton_Click); #line default #line hidden return; case 4: this.CloseButton = ((System.Windows.Controls.Button)(target)); #line 25 "..\..\..\MainWindow.xaml" this.CloseButton.Click += new System.Windows.RoutedEventHandler(this.CloseButton_Click); #line default #line hidden return; case 5: #line 31 "..\..\..\MainWindow.xaml" ((System.Windows.Controls.TabControl)(target)).SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.TabControl_SelectionChanged); #line default #line hidden return; case 6: this.t_account_control = ((LeapLog.T_Accounts)(target)); return; case 7: this.balance_sheet_control = ((LeapLog.BalanceSheet)(target)); return; case 8: this.income_statement = ((LeapLog.IncomeStatement)(target)); return; case 9: this.statementofownersequity = ((LeapLog.StatementofOwnersEquity)(target)); return; case 10: #line 85 "..\..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click); #line default #line hidden return; case 11: this.gettingStartedWindow = ((System.Windows.Controls.Grid)(target)); return; } this._contentLoaded = true; }