In this exercise, you create an application that keeps track of cookie sales. Create a Windows Forms application. Use the following names for the project and solution, respectively: Cookies Project and Cookies Solution. Save the application in the VB2017\Chap11 folder. Figure 11-59 shows the Sales table contained in the VB2017\Chap11\Databases\Cookies.mdf file. The table contains the numbers of boxes of cookies sold in each of three weeks. The Week field is an auto-numbered field. Open the Data Sources window and click Add New Data Source to start the Data Source Configuration Wizard. Connect the Cookies.mdf file to the application. Include the entire Sales table in the dataset. Set the Cookies.mdf file’s Copy to Output Directory property to “Copy if newer”. Display the dataset information in a DataGridView control and then make the necessary modifications to the control. Enter an appropriate Try...Catch statement in the SalesBindingNavigatorSaveItem_Click procedure. Save the solution and then start the application. Change the Chocolate Chip cookie sales in Week 1 to 205. Then, enter the following record for Week 4: 150, 112, and 76. Save the changes. Stop the application and then start it again to verify that the changes you made were saved. Option Explicit On Option Strict On Option Infer Off Imports System.Data.sqlclient Public Class form1     Dim con As sqlconnection     Dim da As sqldataadapter     Dim cmd As sqlcommand     Dim ds As dataset     Private Sub form1_load(sender As Object, e As EventArgs) Handles MyBase.load         salesbindingnavigation()     End Sub     Sub salesbindingnavigation()         con = New sqlconnection("data source=(localdb)/v11.0;attachdbfilename=" +       application.startuppath + "/cockies.mdf;integrated security = true; connect timeout = 30")         con.open()         da = New sqldataadapter("select * from sales", con)         ds = New dataset         da.fill(ds, "sales")         dgvsales.datasource = ds.tables(0)     End Sub     Private Sub dgvsales_rowenter(sender As Object, e As datagridviewcelleventargs) Handles             dgvsales.rowenter     End Sub     Private Sub dgvsales_click(sender As Object, e As EventArgs) Handles dgvsales.click         Try             Dim n1 As String = dgvsales.rows(dgvsales.CurrnetRow.index).cells(1).value             Dim n2 As String = dgvsales.rows(dgvsales.CurrnetRow.index).cells(2).value             Dim n3 As String = dgvsales.rows(dgvsales.CurrnetRow.index).cells(3).value             cmd = New SqlCommand("insert into [sales] values(NEXT VALUE FOR Week_seq," + n1 + "," + n2 + "," + n3 + ")", con)             cmd.ExecuteNonQuery()             salesbindingnavigation()             MsgBox("inserted")         Catch ex As Exception         End Try     End Sub End Class Public Class frmMain     Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click         Me.Close()     End Sub End Class

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In this exercise, you create an application that keeps track of cookie sales. Create a Windows Forms application. Use the following names for the project and solution, respectively: Cookies Project and Cookies Solution. Save the application in the VB2017\Chap11 folder.

  1. Figure 11-59 shows the Sales table contained in the VB2017\Chap11\Databases\Cookies.mdf file. The table contains the numbers of boxes of cookies sold in each of three weeks. The Week field is an auto-numbered field. Open the Data Sources window and click Add New Data Source to start the Data Source Configuration Wizard. Connect the Cookies.mdf file to the application. Include the entire Sales table in the dataset.
  2. Set the Cookies.mdf file’s Copy to Output Directory property to “Copy if newer”.
  3. Display the dataset information in a DataGridView control and then make the necessary modifications to the control.
  4. Enter an appropriate Try...Catch statement in the SalesBindingNavigatorSaveItem_Click procedure.
  5. Save the solution and then start the application. Change the Chocolate Chip cookie sales in Week 1 to 205. Then, enter the following record for Week 4: 150, 112, and 76. Save the changes.
  6. Stop the application and then start it again to verify that the changes you made were saved.

Option Explicit On
Option Strict On
Option Infer Off

Imports System.Data.sqlclient
Public Class form1
    Dim con As sqlconnection
    Dim da As sqldataadapter
    Dim cmd As sqlcommand
    Dim ds As dataset

    Private Sub form1_load(sender As Object, e As EventArgs) Handles MyBase.load
        salesbindingnavigation()
    End Sub
    Sub salesbindingnavigation()
        con = New sqlconnection("data source=(localdb)/v11.0;attachdbfilename=" +
      application.startuppath + "/cockies.mdf;integrated security = true; connect timeout = 30")
        con.open()
        da = New sqldataadapter("select * from sales", con)
        ds = New dataset
        da.fill(ds, "sales")
        dgvsales.datasource = ds.tables(0)
    End Sub
    Private Sub dgvsales_rowenter(sender As Object, e As datagridviewcelleventargs) Handles
            dgvsales.rowenter
    End Sub
    Private Sub dgvsales_click(sender As Object, e As EventArgs) Handles dgvsales.click
        Try
            Dim n1 As String = dgvsales.rows(dgvsales.CurrnetRow.index).cells(1).value
            Dim n2 As String = dgvsales.rows(dgvsales.CurrnetRow.index).cells(2).value
            Dim n3 As String = dgvsales.rows(dgvsales.CurrnetRow.index).cells(3).value
            cmd = New SqlCommand("insert into [sales] values(NEXT VALUE FOR Week_seq," + n1 + "," + n2 + "," + n3 + ")", con)
            cmd.ExecuteNonQuery()
            salesbindingnavigation()
            MsgBox("inserted")
        Catch ex As Exception

        End Try

    End Sub
End Class


Public Class frmMain
    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub
End Class

Week
Chocolate Chip
Peanut Butter
Pecan Sandies
1
200
150
75
185
170
100
3
165
160
120
2.
Transcribed Image Text:Week Chocolate Chip Peanut Butter Pecan Sandies 1 200 150 75 185 170 100 3 165 160 120 2.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 6 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY