Rapid Application Development With Visual Studio

30
http://www.cynics-soft.com Rapid Application Development With Visual Studio Unleash The True Power of Visual Studio Kok Choon 6/11/2008

description

Learn how to write VB dot net code without even coding! Many developer still hard code their software, I am drawing, drag and drop the designer to create my software!

Transcript of Rapid Application Development With Visual Studio

Page 1: Rapid Application Development With Visual Studio

http://www.cynics-soft.com

Rapid Application Development With Visual Studio Unleash The True Power of Visual Studio

Kok Choon 6/11/2008

Page 2: Rapid Application Development With Visual Studio

Rapid Application Development with Visual Studio™

© Kok Choon, All Rights Reserved Worldwide. http://www.cynics-soft.com 2 | P a g e

Important Information: You may distribute this book to anyone without modifying the content, all links and information must be remain in its’ original. Thank you for your attention!

7B

“Rapid Application Development with Visual Studio ™” is a worldwide-protected publication of © Kok Choon and www.cynics-soft.com.

ALL RIGHTS RESERVED

No part of this course (content) may be reproduced or transmitted in any form whatsoever, electronic, or mechanical, including photocopying, recording, or by any informational storage or retrieval system without expressed written, dated and signed permission from the author.

DISCLAIMER AND / OR LEGAL NOTICES

The information presented herein represents the views of the author as of the date of publication. Because of the rate with which conditions change, the author reserves the rights to alter and update his opinions based on the new conditions.

This course is for informational purposes only and the author does not accept any responsibilities for any liabilities resulting from the use of this information.

While every attempt has been made to verify the information provided here, the author and his referrals cannot assume any responsibility for errors, inaccuracies or omissions. Any slights of people or organizations are unintentional.

Page 3: Rapid Application Development With Visual Studio

Rapid Application Development with Visual Studio™

© Kok Choon, All Rights Reserved Worldwide. http://www.cynics-soft.com 3 | P a g e

Contents A Word from the Author… ......................................................................................................................... 4

Before Start… ............................................................................................................................................ 6

Create the Project and Data Sources ........................................................................................................ 6

Draw controls to forms instead of coding ................................................................................................. 13

Unleash the Power of Dataset Designer .................................................................................................. 16

Hierarchical Update with Visual Studio 2008 ........................................................................................... 23

Useful Resources .................................................................................................................................... 30

Page 4: Rapid Application Development With Visual Studio

Rapid Application Development with Visual Studio™

© Kok Choon, All Rights Reserved Worldwide. http://www.cynics-soft.com 4 | P a g e

A Word from the Author…

Dear Valued Reader,

Welcome to Rapid Application Development with Visual Studio™!

This book is design to assist you in developing application with Visual Studio RAD technology.

Many developers still using conventional coding method introduced in VB 6, while these methods are effective in the old days, but the new and powerful Visual Studio 2005 and 2008 provides even more efficient programming tools – The RAD Dataset designer and components.

Conventional programmer will code their way to the end of the project, but new Visual Studio 2005 and 2008 allows developer to “drag and draw” their application from start till the end! They call it Rapid Application Development. Programmer from Borland Delphi in the old days already familiar with RAD programming, but until Microsoft replaced them with the powerful Dataset Designer, Form Designer and other visual tools, most of them switch to Visual Studio, and I am one of the Delphi developers.

From my experience with Visual Studio 2005, you can write code 500% faster than another conventional programmer with the help of visual inheritance, form designer and dataset designer. Some developer still relied on code generation tools such as CodeSmith to generate Insert, Update and Delete stored procedure for SQL server, and certainly data access code in Visual Studio!

The biggest problem for RAD programming not common between Visual Studio 2005 developers is lack of documentation and tutorial… and VS2008 has improved this weakness. Now you can find lots of video tutorial and web demos showing you how to code your software in RAD style; I predict the RAD programming will be become very popular in the next 3 years.

RAD will work very well because its’ utility has become to mature through the time, and developer can lower the development cost and deliver the project faster. If you don’t believe me, try it yourself, compare the “coding style” and “drawing style”, definitely you will agree with me that: Let the tools code for you always the fastest way.

For your information: Visual Studio 2008 added many cool features, you can now do 3-tier programming easier than before! and the Microsoft Synchronization framework for ADO.Net brings RAD into offline application; You can use the software offline and upload any pending updates that you make during offline into the server by batch, very cool feature! And the best part, you can do that RAD all the way…

I

Page 5: Rapid Application Development With Visual Studio

Rapid Application Development with Visual Studio™

hope this book can bring the new age programming into your existing skills, we can expect to see more tools coming from Microsoft in the near future.

While all efforts are done to make this book perfect, inevitably there might be technical mistakes or editing errors, please feel free to contact the author at [email protected] for comment and questions, I will try to revise the book and answer your question as soon as possible.

Thanks for your generous support, look forward to your feedback!

Warmest Regards,

CYNICS SOFTWARE www.cynics-soft.com

© Kok Choon, All Rights Reserved Worldwide. http://www.cynics-soft.com 5 | P a g e

Page 6: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

B

Ybo

U

C

Fi

Fi

©

Before Sta

ou need to dook, and foll

nless you al

Create the

igure 1

igure 2

© Kok Choo

art…

download thow the reso

lready instal

e Project

n, All Rights

e Northwindurces links t

led the Nort

and Data

s Reserved W

d sample datto create the

hwind datab

a Sources

Worldwide. h

tabase from e sample No

base, you ca

s

http://www.c

Microsoft worthwind DB

website or gobefore proce

o to the end oeed.

an skip this s

Creaandsave

YouForm

cynics-soft.co

step.

ate new proj then Windoe the project

u should be am1.vb.

om 6

ject, select Wows Forms At as RADDe

able to see t

of this

Windows Application, mo.

the

6 | P a g e

Page 7: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

Fi

Fi

©

igure 3

igure 4

© Kok Choon, All Rightss Reserved WWorldwide. hhttp://www.c

Now“Shosho

YoupanSou

cynics-soft.co

w, go to the mow Data Sourtcut key “Sh

ur should seeel, click on “

urce…”.

menu, selecurces” or usehift+Alt+D”.

e the “Data S“Ad New Dat

ct “Data” -> e the

Sources” ta

om 7 | P a g e

Page 8: Rapid Application Development With Visual Studio

Rapid Application Development with Visual Studio™

Figure5

Then select Database and click Next.

© Kok Choon, All Rights Reserved Worldwide. http://www.cynics-soft.com 8 | P a g e

Page 9: Rapid Application Development With Visual Studio

Rapid Application Development with Visual Studio™

Figure 6

Select your server name, click refresh to drop down. If you don’t see it, just key in your pc-name\sqlexpress. In the “Select or enter a database name:”, select Northwind.

© Kok Choon, All Rights Reserved Worldwide. http://www.cynics-soft.com 9 | P a g e

Page 10: Rapid Application Development With Visual Studio

Rapid Application Development with Visual Studio™

Figure 7

Select the correct connection and then press “Next”.

Figure 8

Use the default connection name or enter your own.

© Kok Choon, All Rights Reserved Worldwide. http://www.cynics-soft.com 10 | P a g e

Page 11: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

Fi

Fi

©

igure 9

igure 10

© Kok Choon, All Rights RReserved WWorldwide. htttp://www.cy

Fromandjust

4

Youthe objedowcontfield

ynics-soft.com

m here, you procedure nselect: 1. Custome2. Employe3. Order D4. Orders 5. Products

u can see VisNorthWindD

ect access awn each tabletrol to bind f

ds…

can select tneed. In this

ers ees etails

s

sual Studio cDataset for yre here, youe and fields,for the table

the tables s example,

created you, all u can drop select the and

m 11 | P a g e

Page 12: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

Fi

©

igure 11

© Kok Choon, All Rights R

Reserved WWorldwide. htttp://www.cy

Now ClicseleEmp ** A“Co

ynics-soft.com

w, select Ord

ck the drop dect “Combobployee ID.

Also change mbobox”.

ders, Employ

down combobox” to be as

CustomerID

yeeID.

and ssign to

D to

m 122 | P a g e

Page 13: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

D

InDFi

Fi

©

Draw cont

n this sectionesigner. Visields.

igure 12

© Kok Choon

trols to fo

n, you will leasual Studio h

, All Rights R

orms inste

arn how to dhas powerful

Reserved W

ead of co

drag and dro tools in the

Worldwide. ht

oding

op the controData Sourc

ttp://www.cy

ols from Dataces Panel, yo

a Sources inou can assig

nto the Windgn all control

Aftethe Thisform

ynics-soft.com

er that, selecDataGridVie

s will allow Om with contro

m 1

ct Orders andew to Details

Orders to drools assign in

dows Form ls to the

d change s.

op into the the fields.

3 | P a g e

Page 14: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

Fi

Fi

©

igure 13

igure 14

© Kok Choon, All Rights RReserved WWorldwide. htttp://www.cy

NowData If yoEmpgo binstr

AfteshoEmpfrom DragSou DragSou

ynics-soft.com

w drag and daSources in

ou do not seployee ID wiback to Figuructed.

er Drag the Ould assign Cployee ID co

m which table

g Customer urces into Cu

g Employeeurces into Em

drop Orders to the form.

e Customer ith combobore 11 and re

Orders tableCustomer ID ontrols to rete.

table from tustomer ID c

table from tmployee ID c

from

ID and ox control, edo as

, you and

trieve data

he Data combobox.

the Data combobox.

m 144 | P a g e

Page 15: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

Fi

Fi

©

igure 15

igure 16

© Kok Choon, All Rights R

Reserved WWorldwide. htttp://www.cy

Go tableauto

Nowshodata Yousave

ynics-soft.com

to source viee to see the omatic gene

w, hit F5 to culd see the ca from maste

u see how me with RAD

ew, you sholoading coderated.

compile and combobox eer tables cor

uch time yotools…!

uld be e

run, you extract rrectly!

u can

m 15 | P a g e

Page 16: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

U

Ddi

Th

Fi

Fi

©

Unleash th

ataset Desigidn’t even kn

he only reas

igure 17

igure 18

© Kok Choon

he Power

gner is the mnow their exi

son develope

, All Rights R

r of Datas

most powerfuistence or im

er do not use

Reserved W

set Design

ul tools availmportance.

e them are,

Worldwide. ht

ner

lable in Visu

they do not

ttp://www.cy

ual Studio 20005 and 2008; many dev

know how to

NowNortexp Thisimpprog

Seethe Tabintedataneeedit All ccan gen

ynics-soft.com

o customize

w double clicthWindDatalorer.

s is Datasetportant coregramming!

e the Orders OrdersTable

bleAdapter isrface betweeabase, it conded to selecyour table.

codes generthen configuerated sourc

m 16

e it !

ck the set in the so

t Designer, e for Databa

Table, now eAdapter.

s the commuen dataset antains all thect, insert, de

rated by the ure the toolsce.

velopers

olution

the most ase

click on

unication and your e code lete and

tools, you s’

6 | P a g e

Page 17: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

Fi

©

igure 19

© Kok Choon, All Rights RReserved WWorldwide. htttp://www.cy

Afte“OrdstepPangen

ynics-soft.com

er Click on thdersTableAdp, now look anel, you will nerated for yo

he dapter” in preat your Propnotice all 4 cou.

evious perties commands

m 17 | P a g e

Page 18: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

Fi

Fi

©

igure 20

igure 21

© Kok Choon, All Rights RReserved WWorldwide. htttp://www.cy

Theget how NowagaQue

In th“Use“Nex

ynics-soft.com

e standard cowhat you wa

w to configure

w select Ordin, right click

ery”.

his screen, se SQL Statext”.

ommand setant; I will shoe it with filte

ersTableAdak and select

select the deements”, the

t might not ow you r.

apter “Add

efault – n click

m 18 | P a g e

Page 19: Rapid Application Development With Visual Studio

Rapid Application Development with Visual Studio™

Figure 22

Also select the default option that return rows…Click “Next”.

Figure 23

Now in this screen, you can add your own filter statement. Add “WHERE OrderID Between @STARTID AND @ENDID” at the end of “From Orders”. Click Next Button.

© Kok Choon, All Rights Reserved Worldwide. http://www.cynics-soft.com 19 | P a g e

Page 20: Rapid Application Development With Visual Studio

Rapid Application Development with Visual Studio™

Figure 24

You can change the Method Name to anything you want. In this demo, just leave it as default. Click “Next” button.

Figure 25

Click “Next” button again.

© Kok Choon, All Rights Reserved Worldwide. http://www.cynics-soft.com 20 | P a g e

Page 21: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

Fi

Fi

©

igure 26

igure 27

© Kok Choon, All Rights RReserved WWorldwide. htttp://www.cy

Thegen

Nowbutt

ynics-soft.com

e FillBy and Gerated.

w, go to yourton.

Get DataBy

r form and a

Method is

dd a new

m 21 | P a g e

Page 22: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

Fi

D

M

Pac

Af

©

igure 28

ouble click o

Me.OrdersTa

lease note tctually pass

fter complet

© Kok Choon

on the button

bleAdapter.F

hat the STAin the editbo

e, hit F5 to c

, All Rights R

n and switch

Fillby(Me.No

ARTID can beox.text into t

compile and

Reserved W

h to code vie

orthwindData

e replace bythe method d

run.

Worldwide. ht

ew automatic

aset.Orders

y “0000” or adirectly.

ttp://www.cy

cally. Add th

, STARTID,

anything. If y

ynics-soft.com

e fillby meth

ENDID)

you add two

hod in the click event:

more editboox, you can

m 222 | P a g e

Page 23: Rapid Application Development With Visual Studio

Rapid Application Development with Visual Studio™

Hierarchical Update with Visual Studio 2008

In this chapter, you will learn how to create Master details with hierarchical update. In VS2008, Microsoft has included a powerful component called TableAdapterManager, which bring RAD to full support of Hierarchical update!

Unfortunate this tutorial only applies to VS2008, VS2005 still requires a bit coding!

Figure 29

Now let’s resize and extend the width of the form.

© Kok Choon, All Rights Reserved Worldwide. http://www.cynics-soft.com 23 | P a g e

Page 24: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

Fi

Fi

©

igure 30

igure 31

© Kok Choon, All Rights RReserved WWorldwide. htttp://www.cy

NowDeta But “Or Instethe frepr Dragtable

Yousucc If yoof OdataOrde NowwithFigu

ynics-soft.com

w you need tails into the

please take der Details”

ead, click Orfield “Order resentation o

g the Order e into the fo

u can see thecessfully dro

ou select theOrders, then a in the grid werID…

w we have toh the producture…

to drag the Oform.

note, do no”….

rders, and thDetails”, wh

of the detail

Details fromrm.

e detail grid opped on the

e Order DetaOrder Detaiwill not be fi

o link the prot table. See

Order

ot drag

hen select hich is a table.

m the Order

e form.

ails instead ls, the lter by the

oduct ID Next

m 244 | P a g e

Page 25: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

Fi

Cse

Fi

©

igure 32

lick the smaelect Edit co

igure 33

© Kok Choon

all arrow at tholumn as wel

, All Rights R

he top right oll.

Reserved W

of the grid, s

Worldwide. ht

select edit co

ttp://www.cy

olumn. You m

Selec

ynics-soft.com

may right cli

ct the produ

m 2

ck on the gr

ctID.

rid and

5 | P a g e

Page 26: Rapid Application Development With Visual Studio

Rapid Application Development with Visual Studio™

Figure 34

Find ColumnType and change it to DataGridViewComboboxColumn.

Figure 35

Next, select DataSource, drop down and find: Project Data Sources, NorthWindDataset, Products. This will bind Products table with the ProductID column.

© Kok Choon, All Rights Reserved Worldwide. http://www.cynics-soft.com 26 | P a g e

Page 27: Rapid Application Development With Visual Studio

Rapid Application Development with Visual Studio™

Figure 36

Next, Select DisplayMember, drop down and select ProductName.

Figure 37

Next, select ValueMember, drop down and select ProductID. Click OK Button.

© Kok Choon, All Rights Reserved Worldwide. http://www.cynics-soft.com 27 | P a g e

Page 28: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

Fi

Nta

Thpr

Fi

Yco

©

igure 38

ow hit F5 coable when na

he ProductIDroduct name

igure 39

ou should noomponent is

© Kok Choon

ompile and ravigating.

D in the Gride, the produc

otice below s TableAdapt

, All Rights R

un, if everyt

d should shoctID will be u

the form desterManager,

Reserved W

hing setup c

ow Product Nupdated acco

signer, is all , this compo

Worldwide. ht

correct, you w

Name (Displordingly.

the compononent allows

ttp://www.cy

will see the

ayName), a

nents represyou to upda

ynics-soft.com

Order Detail

nd every tim

ls grid followw Order

me you changge the

sentation icoate multiple t

n, one of thetable at once

e new e!

m 28 | P a g e

Page 29: Rapid Application Development With Visual Studio

Rapid AApplicatiion Deveelopmentt with Visual Studdio™

Fi

Fi

Thbo

Bto

FoO

Ben

©

igure 40

igure 41

his statemenoth tables, e

ecause deleo do more co

or example, OrderID entrie

ut when younter into the

© Kok Choon

nt: “Me.Tableven you hav

ete and inseroding…

when you tres.

u want to instable.

, All Rights R

eAdapterMave 3 or 4 or

rt sequence

ry to delete a

ert OrderDe

Reserved W

anager.Updamany tables

are not the

an Order, yo

etails, you m

Worldwide. ht

ateAll(Me.Nos, it will mana

same, witho

ou must first

ust insert Or

ttp://www.cy

Switchshouldconnec

orthwindDataage the upd

out TableAda

delete the O

rder Record

ynics-soft.com

to the Prop see all Tabcted to Table

erties panelleAdapter(s)eAdapterMa

aset)” will doate accordin

apterManage

OrderDetails

first before

, you ) are

anager.

o all the updangly.

ate for

er, developeer will need

s record withh the same

OrderDetailss can be

m 29 | P a g e

Page 30: Rapid Application Development With Visual Studio

Rapid Application Development with Visual Studio™

© Kok Choon, All Rights Reserved Worldwide. http://www.cynics-soft.com 30 | P a g e

Useful Resources

Cynics Software – The Leading Provider in Accounting, POS and Inventory Source Code, build upon Rapid Application Development Tools from Visual Studio 2005 and 2008.

General Ledger Trial Source Code – Sample source code that demonstrates how we build our system using RAD tools.

Rapid Application Development Source Code in this tutorial.