Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Northwind Traders Order Entry. 2 Northwind Traders Call Center Add an Order Entry capability to the Northwind Traders Call Center application. Start.

Similar presentations


Presentation on theme: "1 Northwind Traders Order Entry. 2 Northwind Traders Call Center Add an Order Entry capability to the Northwind Traders Call Center application. Start."— Presentation transcript:

1 1 Northwind Traders Order Entry

2 2 Northwind Traders Call Center Add an Order Entry capability to the Northwind Traders Call Center application. Start with the solution for Project 6 Select Customer http://www.cse.usf.edu/~turnerr/Software_Systems_Development/ Downloads/Project_Solutions/ File P6_Select_Customer.zip http://www.cse.usf.edu/~turnerr/Software_Systems_Development/ Downloads/Project_Solutions/ Expand.zip file Open solution

3 3 Add Button to Home Form Enter New Order will be enabled only when a customer is selected. Brings up new Order Entry form. btnEnterOrder

4 4 Add Order Entry Form

5 5 Order Entry Form Double click on form to create Form Load event handler. lblCurrentCustomer

6 6 Order Entry Form private void Order_Entry_Form_Load(object sender, EventArgs e) { lblCurrentCustomer.Text = "Order for customer: " + Program.Selected_Customer.CompanyName; }

7 7 Enter New Order Add code to Home form to show Order_Entry_Form. private void btnEnterOrder_Click(object sender, EventArgs e) { Order_Entry_Form f = new Order_Entry_Form (); this.Hide(); f.ShowDialog(); this.Show(); }

8 8 Enable Order Entry In Home Form, enable Enter Order button if, and only if, there is a selected customer.

9 9 Home_Form.cs private void btnSelectCustomer_Click(object sender, EventArgs e) { Select_Customer_Form sc = new Select_Customer_Form(); this.Hide(); sc.ShowDialog(); this.Show(); btnEnterOrder.Enabled = Program.Customer_Selected; if (Program.Customer_Selected) { Customer c = Program.Selected_Customer; tbSelectedCustomer.Text = c.CompanyName; } else { tbSelectedCustomer.Text = "No Customer Selected"; } Build and run.

10 10 Order Entry Form

11 11 Order Entry Form User will specify Product Category. Product Quantity Click Submit or Cancel

12 12 Specifying the Product Use a data bound Dropdown list on the Order Entry form to select Product Category. Add and configure data source. Data > Add New Data Source Table Categories Display: CategoryName Value: CategoryID

13 13 Add New Data Source

14 14 New Data Source

15 15 Specify Connection Click New Connection

16 16 Add New Connection Click OK

17 17 Configuring the Data Source Click Next

18 18 Configuring the Data Source Click Next

19 19 Configuring the Data Source Click Finish

20 20 Binding the Data Source We have the data source. Now add a dropdown list (ComboBox) cbCategory Bind it to the data source. Details on following slides.

21 21 Add ComboBox cbCategory Set DataSource

22 22 Set DisplayMember and ValueMember

23 23 Set Connection String Set the connection string for the new Data Source. private void Order_Entry_Form_Load(object sender, EventArgs e) { this.categoriesTableAdapter.Connection.ConnectionString = "server=scorpius.eng.usf.edu; " + "User=" + Program.Username + "; " + "Password=" + Program.Password; // TODO: This line of code loads data into the 'dataSet3.Categories' // table. You can move, or remove it, as needed. this.categoriesTableAdapter.Fill(this.dataSet3.Categories); lblCurrentCustomer.Text = "Order for customer: " + Program.Selected_Customer.CompanyName; }

24 24 Add Event Handler Add an event handler for Selected Index Changed in the Categories ComboBox. Double click on the ComboBox. private void cbCategory_SelectedIndexChanged(object sender, EventArgs e) { MessageBox.Show(cbCategory.SelectedValue.ToString()); }

25 25 Program in Action

26 26 Product Selection Now add a Dropdown List that offers just products of the selected category. Drag ComboBox from Toolbox. Dont copy and paste the first ComboBox. New ComboBox: cbProducts New Data Source: Table Products ProductID ProductName

27 27 Product Selection

28 28 Add Query for Products Note productsTableAdapter Responsible for filling DataSet Click on cbProducts to select it. Click on smart tag (upper right corner) and select Add Query Will specify the query that will be used by the productsTableAdapter to fill the data set that is bound to the Products ComboBox.

29 29 Smart Tag Clicked Click Add Query

30 30 New Query

31 31 Set Connection String private void Order_Entry_Form_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the... this.productsTableAdapter.Connection.ConnectionString = "server=scorpius.eng.usf.edu; " + "User=" + Program.Username + "; " + "Password=" + Program.Password; this.productsTableAdapter.Fill(this.productsDataSet.Products); this.categoriesTableAdapter.Connection.ConnectionString = "server=scorpius.eng.usf.edu; " + "User=" + Program.Username + "; " + "Password=" + Program.Password; this.categoriesTableAdapter.Fill(this.dataSet3.Categories); lblCurrentCustomer.Text = "Order for customer: " + Program.Selected_Customer.CompanyName; }

32 32 Update cbCategory Event Handler private void cbCategory_SelectedIndexChanged(object sender, EventArgs e) { //MessageBox.Show(cbCategory.SelectedValue.ToString()); int category_id = (int)cbCategory.SelectedValue; this.productsTableAdapter.FillByCategory(this.productsDataSet.Products, category_id); cbProducts.Enabled = true; } Whenever a new category is selected, the Products table in ProductsDataSet will be refilled using the FillByCategory query.

33 33 Program in Action

34 34 Clean Up the Form We dont need the fillByCategoryToolStrip Right click, Delete

35 35 Delete Event Handler Delete event handler for fillbyCategoryToolStripButton //private void fillByCategoryToolStripButton_Click(object sender // EventArgs e) //{ // try // { //... // } // catch (System.Exception ex) // { // System.Windows.Forms.MessageBox.Show(ex.Message); // }

36 36 Program in Action

37 37 Add Event Handler Double click on cbProduct to add an event handler. private void cbProduct_SelectedIndexChanged(object sender, EventArgs e) { MessageBox.Show(cbProducts.Text); }

38 38 Program in Action


Download ppt "1 Northwind Traders Order Entry. 2 Northwind Traders Call Center Add an Order Entry capability to the Northwind Traders Call Center application. Start."

Similar presentations


Ads by Google