Académique Documents
Professionnel Documents
Culture Documents
BY
MUHAMMAD ATIF
&
UMAIR AHMAD
BACHELOR OF SCIENCE
IN
COMPUTER SCIENCE
JULY, 2018
NATIONAL COLLEGE OF BUSINESS
ADMINISTRATION & ECONOMICS
MULTAN
BY
MUHAMMAD ATIF
&
UMAIR AHMAD
BACHELOR OF SCIENCE
IN
COMPUTER SCIENCE
JULY, 2019
i
NATIONAL COLLEGE OF BUSINESS
ADMINISTRATION & ECONOMICS
MULTAN
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
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.
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.
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
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
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
xvi
LIST OF ABBREVIATIONS
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.
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:
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.
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:
1
Admin can be added as per the requirement.
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.
The main purpose of the Milk inventory system is to provide complete information about
customer record.
1) Whenever a customer came and he his permanent his daily data is saved and stored.
2
Login Form
Main Form
Suppler
Registration
Sale Record Statistics Find Record Crystal Report
Update Supplier
Record
1 Login Form
2 Main 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.
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
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.
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
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:
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.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
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.
10
Customer
Entry
11
Figure 3.4 Use Case Diagram for Seller
12
CHAPTER – 4
EXPERIMENTAL WORK
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.
14
Column
Data
Figure 4.2 Structure of SQL Database table
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.
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).
17
Figure 4.4 .Net Framework Architecture
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.
19
are checked in to “Database” folder. The source code of Milk Inventory System is
available in “Code/Application” folder.
try
{
frmchangePassWrd cp = new frmchangePassWrd();
this.Hide();
cp.Show(); ;
}
catch (Exception x)
{
MessageBox.Show(x.Message);
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:
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.
After click on the new user registration button on main form a new form is appear.
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.
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.
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.
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.
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.
25
CHAPTER – 5
Results and Discussion, Conclusion and Future work
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.
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
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())
{
}
}
}
}
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();
}
f.Show();
}
f.Focus();
}
s.Show();
}
s.Focus();
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();
}
r.Focus();
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();
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();
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();
}
MessageBox.Show(ex.Message);
}
resetpurchase();
getNextcodePurchase();
getalldataPurchase();
btnSave.Enabled = true;
btnUpdate.Enabled = false;
btnDelete.Enabled = false;
}
}
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 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;
}
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;
}
}
DataView dv;
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);
}
}
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);
}
}
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;
}
}
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);
}
txtCustomerName.Text = string.Empty;
getalldataPurchase();
getNextcodePurchase();
resetpurchase();
}
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);
}
}
}
}
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();
}
43
if (f==null)
{
f=new frmpurchase();
f.MdiParent = this;
f.FormClosing += new FormClosingEventHandler(closepurchase);
f.Show();
}
f.Focus();
}
s.Show();
}
s.Focus();
exp.Show();
}
exp.Focus();
}
44
c.Focus();
}
r.Focus();
}
}
}
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
}
f.Show();
}
f.Focus();
}
s.Show();
}
s.Focus();
exp.Show();
}
exp.Focus();
}
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();
}
r.Focus();
}
}
}
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();
}
f.Show();
}
f.Focus();
}
s.Show();
}
s.Focus();
exp.Show();
48
}
exp.Focus();
}
r.Focus();
}
}
}
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();
50