+ All Categories
Home > Documents > Medical Stores management system in C#.Net

Medical Stores management system in C#.Net

Date post: 21-Jan-2016
Category:
Upload: mayur-wankhede
View: 6,466 times
Download: 4 times
Share this document with a friend
Description:
Manages medical stores daily budget and drugs
Popular Tags:
154
Introduc
Transcript
Page 1: Medical Stores management system in C#.Net

Introduction

Page 2: Medical Stores management system in C#.Net

INDEX

1. Introduction1.1 Project Overview

1.2 Organization Profile

2. Problem Definition2.1 Introduction

3. Introduction3.1 Introduction3.2 Economical Feasibility

3.3 Technical Feasibility

3.4 Operational Feasibility

4. System RequirementAnalysis

4.1 Introduction

4.2 Entity-Relationship Diagram (ERD)

4.3 Data Flow Diagram (DFD)

4.4 Data Dictionary

Page 3: Medical Stores management system in C#.Net

5. System Design

5.1 Introduction

5.2 Design Process

5.4 Database Design

5.3 Design Principles 5.5 Normalization

6. System Testing 6.1 Introduction

6.3 Black-Box Testing

6.2 White-Box Testing (GLASS-BOX TESTING)

6.4 Testing Strategies 6.4.1 Unit Testing

6.4.3 Validation Testing

6.4.2 Integration Testing

7. Software

Implementation7.1 Introduction

7.1.1 Direct Conversion

7.1.2 Parallel Conversion

7.1.3 Pilot Conversion

7.1.4 Phased Conversion

7.2 Software Requirements

7.3 Hardware Requirements

Page 4: Medical Stores management system in C#.Net

8. Literature Survey8.2 About Microsoft SQL Server:8.2.1 Microsoft SQL Server Database 8.2.2 Basic Database Concepts

8.2.3 Introduction to SQL

9. Forms (Snapsots)10. Conclusion11. Source Code12. Future Expansion13. Limitation14.The End

Page 5: Medical Stores management system in C#.Net
Page 6: Medical Stores management system in C#.Net

1. Introduction1.1 Project Overview

Medical Store Management software is general software

developed for Medical Store. This software helps them to do

billing and stock maintenance.

The purpose of this document is to specify

requirements and to give guidelines for the development of

above said project. In particular it gives guidelines on how to

prepare the project.

This document is intended to be a practical guide for

people who want to develop this software.

As this is generic software it can be used by a wide

variety of outlets (Retailers and Wholesalers) to automate the

process of manually maintaining the records related to the

subject of maintaining the stock and cash flows.

The main goal of the application is to maintain the

records of purchase, Sales and stock details with cash

transaction maintenance. Medical Store Management software is

very needy for Medical Store. This software helps them maintain

day to day transactions in computer.

1.2 Organization Profile

Page 7: Medical Stores management system in C#.Net

Since 2002  IT-NetworkZ®  has been providing creative lab training to businesses, professionals, individuals, and students to leverage the vendor certification and utilize the many new digital technologies available today. We've helped businesses, professionals, individuals, and students transform their career needs with vital, practical, flexible vendor certification training that meet their own changing needs as well as those of their customers and employee

Staying ahead of the competition, innovation, creating business intelligence-they're all dependent on association and collaboration.IT-NetworkZ® has the specialized abilities in Network Training and Consultancy. 

It also specializes in project-based training. Headquartered in South Africa, USA, IT-NetworkZ® has its Regional Training Center facility in Nagpur, India. 

In tune with the vision of global excellence, the company is expected to strategically diversify into Offshore Project Services and Placement with its key strength in the area of Training and Consultancy. 

Today, IT-NetworkZ® is a leading training provider with brick and mortar presence in Nagpur. Its main aim is to provide confidence to its clientele (who are businessmen, organizations and individuals) to achieve vendor certification with sound knowledge. 

Origin:

Page 8: Medical Stores management system in C#.Net

 IT-NetworkZ® began its operations in February, 2002 and quickly achieved profitability. The company's clientele since has been consistently increasing, since its inception. The members of the technical team were sourced from the highest ranks of IT network services, and have extensive experience in Training, Knowledge Management & Network Technologies. Certified by multiple vendors of Industry

Standards:

The process methodology adhered to at IT-NetworkZ® results in reduced risks and lower costs in every phase of its complex training, network integration, platform transitions and development outsourcing. By offering various combinations of on-site/off-site/offshore training and consultancy, IT-NetworkZ® is able to deliver zero-defect training to the client, on time, every time, and well within the budget.

CHAPTER 2

Page 9: Medical Stores management system in C#.Net

Problem Definition

Page 10: Medical Stores management system in C#.Net

2.1 Introduction

Medical Store Management System t is very helpful to manage sales information of Medical Store. It can easily keep the record of Hospitals who done regular business deals. This software is comprehensiveness and the simple by which it handles complex tasks easily.

Medical store management system project covers important details required for designing medical software application. Main objective of this project is to develop a software application for medical shops for performing tasks like billing, managing customer’s details, organizing stock details.

This medical store management system project is implemented in C#.net programming language.

3. Feasibility Study

Page 11: Medical Stores management system in C#.Net

3.1 Introduction

All projects are feasible – given unlimited resources and infinite

time! Unfortunately, the development of computer-based system or

product is more likely plagued by a scarcity of resources and difficult

delivery dates. It is both necessary and prudent to evaluate the feasibility

of a project at the earliest possible time. Months or years of effort,

thousands or millions of dollars, and untold professional embarrassment

can be averted if an ill-conceived system is recognized early in the

definition phase.

Generally the feasibility study is used for determining the resource

requirement cost, benefits and whether the proposed system is feasible

with respect to the organization .The feasibility of proposed Automation of

medical stores management system could be evaluated as follows. There

are three types of feasibility which are equally important. They are

Economic feasibility

Technical feasibility

Operational feasibility

3.2 Economical Feasibility

Economic feasibility is concerned with cost savings, increased

profits & reductions in efforts. It shows how much beneficial is the new

developed system over the existing system.

System startup cost

PC with good Processor Rest. 25,000/-

Line Printer Rest. 6,500/-

Furniture Indirect cost for site preparation Rest. 3,500/-

Purchase of Software Rest. 20,000/-

Rest. 55, 000/-

System operating costs

Additional equipment (CDs, ribbons, power supply) maintenances

Program maintenance

Page 12: Medical Stores management system in C#.Net

Stationary

Total operating cost Rs. 5,000/-Total Cost of the Implementation of

the Proposed System Rs. 55,000/-

Rs. 5,000/-

Rs. 60,000/-

As this project is related to service sector which aims at providing

better service to users and viewers and does not yield any income.

Providing better service is the basic requirement of any organization either

service sector or financial sector. So the proposed system is economically

feasible as it also reduces manpower utilization.

3.3 Technical Feasibility

Technical feasibility deals with the existing technology, software and

hardware requirements of the proposed system. The proposed system

“Medical Stores Manangement System” needs the following:

Software required for development:

• Operating System:

• Windows XP/Windows vista

• Front End :

• Microsoft Visual Studio 2008

• Back End:

• Microsoft SQL Server 2005

Hardware requirement for development:

• Processor:

• Pentium IV500MHz or higher

• Memory-RAM:

• 128MB or higher RAM

• Memory-CACHE:

• 128MB or higher RAM

• Hard Disk:

• 40GB or higher

Page 13: Medical Stores management system in C#.Net

In order to implement the proposed system necessary technology will be

acquired. Hence the proposed system is technically feasible.

3.4 Operational Feasibility

Operational feasibility is the willingness & ability of the management,

employees, users and others to use & support a proposed system. As

concerned to the Library of Noble College of Computer Sciences, all the

staff is in desperate need of a Computer Based Information System (CBIS)

to reduce the manual effort & for accurate information. There is no

difficulty in handling the system. There is full support from Management.

So the system is operationally feasible. The proposed Computer Based

Information System (CBIS) for NIVT is in no way inferior to the existing

manual system and it yields better results than the present manual

system. This system can give good support and makes the services easy.

CHAPTER 4

Page 14: Medical Stores management system in C#.Net

4.SystemRequirementAnalysis

4.1 Introduction

System analysis is an important activity that takes place when we

are building a new information system or changing existing ones.

Analysis is used to gain an understanding of an existing system and what

is required of it. At the conclusion of analysis, there is system description

and a set of requirements for a new system. If there is no existing

system, the analysis defines only the requirements.

System models are used to gain precision and to avoid the

ambiguities often found in the natural language system descriptions.

Modeling techniques used in system analysis avoids ambiguity by using

precise modeling constructors and process descriptions. They also

assist analysts to define precisely the requirements of the new system.

Software tools that help analyst in their work now often support system

analysis. These tools are the models developed during analysis and

some convert these models to trail designs.

This phase is detailed appraisal of the existing system. The

appraisal includes finding how the system works and what it does. It

also includes system’s problems and what the end-users require for any

new or changed system. After this phase, analyst should be familiar with

both the detailed operation of the system and what is required of the new

system.

Analysts must spend considerable time in examining components

of existing system. Analysts have to find out what information is send

between the end-users and the staff.

One of the most important factors in system analysis is to

understand the system and its problems. A good understanding of the

system enables designers to identify and correct problems and suggest

realistic solutions for them. It also helps them to develop solutions that

satisfy all users and thus make the new system acceptable in an

organization. System users are the first information source investigated

by the analysts.

Page 15: Medical Stores management system in C#.Net

From users it is to find out the existing system activities and to develop

the user’s objectives and requirements. A system analyst must spend a

lot of time talking to users and finding how they use the system, any

problems they find with the system and what they expect from it.

Thus a rule, system analysis is a difficult but rewarding job. There

are many constraints to be compiled within this work and many people to

satisfy. But there is the reward of seeing of a new system does its job

perfectly.

Process Models Incremental model The incremental model combines elements of the waterfall model applied in an iterative fashion. The incremental process model, like prototyping and other evolutionary approaches, is iterative in nature. But unlike prototyping, the incremental model focuses on the delivery of an operational product with each increment.

Incremental development is particularly useful when staffing is unavailable for a complete implementation by the business deadline that has been established for the project. Early increments can be implemented with fewer people. if the code product is well received, additional staff can be added to implement the next increment.Diagram:

COMMUNICAION PLANNING

DEPLOYMENT

CONSTRUCTION

MODELING

Page 16: Medical Stores management system in C#.Net

RAD Model

Rapid Application Development (RAD) is an incremental software process model that emphasizes a short development cycle. RAD model is a high speed adoption of the waterfall model, in which rapid development is achieved by using a component based construction approach. If requirements are well understood and project scope is constrained, the RAD process enables a development team to create a fully functional system with in a very short period. In RAD model communication works to understand the business problem and information characteristics. Planning is essential because multiple software teams work in parallel on different system functions. Modeling establishes design representations that serve as the basis for RAD construction activity. Construction emphasizes the use of pre existing software components. Finally the deployment establishes a basis for subsequent iterations. The RAD process model is illustrated in the figure below.Diagram:

Team #n

Team #2

Team #1

Communication

Planning

Modeling

construction

Modeling

Modeling

Construction

construction

deployment

Page 17: Medical Stores management system in C#.Net

4.3 Entity-Relationship Diagram (ERD)The Entity-Relationship Diagram depicts a relationship between data

objects. The ERD is the notation that is used to conduct the data

modeling activity. The attributes of each data object noted in the ERD

can be described using a data object description.

At first a set of primary components are identified for ERD i.e.

Data objects, Attributes, Relationships and Various type indicators. Data

objects are represented by labeled rectangles. Relationships are

indicated with labeled lines connecting objects. Connectors between data

objects and relationships are established using a variety of special

symbols that indicate cardinality and modality. ERD notation also

provides a mechanism that represents the association between objects.

Data modeling and the entity-relationship diagram provide the

analyst with a concise notation for examining data with in the context of

data processing application.The ER Diagram for the overall proposed

system is given in the figures 4.0,4.1(a).

Page 18: Medical Stores management system in C#.Net

4.4 Data Flow Diagram (DFD)

The data flow diagram (DFD) is one the most important modeling tools. It

is used to model the system components. These components are the

system process, the data used by the process, an external entity that

interacts with the system and the information flows in the system.

DFD shows how the information moves through the system and

how it is modified by a series of transformations. It is a graphical technique

that depicts information flow and those transformations that are applied as

data moves from input to output.

DFD is also known as bubble chart. A DFD may be used to

represent a system at any level of abstraction. DFD s may be partitioned

into levels that represent increasing information flow and functional details.

A level 0 DFD, also called as the context diagram, represents the

entire system as a single module with input and output data indicated by

incoming and outgoing arrows respectively. Additional process and

information flow paths are represented, as the level 0 DFD is partitioned

to reveal more details. A level 1 DFD, also called as top-level DFD,

represent the system with major modules and data stores. The other

levels will show each module in the top-level DFD in a more detailed

fashion.

Notation:

Data Flow : Data move in a specific direction from an origin to a

destination . The data flow is a “packet” of data.

Process : People, procedures or devices that produce data. The

physical component is not identified.

Source or Destination of data: External sources or destinations of data,

which may be people or organizations or other entities.

Data Store : Here, the data referred by a process in the system.

Page 19: Medical Stores management system in C#.Net

(Data Flow Diagram)

Functional-level DFD (Level 1)

Page 20: Medical Stores management system in C#.Net

4.5 Data Dictionary

A data dictionary is a catalog – a repository – of the elements in the

system. As the name suggests, these elements center on data and the

way they are structured to meet user requirements and organization

needs. A data dictionary is a collection of data about data. The basic idea

is to provide information on the definition, structure and the user of the

element an organization uses. The data element is a unit of data that can’t

be decomposed.

Customer Master:

Item Master:

Stock:

Page 21: Medical Stores management system in C#.Net

Purchase:

Sales:

Page 22: Medical Stores management system in C#.Net

CHAPTER 5

System Design

Page 23: Medical Stores management system in C#.Net

5. System Design5.1 Introduction

Design is the first step in the development phase for any engineering

product (or) system. It may be defined as “the process of applying various

techniques and principles for the purpose of defining a device, a process, or a

system insufficient detail to permit its physical realization”.

Software design is an iterative process through which requirements are

translated into a ‘Blue print’ for constructing the software. The design is

represented at a high level of abstraction, a level that can be directly

translated to specific data, functional and behavioral requirements.

Preliminary design is concerned with the transformation of

requirements into a data and software architecture. Detail design focuses on

refinements to the architectural representation. That leads to detailed data

structure and algorithmic representation for software.

In the design step, the element of the analysis model gets converted in

to a data design, an architectural design, an interface design and a

procedural design.

The data design transforms the information domain model created

during analysis into the data structures that will be required to implement

software.

The architectural design defines the relationship among major

structural elements of the program.

The interface design describes how the software communicates within

itself, to systems that interoperate with it, and with humans who use it. An

interface implies a flow of information (e.g., data and/or control). Therefore,

the data and control flow diagrams provide the information required for

interface design.

Page 24: Medical Stores management system in C#.Net

5.2 Design Process

Design process is in between the analysis and implementation process. The following design diagrams (data flow diagrams and E-R diagrams) make it easy to understand and implement.The design process of software system has two levels. 1. Systems Design or Top Level Design.

2. Detailed Design or Logical Design.

System Design or Top Level Design: In the system design the focus is on deciding which modules are needed for the system, the specification of these modules and how these modules should be interconnected. Detailed Design or Logical Design: In detailed design the interconnection of the modules or how the specifications of the modules can be satisfied is decided . Some properties for a software system design are

Verifiability. Completeness. Consistency. Traceability. Simplicity/understandability

5.3 Design Principles

Basic design principles that enable the software engineer to navigate

the design process are:

The design process should not suffer from “Tunnel vision”.

The design should be traceable to the analysis model.

The design should not reinvent the wheel.

The design should minimize the intellectual distance between the

software and the problem, as it exists in the real world.

The design should exhibit uniformity and integrity.

The design should be structured to accommodate changes.

The design is not coding, the coding is not a design.

The design should be assessed for the quality, as it is being

created, not after the fact.

The design should be reviewed to minimize the conceptual errors.

5.4 Database Design

Page 25: Medical Stores management system in C#.Net

The goal of Database Design is to generate a set of relation schemes that

allow us to store information without unnecessary redundancy and allows us

to retrieve information easily. We can achieve optimization, ease of use in

maintenance by designing the database using relational model in which data

is stored in the form of tables and there exists a relation between or among

the tables .

The design objectives must be:

To reduce redundancy.

To arrive at loss-less join.

To reduce the time as compared to the present system.

To reduce the number of errors.

5.5 Normalization

Normalization of relation schema is done to eliminate insertion and

deletion anomalies that exist in databases.

Normalization is a step-by-step reversible process of converting given

collection of relations to some more desirable form in which the relations have

a progressively simpler and more regular structure. No information is lost in

normalization process.

The objectives of Normalization are

To make it feasible to represent any relation in the database.

To obtain powerful retrieval algorithms based on a simpler

collection of relational operations than would otherwise be

necessary.

To free relations from undesirable insertions, update and deletion

dependencies. To make the collection of relations neutral to query

statistics where these statistics are liable to change as time goes

by.

Page 26: Medical Stores management system in C#.Net

A relation R is said to be in 1NF if all underlying domains contain

atomic values only.A relation R is said to be in 2NF if and only if it is in 1NF

and every non-key attribute is non-transitively dependent on the primary key.

A relationship is said to be in 3NF if and only if it does not feature any

non-trivial functional dependencies between non-prime attributes. A non-

prime attribute is one that does not belong to any candidate key.

All the database used in the project have atomic values.

Page 27: Medical Stores management system in C#.Net

CHAPTER 6

SystemTesting

Page 28: Medical Stores management system in C#.Net

6. System Testing6.1 Introduction

System testing is a critical element of software quality assurance

and represents the ultimate review of specification, design and coding.

Software testing fundamentals define the overriding objectives for software

testing. Testing is one of the steps in the software engineering process

that could be viewed (psychologically, at least) as destructive rather than

constructive.

Testing is a process of executing a program with the intent of

finding an error. A good test case is one that has a high probability of

finding a yet undiscovered error. A successful test is one that uncovers an

as yet undiscovered error.

6.2 White-Box Testing (GLASS-BOX TESTING)

White-box tests focus on the program control structures. Test cases

are derived to ensure that all statement in the program has been executed

at least once during testing and that all logical conditions have been

exercised.

Knowing the internal working of a product, tests can be conducted

to ensure that “all gears mesh”, that is, the internal operation performs

according to specification and all internal components have been

adequately exercised.

White Box Testing is a test case design methods that uses the

control structure of the procedural design to design to derive test cases.

Using white box testing methods, the test cases should

Guarantee that all independent paths within a module

have been exercised at least once

Exercise all logical decision on their and false sides

Execute all loops at their boundaries and within their

operational bounds

Exercise internal data structures to ensure their

validity

Page 29: Medical Stores management system in C#.Net

6.3 Black-Box Testing

Black-box testing focuses on the functional requirements of the

software .It is not an alternative to white-box techniques. Rather, it is a

complementary approach that is likely to uncover a different class of errors

than white-box methods.

Black-box testing attempts to find the following types of errors

Incorrect or missing functions.

Interface errors.

Errors in data structures or external database

access.

Performance errors and

Initialization and termination errors.

In white-box testing, test cases are performing early n the testing

processes where as in black-box testing process, it is applied during later

stages of testing as the attention is focused on the information domain.

6.4 Testing Strategies

Testing is a set of activities that can be planned in advance and

conducted systematically. A strategy for software testing must

accommodate low-level tests that are necessary to verify that a small

source code segment has been correctly implemented as well as high-

level tests that validate system functions against customer requirements.

Software testing is none element of verification and validation.

Verification refers to the set of activities that ensure that software correctly

implements a specific function. Validation refers to a different set of

activities that ensure that the software has been built is traceable to

customer requirements.

Page 30: Medical Stores management system in C#.Net

6.4.1 Unit Testing

Unit testing focuses verification effort on the smallest unit of

software design. Using the procedural design description, important

control paths are tested to uncover errors within the boundary of the

module. The relative complexity of test and uncovered errors is limited by

the constrained scope established for unit testing. The unit test is normally

white box oriented, and the step can be conducted in parallel for multiple

modules.

The module interface is tested to ensure that information properly

flows into and out of the program unit under test. The local data structure

is examined to ensure that data stored temporarily maintains its integrity

during all steps in an algorithm’s execution. Boundary conditions are

tested to ensure that the module operates properly at boundaries

established to limit or restrict processing. All independent paths through

the control structure are exercised to ensure that all statements in a

module have been executed at least once. And finally, all error-handling

paths are tested.

6.4.2 Integration Testing

Integration testing is a systematic technique for constructing the

program structure while conducting tests to uncover errors associated with

interfacing. The objective is to take unit tested modules and build a

program structure that has been dictated by design. There is often a

tendency to attempt non-incremental integration to construct the program

using a big bang approach. All modules are combined in advance. The

entire program is tested as a whole.

Incremental integration is the anti thesis of big bang approach. The

program is constructed and tested in small segments where errors are

easier to isolate and correct; interfaces are more likely to be tested

completely; and systematic test applied. Modules are integrated by moving

downward through the control hierarchy, beginning with the main control

module.

Page 31: Medical Stores management system in C#.Net

6.4.3 Validation Testing

At the culmination of integration testing, software is completely

assembled as a package; interfacing errors have been uncovered and

corrected and a final series of software tests-validation testing-may begin.

Validation can be defined in many ways, but a simple definition is that

validation succeeds when software functions in a manner that can be

reasonably expected by the customer.

Software validation is achieved through a series of black box tests

that demonstrates conformity with requirements. A test plan outlines the

classes of tests to be conducted and a test procedure defines specific test

cases that will be used in an attempt to uncover errors in conformity with

requirements. Both the plan and procedure are designed to ensure that all

functional requirements are satisfied; all performance requirements are

achieved; documentation is correct and human-engineered; and other

requirements are met.

After each validation test case has been conducted, one of the two

possible conditions exists:

The function or performance characteristics conform to specification

and are accepted.

A deviation from specification is uncovered and deficiency list is

created.

Validation testing has been performed after all the above four tests have

been performed. During the validation testing it is found that the system is

performing according to the requirements. All the five steps in the problem

definition have been verified.

Page 32: Medical Stores management system in C#.Net

CHAPTER 7

SoftwareImplementation

Page 33: Medical Stores management system in C#.Net

7.

SoftwareImplementation7.1 Introduction

Implementation is the process of assuring that the information

system is operational and then allowing users take over its operation for

use and evaluation. Implementation includes the following activities:

Obtaining and installing the system hardware.

Installing the system and making it run on its intended

hardware.

Providing user access to the system.

Creating and updating the database.

Training the users on the new system.

Documenting the system for its users and for those who will

be responsible for maintaining it in the future.

Making arrangements to support the users as the system is

used.

Transferring ongoing responsibility for the system from its

developers to the operations or maintenance part.

Evaluating the operation and use of the system.

The most visible component of implementation process is the

system conversion. The four basic conversion strategies include:

Direct Conversion

Parallel Conversion

Pilot Conversion

Phased Conversion

Page 34: Medical Stores management system in C#.Net

7.1.1 Direct Conversion

In direct conversion, the organization stops using the old system

and starts using the new one at the same time.

7.1.2 Parallel Conversion

Parallel conversion involves running both old system and new

system and comparing their results. The new system is accepted only

after the results have matched for an acceptable period.

7.1.3 Pilot Conversion

Pilot conversion means introducing the new system to a small part

of the organization, expanding its use once it is know to operate properly

there. Eventually, it will be in use by the entire organization.

7.1.4 Phased Conversion

Phased conversion means introducing a system in stages, one

component or module at a time, waiting until that one is operating properly

before introducing the next.

7.2 Software Requirements

• Operating System:

• Windows XP/Windows vista

• Front End :

• Microsoft Visual Studio 2008

• Back End:

• Microsoft SQL Server 2005

7.3 Hardware Requirements• Processor:

• Pentium IV500MHz or higher

• Memory-RAM:

• 128MB or higher RAM

Page 35: Medical Stores management system in C#.Net

CHAPTER 8

Literature Survey

Page 36: Medical Stores management system in C#.Net

ABOUT C#

C# is a modern, general-purpose object oriented programming language

developed by Microsoft and approved by Ecma and ISO.

C# was developed by Anders Hejlsberg and his team during the development of

.Net Framework.

C# is designed for Common Language Infrastructure (CLI), which consists of

the executable code and runtime environment that allows use of various high-

level languages to be used on different computer platforms and Architectures.

The following reasons make C# a widely used professional

language:

Modern, general purpose programming language

Object oriented.

Component oriented.

Easy to learn.

Structured language.

It produces efficient programs.

It can be compiled on a variety of computer platforms.

Part of .Net Framework.

Strong Programming Features of C#

Page 37: Medical Stores management system in C#.Net

Although C# constructs closely follows traditional high level

languages C and C++ and being an object oriented

Programming language, it has strong resemblance with Java, it has

numerous strong programming features that

make it endearing to multitude of programmers worldwide.

Following is the list of few important features:

Boolean Conditions

Automatic Garbage Collection

Standard Library

Assembly Versioning

Properties and Events

Delegates and Events Management

Easy to use Generics

Indexers

Conditional Compilation

Simple Multithreading

LINQ and Lambda Expressions

Integration with Windows

Page 38: Medical Stores management system in C#.Net

C# Environment

The .Net framework

The .Net framework is a revolutionary platform that helps you

to write the following types of applications:

Windows applications

Web applications

Web services

The .Net framework applications are multi-platform

applications. The framework has been designed in such a way

that it can be used from any of the following languages:

C# , C++, Visual Basic, Jscript, COBOL etc.

All these languages can access the framework as well as

communicate with each other.

The .Net framework consists of an enormous library of codes

used by the client languages like C#. Following are

some of the components of the .Net framework:

Page 39: Medical Stores management system in C#.Net

Common Language Runtime (CLR)

The .Net Framework Class Library

Common Language Specification

Common Type System

Metadata and Assemblies

Windows Forms

ASP.Net and ASP.Net AJAX

ADO.Net

Windows Workflow Foundation (WF)

Windows Presentation Foundation

Windows Communication Foundation (WCF)

LINQ

Page 40: Medical Stores management system in C#.Net

Integrated Development Environment (IDE) For C#

Microsoft provides the following development tools for C# programming:

Visual Studio 2010 (VS)

Visual C# 2010 Express (VCE)

Visual Web Developer

The last two are freely available from Microsoft official website. Using these

tools you can write all kinds of C# programs from simple command-line

applications to more complex applications. You can also write C# source code

files using a basic text editor, like Notepad, and compile the code into

assemblies using the command-line compiler, which is again a part of the .NET

Framework.

Visual C# Express and Visual Web Developer Express edition are trimmed

down versions of Visual Studio and has the same look and feel. They retain

most features of Visual Studio. In this tutorial, we have used Visual C # 2010

Express.

You can download it from Microsoft Visual Studio. It gets automatically

installed in your machine. Please note that you need an active internet

connection for installing the express edition.

Writing C# Programs on Linux or Mac OS

Although the.NET Framework runs on the Windows operating system, there are

some alternative versions that work on other operating systems. Mono is an

open-source version of the .NET Framework, which includes a C#

compiler and runs on several operating systems, including various flavors of

Linux and Mac OS.

Page 41: Medical Stores management system in C#.Net

C# Program Structure

A C# program basically consists of the following parts:

Namespace declaration

A class

Class methods

Class attributes

A Main method

Statements & Expressions

Comments

Compile & Execute a C# Program:

Using Visual Studio.Net for compiling and executing C# programs, take the

following steps:

Start Visual Studio.

On the menu bar, choose File, New, Project.

Choose Visual C# from templates, and then choose Windows.

Choose Console Application.

Specify a name for your project, and then choose the OK button.

The new project appears in Solution Explorer.

Write code in the Code Editor.

Click the Run button or the F5 key to run the project. A Command Prompt

window appears that contains the

Open a text editor and add the above mentioned code.

Save the file as helloworld.cs

Open the command prompt tool and go to the directory where you saved the

file.

Type csc .cs and press enter to compile your code.

Page 42: Medical Stores management system in C#.Net

8.2 About Microsoft SQL Server:Oracle is a multi-user relational database management system. It is a

software product that specializes in managing a single, shared set of information

among many concurrent users. Oracle products are based on a concept known as

client/server technology. The concept involves segregating the processing of an

application between two systems. One performs all activities related to the database

(server) and the other performs the activities that help the user to interact the

application (client).

A client or front-end database application also interacts with the database by

requesting and receiving information from the database server. It acts an interface

between the user and the database.

The database server and back-end is used to manage the database tables

optimally among multiple clients who concurrently request the server for the same

data. It also enforces data integrity across all client applications and controls

database access and other security requirements.

Any programming environment used to create containers, to manage human

data, in the conceptualization as a Data Management System. Traditionally, the

block of human data being managed is called a Database. Hence, in very simple

terms, these programming environments can the conceptualized as Database

Management Systems.

All Databases Management Systems allow users to create containers for data

storage and management. These containers are called ‘cells’. The minimum

information that has to be given to Oracle for a suitable container to be constructed,

which can hold free from human data, is,The cell name,The cell length, A cell can

also be called as a Field

Page 43: Medical Stores management system in C#.Net

8.2.1 Microsoft SQL Server Database

FeaturesImportant features are introduced with the release of the Oracle9i Database,

including advancements in Real Application Clusters, systems management,

availability, scalability, and security.

The features are

Availability

Enhanced Disaster Recovery Environment

Many tasks for managing a standby database are now automated. LogMiner now

supports log queries based on changes and has comprehensive log analysis

for additional datatypes, plus an easy- to-use graphical user interface.

Precision Database Repair

Oracle9i includes better prevention and improved handling of disk corruption, and

is able to restore the database to a consistent state after recovery.

Scalability

Scalable Session State Management

The footprint required for each user on Oracle9i is substantially reduced,

allowing more users to be hosted on the same, or larger, hardware platforms.

Fine-Grained, Automatic Resource Management

Administrators gain more granular control over resources through new features,

and can specify the maximum active sessions per consumer group.

Page 44: Medical Stores management system in C#.Net

Security

Strong Three-Tier Security

Three-tier security is enhanced by proxy authentication, including credential

proxy of X.509 certificates or distinguished names (DN), support for thick JDBC,

connection pooling for application users (thick and thin JDBC and OCI), and

integration with LDAP.

Improved User and Security Policy Management

A large number of enhancements have been made in areas ranging

from management of network naming and password-based user

management to new replication queue management and reconciliation

tools.

Data Encryption and Label Security

Oracle Label Security provides an out-of-the-box fine-grained access

control solution. Encryption enhancements support most popular algorithms for

encryption and data integrity.

8.2.2 Basic Database ConceptsA database is a corporate collection of data with some inherent meaning,

designed, built and populated with data for a specific purpose. A database stores

data that is useful to us. This data is only a part of the entire data available in the

world around us.

To be able to successfully design and maintain databases we have to do the

following:

Identify which part of the world’s data is of interest to us.

Identify what specific objects in that part of the world’s data are of interest to

us.

Identify a relationship between the objects.

Page 45: Medical Stores management system in C#.Net

Hence the objects, their attributes and the relationship between them that are of

interest to us are still owed in the database that is designed, built and populated with

data for a specific purpose.

CHARACTERISTICS OF A DATABASE MANAGEMENT SYSTEM:

It represents a complex relationship between data.

Keeps a tight control of debtor redundancy.

Enforces user-defined rules to ensure integrity of table data.

Has a centralized data dictionary for the storage of information pertaining

to data and its manipulation.

Ensures that data can be shared across applications.

Enforces data access authorization has automatic, intelligent backup and

recovery procedures for data have different interfaces via which users can

manipulate data.

RELATIONAL DATABASE MANAGEMENT:

A relational database management system uses only its relational capabilities

to manage the information stored in its databases.

INFORMATION REPRESENTATION:

All information stored in a relational database is represented only by data item

values, which are stored in the tables that make up the database. Associations

between data items are not logically represented in any other way, such as the use

of pointers from one table to the other.

LOGICAL ACCESSIBILITY:

Every data item value stored in relational database is accessible by stating

the nature of the table it is stored in, the name of the column under which it is stored

and the value of the primary key that defines the row in which it is stored.

INTEGRITY CONSTRAINTS:

Constraints that apply to entity integrity and referential integrity are specifiable

by the data language implemented by the database management system and not by

the statements coded into the application program.

Page 46: Medical Stores management system in C#.Net

DATA LANGUAGE:

The relational database management system may support many types of

languages for describing data and accessing the database. However, there must be

at least one language that uses ordinary character strings to support the definition of

data, the definition of views, the manipulation of data, constraints on data integrity,

information concerning authorization and the boundaries for recovery of units.

8.2.3 Introduction to SQL

SQL is the language that all users must use to access data with in oracle

database. SQL was developed in a prototype relational database management,

systems R, by IBM in the mid of 1970’s. System R was described by Dr.E.F.CODD

in November 1976 journal of R&D. In 1979 Oracle Corporation introduced the first

commercial implementation of SQL. American National Standard Institute (ANSI)

adapted SQL as the standard language for relational database management

systems in October 1986.

FEATURES OF SQL:

SQL is a non-procedural language i.e., you specify what information

you require, not to get it.

SQL is a language for all users.

SQL is a common language for all relational databases.

SQL is a data administration language that defines the structure of the

database, controls the users to accept the data.

SQL is a client/server language that allows application programs on

PC’ s connected via LAN to communicate with the database servers

that stores shared data.

SQL is used for storing and retrieving information in Oracle. A table is a primary

database object of SQL that is used to store data.

TYPES OF SQL COMMANDS:

SQL commands are divided into the following categories:

Page 47: Medical Stores management system in C#.Net

Data Definition Language

Data Manipulation Language

Transaction Control Language

Session Control Language

Data Definition Language: DDL statements define and maintain objects and drop

objects when they are no longer needed. Examples of this type of commands are

CREATE, ALTER, and DROP commands.

Data Manipulation Language: DML commands are the most frequently used SQL

commands. This are used to query and manipulate existing objects like tables.

Examples of these commands are INSERT, SELECT, UPDATE and DELETE.

Transaction Control Language: A transaction is a logical unit of work. All changes

made to the database can be referred to as a transaction. Transaction control

statements manage the changes made by DML statements. These Statements are

used for controlling data stored in the database. Examples these types of commands

are COMMIT ROLLBACK, SAVEPOINT etc.

Data Control Language: DCL provides users with privilege commands. The owner

of database like tables has the sole authority over them. The owner can allow other

database users access to the objects as per his/her discretion. Examples of these

commands are GRANT, REVOKE.

Session Control language: SCL allows a user to control the properties of his

current session including enabling and disabling roles and changing language

settings. Examples of these commands are ALTER SESSION, SET ROLE.

Page 48: Medical Stores management system in C#.Net

9. SCREENS SHOTS

Forms

Page 49: Medical Stores management system in C#.Net

Login Form

Mdi Parent

Page 50: Medical Stores management system in C#.Net

Item Master

Page 51: Medical Stores management system in C#.Net

Sales Bill

Page 52: Medical Stores management system in C#.Net

Purchase Bill

Page 53: Medical Stores management system in C#.Net

Item Stoke

Page 54: Medical Stores management system in C#.Net

CHAPTER 10

Conclusion

Page 55: Medical Stores management system in C#.Net

This process system is more easy and

reliable to use then manual system.

There is a security system with

password in the system that the manual

system never had and there was theft of

the data being stolen.

There are difference forms for every

record, there necessary to company to

have maintained of data.

There is also feature of showing the

previous customer detail.

Finally we have to come to the

conclusion that whatever the medical

Page 56: Medical Stores management system in C#.Net

store requirements is present in this

software.

CHAPTER 11

Source Code

Page 57: Medical Stores management system in C#.Net

Common Header Files using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;

LOGIN 1namespace Medical_store{ public partial class Login : Form { public Login() { InitializeComponent(); }

private void label3_Click(object sender, EventArgs e) {

}

private void panel1_Paint(object sender, PaintEventArgs e) {

}

private void button2_Click(object sender, EventArgs e) { this.Close(); Application.Exit(); }

private void Login_Load(object sender, EventArgs e)

Page 58: Medical Stores management system in C#.Net

{ // TODO: This line of code loads data into the 'medicalDataSet6.Login' table. You can move, or remove it, as needed. //this.loginTableAdapter.Fill(this.medicalDataSet6.Login); textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus();}

private void button1_Click(object sender, EventArgs e) { try { //Define object of SqlConnection and paasing of ConnectioString copied from database property SqlConnection conn = new SqlConnection(); //conn.ConnectionString = @"Data Source=SAGAR-C2F6419CA;Initial Catalog=info;Integrated Security=True"; conn.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; //Connection with Database starts conn.Open();

//Create object of SqlAdapter and pass the query and object of ConnectionString SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM Login", conn);

//Create object of Dataset DataSet ds = new DataSet();

//dataset is fiiled with dataAdapter adptr.Fill(ds);

//create object of DataTable and assign the table to it DataTable dt = ds.Tables[0];

//loops start Boolean b = false; for (int i = 0; i < dt.Rows.Count; i++) { //comparision with the username and password entered if ((textBox1.Text).Equals((dt.Rows[i][0]).ToString()) && (textBox2.Text).Equals((dt.Rows[i][1]).ToString())) { MessageBox.Show("You Are Successfully Loged in...", "Wel-Come To Medical-Store-Management-System", MessageBoxButtons.OK, MessageBoxIcon.None);

//shows the mdi form and hide the login form Mdi_parent1 childMdi = new Mdi_parent1(); childMdi.Show(); this.Hide(); b = true; break; } }

// if User name and password are not matched if (!b) {

Page 59: Medical Stores management system in C#.Net

MessageBox.Show("Invalid Username and Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus(); }

// Closing of database conn.Close(); } finally { } } }}

LOGIN 2namespace Medical_store{ public partial class loginEditcs : Form { public loginEditcs(Medical_store.Mdi_parent1 parent) { InitializeComponent(); this.MdiParent = parent; }

private void label1_Click(object sender, EventArgs e) {

}

private void button1_Click(object sender, EventArgs e) { //new Button TextBox1.Text = ""; TextBox2.Text = ""; textBox3.Text = ""; TextBox1.Focus(); }

private void loginEditcs_Load(object sender, EventArgs e) { TextBox1.Text = ""; TextBox2.Text = ""; textBox3.Text = ""; TextBox1.Focus(); }

private void button5_Click(object sender, EventArgs e) { //add button //If three of one field is empty then invalid; if (TextBox1.Text.Equals("") || TextBox2.Text.Equals("") || textBox3.Text.Equals(""))

Page 60: Medical Stores management system in C#.Net

{ MessageBox.Show("Invalid User Name Or Password", "Not Valid", MessageBoxButtons.OK, MessageBoxIcon.Error); TextBox1.Focus(); } else { SqlConnection conn = new SqlConnection(); conn.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

try { conn.Open();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM Login", conn);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { //Condition for checking existance of username; if (TextBox1.Text == (dt.Rows[i][0]).ToString()) { MessageBox.Show("Enter Different User Name", "User Name Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Error); TextBox1.Focus(); break; } } //checking of password matching if (TextBox2.Text == textBox3.Text) { SqlCommand cmd = new SqlCommand(); cmd = conn.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "INSERT INTO Login VALUES('" + TextBox1.Text + "','" + TextBox2.Text + "')"; cmd.ExecuteNonQuery(); MessageBox.Show("You Account Has Been Successfully Created", "CONGRATULATION", MessageBoxButtons.OK, MessageBoxIcon.Information);

} else { DialogResult result = MessageBox.Show("Password Does Not Match", "Re-Enter PassWord", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (result == DialogResult.Retry) { TextBox2.Focus(); } else { button5.Focus();

Page 61: Medical Stores management system in C#.Net

} } conn.Close(); } catch (Exception s) { MessageBox.Show(s.Message); } finally { //finally it will clears all the fields; TextBox1.Text = ""; TextBox2.Text = ""; textBox3.Text = ""; TextBox1.Focus(); } } }

private void button7_Click(object sender, EventArgs e) { //delete Account SqlConnection conn = new SqlConnection(); conn.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

try { conn.Open();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM Login", conn); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; int t = 0; for (int i = 0; i < dt.Rows.Count; i++) { if (TextBox1.Text == (dt.Rows[i][0]).ToString() && TextBox2.Text == (dt.Rows[i][1]).ToString()) { DialogResult result = MessageBox.Show("Do you really want to delete your account", "Confirm to delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (TextBox2.Text == textBox3.Text) { SqlCommand cmd = new SqlCommand(); cmd = conn.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "DELETE FROM Login WHERE [User-Name]= '" + TextBox1.Text + "' "; cmd.ExecuteNonQuery(); TextBox1.Focus(); TextBox2.Text = ""; textBox3.Text = ""; MessageBox.Show("Your account has been deleted", "DELETED", MessageBoxButtons.OK, MessageBoxIcon.Information); }

Page 62: Medical Stores management system in C#.Net

}

else { TextBox1.Text = ""; TextBox2.Text = ""; textBox3.Text = ""; TextBox1.Focus(); } t++; break; }

} if (t == 0) { DialogResult result = MessageBox.Show("User Name and ID didn't get Matched", "Information Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation); if (result == DialogResult.Retry) { TextBox1.Text = ""; TextBox2.Text = ""; textBox3.Text = ""; TextBox1.Focus(); } else { TextBox1.Text = ""; TextBox2.Text = ""; textBox3.Text = ""; TextBox1.Focus();

} } conn.Close(); } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button2_Click(object sender, EventArgs e) { this.Close(); } }}

Calender 3namespace Medical_store{ public partial class Calander : Form { public Calander(Medical_store.Mdi_parent1 parent) { InitializeComponent(); this.MdiParent = parent;

Page 63: Medical Stores management system in C#.Net

}

private void Calander_Load(object sender, EventArgs e) {

}

private void button2_Click(object sender, EventArgs e) { this.Close(); } }

Contact 4namespace Medical_store{ public partial class ContactUs : Form { public ContactUs(Medical_store.Mdi_parent1 parent) { InitializeComponent(); this.MdiParent = parent; }

private void ContactUs_Load(object sender, EventArgs e) { } }}

Customer 5namespace Medical_store{ public partial class Customermaster : Form { public int id; public Customermaster(Medical_store.Mdi_parent1 parent) { InitializeComponent(); this.MdiParent = parent; }

private void Customermaster_Load(object sender, EventArgs e) {

Page 64: Medical Stores management system in C#.Net

// TODO: This line of code loads data into the 'medicalDataSet3._Customer_Master' table. You can move, or remove it, as needed. // this.customer_MasterTableAdapter.Fill(this.medicalDataSet3._Customer_Master);

}

private void button3_Click(object sender, EventArgs e) { this.Close(); }

private void button1_Click(object sender, EventArgs e) { //new button textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = "";

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Customer-Master]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox1.Text = b.ToString(); }

private void button7_Click(object sender, EventArgs e) { //insert try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

//insert query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; //cmd.CommandText = "INSERT INTO supplier-master VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "')";

Page 65: Medical Stores management system in C#.Net

cmd.CommandText = "INSERT INTO [Customer-Master] VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "')"; cmd.ExecuteNonQuery(); MessageBox.Show("Record is succesfully added", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information);

cmd.Connection.Close();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Customer-Master]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox1.Text = b.ToString();

} catch (Exception s) { MessageBox.Show(s.Message); } finally { //textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; }

}

private void button6_Click(object sender, EventArgs e) { //update try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

//update query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "UPDATE [Customer-Master] SET [Customer-Id]='" + textBox1.Text + "',[Customer-Name]='" + textBox2.Text + "',[Address]= '" + textBox3.Text + "',[City] = '" + textBox4.Text + "',[Mo-No] = '" + textBox5.Text + "',[Phone-No] = '" + textBox6.Text + "' WHERE [Customer-Id]= '" + textBox1.Text + "'"; cmd.ExecuteNonQuery(); MessageBox.Show("Record is succesfully updated", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information);

Page 66: Medical Stores management system in C#.Net

cmd.Connection.Close();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Customer-Master]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt;

} catch (Exception s) { MessageBox.Show(s.Message); } }

private void button5_Click(object sender, EventArgs e) { //delete query try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; //con.ConnectionString = @"Data Source=PRAKASH\SQLEXPRESS;Initial Catalog=info;Integrated Security=True"; con.Open();

SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "select * from [Customer-Master] "; DialogResult result = MessageBox.Show("Do You Really Want TO Delete This Record", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { textBox1.Focus(); } else { cmd.CommandText = "DELETE FROM [Customer-Master] WHERE [Customer-Id]= '" + textBox1.Text + "'"; cmd.ExecuteNonQuery(); MessageBox.Show("Selected Record is deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); }

cmd.Connection.Close();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Customer-Master]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; }

Page 67: Medical Stores management system in C#.Net

catch (Exception s) { MessageBox.Show(s.Message); } }

private void button4_Click(object sender, EventArgs e) {

}

private void button2_Click(object sender, EventArgs e) { //Next button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [Customer-Master]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0];

for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox1.Text); id = id + 1; if (id <= dt.Rows.Count) { button2.Enabled = true; button10.Enabled = true;

textBox1.Text = (dt.Rows[id - 1][0]).ToString(); textBox2.Text = (dt.Rows[id - 1][1]).ToString(); textBox3.Text = (dt.Rows[id - 1][2]).ToString(); textBox4.Text = (dt.Rows[id - 1][3]).ToString(); textBox5.Text = (dt.Rows[id - 1][4]).ToString(); textBox6.Text = (dt.Rows[id - 1][5]).ToString();

//textBox1.Focus(); con.Close(); } else { button2.Enabled = false; } } catch (Exception s) { MessageBox.Show(s.Message);

Page 68: Medical Stores management system in C#.Net

} }

private void button8_Click(object sender, EventArgs e) { //Last button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [Customer-Master]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0]; int id = dt.Rows.Count; id--; if (id == 0) { MessageBox.Show("Database is Empty"); } else { button8.Enabled = true; button9.Enabled = true; textBox1.Text = (dt.Rows[id][0]).ToString(); textBox2.Text = (dt.Rows[id][1]).ToString(); textBox3.Text = (dt.Rows[id][2]).ToString(); textBox4.Text = (dt.Rows[id][3]).ToString(); textBox5.Text = (dt.Rows[id][4]).ToString(); textBox6.Text = (dt.Rows[id][5]).ToString(); con.Close(); } } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button9_Click(object sender, EventArgs e) { //first button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

Page 69: Medical Stores management system in C#.Net

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [Customer-Master]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0]; int id = dt.Rows.Count; id--; if (id == 0) { MessageBox.Show("Database is Empty"); } else { button9.Enabled = true; button8.Enabled = true; textBox1.Text = (dt.Rows[0][0]).ToString(); textBox2.Text = (dt.Rows[0][1]).ToString(); textBox3.Text = (dt.Rows[0][2]).ToString(); textBox4.Text = (dt.Rows[0][3]).ToString(); textBox5.Text = (dt.Rows[0][4]).ToString(); textBox6.Text = (dt.Rows[0][5]).ToString(); con.Close(); } } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button10_Click(object sender, EventArgs e) { //previous buttom try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [Customer-Master]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0];

for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox1.Text); id = id - 1;

Page 70: Medical Stores management system in C#.Net

if (id > 0) { button2.Enabled = true; button10.Enabled = true;

textBox1.Text = (dt.Rows[id - 1][0]).ToString(); textBox2.Text = (dt.Rows[id - 1][1]).ToString(); textBox3.Text = (dt.Rows[id - 1][2]).ToString(); textBox4.Text = (dt.Rows[id - 1][3]).ToString(); textBox5.Text = (dt.Rows[id - 1][4]).ToString(); textBox6.Text = (dt.Rows[id - 1][5]).ToString();

//textBox1.Focus(); con.Close(); } else { button10.Enabled = false; } }

catch (Exception s) { MessageBox.Show(s.Message); } }

private void groupBox3_Enter(object sender, EventArgs e) {

} }}

INFO 6

namespace Medical_store{ public partial class Info : Form { public int id; public Info(Medical_store.Mdi_parent1 parent) { InitializeComponent(); this.MdiParent = parent; }

private void Info_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'medicalDataSet.info' table. You can move, or remove it, as needed. //this.infoTableAdapter.Fill(this.medicalDataSet.info);

Page 71: Medical Stores management system in C#.Net

textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; comboBox1.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = ""; textBox10.Text = "";

}

private void button5_Click(object sender, EventArgs e) { this.Close(); }

private void button3_Click(object sender, EventArgs e) { //new button textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; comboBox1.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = ""; textBox10.Text = "";

//textBox1.Focus();

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM info", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox1.Text = b.ToString(); }

private void button2_Click(object sender, EventArgs e) { //insert query try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

Page 72: Medical Stores management system in C#.Net

con.Open();

//insert query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "INSERT INTO Info VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + comboBox1.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox10.Text + "')"; cmd.ExecuteNonQuery(); MessageBox.Show("Record is succesfully added", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information);

cmd.Connection.Close();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM info", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt;

} catch (Exception s) { MessageBox.Show(s.Message); } finally { //After succeesful insertion, all the fields will be cleared //textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; comboBox1.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = ""; textBox10.Text = ""; //textBoxSrNo.Text = textBoxSrNo.Text + 1; //textBox1.Focus(); } }

private void button4_Click(object sender, EventArgs e) { //delete query try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

Page 73: Medical Stores management system in C#.Net

//delete query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from [info]"; DialogResult result = MessageBox.Show("Do You Really Want TO Delete This Record", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { textBox1.Focus(); } else { cmd.CommandText = "DELETE FROM [info] WHERE Id= '" + textBox1.Text + "'"; cmd.ExecuteNonQuery(); MessageBox.Show("Selected Record is deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); }

//cmd.CommandText = "select * from [info]";

cmd.Connection.Close();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM info", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt;

} catch (Exception s) { MessageBox.Show(s.Message); } }

private void button6_Click(object sender, EventArgs e) { //update query try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

//update query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "UPDATE info SET Id ='" + textBox1.Text + "', PartyName ='" + textBox2.Text + "', Name ='" + textBox3.Text + "', Gender ='" + comboBox1.Text + "', Age ='" + textBox5.Text + "', Address ='" + textBox6.Text + "', [Contac-No] ='" + textBox7.Text + "', [Mo-No] ='" +

Page 74: Medical Stores management system in C#.Net

textBox8.Text + "', [Email Address] ='" + textBox9.Text + "', Remarks ='" + textBox10.Text + "' WHERE Id = '" + textBox1.Text + "'"; cmd.ExecuteNonQuery(); MessageBox.Show("Record is succesfully updated", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information); cmd.Connection.Close();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM info", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt;

} catch (Exception s) { MessageBox.Show(s.Message); } }

private void button1_Click(object sender, EventArgs e) { //next button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [info]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0];

for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox1.Text); id = id + 1; if (id <= dt.Rows.Count) { button1.Enabled = true; button10.Enabled = true; textBox1.Text = (dt.Rows[id - 1][0]).ToString(); textBox2.Text = (dt.Rows[id - 1][1]).ToString(); textBox3.Text = (dt.Rows[id - 1][2]).ToString(); comboBox1.Text = (dt.Rows[id - 1][3]).ToString(); textBox5.Text = (dt.Rows[id - 1][4]).ToString(); textBox6.Text = (dt.Rows[id - 1][5]).ToString(); textBox7.Text = (dt.Rows[id - 1][6]).ToString(); textBox8.Text = (dt.Rows[id - 1][7]).ToString(); textBox9.Text = (dt.Rows[id - 1][8]).ToString();

Page 75: Medical Stores management system in C#.Net

textBox10.Text = (dt.Rows[id - 1][9]).ToString();

//textBox1.Focus(); con.Close(); } else { button1.Enabled = false; } } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button8_Click(object sender, EventArgs e) { //Last button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [info]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0]; int id = dt.Rows.Count; id--;

if (id == 0) { MessageBox.Show("Database is empty"); } else { button3.Enabled = true; button9.Enabled = true;

textBox1.Text = (dt.Rows[id][0]).ToString(); textBox2.Text = (dt.Rows[id][1]).ToString(); textBox3.Text = (dt.Rows[id][2]).ToString(); comboBox1.Text = (dt.Rows[id][3]).ToString(); textBox5.Text = (dt.Rows[id][4]).ToString(); textBox6.Text = (dt.Rows[id][5]).ToString(); textBox7.Text = (dt.Rows[id][6]).ToString(); textBox8.Text = (dt.Rows[id][7]).ToString(); textBox9.Text = (dt.Rows[id][8]).ToString(); textBox10.Text = (dt.Rows[id][9]).ToString();

Page 76: Medical Stores management system in C#.Net

//textBox1.Focus(); con.Close(); } } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button9_Click(object sender, EventArgs e) { //First button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [info]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0]; int id = dt.Rows.Count; id--;

if (id == 0) { MessageBox.Show("Database is Empty"); } else { button3.Enabled = true; button9.Enabled = true;

textBox1.Text = (dt.Rows[0][0]).ToString(); textBox2.Text = (dt.Rows[0][1]).ToString(); textBox3.Text = (dt.Rows[0][2]).ToString(); comboBox1.Text = (dt.Rows[0][3]).ToString(); textBox5.Text = (dt.Rows[0][4]).ToString(); textBox6.Text = (dt.Rows[0][5]).ToString(); textBox7.Text = (dt.Rows[0][6]).ToString(); textBox8.Text = (dt.Rows[0][7]).ToString(); textBox9.Text = (dt.Rows[0][8]).ToString(); textBox10.Text = (dt.Rows[0][9]).ToString();

//textBox1.Focus(); con.Close(); } } catch (Exception s) { MessageBox.Show(s.Message);

Page 77: Medical Stores management system in C#.Net

}

}

private void button10_Click(object sender, EventArgs e) { //previous button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [info]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0];

for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox1.Text); id = id - 1; if (id > 0) { button1.Enabled = true; button10.Enabled = true; textBox1.Text = (dt.Rows[id - 1][0]).ToString(); textBox2.Text = (dt.Rows[id - 1][1]).ToString(); textBox3.Text = (dt.Rows[id - 1][2]).ToString(); comboBox1.Text = (dt.Rows[id - 1][3]).ToString(); textBox5.Text = (dt.Rows[id - 1][4]).ToString(); textBox6.Text = (dt.Rows[id - 1][5]).ToString(); textBox7.Text = (dt.Rows[id - 1][6]).ToString(); textBox8.Text = (dt.Rows[id - 1][7]).ToString(); textBox9.Text = (dt.Rows[id - 1][8]).ToString(); textBox10.Text = (dt.Rows[id - 1][9]).ToString();

textBox1.Focus(); con.Close(); } else { button1.Enabled = false; } } catch (Exception s) { MessageBox.Show(s.Message); } }

Page 78: Medical Stores management system in C#.Net

private void panel1_Paint(object sender, PaintEventArgs e) {

} }

}

ITEM 7namespace Medical_store{ public partial class ItemMaster : Form { public int ch,id; public ItemMaster(Medical_store.Mdi_parent1 parent) { InitializeComponent(); this.MdiParent = parent; }

private void ItemMaster_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'medicalDataSet1.Stock' table. You can move, or remove it, as needed. this.stockTableAdapter.Fill(this.medicalDataSet1.Stock); // TODO: This line of code loads data into the 'medicalDataSet._Item_master' table. You can move, or remove it, as needed. this.item_masterTableAdapter.Fill(this.medicalDataSet._Item_master);

comboBox1.Text = ""; textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; groupBox3.Enabled=false; SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Item-master]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox1.Text = b.ToString();

}

private void button8_Click(object sender, EventArgs e) { this.Close();

Page 79: Medical Stores management system in C#.Net

}

private void button1_Click(object sender, EventArgs e) { //new button comboBox1.Text = ""; textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Item-master]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox1.Text = b.ToString(); }

private void button2_Click(object sender, EventArgs e) { //insert query try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

if (con.State == ConnectionState.Closed) con.Open(); //insert query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; int a = 0; cmd.CommandText = "INSERT INTO [Item-master] VALUES('" + textBox1.Text + "','" + comboBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "')"; cmd.ExecuteNonQuery(); cmd.CommandText = "INSERT INTO Stock([Company-Name],[Item-id],[Sale-QTY],[Purchase-QTY],[Available-QTY])VALUES ('" + comboBox1.Text + "','" + textBox2.Text + "','" + a + "','" + a + "','" + a + "')"; cmd.ExecuteNonQuery(); MessageBox.Show("Record is succesfully added", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information);

cmd.Connection.Close(); SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Item-master]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt;

Page 80: Medical Stores management system in C#.Net

} catch (Exception s) { MessageBox.Show(s.Message); } finally { //After succeesful insertion, all the fields will be cleared comboBox1.Text = ""; textBox2.Text = ""; textBox3.Text = "";

} }

private void button4_Click(object sender, EventArgs e) { //update query try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

//update query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "UPDATE [Item-master] SET [Sr-NO] = '" + textBox1.Text + "',[Company-Name] = '" + comboBox1.Text + "',[Item-id]='" + textBox2.Text + "', Prize ='" + textBox3.Text + "' WHERE [Item-id] ='" + textBox2.Text + "'"; cmd.ExecuteNonQuery(); MessageBox.Show("Record is succesfully updated", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information); cmd.Connection.Close();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Item-master]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button6_Click(object sender, EventArgs e) { //delete query try { SqlConnection con = new SqlConnection();

Page 81: Medical Stores management system in C#.Net

con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; con.Open();

//delete query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "select * from [Item-master]"; DialogResult result = MessageBox.Show("Do You Really Want TO Delete This Record", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { textBox1.Focus(); } else { cmd.CommandText = "DELETE FROM [Item-master] WHERE [Item-id]= '" + textBox2.Text + "'"; cmd.ExecuteNonQuery(); MessageBox.Show("Selected Record is deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); }

cmd.Connection.Close();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Item-master]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button7_Click(object sender, EventArgs e) { groupBox3.Enabled = true; radioButton1.Focus(); }

private void button11_Click(object sender, EventArgs e) { //search Ok button try { SqlConnection conn = new SqlConnection(); conn.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (conn.State == ConnectionState.Closed) conn.Open();

Page 82: Medical Stores management system in C#.Net

SqlCommand cmd = new SqlCommand(); cmd = conn.CreateCommand(); cmd.CommandType = CommandType.Text;

if (ch == 1) { cmd.CommandText = "SELECT * FROM [Item-master] WHERE [Item-id] = '" + textBox4.Text + "' "; SqlDataAdapter adptr = new SqlDataAdapter(cmd.CommandText, conn); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; MessageBox.Show("Record Found", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information); //groupBox3.Hide();

int s = int.Parse(textBox4.Text); s--; groupBox1.Show();

textBox1.Text = (dt.Rows[s][0]).ToString(); comboBox1.Text = (dt.Rows[s][1]).ToString(); textBox2.Text = (dt.Rows[s][2]).ToString(); textBox3.Text = (dt.Rows[s][3]).ToString();

textBox1.Focus();

} if (ch == 2) { cmd.CommandText = "SELECT * FROM [Item-master] WHERE [Company-Name] = '" + textBox5.Text + "' "; SqlDataAdapter adptr = new SqlDataAdapter(cmd.CommandText, conn); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; MessageBox.Show((dt.Rows.Count).ToString(), "No.Of Record Found", MessageBoxButtons.OK);

} if (ch == 3) { cmd.CommandText = "SELECT * FROM [Item-master] WHERE Prize = '" + textBox6.Text + "' "; SqlDataAdapter adptr = new SqlDataAdapter(cmd.CommandText, conn); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; MessageBox.Show((dt.Rows.Count).ToString(), "No.Of Record Found", MessageBoxButtons.OK);

}

Page 83: Medical Stores management system in C#.Net

//groupBox1.Hide(); //buttonRefresh.Show(); conn.Close(); } catch (Exception s) { //MessageBox.Show(s.Message); } }

private void button12_Click(object sender, EventArgs e) { groupBox3.Enabled = false;

}

private void button5_Click(object sender, EventArgs e) { //next button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [Item-master]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0];

for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox1.Text); id = id + 1; if (id <= dt.Rows.Count) { button5.Enabled = true; button10.Enabled = true;

textBox1.Text = (dt.Rows[id - 1][0]).ToString(); comboBox1.Text = (dt.Rows[id - 1][1]).ToString(); textBox2.Text = (dt.Rows[id - 1][2]).ToString(); textBox3.Text = (dt.Rows[id - 1][3]).ToString();

//textBox1.Focus(); con.Close(); } else {

Page 84: Medical Stores management system in C#.Net

button5.Enabled = false; } } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button3_Click(object sender, EventArgs e) { //Last button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [Item-master]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0]; int id = dt.Rows.Count; id--;

if (id == 0) { MessageBox.Show("Database is empty"); } else { button3.Enabled = true; button9.Enabled = true;

textBox1.Text = (dt.Rows[id][0]).ToString(); comboBox1.Text = (dt.Rows[id][1]).ToString(); textBox2.Text = (dt.Rows[id][2]).ToString(); textBox3.Text = (dt.Rows[id][3]).ToString();

//textBox1.Focus(); con.Close(); } } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button9_Click(object sender, EventArgs e) { //last button

Page 85: Medical Stores management system in C#.Net

try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [Item-master]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0]; int id = dt.Rows.Count; id--;

if (id == 0) { MessageBox.Show("database is Empty"); } else { button3.Enabled = true; button9.Enabled = true;

textBox1.Text = (dt.Rows[0][0]).ToString(); comboBox1.Text = (dt.Rows[0][1]).ToString(); textBox2.Text = (dt.Rows[0][2]).ToString(); textBox3.Text = (dt.Rows[0][3]).ToString();

//textBox1.Focus(); con.Close(); } } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button10_Click(object sender, EventArgs e) { //Previous button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [Item-master]", con);

Page 86: Medical Stores management system in C#.Net

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0];

for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox1.Text); id = id - 1; if (id > 0) { button5.Enabled = true; button10.Enabled = true;

textBox1.Text = (dt.Rows[id - 1][0]).ToString(); comboBox1.Text = (dt.Rows[id - 1][1]).ToString(); textBox2.Text = (dt.Rows[id - 1][2]).ToString(); textBox3.Text = (dt.Rows[id - 1][3]).ToString();

//textBox1.Focus(); con.Close(); } else { button10.Enabled = false; } } catch (Exception s) { MessageBox.Show(s.Message); } }

private void textBox3_TextChanged(object sender, EventArgs e) {

}

private void radioButton1_CheckedChanged(object sender, EventArgs e) { if (radioButton1.Checked) { ch = 1; textBox4.Enabled = true; textBox5.Enabled = false; textBox6.Enabled = false;

} }

private void radioButton2_CheckedChanged(object sender, EventArgs e) { if (radioButton2.Checked) {

Page 87: Medical Stores management system in C#.Net

ch = 2; textBox4.Enabled = false; textBox5.Enabled = true; textBox6.Enabled = false;

} }

private void radioButton3_CheckedChanged(object sender, EventArgs e) { if (radioButton3.Checked) { ch = 3; textBox4.Enabled = false; textBox5.Enabled = false; textBox6.Enabled = true;

} } }}

Item Stock 8namespace Medical_store{ public partial class itemStock : Form { public itemStock(Medical_store.Mdi_parent1 parent) { InitializeComponent(); this.MdiParent = parent; }

private void itemStock_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'medicalDataSet1.Stock' table. You can move, or remove it, as needed. // this.stockTableAdapter.Fill(this.medicalDataSet1.Stock);

}

private void button1_Click(object sender, EventArgs e) { this.Close(); } }}

Page 88: Medical Stores management system in C#.Net

Mdi Parent 9namespace Medical_store{ public partial class Mdi_parent1 : Form { private int childFormNumber = 0;

public Mdi_parent1() { InitializeComponent(); }

private void ShowNewForm(object sender, EventArgs e) { Form childForm = new Form(); childForm.MdiParent = this; childForm.Text = "Window " + childFormNumber++; childForm.Show(); }

private void OpenFile(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { string FileName = openFileDialog.FileName; } }

private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { string FileName = saveFileDialog.FileName; } }

private void ExitToolsStripMenuItem_Click(object sender, EventArgs e) { this.Close(); }

private void CutToolStripMenuItem_Click(object sender, EventArgs e) { }

Page 89: Medical Stores management system in C#.Net

private void CopyToolStripMenuItem_Click(object sender, EventArgs e) { }

private void PasteToolStripMenuItem_Click(object sender, EventArgs e) { }

private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e) { // toolStrip.Visible = toolBarToolStripMenuItem.Checked; }

private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e) { statusStrip.Visible = statusBarToolStripMenuItem.Checked; }

private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.Cascade); }

private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.TileVertical); }

private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.TileHorizontal); }

private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.ArrangeIcons); }

private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e) { foreach (Form childForm in MdiChildren) { childForm.Close(); } }

private void viewMenu_Click(object sender, EventArgs e) {

}

private void toolsMenu_Click(object sender, EventArgs e)

Page 90: Medical Stores management system in C#.Net

{

}

private void windowsMenu_Click(object sender, EventArgs e) {

}

private void infoToolStripMenuItem_Click(object sender, EventArgs e) { Info child = new Info(this); child.Show(); }

private void exitToolStripMenuItem_Click(object sender, EventArgs e) { Application.Exit(); }

private void modelMasterToolStripMenuItem_Click(object sender, EventArgs e) { ItemMaster child = new ItemMaster(this); child.Show(); }

private void supplierMasterToolStripMenuItem_Click(object sender, EventArgs e) { SupplierMaster child = new SupplierMaster(this); child.Show(); }

private void customerMasterToolStripMenuItem_Click(object sender, EventArgs e) { Customermaster child = new Customermaster(this); child.Show(); }

private void purchaseLedgerToolStripMenuItem_Click(object sender, EventArgs e) { PurechaseBill child = new PurechaseBill(this); child.Show(); }

private void salesLedgerToolStripMenuItem_Click(object sender, EventArgs e) { SaleBill child = new SaleBill(this); child.Show(); }

private void salesRegisterToolStripMenuItem_Click(object sender, EventArgs e) { salesreg child = new salesreg(this);

Page 91: Medical Stores management system in C#.Net

child.Show(); }

private void purchaseRegisterToolStripMenuItem_Click(object sender, EventArgs e) { PurchaseReg child = new PurchaseReg(this); child.Show(); }

private void itemStockRegisterToolStripMenuItem_Click(object sender, EventArgs e) { itemStock child = new itemStock(this); child.Show(); }

private void calenderToolStripMenuItem_Click(object sender, EventArgs e) { Calander child = new Calander(this); child.Show(); }

private void contactUsToolStripMenuItem_Click(object sender, EventArgs e) { ContactUs child = new ContactUs(this); child.Show(); }

private void calculatorToolStripMenuItem_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("calc"); }

private void wordpadToolStripMenuItem_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("wordpad"); }

private void accountToolStripMenuItem1_Click(object sender, EventArgs e) { loginEditcs child = new loginEditcs(this); child.Show(); } }}

Purchase 10namespace Medical_store{ public partial class PurchaseReg : Form { public PurchaseReg(Medical_store.Mdi_parent1 parent) {

Page 92: Medical Stores management system in C#.Net

InitializeComponent(); this.MdiParent = parent; }

private void PurchaseReg_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'medicalDataSet5._Purchase_Final' table. You can move, or remove it, as needed. // this.purchase_FinalTableAdapter.Fill(this.medicalDataSet5._Purchase_Final);

}

private void button1_Click(object sender, EventArgs e) { this.Close(); }

private void button2_Click(object sender, EventArgs e) { //Total AMT try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8-9CF1490E8-9CF1490E8-9CF1490E8-9CF1490E8-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

if (con.State == ConnectionState.Closed) con.Open();

SqlCommand cmd = new SqlCommand();

cmd.Connection = con; cmd.CommandText = "select [Bill-No],Date,[Party-Name],[Total-Net-AMT],[Total-Vat-AMT],[Total-AMT] FROM [Purchase-Final]"; SqlDataReader dar = cmd.ExecuteReader();

DataTable dt = new DataTable();

dt.Load(dar);

dataGridView1.DataSource = dt;

double total = 0; for (int i = 0; i < dataGridView1.Rows.Count; i++) {

total += Convert.ToDouble(dataGridView1.Rows[i].Cells[5].Value.ToString().Trim()); textBox1.Text = total.ToString().Trim();

} //textBox1.Text = total.ToString().Trim(); con.Close(); }

Page 93: Medical Stores management system in C#.Net

catch (Exception S) { //MessageBox.Show(S.Message); }

} }}

Purchase Bill 11namespace Medical_store{ public partial class PurechaseBill : Form { public string st, st1; public int id; public PurechaseBill(Medical_store.Mdi_parent1 parent) { InitializeComponent(); this.MdiParent = parent; }

private void PurechaseBill_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'medicalDataSet._Item_master' table. You can move, or remove it, as needed. // this.item_masterTableAdapter.Fill(this.medicalDataSet._Item_master); // TODO: This line of code loads data into the 'medicalDataSet2._supplier_master' table. You can move, or remove it, as needed. //this.supplier_masterTableAdapter.Fill(this.medicalDataSet2._supplier_master); // TODO: This line of code loads data into the 'medicalDataSet1.Stock' table. You can move, or remove it, as needed. // this.stockTableAdapter.Fill(this.medicalDataSet1.Stock); // TODO: This line of code loads data into the 'medicalDataSet5._Purchase_Final' table. You can move, or remove it, as needed. //this.purchase_FinalTableAdapter.Fill(this.medicalDataSet5._Purchase_Final); // TODO: This line of code loads data into the 'medicalDataSet5.Purchase' table. You can move, or remove it, as needed. //this.purchaseTableAdapter.Fill(this.medicalDataSet5.Purchase);

// dataGridView2.Hide(); textBox10.Text = ""; comboBox1.Text = ""; textBox2.Text = ""; comboBox2.Text = ""; comboBox3.Text = "";

Page 94: Medical Stores management system in C#.Net

textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox11.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = "";

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open(); SqlDataAdapter adptr1 = new SqlDataAdapter("SELECT * FROM [Purchase-Final]", con); DataSet ds1 = new DataSet(); adptr1.Fill(ds1); DataTable dt1 = ds1.Tables[0]; dataGridView1.DataSource = dt1; int b = (dt1.Rows.Count); b++; textBox1.Text = b.ToString();

}

private void button8_Click(object sender, EventArgs e) { this.Close(); }

private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e) {

}

private void button2_Click(object sender, EventArgs e) { //Clear Button textBox2.Text = ""; comboBox2.Text = ""; comboBox3.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox11.Text = "";

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open(); SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM Purchase", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0];

Page 95: Medical Stores management system in C#.Net

dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox2.Text = b.ToString(); }

private void button3_Click(object sender, EventArgs e) { //add button //insert into purchase query update into stock try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open(); //insert into purchase SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "SELECT [Company-Name],[Item-id],[Sale-QTY],[Purchase-QTY],[Available-QTY] FROM Stock WHERE [Item-id]='" + comboBox3.Text + "'"; SqlDataReader dar = cmd.ExecuteReader();

DataTable dt = new DataTable();

dt.Load(dar);

dataGridView2.DataSource = dt; int q3=0,q1,q2,q4,q5=0; q1 =int.Parse(textBox5.Text);

q2 = Convert.ToInt32(dataGridView2.Rows[0].Cells[3].Value.ToString().Trim()); q3 = q1 + q2; q4 = Convert.ToInt32(dataGridView2.Rows[0].Cells[4].Value.ToString().Trim()); q5 = q1 + q4;

cmd.CommandText = "UPDATE Stock SET [Company-Name] ='" + comboBox2.Text + "', [Item-id] ='" + comboBox3.Text + "', [Purchase-QTY] ='" + q3 + "',[Available-QTY]='" + q5 + "' WHERE [Item-id] ='" + comboBox3.Text + "'"; cmd.ExecuteNonQuery(); cmd.CommandText = "INSERT INTO Purchase VALUES('" + textBox1.Text + "','" + textBox10.Text + "','" + comboBox1.Text + "','" + textBox2.Text + "','" + comboBox2.Text + "','" + comboBox3.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox11.Text + "')"; cmd.ExecuteNonQuery(); MessageBox.Show("Record is succesfully added", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information);

Page 96: Medical Stores management system in C#.Net

DataSet ds = new DataSet(); SqlDataAdapter adptr = new SqlDataAdapter("SELECT [Bill-No],Date,[Party-Name],[Sr.No],[Company-Name],[Model-Id],Prize,Vat,Qty,[Total-vat],[Total-Prize] FROM Purchase WHERE [Bill-No]='" + textBox1.Text + "'", con); //DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt1 = ds.Tables[0]; dataGridView1.DataSource = dt1; dataGridView1.Rows.Add(); cmd.Connection.Close(); } catch (Exception S) { //MessageBox.Show(S.Message); } }

private void button4_Click(object sender, EventArgs e) { //delete from purchase //update into stock try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

//delete query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Purchase"; DialogResult result = MessageBox.Show("Do You Really Want TO Delete This Record", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { textBox2.Focus(); } else {

cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "SELECT [Company-Name],[Item-id],[Sale-QTY],[Purchase-QTY],[Available-QTY] FROM Stock WHERE [Item-id]='" + comboBox3.Text + "'"; SqlDataReader dar = cmd.ExecuteReader();

DataTable dt = new DataTable();

dt.Load(dar);

dataGridView2.DataSource = dt;

Page 97: Medical Stores management system in C#.Net

int q3 = 0, q1, q2, q4, q5 = 0; q1 = int.Parse(textBox5.Text);

q2 = Convert.ToInt32(dataGridView2.Rows[0].Cells[3].Value.ToString().Trim()); q3 = q2 - q1; q4 = Convert.ToInt32(dataGridView2.Rows[0].Cells[4].Value.ToString().Trim()); q5 = q4 - q1;

cmd.CommandText = "UPDATE Stock SET [Company-Name] ='" + comboBox2.Text + "', [Item-id] ='" + comboBox3.Text + "', [Purchase-QTY] ='" + q3 + "',[Available-QTY]='" + q5 + "' WHERE [Item-id] ='" + comboBox3.Text + "'"; cmd.ExecuteNonQuery(); cmd.CommandText = "DELETE FROM Purchase WHERE [Bill-No]= '" + textBox1.Text + "' AND [Sr.No] = '" + textBox2.Text + "' AND [Model-Id]='" + comboBox3.Text + "'"; cmd.ExecuteNonQuery();

MessageBox.Show("Selected Record is deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); }

//cmd.CommandText = "select * from Purchase ";

} catch (Exception s) { MessageBox.Show(s.Message); } }

private void button12_Click(object sender, EventArgs e) { //next button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From Purchase Where [Bill-No]='" + textBox1.Text + "'", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0];

Page 98: Medical Stores management system in C#.Net

for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox2.Text); id = id + 1; if (id <= dt.Rows.Count) { button12.Enabled = true; button11.Enabled = true;

textBox10.Text = (dt.Rows[id - 1][1]).ToString(); comboBox1.Text = (dt.Rows[id - 1][2]).ToString(); textBox2.Text = (dt.Rows[id - 1][3]).ToString(); comboBox2.Text = (dt.Rows[id - 1][4]).ToString(); comboBox3.Text = (dt.Rows[id - 1][5]).ToString(); textBox3.Text = (dt.Rows[id - 1][6]).ToString(); textBox4.Text = (dt.Rows[id - 1][7]).ToString(); textBox5.Text = (dt.Rows[id - 1][8]).ToString(); textBox6.Text = (dt.Rows[id - 1][9]).ToString(); textBox11.Text = (dt.Rows[id - 1][10]).ToString();

//textBox1.Focus(); con.Close(); } else { button12.Enabled = false; } } catch (Exception s) { //MessageBox.Show(s.Message); } }

private void button11_Click(object sender, EventArgs e) { //Previous button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From Purchase Where [Bill-No]='" + textBox1.Text + "'", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0];

for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1);

Page 99: Medical Stores management system in C#.Net

} id = int.Parse(textBox2.Text); id = id - 1; if (id <= dt.Rows.Count) { button12.Enabled = true; button11.Enabled = true;

textBox10.Text = (dt.Rows[id - 1][1]).ToString(); comboBox1.Text = (dt.Rows[id - 1][2]).ToString(); textBox2.Text = (dt.Rows[id - 1][3]).ToString(); comboBox2.Text = (dt.Rows[id - 1][4]).ToString(); comboBox3.Text = (dt.Rows[id - 1][5]).ToString(); textBox3.Text = (dt.Rows[id - 1][6]).ToString(); textBox4.Text = (dt.Rows[id - 1][7]).ToString(); textBox5.Text = (dt.Rows[id - 1][8]).ToString(); textBox6.Text = (dt.Rows[id - 1][9]).ToString(); textBox11.Text = (dt.Rows[id - 1][10]).ToString();

//textBox1.Focus(); con.Close(); } else { button11.Enabled = false; } } catch (Exception s) { //MessageBox.Show(s.Message); } }

private void button1_Click(object sender, EventArgs e) { //total prize st = ((float.Parse(textBox3.Text) * (float.Parse(textBox5.Text))) + ((((float.Parse(textBox4.Text)) / 100) * (float.Parse(textBox3.Text))) * (float.Parse(textBox5.Text)))).ToString(); textBox11.Text = st; st1 = (float.Parse(textBox3.Text) * ((float.Parse(textBox4.Text)) / 100) * (float.Parse(textBox5.Text))).ToString(); textBox6.Text = st1;

}

private void button10_Click(object sender, EventArgs e) { //total amt //Total Vat AMT //Total Net AMT

try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

Page 100: Medical Stores management system in C#.Net

if (con.State == ConnectionState.Closed) con.Open();

SqlCommand cmd = new SqlCommand();

cmd.Connection = con; cmd.CommandText = "select [Bill-No],Date,[Party-Name],[Sr.No],[Company-Name],[Model-Id],Prize,Vat,Qty,[Total-vat],[Total-Prize] from Purchase Where [Bill-No]='" + int.Parse(textBox1.Text) + "'"; SqlDataReader dar = cmd.ExecuteReader();

DataTable dt = new DataTable();

dt.Load(dar);

dataGridView1.DataSource = dt;

double total = 0; double total1 = 0; for (int i = 0; i < dataGridView1.Rows.Count; i++) {

total1 += Convert.ToDouble(dataGridView1.Rows[i].Cells[6].Value.ToString().Trim()); total += Convert.ToDouble(dataGridView1.Rows[i].Cells[7].Value.ToString().Trim()); textBox8.Text = total1.ToString().Trim(); textBox7.Text = total.ToString().Trim(); textBox9.Text = (double.Parse(textBox7.Text) - double.Parse(textBox8.Text)).ToString();

}

con.Close(); } catch (Exception S) { //MessageBox.Show(S.Message); } }

private void button5_Click(object sender, EventArgs e) { //new button textBox1.Text = ""; //textBox10.Text = ""; comboBox1.Text = ""; textBox2.Text = ""; comboBox2.Text = ""; comboBox3.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox11.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = "";

SqlConnection con = new SqlConnection();

Page 101: Medical Stores management system in C#.Net

con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open(); SqlDataAdapter adptr1 = new SqlDataAdapter("SELECT * FROM [Purchase-Final]", con); DataSet ds1 = new DataSet(); adptr1.Fill(ds1); DataTable dt1 = ds1.Tables[0]; dataGridView1.DataSource = dt1; int b = (dt1.Rows.Count); b++; textBox1.Text = b.ToString(); }

private void button6_Click(object sender, EventArgs e) { //Save button //insert into purchasefinal try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "INSERT INTO [Purchase-Final] VALUES('" + textBox1.Text + "','" + textBox10.Text + "','" + comboBox1.Text + "','" + textBox9.Text + "','" + textBox8.Text + "','" + textBox7.Text + "')"; cmd.ExecuteNonQuery(); MessageBox.Show("Record is succesfully added", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information);

cmd.Connection.Close(); SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Purchase-Final]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt;

//textBox10.Text = ""; comboBox1.Text = ""; textBox2.Text = ""; comboBox2.Text = ""; comboBox3.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox11.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = "";

Page 102: Medical Stores management system in C#.Net

con.Close(); } catch (Exception s) { //MessageBox.Show(s.Message); } }

private void button7_Click(object sender, EventArgs e) { //update query [Purchase-Final] try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

//update query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "UPDATE [Purchase-Final] SET [Bill-No]='" + textBox1.Text + "',Date='" + textBox10.Text + "', [Party-Name]='" + comboBox1.Text + "', [Total-Net-AMT]='" + textBox9.Text + "', [Total-Vat-AMT]='" + textBox8.Text + "', [Total-AMT]='" + textBox7.Text + "'"; cmd.ExecuteNonQuery(); MessageBox.Show("Record is succesfully updated", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information); cmd.Connection.Close();

} catch (Exception s) { MessageBox.Show(s.Message); } }

private void button9_Click(object sender, EventArgs e) { //delete query in [Purchase-Final] try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

//delete query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from [Purchase-Final]"; DialogResult result = MessageBox.Show("Do You Really Want TO Delete This Record", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

Page 103: Medical Stores management system in C#.Net

if (result == DialogResult.No) { textBox1.Focus(); } else { cmd.CommandText = "DELETE FROM [Purchase-Final] WHERE [Bill-No]= '" + textBox1.Text + "'"; cmd.ExecuteNonQuery(); MessageBox.Show("Selected Record is deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); }

cmd.Connection.Close();

//SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Purchase-Final]", con); //DataSet ds = new DataSet(); //adptr.Fill(ds); //DataTable dt = ds.Tables[0]; //dataGridView1.DataSource = dt;

} catch (Exception s) { MessageBox.Show(s.Message); } }

private void textBox4_TextChanged(object sender, EventArgs e) {

}

private void label5_Click(object sender, EventArgs e) {

}

private void label6_Click(object sender, EventArgs e) {

} }}

Sales Bill 12namespace Medical_store{ public partial class SaleBill : Form { public int id;

Page 104: Medical Stores management system in C#.Net

public string st1, st; public SaleBill(Medical_store.Mdi_parent1 parent) { InitializeComponent(); this.MdiParent = parent; }

private void SaleBill_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'medicalDataSet._Item_master' table. You can move, or remove it, as needed. // this.item_masterTableAdapter.Fill(this.medicalDataSet._Item_master); // TODO: This line of code loads data into the 'medicalDataSet3._Customer_Master' table. You can move, or remove it, as needed. //this.customer_MasterTableAdapter.Fill(this.medicalDataSet3._Customer_Master); // TODO: This line of code loads data into the 'medicalDataSet1.Stock' table. You can move, or remove it, as needed. //this.stockTableAdapter.Fill(this.medicalDataSet1.Stock); // TODO: This line of code loads data into the 'medicalDataSet4._Sales_Final' table. You can move, or remove it, as needed. //this.sales_FinalTableAdapter.Fill(this.medicalDataSet4._Sales_Final); // TODO: This line of code loads data into the 'medicalDataSet4.Sales' table. You can move, or remove it, as needed. // this.salesTableAdapter.Fill(this.medicalDataSet4.Sales);

//dataGridView2.Hide(); comboBox1.Text = ""; textBox2.Text = ""; comboBox2.Text = ""; comboBox3.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox11.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = "";

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open(); SqlDataAdapter adptr1 = new SqlDataAdapter("SELECT * FROM [Sales-Final]", con); DataSet ds1 = new DataSet(); adptr1.Fill(ds1); DataTable dt1 = ds1.Tables[0]; dataGridView1.DataSource = dt1; int b = (dt1.Rows.Count); b++;

Page 105: Medical Stores management system in C#.Net

textBox1.Text = b.ToString();

}

private void button8_Click(object sender, EventArgs e) { this.Close(); }

private void button2_Click(object sender, EventArgs e) { //Clear Button textBox2.Text = ""; comboBox2.Text = ""; comboBox3.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox11.Text = "";

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; con.Open(); SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM Sales", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox2.Text = b.ToString();

}

private void button3_Click(object sender, EventArgs e) { //add button //insert into Sales query //update into stock try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

//insert into purchase SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "SELECT [Company-Name],[Item-id],[Sale-QTY],[Purchase-QTY],[Available-QTY] FROM Stock WHERE [Item-id]='" + comboBox3.Text + "'"; SqlDataReader dar = cmd.ExecuteReader();

Page 106: Medical Stores management system in C#.Net

DataTable dt = new DataTable();

dt.Load(dar);

dataGridView2.DataSource = dt;

int q3 = 0, q1, q2, q4, q5 = 0; q1 = int.Parse(textBox5.Text);

q2 = Convert.ToInt32(dataGridView2.Rows[0].Cells[2].Value.ToString().Trim()); if (q2 <= 5) { MessageBox.Show("out of stock item"); } q3 = q2 + q1; q4 = Convert.ToInt32(dataGridView2.Rows[0].Cells[4].Value.ToString().Trim()); q5 = q4 - q1;

cmd.CommandText = "UPDATE Stock SET [Company-Name] ='" + comboBox2.Text + "', [Item-id] ='" + comboBox3.Text + "', [Sale-QTY] ='" + q3 + "',[Available-QTY]='" + q5 + "' WHERE [Item-id] ='" + comboBox3.Text + "'"; cmd.ExecuteNonQuery(); cmd.CommandText = "INSERT INTO Sales VALUES('" + textBox1.Text + "','" + textBox10.Text + "','" + comboBox1.Text + "','" + textBox2.Text + "','" + comboBox2.Text + "','" + comboBox3.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox11.Text + "')"; cmd.ExecuteNonQuery(); MessageBox.Show("Record is succesfully added", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information);

DataSet ds = new DataSet(); SqlDataAdapter adptr = new SqlDataAdapter("SELECT [Bill-No],Date,[Party-Name],[Sr.No],[Company-Name],[Model-Id],Prize,Vat,Qty,[Total-vat],[Total-Prize] FROM Sales WHERE [Bill-No]='" + textBox1.Text + "'", con); //DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt1 = ds.Tables[0]; dataGridView1.DataSource = dt1; dataGridView1.Rows.Add();

cmd.Connection.Close();

} catch (Exception S) { //MessageBox.Show(S.Message); } }

private void button4_Click(object sender, EventArgs e) { //delete from Sales //update into stock try

Page 107: Medical Stores management system in C#.Net

{ SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

//delete query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Sales"; DialogResult result = MessageBox.Show("Do You Really Want TO Delete This Record", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { textBox2.Focus(); } else {

cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "SELECT [Company-Name],[Item-id],[Sale-QTY],[Purchase-QTY],[Available-QTY] FROM Stock WHERE [Item-id]='" + comboBox3.Text + "'"; SqlDataReader dar = cmd.ExecuteReader();

DataTable dt = new DataTable();

dt.Load(dar);

dataGridView2.DataSource = dt;

int q3 = 0, q1, q2, q4, q5 = 0; q1 = int.Parse(textBox5.Text);

q2 = Convert.ToInt32(dataGridView2.Rows[0].Cells[2].Value.ToString().Trim()); q3 = q2 - q1; q4 = Convert.ToInt32(dataGridView2.Rows[0].Cells[4].Value.ToString().Trim()); q5 = q4 + q1;

cmd.CommandText = "UPDATE Stock SET [Company-Name] ='" + comboBox2.Text + "', [Item-id] ='" + comboBox3.Text + "', [Sale-QTY] ='" + q3 + "',[Available-QTY]='" + q5 + "' WHERE [Item-id] ='" + comboBox3.Text + "'"; cmd.ExecuteNonQuery(); cmd.CommandText = "DELETE FROM Sales WHERE [Bill-No]= '" + textBox1.Text + "' AND [Sr.No] = '" + textBox2.Text + "' AND [Model-Id]='" + comboBox3.Text + "'"; cmd.ExecuteNonQuery();

MessageBox.Show("Selected Record is deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);

Page 108: Medical Stores management system in C#.Net

} } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button12_Click(object sender, EventArgs e) { //next button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From Sales Where [Bill-No]='" + textBox1.Text + "'", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0];

for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox2.Text); id = id + 1; if (id <= dt.Rows.Count) { button12.Enabled = true; button11.Enabled = true;

textBox10.Text = (dt.Rows[id - 1][1]).ToString(); comboBox1.Text = (dt.Rows[id - 1][2]).ToString(); textBox2.Text = (dt.Rows[id - 1][3]).ToString(); comboBox2.Text = (dt.Rows[id - 1][4]).ToString(); comboBox3.Text = (dt.Rows[id - 1][5]).ToString(); textBox3.Text = (dt.Rows[id - 1][6]).ToString(); textBox4.Text = (dt.Rows[id - 1][7]).ToString(); textBox5.Text = (dt.Rows[id - 1][8]).ToString(); textBox6.Text = (dt.Rows[id - 1][9]).ToString(); textBox11.Text = (dt.Rows[id - 1][10]).ToString();

//textBox1.Focus(); con.Close(); } else { button12.Enabled = false; } } catch (Exception s)

Page 109: Medical Stores management system in C#.Net

{ //MessageBox.Show(s.Message); } }

private void button11_Click(object sender, EventArgs e) { //Previous button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From Sales Where [Bill-No]='" + textBox1.Text + "'", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0];

for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox2.Text); id = id - 1; if (id <= dt.Rows.Count) { button12.Enabled = true; button11.Enabled = true;

textBox10.Text = (dt.Rows[id - 1][1]).ToString(); comboBox1.Text = (dt.Rows[id - 1][2]).ToString(); textBox2.Text = (dt.Rows[id - 1][3]).ToString(); comboBox2.Text = (dt.Rows[id - 1][4]).ToString(); comboBox3.Text = (dt.Rows[id - 1][5]).ToString(); textBox3.Text = (dt.Rows[id - 1][6]).ToString(); textBox4.Text = (dt.Rows[id - 1][7]).ToString(); textBox5.Text = (dt.Rows[id - 1][8]).ToString(); textBox6.Text = (dt.Rows[id - 1][9]).ToString(); textBox11.Text = (dt.Rows[id - 1][10]).ToString(); con.Close(); } else { button11.Enabled = false; } } catch (Exception s) { //MessageBox.Show(s.Message); } }

private void button1_Click(object sender, EventArgs e)

Page 110: Medical Stores management system in C#.Net

{ //total priz st = ((float.Parse(textBox3.Text) * (float.Parse(textBox5.Text))) + ((((float.Parse(textBox4.Text)) / 100) * (float.Parse(textBox3.Text))) * (float.Parse(textBox5.Text)))).ToString(); textBox11.Text = st; st1 = (float.Parse(textBox3.Text) * ((float.Parse(textBox4.Text)) / 100) * (float.Parse(textBox5.Text))).ToString(); textBox6.Text = st1; }

private void button10_Click(object sender, EventArgs e) { //total amt //Total Vat AMT //Total Net AMT

try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

if (con.State == ConnectionState.Closed) con.Open();

SqlCommand cmd = new SqlCommand();

cmd.Connection = con; cmd.CommandText = "select [Bill-No],Date,[Party-Name],[Sr.No],[Company-Name],[Model-Id],Prize,Vat,Qty,[Total-vat],[Total-Prize] from Sales Where [Bill-No]='" + int.Parse(textBox1.Text) + "'"; SqlDataReader dar = cmd.ExecuteReader();

DataTable dt = new DataTable();

dt.Load(dar);

dataGridView1.DataSource = dt;

double total = 0; double total1 = 0; for (int i = 0; i < dataGridView1.Rows.Count; i++) {

total1 += Convert.ToDouble(dataGridView1.Rows[i].Cells[6].Value.ToString().Trim()); total += Convert.ToDouble(dataGridView1.Rows[i].Cells[7].Value.ToString().Trim()); textBox8.Text = total1.ToString().Trim(); textBox7.Text = total.ToString().Trim(); textBox9.Text = (double.Parse(textBox7.Text) - double.Parse(textBox8.Text)).ToString();

}

con.Close();

Page 111: Medical Stores management system in C#.Net

} catch (Exception S) { //MessageBox.Show(S.Message); } }

private void button5_Click(object sender, EventArgs e) { //new button textBox1.Text = ""; comboBox1.Text = ""; textBox2.Text = ""; comboBox2.Text = ""; comboBox3.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox11.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = "";

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open(); SqlDataAdapter adptr1 = new SqlDataAdapter("SELECT * FROM [Sales-Final]", con); DataSet ds1 = new DataSet(); adptr1.Fill(ds1); DataTable dt1 = ds1.Tables[0]; dataGridView1.DataSource = dt1; int b = (dt1.Rows.Count); b++; textBox1.Text = b.ToString(); }

private void button6_Click(object sender, EventArgs e) { //Save button //insert into [Sales-Final] try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "INSERT INTO [Sales-Final] VALUES('" + textBox1.Text + "','" + textBox10.Text + "','" + comboBox1.Text + "','" + textBox9.Text + "','" + textBox8.Text + "','" + textBox7.Text + "')"; cmd.ExecuteNonQuery();

Page 112: Medical Stores management system in C#.Net

MessageBox.Show("Record is succesfully added", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information);

cmd.Connection.Close(); SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Sales-Final]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt;

//textBox10.Text = ""; comboBox1.Text = ""; textBox2.Text = ""; comboBox2.Text = ""; comboBox3.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox11.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = "";

con.Close(); } catch (Exception s) { //MessageBox.Show(s.Message); } }

private void button7_Click(object sender, EventArgs e) { //update query [Sales-Final] try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

//update query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "UPDATE [Sales-Final] SET [Bill-No]='" + textBox1.Text + "',Date='" + textBox10.Text + "', [Party-Name]='" + comboBox1.Text + "', [Total-Net-AMT]='" + textBox9.Text + "', [Total-Vat-AMT]='" + textBox8.Text + "', [Total-AMT]='" + textBox7.Text + "'"; cmd.ExecuteNonQuery(); MessageBox.Show("Record is succesfully updated", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information); cmd.Connection.Close();

}

Page 113: Medical Stores management system in C#.Net

catch (Exception s) { MessageBox.Show(s.Message); } }

private void button9_Click(object sender, EventArgs e) { //delete query in [Sales-Final] try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

//delete query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from [Sales-Final]"; DialogResult result = MessageBox.Show("Do You Really Want TO Delete This Record", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { textBox1.Focus(); } else { cmd.CommandText = "DELETE FROM [Sales-Final] WHERE [Bill-No]= '" + textBox1.Text + "'"; cmd.ExecuteNonQuery(); MessageBox.Show("Selected Record is deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); }

cmd.Connection.Close(); } catch (Exception s) { MessageBox.Show(s.Message); } } }}

SalesReg 13namespace Medical_store{ public partial class salesreg : Form { public salesreg(Medical_store.Mdi_parent1 parent) {

Page 114: Medical Stores management system in C#.Net

InitializeComponent(); this.MdiParent = parent; }

private void salesreg_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'medicalDataSet4._Sales_Final' table. You can move, or remove it, as needed. // this.sales_FinalTableAdapter.Fill(this.medicalDataSet4._Sales_Final);

}

private void button1_Click(object sender, EventArgs e) { this.Close(); }

private void button2_Click(object sender, EventArgs e) { //Total AMT try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

if (con.State == ConnectionState.Closed) con.Open();

SqlCommand cmd = new SqlCommand();

cmd.Connection = con; cmd.CommandText = "select [Bill-No],Date,[Party-Name],[Total-Net-AMT],[Total-Vat-AMT],[Total-AMT] FROM [Sales-Final]"; SqlDataReader dar = cmd.ExecuteReader();

DataTable dt = new DataTable();

dt.Load(dar);

dataGridView1.DataSource = dt;

double total = 0;

for (int i = 0; i < dataGridView1.Rows.Count; i++) {

total += Convert.ToDouble(dataGridView1.Rows[i].Cells[5].Value.ToString().Trim());

textBox1.Text = total.ToString().Trim();

} //textBox1.Text = total.ToString().Trim(); con.Close(); } catch (Exception S)

Page 115: Medical Stores management system in C#.Net

{ //MessageBox.Show(S.Message); } } }}

Supplier Master 14namespace Medical_store{ public partial class SupplierMaster : Form { public int id; public SupplierMaster(Medical_store.Mdi_parent1 parent) { InitializeComponent(); this.MdiParent = parent; }

private void SupplierMaster_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'medicalDataSet2._supplier_master' table. You can move, or remove it, as needed. //this.supplier_masterTableAdapter.Fill(this.medicalDataSet2._supplier_master); textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; }

private void groupBox1_Enter(object sender, EventArgs e) {

}

private void groupBox3_Enter(object sender, EventArgs e) {

}

private void button3_Click(object sender, EventArgs e) { this.Close(); }

private void button1_Click(object sender, EventArgs e) { //new button //textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = "";

Page 116: Medical Stores management system in C#.Net

textBox6.Text = ""; SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [supplier-master]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox1.Text = b.ToString(); }

private void button7_Click(object sender, EventArgs e) { //insert try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

//insert query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; //cmd.CommandText = "INSERT INTO supplier-master VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "')"; cmd.CommandText = "INSERT INTO [supplier-master] VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "')"; cmd.ExecuteNonQuery(); MessageBox.Show("Record is succesfully added", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information);

cmd.Connection.Close();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [supplier-master]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox1.Text = b.ToString();

} catch (Exception s) { MessageBox.Show(s.Message);

Page 117: Medical Stores management system in C#.Net

} finally { textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; } }

private void button6_Click(object sender, EventArgs e) { //update try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";

con.Open();

//update query SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "UPDATE [supplier-master] SET [supplier-id]='" + textBox1.Text + "',[supllier-name]='" + textBox2.Text + "',[address]='" + textBox3.Text + "',[city]='" + textBox4.Text + "',[Mo-No]='" + textBox5.Text + "',[Phone-No]='" + textBox6.Text + "' WHERE [supplier-id]= '" + textBox1.Text + "'"; cmd.ExecuteNonQuery(); MessageBox.Show("Record is succesfully updated", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information); cmd.Connection.Close();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [supplier-master]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt;

} catch (Exception s) { MessageBox.Show(s.Message); } }

private void button5_Click(object sender, EventArgs e) { //delete query try { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; //con.ConnectionString = @"Data Source=PRAKASH\SQLEXPRESS;Initial Catalog=info;Integrated Security=True";

Page 118: Medical Stores management system in C#.Net

con.Open();

SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text;

cmd.CommandText = "select * from [supplier-master]"; DialogResult result = MessageBox.Show("Do You Really Want TO Delete This Record", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { textBox1.Focus(); } else { cmd.CommandText = "DELETE FROM [supplier-master] WHERE [supplier-id]= '" + textBox1.Text + "'"; cmd.ExecuteNonQuery(); MessageBox.Show("Selected Record is deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); }

cmd.Connection.Close();

SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [supplier-master]", con); DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button2_Click(object sender, EventArgs e) { //Next button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [supplier-master]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0];

Page 119: Medical Stores management system in C#.Net

for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox1.Text); id = id + 1; if (id <= dt.Rows.Count) { button2.Enabled = true; button10.Enabled = true;

textBox1.Text = (dt.Rows[id - 1][0]).ToString(); textBox2.Text = (dt.Rows[id - 1][1]).ToString(); textBox3.Text = (dt.Rows[id - 1][2]).ToString(); textBox4.Text = (dt.Rows[id - 1][3]).ToString(); textBox5.Text = (dt.Rows[id - 1][4]).ToString(); textBox6.Text = (dt.Rows[id - 1][5]).ToString();

//textBox1.Focus(); con.Close(); } else { button2.Enabled = false; } } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button8_Click(object sender, EventArgs e) { //Last button try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [supplier-master]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0]; int id = dt.Rows.Count; id--; if (id == 0) { MessageBox.Show("Database is empty"); } else {

Page 120: Medical Stores management system in C#.Net

button8.Enabled = true; button9.Enabled = true;

textBox1.Text = (dt.Rows[id][0]).ToString(); textBox2.Text = (dt.Rows[id][1]).ToString(); textBox3.Text = (dt.Rows[id][2]).ToString(); textBox4.Text = (dt.Rows[id][3]).ToString(); textBox5.Text = (dt.Rows[id][4]).ToString(); textBox6.Text = (dt.Rows[id][5]).ToString();

//textBox1.Focus(); con.Close(); } } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button9_Click(object sender, EventArgs e) { //First buttom try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [supplier-master]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0]; int id = dt.Rows.Count; id--; if (id == 0) { MessageBox.Show("database is empty"); } else { button8.Enabled = true; button9.Enabled = true;

textBox1.Text = (dt.Rows[0][0]).ToString(); textBox2.Text = (dt.Rows[0][1]).ToString(); textBox3.Text = (dt.Rows[0][2]).ToString(); textBox4.Text = (dt.Rows[0][3]).ToString(); textBox5.Text = (dt.Rows[0][4]).ToString(); textBox6.Text = (dt.Rows[0][5]).ToString();

//textBox1.Focus();

Page 121: Medical Stores management system in C#.Net

con.Close(); } } catch (Exception s) { MessageBox.Show(s.Message); } }

private void button10_Click(object sender, EventArgs e) { //previous buttom try {

SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();

SqlDataAdapter adptr = new SqlDataAdapter("Select * From [supplier-master]", con);

DataSet ds = new DataSet();

adptr.Fill(ds);

DataTable dt = ds.Tables[0];

for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox1.Text); id = id - 1; if (id > 0) { button2.Enabled = true; button10.Enabled = true;

textBox1.Text = (dt.Rows[id - 1][0]).ToString(); textBox2.Text = (dt.Rows[id - 1][1]).ToString(); textBox3.Text = (dt.Rows[id - 1][2]).ToString(); textBox4.Text = (dt.Rows[id - 1][3]).ToString(); textBox5.Text = (dt.Rows[id - 1][4]).ToString(); textBox6.Text = (dt.Rows[id - 1][5]).ToString();

//textBox1.Focus(); con.Close(); } else { button10.Enabled = false; } } catch (Exception s) { MessageBox.Show(s.Message);

Page 122: Medical Stores management system in C#.Net

} } }}

Future Expansion• In next version master can change rate &

type of Medicines Company & rate.

• In next version master can change rate&

type of the table.

• As well as they can also add new

Medicines details.

• We will also include the new modules in

next version.

• Solve all the limitations of the project.

Page 123: Medical Stores management system in C#.Net

 Create a data base in XML so system can be

more flexible for various Operating

Systems

Limitations• There are many kind of advantages for

application but some amounts of limitation

are Available in this system.

• These certain limitation is following here :

• SQL server is must be required in the

software

• It can’t be used big medical Firms, it only

applicable for small Units.

Page 124: Medical Stores management system in C#.Net

• No interactive designs are included in the

software.

Page 125: Medical Stores management system in C#.Net

THE END


Recommended