|
The Form design,
SalesForm.vb - Master Detail type
Create Visual Basic .Net Forn - SalesForm.vb
Classes used in this
Form: SqlConnection,
SqlDataAdapter, SqlCommand, DataSet, ImageList,
Label, TextBox, Button,
DataGrid, ComboBox,
ToolTip and DateTimePicker
1- Info about database
used
...
SQL database -
RBT
Tables - ord_sales and it_sales, (Master-details)
Fields of 1st table -
ord_inv, ord_date, type_cur, val_ll, child_ref, desc_name, dlv_name,
disc_cur, total_cur,
old_bal_cur, new_bal_cur and notes
Fields
of 2nd table -
ord_inv, prod_id, prod_name, quantity, unit_price and extension2- Create the Form
SalesForm.vb
- On the View
menu , click Solution Explorer
- In Solution
Explorer, right click the RBT Accounting Net,
select Add on the shortcut menu to open other
shortcut menu, click Add New Item, the Add
New Item - RBT Accounting Net dialog box appears.
- In the Add
New Item -RBT Accounting Net dialog box:
- In the
Categories pane, select Local Project
Items
- In the Templates
pane, select Windows form . A message
appears - (a form for Windows Applications).
- In the Name
box, type SalesForm.vb
- Click
Open
- In the
windows Forms Designer appears the empty window
Form design
|
|
1- |
The Form Properties -
SalesForm.vb
|
|
Name: Backcolor: Icon:
MaximizeBox Menu: Size: StartPosition: Text: WindowState: |
|
SalesForm Control Icon false (none)
608,432 CenterScreen
SalesForm
Normal | | |
2- |
The SalesForm.vb
design
From
the
Toolbox/Data add two SqlDataAdapter
controls
and from the
Toolbox/Windows Form add these controls
..
Forteen Label controls,
thirteen
TextBox controls, five Button controls, one
ComboBox control, four panel controls, one
ToolTip control, one DataGrid control
and one ImageList control.
- Add two SqlDataAdapter controls
Represents
a set of data commands and a database connection that are
used to fill the DataSet and update a SQL
Server database The SqlDataAdapter, serves as a
bridge between a DataSet and SQL Server for
retrieving and saving data.
From the
Toolbox/Data add two SqlDataAdapter
control
...
- Add 1st SqlDataAdapter control,
SqlDataAdapter1
- The Data
Adapter Configuration Wizard dialog box appears,
click Next
- New Data
Adapter Configuration Wizard dialog box
appears, click New Connection ... The
Data Link Properties dialog box
appears:
- In
Provider Tab, select Microsoft OLE DB
Provider for SQL Server
- In
Connection Tab, type or select your
server name in the Select or enter a server
name combobox
- Select
the Use Windows NT Integrated security
radio button
- Select
the Select the database file as a
database name radio button and from the
combobox select RBT
- Click
Ok.
|
In the
Which data a connection ... combobox display
the names of the server and the database. Click
Next.
- New Data
Adapter Configuration Wizard dialog box appears,
select the Use SQL Statements radio button,
click Next.
- New Data
Adapter Configuration Wizard dialog box appears,
in the what data should ... box
type SELECT ord_inv, ord_date, type_cur,
val_ll, child_ref, desc_name, dlv_name, disc_cur,
total_cur, old_bal_cur, new_bal_cur, notes FROM
ord_sales (or click
Query Builder ...), click Next.
- New Data
Adapter Configuration Wizard dialog box
appears, click Finish. new
SqlConnection control - SqlConnection1 added to this
Form
The
SqlDataAdapter1 Properties:
Name:
DeleteCommand
InsertCommand:
SelectCommand:
UpdateCommand: |
SqlDataAdapter1
SqlDeleteCommand1
SqlInsertCommand1
SqlSelectCommand1
SqlUpdateCommand, |
|
The
SqlConnection1 Properties:
Name:
ConnectionString |
SqlConnection1
workstation id="
.... |
|
|
- Add 2nd SqlDataAdapter control,
SqlDataAdapter2
- The Data
Adapter Configuration Wizard dialog box appears,
click Next
- New Data
Adapter Configuration Wizard dialog box
appears, click New Connection ... The
Data Link Properties dialog box
appears:
- In
Provider Tab, select Microsoft OLE DB
Provider for SQL Server
- In
Connection Tab, type or select your
server name in the Select or enter a server
name combobox
- Select
the Use Windows NT Integrated security
radio button
- Select
the Select the database file as a
database name radio button and from the
combobox select RBT
- Click
Ok.
|
In the
Which data a connection ... combobox display
the names of the server and the database. Click
Next.
- New Data
Adapter Configuration Wizard dialog box appears,
select the Use SQL Statements radio button,
click Next.
- New Data
Adapter Configuration Wizard dialog box appears,
in the what data should ... box
type SELECT ord_inv, prod_id, prod_name,
quantity, unit_price, extension FROM it_sales (or click
Query Builder ...), click Next.
- New Data
Adapter Configuration Wizard dialog box
appears, click Finish. new
SqlConnection control - SqlConnection1 added to this
Form
The
SqlDataAdapter2 Properties:
Name:
SelectCommand: |
SqlDataAdapter2
SqlSelectCommand1 |
|
This
DataAdapter use the previous SqlConnection
created SqlConnection1
|
|
Generate Dataset corresponding
to the two
SqlDataAdapter
controls created
- Right click the
SqlDataAdapter1, on the
shortcut menu click Generate Dataset ..., the
Generate Dataset dialog box appears:
Select the New radio
button and in the box type salesdset., and then click
Ok
New
DataSet - salesdset1.xsd added to the Solution
Explorer and new DataSet control - salesdset1
added to the Form design -
salesForm.vb
- Right click the
SqlDataAdapter2 , on the
shortcut menu click Generate Dataset ..., the
Generate Dataset dialog box appears:
Select the Existing radio
button and from combobox select
RBT_Accounting_Net.salesdset and then click
Ok
|
- Add
Forteen Label controls, Properties:
Order
|
Name |
Text |
1
2
3
4
5
6
7
8
9
10
11
12
13
14 |
Labelinvoice
Labelinvdate
Labelcurrency
LabelAcct
Labelname
Labeldelivery
Label6
Label3
Label2
Label5
Label1
Label7
Labelnotes
lblNavLocation |
Invoice
Order
Invoice Date
Currency
Account
Name
Delivery
Total
Discount
General Total
General Total, LL
New Balance
Old Balance
Notes |
|
- Add
thirteen TextBox
controls, Properties:
Order
|
Name
|
DataBindings - Text |
Size |
1
2
3
4
5
6
7
8
9
10
11
12
13 |
editord_inv
editord_date
edittype_cur
editval_ll
editdesc_name
editdlv_name
edittotal
editdiscount
editGtotal
editGtotalll
editnewval
editoldval
editnotes |
salesdset1 -
ord_sales.ord_inv
salesdset1 - ord_sales.ord_date
salesdset1 - ord_sales.type_cur
salesdset1 - ord_sales.val_ll
salesdset1 - ord_sales.desc_name
salesdset1 - ord_sales.dlv_name
salesdset1 - ord_sales.disc_cur
salesdset1 - ord_sales.total_cur
salesdset1 - ord_sales.new_bal_cur
salesdset1 - ord_sales.old_bal_cur
salesdset1 - ord_sales.notes |
100, 20
100, 20
100, 20
48,20
227, 20
227, 20
114, 20
114, 20
114, 20
114, 20
120, 20
120, 20
192, 80 |
|
- Add the ImageList
control - ImageList1,
Properties:
Name:
Images:
ImageSize:
TransparentColor: |
ImageList1
(Collection)
16,16
Transparent |
|
Add image
to this ImageList: When you click
Collection of Images property, the
Image Collection Editor dialog box
appears. In
this Editor dialog click Add, the Open
Dialog box appears In the Open dialog,
display list of files stored in the folder c:\RBT
Accounting Net\pic In the Filename combo box
type First.bmp In the Files Type combo box
choose All image ... and then click
Open Automatically, lists of information display
in the Image Collection Editor dialog box Repeat this
operation to be add the following bmp files: Prev.bmp,
Next.bmp, Last.bmp and
Close.bmp And then click OK
- Add five Button
controls, Properties:
Order |
Name |
ImageList |
ImageIndex |
Size
|
1
2
3
4
5 |
btnNavFirst
btnNavPrev
btnNavNext
btnLast
btnclose |
ImageList1
ImageList1
ImageList1
ImageList1
ImageList1 |
0
1
2
3
4 |
23,24
23,24
23,24
23,24
23,24 |
|
1
- Add four Panel
controls ,
Properties:
Order |
Name
|
1
2
3
4 |
Frame3
Frame2
picStatBox
picButtons |
|
1
- Add the ComboBox
control - cmbAcct,
Properties:
DataBindings
Text: Name: Size: |
salesdset1 -
ord_sales.child_ref cmbAcct 227,22 | |
- Add the ToolTip
control - ToolTip1,
Properties:
- Add the DataGrid
control -grdit_sales,
Properties:
Name: DataMember: DataSourse: Size: Table
Styles: |
grdit_sales it_sales
salesdset1 576, 160 (Collection) | |
when you click
Collection of Table Styles property, the
DataGridTableStyle Collection Editor dialog box
appears. In this Editor, click Add. - ( add 1
DataGridTableStyle)
Members
pane |
DataGridTableStyle1
Properties |
DataGridTableStyle1 |
Name: GridColumnStyles: MappingName: |
objTableStylegrdit_salesit_sales (Collection)
it_sales | | | |
when you click
Collection of
GridColumnStyles property, the
DataGridColumnStyles Collection
Editor dialog box appears. In this Editor add
5
DataGridTextBoxColumns
Members
pane |
DataGridTextBoxColumns
Properties |
objColumnStylegrdit_salesprod_id |
Header |
Width |
MappingName |
Product
Id |
75 |
prod_id | |
objColumnStylegrdit_salesprod_name |
Header |
Width |
MappingName |
Product
name |
140 |
prod_name | |
objColumnStylegrdit_salesquatity |
Header |
Width |
MappingName |
Quantity |
75 |
quantity | |
objColumnStylegrdit_salesunit_price |
Header |
Width |
MappingName |
Unit Price |
115 |
unit_price | |
objColumnStylegrdit_salesextension |
Header |
Width |
MappingName |
Extension |
115 |
extension | | |
Click Ok.
And then click Ok. New
Columns display in the DataGrid
control |
|
| |
The codes ...
|
|