|
The Form design,
ProductForm.vb
1st
TabPage of TabControl control selected ... |
2nd
TabPage of TabControl control selected ... |
 |
 |
Create Visual Basic .Net Forn - ProductForm.vb
Classes used in this
Form: SqlConnection,
SqlDataAdapter, SqlCommand, DataSet, ImageList,
Label, TextBox, Button,
TabControl, ComboBox, ToolTip
1- Info about database used ...
SQL database - RBT
Table - product
Fields - prod_id,
type_cur, prod_name, quantity. cost_cur, unit_cost
and umit_price
2-
Create
the Form
ProductForm.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
ProductForm.vb
- Click Open
- In the windows
Forms Designer appears the empty window Form
design
|
|
1- |
The Form Properties -
ProductForm.vb |
|
Name: Backcolor: Icon:
Menu: Size: StartPosition: Text: WindowState: |
|
ProductForm Control Icon
false (none) 520,336 CenterScreen
Product... Normal | | |
2- |
The ProductForm.vb
design
1st page of
the TabControl control selected ...
From the Toolbox/Data add one SqlDataAdapter
control. and
from the Toolbox/Windows Form add these
controls .. Nine Label controls,
seven TextBox controls, seven Button
controls, one ComboBox control, one panel
control, one ToolTip control, one Tabcontrol control
and one ImageList control.
-
Add the SqlDataAdapter control,
SqlDataAdapter1
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
SqlDataAdapter
control ...
- 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 prod_id, type_cur,
prod_name, quantity, cost_cur, unit_cost, unit_price FROM product
ORDER BY prod_id (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="
.... |
|
right click the
SqlDataAdapter1 control, on
the shortcut menu click Generate Dataset ..., the
Generate Dataset dialog box appears:
Select the New radio button and in the box type ProductDSet.
New DataSet - ProductDSet.xsd added to the Solution
Explorer and new DataSet control - ProductDSet1 added
to the Form
design - ProductForm.vb
- Add the Label
control
- ldate, Properties:
Name:
Size:
Text: |
ldate
48,16
Today : |
|
- Add the TextBox
control
- txttdate, Properties:
Name:
Size: |
txttdate
184,20 |
|
- Add the TabControl
control
- TabControl1, Properties:
Name:
Size:
TabPages: |
TabControl1
496,272
(Collection) |
|
Add 2
pages to this
TabControl, when you click
Collection of TabPages property,
the TabPage Collection Editor dialog box
appears. In this Editor add 2
pages
Member |
BackColor |
Text |
Size |
TabPage1
TabPage2 |
Control
Control |
By Product
All Product |
488,246
488,246 |
|
- Add the Label
control
- lnote1, Properties:
Name:
Size:
Text: |
lnote1
224,16
After any Input, click 'DoubleClick mouse ' |
|
- Add the Button
control
- btnNavFirst, Properties:
Name:
ImageList:
ImageIndex:
Size: |
btnNavFirst
ImageList1
0
23,24 |
|
- Add the Button
control
- btnNavPrev, Properties:
Name:
ImageList:
ImageIndex:
Size: |
btnNavPrev
ImageList1
1
23,24 |
|
- Add the Button
control
- btnNavNext, Properties:
Name:
ImageList:
ImageIndex:
Size: |
btnNavNext
ImageList1
2
23,24 |
|
- Add the Button
control
- btnLast, Properties:
Name:
ImageList:
ImageIndex:
Size: |
btnLast
ImageList1
3
23,24 |
|
- Add the Button
control
- btnAdd, Properties:
Name:
ImageList:
ImageIndex:
Size: |
btnAdd
ImageList1
4
23,24 |
|
- Add the Button
control
- btn,Update Properties:
Name:
ImageList:
ImageIndex:
Size: |
btnUpdate
ImageList1
5
23,24 |
|
- Add the Button
control
- btnclose, Properties:
Name:
ImageList:
ImageIndex:
Size: |
btnclose
ImageList1
6
23,24 |
|
- Add the Panel
control
- Panel1, Properties:
- Add the Label
control
- lblNavLocation, Properties:
Name:
Size:
Text: |
lblNavLocation
95,16
No Records |
|
- Add the ComboBox
control
- cmbcurrency, Properties:
DataBindings
Text:
Name:
Size: |
ProductDSet1 - product.type_cur
cmbcurrency
240,21 |
|
- Add the TextBox
control
- txtId, Properties:
DataBindings
Text:
Name:
Size: |
ProductDSet1 - product.prod_id
txtId
240,21 |
|
- Add the TextBox
control
- txtname, Properties:
DataBindings
Text:
Name:
Size: |
ProductDSet1 - product.prod_name
txtname
240,21 |
|
- Add the TextBox
control
- txtquantity, Properties:
DataBindings
Text:
Name:
Size: |
ProductDSet1 - product.quantity
txtquantity
240,21 |
|
- Add the TextBox
control
- txtcostcur, Properties:
DataBindings
Text:
Name:
Size: |
ProductDSet1 - product.cost_cur
txtcostcur
240,21 |
|
- Add the TextBox
control
- txtunitcost, Properties:
DataBindings
Text:
Name:
Size: |
ProductDSet1 - product.txtunit_cost
txttxtunitcost
240,21 |
|
- Add the ComboBox
control
- txtunitprice, Properties:
DataBindings
Text:
Name:
Size: |
ProductDSet1 - product.unit_price
txtunitprice
240,21 |
|
- Add the Label
control
- Labels_0, Properties:
Name:
Size:
Text: |
Labels_0
90,17
Product Id: |
|
- Add the Label
control
- Labels_1, Properties:
Name:
Size:
Text: |
Labels_1
90,17
Type Currency: |
|
- Add the Label
control
- Labels_2, Properties:
Name:
Size:
Text: |
Labels_2
90,17
Product Name: |
|
- Add the Label
control
- Labels_3, Properties:
Name:
Size:
Text: |
Labels_3
90,17
Quantity: |
|
- Add the Label
control
- Labels_4, Properties:
Name:
Size:
Text: |
Labels_4
90,17
Unit Cost (cur): |
|
- Add the Label
control
- Labels_5, Properties:
Name:
Size:
Text: |
Labels_5
90,17
Unit Cost $: |
|
- Add the Label
control
- Labels_6, Properties:
Name:
Size:
Text: |
Labels_6
90,17
Unit Price $: |
|
- 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, New.bmp, Save.bmp and
Close.bmp
And
then click OK
- Add the ToolTip
control
- ToolTip
2nd page of
the TabControl control selected ...
From the Toolbox/Windows Form add
one DataGrid control
- Add the DataGrid
control
- DataGrid1, Properties:
Name: DataMember:
DataSourse: Size: Table Styles: |
DataGrid1
product ProductDSet
472,216
(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: |
DataGridTableStyle1
(Collection)
product |
|
|
|
when you click
Collection of GridColumnStyles property,
the DataGridColumnStyles Collection Editor dialog box
appears. In this Editor add 5
DataGridTextBoxColumns
Members pane
|
DataGridTextBoxColumn1/2/3/4/5 Properties
|
DataGridTextBoxColumn1 |
Header
|
Width
|
MappingName
|
Product Id |
75 |
prod_id |
|
DataGridTextBoxColumn2 |
Header |
Width
|
MappingName
|
Currency |
75 |
type_cur |
|
DataGridTextBoxColumn3 |
Header
|
Width
|
MappingName
|
Name |
115 |
prod_name |
|
DataGridTextBoxColumn4 |
Header
|
Width
|
MappingName
|
Quantity |
75 |
quantity |
|
DataGridTextBoxColumn5 |
Header |
Width
|
MappingName
|
Unit Price |
75 |
unit_price |
|
|
Click Ok. And then click
Ok. New Columns display in the
DataGrid control
|
|
|
|
The codes
...
|
|