Public Class Form1 Dim list As Single Dim cost As Single Dim pricing(11) As Single Dim counter As Integer Dim price As Single Dim normalpart As Boolean Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'dsIntrol.TestQuote' table. You can move, or remove it, as needed. Me.taTestQuote.Fill(Me.dsIntrol.TestQuote) 'TODO: This line of code loads data into the 'dsIntrol.pricelist' table. You can move, or remove it, as needed. Me.taPricelist.Fill(Me.dsIntrol.pricelist) btnadd.Enabled = False grpQuote.Enabled = False grpQuoteDetail.Enabled = False 'btnnew.Enabled = False lblquote.Text = "$0.00" btnmake.Enabled = False cleartextboxes() calcpricing() calcprice() btnprint.Enabled = False btnPrint2.Enabled = False DateTimePicker1.Value = DateTime.Now() End Sub Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click Try Me.Validate() bspricelist.EndEdit() daPricelist.Update(dsIntrol.pricelist) Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Me.taPricelist.Fill(Me.dsIntrol.pricelist) End Sub Private Function GetRow() As dsIntrol.pricelistRow Dim drv As DataRowView drv = bspricelist.Current GetRow = drv.Row End Function Private Sub cleartextboxes() txtuser1.Text = "" txtuser2.Text = "" txtuser3.Text = "" txtoem1.Text = "" txtoem2.Text = "" txtoem3.Text = "" txtreseller1.Text = "" txtreseller2.Text = "" txtreseller3.Text = "" txtdistributor1.Text = "" txtdistributor2.Text = "" txtdistributor3.Text = "" End Sub Private Sub calcprice() Try If cbxcustomer.Text = "User" Then If numqty.Value < 5 Then price = pricing(0) * numqty.Value ElseIf numqty.Value < 25 Then price = pricing(1) * numqty.Value Else price = pricing(2) * numqty.Value End If ElseIf cbxcustomer.Text = "OEM" Then If numqty.Value < 5 Then price = pricing(3) * numqty.Value ElseIf numqty.Value < 25 Then price = pricing(4) * numqty.Value Else price = pricing(5) * numqty.Value End If ElseIf cbxcustomer.Text = "Reseller" Then If numqty.Value < 5 Then price = pricing(6) * numqty.Value ElseIf numqty.Value < 25 Then price = pricing(7) * numqty.Value Else price = pricing(8) * numqty.Value End If ElseIf cbxcustomer.Text = "Distributor" Then If numqty.Value < 5 Then price = pricing(9) * numqty.Value ElseIf numqty.Value < 25 Then price = pricing(10) * numqty.Value Else price = pricing(11) * numqty.Value End If End If lblquote.Text = "$" & price & ".00" Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try End Sub Private Sub calcpricing() Try If txtlistprice.Text <> Nothing And txtcost.Text <> Nothing Then If chkmotor.Checked = False Then 'grab the list value list = CSng(txtlistprice.Text) pricing(0) = list pricing(1) = RoundingRoutine(list, 0.95) pricing(2) = RoundingRoutine(list, 0.9) pricing(3) = RoundingRoutine(list, 0.9) pricing(4) = RoundingRoutine(list, 0.85) pricing(5) = RoundingRoutine(list, 0.8) pricing(6) = RoundingRoutine(list, 0.82) pricing(7) = RoundingRoutine(list, 0.8) pricing(8) = RoundingRoutine(list, 0.75) pricing(9) = RoundingRoutine(list, 0.65) pricing(10) = RoundingRoutine(list, 0.6) pricing(11) = 0.0 'populate the boxes normalpart = True populateboxes() Else If chkaccessory.Checked = True Then 'start accessory pricing normalpart = False list = CSng(txtlistprice.Text) pricing(0) = list pricing(1) = RoundingRoutine(list, 0.95) pricing(2) = RoundingRoutine(list, 0.95) pricing(3) = RoundingRoutine(list, 0.91) pricing(4) = RoundingRoutine(list, 0.89) pricing(5) = RoundingRoutine(list, 0.89) pricing(6) = RoundingRoutine(list, 0.91) pricing(7) = RoundingRoutine(list, 0.89) pricing(8) = RoundingRoutine(list, 0.89) pricing(9) = RoundingRoutine(list, 0.83) pricing(10) = RoundingRoutine(list, 0.8) pricing(11) = RoundingRoutine(list, 0.8) populateboxes() Else '**** BEGIN MOTOR DESCRIPTION BUILDING **** buildmotordescription() 'start motor pricing normalpart = False list = CSng(txtlistprice.Text) pricing(0) = list pricing(1) = roundingroutine(list, 0.95) pricing(2) = roundingroutine(list, 0.95) pricing(3) = roundingroutine(list, 0.9) pricing(4) = roundingroutine(list, 0.85) pricing(5) = roundingroutine(list, 0.85) pricing(6) = roundingroutine(list, 0.9) pricing(7) = roundingroutine(list, 0.85) pricing(8) = roundingroutine(list, 0.95) pricing(9) = roundingroutine(list, 0.8) pricing(10) = roundingroutine(list, 0.75) pricing(11) = roundingroutine(list, 0.75) populateboxes() End If End If End If Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try End Sub Private Sub buildmotordescription() Dim firsthash As Integer = 0 Dim secondhash As Integer = 0 Dim startpos As Integer = 0 Dim cursor As Integer = 0 Dim prodnum As String Dim tempchar As String = "" prodnum = IntrolProductNumberTextBox.Text '**** FIND THE FIRST HASH **** tempchar = prodnum.IndexOf("-") firsthash = tempchar tempchar = 0 '**** FIND THE SECOND HASH **** tempchar = prodnum.Substring(prodnum.IndexOf("-") + 1).IndexOf("-") secondhash = tempchar MessageBox.Show(firsthash.ToString) MessageBox.Show(secondhash.ToString) If firsthash Or secondhash = -1 Then MessageBox.Show("There was an issue with this product number, the description will not be built") Exit Sub End If End Sub Private Sub populateboxes() txtuser1.Text = CStr("$" & pricing(0) & ".00") txtuser2.Text = CStr("$" & pricing(1) & ".00") txtuser3.Text = CStr("$" & pricing(2) & ".00") txtoem1.Text = CStr("$" & pricing(3) & ".00") txtoem2.Text = CStr("$" & pricing(4) & ".00") txtoem3.Text = CStr("$" & pricing(5) & ".00") txtreseller1.Text = CStr("$" & pricing(6) & ".00") txtreseller2.Text = CStr("$" & pricing(7) & ".00") txtreseller3.Text = CStr("$" & pricing(8) & ".00") txtdistributor1.Text = CStr("$" & pricing(9) & ".00") txtdistributor2.Text = CStr("$" & pricing(10) & ".00") txtdistributor3.Text = CStr("$" & pricing(11) & ".00") If normalpart = True Then txtdistributor3.Text = "Call for Pricing" End If End Sub Private Sub txtlistprice_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtlistprice.TextChanged cleartextboxes() calcpricing() calcprice() End Sub Private Sub AccessoryCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkaccessory.CheckedChanged 'this ensures if Accessory checkbox is checked, the motor checkbox will also set to checked since accessories are 'accessories to motors and follow the motor logic structure in the pricing procedure. chkmotor.Checked = True End Sub Private Sub numqty_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles numqty.ValueChanged 'this recalculates a item-line quantity pricing for different users when the user changes the quanity 'the pricing calculation is fired again to reupdate the quote price. calcprice() End Sub Private Sub cbxcustomer_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxcustomer.SelectedIndexChanged 'this recalculates a item-line quantity pricing for different users when the user changes the status of a customer 'type the pricing calculation is fired again to reupdate the quote price. calcprice() End Sub Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click Try Me.taPricelist.FillByProductNumber(Me.dsIntrol.pricelist, ToolStripTextBox1.Text) cleartextboxes() calcpricing() calcprice() Catch ex As System.Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try End Sub Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click Try Me.taPricelist.FillByMotorNumber(Me.dsIntrol.pricelist, ToolStripTextBox1.Text) cleartextboxes() calcpricing() calcprice() Catch ex As System.Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try End Sub Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click Try Me.taPricelist.FillByDescription(Me.dsIntrol.pricelist, ToolStripTextBox1.Text) cleartextboxes() calcpricing() calcprice() Catch ex As System.Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try End Sub Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click Me.taPricelist.Fill(Me.dsIntrol.pricelist) End Sub Private Sub BindingNavigatorMoveNextItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorMoveNextItem.Click End Sub Private Sub btnnew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnew.Click 'TODO: This line of code loads data into the 'dsIntrol.Customers' table. You can move, or remove it, as needed. Me.taCustomers.Fill(Me.dsIntrol.Customers) Dim highquote As Long btnmake.Enabled = True btnnew.Enabled = False grpQuote.Enabled = True cnIntrol.Open() highquote = cmdGetQuoteNum.ExecuteScalar txtquotenum.Text = (highquote + 1).ToString cnIntrol.Close() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click My.Forms.Form2.ShowDialog() End Sub Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmake.Click TextBox19.Text = CType(txtquotenum.Text, String) btnadd.Enabled = True grpQuote.Enabled = False grpQuoteDetail.Enabled = True Me.taTestQuote.Fill(Me.dsIntrol.TestQuote) Dim drnewquote As DataRow drnewquote = dsIntrol.TestQuote.NewRow() drnewquote.Item("Customer") = cbxtradingname.Text drnewquote.Item("Address1") = TextBox3.Text + " " + TextBox4.Text drnewquote.Item("Address2") = TextBox4.Text drnewquote.Item("Address3") = TextBox5.Text + ", " + TextBox6.Text + " " + TextBox7.Text + " " + TextBox8.Text drnewquote.Item("City") = TextBox5.Text drnewquote.Item("State") = TextBox6.Text drnewquote.Item("Zip") = TextBox7.Text drnewquote.Item("Country") = TextBox8.Text drnewquote.Item("Quotenumber") = txtquotenum.Text drnewquote.Item("Quotedate") = DateTimePicker1.Text drnewquote.Item("Quoterep") = TextBox9.Text drnewquote.Item("Quoteshipdate") = TextBox2.Text drnewquote.Item("Quoteshipmethod") = ComboBox2.Text drnewquote.Item("Quotefob") = ComboBox3.Text drnewquote.Item("Quoteterms") = ComboBox1.Text dsIntrol.TestQuote.Rows.Add(drnewquote) Try Me.Validate() bsTestQuote.EndEdit() taTestQuote.Update(dsIntrol.TestQuote) Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try 'TODO: This line of code loads data into the 'dsIntrol.TestQuoteDetail' table. You can move, or remove it, as needed. 'Me.taTestQuoteDetail.Fill(Me.daTestQuoteDetail) Me.taTestQuoteDetail.FillBy(Me.dsIntrol.TestQuoteDetail, TextBox19.Text) End Sub Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click Try btnprint.Enabled = False btnPrint2.Enabled = False grpQuoteDetail.Enabled = True Dim drnew As DataRow drnew = dsIntrol.TestQuoteDetail.NewRow() drnew.Item("Partnumber") = IntrolProductNumberTextBox.Text.ToString() drnew.Item("Quotenumber") = TextBox19.Text.ToString() drnew.Item("Price") = CType(CType(price.ToString + ".0000", Short) / CType(numqty.Text.ToString, Short), String) + ".0000" drnew.Item("Quantity") = numqty.Text.ToString() drnew.Item("Description") = DescriptionTextBox.Text.ToString() drnew.Item("ExtPrice") = price.ToString() + ".0000" dsIntrol.TestQuoteDetail.Rows.Add(drnew) Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Try Me.Validate() bsTestQuoteDetail.EndEdit() daTestQuoteDetail.Update(dsIntrol.TestQuoteDetail) 'taTestQuoteDetail.Update(dsIntrol.TestQuoteDetail) btnprint.Enabled = True btnPrint2.Enabled = True Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprint.Click quotenumber = TextBox19.Text My.Forms.Form3.ShowDialog() End Sub Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint2.Click quotenumber = TextBox19.Text My.Forms.Form4.ShowDialog() End Sub Private Sub TestQuoteDetailDataGridView_CellBeginEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles TestQuoteDetailDataGridView.CellBeginEdit btnprint.Enabled = False btnPrint2.Enabled = False End Sub Private Sub TestQuoteDetailDataGridView_RowsRemoved(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowsRemovedEventArgs) Handles TestQuoteDetailDataGridView.RowsRemoved btnprint.Enabled = False btnPrint2.Enabled = False End Sub Private Sub TestQuoteDetailDataGridView_RowStateChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowStateChangedEventArgs) Handles TestQuoteDetailDataGridView.RowStateChanged btnprint.Enabled = False btnPrint2.Enabled = False End Sub End Class