Vous êtes sur la page 1sur 68

NATIONAL COLLEGE OF BUSINESS

ADMINISTRATION & ECONOMICS


MULTAN

Milk Inventory System Using C# .Net

BY
MUHAMMAD ATIF
&
UMAIR AHMAD

BACHELOR OF SCIENCE
IN
COMPUTER SCIENCE

JULY, 2018
NATIONAL COLLEGE OF BUSINESS
ADMINISTRATION & ECONOMICS
MULTAN

Milk Inventory System Using C# .Net

BY

MUHAMMAD ATIF
&
UMAIR AHMAD

A Report of Project submitted to School of Computer Science


National College of Business Administration & Economics

In partial fulfillment of the


Requirements for the degree of

BACHELOR OF SCIENCE
IN
COMPUTER SCIENCE

JULY, 2019

i
NATIONAL COLLEGE OF BUSINESS
ADMINISTRATION & ECONOMICS
MULTAN

Milk Inventory System Using C# .Net


BY
MUHAMMAD ATIF
&
UMAIR AHMAD
__________________________________________________________________________

A Report of Project submitted to School of Computer Sciences, in partial fulfillment


of the requirements for the degree of

BACHELOR OF SCIENCE
IN
COMPUTER SCIENCE

Dissertation Committee:
____________________________
Chairman
____________________________
Member
____________________________
Member

______ ______
Pro-Rector
National College of Business
Administration & Economics Multan

ii
iii
DECLARATION

I hereby declare that the project report on “Milk Inventory System Using C# .Net”
submitted by Muhammad Atif & Umair Ahmad to National College of Business
Administration & Economics Multan Campus, fulfillment of the requirement of the
degree of BSCS (Hons) in department of computer science under the supervision of Mr.
Omer Aziz. The material contained in the report has not been submitted to any University or
Institution for the award of any degree.

MUHAMMAD ATIF
&
UMAIR AHMAD
JULY 2018

iv
National College of Business Administration &
Economics Multan Campus
11/B, Gulgasht Colony, Bosan Road Multan

COURSE COMPLETION CERTIFICATE

Ref. ______________ Dated:___________

It is certified that Course requirements of Mr. Muhammad Atif & Umair Ahmad
Registration No. 12142169 & 12144074 for the program BSCS has been completed and his
current CGPA is 2.6 & 2.8 respectively.

Prof. Dr. Farkhand Shakeel Prof. Dr. GR Pasha


Director (R&D) Pro-Rector

Copy to
1. The Director NCBA&E Lahore
2. The Director NCBA&E Multan Campus.
3. Notification file.

v
RESEARCH COMPLETION CERTIFICATE

It is certified that the research work contained in this thesis entitled “Milk Inventory
System Using C# .Net” has been carried out and completed by Muhammad Atif & Umair
Ahmad under my guidance and supervision during his BS Computer Science program.

(Mr. Omer Aziz)


Supervisor

vi
ACKNOWLEDGEMENT

In the name of ALLAH, the most gracious, merciful and beneficent who has given me
the strength and has made me able to fulfill the requirement of this project successfully in a
short period of time within limited resources and knowledge.
I express my gratitude and obligation to Prof. Dr. Farkhand Shakeel Mahmood &
Prof. DR. G.R Pasha (Pro-Rector of NCBA&E Multan Campus) who did their selfless
and tireless efforts for providing us all facilities throughout the academic session and their
kind and loving attitude, always, has encouraged us to work hard.
I feel great honor to express my sincere and cordial thanks to respected teacher, Mr.
Omer Aziz for his guidance, sympatric attitude, solving related problems that I faced in
project completion period. He guided me in critical times and helped me whenever I needed.
And special thanks to NCBA&E MULTAN CAMPUS for completing this manuscript.

MUHAMMAD ATIF
&
UMAIR AHMAD
JULY, 2018

vii
DEDICATED TO

My father who have always been a source of inspiration for me .My teachers
who supported me in every step of life.my mother who always prays for my
success and always been a role model for me.

viii
ABSTRACT

Inventory management is an important aspect of any successful business. It


is the process of overseeing and controlling the flow of inventory units a
business uses in the production or manufacture of goods for sale or
distribution. Inventories are usually made up of a combination of goods, raw
materials and finished products, and effective management of these items is
essential to ensure optimal stock levels and to maximize the earning potential
of the company. It also allows a business to prevent or mitigate any inventory-
associated losses. Inventory management software is used by businesses for
various reasons: it can track the costs of inventory throughout the
manufacture and sales process, tell businesses when to replenish stock, and
allow them to track profits. It can also be used to forecast inventory levels
and prices, as well as expected product demand. Through this system
customer is updated in our list and we print the file record of the customer.
Customers are updated as we enter their data. Whenever he comes to us
second time we give him his information. Customers are of two type some of
them are new and some of them are old. Some of them temporary and some of
them are temporary and some of them are permanent. We give customer a
token in which his no is written.is written. New customers data is saved
although the old customer data is updated. The customers who come to us
regularly are saved hence they become our permanent customers. Supplier
are those who supplies us milk. We give them money and buy milk. Suppliers
bring milk from dairy farms

ix
x
SUMMARY

Effective inventory management is important as not only is inventory one of the most
valuable assets to a business; there is a direct link between inventory levels and company
profits. Inventory represents an investment that is tied up until either the item is sold, or it is
used in the production of another item that is sold. Businesses are reliant on having items in
stock; otherwise customers will simply go to a competitor who can provide what they
want.

xi
PROJECT BRIEF

PROJECT NAME Milk Inventory System

ORGANIZATION Desktop Application

SUBMITTED BY Muhammad Atif & Umair Ahmad

SUPERVISED TO Mr. Omer Aziz

STARTING DATE July, 2018

COMPLETION DATE September, 2018

COMPUTER USED Intel Core i5

OPERATING SYSTEM Windows 10

SOURCE LANGUAGE C#. Net

TOOLS Visual Studio 2013

xii
TABLE OF CONTENTS

DECLARATION I
V
RESEARCH COMPLETION CERTIFICATE V
I
ACKNOWLEDGMENT V
I
I
ABSTRACT I
X
SUMMARY X

CHAPTER-1: INTRODUCTION 1
1.1 Problem Statement 1
1.2 Motivation 1
1.3 Proposed Application 2
1.4 Scope 2
1.5 Features of Project 2
1.6 Objectives of the Project 2
1.6.1 Primary Objective 3
1.6.2 Secondary Objective
1.6.3 Hierarchy of Application 3
1.6.4 Mains Forms of the Application
4

4
CHAPTER-2: LITERATURE REVIEW 5
2.1 Programming Concepts 5
2.2 Object Oriented Programming Concepts 5
2.2.1 Encapsulation 6
2.2.2 Inheritance 7
2.2.3 Polymorphism 7
2.2.4 Advantages of OOP 7
2.2.5 Disadvantages of OOP 8
2.3 Structured Query Language SQL 8
CHAPTER-3: ANALYSIS AND DESIGN 9
3.1 Analysis 9
3.2 System Overview 9
3.2.1 Database 9
3.2.2 Milk Inventory System 9
3.2.3 LabelWrite Application 9
3.3 Design 1
0
3.4 Application Design 1
0
3.4.1 System Architecture 1
0
3.5 Feasibility Analysis 1
xiii
1
3.5.1 Economic Feasibility 1
1
3.5.2 Technical Feasibility 1
1
3.5.3 Operational Feasibility 1
1
3.6 Process Flow Diagram 1
1
3.7 Use Case Diagram 1
2
3.7.1 Diagram Building Block 1
3
CHAPTER-4: EXPERIMENTAL WORK 1
4
4.1 Visual Studio 2013 1
4
4.2 Windows Forms 1
4
4.3 Database Design Concepts 1
5
4.3.1 Relational Database Model 1
5
4.3.2 Database Diagram 1
6
4.4 SQL Server 2012 1
7
4.4.1 Data Retrieval and Manipulation in SQL Server 1
7
4.4.2 Concurrency and Locking 1
8
4.4.3 SQL Server Management Studio 1
8
4.5 .Net Framework 4.7 1
8
4.5.1 .Net Framework Structure 1
8
4.6 Technology Used 1
9
4.6.1 JIT Compilation 1
9
4.6.2 .Net Languages 1
9
4.6.3 Connection Object 2
0
4.6.4 Command Object 2
0
4.6.5 Team Foundation Server 2

xiv
0
4.7 Source Code Control 2
0
4.8 Best Coding Practices 2
1
4.8.1 Commenting 2
1
4.8.2 Exception Handling 2
1
4.9 Testing 2
2
4.1 Project Screenshots 2
0 2
CHAPTER-5: Results and Discussion, Conclusion and Future Work 2
7
5.1 Results and Discussion 2
7
5.2 Conclusion 2
8
5.3 Future Enhancement 2
9
REFERENCES 3
0
APPENDIX 3
1

xv
LIST OF FIGURES

FIGURE 1.1 Hierarchy of Application 4


FIGURE 2.1 Encapsulation 6
FIGURE 2.2 Inheritance 7
FIGURE 3.1 One tire Architecture of MIS 10
FIGURE 3.2 Process flow diagram of MIS 12
FIGURE 3.3 Use case diagram for Admin 12
FIGURE 3.4 Use case diagram for Seller 13
FIGURE 4.1 Table design for SQL Database 15
FIGURE 4.2 Structure of SQL Database table 16
FIGURE 4.3 Features of ER Win 16
FIGURE 4.4 .Net framework Architecture 19
FIGURE 4.5 Folder Structure in TFS 20
FIGURE 4.6 Exception handling try and catch 21
FIGURE 4.7 Admin or Login Form 22
FIGURE 4.8 Main Form 23
FIGURE 4.9 Customer Form 23
FIGURE 4.10 Purchase Form 24
FIGURE 4.11 Sales Record Form 25
FIGURE 4.12 Report Form 25
FIGURE 4.13 Expense Report Form 26
FIGURE 4.14 Delete User Account Form 26

xvi
LIST OF ABBREVIATIONS

MIS Milk Inventory System


DBMS Database Management System
DFD Data Flow Diagram
DML Data Manipulation Language
DDL Data Definition Language
DCL Data Control Language
CLR Common Language Runtime
SQL Structured Query Language
TFS Team Foundation Server

xvii
CHAPTER -1
INTRODUCTION
Milk inventory system is a desktop application based on C#.netin its first chapter we will tell
how we deal with the customers. Through this system we have an ease that we can show
customer his old data. Through this paper work is avoided in our small milk shop. And it
becomes easy for us to us to understand information .In it there are tables through which data
is saved. Every customer is given his own ID. There is also user name and password of this
application.

1.1 Problem Statement

After analyzing several existing inventory system we have now the obvious vision of the
project to be developed. Before we started to build the application team had many challenges.
We defined our problem statement as:

1) To make desktop based application of inventory system for small organization.

2) To make the system easily managed and can be secured.

3) To cover all the areas of inventory system like purchase details and sales details.

1.2 Motivation

When there was no inventory system, It takes time to do this work and the people who come
to us for buying milk have to wait a lot. But now when there is milk inventory system the
work is done accurately. Time is also saved by it.

1.3 Proposed Application

It is important to users because user can get information about customer registration. The
users have to use it, can save time, money and get every information about any customer that
is registered in recording list.

1.4 Scope

The Desktop application is an easy to use self-service which enables the users that want to
save time and money, to use it with easy user interface and get information about the
customer and their consultants. Some of scopes are:

 Only one person is responsible in assigning the details or records.


 It is security driven.

1
 Admin can be added as per the requirement.

1.5 Features of Project

This application is used to show the details about the sales and purchase. It gives the details
about the purchasing and selling. The details components are described below:

Login page: As application starts the login page appears. Admin login is determined by the
username and password that has all the authority to add, update and delete the stock as per
the requirement.

Sales details: It show the details about the product of the sale.

Purchase details: It shows the details about the purchase along with the price and dates.

1.6 Objectives of the Project

The main purpose of the Milk inventory system is to provide complete information about
customer record.

1.6.1 Primary Objective

The primary objectives of the project are mentioned below:

1) To give people ease and easiness.

2) To secure the record of the people.

1.6.2 Secondary objective

The secondary objectives of this project are mentioned below:

1) Whenever a customer came and he his permanent his daily data is saved and stored.

2) To make inventory easy.


3) To collect all information about the product and make god changes in the product by
it..
4) To make product manageable and make inventory sophisticated

1.6.3 Hierarchy of Application

2
Login Form

Main Form

Suppler
Registration
Sale Record Statistics Find Record Crystal Report

Update Supplier
Record

New Customer Form Expenses Form Reports Form

Figure 1.1 Hierarchy of Application

1.6.4 Main Forms of the Application

The Application has following Activities

1 Login Form

2 Main Form

3 Supplier Registration Form

CHAPTER - 2
LITERATURE REVIEW

Products are considered as the business resources for the organization. This
includes managing the product with appropriate way to review any time as per the
requirement. Therefore it is important to have a computer based Milk Inventory
System which has the ability to generate reports, maintain the balance of the stock,
details about the purchase and sales and also maintain the worker and customer

3
record. This application can be used by the small company for the management of
their stock record in the production houses.
After analyzing the other software’s, I decided to include some of common and key
features that should be included in every management system. So we decided to
include those things that help the small organization in a way or other.

2.1 Programming Concepts


Programming is the process of designing/writing computer applications.
Thousands of programming languages have been designed/used with a specific
purpose. Even though each programming language has their unique features or
syntax, there are certain concepts common to all languages. There are different types
of programming styles such as structured programming, object oriented programming,
etc. In structured programming, blocks of programming statements (code) are
executed one after another. Control statements change which blocks of code is
executed next. In object oriented programming, data are contained in objects and is
accessed using methods specific to the type of the object. There is no single “flow” of
the program as objects can freely interact with one another by passing messages.

2.2 Object Oriented Programming Concepts


OOP is a programming methodology based on objects which is concerned to
develop application on real time, so more emphasis is given on data unlike the other
programming styles like structured or functional. The concept of having objects
makes OOP more organized, reusable and speedy. Today most of the programming
languages support OOP. Most of them have enhanced features to make OOP more
easy and maintainable.

1) Object
An object consists of attributes and methods. Attributes define the properties of the
object while methods define its behavior. In OOP, object is considered as an instance
of a class. Considering Milk Inventory System, “Seller” and “Customer” can be
considered as objects and “Seller Name” and “Customer Name” can be considered as
their attributes.
2) Class

4
A class is simply a representation of a type of object. Using the blueprint analogy, a
class is a blueprint of an object, and an object is a building made from that blueprint
(Microsoft, 2013 1). It consists of a name, attributes and methods.
Encapsulation, inheritance and polymorphism are the main fundamental concepts in
OOP.
2.2.1 Encapsulation
Encapsulation normally refers to information hiding or treating a group of related
properties, methods, and other members as a single unit or object (Microsoft. 2014 2).
Hence encapsulation guarantees integrity of object data and uses methods to access
information as shown in Figure 2.1

Figure 2.1 Encapsulation [1995]

Encapsulation can be achieved using “private”, “public” and “protected” access


modifiers.
“Public” – access is not restricted
“Private” – access limited to members of same class
“Protected” – access limited to members of same class or descendants

2.2.2 Inheritance
Inheritance describes the ability to create new classes based on an existing class. So
the object can inherit properties from another object while defining common codes
only one place with enhancing maintainability of the software. Figure 2.2 shows an

5
example of inheritance. According to the Figure 2.2 “Customer” is the parent class.
Both “Student” and “Staff” inherit all the fields and methods of the parent class
“Customer”. Hence inheritance guarantees code reusability.

Figure 2.2 An example of Inheritance

2.3.3 Polymorphism
Polymorphism is the ability to take more than one forms depending on data type or
class, so that multiple classes can be used interchangeably, even though each class
implements the same properties or methods in different ways. Hence polymorphism
guarantees maintainability of the software. Interface introduces polymorphism. It
contains only definition of methods, properties and events, so the class that
implements the interface, has the implementation or declaration to achieve
polymorphism.
2.3.4 Advantages of Object Oriented Programming
 Easy to maintain and extend existing code
 Enhanced code reusability
 Object hiding can be achieved
 Improved reliability and flexibility, as objects can be dynamically called and
accessed, new objects may be created at any time
 Faster development, as reusing software modules lowers the time usage
 Cost effectiveness, as reusing software modules lowers the cost of development

2.3.5 Disadvantages of Object Oriented Programming


 Need extra time and effort for planning
 Not suitable for all types of problems
 OOP programs are generally larger and slower than normal programs

6
2.4 Structured Query Language (SQL)
The structured Query language (SQL) is the set of instructions used to interact with a
relational database. In fact, SQL is the only language the most database actually
understand. Whenever you interact with such a database, the software translates your
commands into SQL statement that the database knows how to interpret. SQL has
three major Components:

 Data Manipulation Language (DML


 Data Definition Language (DDL)
 Data Control Language (DCL)

7
CHAPTER - 3
ANALYSIS AND DESIGN

3.1 Analysis
Analysis is the process of determining user expectations for a software application. It
is really important as requirements are the basis for software design, development and
testing. Therefore this affects to the project cost. Requirements can be categorized
into two groups as functional requirements and non-functional requirements.
Functional requirements define functions or behaviors of the system while non-
functional requirements specify quality of the system. But before dig into the analysis,
it is also necessary to identify major components of the system with their interactions
and behaviors.

3.2 System Overview


Milk Inventory System consists of three major components, a database, “Milk
Inventory System” software, “Label Writer” application.
3.2.1 Database
Database is used to store information of customer profiles, and sale/purchase of
records. SQL Server is used as the DBMS for Milk Inventory System.
3.2.2 Milk Inventory System
Admin can access in application through the login. It is mainly for managing worker
profiles, handling sale/purchase data and registering equipment and Items detail. It
allows search functionality as well. Before using the application, admin has to enter as
a valid user name and password.
3.2.3 Label Writer Application
Label Writer application is a desktop application which is installed in administrator’s
computer. Administrator can search the customers and update customer’s data. How
much milk is purchased and how much milk is sold. This application has several
forms.

3.3 Design
Analysis phase focuses on doing the “right” thing while design phase focuses on
doing the “things” right. The aim of design phase is to map functional requirements to

8
hardware and software environment. In the design phase architecture is established
and modules, system components, interaction among components, objects, external
systems and interfaces are identified and defined. Hence successful completion of
design phase compromises transformation of all requirements into detailed
specifications.
During the design phase, following areas will be focused (H. P. Halvorson. 2014)
1) Application Architecture
2) Detailed Specification
3) System Interface Design
4) Finalize User Interface
5) Test Plans

3.4 Application Design


During application design, system architecture is defined and the class diagram is
documented for Milk Inventory System.
3.4.1 System Architectural
This desktop based application is based on 1-tier architecture of .Net Framework.
One Tier application also known as Standalone application. Figure 3.1 shows the
architecture diagram of Milk Inventory System using C# .Net.

Figure 3.1 One Tier Architecture of MIS

One tier architecture has all the layers such as Presentation, Business, and Data
Access layers in a single software package. Applications which handles all the three
tiers such as MP3 player, MS Office are come under one tier application. The data is
stored in the local system or a shared drive.

9
3.5 Feasibility Analysis
An analysis and evaluation of a proposed project to determine if it is
technically feasible, is feasible within the estimated cost, and will be
profitable. Feasibility studies are almost always conducted where large sums are at
stake. Also called feasibility analysis.
3.5.1 Economic Feasibility
The system is estimated to be economically affordable. The system is medium scale
desktop application and has affordable price. The benefits include increased
efficiency, effectiveness, and the better performance. Comparing the cost and benefits
the system is found to be economically feasible.
3.5.2 Technical Feasibility
Development of the system requires tools like:
 Visual Studio 2013
 .NET Framework 4.7.02046
 Microsoft SQL server 2012, etc.
3.5.3 Operational Feasibility
The system provides better solution to the libraries by adding the typical requirement
and necessities. The solution provided by this system will be acceptable to ultimate
solution for the stock management.

3.6 Process Flow Diagram


Process Flow Diagram or Flowchart is a diagram which uses geometric symbols and
arrows to define the relationships between different modules. It is a diagrammatic
representation of the algorithm. The Process flow Diagram of our application is
shown in figure 3.2

10
Customer
Entry

Figure 3.2 Process Flow Diagram of MIS

3.7 Use Case Diagram


It is used to represent a graphical overview of the functionality provided by a system
in terms of actors and their goals. The main purpose of a use case diagram is to show
what system functions are performed for which actors.

Figure 3.3 Use Case Diagram for Admin

11
Figure 3.4 Use Case Diagram for Seller

3.7.1 Diagram Building Block


1) Use cases
A use case describes a sequence of actions that provide something of measurable
value to an actor and is drawn as a horizontal ellipse.
2) Actor
An actor is a person, organization or external system that plays a role in one or more
interactions with the system
3) System boundary boxes (optional)
A rectangle is drawn around the use case called the system boundary box to indicate
scope of the system.

12
CHAPTER – 4
EXPERIMENTAL WORK

4.1 Visual Studio 2013


As per the task description, Milk Inventory System is implemented using Visual
Studio 2013. Visual Studio is a comprehensive collection of tools and services to help
developers to create a wide variety of apps, both for the Microsoft platform and
beyond (Microsoft, 2013 3). It was developed by Microsoft. Microsoft has released
several versions of Visual Studio as Visual Studio 2005, Visual Studio 2008, Visual
Studio 2010, Visual Studio 2012 and the latest version is Visual Studio 2013. It is also
available in several editions as Visual Studio Express, Visual Studio Professional and
Visual Studio Ultimate and is used to develop standalone applications, mobile
applications, web sites, web applications and web services. It supports different
programming languages such as C, C++, C#.net, and VB.net and F#. It also supports
XML/XSLT, HTML/XHTML, JavaScript and CSS.

4.2 Windows Forms


Sale/Purchase Equipment applications are implemented using Windows Forms
(WinForms). WinForms is the graphical application programming interface included
as a part of Microsoft Visual Studio. It can display data, handle user input and deploy
applications easily and with enhanced security. In Windows Forms, a form is a visual
surface which displays information to the user. A control is a user interface element
that displays data or accepts data input. A form can be enhanced with controls to
create the appropriate user interface while adding code to manipulate data. WinForms
contains variety of controls such as TextBoxes, Radio Buttons, Buttons,
ComboBoxes, GridViews, etc. It supports creating custom controls as well. It has rich
user interface components to interact with high end applications like Microsoft
Office.

13
4.3 Database Design Concepts
Database is a collection of logically related records (or data). It may consist of
enormous number of data. Hence it is really important to manage and organize data
within the database. Database Management Systems (DBMSs) are software
applications that use to interact with database and the user by giving capability of
managing data. It allows tagging, retrieving and manipulating data efficiently and
quickly while ensuring the security and unauthorized access. SQL Server is one of the
well-known DBMS used today.
4.3.1 Relational Database Model
The idea behind relational data model comes with organizing and storing data in
tables. Relations, attributes and domains are the three main key terms used in
relational database model. Tables of information is called relations, while attributes
refer to the columns of the table and the domain is the set of values the attributes are
allowed to take (Silberschatz, 2010 3). A database column can be defined as a primary
key or a foreign key. Primary key is used to identify unique records while foreign key
field describes some relationships between tables. One-to-one relationships associate
one record in one table with a single record in the other table. One-to-many
relationships associate one record in one table with many records in the other table.
Figure 4.1 and Figure 4.2 show an example of a table design and a table structure
respectively. It is always a good practice to reduce data redundancy (repetition of
data) when designing tables to enhance the efficiency of the database.

Primary key column

Columns Data type of column

Figure 4.1 Table Design of SQL Database

14
Column

Data
Figure 4.2 Structure of SQL Database table

4.3.2 Database Diagram


Database design diagram is a graphical representation of set of entities (tables) and
their relationships among each other. Before designing the database diagram, it is
necessary to understand the requirements, make assumptions, and identify the entities,
attributes, data types, limitations and their relationships. Software applications like
SQL server, Microsoft Visio and ERWin provide easy and user friendly design
package for drawing database diagrams.
ERWin
ERWin is a software application for designing databases and it is used to design
database diagram of MIS using C# .Net

Figure 4.3 Features of ERWin [Platinum Technology (1998–1999)]

15
It provides a collaborative data modeling environment to manage enterprise data
through an intuitive, graphical interface. Figure 4.3 shows supported features of
ERWin.

4.4 SQL Server 2012


SQL Server which is developed by Microsoft is the most popular DBMS today.
Microsoft has released several versions of SQL Server as SQL Server 2005, SQL
Server 2008, SQL Server 2012 and etc. Its main functionality is storing and retrieving
data in a secure manner as requested by other applications. T-SQL is the proprietary
query language in SQL Server. Microsoft has released several SQL Server editions
targeting different user groups such as Web, Express, Enterprise and Standard.
4.4.1 Data Retrieval and Manipulation in SQL Server
In a database, data is stored as a collection of tables with typed columns. SQL Server
supports different data types such as Integer, Float, Decimal, Char (including
character strings), Varchar (variable length character strings), binary, Text and etc. It
supports user defined composite types as well. Queries are used for data retrieval
operations. The standard SQL commands such as SELECT, INSERT, UPDATE and
DELETE are used for basic data manipulation operations. SELECT statement
retrieves data from one or more tables. INSERT adds rows to an existing table while
UPDATE modifies existing rows in a table. DELETE statement removes existing
rows from the tables.
SQL Server also allows stored procedures to be defined. A stored procedure is a group
of SQL statements that form a logical unit and perform a particular task, and they are
used to encapsulate a set of operations or queries to execute on a database server.
Stored procedures are more quick and efficient than queries as they are compiled once
and stored in executable form. Hence it requires low memory requirements. Stored
procedures improves scalability (increase scalability by isolating application
processing on the server), maintainability (can reuse in different applications) and
security (users can be granted permission to execute a stored procedure even if they
do not have permission to execute the procedure's statements directly. Other than that
it reduces network traffic with single call execution.

16
4.4.2 Concurrency and Locking
Concurrency refers to allowing multiple users to use same database simultaneously
while ensuring data integrity when accessing shared data (for example when several
users update same data or try to read data that is in the process of being changed by
another user). It is one of the main feature that differentiate database from other data
sources like spreadsheets. SQL Server provides two modes of concurrency control as
pessimistic concurrency and optimistic concurrency. Pessimistic concurrency is
controlling concurrent access by using locks. Optimistic concurrency control
mechanism allows a new version of a row to be created whenever the row is updated,
as opposed to overwriting the row.
4.4.3 SQL Server Management Studio
SQL Server Management Studio is a GUI tool included with SQL Server 2005 and
later for configuring, managing, and administering all components within Microsoft
SQL Server. It includes both script editors and graphical tools that work with objects
and features of the SQL server (Microsoft. 2013 4).

4.5 .NET Framework 4.7


The .NET Framework is a development platform for building apps for Windows,
Windows Phone, Windows Server, and Microsoft Azure. It consists of the common
language runtime (CLR) and the .NET Framework class library, which includes
classes, interfaces, and value types that support an extensive range of technologies.
The .NET Framework provides a managed execution environment, simplified
development and deployment, and integration with a variety of programming
languages, including Visual Basic and Visual C#.
4.5.1 .NET Framework Structure
The .Net architecture is basically segregated in to three layers namely top, middle and
bottom layer. The bottom layer is CLR, it is the heart of .NET Framework which
provides the runtime environment in which programs are executed. The middle layer
comprises the next generation of standard system services are brought under the
control of the framework, making them universally available and standardizing their
usage across languages. The top layer includes user and program interfaces as Figure
4.4 shows:

17
Figure 4.4 .Net Framework Architecture

4.6 Technology Used


4.6.1 JIT compilation
The .NET Framework contains one or more JIT compilers that compile IL code down
to machine code. This is done when the application is executed for the first time.
4.6.2 The .NET Language
To be part of the .NET Framework, a language only has to follow certain rules. The
biggest and most important rule for inclusion is that the language needs to be an
Object-oriented language. Microsoft provides four language with the .NET
Framework:
 Visual Basic .NET
 C#
 C++.NET and
 Jscript .NET.

18
4.6.3 Connection Object
The Connection Object connect to the specified Data Source and open a connection
between the C# application and the Data Source, depends on the parameter specified
in the Connection String. When the connection is established, SQL Commands will
execute with the help of the Connection Object and retrieve or manipulate data in the
Data Source.
4.6.4 The command Object
The Command Object requires an instance of a C# Connection Object for executing
the SQL statements. In order to retrieve a result set or execute an SQL statement
against a Data Source, first you have to create a Connection Object and open a
connection to the Data Source specified in the connection string.
4.6.5 Team Foundation Server
Team Foundation Server (commonly abbreviated to TFS) is a Microsoft product that
provides source code management (either with Team Foundation Version Control or
Git), reporting, requirements management, project management (for both agile
software development and waterfall teams), automated builds, and lab management.

4.7 Source Code Control


TFS is used to manage source code of Milk Inventory System. The folder structure in
TFS as shown in Figure 4.5. Database scripts, stored procedures and views

Figure 4.5 Folder Structure in TFS

19
are checked in to “Database” folder. The source code of Milk Inventory System is
available in “Code/Application” folder.

4.8 Best Coding Practices


During the implementation phase of Milk Inventory System, several coding practices
have been used to maximize the code readability. Proper naming conventions have
been used throughout the implementation process with meaningful names. For
example, function names or class names always start with a capital latter, while
variable names start with a simple letter (the class name to handle customer operations
would be “Customer” while a variable name to save customer name would be
“name”). Other than proper naming conventions, commenting and exception handling
can also be considered as best coding practices.
4.8.1 Commenting
During the implementation process of Milk Inventory System, code comments have
been written for functions, classes and logics. Commenting describes the purpose of a
code block. Proper use of commenting improves maintenance and readability of
source code and helps to find bugs faster.
4.8.2 Exception Handling
Exception handling is a mechanism to detect and handle run time errors. During the
implementation process of Lab Inventory System, “try” and “catch” blocks are used to
handle exceptions as shown in Figure 4.6.

try
{
frmchangePassWrd cp = new frmchangePassWrd();
this.Hide();
cp.Show(); ;
}
catch (Exception x)
{
MessageBox.Show(x.Message);

Figure 4.6 Exception handling using "try" and "catch"

20
4.9 Testing
Testing is the process of executing a software system to determine whether it matches
its specification or meets its expected results. It is a very effective way to show the
presence of bugs (errors, faults or failures in the software system) and understand the
risk of software implementation. Hence it is a process of validating and verifying
software application. Typical goals of testing are:

 Check if critical functionalities work


 It helps to determine what is most important to end users
 Improve reliability and maintainability of the software application
 Ensure better quality software application

To achieve a reliable and perfect software system, testing is really important as it


assesses the quality of the application.

4.10 Project Screenshots

4.10.1 Login Form

When users run this application a Login Form is open.

Figure 4.7 Admin or Login Form

21
4.10.2 Main Form

After the user login form when the user enter correct user id and password then their is a
main menu form is opened.

Figure 4.8 Main Form

4.10.3 Customer Form

After click on the new user registration button on main form a new form is appear.

Figure 4.9 Customer Form

22
4.10.4 Purchase Form

After click on the customer registration button on main form a new form is appear. On this
form new customers can be register by user.

Figure 4.10 Purchase Form

23
4.10.5 Sales Record Form

After click on the update customer data button on main form a new form is appear. On this
form customer’s records are updated by user.

Figure 4.11 Sales Record Form

4.10.6 Report Form

After click on the statistics button on main form a new form is appear. On this form the user
can get all records of different customers of different categories.

Figure 4.12 Report Form

24
4.10.7 Expense Report Form

After click on the find button on new form is appear. On this form customer record is finding
by user.

Figure 4.13 Expense Report Form

4.10.8 Delete User Account Form

After click on the delete button on main form a new form is appear. On this form the record
of any customer can be deleted by user.

Figure 4.14 Delete User Account Form

25
CHAPTER – 5
Results and Discussion, Conclusion and Future work

5.1 Results and Discussion


Hard working comes to the good results. The most part of the project is done right
now. The thesis paper and theory researches are also done. Now I am starting to
thinking about the achievement of the thesis topic and project.
The milk inventory system is a desktop application, which will be help us to handle
the business for our ease about the milk. The report explains the design and
implementation of Milk Inventory System in detail. Whole system was implemented
using Visual Studio 2013, SQL Server was used for database design according to the
task description. Therefore the theories and concepts behind programming and
database design were studied beforehand with Visual Studio, SQL Server and their
tools. When open the project there will show a login form in which we enter the user
name and password then this form will be open. After the login there will be a form
which is named as main form. The main form includes the different menus such as
purchase form, customer form, crystal report and expenses form etc. Here the login
page is created to protect records in order to prevent it from the threat and misuse of
the system. Without user name and password no one can access in windows
application and also given change user name and password option at the bottom of the
login page through this admin secure his system from misusers.
In purchase form, if we want to add a new supplier then his id, phone number,
address, one kg price, total payment, due payment, and weight are our requirements.
And same these requirements are required for the sale form.

When open the customer form, if we want to add any new customer we have required
his id, phone number, name, address and city. Also we can delete and update the data
about the customer when we want. In the expenses form we can know about the total
expenses. We can know about our daily expenses, weekly expenses and monthly
expenses. We can also search the expenses of any customer by giving the required
date of expenses. We can search the any customer by his id and name. We can get the
report of any customer by giving the customer name and required date, also can get
the monthly report of the customers.

26
We have design it by using the C# language and different tools such as visual studio,
frame work 4.2 and devexpress etc. C# is an object oriented programming language.
Visual studio is a software development platform written in C#. The Visual studio
platform allows applications to be developed from a set of modular software
components called modules. Applications based on the Visual studio platform,
including the frame work integrated development environment. The Visual studio also
supports other languages, in particular PHP, C/C+

5.2 Conclusion
By the grace of Allah Almighty our project has completed and now we can use it. The
report explains the design and implementation in detail. Project is a desktop
application named as Milk Inventory System. This desktop application has many
features. By using this application we can save our time. We can save all the data of
customers and suppliers permanently if we want.
This application is very easy and simple to use. First page is login, after the login page
there will be show a menu bar page, and we can select any form which is our need.
This application also provides a simple report on daily basis to know the daily sales
and purchases details. Whole system was implemented using Visual Studio 2013, SQL
Server was used for database design according to the task description. Therefore the
theories and concepts behind programming and database design was studied
beforehand Visual with Studio, SQL Server and their tools.
The aim of this application/project is to providing the awareness to the milk company
owners and also all the records can be saved and checked correctly. They have to
maintain various records daily, manually which involves about borrower’s reports,
payment sheets and many more. To overcome this problem we have design a
computer based “Milk Inventory System” by which we can solve all these problems
easily and correctly.

5.3 Future Enhancements

Since this project was started with very little knowledge about the Milk Inventory
System, we came to know about the enhancement capability during the process of
building it. In Future, we will try to make it more and better. We want to make this

27
application more powerful and will have wished to make it an advanced application.
A main problem which is in our mind that there is not any system which tells us the
the expiry date of the dairy milk, mean we want to make a such system that tells us
that milk has rancid, in simple words tells us expiry date of milk. Some of the scope
we can increase for the betterment and effectiveness are listed below:
Interactive user interface design.
 Use of Oracle as its database.
 Online payment system can be added.
 Making the system flexible in any type.
 Sales and purchase return system will be added in order to make return of
product.
 Lost and breakage.
 This desktop application is able to generate only simple reports.
 In future, I can further enhance this project by assigning right creating
multiple admins.

28
REFERENCES

Encapsulation (1995). Available: http://faculty.orangecoastcollege.edu/sgilbert/book/ 11-3-


Encapsulation/index.html

H. P. Halvorson. (2014). the Software Development Process. Available:


http://home.hit.no/~hansha/documents/software/software_development/topics/resources/SD
LC%20Overview.pdf

Microsoft. (2013). Visual Studio 2013; Available:


http://www.visualstudio.microsoft.com/vs/ older-downloads

Microsoft. (2013). Object-Oriented Programming (C# and Visual Basic). Available:


http://msdn.microsoft.com/en-us/library/dd460654.aspx#Classes

Microsoft. (2013). Use SQL Server Management Studio. Available:


http://msdn.microsoft.com/en-us/library/ms174173.aspx

Microsoft. (2013). UML Use Case Diagrams: Guidelines. Available:


http://msdn.microsoft.com/en-us/library/dd409432.aspx

Microsoft. (2013). Net Framework: Guidelines Available:


https://en.wikipedia.org/wiki/.NET_Framework

Microsoft. (2013). Use Case Diagram for Admin: Guideline Available:


https://docs.microsoft.com/en-us/visualstudio/modeling/uml-sequence-diagrams-
guidelines?view=vs-2015

Microsoft. (2013). Use Case Diagram for Seller: Guideline Available:


https://docs.microsoft.com/en-us/visualstudio/modeling/create-uml-modeling-projects-
and-diagrams?view=vs-2017

Silberschatz, A., Korth, H. F., & Sudarshan, S. (1997). Database system concepts (Vol. 4).
New York: McGraw-Hill.

29
APPENDIX

SOURCE CODE
1) Code Structure
Milk Inventory System is developed in Visual Studio 2013 following the one tier
application architecture. It provided code editor and the solution explorer where code
files are kept. A source code editor is a text editor program designed specifically for
editing source code of computer programs by programmers. It may be a standalone
application or it may be built into an integrated development environment (IDE) or
web browser.
2) Logic
Logic is the main component of any application developed through the script. Every
module of the application includes logic. Most of the logic are common and
understandable as we call 1-tier architecture based system.

LogIn Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;

namespace frmlogin
{
public partial class frmlogin : DevExpress.XtraEditors.XtraForm
{
public frmlogin()
{
InitializeComponent();
}
SqlConnection con;
SqlCommand com;

30
private void simpleButton1_Click(object sender, EventArgs e)
{
con = new SqlConnection(DBhelper.connectionstring());
com = new SqlCommand();
con.Open();
com.Connection = con;
com.CommandText = "select User_Name,password from login where User_Name='"
+ txtname.Text + "' and password='" + txtpassword.Text + "'";
SqlDataReader rdr = com.ExecuteReader();
if (rdr.Read())
{

frmmain f = new frmmain();


f.Show();
this.Hide();
}
else
{

MessageBox.Show("Invailed User Name And Password");


txtname.Text = "";
txtpassword.Text = "";
txtname.Focus();
return;

}
}

private void label4_Click(object sender, EventArgs e)


{
this.Hide();
frmforgetname f = new frmforgetname();
f.Show();
}

private void label3_Click(object sender, EventArgs e)


{
this.Hide();
frmforgetpassword f = new frmforgetpassword();
f.Show();
}

private void simpleButton2_Click(object sender, EventArgs e)


{
Application.Exit();
}

private void frmlogin_Load(object sender, EventArgs e)


{

private void txtname_TextChanged(object sender, EventArgs e)


{

}
}

31
Main Form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace frmlogin
{
public partial class frmmain : DevExpress.XtraEditors.XtraForm
{
public frmmain()
{
InitializeComponent();
}

private void frmmain_FormClosing(object sender, FormClosingEventArgs e)


{
Application.Exit();
}
frmpurchase f;
private void purchaseToolStripMenuItem_Click(object sender, EventArgs e)
{
if (f==null)
{
f=new frmpurchase();
f.MdiParent = this;
f.FormClosing += new FormClosingEventHandler(closepurchase);

f.Show();
}
f.Focus();
}

private void closepurchase(object sender, FormClosingEventArgs e)


{
f=null;
}
frmSale s;
private void saleToolStripMenuItem_Click(object sender, EventArgs e)
{
if (s == null)
{
s = new frmSale();
s.MdiParent = this;
s.FormClosing += new FormClosingEventHandler(closes);

s.Show();
}
s.Focus();

private void closes(object sender, FormClosingEventArgs e)


{

32
s=null;
}
frmExpenses exp;
private void expensesToolStripMenuItem_Click(object sender, EventArgs e)
{
if (exp == null)
{
exp = new frmExpenses();
exp.MdiParent = this;
exp.FormClosing += new FormClosingEventHandler(closeExp);

exp.Show();
}
exp.Focus();
}

private void closeExp(object sender, FormClosingEventArgs e)


{
exp=null;
}
frmCustomer c;
private void customerToolStripMenuItem_Click(object sender, EventArgs e)
{
if (c==null)
{
c = new frmCustomer();
c.MdiParent = this;
c.FormClosing += new FormClosingEventHandler(Cclose);
c.Show();
}
c.Focus();
}

private void Cclose(object sender, FormClosingEventArgs e)


{
c=null;
}
frmReportSelect r;
private void monthReportToolStripMenuItem_Click(object sender, EventArgs e)
{
if (r==null)
{
r = new frmReportSelect();
r.FormClosing += new FormClosingEventHandler(cc);
r.Show();
}

r.Focus();

private void cc(object sender, FormClosingEventArgs e)


{
r=null;
}

private void poweredByToolStripMenuItem_Click(object sender, EventArgs e)


{
frmPoweredBy f = new frmPoweredBy();
f.ShowDialog();
}

33
private void frmmain_Load(object sender, EventArgs e)
{

}
}
}

Purchase Form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.SqlClient;
using System.Diagnostics;
namespace frmlogin
{
public partial class frmpurchase : DevExpress.XtraEditors.XtraForm
{
public frmpurchase()
{
InitializeComponent();
}

SqlConnection con;
SqlCommand com;
int x;
private void getNextcodePurchase()
{

try
{
con = new SqlConnection(DBhelper.connectionstring());
com = new SqlCommand();
con.Open();
com.Connection = con;
com.CommandText = "SELECT max(id)+1 FROM purchase";
com.ExecuteScalar();
x = Convert.ToInt32(com.ExecuteScalar());
txtid.Text = x.ToString();
}
catch (Exception)
{
if (x == 0)
{
x++;
txtid.Text = x.ToString();
}

34
}
private void resetpurchase()
{
txtid.Text = "";
txtName.Text = "";
txtMobileNo.Text = "";
// txtPricePerKG.Text = "";
txtTotalprice.Text = string.Empty;
txtweight.Text = "";
txtpayment.Text = "";
txtDuepayment.Text = "";
txtdate.Text = DateTime.Today.ToString();
getNextcodePurchase();
}
DataTable dt;
private void getalldataPurchase()
{
try
{
con = new SqlConnection(DBhelper.connectionstring());
com = new SqlCommand();
con.Open();
com.Connection = con;
com.CommandText = "SELECT * FROM purchase";
SqlDataAdapter da = new SqlDataAdapter(com);
dt = new DataTable();
da.Fill(dt);
dgvPurchase.DataSource = dt;
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void showlookup()
{
con = new SqlConnection(DBhelper.connectionstring());
com = new SqlCommand();
con.Open();
com.Connection = con;
string query = "select * from purchase order by name asc";

com.CommandText = query;

SqlDataReader rs = com.ExecuteReader();

DataTable dt = new DataTable();


dt.Columns.Add("id");
dt.Columns.Add("name");

while (rs.Read())
{

DataRow dr = dt.NewRow();

dr[0] = rs["id"].ToString();
dr[1] = rs["name"].ToString();

35
dt.Rows.Add(dr);
}
con.Close();

txtCustomerName.Properties.DisplayMember = "name";
txtCustomerName.Properties.ValueMember = "name";
txtCustomerName.Properties.NullText = "Select Customer Name";
txtCustomerName.Properties.DataSource = dt;
}
private void frmpurchase_Load(object sender, EventArgs e)
{

resetpurchase();
getNextcodePurchase();
getalldataPurchase();
dgvFontAndColors();
showlookup();

private void btnnew_Click(object sender, EventArgs e)


{
resetpurchase();
getNextcodePurchase();
getalldataPurchase();
btnSave.Enabled = true;
btnUpdate.Enabled = false;
btnDelete.Enabled = false;
}

private void btnSave_Click(object sender, EventArgs e)


{
if (txtid.Text != "" && txtName.Text != "" && txtPricePerKG.Text != "" &&
txtweight.Text != "" && txtTotalprice.Text != "")
{
con = new SqlConnection();
com = new SqlCommand();
con.ConnectionString = DBhelper.connectionstring();
con.Open();
com.Connection = con;
com.CommandText = "INSERT into purchase values(" + txtid.Text + ",'" +
txtName.Text + "','" + txtMobileNo.Text + "'," + txtPricePerKG.Text + "," +
txtweight.Text + "," + txtTotalprice.Text + "," + txtpayment.Text + "," +
txtDuepayment.Text + ",'" + txtdate.Value + "')";
com.ExecuteNonQuery();

MessageBox.Show("Data Save");

resetpurchase();
getNextcodePurchase();
getalldataPurchase();
con.Close();
}
else
{
MessageBox.Show("Full Fill All Requirements");
return;
}

36
private void txtweight_TextChanged(object sender, EventArgs e)
{
double val1 = 0;
double val2 = 0;
double.TryParse(txtPricePerKG.Text, out val1);
double.TryParse(txtweight.Text, out val2);
double I = (val1 * val2);
txtTotalprice.Text = I.ToString();
payment();
}

private void txtPricePerKG_KeyPress(object sender, KeyPressEventArgs e)


{

private void btnDelete_Click(object sender, EventArgs e)


{
DialogResult result = MessageBox.Show("Are you sure ", "Delete?",
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
try
{
con = new SqlConnection(DBhelper.connectionstring());
com = new SqlCommand();
con.Open();
com.Connection = con;
com.CommandText = "DELETE FROM purchase WHERE id=" + txtid.Text +
"";
com.ExecuteScalar();
MessageBox.Show("Data Delete Successfully!");
resetpurchase();
getNextcodePurchase();
getalldataPurchase();
con.Close();
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);
}
resetpurchase();
getNextcodePurchase();
getalldataPurchase();
btnSave.Enabled = true;
btnUpdate.Enabled = false;
btnDelete.Enabled = false;

}
}

private void btnUpdate_Click(object sender, EventArgs e)


{
if (txtid.Text != "" && txtpayment.Text != "" && txtTotalprice.Text != "")
{
try
{
con = new SqlConnection(DBhelper.connectionstring());
com = new SqlCommand();
con.Open();
com.Connection = con;

37
com.CommandText = "UPDATE purchase SET name='" + txtName.Text +
"',mobile_no='" + txtMobileNo.Text + "',Price_Per_KG=" + txtPricePerKG.Text +
",Weight=" + txtweight.Text + ",Total_Price=" + txtTotalprice.Text + ",payment=" +
txtpayment.Text + ",Due_payment=" + txtDuepayment.Text + ",[Current_date]='" +
txtdate.Value + "' where id=" + txtid.Text + "";
com.ExecuteNonQuery();
MessageBox.Show("Data UpDate");
resetpurchase();
getalldataPurchase();
getNextcodePurchase();
btnSave.Enabled = true;
btnUpdate.Enabled = false;
btnDelete.Enabled = false;
con.Close();
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);
}
resetpurchase();
getNextcodePurchase();
getalldataPurchase();

}
else
{
MessageBox.Show("Full Fill All Requirements");
}

private void dgvPurchase_CellContentClick(object sender,


DataGridViewCellEventArgs e)
{

}
private void dgvFontAndColors()
{
this.dgvPurchase.DefaultCellStyle.Font = new Font("Tahoma", 9);
this.dgvPurchase.DefaultCellStyle.ForeColor = Color.Black;
this.dgvPurchase.ColumnHeadersDefaultCellStyle.Font = new Font("Tahoma",
10);
this.dgvPurchase.DefaultCellStyle.BackColor = Color.WhiteSmoke;
this.dgvPurchase.DefaultCellStyle.SelectionForeColor = Color.Yellow;
this.dgvPurchase.DefaultCellStyle.SelectionBackColor = Color.Black;
}

private void dgvPurchase_CellDoubleClick(object sender,


DataGridViewCellEventArgs e)
{
txtid.Text = dgvPurchase.CurrentRow.Cells[0].Value.ToString();
txtName.Text = dgvPurchase.CurrentRow.Cells[1].Value.ToString();
txtMobileNo.Text = dgvPurchase.CurrentRow.Cells[2].Value.ToString();

txtPricePerKG.Text = dgvPurchase.CurrentRow.Cells[3].Value.ToString();
txtweight.Text = dgvPurchase.CurrentRow.Cells[4].Value.ToString();
txtTotalprice.Text = dgvPurchase.CurrentRow.Cells[5].Value.ToString();
txtpayment.Text = dgvPurchase.CurrentRow.Cells[6].Value.ToString();
txtDuepayment.Text = dgvPurchase.CurrentRow.Cells[7].Value.ToString();
btnSave.Enabled = false;
btnUpdate.Enabled = true;

38
btnDelete.Enabled = true;
}

private void txtPricePerKG_TextChanged(object sender, EventArgs e)


{
double val1 = 0;
double val2 = 0;
double.TryParse(txtPricePerKG.Text, out val1);
double.TryParse(txtweight.Text, out val2);
double I = (val1 * val2);
txtTotalprice.Text = I.ToString();
payment();
}

public void txtPricePerKG_KeyPress_1(object sender, KeyPressEventArgs e)


{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar !
= '.'))
{
e.Handled = true;
}
if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
{
e.Handled = true;
}
}

private void dgvPurchase_CellContentClick_1(object sender,


DataGridViewCellEventArgs e)
{

}
DataView dv;

private void txtIDsearch_TextChanged(object sender, EventArgs e)


{
try
{

if (txtIdsearch.Text != "")
{
dv = new DataView(dt);
dv.RowFilter ="id="+txtIdsearch.Text+"";
dgvPurchase.DataSource = dv;
}
else
{
dgvPurchase.DataSource = dt;
}
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);
}
}

private void txtnameSearch_TextChanged(object sender, EventArgs e)


{
try
{

39
if (txtnameSearch.Text != "")
{
dv = new DataView(dt);
dv.RowFilter = string.Format("name LIKE '%{0}%'",
txtnameSearch.Text);
dgvPurchase.DataSource = dv;
}
else
{
dgvPurchase.DataSource = dt;
}
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);
}
}

private void txtIDsearch_KeyPress(object sender, KeyPressEventArgs e)


{

private void btngetdatedata_Click(object sender, EventArgs e)


{
resetpurchase();
if (txtCustomerName.Text != "Select Customer Name")
{
try
{
con = new SqlConnection(DBhelper.connectionstring());
com = new SqlCommand();
con.Open();
com.Connection = con;
com.CommandText = "select * from purchase where name='" +
txtCustomerName.Text + "' and [Current_date]>='" + this.txtdateFrom.Text + "' and
[Current_date]<='" + this.txtdateTO.Text + "'";
com.ExecuteNonQuery();
dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(com);
da.Fill(dt);
dgvPurchase.DataSource = dt;

Int64 sum = 0;
Int64 sum1 = 0;
Int64 sum2 = 0;
foreach (DataGridViewRow re in this.dgvPurchase.Rows)
{
Int64 a = Convert.ToInt64(re.Cells[5].Value);
Int64 b = Convert.ToInt64(re.Cells[6].Value);
Int64 c = Convert.ToInt64(re.Cells[7].Value);

sum = sum + a;
sum1 = sum1 + b;
sum2 = sum2 + c;
}
txtTotalprice.Text = sum.ToString();
txtpayment.Text = sum1.ToString();
txtDuepayment.Text = sum2.ToString();

btnSave.Enabled = false;

40
btnUpdate.Enabled = true;
con.Close();
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);
}
}
else
{
MessageBox.Show("Please Select Customer Name,Then Try Again!");
return;
}
}

private void txtpayment_TextChanged(object sender, EventArgs e)


{

payment();

}
private void payment()
{
try
{
double val1 = 0;
double val2 = 0;
double val3 = 0;
double.TryParse(txtTotalprice.Text, out val3);
double.TryParse(txtpayment.Text, out val1);
double.TryParse(txtDuepayment.Text, out val2);
if (val1 != 0)
{
if (val3 != 0)
{
if (val1 > val3)
{
MessageBox.Show("Payment Amount is Greater than Total
Amount", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtpayment.Text = "";
txtpayment.Focus();
return;
}
else
{
txtDuepayment.Text = (val3 - val1).ToString();
}

}
else
{
// MessageBox.Show("Total Amount is empty ", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
int a = 0;
if (txtTotalprice.Text == "" || txtTotalprice.Text ==
a.ToString())
{
txtpayment.Text = string.Empty;
txtDuepayment.Text = string.Empty;
}
return;

41
}

}
else
{
txtDuepayment.Text = val3.ToString();
}
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);
}

private void btnresetdate_Click(object sender, EventArgs e)


{
dgvPurchase.DataSource = null;
txtTotalprice.Text = "";
txtDuepayment.Text = "";
txtpayment.Text = "";

txtCustomerName.Text = string.Empty;
getalldataPurchase();
getNextcodePurchase();
resetpurchase();
}

private void deleteToolStripMenuItem_Click(object sender, EventArgs e)


{
try
{
SqlConnection con = new SqlConnection(DBhelper.connectionstring());
SqlCommand com = new SqlCommand();
int i = 0;
if (dgvPurchase.Rows.Count > 0)
{
con.Open();
com.Connection = con;
com.CommandText = "DELETE FROM purchase WHERE id=" +
dgvPurchase.SelectedRows[i].Cells[0].Value.ToString() + "";

com.ExecuteNonQuery();

dgvPurchase.Rows.RemoveAt(dgvPurchase.SelectedRows[i].Index);
resetpurchase();
getNextcodePurchase();
getalldataPurchase();
// MessageBox.Show("Row Deleted");
con.Close();
}

42
catch (Exception ex)
{

MessageBox.Show(ex.Message);
}
}

private void linkLabel1_LinkClicked(object sender,


LinkLabelLinkClickedEventArgs e)
{
Process.Start("http://maxdigital.biz");

private void label15_Click(object sender, EventArgs e)


{
Process.Start("http://maxdigital.biz");
}

private void txtCustomerName_EditValueChanged(object sender, EventArgs e)


{

}
}

Sales Form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;

using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace frmlogin
{
public partial class frmmain : DevExpress.XtraEditors.XtraForm
{
public frmmain()
{
InitializeComponent();
}

private void frmmain_FormClosing(object sender, FormClosingEventArgs e)


{
Application.Exit();
}
frmpurchase f;
private void purchaseToolStripMenuItem_Click(object sender, EventArgs e)
{

43
if (f==null)
{
f=new frmpurchase();
f.MdiParent = this;
f.FormClosing += new FormClosingEventHandler(closepurchase);

f.Show();
}
f.Focus();
}

private void closepurchase(object sender, FormClosingEventArgs e)


{
f=null;
}
frmSale s;
private void saleToolStripMenuItem_Click(object sender, EventArgs e)
{
if (s == null)
{
s = new frmSale();
s.MdiParent = this;
s.FormClosing += new FormClosingEventHandler(closes);

s.Show();
}
s.Focus();

private void closes(object sender, FormClosingEventArgs e)


{
s=null;
}
frmExpenses exp;
private void expensesToolStripMenuItem_Click(object sender, EventArgs e)
{
if (exp == null)
{
exp = new frmExpenses();
exp.MdiParent = this;
exp.FormClosing += new FormClosingEventHandler(closeExp);

exp.Show();
}
exp.Focus();
}

private void closeExp(object sender, FormClosingEventArgs e)


{
exp=null;
}
frmCustomer c;
private void customerToolStripMenuItem_Click(object sender, EventArgs e)
{
if (c==null)
{
c = new frmCustomer();
c.MdiParent = this;
c.FormClosing += new FormClosingEventHandler(Cclose);
c.Show();
}

44
c.Focus();
}

private void Cclose(object sender, FormClosingEventArgs e)


{
c=null;
}
frmReportSelect r;
private void monthReportToolStripMenuItem_Click(object sender, EventArgs e)
{
if (r==null)
{
r = new frmReportSelect();
r.FormClosing += new FormClosingEventHandler(cc);
r.Show();
}

r.Focus();

private void cc(object sender, FormClosingEventArgs e)


{
r=null;
}

private void poweredByToolStripMenuItem_Click(object sender, EventArgs e)


{
frmPoweredBy f = new frmPoweredBy();
f.ShowDialog();
}

private void frmmain_Load(object sender, EventArgs e)


{

}
}
}

Expense Form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;

using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace frmlogin
{
public partial class frmmain : DevExpress.XtraEditors.XtraForm
{
public frmmain()
{
InitializeComponent();

45
}

private void frmmain_FormClosing(object sender, FormClosingEventArgs e)


{
Application.Exit();
}
frmpurchase f;
private void purchaseToolStripMenuItem_Click(object sender, EventArgs e)
{
if (f==null)
{
f=new frmpurchase();
f.MdiParent = this;
f.FormClosing += new FormClosingEventHandler(closepurchase);

f.Show();
}
f.Focus();
}

private void closepurchase(object sender, FormClosingEventArgs e)


{
f=null;
}
frmSale s;
private void saleToolStripMenuItem_Click(object sender, EventArgs e)
{
if (s == null)
{
s = new frmSale();
s.MdiParent = this;
s.FormClosing += new FormClosingEventHandler(closes);

s.Show();
}
s.Focus();

private void closes(object sender, FormClosingEventArgs e)


{
s=null;
}
frmExpenses exp;
private void expensesToolStripMenuItem_Click(object sender, EventArgs e)
{
if (exp == null)
{
exp = new frmExpenses();
exp.MdiParent = this;
exp.FormClosing += new FormClosingEventHandler(closeExp);

exp.Show();
}
exp.Focus();
}

private void closeExp(object sender, FormClosingEventArgs e)


{
exp=null;
}
frmCustomer c;

46
private void customerToolStripMenuItem_Click(object sender, EventArgs e)
{
if (c==null)
{
c = new frmCustomer();
c.MdiParent = this;
c.FormClosing += new FormClosingEventHandler(Cclose);
c.Show();
}
c.Focus();
}

private void Cclose(object sender, FormClosingEventArgs e)


{
c=null;
}
frmReportSelect r;
private void monthReportToolStripMenuItem_Click(object sender, EventArgs e)
{
if (r==null)
{
r = new frmReportSelect();
r.FormClosing += new FormClosingEventHandler(cc);
r.Show();
}

r.Focus();

private void cc(object sender, FormClosingEventArgs e)


{
r=null;
}

private void poweredByToolStripMenuItem_Click(object sender, EventArgs e)


{
frmPoweredBy f = new frmPoweredBy();
f.ShowDialog();
}

private void frmmain_Load(object sender, EventArgs e)


{

}
}
}

Customer form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

47
using DevExpress.XtraEditors;

namespace frmlogin
{
public partial class frmmain : DevExpress.XtraEditors.XtraForm
{
public frmmain()
{
InitializeComponent();
}

private void frmmain_FormClosing(object sender, FormClosingEventArgs e)


{
Application.Exit();
}
frmpurchase f;
private void purchaseToolStripMenuItem_Click(object sender, EventArgs e)
{
if (f==null)
{
f=new frmpurchase();
f.MdiParent = this;
f.FormClosing += new FormClosingEventHandler(closepurchase);

f.Show();
}
f.Focus();
}

private void closepurchase(object sender, FormClosingEventArgs e)


{
f=null;
}
frmSale s;
private void saleToolStripMenuItem_Click(object sender, EventArgs e)
{
if (s == null)
{
s = new frmSale();
s.MdiParent = this;
s.FormClosing += new FormClosingEventHandler(closes);

s.Show();
}
s.Focus();

private void closes(object sender, FormClosingEventArgs e)


{
s=null;
}
frmExpenses exp;
private void expensesToolStripMenuItem_Click(object sender, EventArgs e)
{
if (exp == null)
{
exp = new frmExpenses();
exp.MdiParent = this;
exp.FormClosing += new FormClosingEventHandler(closeExp);

exp.Show();

48
}
exp.Focus();
}

private void closeExp(object sender, FormClosingEventArgs e)


{
exp=null;
}
frmCustomer c;
private void customerToolStripMenuItem_Click(object sender, EventArgs e)
{
if (c==null)
{
c = new frmCustomer();
c.MdiParent = this;
c.FormClosing += new FormClosingEventHandler(Cclose);
c.Show();
}
c.Focus();
}

private void Cclose(object sender, FormClosingEventArgs e)


{
c=null;
}
frmReportSelect r;
private void monthReportToolStripMenuItem_Click(object sender, EventArgs e)
{
if (r==null)
{
r = new frmReportSelect();
r.FormClosing += new FormClosingEventHandler(cc);
r.Show();
}

r.Focus();

private void cc(object sender, FormClosingEventArgs e)


{
r=null;
}

private void poweredByToolStripMenuItem_Click(object sender, EventArgs e)


{
frmPoweredBy f = new frmPoweredBy();
f.ShowDialog();
}

private void frmmain_Load(object sender, EventArgs e)


{

}
}
}

49
DB Helper

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Milk
{
class Db_helper
{
public static string connectionstring()
{
return "Data Source=DESKTOP-TQQNMIA;Initial Catalog=Milk;Integrated
Security=True";
}
SqlCommand cmd;
SqlConnection con = new SqlConnection(connectionstring());
public void insert(string Query)
{
con.Open();

cmd =new SqlCommand(Query,con);


cmd.ExecuteNonQuery();
con.Close();

MessageBox.Show("Record Saved Successfully");


}
}

50

Vous aimerez peut-être aussi