+ All Categories
Home > Documents > 1 Northwind Traders Order Entry. 2 Northwind Traders Call Center Add an Order Entry capability to...

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

Date post: 28-Mar-2015
Category:
Upload: darien-burken
View: 229 times
Download: 3 times
Share this document with a friend
Popular Tags:
38
1 Northwind Traders Order Entry
Transcript
Page 1: 1 Northwind Traders Order Entry. 2 Northwind Traders Call Center Add an Order Entry capability to the Northwind Traders Call Center application. Start.

1

Northwind Traders Order Entry

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

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_Develo

pment/Downloads/Project_Solutions/ File P6_Select_Customer.zip

Expand .zip file Open solution

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

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

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

4

Add Order Entry Form

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

5

Order Entry Form

Double click on form to create Form Load event handler.

lblCurrentCustomer

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

6

Order Entry Form

private void Order_Entry_Form_Load(object sender, EventArgs e)

{

lblCurrentCustomer.Text =

"Order for customer: " +

Program.Selected_Customer.CompanyName;

}

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

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();

}

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

8

Enable Order Entry

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

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

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.

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

10

Order Entry Form

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

11

Order Entry Form

User will specify Product Category. Product Quantity

Click Submit or Cancel

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

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

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

13

Add New Data Source

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

14

New Data Source

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

15

Specify Connection

Click New Connection

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

16

Add New Connection

Click OK

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

17

Configuring the Data Source

Click Next

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

18

Configuring the Data Source

Click Next

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

19

Configuring the Data Source

Click Finish

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

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.

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

21

Add ComboBox

cbCategory

Set DataSource

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

22

Set DisplayMember and ValueMember

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

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;

}

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

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());

}

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

25

Program in Action

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

26

Product Selection

Now add a Dropdown List that offers just products of the selected category. Drag ComboBox from Toolbox. Don’t copy and paste the first ComboBox.

New ComboBox: cbProducts New Data Source: Table Products

ProductID ProductName

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

27

Product Selection

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

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.

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

29

Smart Tag Clicked

Click Add Query

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

30

New Query

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

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;

}

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

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.

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

33

Program in Action

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

34

Clean Up the Form

We don’t need the fillByCategoryToolStrip

Right click, Delete

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

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);

// }

//}

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

36

Program in Action

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

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);

}

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

38

Program in Action


Recommended