[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Function[/COLOR][/SIZE][SIZE=2] ProcessTransaction([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] strTransType [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] intTabPage [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Boolean
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' controls to make this sub generic
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ctlDateTimePicker [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DateTimePicker, ctlComboBox [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ComboBox, ctlTextBox [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] TextBox
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ctlCheckBox1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] CheckBox, ctlCheckBox2 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] CheckBox, ctlCheckBoxVoid [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] CheckBox
[/SIZE][SIZE=2][COLOR=#008000]' create an SQL command object to write changes to the database
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] cmdTransactions [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Data.SqlClient.SqlCommand
[/SIZE][SIZE=2][COLOR=#008000]' string to pass table name to dynamic sql
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strTableName [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#a31515]""
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' query callers name to setup the sql staement and controls
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Select[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] strTransType
[/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#a31515]"monthly"
[/COLOR][/SIZE][SIZE=2]strTableName = [/SIZE][SIZE=2][COLOR=#a31515]"transactions"
[/COLOR][/SIZE][SIZE=2]cmdTransactions.CommandText = [/SIZE][SIZE=2][COLOR=#a31515]"INSERT INTO transactions (tran_date, tran_id, tran_amount, tran_balance, tran_save, "[/COLOR][/SIZE][SIZE=2] & _
[/SIZE][SIZE=2][COLOR=#a31515]"tran_withdrawal, void) VALUES (@TransDate, @TransDesc, @TranAmount, 0, @Saved, @WithDraw, 0)"
[/COLOR][/SIZE][SIZE=2]ctlDateTimePicker = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].dtmTransDate1
ctlComboBox = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].cboTransDescription1
ctlTextBox = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].txtAmount1
ctlCheckBox1 = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].chkSave
ctlCheckBox2 = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].chkWithDraw
ctlCheckBoxVoid = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].chkShowVoid1
[/SIZE][SIZE=2][COLOR=#008000]' detailed monthly has these but detailed weekly does not
[/COLOR][/SIZE][SIZE=2]cmdTransactions.Parameters.Add([/SIZE][SIZE=2][COLOR=#a31515]"@Saved"[/COLOR][/SIZE][SIZE=2], SqlDbType.Decimal).Value = ctlCheckBox1.Checked
cmdTransactions.Parameters.Add([/SIZE][SIZE=2][COLOR=#a31515]"@WithDraw"[/COLOR][/SIZE][SIZE=2], SqlDbType.Decimal).Value = ctlCheckBox2.Checked
[/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Select
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' link the command to the database connection
[/COLOR][/SIZE][SIZE=2]cmdTransactions.Connection = glb_cnMM2007
[/SIZE][SIZE=2][COLOR=#008000]' add the parameters to the command
[/COLOR][/SIZE][SIZE=2]cmdTransactions.Parameters.Add([/SIZE][SIZE=2][COLOR=#a31515]"@TransDate"[/COLOR][/SIZE][SIZE=2], SqlDbType.DateTime).Value = ctlDateTimePicker.Value
cmdTransactions.Parameters.Add([/SIZE][SIZE=2][COLOR=#a31515]"@TransDesc"[/COLOR][/SIZE][SIZE=2], SqlDbType.VarChar).Value = ctlComboBox.SelectedValue.ToString
cmdTransactions.Parameters.Add([/SIZE][SIZE=2][COLOR=#a31515]"@TranAmount"[/COLOR][/SIZE][SIZE=2], SqlDbType.Decimal).Value = ctlTextBox.Text
[/SIZE][SIZE=2][COLOR=#008000]' if the record was appended successfully then update the transaction display
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] cmdTransactions.ExecuteNonQuery().Equals(1) [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' refresh the rolling balance in transaction table
[/COLOR][/SIZE][SIZE=2]CalculateRollingBalance(strTableName, ctlCheckBoxVoid.Checked)
RefreshTransactionLists(intTabPage)
ScrollListViews()
[/SIZE][SIZE=2][COLOR=#008000]' reset the transaction fields
[/COLOR][/SIZE][SIZE=2]ctlTextBox.Text = [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2].Empty
ctlCheckBox1.Checked = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2]ctlCheckBox2.Checked = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2]ctlTextBox.Select()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2]ProcessTransaction = [/SIZE][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] objError [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception
MessageBox.Show([/SIZE][SIZE=2][COLOR=#a31515]"Location: ProcessTransaction"[/COLOR][/SIZE][SIZE=2] & System.Environment.NewLine & System.Environment.NewLine & [/SIZE][SIZE=2][COLOR=#a31515]"The following error occurred whilst processing the transaction"[/COLOR][/SIZE][SIZE=2] & _
System.Environment.NewLine & System.Environment.NewLine & objError.Message & System.Environment.NewLine & System.Environment.NewLine & [/SIZE][SIZE=2][COLOR=#a31515]"If the problem persists contact support@........"[/COLOR][/SIZE][SIZE=2], _
[/SIZE][SIZE=2][COLOR=#a31515]"Save Error"[/COLOR][/SIZE][SIZE=2], MessageBoxButtons.OK, MessageBoxIcon.Error)
ProcessTransaction = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Finally
[/COLOR][/SIZE][SIZE=2]cmdTransactions.Dispose()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Function
[/COLOR][/SIZE]