You are on page 1of 157

A

PROJECT REPORT

On

MEDICAL STORE MANAGEMENT

Submitted to

In the partial fulfillment of the degree of

Project Guide by: Submitted By:

1
Acknowledgement
My thanks go to esteemed organisation Sood Medicine Traders Limited,
Hoshiarpur immense gratitude to Mr. Anuj Sood, Director, staff and other members of
the organisation for their continued guidance and support in the development of this
Project and also their requisite skills which gave us self-confidence for completing this
Project.
We also gratefully acknowledge our most affectionate teacher and project super
visor Prof. Mohan Bhardwaj by helping us through his expert guidance, strong criticisms
and valuable suggestions at project work.
With immense pleasure, we thank Prof. Mohan Bhardwaj project supervisor, for
his valuable guidance, which he provided so generously during the Project Preparation. We
feel, without this consistency, it would never have been possible to complete this task.

2
SOMETHING ABOUT
COMPUTERS
Computer can no longer be termed as a mere invention. It’s a revolution. We
cannot imagine our world without Computers. There is no area, in world, which is
untouched by Computers.
Computers are fast, accurate and reliable device. A fast modern computer can
execute millions of instructions per seconds. If properly maintained, it can work
continuously for days and weeks together, without interruption and it rarely fail.
Computers, however, lack in intelligence and are no match for human beings in
this respect. That is why human beings still remain supreme and cannot be replaced by
computers. In other words, computers cannot work without human beings and each
computer can keep a number of professionals busy, day and night. That is why there is
greater demand for computer professionals throughout the world.

In India also computers are getting acceptability. Already a large number of


them have been installed and many more are on the way. The demand of computer
professionals is also increasing correspondingly. Computers enhance the capability,
effectiveness and output standards of any fields in which they are applied.

3
About the Project

Introduction

This project “Computerization of Sood Medicine Traders Limited (CSMTL)”is a


project that can be used by every Medicine Traders to handle their routine need of Sale,
Purchase, Stock detail information and many more which are highlighted as below:

 Handling entry of new parties.

 Maintains the record of all Whole sailors and retailers.

 Gives full detail about the available stock of medicine and other surgical items.

 Shows the detailed information about the dead stock.

 Gives details about Trade’s incomes and expenditures.

 Sale and Purchase reports.

 DBA and user Administration.

 DATA Management.

 Daily Reports.

 Reports on sale returns.

4
HARDWARE
AND
SOFTWARE REQUIREMENTS

HARDWARE REQUIREMENT (Minimum)

 An IBM compatible PC and Intel 486 or above Microprocessor

 4 GB Hard Disk.

 32 MB RAM.

 144 MB Floppy Disk Drive.

 Standard 2/3 Button Mouse.

 DOT Matrix Printer/ Laser Printer

 Key Board.

 MONA/SVGA 15 Inch Colour Monitor.

SOFTWARE REQUIREMENT

 Windows ME/2000/XP

 Personal Visual Basic 5.0 or Visual Basic 6.0

 MS-Access 97/2000/XP

5
Introduction for VISUAL BASIC
(Used as Front End)

Visual Basic is an object oriented programming development system for creating


applications that run under any of the Microsoft windows environments. Visual Basic is
the fastest and easy way to create application for Microsoft Windows. Visual Basic
provides you with a complete set of tools to simplify rapid application development.

The “Visual” part refers to method used to create the graphical user interface
(GUI). Rather than writing numerous lines of code to describe the appearance and
location of Interface elements, you simply drag and drop pre-built objects into place on
screen.

The “Basic” part refers to the BASIC (Beginners All-Purpose Symbolic


Instruction Code) language used by most of the programmers than any other language in
the history of computers. Visual Basic has evolved from the original BASIC language
and now contains thousand of statements, functions and keywords, many of which relate
directly to Windows GUI. Beginners can create useful applications by learning just a few
of the keywords, yet the power of the language allows professionals to accomplish
anything that can be accomplished using any other Windows programming language.

Visual Basic 6.0 is a development environment that runs under Microsoft


Windows. It is used to write programmes that also run under Microsoft Windows. It
combines extraordinary use with great power and flexibility. Visual basic is used in many
ways and at many levels from programmers to the expert’s artists of programming.
Visual basic language is having several faces one is visual which comprises of objects
and tools that easily assemble themselves into a modern windows interface. Another face
is the visual basic language, which is an outcome of the original basic language. Basic
was invented in the early 1960s. Visual basic has kept the basic tradition intact in this
respect. It is one of the easiest computer languages to work with an understanding.

6
The Visual Basic programming language is not unique to Visual Basic. The
Visual Basic programming system, Application Edition included in Microsoft Excel,
Microsoft Access, and many other Windows applications uses the same language. It is
becoming very popular among the users due to its user friendliness and advanced
features.

7
Features of Visual Basic

• Visual basic is visual and uses a simple BASIC-like programming language, yet
Visual Basic enables you to create powerful Windows programs.
• A bug is any kind of error in a programme, and refers to the process of removing
program bugs.
• A program written in a complied language runs much faster than one written in an
interpreted language.
• A program written in an interpreted language is easier to debug than one written
in a complied language.
• There are three editions of visual basic: Learning, Professional and Enterprise.
• There are various types of wizards in Visual Basic. They are: Standard Exe,
Active Exe, ActiveX DLL and many others. Mostly Standard Exe type is used for
typical applications.
• The integrated development is that where Visual basic puts applications together.
It is made of various components like toolbar, toolbox, form designer, etc.
• Visual basic applications are event-driven – events are triggered by the user
section and executes different sections of codes in response to events.
• Properties comprised the objects data, setting and attributes which can be design
time or run time.
• Methods are procedures that operate on the objects.
• Events are action recognizes by form or control – pressing a key or clicking a
mouse is an event for which an appropriate code is written.

8
ABOUT M.S.-ACCESS
Used as Back End

Authentication

Ms-Access allows for various types authentication. Ms Access-based authentication


allows for Access database accounts with user-ids and strong password management. Ms
Access also supports host-based authentication which is based on the operating system’s
user accounts which are then passed on to Ms-Access.

Privileges

There are two types of privileges available to be granted to users. They are system and
object privileges. System privileges allow a user to create or manipulate objects, but do
not give access to actual database objects. System privileges allow a user to execute
commands such as ALTER TABLE, CREATE TABLE and DELETE TABLE, etc.
Object privileges are used to allow access to a specific database object, such as a
particular table or view. Object privileges that are given at the view level are especially
impressive.

Roles

Roles are used to ease the management task of assigning a multitude of privilege to users.
Roles are first created and then given sets of privileges that can be assigned to users and
other roles. Users can be given multiple roles.

Database Encryption

At first thought, it might seem desirable to encrypt a confidential database. However, if


the proper user access controls are in place than an encrypted database would only
provide protection from unauthorized users and, of course, the database administrator
who has unlimited access.

9
Auditing

There are three standard types of auditing available in Ms Access, including SQL
statement-level, privilege-level, and object-level auditing. Audit records can be written

Ms Access audit table, to an operating system audit trail, or to an external file.

Protecting Data Integrity

Ms Access provides several features to ensure data integrity whether in the case of
system failure, human error, or malicious attacks. These features include redo log files,
rollback segments, and Log Miner.

Ms Access’s Advanced Security Option

The Ms Access’s Advanced Security Option includes features which ensure secure
communications when accessing a database even over the internet. RSA, RC4, Triple
DES can be used for data encryption over a network.

10
Introduction to Problem
Today in, 21st century, we can’t ignore the presences of computers and its importance.
It is their in every part of life, society, business, education. Computer provides a good
management and accurate estimation of the material. Every business and management
concern having computer system with them but software to handle them is again a big
problem. User should be able to understand the software and most important software
should serve all the corner of concern.
In this project we are dealing with CSMTL (Computerization of Sood Medicine Traders
Limited). A big or small Medicine Traders requires proper utilization of recourses and
management of Consignment of Sale Purchase, Stock Transaction Record which is of
most importance.
Sood Medicine Trader Limited is concerned more with serving lots of customers
(wholesalers & retailers). Number of customers visits SMTL (Sood Medicine Traders
Ltd). daily for purchasing medicine. Record of each and every customers, their payment
discount, and dead material recovered are major concern to store. What type of material,
a particular customers has received in the SMTL, what was the date, types of material,
modes of payment all these should be available as and when demanded. Information of
SMTL’s property and utilities available to customers, list of medicine and surgical items,
detail of Staff members, information of all the Departments, Room details was work
assigned to administration department and now handled through one person with the use
of this software. Security of the database is available in this software by providing
centralized database system. Data can be stored on system or can be kept on auxiliary
devices.
Stocks and Accounts records maintenance of medicine trade a big problem. A different
authority needed to handle stock and accounts. Again getting information of stock and
accounts at the moment was a difficult job which also includes the possibilities of wrong
information, so decision goes in wrong direction. Stock and account statement is again a
big time consuming task. So to reduce all these problems computer software will again
help human.

11
Quarries of normal person (outsiders) regarding information of medicine like rate, date of
mfg., discount etc is solved without much effort.
This software will help management in easy decision making and this will save time and
efforts.
This software can be used by every medicine trade. This also includes facility of adding
extra features to enhance the scope of software, suppose presently medicine trade don’t
have medical representative, own transportation etc. but these field can be add on in this
software later without much difficulties. This shows flexibility of software. But initially it
will cover most essential aspects of the medicine trade which can’t be left untouched.

12
Previous Systems

Fact finding means to trace the following factors in the field of SYSTEM ANALYSIS
AND DESIGN. The fact finding passes through the following stages.

1. To check the performance of old system.


2. Problems in the old system.
3. Recommendations which can rectify the problems.
4. The management biases.
5. The user limitations.
6. Present hardware and software.
7. Finance involved
8. Errors in the system
9. Non-reliability of previous system.
10. Time saving.
11. Proper decision making.
12. Flexibility.
13. Extendibility in the present system.
14. Upgrading software language i.e. from VB to VB.NET

Fact-finding is also called feasibility study. SYSTEM ANALYSIS AND DESIGN is just as
a manufacturing unit in which raw material is entered as input, machine and plant work
as process and products/finished goods as output. In the SAD the raw data is the input,
programs are the processes and information is output. Some time if the information is not
up to the standards then the output can be fed to the system as input - It means it work as
a cycle. So that why SAD is also called SDLC i.e. System Development Life Cycle.
During the system analysis, it is found that the old system is the manual system. The old
system has following disadvantages
1. It was very difficult to maintain the Records, Reports, list, Register etc. relating to
Students, Faculties and items stocks information.
2. No automated tool like COMPUTER is used for the processing.
3. More staff was required.
4. Due to manual work, lot of hard work done by staff to accomplish the certain task.

13
Need of the New System
Need of new system is required because old system has following limitations.

1. NO SECURITY OF DATA – In manual system, anybody who can have access to


the account’s store room can change or destroy information.
2. NO DATA INTEGRATION – As the data is stored in different registers without
sorting or indexing, so its very difficult look for a particular information searching
through all registers manually.
3. NO BACKUP – If the data is lost or accounts store room is destroyed in any accident
then all information is lost.
4. DATA INCONSISTENCY – Sometimes an accountant forgets to make changes in
one register for example: about customer’s room no. then the information won’t
match with other registers.
5. TIME CONSUMING – Accountant have to perform each and every computation
manually so to prepare a simple report about total payment collection during a
particular period would take days.
6. NO ACCURACY – No matter how good an accountant is but still the result of
reports are never reliable and accurate.
7. ADDITION, MODIFICATION & DELETION – To make modification about a
customer’s and employees information, his old record is marked for deletion on
the register by cutting it with pen physically, which is messy and then the
information is written by collecting the old data, wherever the space is available.
Same is the problem for adding the information about the new addition of
customer or employee. Deletion becomes very messy as we have to physically
mark the record for that and there is no way that we can make the record
disappear from the register.

14
Proposed System

The new recommended system is also a computerized system, which has many
advantages over the old one.

1. Use of visual language.


2. Single-user system.
3. Use of Relation Database Management System.
4. Better security and privacy mechanism.
5. Account handling & maintenance.
6. Final Reports system.
7. Easy understandable and hand able.
8. The long processes will shorten here.
And many more features.

15
FEASIBILITY STUDY

The project is basically designed to give a friendly approach to the fast working
environment of medicine trade were one of the main function in the sale purchase and
stock is manage in their respective organizations

So this project has tried to work on each process of the system to give a
friendly approach to the user where by the employ’s of any particular organization can
work with the software without making less mistakes.

Also the software used is user friendly and the most advanced technology is
used to give the best layout to the system. Also the database storage and its security are
consistent while in day to day approach. Ever aspect of this project is well studied.

16
System Flowchart

Data documents Programs Data Base

Transactions

Display Reports

Query

Printed Reports

17
Project Flow Chart

Start

Execute the login form process

Read User Name & Password from Users

Do the data

matches
Close the system and Load Software Menu
print an error message

Master Display Help


Stop

Transaction System

18
About the Project

Introduction

This project “Computerization of Sood Medicine Traders Limited (CSMTL)”is a


project that can be used by every Medicine Traders to handle their routine need of Sale,
Purchase, Stock detail information and many more which are highlighted as below:

 Handling entry of new parties.

 Maintains the record of all Whole sailors and retailers.

 Gives full detail about the available stock of medicine and other surgical items.

 Shows the detailed information about the dead stock.

 Gives details about Trade’s incomes and expenditures.

 Sale and Purchase reports.

 DBA and user Administration.

 DATA Management.

 Daily Reports.

 Reports on sale returns.

19
DATABASE
DESIGN

20
Database Details

Table AcDet
Field Name Type Description
Aname varchar2(50) Account Name
Address varchar2(100)
Root varchar2(50) City Area Divided in Roots
Phno varchar2(20)
FaxNo varchar2(20)
VatNo varchar2(20)
StCst varchar2(20)
ope number(10) Opening Balance
oSide varchar2(20) Dr. / Cr.
Grp varchar2(40) Group
Remark varchar2(120)

21
Table itemMaster

Field Name Data Type Remarks


iname varchar2(50) Item Name
itype varchar2(25) Item Group of Tax
mrp varchar2(15) Market Retail Price
srate varchar2(10) Sale Rate
op varchar2(10) Opening Pcs.
opvalue varchar2(10) Value of Stock

22
Table Name Transaction
Column Name Data Type Remarks
vn number(10) Voucher No.
edate varchar2(15) Entry Date
acr varchar2(50) A/c Cr.
cg varchar2(50) Cr. Group
cn varchar2(150) Narration
camt number(10) Cr amount
adr varchar2(50) A/c Dr.
dg varchar2(50) Dr. Group
dn varchar2(150) Narration
damt number(10) Dr. Amount
kk varchar2(50) Key Field
vtype varchar2(50) Voucher Type

23
Table Name PurchaseMaster

Field Name Type Remarks


EDate varchar2(15) Entry Date
Bno varchar2(20)
cname varchar2(100)
BType varchar2(20) Cash / Credit
disc number(10,2) Discount
amt number(10,2) Amount
labo number(10,2) Labour Amount
frh number(10,2) Freight Amount

24
Table PDet
Field Name Type Remarks
bno varchar2(20)
item varchar2(50)
grp varchar2(25) Tax Group
mrp varchar2(25)
srate number(10,2) Sale Rate
qty number(10,2)
sch number(10,2) Scheme
cname varchar2(100)
sno varchar2(50) Sales Tax No.
amt number(10,2) Amount
edate varchar2(50)
cost number(10,2) Cost Per Pcs.

25
Table SaleMaster

Field Data Type Remarks


EDate varchar2(15) Entry Date
Bno number(10)
BType varchar2(20) VAT / TOT
cname varchar2(100) Customer Name
vatno varchar2(20)
root varchar2(100) Area of City
addr varchar2(100)
stype varchar2(100) Cash / Credit
tax number(10,2)
samt number(10,2) Sale Amount
amt number(10,2)
deli varchar2(50) Delivered By
dis number(10,2) Discount Amount
discp number(10,2) Discount in Percentage
itemSch number(10,2) Item Scheme

26
Table Name Sale Details
Field Name Types Remarks
bno number(10) Bill No.
BType varchar2(20) VAT / TOT
item varchar2(50)
grp varchar2(25) Tax Group
mrp varchar2(25)
qty number(10,2)
srate number(10,2)
sch number(10,2)
schp number(10,2) Scheme in Pieces
Discount number(10,2)
replace number(10,2) Replace Qty
amt number(10,2)
tax number(10,2) Tax Amount

27
DESCRIPTION
&
SCREEN SHOTS

28
NEW ACCOUNT CREATION

• Purpose of this window is to create a new account of the parties who’s Purchased
the material from SMTL, and material purchase by the SMTL to the other parties.
• In this window firstly we feed the name of the parties and chose the group like
Sundry debtor or sundry creditor, Vat no., Sale tax no., Address, Root of the customer,
Phone no. , Fax no., Opening balance of the party, Dr. or Cr. (chose any one), remarks
enter if any and last save it. The msgbox ‘saved’ is appeared for the confirmation purpose
of the task.
• If you want to change the record click on the name text box and choose any name
from the window and make changes in it and pressed the command button modified. The
record is modified and saved. The msgbox ‘saved’ is appeared for the confirmation
purpose of the task.
• If you want to delete any record first you select the record and pressed the delete
command button.
• If you want exit from this option click on exit button.

29
1.1 NEW ITEM GROUP

• Purpose of this window is to enter the tax category of newly item received by the
SMTL and click on save button. The msgbox ‘Record Saved’ is appeared for the
confirmation purpose of the task.
• If you want to change the category choose any one from the ‘Select Tax Category
to Modify’ window and make changes in it and click the command button modified. The
record is modified and saved. The msgbox ‘Modified’ is appeared for the confirmation
purpose of the task.
• If you want exit from this option click on exit button.

30
1.2 NEW ITEM

• Purpose of this window to create information about the new item.


• In this window we feed item name, tax category, MRP, sale rate, opening stock,
and value of opening of stock and click on save. The msgbox ‘Record Saved’ is appeared
for the confirmation purpose of the task.
• If you want to change the category choose any one from the ‘Item Name’ window
and make changes in it and click the command button modified. The record is modified
and saved. The msgbox ‘Modified’ is appeared for the confirmation purpose of the task.
• If you want to delete any record first you select the record and pressed the delete
command button.
• If you want exit from this option click on exit button.

31
2. TRANSACTION MENU
2.1 SALE ENTRY

• Purpose of this window to enter the details of any sale of material.


• In this window we select the vat no. or tot no., cash or cr.( mode of payment),Party
name, root, item name, tax category. Then we feed MRP, previous sale replacement rate,
quantity, sale rate, any scheme, any scheme %age, discount, if sale any other item in same
bill click the next button, then enter name of delivery boy and feed discount %age on
whole item then click save button. The msgbox ‘Record Saved’ is appeared for the
confirmation purpose of the task and also show the net amount..
• If you want to any changes in the bill click on modified button and enter bill no.
then click save button. The record is modified and saved. The msgbox ‘Modified’ is
appeared for the confirmation purpose of the task.
• If you want to delete any record first you select the record and pressed the delete
command button.
• For print the receipt click the print button.
• If you want exit from this option click on exit button.

32
2.2 PURCHASE ENTRY

• Purpose of this window to enter the details of any purchase of material.


• In this window we feed bill no. then we click on the check button if the bill no is
new then message appear not entered otherwise it print bill already entered, we select the
cash or cr. (mode of payment), then select Party name from the window, feed the address,
select item name, feed the MRP, sale rate, quantity, scheme in pieces. The total amount
and cost per piece automatically calculated and appear in assigned box. Then we feed
discount total, freight & octrai and labour. The msgbox ‘Record Saved’ is appeared for the
confirmation purpose of the task and also show the Total amount.
• If you want to any changes in the bill click on modified button and enter bill no.
then click save button. The record is modified and saved. The msgbox ‘Modified’ is
appeared for the confirmation purpose of the task.
• If you want to delete any record first you select the record and pressed the delete
command button.
• If you want exit from this option click on exit button.

33
2.3 EXPIRY RETURN

• Purpose of this window to enter the details of any expiry return of material.
• In this window we select the party name, root of the party, item name and then
feed the quantity and rate of the material.
• If another item is return then click on next button and feed the detail then click
on the save button. The msgbox ‘Record Saved’ is appeared for the confirmation purpose
of the task and also show the Net amount.
• If you want exit from this option click on exit button.

34
2.4 VOUCHER

• Purpose of this window to enter the details of any receipt and payments.
• In this window feed the dr. name, amount, narration cr. name amount selected
account for created and narration, select the one radio button and click the save button.
• If you want to any changes in the bill click on modified button and feed the date,
voucher no., dr. name, amount, narration cr. name amount selected account for created and
narration, select the one radio button and click the modified button. The msgbox
‘Modified’ is appeared for the confirmation purpose of the task.
• If you want to clear any record first you select the record and pressed the clear
button.
• If you want to display any voucher select the field and criteria and value then
click on display button.
• If you want exit from this option click on exit button.

35
3. DISPLAY MENU
3.1 LEDGER

• Purpose of this window to see the ledger of any party.


• Select the party name and click on the display button.
• If you want to print the ledger of the party, firstly select the party name display it
and click on print button.
• If you want exit from this option click on exit button.

36
3.2 PURCHASE BILL

• Purpose of this window to see the ledger of purchase bill.


• Select the party name and click on the display button.
• If you want exit from this option click on exit button.

37
3.3 STOCK ITEM WISE

• Purpose of this window to see the summary of any item.


• Feed the first alphabet of item name who’s you want to see. The summary of
selected item is show in below.
• If you want to print the ledger of the summary of any item Feed the first alphabet
of item name and click on print button.
• If you want exit from this option click on exit button.

38
3.4 STOCK DATE WISE

• Purpose of this window to see the summary of any item date wise.
• Feed the date FROM and then feed the TO date who’s you want to see. The
summary of selected the item name and click on display button show in below.
• If you want exit from this option click on exit button.

3.5 EXPIRY STOCK

39
• Purpose of this window to see the summary of expiry stock.
• To see the summary of expiry stock click on the option expiry stock from the
display menu.
• If you want exit from this window click on close button form the menu bar.

4. SYSTEM MENU
40
4.1 ADD USER

• Purpose of this window to enter the user name.


• In this window feed the user name, password, same password feed one more time
and click the save button. The msgbox ‘Record Saved’ is appeared for the confirmation
purpose of the task.
• If you want to any changes in the user name and password click on modified
button. The msgbox ‘Modified’ is appeared for the confirmation purpose of the task.
• If you want to delete any record first you select the record and pressed the delete
command button.
• If you want exit from this option click on exit button.

4.2 EXIT WINDOW

41
• Purpose of this window to exit from the window.
• If you want exit from the window click on yes button.

SOURCE CODE
Login Form

Dim rsCmdLogin As New ADODB.Recordset

42
Dim SQLQuerry As String
Private Sub butCancel_Click()
End
End Sub

Private Sub butOk_Click()


If IsValidField Then
If CheckUserIsValid Then
MsgBox "Successful Login", vbInformation, "Medicine Store"
Timer1.Enabled = False
Unload Me
frmMain.Show
Else
MsgBox "Invalid User Name / Password ! ", vbCritical, "Medicine
Store"
End If
End If
End Sub

Private Function CheckUserIsValid() As Boolean


SQLQuerry = "Select * from UserD where UName = " & "'" &
txtUser.Text & "'" & " and Psswd = " & "'" & txtPassword.Text & "'"
With rsCmdLogin
If .State = adStateOpen Then
.Close
End If
.Open SQLQuerry, cn, adOpenStatic, adLockReadOnly
If .RecordCount > 0 Then
If Not IsNull(.Fields(0).Value) Then
CheckUserIsValid = True
Else
CheckUserIsValid = False
End If
Else
CheckUserIsValid = False
End If
End With
End Function
Private Function IsValidField() As Boolean
If Len(Trim(txtUser.Text)) = 0 Then
IsValidField = False
MsgBox "User Name Should be Valid.", vbCritical, "Medicine
Store"
Exit Function
Else
IsValidField = True

43
End If
If Len(Trim(txtPassword.Text)) = 0 Then
IsValidField = False
MsgBox "Password Should be Valid.", vbCritical, "Medicine Store"
Exit Function
Else
IsValidField = True
End If
End Function

Private Sub chngCap_Timer()


frmLogin.Caption = " Login Window " + Str(Time)
End Sub

Private Sub Form_Load()


DoEvents
MakeConnection ("temp.mdb")
End Sub

Private Sub Timer1_Timer()


If Label1(1).FontSize > 12 Then
Label1(1).FontSize = 10
Label1(5).FontSize = 10
Else
Label1(1).FontSize = Label1(1).FontSize + 4
Label1(5).FontSize = Label1(5).FontSize + 4
End If
End Sub

Main Form
Dim rr As String
Private Sub MDIForm_Load()
'MakeConnection "Temp.mdb"
MakeConnection
VarVchForMix = GenVchNo
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
On Error GoTo rr

44
If Button.Caption = "Close" Then
Unload frmMain.ActiveForm
Toolbar1.Buttons.Item(6).Visible = False
ElseIf Button.Caption = "Help" Then
frmHelp.Show
End If
rr:
If Err.Number = 91 Then
Err.Clear
End If
End Sub

Private Sub Toolbar1_ButtonMenuClick(ByVal ButtonMenu As


MSComctlLib.ButtonMenu)
On Error GoTo rr
If ButtonMenu.Text = "New Account" Then
Unload frmMain.ActiveForm
frmAcc.Show
ElseIf ButtonMenu.Text = "New Item" Then
Unload frmMain.ActiveForm
frmItem.Show
ElseIf ButtonMenu.Text = "New Item Group" Then
Unload frmMain.ActiveForm
frmItemGrp.Show
ElseIf ButtonMenu.Text = "Sale Entry" Then
Unload frmMain.ActiveForm
frmSale.Show
ElseIf ButtonMenu.Text = "Purchase" Then
Unload frmMain.ActiveForm
frmPurchase.Show
ElseIf ButtonMenu.Text = "Voucher" Then
Unload frmMain.ActiveForm
frmJournal.Show
ElseIf ButtonMenu.Text = "Ledger" Then
Unload frmMain.ActiveForm
frmLedger.Show
ElseIf ButtonMenu.Text = "Expiry Return" Then
Unload frmMain.ActiveForm
frmSaleRet.Show
ElseIf ButtonMenu.Text = "Purchase Bill" Then
Unload frmMain.ActiveForm
frmDispPurBill.Show
ElseIf ButtonMenu.Text = "Stock Item Wise" Then
Unload frmMain.ActiveForm
Module1.isu = "stock"
frmStockSummary.ListView2.Visible = False

45
frmStockSummary.Label2.Visible = False
frmStockSummary.Label3.Visible = False
frmStockSummary.Label4.Visible = False
frmStockSummary.lblSale.Visible = False
frmStockSummary.lblPurchase.Visible = False
frmStockSummary.Show
ElseIf ButtonMenu.Text = "Stock Date Wise" Then
Unload frmMain.ActiveForm
Module1.isu = "dw"
frmStockSummary.txtStDate.Visible = True
frmStockSummary.txtEdDate.Visible = True
frmStockSummary.Combo1.Visible = True
frmStockSummary.butDisplay.Visible = True
frmStockSummary.txtChar.Visible = False
frmStockSummary.Label1.Visible = False
frmStockSummary.ListView2.Visible = True
frmStockSummary.Label2.Visible = True
frmStockSummary.Label3.Visible = True
frmStockSummary.butPrint.Visible = False
frmStockSummary.lblDate1.Visible = True
frmStockSummary.lblDate2.Visible = True
frmStockSummary.butPrint.Visible = False
frmStockSummary.ProgressBar1.Visible = False
frmStockSummary.lblSale.Visible = True
frmStockSummary.lblPurchase.Visible = True
frmStockSummary.Show
ElseIf ButtonMenu.Text = "Expiry Stock" Then
Unload frmMain.ActiveForm
With DataEnvironment1
If .rsExpiry.State = adStateClosed Then
.rsExpiry.Open
End If
.rsExpiry.Requery
.rsExpiry.Requery
.rsExpiry.Requery
.rsExpiry.Requery
.rsExpiry.Requery
End With
frmMain.Toolbar1.Buttons.Item(6).Visible = True
RptExpiry.Show
ElseIf ButtonMenu.Text = "Add User" Then

Unload frmMain.ActiveForm
frmAddUser.Show
ElseIf ButtonMenu.Text = "Create Tables" Then
CreateTables

46
ElseIf ButtonMenu.Text = "Exit" Then
If MsgBox("Sure to Quit !", vbYesNo, "Medicine Store") = vbYes
Then
End
End If
End If
rr:
If Err.Number = 91 Then
Resume Next
End If
End Sub

47
Open New Account
Dim VarStoreNameToModify As String, VarStoreIndexOfCmbName As
Double
Dim SQLQuerry As String
Private Sub butCancel_Click()
Unload Me
End Sub

Private Sub butDelete_Click()


If Len(Trim(txtName.Text)) = 0 Then
MsgBox "Select A/c Name from List", vbInformation, "Invalid
Operation"
Exit Sub
End If
If IsEntryInMix(txtName.Text) Then
MsgBox "Invalid , Enteries entered already", vbCritical, "Invalid
Operation"
Exit Sub
End If
cn.Execute "Delete from Acdet where aName = " & "'" &
txtName.Text & "'"
MsgBox "Deleted", vbInformation, "Action Completed"
cmbAName.RemoveItem (cmbAName.ListIndex)
PopulateCmbAName
ClearFields
End Sub

Private Function IsEntryInMix(varAName As String) As Boolean


Dim RstFAccount As New ADODB.Recordset
SQLQuerry = "Select * from mix where acr = " & "'" & varAName &
"'" & " or adr = " & "'" & varAName & "'"
With RstFAccount
.Open SQLQuerry, cn, adOpenKeyset, adLockReadOnly
If .RecordCount > 0 Then
If Not IsNull(.Fields(0).Value) Then
IsEntryInMix = True
Else
IsEntryInMix = False
End If
Else
IsEntryInMix = False
End If

48
End With
End Function

Private Sub butModify_Click()


If Trim(UCase(txtName.Text)) <>
Trim(UCase(VarStoreNameToModify)) Then
If IsRecordAlreadyExist(txtName.Text) = True Then
MsgBox "Account Already Exist", , "Medicine Store"
Exit Sub
End If
End If

If IsFieldValid = True Then


Call DeleteAccountFromAcDetail(VarStoreNameToModify)
Call SaveDataInAcDetail
Else
Exit Sub
End If
' cmbAName.RemoveItem (VarStoreIndexOfCmbName)
' cmbAName.AddItem txtName.Text, VarStoreIndexOfCmbName
Call ClearFields
End Sub

Private Sub butSave_Click()


If IsFieldValid = True Then
If IsRecordAlreadyExist(txtName.Text) = False Then
Call SaveDataInAcDetail
Else
MsgBox "Account Already Exist", , "Medicine Store"
Exit Sub
End If
End If
cmbAName.AddItem txtName.Text
Call ClearFields
End Sub

Private Sub cmbAName_Click()


VarStoreNameToModify = cmbAName.List(cmbAName.ListIndex)
If cmbAName.ListIndex >= 0 Then
VarStoreIndexOfCmbName = cmbAName.ListIndex
End If
Dim TempRstFindName As New ADODB.Recordset
SQLQuerry = "Select * from AcDet where Aname = " & "'" &
VarStoreNameToModify & "'"
With TempRstFindName
If .State = adStateOpen Then

49
.Close
End If
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
txtName.Text = .Fields("Aname").Value
txtAdd.Text = .Fields("address").Value
txtRoot.Text = .Fields("root").Value
txtPh.Text = .Fields("phno").Value
txtFax.Text = .Fields("faxno").Value
txtVat.Text = .Fields("vatno").Value
txtST.Text = .Fields("stcst").Value
txtOp.Text = .Fields("ope").Value
If .Fields("OSide").Value = "Dr" Then
optDebit.Value = True
Else
optCredit.Value = True
End If
txtGrp.Text = .Fields("grp").Value
If .Fields("grp").Value <> "Indirect Income" And
.Fields("grp").Value <> "Indirect Expense" Then
Frame1.Visible = True
Frame2.Visible = True
Else
Frame1.Visible = False
Frame2.Visible = False
End If
txtremak.Text = .Fields("remark").Value
End If
End With
Set TempRstFindName = Nothing
End Sub

Private Sub cmbGrp_Click()


txtGrp.Text = cmbGrp.List(cmbGrp.ListIndex)
End Sub

Private Sub cmbGrp_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
frameGrp.Visible = False
End If
End Sub

Private Sub cmbGrp_LostFocus()


frameGrp.Visible = False
If cmbGrp.List(cmbGrp.ListIndex) = "Indirect Income" Or
cmbGrp.List(cmbGrp.ListIndex) = "Indirect Expense" Then

50
Frame1.Visible = False
Frame2.Visible = False
Else
Frame1.Visible = True
Frame2.Visible = True
End If
End Sub

Private Sub cmbRoot_Click()


txtRoot.Text = cmbRoot.List(cmbRoot.ListIndex)
End Sub

Private Sub cmbRoot_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
FrameRoot.Visible = False
End If
End Sub

Private Sub cmbRoot_LostFocus()


FrameRoot.Visible = False
End Sub

Private Sub Form_Activate()


Me.Top = 100
Me.Left = 50
End Sub

Private Sub Form_Load()


Call PopulateCmbGroup
Call PopulateCmbRoot
Call PopulateCmbAName
End Sub

Private Sub txtGrp_GotFocus()


frameGrp.ZOrder (0)
frameGrp.Visible = True
cmbGrp.SetFocus
End Sub

Private Sub txtName_KeyPress(KeyAscii As Integer)


TxtAllowOnly txtName, KeyAscii
End Sub

Private Sub txtName_LostFocus()


txtName.Text = Trim(txtName.Text)
End Sub

51
Private Sub txtOp_KeyPress(KeyAscii As Integer)
NumAllowOnly txtOp, KeyAscii
End Sub

Private Sub txtRoot_GotFocus()


FrameRoot.ZOrder (0)
FrameRoot.Visible = True
cmbRoot.SetFocus
End Sub

Private Sub PopulateCmbGroup()


cmbGrp.Clear
Dim TempRstGroup As New ADODB.Recordset
SQLQuerry = "Select * from Grp order by grpName"
With TempRstGroup
If .State = adStateOpen Then
.Close
End If
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
cmbGrp.AddItem .Fields("grpName").Value
.MoveNext
Loop
End If
.Close
Set TempRstGroup = Nothing
End With
End Sub

Private Sub PopulateCmbRoot()


cmbRoot.Clear
Dim TempRstRoot As New ADODB.Recordset
SQLQuerry = "Select * from RootDet order by RootList"
With TempRstRoot
If .State = adStateOpen Then
.Close
End If
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
cmbRoot.AddItem .Fields("RootList").Value
.MoveNext

52
Loop
End If
.Close
Set TempRstRoot = Nothing
End With
End Sub

Private Sub PopulateCmbAName()


cmbAName.Clear
Dim TempRstAName As New ADODB.Recordset
SQLQuerry = "Select * from ACDet order by Aname"
With TempRstAName
If .State = adStateOpen Then
.Close
End If
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
cmbAName.AddItem .Fields("Aname").Value
.MoveNext
Loop
End If
.Close
Set TempRstAName = Nothing
End With
End Sub

Private Function IsFieldValid() As Boolean


If Len(Trim(txtName.Text)) = 0 Then
MsgBox "Enter A Valid Account Name", , "Medicine Store"
Exit Function
IsFieldValid = False
End If

If Len(Trim(txtGrp.Text)) = 0 Then
MsgBox "Select Groip From List", , "Medicine Store"
txtGrp.SetFocus
Exit Function
IsFieldValid = False
End If

If Len(Trim(txtRoot.Text)) = 0 And txtGrp.Text = "Sundry Debitor"


Then
MsgBox "Select Root For Ur Sundry Debitor", , "Medicine Store"
txtRoot.SetFocus

53
Exit Function
IsFieldValid = False
End If

If Len(Trim(txtVat.Text)) = 0 Then
txtVat.Text = " "
End If

If Len(Trim(txtPh.Text)) = 0 Then
txtPh.Text = " "
End If

If Len(Trim(txtST.Text)) = 0 Then
txtST.Text = " "
End If

If Len(Trim(txtFax.Text)) = 0 Then
txtFax.Text = " "
End If

If Len(Trim(txtAdd.Text)) = 0 Then
txtAdd.Text = " "
End If

If Len(Trim(txtremak.Text)) = 0 Then
txtremak.Text = " "
End If

If Val(txtOp.Text) < 0 Then


txtOp.Text = 0
End If
IsFieldValid = True
End Function

Private Sub SaveDataInAcDetail()


If optDebit.Value = True Then
VarSideOP = "Dr"
ElseIf optCredit.Value = True Then
VarSideOP = "Cr"
End If
cn.Execute "Insert into ACDet Values (" & "'" & txtName.Text & "'"
& "," & "'" & txtAdd.Text & "'" & "," & "'" & txtRoot.Text & "'" & "," & "'"
& txtPh.Text & "'" & "," & "'" & txtFax.Text & "'" & "," & "'" &
txtVat.Text & "'" & "," & "'" & txtST.Text & "'" & "," & Val(txtOp.Text) &

54
"," & "'" & VarSideOP & "'" & "," & "'" & txtGrp.Text & "'" & "," & "'" &
txtremak.Text & "'" & ")"
MsgBox "Saved", , "Medicine Store"
End Sub

Private Sub DeleteAccountFromAcDetail(varAName As String)


cn.Execute "Delete from AcDet where Aname = " & "'" & varAName
& "'"
End Sub

Private Function IsRecordAlreadyExist(VarAcName As String) As


Boolean
SQLQuerry = "Select * from ACDet where Aname = " & "'" &
txtName.Text & "'"
Dim TempRstADetExistRecord As New ADODB.Recordset
With TempRstADetExistRecord
.Open SQLQuerry, cn, adOpenKeyset
If .State = adStateOpen Then
If .RecordCount > 0 Then
IsRecordAlreadyExist = True
Else
IsRecordAlreadyExist = False
End If
Else
IsRecordAlreadyExist = False
End If
End With
Set TempRstADetExistRecord = Nothing
End Function

Private Sub ClearFields()


Dim cc As Control
For Each cc In frmAcc
If TypeOf cc Is TextBox Then
cc.Text = ""
End If
Next
PopulateCmbAName
End Sub

55
Add New User
Dim SQLQuerry As String
Dim varRecModify As Boolean
Private Sub butCancel_Click()
Unload Me
End Sub

Private Function IsValidField() As Boolean


If Len(Trim(txtUser.Text)) = 0 Then
IsValidField = False
MsgBox "User Name Should be Valid.", vbCritical, "Medicine
Store"
Exit Function
Else
IsValidField = True
End If
If Len(Trim(txtPassword.Text)) = 0 Then
IsValidField = False
MsgBox "Password Should be Valid.", vbInformation, "Medicine
Store"
Exit Function
Else
IsValidField = True
End If
If txtRPassword.Text <> txtPassword.Text Then
IsValidField = False
MsgBox "Password Should be Same For Re-Enter!",
vbExclamation, "Medicine Store"
Exit Function
Else
IsValidField = True
End If
IsValidField = True
End Function

Private Sub butDelete_Click()


If IsValidField Then
If IsUserIsValid Then
DeleteRec
Else
MsgBox "User Not Exist !", , "Medicine Store"
End If
End If
End Sub

56
Private Sub butModify_Click()
If Len(Trim(txtMUserName.Text)) = 0 Or
Len(Trim(txtMPassWord.Text)) = 0 Then
MsgBox "User Name / Password must be entered for
Modification", vbCritical, "Medicine Store"
Exit Sub
End If
Dim RstUserD As New ADODB.Recordset
If IsValidField Then
If CheckUserForModify Then
With RstUserD
.Open "Select * from UserD", cn, adOpenKeyset,
adLockOptimistic
Do While Not .EOF
If .Fields(0).Value = txtMUserName.Text And
.Fields(1).Value = txtMPassWord.Text Then
.Fields(0).Value = txtUser.Text
.Fields(1).Value = txtPassword.Text
.Update
Exit Do
End If
.MoveNext
Loop
End With
'cn.Execute " Update USerd set psswd = " & "'" &
txtMPassWord.Text & "'" & " where uName = " & "'" & txtUser.Text &
"'"
'cn.Execute " Update Userd set UNAme = " & "'" &
txtMUserName.Text & "'" & " where uName = " & "'" & txtUser.Text &
"'"
MsgBox "Record Update!", , "Medicine Store"
ClearFields
End If
End If
End Sub

Private Sub butSave_Click()


If IsValidField Then
If IsUserIsAlreadyExist = False Then
Call SaveRec
End If
End If
End Sub

Private Sub CentreScreen()


frmAddUser.Left = (Screen.Width - frmAddUser.Width) / 2

57
frmAddUser.Top = (Screen.Height - frmAddUser.Height) / 2
End Sub

Private Sub Form_Load()


Call CentreScreen
End Sub

Private Sub SaveRec()


Dim ss As String
On Error GoTo ss
SQLQuerry = "Insert into USerD values ( " & "'" & txtUser.Text & "'"
& "," & "'" & txtPassword.Text & "'" & ")"
cn.Execute SQLQuerry
MsgBox "Record Saved !", , "Medicine Store"
Call ClearFields
ss:
If Err.Number = -214 Then
End If
End Sub

'Private Function IsUserIsAlreadyExist() As Boolean


' If DD.rsCmdLogin.RecordCount > 0 Then
' DD.rsCmdLogin.MoveFirst
' End If
' With DD.rsCmdLogin
' Do While Not .EOF
' If UCase(Trim(.Fields(0).Value)) = UCase(Trim(txtUser.Text))
Then
' IsUserIsAlreadyExist = True
' MsgBox "User Already Exist With this Name.", vbCritical,
"Re-Enter User Name"
' txtUser.SetFocus
' txtUser.Text = ""
' Exit Function
' End If
' .MoveNext
' Loop
' End With
' IsUserIsAlreadyExist = False
'End Function

Private Function CheckUserForModify() As Boolean


Dim rsCmdLogin1 As New ADODB.Recordset

58
SQLQuerry = "Select * from syst where UNAme = " & "'" &
txtMUserName.Text & "'" & " and Psswd =" & "'" & txtMPassWord.Text
& "'"
With rsCmdLogin1
If .State = adStateOpen Then
.Close
End If
.Open SQLQuerry, cn, adOpenKeyset, adLockReadOnly
If .RecordCount > 0 Then
If Not IsNull(.Fields(0).Value) Then
CheckUserForModify = True
Exit Function
Else
CheckUserForModify = False
Exit Function
End If
Else
CheckUserForModify = False
End If
End With
End Function

Private Function IsUserIsValid() As Boolean


Dim rsCmdLogin As New ADODB.Recordset
SQLQuerry = "Select * from syst where UNAme = " & "'" &
txtUser.Text & "'" & " and Psswd =" & "'" & txtPassword.Text & "'"
With rsCmdLogin
If .State = adStateOpen Then
.Close
End If
.Open SQLQuerry, cn, adOpenKeyset, adLockReadOnly
If .RecordCount > 0 Then
If Not IsNull(.Fields(0).Value) Then
IsUserIsValid = True
Exit Function
Else
IsUserIsValid = False
Exit Function
End If
Else
IsUserIsValid = False
End If
End With
End Function

Private Sub ClearFields()

59
txtUser.Text = ""
txtPassword.Text = ""
txtRPassword.Text = ""
txtMPassWord.Text = ""
txtMUserName.Text = ""
txtUser.SetFocus
End Sub

Private Sub DeleteRec()


SQLQuerry = "Delete from [syst] where UNAme = " & "'" &
txtUser.Text & "'"
cn.Execute SQLQuerry
MsgBox "Record Deleted ! ", , "Medicine Store"
ClearFields
End Sub

60
Display Purchase Bill
Dim pm As New Recordset
Dim pd As New Recordset
Dim cd As New Recordset ' for creditor
Dim name1 As String, bn As String, da As String
Dim tam As String, dis As String
Dim fr As String, lo As String
Dim SQLQuerry As String

Private Sub cmbName_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
butDisplay.SetFocus
End If
End Sub

Private Sub butDisplay_Click()


Dim ss As String
'On Error GoTo ss
cn.Execute "delete from bil"

If cmbName.ListIndex = -1 Then
MsgBox "Select Company Name", , "Medicine Store"
Exit Sub
End If

txtBillNo.Text = UCase(txtBillNo.Text)

If Len(Trim(txtBillNo.Text)) = 0 Then
MsgBox "Enter BiLL No", , "Medicine Store"
Exit Sub
End If

pm.Open " select * from pmain where cname=" & "'" &
cmbName.Text & "'" & " and bno =" & "'" & txtBillNo.Text & "'", cn,
adOpenKeyset, adLockPessimistic
If pm.RecordCount = 0 Then
MsgBox "Bill Not Exist", vbCritical, "Invalid Data"
pm.Close
Exit Sub
End If
name1 = pm!cname
bn = pm!bno
da = pm!eDate

61
tam = Str(pm!amt)
dis = Str(pm.Fields(4).Value)
fr = Str(pm.Fields(7).Value)
lo = Str(pm.Fields(6).Value)

pd.Open " select * from pdet where cname=" & "'" & cmbName.Text
& "'" & " and bno =" & "'" & txtBillNo.Text & "'", cn, adOpenDynamic,
adLockPessimistic

Dim f As Integer
f=0
Do While Not pd.EOF = True
If UCase(Trim(pd!bno)) = Trim(UCase(txtBillNo.Text)) And
Trim(UCase(pd!cname)) = Trim(UCase(cmbName.Text)) Then
f=1
End If
pd.MoveNext
Loop

If f = 0 Then
MsgBox "Bill Not Exist", , "Medicine Store"
Exit Sub
End If

cn.Execute "delete from bil "


Dim sp As String, sp1 As String
Dim sp2 As String, sp3 As String
Dim sp4 As String, sp5 As String
Dim sp6 As String, sp7 As String, sp8 As String
Dim sno As Integer

sp2 = "BiLL No"


sp = " "
sp1 = "M/S "
sp3 = "DATE "

cn.Execute "insert into bil values(" _


& "'" & sp1 & "'" & "," _
& "'" & name1 & "'" & "," _
& "'" & sp & "'" & "," _
& "'" & sp & "'" & "," _
& "'" & sp & "'" & "," _
& "'" & sp & "'" & "," _
& "'" & sp3 & "'" & "," _
& "'" & da & "'" & "," _

62
& "'" & sp & "'" & ")"

cn.Execute "insert into bil values(" _


& "'" & sp2 & "'" & "," _
& "'" & bn & "'" & "," _
& "'" & sp & "'" & "," _
& "'" & sp & "'" & "," _
& "'" & sp & "'" & "," _
& "'" & sp & "'" & "," _
& "'" & sp & "'" & "," _
& "'" & sp & "'" & "," _
& "'" & sp & "'" & ")"

sp1 = "--------------------------------------------------------------------"

cn.Execute "insert into bil values(" _


& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp & "'" & ")"

sp1 = "PARTICULARS"
sp2 = "MRP"
sp3 = "RATE"
sp4 = "QTY"
sp5 = "SCH"
sp6 = "TYPE"
sp7 = "AMOUNT"
sp8 = " "

sp = " "

cn.Execute "insert into bil values(" _


& "'" & sp & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp2 & "'" & "," _
& "'" & sp3 & "'" & "," _

63
& "'" & sp4 & "'" & "," _
& "'" & sp5 & "'" & "," _
& "'" & sp6 & "'" & "," _
& "'" & sp7 & "'" & "," _
& "'" & sp & "'" & ")"

sp1 = "--------------------------------------------------------------------"

cn.Execute "insert into bil values(" _


& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp & "'" & ")"

sno = 1
pd.MoveFirst
Do While Not pd.EOF = True
sp1 = pd!Item
sp2 = pd!mrp
sp3 = Str(pd!srate)
sp4 = Str(pd!qty)
sp5 = Str(pd!sch)
sp6 = pd!grp
sp7 = Str(pd!amt)

cn.Execute "insert into bil values(" _


& "'" & sp & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp2 & "'" & "," _
& "'" & sp3 & "'" & "," _
& "'" & sp4 & "'" & "," _
& "'" & sp5 & "'" & "," _
& "'" & sp6 & "'" & "," _
& "'" & sp7 & "'" & "," _
& "'" & sp & "'" & ")"

sno = sno + 1

64
pd.MoveNext

Loop

sp1 = "--------------------------------------------------------------------"

cn.Execute "insert into bil values(" _


& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp & "'" & ")"

sp2 = "DISCOUNT"
sp3 = dis
sp1 = " "
cn.Execute "insert into bil values(" _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp2 & "'" & "," _
& "'" & sp3 & "'" & "," _
& "'" & sp & "'" & ")"

sp2 = "LABOUR"
sp3 = lo
sp1 = " "
cn.Execute "insert into bil values(" _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp2 & "'" & "," _
& "'" & sp3 & "'" & "," _
& "'" & sp & "'" & ")"

65
sp2 = "FR & OCT."
sp3 = fr
sp1 = " "
cn.Execute "insert into bil values(" _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp2 & "'" & "," _
& "'" & sp3 & "'" & "," _
& "'" & sp & "'" & ")"

sp1 = " "

sp2 = "NET AMOUNT "


sp3 = tam

ProgressBar1.Visible = True

cn.Execute "insert into bil values(" _


& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp2 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp3 & "'" & "," _
& "'" & sp & "'" & ")"

sp1 = "--------------------------------------------------------------------"

cn.Execute "insert into bil values(" _


& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp1 & "'" & "," _
& "'" & sp & "'" & ")"

66
Dim yy As Double

For yy = 0 To 100 Step 0.01


ProgressBar1.Value = yy
Next

With DataEnvironment1
If .rsBill.State = adStateOpen Then
DataEnvironment1.rsBill.Close
End If
.rsBill.Source = "select * from bil"
.rsBill.Open
End With

Set pm = Nothing
Set pd = Nothing
Set cd = Nothing
Set cn = Nothing
frmMain.Toolbar1.Buttons.Item(6).Visible = True
Unload Me
RptPurBill.Show
'ss:
' If Err.Number = 3021 Then
' Resume Next
' End If
End Sub

Private Sub butCancel_Click()


Unload Me
End Sub

Private Sub Form_Load()


MakeConnection "temp.mdb"
Dim t As String
t = "Sundry Creditor"
SQLQuerry = "select aname from acdet where grp=" & "'" & t & "'"
cd.Open SQLQuerry, cn, adOpenStatic, adLockReadOnly

Do While Not cd.EOF = True


cmbName.AddItem cd!aName
cd.MoveNext
Loop
End Sub

67
Private Sub Form_Unload(Cancel As Integer)
Set pm = Nothing
Set pd = Nothing
Set cd = Nothing
Set cn = Nothing
End Sub

Private Sub txtBillNo_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
cmbName.SetFocus
End If
End Sub

68
Help Form
Private Sub cmbHelp_Click()
Dim ss As String
On Error GoTo ss
If cmbHelp.ListIndex = 0 Then
txtHelpBox.LoadFile App.Path + "\AbtPrj.rtf"
ElseIf cmbHelp.ListIndex = 1 Then
txtHelpBox.LoadFile App.Path + "\NACCCre.rtf"
ElseIf cmbHelp.ListIndex = 2 Then
txtHelpBox.LoadFile App.Path + "\NItemG.rtf"
ElseIf cmbHelp.ListIndex = 3 Then
txtHelpBox.LoadFile App.Path + "\NItem.rtf"
ElseIf cmbHelp.ListIndex = 4 Then
txtHelpBox.LoadFile App.Path + "\SEntry.rtf"
ElseIf cmbHelp.ListIndex = 5 Then
txtHelpBox.LoadFile App.Path + "\PEntry.rtf"
ElseIf cmbHelp.ListIndex = 6 Then
txtHelpBox.LoadFile App.Path + "\EXPRETURN.rtf"
ElseIf cmbHelp.ListIndex = 7 Then
txtHelpBox.LoadFile App.Path + "\VOUCHER.rtf"
ElseIf cmbHelp.ListIndex = 8 Then
txtHelpBox.LoadFile App.Path + "\Ledger.rtf"
ElseIf cmbHelp.ListIndex = 9 Then
txtHelpBox.LoadFile App.Path + "\Display PURCHASE BILL.rtf"
ElseIf cmbHelp.ListIndex = 10 Then
txtHelpBox.LoadFile App.Path + "\STOCK ITEM WISE.rtf"
ElseIf cmbHelp.ListIndex = 11 Then
txtHelpBox.LoadFile App.Path + "\STOCK Date WISE.rtf"
ElseIf cmbHelp.ListIndex = 12 Then
txtHelpBox.LoadFile App.Path + "\EXPIRY STOCK.rtf"
ElseIf cmbHelp.ListIndex = 13 Then
txtHelpBox.LoadFile App.Path + "\ADD USER.rtf"
End If
ss:
If Err.Number = 75 Then
MsgBox "Help File Missing", vbCritical, "Sood Medicine Store"
Err.Clear
Resume Next
End If
End Sub

Private Sub cmbHelp_KeyPress(KeyAscii As Integer)


If KeyAscii = 27 Then
Unload Me
End If

69
End Sub

Private Sub Form_Activate()


Me.Left = 50
Me.Top = 100
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)


If KeyAscii = 27 Then
Unload Me
End If
End Sub

Private Sub txtHelpBox_KeyDown(KeyCode As Integer, Shift As Integer)


If KeyAscii = 27 Then
Unload Me
End If
End Sub

Private Sub txtHelpBox_KeyPress(KeyAscii As Integer)


If KeyAscii = 27 Then
Unload Me
End If
End Sub

70
Item Group
Dim StoreItemGrpToModify As String
Dim SQLQuerry As String
Private Sub PopulateCmbItemGrp()
cmbItemGrp.Clear
Dim TempRstCmbgrp As New ADODB.Recordset
SQLQuerry = "Select * from ItemGrpDet order by ItemGrp"
With TempRstCmbgrp
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
Do While Not .EOF
cmbItemGrp.AddItem .Fields("ItemGrp").Value
.MoveNext
Loop
End If
End With
Set TempRstCmbgrp = Nothing
End Sub

Private Sub butCancel_Click()


Unload Me
End Sub

Private Sub butModify_Click()


If IsFieldValid = False Then
Exit Sub
End If
If Trim(UCase(StoreItemGrpToModify)) <>
Trim(UCase(txtItemGrp.Text)) Then
If IsRecordAlreadyExist(txtItemGrp.Text) = True Then
Exit Sub
End If
End If
Call DeleteRecordFromItemGrpDet(StoreItemGrpToModify)
Call SaveDataInItemGrpDet
txtItemGrp.Text = ""
MsgBox "Modified", , "Medicine Store"
Call PopulateCmbItemGrp
End Sub

Private Sub butRefresh_Click()


Call PopulateCmbItemGrp
End Sub

Private Sub butSave_Click()

71
If IsFieldValid = False Then
Exit Sub
End If
If IsRecordAlreadyExist(txtItemGrp.Text) = True Then
Exit Sub
End If
Call SaveDataInItemGrpDet
MsgBox "Record Saved", , "Medicine Store"
txtItemGrp.Text = ""
Call PopulateCmbItemGrp
End Sub

Private Sub cmbItemGrp_Click()


StoreItemGrpToModify = cmbItemGrp.List(cmbItemGrp.ListIndex)
txtItemGrp.Text = cmbItemGrp.List(cmbItemGrp.ListIndex)
End Sub

Private Sub Form_Load()


Call PopulateCmbItemGrp
End Sub

Private Function IsFieldValid() As Boolean


If Len(Trim(txtItemGrp.Text)) = 0 Then
MsgBox "Enter A Valid Group Name", , "Medicine Store"
IsFieldValid = False
Exit Function
Else
IsFieldValid = True
End If
End Function

Private Sub SaveDataInItemGrpDet()


cn.Execute "Insert into ItemGrpDet values ( " & "'" & txtItemGrp.Text
& "'" & ")"
End Sub

Private Function IsRecordAlreadyExist(varItemGrp As String) As


Boolean
SQLQuerry = "Select * from ItemGrpDet where ItemGrp = " & "'" &
varItemGrp & "'"
Dim TempRstExistGrp As New ADODB.Recordset
With TempRstExistGrp
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
IsRecordAlreadyExist = True

72
MsgBox "Record Already Exist", , "Medicine Store"
Exit Function
Else
IsRecordAlreadyExist = False
End If
End With
Set TempRstExistGrp = Nothing
End Function

Private Sub DeleteRecordFromItemGrpDet(varItemGrp As String)


cn.Execute "Delete From itemGrpDet where ItemGrp = " & "'" &
varItemGrp & "'"
End Sub

Private Sub txtItemGrp_LostFocus()


txtItemGrp.Text = Trim(txtItemGrp.Text)
End Sub

73
Item Transaction
Dim StoreItemNameToModify As String
Dim SQLQuerry As String
Private Sub butCancel_Click()
Unload Me
End Sub

Private Sub butDelete_Click()


DeleteItemFromItemDet txtItem.Text
Call ClearFields
PopulateCmbItem
MsgBox "Deleted", , "Medicine Store"
End Sub

Private Sub butModify_Click()


If Len(Trim(txtItem.Text)) = 0 Then
MsgBox "Select Item to Modify", , "Medicine Store"
Exit Sub
End If
If IsFieldsValid = False Then
Exit Sub
End If
If Trim(UCase(StoreItemNameToModify)) <>
Trim(UCase(txtItem.Text)) Then
If IsItemAlreadyExist(txtItem.Text) = True Then
Exit Sub
End If
End If
Call DeleteItemFromItemDet(StoreItemNameToModify)
Call SaveDataInItemDet
MsgBox "Record Modified", , "Medicine Store"
ClearFields
PopulateCmbItem
End Sub

Private Sub butSave_Click()


If IsFieldsValid = False Then
Exit Sub
End If
If IsItemAlreadyExist(txtItem.Text) = True Then
Exit Sub
End If
Call SaveDataInItemDet
MsgBox "Saved", , "Medicine Store"
ClearFields

74
PopulateCmbItem
End Sub

Private Sub cmbGrp_Click()


txtItemGrp.Text = cmbGrp.List(cmbGrp.ListIndex)
End Sub

Private Sub cmbGrp_KeyPress(KeyAscii As Integer)


txtItemGrp.Text = cmbGrp.List(cmbGrp.ListIndex)
If KeyAscii = 13 Then
frameGrp.Visible = False
End If
End Sub

Private Sub cmbGrp_LostFocus()


txtItemGrp.Text = cmbGrp.List(cmbGrp.ListIndex)
End Sub

Private Sub cmbItem_Click()


StoreItemNameToModify = cmbItem.List(cmbItem.ListIndex)
Dim RstItemDetailDisplay As New ADODB.Recordset
SQLQuerry = "Select * from ItemDet where iname = " & "'" &
cmbItem.List(cmbItem.ListIndex) & "'"
With RstItemDetailDisplay
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
txtItem.Text = .Fields("iname").Value
txtItemGrp.Text = .Fields("itype").Value
txtMrp.Text = .Fields("mrp").Value
txtSaleRate.Text = .Fields("srate").Value
txtOpStock.Text = .Fields("op").Value
txtOpValue.Text = .Fields("opValue").Value
End If
End With
Set RstItemDetailDisplay = Nothing
End Sub

Private Sub Form_Activate()


Me.Left = 100
Me.Top = 100
End Sub

Private Sub Form_Load()


Call PopulateCmbGrp

75
Call PopulateCmbItem
End Sub

Private Sub calOpBalanceValue()


txtOpValue.Text = Val(txtOpStock.Text) * Val(txtSaleRate.Text)
End Sub

Private Sub txtItem_LostFocus()


txtItem.Text = Trim(txtItem.Text)
End Sub

Private Sub PopulateCmbGrp()


cmbGrp.Clear
cmbGrp.Text = "TaxAble Category"
Dim RstGrpC As New ADODB.Recordset
SQLQuerry = "Select * from ItemGrpDet"
With RstGrpC
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
Do While Not .EOF
cmbGrp.AddItem .Fields("ItemGrp").Value
.MoveNext
Loop
End If
End With
End Sub

Private Sub PopulateCmbItem()


cmbItem.Clear
cmbItem.Text = "Item Name"
Dim RstCmbItempop As New ADODB.Recordset
SQLQuerry = "Select * from itemDet"
With RstCmbItempop
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
.MoveFirst
End If
Do While Not .EOF
cmbItem.AddItem .Fields("iname").Value
.MoveNext
Loop
End With
Set RstCmbItempop = Nothing
End Sub

Private Function IsFieldsValid() As Boolean

76
If Len(Trim(txtItem.Text)) = 0 Then
MsgBox "Enter A Valid Item Name", , "Medicine Store"
IsFieldsValid = False
Exit Function
End If

If Len(Trim(txtItemGrp.Text)) = 0 Then
MsgBox "Select A Valid Group", , "Medicine Store"
IsFieldsValid = False
txtItemGrp.SetFocus
Exit Function
End If

If Val(txtMrp.Text) <= 0 Then


MsgBox "Enter A Valid MRP", , "Medicine Store"
IsFieldsValid = False
txtMrp.SetFocus
Exit Function
End If

If Val(txtSaleRate.Text) <= 0 Then


MsgBox "Enter A Valid Sale Rate", , "Medicine Store"
IsFieldsValid = False
txtSaleRate.SetFocus
Exit Function
End If

If Val(txtOpStock.Text) <= 0 Then


txtOpStock.Text = " "
End If

If Val(txtOpValue.Text) <= 0 Then


txtOpValue.Text = " "
End If
IsFieldsValid = True
End Function

Private Sub SaveDataInItemDet()


cn.Execute "Insert into ItemDet Values ( " & "'" & txtItem.Text & "'"
& "," & "'" & txtItemGrp & "'" & "," & "'" & txtMrp.Text & "'" & "," & "'" &
txtSaleRate.Text & "'" & "," & "'" & txtOpStock.Text & "'" & "," & "'" &
txtOpValue.Text & "'" & ")"
End Sub

77
Private Function IsItemAlreadyExist(varItemName As String) As
Boolean
SQLQuerry = "Select * from ItemDet where iname = " & "'" &
varItemName & "'"
Dim RstChekItemExist As New ADODB.Recordset
With RstChekItemExist
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
MsgBox "Item Already Exist", , "Medicine Store"
IsItemAlreadyExist = True
Exit Function
Else
IsItemAlreadyExist = False
End If
End With
End Function

Private Sub DeleteItemFromItemDet(varItemName As String)


cn.Execute "Delete From itemDet where iname = " & "'" &
varItemName & "'"
End Sub

Private Sub ClearFields()


Dim cc As Control
For Each cc In frmItem
If TypeOf cc Is TextBox Then
cc.Text = ""
End If
Next
PopulateCmbItem
End Sub

Private Sub txtMrp_KeyPress(KeyAscii As Integer)


NumAllowOnly txtMrp, KeyAscii
End Sub

Private Sub txtOpStock_Change()


calOpBalanceValue
End Sub

Private Sub txtOpStock_KeyPress(KeyAscii As Integer)


NumAllowOnly txtOpStock, KeyAscii
End Sub

Private Sub txtOpValue_KeyPress(KeyAscii As Integer)


NumAllowOnly txtOpValue, KeyAscii

78
End Sub

Private Sub txtSaleRate_Change()


calOpBalanceValue
End Sub

Private Sub txtSaleRate_KeyPress(KeyAscii As Integer)


NumAllowOnly txtSaleRate, KeyAscii
End Sub

79
Voucher Entry
Dim RstFindRec As New ADODB.Recordset
Dim varDrIndex As Integer, varCrIndex As Integer
Dim varStoreVchType As String, VarClickedDisplay As Boolean,
SQuerry As String
Dim varSelFieldIndex As Integer
Private Sub PopulateCmbs()
Dim TempRstAcco As New ADODB.Recordset
Dim SQLQuerry As String
SQLQuerry = "Select aname,grp from Acdet"
With TempRstAcco
If .State = adStateOpen Then
.Close
End If
.Open SQLQuerry, cn, adOpenKeyset, adLockPessimistic
Do While Not .EOF
cmbDr.AddItem .Fields("Aname").Value
cmbDrG.AddItem .Fields("grp").Value
cmbCr.AddItem .Fields("Aname").Value
cmbCrG.AddItem .Fields("grp").Value
.MoveNext
Loop
End With
End Sub

Private Sub butClose_Click()


Unload Me
End Sub

Private Sub butClear_Click()


ClearFields
End Sub

Private Sub butDisplay_Click()


If Len(txtCriteria.Text) = 0 Then
MsgBox "Enter Value For Search", , "Medicine Store"
Exit Sub
End If
If cmbFF.ListIndex = -1 Then
MsgBox "Select Field Name from List", , "Medicine Store"
Exit Sub
End If
If Not FindOpenRecordSet(cmbFields.List(cmbFF.ListIndex),
txtCriteria.Text) Then

80
Exit Sub
Else
'ClearFields
'EnableDisable frmLabMaster, False
butFirst_Click
End If
End Sub

Private Sub butExit_Click()


Unload Me
End Sub

Private Sub butModify_Click()


If Not VarClickedDisplay Then
MsgBox "First Click on Display", , "Medicine Store"
Exit Sub
End If
If Val(txtVNo.Text) <= 0 Then
MsgBox "Invalid Process", , "Medicine Store"
Exit Sub
End If
If IsFieldEmpty Then
Exit Sub
End If
ModifyRec Val(txtVNo.Text)
ClearFields
End Sub

Private Sub butSave_Click()


If IsFieldEmpty Then
Exit Sub
End If
Dim RstATrn As New ADODB.Recordset
Dim SQLQuerry As String, VarStoreVchNo As Long
VarStoreVchNo = GenVchNo
txtVNo.Text = VarStoreVchNo
SQLQuerry = "Select * from mix"
With RstATrn
If .State = adStateOpen Then
.Close
End If
.Open SQLQuerry, cn, adOpenKeyset, adLockPessimistic
.AddNew
.Fields("vn").Value = Val(txtVNo.Text)
.Fields("edate").Value = txtDate.Text

81
.Fields("Acr").Value = txtAcr.Text
.Fields("Cg").Value = cmbCrG.List(varCrIndex)
.Fields("Cn").Value = txtCn.Text
.Fields("Camt").Value = Val(txtCamt.Text)
.Fields("Adr").Value = txtAdr.Text
.Fields("Dg").Value = cmbDrG.List(varDrIndex)
.Fields("dn").Value = txtDn.Text
.Fields("Damt").Value = Val(txtDamt.Text)
If optReceipt.Value = True Then
.Fields("vType").Value = optReceipt.Caption
ElseIf optPayment.Value = True Then
.Fields("vType").Value = optPayment.Caption
Else
.Fields("vType").Value = optJournal.Caption
End If
.Update
End With
MsgBox "Saved", , "Medicine Store"
Call ClearFields
cmbDr.SetFocus
End Sub
Private Function GenVchNo()
Dim SQLQuerry As String
Dim RstMixVch As New ADODB.Recordset
With RstMixVch
SQLQuerry = "Select count(*),max(vn) from mix"
If .State = adStateOpen Then
.Close
End If
.Open SQLQuerry, cn, adOpenKeyset, adLockPessimistic
If .State = adStateOpen Then
If Not IsNull(.Fields(0).Value) Then
If .Fields(0).Value > 0 Then
GenVchNo = .Fields(1).Value + 1
Else
GenVchNo = 1
End If
Else
GenVchNo = 1
End If
End If
End With
End Function

Private Function IsFieldEmpty() As Boolean


If txtAdr.Text = txtAcr.Text Then

82
MsgBox "Invalid Not Possible", , "Medicine Store"
IsFieldEmpty = True
Exit Function
End If
If Len(Trim(txtAdr.Text)) = 0 Then
MsgBox "A/c Debit", , "Medicine Store"
IsFieldEmpty = True
Exit Function
End If

If Len(Trim(txtAcr.Text)) = 0 Then
MsgBox "A/c Credit", , "Medicine Store"
IsFieldEmpty = True
Exit Function
End If

If Val(txtDamt.Text) <= 0 Then


MsgBox "Enter Valid Amount", , "Medicine Store"
IsFieldEmpty = True
Exit Function
End If

If Val(txtCamt.Text) <= 0 Then


MsgBox "Enter Valid Amount", , "Medicine Store"
IsFieldEmpty = True
Exit Function
End If

If Val(txtDamt.Text) <> Val(txtCamt.Text) Then


MsgBox "Amount Not matched", , "Medicine Store"
IsFieldEmpty = True
Exit Function
End If
If Len(Trim(txtDn.Text)) = 0 Then
txtDn.Text = " "
End If
If Len(Trim(txtCn.Text)) = 0 Then
txtCn.Text = " "
End If
IsFieldEmpty = False
End Function
'Private Sub ClearFields()
' txtAdr.Text = ""
' txtDamt.Text = ""
' txtAcr.Text = ""
' txtCamt.Text = ""

83
' txtDn.Text = ""
' txtCn.Text = ""
'End Sub
Private Sub cmbCr_Click()
varCrIndex = cmbCr.ListIndex
txtAcr.Text = cmbDr.List(cmbCr.ListIndex)
End Sub

Private Sub cmbCr_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtCamt.SetFocus
End If
End Sub

Private Sub cmbCriteria_Click()


txtCriteria.Text = cmbCriteria.List(cmbCriteria.ListIndex)
End Sub

Private Sub cmbDr_Click()


varDrIndex = cmbDr.ListIndex
txtAdr.Text = cmbDr.List(cmbDr.ListIndex)
End Sub

Private Sub cmbDr_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtDamt.SetFocus
End If
End Sub

Private Sub cmbFF_Click()


If cmbFF.ListIndex >= 0 Then
'FillCmbValuesWithSelectedField
cmbFields.List(cmbFields.ListIndex)
FillCmbValuesWithSelectedField cmbFields.List(cmbFF.ListIndex)
End If
varSelFieldIndex = cmbFF.ListIndex
End Sub

Private Sub cmbFields_Click()


' If cmbFields.ListIndex >= 0 Then
' FillCmbValuesWithSelectedField
cmbFields.List(cmbFields.ListIndex)
' End If
' varSelFieldIndex = 0
End Sub

84
Private Sub Form_Activate()
Me.Top = 250
Me.Left = 500
End Sub

Private Sub Form_Load()


MakeConnection ("temp.mdb")
txtDate.Text = Date
PopulateCmbs
PopulateFieldNamesForFind
txtVNo = GenVchNo
CentreScreen
End Sub

Private Sub CentreScreen()


frmJournal.Left = (Screen.Width - frmJournal.Width) / 2
frmJournal.Top = (Screen.Height - frmJournal.Height) / 2
End Sub

Private Sub txtCamt_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 46 Or KeyAscii
= 8 Then
txtCamt.Text = txtCamt.Text + vbkeyascii
Else
If KeyAscii = 13 Then
txtCn.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If
End Sub

Private Sub txtCn_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
butSave.SetFocus
End If
End Sub

Private Sub txtDamt_Change()


txtCamt.Text = txtDamt.Text
End Sub

Private Sub txtDamt_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 46 Or KeyAscii
= 8 Then

85
txtDamt.Text = txtDamt.Text + vbkeyascii
Else
If KeyAscii = 13 Then
txtDn.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If
End Sub

Private Sub txtDate_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Or KeyAscii =
45 Then
txtDate.Text = txtDate.Text + vbkeyascii
Else
If KeyAscii = 13 Then
cmbDr.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If
End Sub

Private Sub butFirst_Click()


If Not VarClickedDisplay Then
MsgBox "Click on Display Button First", , "Medicine Store"
Exit Sub
End If
With RstFindRec
If .RecordCount > 0 Then
.MoveFirst
DisplayFindValue
End If
End With
VarClickedDisplay = True
End Sub

Private Sub butLast_Click()


If Not VarClickedDisplay Then
MsgBox "Click on Display Button First", , "Medicine Store"
Exit Sub
End If
With RstFindRec
If .RecordCount > 0 Then
.MoveLast

86
DisplayFindValue
End If
End With
VarClickedDisplay = True
End Sub

Private Sub butNext_Click()


If Not VarClickedDisplay Then
MsgBox "Click on Display Button First", , "Medicine Store"
Exit Sub
End If
With RstFindRec
If .EOF = False Then
.MoveNext
If .EOF = True Then
Exit Sub
End If
DisplayFindValue
End If
End With
VarClickedDisplay = True
End Sub

Private Sub butPrev_Click()


If Not VarClickedDisplay Then
MsgBox "Click on Display Button First", , "Medicine Store"
Exit Sub
End If
With RstFindRec
If .BOF = False Then
.MovePrevious
If .BOF = True Then
Exit Sub
End If
DisplayFindValue
End If
End With
VarClickedDisplay = True
End Sub

Private Sub DisplayFindValue()


With RstFindRec
txtVNo.Text = .Fields("vn").Value
txtDate.Text = .Fields("edate").Value
txtAcr.Text = .Fields("Acr").Value
For h = 0 To cmbCr.ListCount - 1

87
If txtAcr.Text = cmbCr.List(h) Then
varCrIndex = h
End If
Next
cmbCrG.List(varCrIndex) = .Fields("Cg").Value
txtCn.Text = .Fields("Cn").Value
txtCamt.Text = .Fields("Camt").Value
txtAdr.Text = .Fields("Adr").Value
For h = 0 To cmbDr.ListCount - 1
If txtAdr.Text = cmbDr.List(h) Then
varDrIndex = h
End If
Next
cmbDrG.List(varDrIndex) = .Fields("Cg").Value
txtDn.Text = .Fields("Cn").Value
txtDamt.Text = .Fields("Damt").Value
If .Fields("vType").Value = optReceipt.Caption Then
optReceipt.Value = True
ElseIf .Fields("vType").Value = optPayment.Caption Then
optPayment.Value = True
Else
optJournal.Value = True
End If
End With
End Sub

Private Sub FillCmbValuesWithSelectedField(varFieldName As String)


Dim RstCmbValue As New ADODB.Recordset
SQLQuerry = "Select distinct " & varFieldName & " from mix"
cmbCriteria.Clear
With RstCmbValue
.Open SQLQuerry, cn, adOpenKeyset, adLockReadOnly
Do While Not .EOF
cmbCriteria.AddItem .Fields(0).Value & ""
.MoveNext
Loop
End With
End Sub

Private Function FindOpenRecordSet(varFName As String, varValue As


String) As Boolean
If varSelFieldIndex = 0 Or varSelFieldIndex = 3 Or varSelFieldIndex
= 5 Then
SQLQuerry = "Select * from mix where " & varFName & " = " &
varValue
Else

88
SQLQuerry = "Select * from mix where " & varFName & " = " & "'"
& varValue & "'"
End If
With RstFindRec
If .State = adStateOpen Then
.Close
End If
.Open SQLQuerry, cn, adOpenKeyset, adLockReadOnly
If .RecordCount > 0 Then
FindOpenRecordSet = True
VarClickedDisplay = True
Else
FindOpenRecordSet = False
End If
End With
End Function

Private Sub PopulateFieldNamesForFind()


cmbFields.Clear
cmbFields.AddItem "vn"
cmbFields.AddItem "date"
cmbFields.AddItem "acr"
cmbFields.AddItem "camt"
cmbFields.AddItem "adr"
cmbFields.AddItem "damt"
cmbFF.Clear
cmbFF.AddItem "Vch No"
cmbFF.AddItem "Date"
cmbFF.AddItem "A/c Credit"
cmbFF.AddItem "Cr Amt"
cmbFF.AddItem "A/c Debit"
cmbFF.AddItem "Dr Amt"
End Sub

Private Sub ModifyRec(varRecNo As Long)


Dim RstModify As New ADODB.Recordset
SQuerry = "Select * from mix where Vn = " & varRecNo
With RstModify
If .State = adStateOpen Then
.Close
End If
.Open SQuerry, cn, adOpenKeyset, adLockOptimistic
If .RecordCount > 0 And Not IsNull(.Fields(0).Value) Then
.Fields("vn").Value = Val(txtVNo.Text)
.Fields("date").Value = txtDate.Text
.Fields("Acr").Value = txtAcr.Text

89
.Fields("Cg").Value = cmbCrG.List(varCrIndex)
.Fields("Cn").Value = txtCn.Text
.Fields("Camt").Value = Val(txtCamt.Text)
.Fields("Adr").Value = txtAdr.Text
.Fields("Dg").Value = cmbDrG.List(varDrIndex)
.Fields("dn").Value = txtDn.Text
.Fields("Damt").Value = Val(txtDamt.Text)
If optReceipt.Value = True Then
.Fields("VType").Value = optReceipt.Caption
ElseIf optPayment.Value = True Then
.Fields("VType").Value = optPayment.Caption
Else
.Fields("VType").Value = optJournal.Caption
End If
.Update
End If
End With
End Sub

Private Sub ClearFields()


Dim varR As Control
For Each varR In frmJournal
If TypeOf varR Is TextBox Then
varR.Text = ""
ElseIf TypeOf varR Is ComboBox Then
varR.ListIndex = -1
End If
Next
VarClickedDisplay = False
txtVNo.Text = GenVchNo
txtDate.Text = Date
End Sub

90
Ledger
Dim TempRst As New ADODB.Recordset
Dim i As Integer, j As Integer
Private Sub butClose_Click()
Unload Me
End Sub

Private Sub butDisp_Click()


Dim ss As String
' On Error GoTo ss
varNameR = Label1.Caption
varStDate = txtSt.Text
varEdDate = txtEd.Text
If Not IsDate(txtSt.Text) Or Not IsDate(txtEd.Text) Then
MsgBox "Date must be in Valid Format ", vbCritical, "DD-MM-YY"
txtSt.SetFocus
Exit Sub
End If
cmbAcco.SetFocus
t3 = ""
bb = ""
Dim tmix As New Recordset
If Not IsDate(txtSt.Text) Then
MsgBox "Invalid Date", vbInformation, "DD-MM-YY"
txtSt.SetFocus
Exit Sub
End If
If Not IsDate(txtEd.Text) Then
MsgBox "Invalid Date", vbInformation, "DD-MM-YY"
txtEd.SetFocus
Exit Sub
End If

If cmbAcco.ListIndex = -1 Then
MsgBox "Select A/c To List", , "Medicine Store"
cmbAcco.SetFocus
Exit Sub
End If
cmbAcco.SetFocus
cn.Execute "delete from led"
Me.MousePointer = vbHourglass
tmix.Open "select * from mix where Adr =" & "'" &
cmbAcco.List(cmbAcco.ListIndex) & "'" & " or Acr = " & "'" &
cmbAcco.List(cmbAcco.ListIndex) & "'" _

91
& " order by vn ", cn, adOpenKeyset, adLockPessimistic
j=1
i=1
Dim d As Double, c As Double
Dim fg As Integer
Dim td As Double, tc As Double
td = 0
tc = 0
ListView1.ListItems.Clear
tot1 = 0
tot2 = 0

'''''''For Getting Opening Balance

Do While Not tmix.EOF


If tmix!eDate < CDate(txtSt.Text) Then
If tmix!acr = cmbAcco.List(cmbAcco.ListIndex) And tmix!cg =
cmbAccoG.List(cmbAcco.ListIndex) Then
tc = tc + tmix!Camt
tot1 = tot1 + tmix!Camt
End If
If tmix!adr = cmbAcco.List(cmbAcco.ListIndex) And tmix!dg =
cmbAccoG.List(cmbAcco.ListIndex) Then
td = td + tmix!damt
tot2 = tot2 + tmix!damt
End If
End If
tmix.MoveNext
Loop

Dim hh As Double, hh1 As Double


If tc - td > 0 Or td - tc > 0 Then
Set a = ListView1.ListItems.Add(j, , " ")
With a
.SubItems(i) = "Opening Balance "
i=i+1
If td > 0 Then
.SubItems(i) = td
hh = td
Else
.SubItems(i) = " "
End If
i=i+1
If tc > 0 Then
.SubItems(i) = Val(tc)
hh = tc

92
Else
.SubItems(i) = " "
End If
i=i+1
If tc > td Then
.SubItems(i) = Str(tc - td) + " Cr"
ElseIf td > tc Then
.SubItems(i) = Str(td - tc) + " Dr"
Else
.SubItems(i) = "NiLL"
End If
j=j+1
End With
i=1
End If

'''''''''''BLOCK FOR ADDING ENTERIES'''''''''''


tc = 0
tot1 = 0

If tmix.RecordCount > 0 Then


tmix.MoveFirst
End If

Do While Not tmix.EOF


If tmix!eDate >= CDate(txtSt.Text) And tmix!eDate <=
CDate(txtEd.Text) Then
If tmix!acr = cmbAcco.List(cmbAcco.ListIndex) And tmix!cg =
cmbAccoG.List(cmbAcco.ListIndex) Then
pa = tmix!cn
ca = Str(tmix!Camt)
tc = tc + tmix!Camt
tot1 = tot1 + tmix!Camt
fg = 1
End If
If tmix!adr = cmbAcco.List(cmbAcco.ListIndex) And tmix!dg =
cmbAccoG.List(cmbAcco.ListIndex) Then
pa = tmix!dn
da = Str(tmix!damt)
td = td + tmix!damt
tot2 = tot2 + tmix!damt
fg = 2
End If
End If

93
If fg = 1 Or fg = 2 Then
Set a = ListView1.ListItems.Add(j, , tmix!eDate)
With a
If IsNull(pa) Then
.SubItems(i) = " "
Else
.SubItems(i) = pa
End If
i=i+1
If Val(da) > 0 Then
.SubItems(i) = Val(da)
Else
.SubItems(i) = " "
End If
i=i+1
If Val(ca) > 0 Then
.SubItems(i) = Val(ca)
Else
.SubItems(i) = " "
End If
i=i+1
If Val(td) > Val(tc) Then
.SubItems(i) = Str(Round(td - tc, 2)) + " Dr"
ElseIf Val(tc) > Val(td) Then
.SubItems(i) = Str(Round(tc - td, 2)) + " Cr"
Else
.SubItems(i) = "NiLL"
End If
j=j+1
End With
i=1
End If
tmix.MoveNext
pa = ""
ca = ""
da = ""
Loop
d=0
c=0
d=0
c=0
i=0
Dim jd As Double
For i = 1 To ListView1.ListItems.Count
d = d + Val(ListView1.ListItems(i).SubItems(2))

94
c = c + Val(ListView1.ListItems(i).SubItems(3))
jd = 0
If d > c Then
bb = Str(Round(d - c, 2)) + " Dr"
hh1 = d - c
Else
If c > d Then
bb = Str(Round(c - d, 2)) + " Cr"
hh1 = c - d
Else
bb = "NiLL"
End If
End If
ListView1.ListItems(i).SubItems(4) = bb
Next

Label3.Caption = "Dr " + FormatNumber(d, , vbUseDefault) + "


" + "Cr " + FormatNumber(c, , vbUseDefault) + " "+
"Balance" + " " + bb

t1 = d
t2 = c
t3 = bb
tmix.Close
Set tmix = Nothing
Me.MousePointer = vbNormal
'ss:
' If Err.Number = 3021 Then
' Resume Next
' End If
End Sub

Private Sub butPrint_Click()


frmMain.Toolbar1.Buttons.Item(6).Visible = True
Me.MousePointer = vbHourglass
Call SendDataInLedTableForPrinting
Unload Me
Me.MousePointer = vbNormal
DataReport1.Show
End Sub

Private Sub cmbAcco_Click()


Label1.Caption = cmbAcco.List(cmbAcco.ListIndex)

95
End Sub

Private Sub Command3_Click()

End Sub

Private Sub cmbAcco_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
butDisp.SetFocus
End If
End Sub

Private Sub Form_Load()


MakeConnection "temp.mdb"
txtSt.Text = "1-04-06"
txtEd.Text = Date
cmbAcco.Clear
cmbAccoG.Clear
i=1
j=1
With TempRst
If .State = adStateOpen Then
.Close
End If
.Open "select Aname,grp from acdet", cn, adOpenDynamic,
adLockPessimistic
Do While Not .EOF
cmbAcco.AddItem .Fields("Aname").Value
cmbAccoG.AddItem .Fields("grp").Value
.MoveNext
Loop
End With
ListView1.ColumnHeaders.Add 1, , "DATE", 1200
ListView1.ColumnHeaders.Add 2, , "PARTICULAR", 3000
ListView1.ColumnHeaders.Add 3, , "DEBIT", 1000
ListView1.ColumnHeaders.Add 4, , "CREDIT", 1000
ListView1.ColumnHeaders.Add 5, , "BALANCE", 1500
End Sub

Private Sub txtEd_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Or KeyAscii =
45 Then
txtEd.Text = txtEd.Text + vbkeyascii
Else
If KeyAscii = 13 Then
cmbAcco.SetFocus

96
Else
KeyAscii = Val(vbkeyascii)
End If
End If
End Sub

Private Sub SendDataInLedTableForPrinting()


On Error GoTo ss
cn.Execute "delete from led"
Dim d1 As String, d2 As String, d3 As String, d4 As String
Dim d5 As String

d1 = UCase(Label1.Caption)

d2 = "Account Of "

d3 = " "
cn.Execute "insert into led values(" & "'" & d2 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d3 & "'" _
& "," & "'" & d3 & "'" _
& "," & "'" & d3 & "'" & ")"

d1 =
"--------------------------------------------------------------------------------------------------
--"

cn.Execute "insert into led values(" & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" & ")"

d1 = "DATE"
d2 = "PARTICULARS"
d3 = "DEBIT"
d4 = "CREDIT"
d5 = "BALANCE"

cn.Execute "insert into led values(" & "'" & d1 & "'" _
& "," & "'" & d2 & "'" _
& "," & "'" & d3 & "'" _
& "," & "'" & d4 & "'" _

97
& "," & "'" & d5 & "'" & ")"

d1 =
"--------------------------------------------------------------------------------------------------
--"

cn.Execute "insert into led values(" & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" & ")"

Dim d6 As String, d7 As String

For i = 1 To ListView1.ListItems.Count

If Val(ListView1.ListItems(i).SubItems(2)) > 0 Then


d6 = FormatNumber(Val(ListView1.ListItems(i).SubItems(2)))
tot1 = tot1 + Val(ListView1.ListItems(i).SubItems(2))
Else
d6 = " "
End If

If Val(ListView1.ListItems(i).SubItems(3)) > 0 Then


d7 = FormatNumber(Val(ListView1.ListItems(i).SubItems(3)))
tot2 = tot2 + Val(ListView1.ListItems(i).SubItems(3))
Else
d7 = " "
End If

cn.Execute "insert into LED values(" & "'" &


ListView1.ListItems(i).Text & "'" _
& "," & "'" & ListView1.ListItems(i).SubItems(1) & "'" _
& "," & "'" & d6 & "'" _
& "," & "'" & d7 & "'" _
& "," & "'" & ListView1.ListItems(i).SubItems(4) & "'" & ")"

Next

d1 =
"-------------------------------------------------------------------------------------------"

98
cn.Execute "insert into led values(" & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" & ")"

d1 = " "
d2 = "TOTAL "

cn.Execute "insert into led values(" & "'" & d1 & "'" _
& "," & "'" & d2 & "'" _
& "," & "'" & FormatNumber(tot1, , vbUseDefault) & "'" _
& "," & "'" & FormatNumber(tot2, , vbUseDefault) & "'" _
& "," & "'" & t3 & "'" & ")"

d1 =
"-------------------------------------------------------------------------------------------"

cn.Execute "insert into led values(" & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" & ")"

cn.Execute "insert into led values(" & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" _
& "," & "'" & d1 & "'" & ")"
ss:
If Err.Number = 8542 Then
MsgBox "Please Increase Paper Size into Printer settings",
vbCritical, "Invalid Paper Size"
Err.Clear
Exit Sub
End If
End Sub

Private Sub txtSt_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Or KeyAscii =
45 Then

99
txtSt.Text = txtSt.Text + vbkeyascii
Else
If KeyAscii = 13 Then
txtEd.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If
End Sub

100
Purchase Entry
'Option Explicit
Dim ty As String
Dim it As New Recordset ' for item list
Dim clist As New Recordset ' for list of creditor
Dim tmix As New Recordset ' for getting max voucher number
Dim itype As String, imrp As String ' for cmbItem store mrp or group
Dim b As ColumnHeader
Dim a As ListItem
Dim sno As String
Dim i As Integer, j As Integer, c As Integer 'for listview
Dim q As Double ' for modify purchase store limit of qty
Dim q1 As Double ' for total sale modify purchase
Dim bnum As String ' for bill number for modify purchase
Dim ky As String
Dim sq As Double
'Dim t As Double 'for total sale sch or replace pcs
'Dim t1 As Double ' for total purchase pcs
Dim tpp As Double ' for total purchase
Dim tem As Double ' for purchase modify store pcs in case of p modi

Private Sub cmbName_Click()


'Dim ss As String
'On Error GoTo ss
txtName.Text = cmbName.Text
clist.MoveFirst
Do While Not clist.EOF = True
If clist!aName = cmbName.Text Then
txtName.Text = clist!aName
txtAddress.Text = clist!Address
If Len(clist!vatno) = 0 Then
sno = " "
Else
sno = clist!vatno
End If
Exit Sub
End If
clist.MoveNext
Loop
'ss:
'If Err.Number = 3021 Then
'Resume Next
'End If
End Sub

101
Private Sub cmbName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmbItem.SetFocus
End If
End Sub

Private Sub cmbItem_Click()


Dim ss As String
'On Error GoTo ss
txtItem.Text = cmbItem.Text
it.MoveFirst
Do While Not it.EOF = True
If it!iname = cmbItem.Text Then
itype = it!itype
imrp = it!mrp
Label15.Caption = it!itype
txtMrp.Text = it!mrp
txtSRate.Text = it.Fields(2).Value
Exit Sub
End If
it.MoveNext
Loop
'ss:
'If Err.Number = 3021 Then
'Resume Next
'End If
End Sub

Private Sub cmbItem_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtMrp.SetFocus
End If
End Sub

Private Sub Combo3_Click()


cmbItem.Text = Combo3.Text
End Sub

Private Sub butSave_Click()


If Not IsDate(txtDate.Text) Then
MsgBox "Date must be in Valid format", vbCritical, "DD-MM-YY"
Exit Sub
End If
txtDate.Text = Format(txtDate.Text, "dd-MM-YY")
If Len(txtDate.Text) < 6 Then

102
MsgBox "Enter Bill Date", vbOKOnly, "DD-MM-YY"
Exit Sub
End If

txtBillNo.Text = UCase(txtBillNo.Text)
If Len(txtBillNo.Text) = 0 Then
MsgBox "Enter Bill No", , "Medicine Store"
Exit Sub
End If

If UCase(txtBillNo.Text) = "REPL" Then


MsgBox "Enter Bill No And Dont' Delete already written Word
Repl", vbCritical, "Invalid Entry"
Exit Sub
End If

If Len(txtName.Text) = 0 Then
MsgBox "Select company Name", , "Medicine Store"
Exit Sub
End If

' If Module1.prep = "purchase" Then


If Option1.Value = False And Option2.Value = False Then
MsgBox "Select Cash/Cr.", , "Medicine Store"
Exit Sub
End If
' End If

If checkBillAlreadyExist Then
MsgBox "Bill Already Exist", , "Medicine Store"
Exit Sub
End If

If Module1.prep = "pmodi" Then


clist.MoveFirst
Do While Not clist.EOF = True
If clist!aName = txtName.Text Then
txtName.Text = clist!aName
txtAddress.Text = clist!Address
If Len(clist!vatno) = 0 Then
sno = " "
Else
sno = clist!vatno
End If
Exit Do

103
End If
clist.MoveNext
Loop
End If
Dim ch As String
If Len(txtDiscTotal.Text) = 0 Then
ch = MsgBox("Do You Want Enter Disocunt", vbYesNo, "Medicine
Store")
If ch = vbYes Then
Exit Sub
Else
txtDiscTotal.Text = 0
End If
End If

If Len(txtFr.Text) = 0 Then
ch = MsgBox("Do You Want Enter Freight & Octroi", vbYesNo,
"Medicine Store")
If ch = vbYes Then
Exit Sub
Else
txtFr.Text = 0
End If
End If

If Len(txtLabour.Text) = 0 Then
ch = MsgBox("Do You Want Enter Labour", vbYesNo, "Medicine
Store")
If ch = vbYes Then
Exit Sub
Else
txtLabour.Text = 0
End If
End If

Dim tot As Double


tot = 0
If Option1.Value = True Then
ty = "cr"
Else
If Option2.Value = True Then
ty = "cash"
End If
End If

If ListView1.ListItems.Count = 0 Then

104
MsgBox "Click On Next Button", , "Medicine Store"
Exit Sub
End If

If Module1.prep = "pmodi" Then


cn.Execute "delete from [pmain] where [bno]=" & "'" & bnum &
"'" & "and [cname]=" & "'" & txtName.Text & "'"
cn.Execute "delete from [pdet] where [bno]=" & "'" & bnum & "'"
& "and [cname]=" & "'" & txtName.Text & "'"
cn.Execute "delete from [mix] where [kk]=" & "'" & ky & "'"
End If

For i = 1 To ListView1.ListItems.Count
'cn.Execute "insert into [pdet] values(" & "'" & txtBillNo.Text & "'"
& "," & "'" & ListView1.ListItems.Item(i).SubItems(1) & "'" & "," & "'" &
ListView1.ListItems.Item(i).SubItems(2) & "'" & "," & "'" &
ListView1.ListItems.Item(i).SubItems(3)& "'" & "," &
val(ListView1.ListItems.Item(i).SubItems(4)) & "," &
val(ListView1.ListItems.Item(i).SubItems(5) & "," &
val(ListView1.ListItems.Item(i).SubItems(6))& "," & "'"& txtName.Text &
"'" & "," & "'" & sno & "'" & "," &
val(ListView1.ListItems.Item(i).SubItems(7)) & ")"
cn.Execute "insert into pdet values(" & "'" & txtBillNo.Text & "'" &
"," & "'" & ListView1.ListItems.Item(i).SubItems(1) & "'" & "," & "'" &
ListView1.ListItems.Item(i).SubItems(2) & "'" & "," & "'" &
ListView1.ListItems.Item(i).SubItems(3) & "'" & "," &
Val(ListView1.ListItems.Item(i).SubItems(4)) & "," &
Val(ListView1.ListItems.Item(i).SubItems(5)) & "," &
Val(ListView1.ListItems.Item(i).SubItems(6)) & "," & "'" & txtName.Text
& "'" & "," & "'" & sno & "'" & "," &
Val(ListView1.ListItems.Item(i).SubItems(7)) & "," & "'" &
CDate(txtDate.Text) & "'" & "," &
Val(ListView1.ListItems.Item(i).SubItems(8)) & ")"
tot = tot + Val(ListView1.ListItems.Item(i).SubItems(7))
Next
tot = tot - Val(txtDiscTotal.Text)
txtTotal.Text = Str(tot)

cn.Execute "insert into pmain values(" & "'" & CDate(txtDate.Text) &
"'" & "," & "'" & txtBillNo.Text & "'" & "," & "'" & txtName.Text & "'" &
"," & "'" & ty & "'" & "," & Val(txtDiscTotal.Text) & "," &
Val(txtTotal.Text) & "," & Val(txtLabour.Text) & "," & Val(txtFr.Text) &
")"

' block start for saving dis freight labour entry in mix

105
Dim k As String, b1 As String
Dim nar As String, an1 As String, nar1 As String
Dim tg As String, an2 As String, typ As String
Dim k1 As Double
k1 = 0
Dim t1 As String

k = "B" + txtBillNo.Text + "D" + Str(CDate(txtDate.Text)) + "P" +


txtName.Text
nar = "By Bill No " & txtBillNo.Text
tg = "cred"
an1 = "Purchase A/c"

If Option1.Value = True Then


an2 = "Purchase"
nar1 = "To Bill No " & txtBillNo.Text
End If

If Option2.Value = True Then


an2 = "Cash"
nar1 = "By Bill No " & txtBillNo.Text
End If

typ = "Purchase"
Module1.vch = Module1.vch + 1

If Option1.Value = True Then


cn.Execute "insert into mix values(" & Module1.vch & "," & "'" &
CDate(txtDate.Text) & "'" _
& "," & "'" & txtName.Text & "'" & "," & "'" & tg & "'" & "," & "'" &
nar & "'" & "," _
& Val(txtTotal.Text) & "," & "'" & an1 & "'" & "," & "'" & an2 & "'" &
"," _
& "'" & nar1 & "'" & "," & Val(txtTotal.Text) & "," & "'" & k & "'" &
"," & "'" & typ & "'" _
& ")"
Else
If Option2.Value = True Then
cn.Execute "insert into mix values(" & Module1.vch & "," & "'" &
CDate(txtDate.Text) & "'" _
& "," & "'" & "Cash A/c" & "'" & "," & "'" & "Cash" & "'" & "," &
"'" & "By Bill No " + txtBillNo.Text & "'" & "," _
& Val(txtTotal.Text) & "," & "'" & "Purchase A/c" & "'" & "," & "'"
& "Purchase" & "'" & "," _
& "'" & "To Bill No " + txtBillNo.Text & "'" & "," &
Val(txtTotal.Text) & "," & "'" & k & "'" & "," & "'" & typ & "'" _

106
& ")"
End If
End If

If Len(txtDiscTotal.Text) > 0 And Val(txtDiscTotal.Text) > 0 Then


an1 = "Discount Receipt A/c"
t1 = "Income"
nar = "By Bill No " & txtBillNo.Text
b1 = txtName.Text
Module1.vch = Module1.vch + 1
cn.Execute "insert into mix values(" & Module1.vch & "," & "'" &
txtDate.Text & "'" & "," _
& "'" & an1 & "'" & "," & "'" & t1 & "'" & "," & "'" & nar & "'" & "," _
& Val(txtDiscTotal.Text) & "," & "'" & b1 & "'" & "," & "'" & b1 & "'"
& "," _
& "'" & b1 & "'" & "," & k1 & "," & "'" & k & "'" & "," & "'" & t1 & "'"
& ")"
End If

If Len(txtFr.Text) > 0 And Val(txtFr.Text) > 0 Then


an1 = "Freight & Oct."
b1 = " "
t1 = "Loss"
nar = "To Bill No " & txtBillNo.Text
an2 = "Cash A/c"
tg = "Cash"
nar1 = "To Cash BiLL No. " + txtBillNo.Text
typ = "Expense"
Module1.vch = Module1.vch + 1
cn.Execute "insert into mix values(" & Module1.vch & "," & "'" &
txtDate.Text & "'" & "," _
& "'" & an2 & "'" & "," & "'" & tg & "'" & "," & "'" & nar1 & "'" & ","
_
& Val(txtFr.Text) & "," & "'" & an1 & "'" & "," & "'" & t1 & "'" & "," _
& "'" & nar & "'" & "," & Val(txtFr.Text) & "," & "'" & k & "'" & "," &
"'" & typ & "'" _
& ")"
End If
If Len(txtLabour.Text) > 0 And Val(txtLabour.Text) > 0 Then
an1 = "Labour"
b1 = " "
t1 = "Loss"
nar = "To Bill No " & txtBillNo.Text
an2 = "Cash A/c"
tg = "Cash"
nar1 = "To BiLL No. " + txtBillNo.Text

107
typ = "Expense"
Module1.vch = Module1.vch + 1
cn.Execute "insert into mix values(" & Module1.vch & "," & "'" &
txtDate.Text & "'" & "," _
& "'" & an2 & "'" & "," & "'" & tg & "'" & "," & "'" & nar1 & "'" & ","
_
& Val(txtLabour.Text) & "," & "'" & an1 & "'" & "," & "'" & t1 & "'" &
"," _
& "'" & nar & "'" & "," & Val(txtLabour.Text) & "," & "'" & k & "'" &
"," & "'" & typ & "'" _
& ")"
End If

' block close for saving dis freight labour entry in mix
i=1
j=1
c=1

MsgBox "Record Saved", , "Medicine Store"


Dim cc As Control
For Each cc In frmPurchase
If TypeOf cc Is TextBox Then
cc.Text = ""
End If
Next
i=1
j=1
c=1
ListView1.ListItems.Clear
For Each cc In frmPurchase
If TypeOf cc Is TextBox Then
cc.Text = ""
End If
Next
txtDate.Text = Date
'ss:
' If Err.Number = 3021 Then
' Resume Next
' End If
End Sub

Private Sub butCancel_Click()


Unload Me
End Sub

Private Sub butNext_Click()

108
cmbItem.SetFocus
If Len(txtItem.Text) = 0 Then
MsgBox "Select Item", , "Medicine Store"
cmbItem.SetFocus
Exit Sub
End If

If Len(txtSRate.Text) = 0 Then
MsgBox "Enter Sale Rate", , "Medicine Store"
txtSRate.SetFocus
Exit Sub
End If

If Len(txtQty.Text) = 0 And Val(txtSchPcs.Text) = 0 Then


MsgBox "Enter Qty", , "Medicine Store"
txtQty.SetFocus
Exit Sub
End If

If Len(txtQty.Text) = 0 Then
txtQty.Text = 0
txtQty.SetFocus
Exit Sub
End If

If Len(txtMrp.Text) = 0 Then
txtMrp.Text = " "
End If

If Len(txtSchPcs.Text) = 0 Then
txtSchPcs.Text = 0
End If

If Val(txtQty.Text) > 0 Then


TxtCostPerUnit.Text = Val(txtAmtGroup.Text) / Val(txtQty.Text)
TxtCostPerUnit.Text = Round(Val(TxtCostPerUnit.Text), 2)
End If

If Val(txtAmtGroup.Text) <= 0 Then


MsgBox "Enter A Valid Amount", , "Medicine Store"
Exit Sub
End If

If Module1.prep = "purchase" Then

109
If Len(txtQty.Text) = 0 Then 'Or Val(txtAmtGroup.Text) <= 0
Then
MsgBox "Enter Amount GroupWise !", , "Medicine Store"
txtQty.SetFocus
Exit Sub
End If
End If

If Module1.prep = "pmodi" Then


If Len(txtQty.Text) > 0 And Val(txtAmtGroup.Text) <= 0 Then
MsgBox "Enter Amonut Group Wise !", , "Medicine Store"
txtAmtGroup.SetFocus
Exit Sub
End If
End If
If Module1.prep = "pmodi" Then
If Val(txtSchPcs) + Val(txtQty) + tpp < sq Then
MsgBox "Not A Valid Qty ", vbOKOnly, "You Already Sale" & q1
MsgBox "total purchase", vbOKOnly, tpp
txtQty.SetFocus
Exit Sub
End If
End If
Set a = ListView1.ListItems.Add(j, , c)
With a
.SubItems(i) = Str(c)
.SubItems(i) = txtItem.Text
i=i+1
.SubItems(i) = itype
i=i+1
.SubItems(i) = txtMrp.Text
i=i+1
.SubItems(i) = txtSRate.Text
i=i+1
.SubItems(i) = Str(txtQty.Text)
i=i+1
.SubItems(i) = Str(txtSchPcs.Text)
i=i+1
.SubItems(i) = Str(txtAmtGroup.Text)
i=i+1
.SubItems(i) = Str(TxtCostPerUnit.Text)
j=j+1
c=c+1
End With
i=1
txtSRate.Text = ""

110
txtQty.Text = ""
txtSchPcs.Text = ""
txtAmtGroup.Text = ""
TxtCostPerUnit.Text = ""
End Sub

Private Sub butModify_Click()


' Dim ss As String
' On Error GoTo ss
j=1
c=1
i=1
bnum = ""
bnum = InputBox("Enter Bill Number")

Dim pm As New Recordset


Dim pd As New Recordset

pm.Open "select * from pmain where bno=" & "'" & bnum & "'", cn,
adOpenStatic, adLockPessimistic

If pm.RecordCount <= 0 Then


MsgBox "Record Not Exist With Given Bill MoNo", , "Medicine
Store"
Exit Sub
End If
Module1.prep = "pmodi"
pd.Open "select * from pdet where bno=" & "'" & bnum & "'", cn,
adOpenStatic, adLockPessimistic

txtDate.Text = pm!eDate
txtBillNo.Text = pm!bno
txtName.Text = pm!cname

If pm!BType = "cr" Then


Option1.Value = True
Else
If pm!Type = "cash" Then
Option2.Value = True
End If
End If

txtDiscTotal.Text = pm.Fields(4).Value
txtTotal.Text = pm.Fields(5).Value

txtLabour.Text = pm.Fields(6).Value ' labour

111
txtFr.Text = pm.Fields(7).Value ' freight

Do While Not pd.EOF = True

Set a = ListView1.ListItems.Add(j, , c)
With a
.SubItems(i) = Str(c)
.SubItems(i) = pd!Item
i=i+1
.SubItems(i) = pd!grp
i=i+1
.SubItems(i) = pd!mrp
i=i+1
.SubItems(i) = Str(pd.Fields(4).Value)
i=i+1
.SubItems(i) = Str(pd.Fields(5).Value)
i=i+1
.SubItems(i) = Str(pd.Fields(6).Value)
i=i+1
.SubItems(i) = Str(pd.Fields(9).Value)
i=i+1
.SubItems(i) = Str(pd.Fields(11).Value)
End With
j=j+1
c=c+1
i=1
pd.MoveNext
Loop
ky = "B" + txtBillNo.Text + "D" + txtDate.Text + "P" +
txtName.Text
'ss:
' If Err.Number = 3021 Then
' Resume Next
' End If
End Sub

Private Function checkBillAlreadyExist() As Boolean


Dim pu As New Recordset
pu.Open "select bno,cname from pmain", cn, adOpenDynamic,
adLockPessimistic
Do While Not pu.EOF = True
If Trim(UCase(pu!bno)) = Trim(UCase(txtBillNo.Text)) And
Trim(UCase(pu!cname)) = Trim(UCase(txtName.Text)) Then
Set pu = Nothing
checkBillAlreadyExist = True

112
Exit Function
End If
pu.MoveNext
Loop
checkBillAlreadyExist = False
Set pu = Nothing
End Function

Private Sub Form_Load()


txtDate.Text = Date
Dim ss As String
On Error GoTo ss
i=1
j=1
c=1
MakeConnection "temp.mdb"

it.Open "select * from itemDet ", cn, adOpenDynamic,


adLockPessimistic

tmix.Open "select max(vn) from mix", cn, adOpenDynamic,


adLockPessimistic

If IsNull(tmix.Fields(0).Value) Then
Module1.vch = 0
Else
Module1.vch = tmix.Fields(0).Value
End If

it.MoveFirst
Do While Not it.EOF = True
cmbItem.AddItem it!iname
it.MoveNext
Loop

clist.Open "select aname,address,vatno,grp from AcDet", cn,


adOpenDynamic, adLockPessimistic

clist.MoveFirst
Do While Not clist.EOF = True
If clist!grp = "Sundry Creditor" Then
cmbName.AddItem clist!aName

113
End If
clist.MoveNext
Loop
ListView1.ColumnHeaders.Add 1, , "Sr.", 500
ListView1.ColumnHeaders.Add 2, , "Item", 2800
ListView1.ColumnHeaders.Add 3, , "Group", 1100
ListView1.ColumnHeaders.Add 4, , "Mrp", 1100
ListView1.ColumnHeaders.Add 5, , "S_Rate", 1100
ListView1.ColumnHeaders.Add 6, , "Qty", 1200
ListView1.ColumnHeaders.Add 7, , "Sch", 1000
ListView1.ColumnHeaders.Add 8, , "Amt", 1200
ListView1.ColumnHeaders.Add 9, , "Cost 1 Pcs.", 1300

ss:
If Err.Number = 3021 Then
Resume Next
Else
If Err.Number = 94 Then
Module1.vch = 0
Resume Next
End If
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)


Set it = Nothing
Set clist = Nothing
Set tmix = Nothing
End Sub

Private Sub ListView1_KeyDown(KeyCode As Integer, Shift As Integer)


Dim ss As String
On Error GoTo ss

If Module1.prep = "pmodi" Then


Dim st As New Recordset
Dim pt As New Recordset

Dim ina As String


Dim t As Double 'for total sale sch or replace pcs
Dim t1 As Double ' for sch pcs

ina =
ListView1.ListItems(ListView1.SelectedItem.Index).SubItems(1)

114
' for sale
st.Open "select item,sum(qty+sch+replace) from sdet group by
item", cn, adOpenDynamic, adLockPessimistic
st.MoveFirst
Do While Not st.EOF = True
If st!Item = ina Then
t = st.Fields(1).Value
sq = st.Fields(1).Value
q1 = t
Exit Do
End If
st.MoveNext
Loop

' for purchase


pt.Open "select item,sum(qty+sch) from pdet group by item", cn,
adOpenDynamic, adLockPessimistic
pt.MoveFirst
Do While Not pt.EOF = True
If pt!Item = ina Then
t1 = pt.Fields(1).Value
tpp = pt.Fields(1).Value ' for total purchase
Exit Do
End If
pt.MoveNext
Loop

tpp = tpp - Val(ListView1.ListItems(1).SubItems(5)) +


Val(ListView1.ListItems(1).SubItems(6))

If t > t1 Then
MsgBox "Item Qty Cannot Change", vbOKOnly, "Sale With Sch Or
Repl Qty is ", t
Set st = Nothing
Set pt = Nothing
Exit Sub
Else
q = t1 - t
If KeyCode = 46 Then
ListView1.ListItems.Remove (ListView1.SelectedItem.Index)
If j > 1 Then
j=j-1
Else
j=1
End If

115
End If
End If
Else
If KeyCode = 46 Then
ListView1.ListItems.Remove (ListView1.SelectedItem.Index)
If j > 1 Then
j=j-1
Else
j=1
End If
End If
End If
Set st = Nothing
Set pt = Nothing
ss:
If Err.Number = 3021 Then
Resume Next
End If
End Sub

Private Sub txtAmtGroup_LostFocus()


CalAmtGrp
End Sub

Private Sub txtDate_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Or KeyAscii =
45 Then
txtDate.Text = txtDate.Text + vbkeyascii
Else
If KeyAscii = 13 Then
txtBillNo.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If
End Sub

Private Sub txtDate_LostFocus()


txtDate.Text = Format(txtDate.Text, "dd-MM-YY")
End Sub

Private Sub txtDiscTotal_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 46 Or KeyAscii
= 8 Then
txtDiscTotal.Text = txtDiscTotal.Text + vbkeyascii
Else

116
If KeyAscii = 13 Then
txtFr.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If
End Sub

Private Sub txtFr_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 46 Or KeyAscii
= 8 Then
txtFr.Text = txtFr.Text + vbkeyascii
Else
If KeyAscii = 13 Then
txtLabour.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If

End Sub

Private Sub txtLabour_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 46 Or KeyAscii
= 8 Then
txtLabour.Text = txtLabour.Text + vbkeyascii
Else
If KeyAscii = 13 Then
txtTotal.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If

End Sub

Private Sub txtQty_Change()


CalAmtGrp
End Sub

Private Sub txtSRate_Change()


CalAmtGrp
End Sub

Private Sub txtTotal_KeyPress(KeyAscii As Integer)

117
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 46 Or KeyAscii
= 8 Then
txtTotal.Text = txtTotal.Text + vbkeyascii
Else
If KeyAscii = 13 Then
Command1.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If

End Sub

Private Sub TxtCostPerUnit_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 46 Or KeyAscii
= 8 Then
TxtCostPerUnit.Text = TxtCostPerUnit.Text + vbkeyascii
Else
If KeyAscii = 13 Then
Command3.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If
End Sub

Private Sub txtBillNo_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
cmbName.SetFocus
End If
End Sub

Private Sub txtMrp_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtSRate.SetFocus
End If
NumAllowOnly txtMrp, KeyAscii
End Sub

Private Sub txtSRate_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 46 Or KeyAscii
= 8 Then
txtSRate.Text = txtSRate.Text + vbkeyascii
Else
If KeyAscii = 13 Then
txtQty.SetFocus

118
Else
KeyAscii = Val(vbkeyascii)
End If
End If

End Sub

Private Sub txtQty_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 46 Or KeyAscii
= 8 Then
txtQty.Text = txtQty.Text + vbkeyascii
Else
If KeyAscii = 13 Then
txtSchPcs.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If
End Sub

Private Sub txtSchPcs_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 46 Or KeyAscii
= 8 Then
txtSchPcs.Text = txtSchPcs.Text + vbkeyascii
Else
If KeyAscii = 13 Then
txtAmtGroup.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If
End Sub

Private Sub txtAmtGroup_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 46 Or KeyAscii
= 8 Then
txtAmtGroup.Text = txtAmtGroup.Text + vbkeyascii
Else
If KeyAscii = 13 Then
butNext.SetFocus
'Command3.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If
End Sub

119
Private Sub CalAmtGrp()
txtAmtGroup.Text = Val(txtSRate.Text) * Val(txtQty.Text)
End Sub

120
Sale Entry
Option Explicit
Dim ctr As Double
Dim VarStoreBillNoToModify As Double
Dim varGrpForMix As String, VarKey As String
Dim VarTotalTax As Double, VarTotalDiscount As Double
Dim VarSrNo As Integer, VarIndex As Integer
Dim VarBillType As String, varVatNo As String, VarAddress As String
Dim VarSaleType As String
Dim i As Integer, j As Integer, c As Integer
Dim SQLQuerry As String
Dim VarModifySale As Boolean
Dim VarStoreSaleTypeToModify As String
Private Sub PopulateCmbItem()
cmbItem.Clear
cmbGrp.Clear
cmbMrp.Clear
Dim TempRstItemPop As New ADODB.Recordset
SQLQuerry = "Select iname,itype,mrp from itemDet"
With TempRstItemPop
If .State = adStateOpen Then
.Close
End If
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
cmbItem.AddItem .Fields("Iname").Value
cmbGrp.AddItem .Fields("itype").Value
cmbMrp.AddItem .Fields("mrp").Value
.MoveNext
Loop
End If
End With
Set TempRstItemPop = Nothing
End Sub

Private Sub populateCmbCustomer()


cmbCustomer.Clear
Dim TempRstCmbCust As New ADODB.Recordset
SQLQuerry = "Select * from AcDet where Grp = " & "'" & "Sundry
Debitor" & "'"
With TempRstCmbCust
.Open SQLQuerry, cn, adOpenKeyset

121
If .RecordCount > 0 Then
.MoveFirst
End If
Do While Not .EOF
cmbCustomer.AddItem .Fields("Aname").Value
.MoveNext
Loop
End With
End Sub

Private Sub butCancel_Click()


Unload Me
End Sub

Private Sub butModify_Click()


Dim VSType As String
VarStoreBillNoToModify = Val(InputBox("Enter Bill No"))
If VarStoreBillNoToModify <= 0 Then
MsgBox "Enter A Valid Bill No", , "Medicine Store"
Exit Sub
End If
If optVat.Value = True Then
VSType = optVat.Caption
Else
VSType = optTot.Caption
End If
VarModifySale = True
VarStoreSaleTypeToModify = VSType
Call DisplayWholeRecord(VarStoreBillNoToModify, VSType)
End Sub

Private Sub butNext_Click()


Call AddDataInListView
Call CalculateDiscountAndTaxes
clearNextFields
End Sub

Private Sub butPrint_Click()


Dim ss As String
On Error GoTo ss
cmbCustomer.Visible = False
cmbItem.Visible = False
frmSale.PrintForm
cmbCustomer.Visible = True
cmbItem.Visible = True
ss:

122
If Err.Number = 482 Then
MsgBox "Printer/Page Error", , "Medicine Store"
Err.Clear
Resume Next
End If
End Sub

Private Sub butSave_Click()


If IsFieldValid = False Then
Exit Sub
End If
If optVat.Value = True Then
VarBillType = optVat.Caption
Else
VarBillType = optTot.Caption
End If
If optCash.Value = True Then
VarSaleType = "Cash"
Else
VarSaleType = "Cr"
End If
If optCr.Value = True Then
varGrpForMix = "Sundry Debitor"
Else
varGrpForMix = "Cash in Hand"
End If
Call CalculateDiscountAndTaxes
If VarModifySale = True Then
Call DeleteRecordSaleToModify(VarStoreBillNoToModify,
VarStoreSaleTypeToModify)
End If
Call SaveDataInSale
Call SaveDataInSaleDet
Call SaveDataInMix
MsgBox "Saved", , "Medicine Store"
ClearFields
End Sub

Private Sub cmbCustomer_Click()


txtName.Text = cmbCustomer.List(cmbCustomer.ListIndex)
SQLQuerry = "Select * from AcDet where AName = " & "'" &
cmbCustomer.List(cmbCustomer.ListIndex) & "'" & " and grp = " & "'"
& "Sundry Debitor" & "'"
Dim TempRstSearchCust As New ADODB.Recordset
With TempRstSearchCust
.Open SQLQuerry, cn, adOpenKeyset

123
If .RecordCount > 0 Then
txtRoot.Text = .Fields("Root").Value
VarAddress = .Fields("Address").Value
varVatNo = .Fields("VatNo").Value
End If
End With
Set TempRstSearchCust = Nothing
End Sub

Private Sub cmbDelivery_Change()

End Sub

Private Sub cmbItem_Click()


Dim varCmbItemIndex As Integer
varCmbItemIndex = cmbItem.ListIndex
txtItem.Text = cmbItem.List(varCmbItemIndex)
txtItemGrp.Text = cmbGrp.List(varCmbItemIndex)
txtMrp.Text = cmbMrp.List(varCmbItemIndex)
'txtUnitM.Text = cmbUnitMear.List(varCmbItemIndex)
End Sub

Private Sub Form_Activate()


optVat_Click
End Sub

Private Sub Form_Load()


txtEDate.Text = Date
VarSrNo = 0
VarIndex = 0
Call PopulateCmbItem
Call populateCmbCustomer
Call AddListHeadings
End Sub

Private Sub AddListHeadings()


ListView1.ColumnHeaders.Add 1, , "SR.", 500
ListView1.ColumnHeaders.Add 2, , "ITEM", 1950
ListView1.ColumnHeaders.Add 3, , "GROUP", 1300
ListView1.ColumnHeaders.Add 4, , "M R P", 800
ListView1.ColumnHeaders.Add 5, , "QTY", 900
ListView1.ColumnHeaders.Add 6, , "S_Rate", 900
ListView1.ColumnHeaders.Add 7, , "SCH", 900
ListView1.ColumnHeaders.Add 8, , "SCH %", 900
ListView1.ColumnHeaders.Add 9, , "Disct", 900

124
ListView1.ColumnHeaders.Add 10, , "REPL", 700
ListView1.ColumnHeaders.Add 11, , "AMOUNT", 1230
ListView1.ColumnHeaders.Add 12, , "Tax", 550
End Sub

Private Sub AddDataInListView()


If Val(txtItemGrp.Text) > 0 Then
txtTax.Text = Round(txtItemAmount.Text * Val(txtItemGrp.Text) /
100, 2)
End If
VarSrNo = VarSrNo + 1
VarIndex = VarIndex + 1
ListView1.ListItems.Add VarIndex, , VarSrNo
ListView1.ListItems(VarIndex).SubItems(1) = txtItem.Text
ListView1.ListItems(VarIndex).SubItems(2) = txtItemGrp.Text
ListView1.ListItems(VarIndex).SubItems(3) = txtMrp.Text
ListView1.ListItems(VarIndex).SubItems(4) = txtQty.Text
ListView1.ListItems(VarIndex).SubItems(5) = txtRate.Text
ListView1.ListItems(VarIndex).SubItems(6) = txtSchPcs.Text
ListView1.ListItems(VarIndex).SubItems(7) = txtSchPercen.Text
ListView1.ListItems(VarIndex).SubItems(8) = txtDiscItem.Text
ListView1.ListItems(VarIndex).SubItems(9) = txtRepl.Text
ListView1.ListItems(VarIndex).SubItems(10) = txtItemAmount.Text
ListView1.ListItems(VarIndex).SubItems(11) = txtTax.Text
End Sub

Private Sub SaveDataInSaleDet()


Dim varC As Integer
With ListView1
For varC = 1 To .ListItems.Count
cn.Execute "insert into sdet values (" & Val(txtBillNo.Text) & ","
& "'" & VarBillType & "'" & "," & "'" & .ListItems(varC).SubItems(1) & "'"
& "," & "'" & .ListItems(varC).SubItems(2) & "'" & "," & "'" &
.ListItems(varC).SubItems(3) & "'" & "," &
Val(.ListItems(varC).SubItems(4)) & "," &
Val(.ListItems(varC).SubItems(5)) & "," &
Val(.ListItems(varC).SubItems(6)) & "," &
Val(.ListItems(varC).SubItems(7)) & "," &
Val(.ListItems(varC).SubItems(8)) & "," &
Val(.ListItems(varC).SubItems(9)) & "," &
Val(.ListItems(varC).SubItems(10)) & "," & Val(txtTax.Text) & ")"
Next
End With
End Sub

Private Function IsFieldValidForItemEntry() As Boolean

125
If Len(Trim(txtItem.Text)) = 0 Then
MsgBox "Select Item From List", , "Medicine Store"
IsFieldValidForItemEntry = False
Exit Function
End If

If Val(txtRepl.Text) <= 0 And Val(txtQty.Text) <= 0 Then


MsgBox "Enter A Valid Qty / Replacement", , "Medicine Store"
IsFieldValidForItemEntry = False
Exit Function
End If

If Val(txtQty.Text) > 0 Then


If Val(txtRate.Text) <= 0 Then
MsgBox "Enter A Valid Rate", , "Medicine Store"
IsFieldValidForItemEntry = False
Exit Function
End If
End If

IsFieldValidForItemEntry = True
End Function

Private Sub CalculateAmountForSingleItem()


If Val(txtQty.Text) > 0 Then
txtItemAmount.Text = Round(Val(txtQty.Text) * Val(txtRate.Text),
2)
End If
End Sub

Private Sub ListView1_KeyDown(KeyCode As Integer, Shift As Integer)


If KeyCode = 46 Then
If ListView1.ListItems.Count >= 1 Then
ListView1.ListItems.Remove (ListView1.SelectedItem.Index)
If ListView1.ListItems.Count >= 1 Then
VarIndex = ListView1.ListItems.Count
Else
VarIndex = 0
End If
End If
End If

126
For ctr = 1 To ListView1.ListItems.Count
ListView1.ListItems.Item(ctr).Text = ctr
Next
VarSrNo = ListView1.ListItems.Count
End Sub

Private Sub optTot_Click()


GenBillNo
End Sub

Private Sub optVat_Click()


GenBillNo
End Sub

Private Sub txtDeliver_KeyPress(KeyAscii As Integer)


TxtAllowOnly txtDeliver, KeyAscii
End Sub

Private Sub txtDiscItem_KeyPress(KeyAscii As Integer)


NumAllowOnly txtDiscItem, KeyAscii
End Sub

Private Sub txtDiscountPerc_KeyPress(KeyAscii As Integer)


NumAllowOnly txtDiscountPerc, KeyAscii
End Sub

Private Sub txtItemAmount_KeyPress(KeyAscii As Integer)


NumAllowOnly txtItemAmount, KeyAscii
End Sub

Private Sub txtItemGrp_Change()


TaxesForSingleItemOnly
End Sub

Private Sub txtMrp_KeyPress(KeyAscii As Integer)


NumAllowOnly txtMrp, KeyAscii
End Sub

Private Sub txtQty_Change()


Call CalculateAmountForSingleItem
Call TaxesForSingleItemOnly
End Sub

Private Sub txtQty_KeyPress(KeyAscii As Integer)


NumAllowOnly txtQty, KeyAscii
End Sub

127
Private Sub txtRate_Change()
Call CalculateAmountForSingleItem
Call TaxesForSingleItemOnly
End Sub

Private Sub SaveDataInSale()


cn.Execute "insert into Sale values ( " & "'" & txtEDate.Text & "'" &
"," & Val(txtBillNo.Text) & "," & "'" & VarBillType & "'" & "," & "'" &
txtName.Text & "'" & "," & "'" & varVatNo & "'" & "," & "'" &
txtRoot.Text & "'" & "," & "'" & VarAddress & "'" & "," & "'" &
VarSaleType & "'" & "," & Val(txtTaxTotal.Text) & "," &
Val(txtSaleAmount.Text) & "," & Val(txtNetAmount.Text) & "," & "'" &
txtDeliver.Text & "'" & "," & Val(txtTotalDisc.Text) & "," &
Val(txtDiscountPerc.Text) & "," & Val(txtSchTotal.Text) & ")"
End Sub

Private Function IsFieldValid() As Boolean


If IsDate(txtEDate.Text) = False Then
MsgBox "Enter A Valid Date", , "Medicine Store"
IsFieldValid = False
Exit Function
End If

If Len(Trim(txtName.Text)) = 0 Then
MsgBox "Select Customer Name From List", , "Medicine Store"
IsFieldValid = False
Exit Function
End If

If ListView1.ListItems.Count = 0 Then
MsgBox "Click on Next Button", , "Medicine Store"
IsFieldValid = False
Exit Function
End If

IsFieldValid = True
End Function

Private Sub CalculateDiscountAndTaxes()


Dim VarTotalTax As Double, varC As Integer
Dim varTotalSchPerc As Double, varSch As Double,
varAmountLessDiscount As Double
Dim varAmount As Double, VarTotalDiscount As Double
For varC = 1 To ListView1.ListItems.Count

128
VarTotalTax = VarTotalTax +
Val(ListView1.ListItems(varC).SubItems(11))
varSch = Round(Val(ListView1.ListItems(varC).SubItems(10)) *
Val(ListView1.ListItems(varC).SubItems(7)) / 100, 2)
varTotalSchPerc = varTotalSchPerc + varSch
VarTotalDiscount = VarTotalDiscount + Val(txtDiscItem.Text)
varAmount = varAmount +
Val(ListView1.ListItems(varC).SubItems(10))
Next
txtSaleAmount.Text = varAmount
txtSchTotal.Text = varTotalSchPerc + VarTotalDiscount
txtTaxTotal = VarTotalTax
txtTotalDisc.Text = Round(txtSaleAmount.Text *
Val(txtDiscountPerc.Text) / 100, 2)
txtNetAmount.Text = Val(txtSaleAmount.Text) -
Val(txtTotalDisc.Text) + Val(txtTaxTotal.Text) - Val(txtSchTotal.Text)
End Sub

Private Sub TaxesForSingleItemOnly()


txtTax.Text = Round((Val(txtItemGrp.Text) *
Val(txtItemAmount.Text)) / 100, 2)
End Sub

Private Sub SaveDataInMix()


VarKey = GenKeyForMix
Dim VarVchNo As Double, varValue As String, varNumericValue As
Integer
varValue = " "
varNumericValue = 0
VarVchNo = VarVchForMix + 1
Dim varDN As String, varCN As String
varDN = "To Sale Bill No " & txtBillNo.Text
varCN = "By Sale Bill No " & txtBillNo.Text
cn.Execute "insert into mix values (" & VarVchNo & "," & "'" &
CDate(txtEDate.Text) & "'" & "," & "'" & "Sale A/c" & "'" & "," & "'" &
"Sale" & "'" & "," & "'" & varCN & "'" & "," & Val(txtSaleAmount.Text) &
"," & "'" & txtName.Text & "'" & "," & "'" & varGrpForMix & "'" & "," &
"'" & varDN & "'" & "," & Round(Val(txtNetAmount.Text), 0) & "," & "'" &
VarKey & "'" & "," & "'" & "Sale" & "'" & ")"
If Val(txtTotalDisc.Text) + Val(txtSchTotal.Text) > 0 Then
varGrpForMix = "Indirect Expense"
cn.Execute "insert into mix values (" & VarVchNo & "," & "'" &
CDate(txtEDate.Text) & "'" & "," & "'" & varValue & "'" & "," & "'" &
varValue & "'" & "," & "'" & varValue & "'" & "," & varNumericValue &
"," & "'" & "Discount On Sale A/c" & "'" & "," & "'" & varGrpForMix & "'"

129
& "," & "'" & "To Bill No " + txtBillNo.Text & "'" & "," &
Val(txtTotalDisc.Text) + Val(txtSchTotal.Text) & "," & "'" & VarKey & "'"
& "," & "'" & "DiscountS" & "'" & ")"
End If
Dim VarStoreValue As Double
VarStoreValue = Round(txtNetAmount.Text, 0)
If VarStoreValue > Val(txtNetAmount.Text) Then
VarStoreValue = Round(VarStoreValue - Val(txtNetAmount.Text),
2)
Else
VarStoreValue = Round(Val(txtNetAmount.Text) - VarStoreValue,
2)
End If

If VarStoreValue < 0.5 Then


cn.Execute "insert into mix values (" & VarVchNo & "," & "'" &
txtEDate.Text & "'" & "," & "'" & "Round Off A/c" & "'" & "," & "'" &
varGrpForMix & "'" & "," & "'" & "By Bill No " + txtBillNo.Text & "'" & ","
& VarStoreValue & "," & "'" & varValue & "'" & "," & "'" & varValue & "'"
& "," & "'" & varValue & "'" & "," & varNumericValue & "," & "'" &
VarKey & "'" & "," & "'" & "DiscountS" & "'" & ")"
Else
cn.Execute "insert into mix values (" & VarVchNo & "," & "'" &
txtEDate.Text & "'" & "," & "'" & varValue & "'" & "," & "'" & varValue &
"'" & "," & "'" & varValue & "'" & "," & varNumericValue & "," & "'" &
"Round Off A/c" & "'" & "," & "'" & varGrpForMix & "'" & "," & "'" & "To
Bill No " + txtBillNo.Text & "'" & "," & VarStoreValue & "," & "'" &
VarKey & "'" & "," & "'" & "DiscountS" & "'" & ")"
End If
If Val(txtTaxTotal.Text) > 0 Then
cn.Execute "insert into mix values (" & VarVchNo & "," & "'" &
txtEDate.Text & "'" & "," & "'" & "VAT Tax" & "'" & "," & "'" & "Current
Liabilities" & "'" & "," & "'" & "By Bill No " + txtBillNo.Text & "'" & "," &
Val(txtTaxTotal.Text) & "," & "'" & varValue & "'" & "," & "'" & varValue
& "'" & "," & "'" & varValue & "'" & "," & varNumericValue & "," & "'" &
VarKey & "'" & "," & "'" & "DiscountS" & "'" & ")"
End If
End Sub

Private Function GenKeyForMix() As String


GenKeyForMix = Trim(txtBillNo.Text) + Trim(VarBillType)
End Function

Private Function DisplayWholeRecord(varBillNo As Double, VarSaleType


As String) As Boolean

130
SQLQuerry = "Select * from Sale where bno = " & varBillNo & " and
btype = " & "'" & VarSaleType & "'"
Dim RstSaleMain As New ADODB.Recordset
With RstSaleMain
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount <= 0 Then
MsgBox "Enter A Valid Bill No Or Sale Type", , "Medicine Store"
DisplayWholeRecord = False
Exit Function
Else
DisplayWholeRecord = True
End If
If UCase(Trim(.Fields("btype").Value)) = "VAT" Then
optVat.Value = True
Else
optTot.Value = True
End If

If UCase(Trim(.Fields("stype").Value)) = "Cash" Then


optCash.Value = True
Else
optCr.Value = True
End If

txtEDate.Text = .Fields("Edate").Value
txtBillNo.Text = .Fields("bno").Value & ""
txtName.Text = .Fields("cname").Value & ""
txtRoot.Text = .Fields("root").Value & ""
txtTaxTotal.Text = .Fields("tax").Value & ""
txtSaleAmount.Text = .Fields("samt").Value & ""
txtNetAmount.Text = .Fields("amt").Value & ""
txtDeliver.Text = .Fields("deli").Value & ""
txtDiscountPerc.Text = .Fields("discp").Value & ""
txtTotalDisc.Text = .Fields("dis").Value & ""
txtSchTotal.Text = .Fields("itemsch").Value & ""
varVatNo = .Fields("vatno").Value & ""
End With

Set RstSaleMain = Nothing

Dim RstSaleDetails As New ADODB.Recordset


SQLQuerry = "Select * from sdet where bno = " & varBillNo & " and
btype = " & "'" & VarSaleType & "'"
With RstSaleDetails
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount <= 0 Then

131
DisplayWholeRecord = False
MsgBox "No Detailed Record " + vbCrLf + "Please Contact
Programer", , "Medicine Store"
Exit Function
End If
ListView1.ListItems.Clear
VarSrNo = 0
VarIndex = 0
Do While Not .EOF
VarSrNo = VarSrNo + 1
VarIndex = VarIndex + 1
ListView1.ListItems.Add VarIndex, , VarSrNo
ListView1.ListItems(VarIndex).SubItems(1) =
.Fields("item").Value & ""
ListView1.ListItems(VarIndex).SubItems(2) =
.Fields("grp").Value & ""
ListView1.ListItems(VarIndex).SubItems(3) =
.Fields("mrp").Value & ""
ListView1.ListItems(VarIndex).SubItems(4) =
.Fields("qty").Value & ""
ListView1.ListItems(VarIndex).SubItems(5) =
.Fields("srate").Value & ""
ListView1.ListItems(VarIndex).SubItems(6) =
.Fields("sch").Value & ""
ListView1.ListItems(VarIndex).SubItems(7) =
.Fields("schp").Value & ""
ListView1.ListItems(VarIndex).SubItems(8) =
.Fields("discount").Value & ""
ListView1.ListItems(VarIndex).SubItems(9) =
.Fields("replace").Value & ""
ListView1.ListItems(VarIndex).SubItems(10) =
.Fields("amt").Value & ""
ListView1.ListItems(VarIndex).SubItems(11) =
.Fields("Tax").Value & ""
.MoveNext
Loop
End With
End Function

'Private Function DeleteRecordSaleCompletely(varBillNo As Double,


varSType As String) As Boolean
' Dim RstFindMaxBillNo As New ADODB.Recordset
' Dim VarMaxBillNo As Double
' SQLQuerry = "Select max(bno) from sale where btype = " & "'" &
varSType & "'"
' With RstFindMaxBillNo

132
' .Open SQLQuerry, cn, adOpenKeyset
' If .RecordCount > 0 Then
' If Not IsNull(.Fields(0).Value) Then
' VarMaxBillNo = .Fields(0).Value
' Else
' MsgBox "Record Not Exist", , "Medicine Store"
' DeleteRecordSaleCompletely = False
' End If
' Else
' MsgBox "Record Not Exist", , "Medicine Store"
' DeleteRecordSaleCompletely = False
' End If
' End With
' If VarMaxBillNo = Val(txtBillNo.Text) Then
' If MsgBox("Are You Sure For Deleteion", vbYesNo, "Medicine
Store") = vbYes Then
' cn.Execute "delete from [Sale] where [bno] = " & varBillNo & "
and [btype] = " & "'" & Trim(varSType) & "'"
' cn.Execute "delete from [Sdet] where [bno] = " & varBillNo &
" and [btype] = " & "'" & varSType & "'"
' Dim varKeyy As String
' varKeyy = Trim(Str(varBillNo)) + Trim(varSType)
' cn.Execute "delete from [mix] where [kk] = " & "'" & varKeyy &
"'"
' End If
' Else
' MsgBox "Only Last Bill No Cancelation is Valid ", , "Medicine
Store"
' DeleteRecordSaleCompletely = False
' End If
'End Function

Private Sub DeleteRecordSaleToModify(varBillNo As Double, varSType


As String)
cn.Execute "delete from Sale where bno = " & varBillNo & " and
btype = " & "'" & varSType & "'"
cn.Execute "delete from Sdet where bno = " & varBillNo & " and
btype = " & "'" & varSType & "'"
Dim varKeyy As String
varKeyy = Trim(Str(VarStoreBillNoToModify)) +
Trim(VarStoreSaleTypeToModify)
cn.Execute "delete from mix where kk = " & "'" & varKeyy & "'"
End Sub

Private Sub ClearFields()


Dim cc As Control

133
For Each cc In frmSale
If TypeOf cc Is TextBox Then
cc.Text = ""
End If
Next
ListView1.ListItems.Clear
GenBillNo
VarIndex = 0
End Sub

Private Function GenBillNo() As Long


Dim RstGenBill As New ADODB.Recordset
Dim SQur As String
If optTot.Value = True Then
SQur = "Select max(bno) from sale where btype = " & "'" &
optTot.Caption & "'"
Else
SQur = "Select max(bno) from sale where btype = " & "'" &
optVat.Caption & "'"
End If
With RstGenBill
If .State = adStateOpen Then
.Close
End If
.Open SQur, cn, adOpenStatic, adLockReadOnly
If .RecordCount > 0 Then
If Not IsNull(.Fields(0).Value) Then
txtBillNo.Text = .Fields(0).Value + 1
Else
txtBillNo.Text = 1
End If
Else
txtBillNo.Text = 1
End If
End With
End Function

Private Sub txtRate_KeyPress(KeyAscii As Integer)


NumAllowOnly txtRate, KeyAscii
End Sub

Private Sub txtRepl_KeyPress(KeyAscii As Integer)


NumAllowOnly txtRepl, KeyAscii
End Sub

Private Sub txtSchPcs_KeyPress(KeyAscii As Integer)

134
NumAllowOnly txtSchPcs, KeyAscii
End Sub

Private Sub txtSchPercen_KeyPress(KeyAscii As Integer)


NumAllowOnly txtSchPercen, KeyAscii
End Sub

Private Sub txtSchTotal_KeyPress(KeyAscii As Integer)


NumAllowOnly txtSchTotal, KeyAscii
End Sub

Private Sub txtTax_KeyPress(KeyAscii As Integer)


NumAllowOnly txtTax, KeyAscii
End Sub

Private Sub clearNextFields()


txtItem.Text = ""
txtMrp.Text = ""
txtRepl.Text = ""
txtItemGrp.Text = ""
txtQty.Text = ""
txtSchPcs.Text = ""
txtSchPercen.Text = ""
txtTax.Text = ""
txtItemAmount.Text = ""
txtDiscItem.Text = ""
txtRate.Text = ""
End Sub

Private Sub txtTotalDisc_KeyPress(KeyAscii As Integer)


NumAllowOnly txtTotalDisc, KeyAscii
End Sub

135
Return Entry
Dim ctr As Double
Dim VarStoreBillNoToModify As Double
Dim varGrpForMix As String, VarKey As String
Dim VarTotalTax As Double, VarTotalDiscount As Double
Dim VarSrNo As Integer, VarIndex As Integer
Dim VarBillType As String, varVatNo As String, VarAddress As String
Dim VarSaleType As String
Dim i As Integer, j As Integer, c As Integer
Dim SQLQuerry As String
Private Sub PopulateCmbItem()
cmbItem.Clear
cmbGrp.Clear
cmbMrp.Clear
Dim TempRstItemPop As New ADODB.Recordset
SQLQuerry = "Select iname,itype,mrp from itemDet"
With TempRstItemPop
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
cmbItem.AddItem .Fields("Iname").Value
cmbGrp.AddItem .Fields("itype").Value
cmbMrp.AddItem .Fields("mrp").Value
.MoveNext
Loop
End If
End With
Set TempRstItemPop = Nothing
End Sub

Private Sub populateCmbCustomer()


cmbCustomer.Clear
Dim TempRstCmbCust As New ADODB.Recordset
SQLQuerry = "Select * from AcDet where Grp = " & "'" & "Sundry
Debitor" & "'"
With TempRstCmbCust
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
.MoveFirst
End If
Do While Not .EOF
cmbCustomer.AddItem .Fields("Aname").Value
.MoveNext

136
Loop
End With
End Sub

Private Sub butCancel_Click()


Unload Me
End Sub

Private Sub butNext_Click()


If Not IsNextFieldsValid Then
Exit Sub
End If
Call AddDataInListView
Call clearNextFields
End Sub

Private Function IsNextFieldsValid()


If Val(txtQty.Text) <= 0 Then
MsgBox "Qty should be valid"
IsNextFieldsValid = False
Exit Function
End If
If Val(txtRate.Text) <= 0 Then
MsgBox "Rate should be valid"
IsNextFieldsValid = False
Exit Function
End If
If Val(txtItemAmount.Text) <= 0 Then
MsgBox "Item Amount should be Valid"
IsNextFieldsValid = False
Exit Function
End If

If Len(Trim(txtItem.Text)) <= 0 Then


MsgBox "Item Name Should be Valid"
IsNextFieldsValid = False
Exit Function
End If
IsNextFieldsValid = True
End Function

Private Sub clearNextFields()


txtItem.Text = ""
txtMrp.Text = ""
txtQty.Text = ""
txtTax.Text = ""

137
txtItemGrp.Text = ""
txtRate.Text = ""
txtItemAmount.Text = ""
End Sub

Private Sub butSave_Click()


If IsFieldValid = False Then
Exit Sub
End If
GenBillNo
CalCulateTotalTax
Call SaveDataInSaleRet
Call SaveDataInSaleDetRet
Call SaveDataInMix
MsgBox "Saved", , "Medicine Store"
ClearFields
End Sub

Private Sub cmbCustomer_Click()


txtName.Text = cmbCustomer.List(cmbCustomer.ListIndex)
SQLQuerry = "Select * from AcDet where AName = " & "'" &
cmbCustomer.List(cmbCustomer.ListIndex) & "'" & " and grp = " & "'"
& "Sundry Debitor" & "'"
Dim TempRstSearchCust As New ADODB.Recordset
With TempRstSearchCust
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
txtRoot.Text = .Fields("Root").Value
VarAddress = .Fields("Address").Value
varVatNo = .Fields("VatNo").Value
End If
End With
Set TempRstSearchCust = Nothing
End Sub

Private Sub cmbItem_Click()


Dim varCmbItemIndex As Integer
varCmbItemIndex = cmbItem.ListIndex
txtItem.Text = cmbItem.List(varCmbItemIndex)
txtItemGrp.Text = cmbGrp.List(varCmbItemIndex)
txtMrp.Text = cmbMrp.List(varCmbItemIndex)
End Sub

Private Sub Command1_Click()

138
' CalCulateTotalTax
' cn.Execute "insert into SaleRet values ( " & "'" & txtEDate.Text & "'"
& "," & Val(txtBillNo.Text) & "," & "'" & txtName.Text & "'" & "," & "'" &
txtRoot.Text & "'" & "," & "'" & VarAddress & "'" & "," &
Val(txtTaxTotal.Text) & "," & Val(txtNetAmount.Text) & "," &
Val(txtTotalDisc.Text) & ")"
SaveDataInSaleDetRet
End Sub

Private Sub Form_Load()


MakeConnection "temp.mdb"
VarVchForMix = GenVchNo
txtEDate.Text = Date
VarSrNo = 0
VarIndex = 0
Call PopulateCmbItem
Call populateCmbCustomer
Call AddListHeadings
Call GenBillNo
End Sub

Private Sub AddListHeadings()


ListView1.ColumnHeaders.Add 1, , "SR.", 545
ListView1.ColumnHeaders.Add 2, , "ITEM", 1950
ListView1.ColumnHeaders.Add 3, , "GROUP", 1300
ListView1.ColumnHeaders.Add 4, , "M R P", 800
ListView1.ColumnHeaders.Add 5, , "QTY", 900
ListView1.ColumnHeaders.Add 6, , "S_Rate", 900
ListView1.ColumnHeaders.Add 7, , "AMOUNT", 1230
ListView1.ColumnHeaders.Add 8, , "Tax", 550
End Sub

Private Sub AddDataInListView()


If Val(txtItemGrp.Text) > 0 Then
txtTax.Text = Round(Val(txtItemAmount.Text) *
Val(txtItemGrp.Text) / 100, 2)
End If
VarSrNo = VarSrNo + 1
VarIndex = VarIndex + 1
ListView1.ListItems.Add VarIndex, , VarSrNo
ListView1.ListItems(VarIndex).SubItems(1) = txtItem.Text
ListView1.ListItems(VarIndex).SubItems(2) = txtItemGrp.Text
ListView1.ListItems(VarIndex).SubItems(3) = txtMrp.Text
ListView1.ListItems(VarIndex).SubItems(4) = txtQty.Text
ListView1.ListItems(VarIndex).SubItems(5) = txtRate.Text
ListView1.ListItems(VarIndex).SubItems(6) = txtItemAmount.Text

139
ListView1.ListItems(VarIndex).SubItems(7) = txtTax.Text
End Sub

Private Sub SaveDataInSaleDetRet()


Dim varC As Integer
With ListView1
For varC = 1 To .ListItems.Count
cn.Execute "insert into sdetret values (" & Val(txtBillNo.Text) &
"," & "'" & .ListItems(varC).SubItems(1) & "'" & "," & "'" &
.ListItems(varC).SubItems(2) & "'" & "," & "'" &
.ListItems(varC).SubItems(3) & "'" & "," &
Val(.ListItems(varC).SubItems(4)) & "," &
Val(.ListItems(varC).SubItems(5)) & "," &
Val(.ListItems(varC).SubItems(6)) & "," &
Val(.ListItems(varC).SubItems(7)) & ")"
Next
End With
End Sub

Private Function IsFieldValidForItemEntry() As Boolean


If Len(Trim(txtItem.Text)) = 0 Then
MsgBox "Select Item From List", , "Medicine Store"
IsFieldValidForItemEntry = False
Exit Function
End If

If Val(txtQty.Text) > 0 Then


If Val(txtRate.Text) <= 0 Then
MsgBox "Enter A Valid Rate", , "Medicine Store"
IsFieldValidForItemEntry = False
Exit Function
End If
End If

IsFieldValidForItemEntry = True
End Function

Private Sub CalculateAmountForSingleItem()


If Val(txtQty.Text) > 0 Then
txtItemAmount.Text = Round(Val(txtQty.Text) * Val(txtRate.Text),
2)
End If
End Sub

Private Sub ListView1_KeyDown(KeyCode As Integer, Shift As Integer)


If KeyCode = 46 Then

140
If ListView1.ListItems.Count >= 1 Then
ListView1.ListItems.Remove (ListView1.SelectedItem.Index)
If ListView1.ListItems.Count >= 1 Then
VarIndex = ListView1.ListItems.Count
Else
VarIndex = 0
End If
End If
End If

For ctr = 1 To ListView1.ListItems.Count


ListView1.ListItems.Item(ctr).Text = ctr
Next
VarSrNo = ListView1.ListItems.Count
End Sub

Private Sub txtItemAmount_KeyPress(KeyAscii As Integer)


NumAllowOnly txtItemAmount, KeyAscii
End Sub

Private Sub txtMrp_KeyPress(KeyAscii As Integer)


NumAllowOnly txtMrp, KeyAscii
End Sub

Private Sub txtQty_Change()


Call CalculateAmountForSingleItem
End Sub

Private Sub txtQty_KeyPress(KeyAscii As Integer)


NumAllowOnly txtQty, KeyAscii
End Sub

Private Sub txtRate_Change()


Call CalculateAmountForSingleItem
End Sub

Private Sub SaveDataInSaleRet()


cn.Execute "insert into SaleRet values ( " & "'" & txtEDate.Text & "'"
& "," & Val(txtBillNo.Text) & "," & "'" & txtName.Text & "'" & "," & "'" &
txtRoot.Text & "'" & "," & "'" & VarAddress & "'" & "," &
Val(txtTaxTotal.Text) & "," & Val(txtNetAmount.Text) & "," &
Val(txtTotalDisc.Text) & ")"
End Sub

Private Function IsFieldValid() As Boolean


If IsDate(txtEDate.Text) = False Then

141
MsgBox "Enter A Valid Date", , "Medicine Store"
IsFieldValid = False
Exit Function
End If

If Len(Trim(txtName.Text)) = 0 Then
MsgBox "Select Customer Name From List", , "Medicine Store"
IsFieldValid = False
Exit Function
End If

If ListView1.ListItems.Count = 0 Then
MsgBox "Click on Next Button", , "Medicine Store"
IsFieldValid = False
Exit Function
End If

IsFieldValid = True
End Function

Private Sub SaveDataInMix()


VarKey = GenKeyForMix
Dim VarVchNo As Double, varValue As String, varNumericValue As
Integer
varValue = " "
varNumericValue = 0
VarVchNo = VarVchForMix + 1
Dim varDN As String, varCN As String
varDN = "To Sale Ret Bill No " & txtBillNo.Text
varCN = "By Sale Ret Bill No " & txtBillNo.Text
varGrpForMix = "Sundry Creditor"
cn.Execute "insert into mix values (" & VarVchNo & "," & "'" &
CDate(txtEDate.Text) & "'" & "," & "'" & txtName.Text & "'" & "," & "'" &
varGrpForMix & "'" & "," & "'" & varCN & "'" & "," &
Val(txtNetAmount.Text) - Val(txtTotalDisc.Text) & "," & "'" & "Sale Ret
A/c" & "'" & "," & "'" & "Sale" & "'" & "," & "'" & varDN & "'" & "," &
Round(Val(txtNetAmount.Text), 0) & "," & "'" & VarKey & "'" & "," & "'"
& "Sale" & "'" & ")"
If Val(txtTotalDisc.Text) > 0 Then
varGrpForMix = "Indirect Expense"
cn.Execute "insert into mix values (" & VarVchNo & "," & "'" &
CDate(txtEDate.Text) & "'" & "," & "'" & "Discount On Sale A/c" & "'" &
"," & "'" & "To Bill No " + txtBillNo.Text & "'" & "," & "'" & varGrpForMix
& "'" & "," & Val(txtTotalDisc.Text) & "," & "'" & varValue & "'" & "," &
"'" & varValue & "'" & "," & "'" & varValue & "'" & "," &

142
varNumericValue & "," & "'" & VarKey & "'" & "," & "'" & "DiscountS" &
"'" & ")"
End If
If Val(txtTaxTotal.Text) > 0 Then
cn.Execute "insert into mix values (" & VarVchNo & "," & "'" &
txtEDate.Text & "'" & "," & "'" & varValue & "'" & "," & "'" & varValue &
"'" & "," & "'" & varValue & "'" & "," & Val(varValue) & "," & "'" & "VAT
A/c" & "'" & "," & "'" & "Current Liabilites" & "'" & "," & "'" & "To Sale
Ret Bill No " + txtBillNo.Text & "'" & "," & varNumericValue & "," & "'" &
VarKey & "'" & "," & "'" & "DiscountS" & "'" & ")"
End If
End Sub

Private Function GenKeyForMix() As String


GenKeyForMix = Trim(txtBillNo.Text)
End Function

Private Sub ClearFields()


Dim cc As Control
For Each cc In frmSaleRet
If TypeOf cc Is TextBox Then
cc.Text = ""
End If
Next
ListView1.ListItems.Clear
GenBillNo
End Sub

Private Function GenBillNo() As Long


Dim RstGenBill As New ADODB.Recordset
Dim SQur As String
SQur = "Select max(bno) from saleRet"
With RstGenBill
If .State = adStateOpen Then
.Close
End If
.Open SQur, cn, adOpenStatic, adLockReadOnly
If .RecordCount > 0 Then
If Not IsNull(.Fields(0).Value) Then
txtBillNo.Text = .Fields(0).Value + 1
Else
txtBillNo.Text = 1
End If
Else
txtBillNo.Text = 1
End If

143
End With
End Function

Private Sub CalCulateTotalTax()


txtTaxTotal.Text = ""
txtNetAmount.Text = ""
For varC = 1 To ListView1.ListItems.Count
txtTaxTotal.Text = Val(txtTaxTotal.Text) +
Val(ListView1.ListItems(varC).SubItems(7))
txtNetAmount.Text = Val(txtNetAmount.Text) +
Val(ListView1.ListItems(varC).SubItems(6))
Next
txtNetAmount.Text = Val(txtNetAmount.Text) + Val(txtTaxTotal) -
Val(txtTotalDisc.Text)
End Sub

Private Sub txtRate_KeyPress(KeyAscii As Integer)


NumAllowOnly txtRate, KeyAscii
End Sub

Private Sub txtTotalDisc_KeyPress(KeyAscii As Integer)


NumAllowOnly txtTotalDisc, KeyAscii
End Sub

144
STOCK SUMMARY
Dim sdt As New Recordset, it As New Recordset
Dim i As Integer
Dim j As Integer, t As Double
Dim sp As String, sp1 As String

Private Sub Combo1_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
txtStDate.SetFocus
End If
End Sub

Private Sub butCancel_Click()


Unload Me
End Sub

Private Sub butDisplay_Click()


t=0
cn.Execute "delete from bil"
ListView2.ListItems.Clear
If Combo1.ListIndex = -1 Then
MsgBox "Select Item To List", , "Medicine Store"
Combo1.SetFocus
Exit Sub
End If

If Len(txtStDate.Text) < 6 Then


MsgBox "Invalid Date", , "Medicine Store"
txtStDate.SetFocus
Exit Sub
End If

If Len(txtEdDate.Text) < 6 Then


MsgBox "Invalid Date", , "Medicine Store"
txtEdDate.SetFocus
Exit Sub
End If

If CDate(txtStDate.Text) > CDate(txtEdDate.Text) Then


MsgBox "Invalid Date Sequence", , "Medicine Store"
txtStDate.SetFocus
Exit Sub
End If

145
If Len(txtStDate.Text) < 6 Then
MsgBox "Enter Exact Date", vbInformation, "DD-MM-YY"
txtStDate.SetFocus
Exit Sub
End If

If Len(txtEdDate.Text) < 6 Then


MsgBox "Enter Exact Date", vbInformation, "DD-MM-YY"
txtEdDate.SetFocus
Exit Sub
End If
ListView1.ListItems.Clear
Dim SQLQuerry As String
'SqlQuerry = "select edate,bno,qty,sch,replace,schp,srate from
sdet where item = " & "'" & Combo1.Text & "'"
SQLQuerry = "SELECT sdet.*, sale.Edate FROM sale,Sdet where
sale.bno = sdet.bno"
If sdt.State = adStateOpen Then
sdt.Close
End If
sdt.Open SQLQuerry, cn, adOpenStatic, adLockReadOnly

i=1
j=1
Do While Not sdt.EOF = True
If sdt!eDate >= CDate(txtStDate.Text) And sdt!eDate <=
CDate(txtEdDate.Text) Then
Set a = ListView1.ListItems.Add(j, , sdt!eDate)
With a
.SubItems(i) = sdt.Fields(1).Value
i=i+1
.SubItems(i) = Str(sdt.Fields(6).Value)
i=i+1
.SubItems(i) = sdt.Fields("Qty").Value
i=i+1
.SubItems(i) = sdt.Fields("SchP").Value
i=i+1
.SubItems(i) = sdt.Fields("Sch").Value
i=i+1
.SubItems(i) = sdt.Fields("Replace").Value
i=i+1
.SubItems(i) = sdt.Fields("Qty").Value +
sdt.Fields("Sch").Value + sdt.Fields("Replace").Value
j=j+1

146
End With
i=1
End If

If sdt!eDate <= CDate(txtEdDate.Text) Then


t = t + sdt!qty + sdt!sch + sdt!Replace
End If
sdt.MoveNext
Loop

Dim tt As Double
For i = 1 To ListView1.ListItems.Count
tt = tt + Val(ListView1.ListItems(i).ListSubItems(7))
Next
Label4.Caption = tt
Label2.Caption = "ToTal Sale Pcs. " & Str(t) & " Pcs."
Set sdt = Nothing

' for getting single item purchase

Dim i1 As Integer, j1 As Integer


Dim pse As New Recordset

i1 = 1
j1 = 1

' for purchase details

Dim yh As Double 'for total purchase


pse.Open "select * from pdet where item = " & "'" &
Combo1.List(Combo1.ListIndex) & "'", cn, adOpenDynamic,
adLockOptimistic
Do While Not pse.EOF = True
If pse!bno = " opening" Then
Set a = ListView2.ListItems.Add(j1, , pse!Date)
With a
.SubItems(i1) = pse!bno
i1 = i1 + 1
.SubItems(i1) = pse!qty
i1 = i1 + 1
.SubItems(i1) = pse!sch
i1 = i1 + 1
.SubItems(i1) = pse!qty + pse!sch
j1 = j1 + 1
End With
i1 = 1

147
End If
If pse!eDate >= CDate(txtStDate.Text) And pse!eDate <=
CDate(txtEdDate.Text) Then
If pse!bno <> " opening" Then
Set a = ListView2.ListItems.Add(j1, , pse!eDate)
With a
.SubItems(i1) = pse!bno
i1 = i1 + 1
.SubItems(i1) = pse!qty
i1 = i1 + 1
.SubItems(i1) = pse!sch
i1 = i1 + 1
.SubItems(i1) = pse!qty + pse!sch
j1 = j1 + 1
End With
i1 = 1
End If
End If
If pse!eDate <= CDate(txtEdDate.Text) Then
yh = yh + pse!qty + pse!sch
End If
pse.MoveNext
Loop
Label3.Caption = "ToTal Purchase " + Str(yh) + " Pcs."
Label4.Caption = "Balance " + Str(yh - t) + " Pcs."
End Sub
Private Sub Form_Load()
Dim ss As String
On Error GoTo ss

ListView2.ColumnHeaders.Add 1, , "Date"
ListView2.ColumnHeaders.Add 2, , "Bill No."
ListView2.ColumnHeaders.Add 3, , "Qty"
ListView2.ColumnHeaders.Add 4, , "Sch"
ListView2.ColumnHeaders.Add 5, , "ToTal"
' block for stock summary
If Module1.isu = "stock" Then
ListView1.Width = 7600
ListView1.ColumnHeaders.Add 1, , "ITEM.", 3800
ListView1.ColumnHeaders.Add 2, , "INWARD", 1100
ListView1.ColumnHeaders.Add 3, , "OUTWARD", 1100
ListView1.ColumnHeaders.Add 4, , "BALANCE", 1100
' it for pdet
it.Open "select item,sum(qty+sch) from pdet group by item order
by item", cn, adOpenDynamic, adLockPessimistic

148
' sdt for sdet
sdt.Open "select item ,sum(qty+replace+sch) from sdet group by
item order by item", cn, adOpenDynamic, adLockPessimistic

Dim f As Integer, f1 As Integer


f1 = 1
j=1
i=1

Do While Not it.EOF = True


f=0
sdt.MoveFirst
Do While Not sdt.EOF = True
If it!Item = sdt!Item Then
Set a = ListView1.ListItems.Add(j, , it!Item)
With a
.SubItems(i) = it.Fields(1).Value
i=i+1
.SubItems(i) = sdt.Fields(1).Value
i=i+1
If it.Fields(1).Value > 0 Then
.SubItems(i) = it.Fields(1).Value - sdt.Fields(1).Value
Else
.SubItems(i) = 0
End If
j=j+1
End With
i=1
f=1
f1 = f1 + 1
End If
sdt.MoveNext
Loop
If f = 0 Then
Set a = ListView1.ListItems.Add(j, , it!Item)
With a
.SubItems(i) = it.Fields(1).Value
i=i+1
.SubItems(i) = "0"
i=i+1
.SubItems(i) = it.Fields(1).Value
j=j+1
End With
i=1

149
End If
it.MoveNext
Loop
End If

' block for item wise details according to date

If Module1.isu = "dw" Then


If it.State = adStateOpen Then
it.Close
End If
it.Open "select iname from itemdet ", cn, adOpenDynamic,
adLockPessimistic
Do While Not it.EOF = True
Combo1.AddItem it!iname
it.MoveNext
Loop
ListView1.ColumnHeaders.Add 1, , "DATE", 1200
ListView1.ColumnHeaders.Add 2, , "BiLL No", 3000
ListView1.ColumnHeaders.Add 3, , "RATE", 1100
ListView1.ColumnHeaders.Add 4, , "QTY", 1100
ListView1.ColumnHeaders.Add 5, , "SCH %", 1100
ListView1.ColumnHeaders.Add 6, , "SCH PCS.", 1100
ListView1.ColumnHeaders.Add 7, , "REPL.", 1500
ListView1.ColumnHeaders.Add 8, , "TOTAL_QTY", 1230
End If
ss:
If Err.Number = 3021 Then
Resume Next
End If
End Sub

Private Sub txtstdate_KeyPress(KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Or KeyAscii
= 45 Then
txtStDate.Text = txtStDate.Text + vbkeyascii
Else
If KeyAscii = 13 Then
txtEdDate.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If
End Sub

Private Sub txteddate_KeyPress(KeyAscii As Integer)

150
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Or KeyAscii
= 45 Then
txtEdDate.Text = txtEdDate.Text + vbkeyascii
Else
If KeyAscii = 13 Then
butDisplay.SetFocus
Else
KeyAscii = Val(vbkeyascii)
End If
End If
End Sub

151
Function Module
Public VarStoreSaleTypeToModify As String
Public VarModifySale As Boolean
Public VarVchForMix As Double
Public cn As New ADODB.Connection

Public Sub MakeConnection(Optional varUserId As String, Optional


varPassWord As String, Optional varServerName As String)
Dim sConStr As String
Set cn = Nothing
varUserId = "Scott"
varPassWord = "Tiger"
sConStr = "provider=msdasql;driver=microsoft odbc for
oracle;server=" & varServerName & ";uid=" & varUserId & ";pwd=" &
varPassWord
cn.Open sConStr
End Sub

Public Function GenVchNo() As Double


''''''''''''''Genrate Voucher No For Mix''''''''''''''
Dim RstGenVchNo As New ADODB.Recordset
SQLQuerry = "Select max(vn) from mix"
With RstGenVchNo
If .State = adStateOpen Then
.Close
End If
.Open SQLQuerry, cn, adOpenKeyset
If .RecordCount > 0 Then
If Not IsNull(.Fields(0).Value) Then
GenVchNo = .Fields(0).Value
Else
GenVchNo = 1
End If
Else
GenVchNo = 1
End If
End With
End Function

Public Sub TxtAllowOnly(txtBox As TextBox, KeyAscii As Integer)


If KeyAscii >= 97 And KeyAscii <= 122 Or KeyAscii >= 65 And
KeyAscii <= 90 Or KeyAscii = 8 Or KeyAscii = 32 Then

152
txtBox.Text = txtBox.Text + vbkeyascii
Else
KeyAscii = 0
End If
End Sub

Public Sub NumAllowOnly(txtBox As TextBox, KeyAscii As Integer)


If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Or KeyAscii =
32 Or KeyAscii = 46 Then
txtBox.Text = txtBox.Text + vbkeyascii
Else
KeyAscii = 0
End If
End Sub

Public Sub About()


MsgBox "Project Developed For Medicine Store, Hoshiarpur " +
vbCrLf + "Developed By Sheetal Kumar , Student Of MCA " + vbCrLf +
vbCrLf + " KURUKSHETRA UNIVERSITY", , "Medicine Store"
End Sub

Public Sub CreateTables()


On Error Resume Next
cn.Execute "Drop table AcDet"
cn.Execute "Create table AcDet(Aname varchar2(50),Address
varchar2(100),Root varchar2(50),Phno varchar2(20),FaxNo
varchar2(20),VatNo varchar2(20),StCst varchar2(20),ope
number(10),oSide varchar2(20),Grp varchar2(40),Remark
varchar2(120))"
cn.Execute "Drop table bill"
cn.Execute "create table bil(d1 varchar2(120),d2 varchar2(120),d3
varchar2(120),d4 varchar2(120),d5 varchar2(120),d6 varchar2(120),d7
varchar2(120),d8 varchar2(120),d9 varchar2(120))"
cn.Execute "drop table CSendDetails"
cn.Execute "Create table CSendDetails(RefNo number(10),item
varchar2(50),Grp varchar2(50),Mrp varchar2(50),Qty varchar2(50))"
cn.Execute "Drop table Grp"
cn.Execute "create table Grp(grpName varchar2(50))"
cn.Execute "insert into Grp values('Bank')"
cn.Execute "insert into Grp values('Cash')"
cn.Execute "insert into Grp values('Capital')"
cn.Execute "insert into Grp values('Current Liabilities')"
cn.Execute "insert into Grp values('Direct Expense')"
cn.Execute "insert into Grp values('Direct Income')"
cn.Execute "insert into Grp values('Duties & Taxes')"

153
cn.Execute "insert into Grp values('Indirect Expense')"
cn.Execute "insert into Grp values('Indirect Expense')"
cn.Execute "insert into Grp values('Indirect Income')"
cn.Execute "insert into Grp values('Loan')"
cn.Execute "insert into Grp values('Purchase')"
cn.Execute "insert into Grp values('Sale')"
cn.Execute "insert into Grp values('Sundry Debitor')"
cn.Execute "insert into Grp values('Sundry Creditor')"
cn.Execute "insert into Grp values('Unsecured Loan')"
cn.Execute "drop table itemDet"
cn.Execute "create table itemDet(iname varchar2(50),itype
varchar2(25),mrp varchar2(15),srate varchar2(10),op
varchar2(10),opvalue varchar2(10))"
cn.Execute "drop table itemGrpDet"
cn.Execute "Create table itemGrpDet(itemGrp varchar2(30))"
cn.Execute "drop table led"
cn.Execute "Create table led(d1 varchar2(180),d2 varchar2(180),d3
varchar2(180),d4 varchar2(180),d5 varchar2(180))"
cn.Execute "drop table mix"
cn.Execute "create table mix(vn number(10),edate varchar2(15),acr
varchar2(50),cg varchar2(50),cn varchar2(150),camt number(10),adr
varchar2(50),dg varchar2(50),dn varchar2(150),damt number(10),kk
varchar2(50),vtype varchar2(50))"
cn.Execute "drop table PDet"
cn.Execute "create table PDet(bno varchar2(20),item
varchar2(50),grp varchar2(25),mrp varchar2(25),srate
number(10,2),qty number(10,2),sch number(10,2),cname
varchar2(100),sno varchar2(50),amt number(10,2),edate
varchar2(50),cost number(10,2))"
cn.Execute "drop table Pmain"
cn.Execute "create table Pmain(EDate varchar2(15),Bno
varchar2(20),cname varchar2(100),BType varchar2(20),disc
number(10,2),amt number(10,2),labo number(10,2),frh number(10,2))"
cn.Execute "drop table RootDet"
cn.Execute "create table RootDet(Rootlist varchar2(100))"
cn.Execute "insert into RootDet values('Railway Road Hsp')"
cn.Execute "insert into RootDet values('Red Road Hsp')"
cn.Execute "insert into RootDet values('Kashmiri Bazar Hsp')"
cn.Execute "insert into RootDet values('Partap Bazar Hsp')"
cn.Execute "insert into RootDet values('Jal Road Hsp')"
cn.Execute "insert into RootDet values('MahiL Pur')"
cn.Execute "insert into RootDet values('Phgwara Road Hsp')"
cn.Execute "drop table Sale"
cn.Execute "create table Sale(EDate varchar2(15),Bno
number(10),BType varchar2(20),cname varchar2(100),vatno
varchar2(20),root varchar2(100),addr varchar2(100),stype

154
varchar2(100),tax number(10,2),samt number(10,2),amt
number(10,2),deli varchar2(50),dis number(10,2),discp
number(10,2),itemSch number(10,2))"
cn.Execute "Drop table SaleRet"
cn.Execute "create table SaleRet(EDate varchar2(15),Bno
number(10),cname varchar2(100),root varchar2(50),addr
varchar2(150),tax number(10,2),amt number(10,2),dis Number(10,
2))"
cn.Execute "Drop table SDet"
cn.Execute "create table SDet(bno number(10),BType
varchar2(20),item varchar2(50),grp varchar2(25),mrp varchar2(25),qty
number(10,2),srate number(10,2),sch number(10,2),schp
number(10,2),Discount number(10,2),replace number(10,2),amt
number(10,2),tax number(10,2))"
cn.Execute "Drop table SDetRet"
cn.Execute "create table SDetRet(Bno number(20),item
varchar2(20),grp varchar2(20),mrp varchar2(10),qty
number(10,2),srate number(10,2),amt number(10,2),tax Number(10,
2))"
cn.Execute "Drop table UserD"
cn.Execute "create table UserD(UName varchar2(50),Psswd
varchar2(50))"
cn.Execute "Insert into UserD values('Admin','Admin')"
cn.Execute "Insert into UserD values('Upasna','Upasna')"
MsgBox "Tables Created "
End Sub

155
CONCLUSION

FINDINGS

The system will definitely be fruitful to both the organization and the members.
The members will benefit from the increased efficiency of the organization. On the other
hand organization with the little manpower will be in a position to save lot of money and
time.

LIMITATIOINS

In this software the provision for accounts management of the company is not
done, which if present can lead to best system.

FUTURE SCOPE OF THE PROJECT

Integrated system may be put on the web to make available all the information
online to the public.

156
BIBLIOGRAPHY
 Visual Basic Manual, NIC Training Division, NIC, New Delhi

 MS-Access user Manual from Microsoft.

 Using Visual Basic 6 by Reselman & Other. ( Prentice-Hall of India .)

 Teach Yourself Visual Basic 6 in 21 Days by Days Maver. (Tech – media)

 System Analysis And Design by Elias M. Awad. (Galgotia Publications).

 Principles of Database Management System, by James Martin

 Database Management System, by C J date

 An Introduction to Database Systems by Bipin C. Desai. (Galgotia Publications).

157

You might also like