You are on page 1of 55

BUILDING AN BILLING SOFTWARE

A PROJECT REPORT
Submitted by

CHINNAKARRUPUSAMY G (22500226)

AJISH U (22500221)

AKSHATHA K (22500222)

SANDEEP KUMAR J (22500263)

In partial fulfillment for the award


of
DIPLOMA
IN
COMPUTER ENGINEERING

GOVERNMENT POLYTECHNIC COLLEGE


COIMBATORE–641 014

DIRECTORATE OF TECHNICAL EDUCATION


CHENNAI–600025
APRIL-2024
BONAFIDE CERTIFICATE

Certified that this project report titled “BUILDING AN BILLING


SOFTWARE” is the bonafide work of CHINNAKARRUPUSAMY G
(22500226), AJISH U (22500221), AKSHATHA K (22500222), SANDEEP
KUMAR J (22500263) who carried out the work under my supervision. Certified
further that to the best of my knowledge the work reported herein does not form
part of any other project report.
BUILDING AN BILLING SOFTWARE

A PROJECT REPORT

Submitted by

CHINNAKARRUPUSAMY G (22500226)

AJISH U (22500221)

AKSHATHA K (22500222)

SANDEEP KUMAR J (22500263)

The viva-voice examination of this project work has been done as a part of

curriculum in the Diploma Course in COMPUTERENGINEERING

department is held on…………………

INTERNAL EXAMINER EXTERNAL EXAMINER


ACKNOWLEDGEMENT

We are extremely thankful to Principal P THENMOZHI M.E.,MBA,


(FAC), Government Polytechnic College, Coimbatore for giving us the
opportunity to execute this project.
Our special thanks to Mrs. D. JAMUNARANI,M.E., Head of the
Computer Engineering Department, for all the facilities provided to successfully
complete this work.
We would like to express our deepest sense of respect and indebtedness to
my project supervisor, Mr. S .AHALYA,M.E., Lecturer, Department of Computer
Engineering, for his consistent support, guidance, encouragement, and precious
pieces of advice in times during the project.
I am also very thankful to all the faculty members of the department for their
constant encouragement, invaluable advice, encouragement, inspiration, and
blessings during the project.
I also express my gratitude to the respondents, Parents, and dear friends
without whom the project would not have been successful.
Above all, I wish to thank the almighty for giving courage and wisdom to
take up this project and complete it successfully.
ABSTRACT

This project aims to develop a comprehensive department store billing


software system that streamlines the billing process and enhances customer
experience. The software will offer a user-friendly interface for store employees to
efficiently search and register products, calculate prices, apply discounts, and
generate itemized bills and has Intelligent basket which provides suggestions for
customers to meet their expectations. It will also maintain a centralized inventory
database to ensure accurate stock management. The system's integration with
payment gateways will enable seamless transaction processing, while its reporting
module will provide insights into sales trends, stock levels, and revenue
generation. Overall, the department store billing software project seeks to optimize
operational efficiency, reduce errors, and elevate customer satisfaction within the
store environment.
In today's dynamic business landscape, efficient and accurate billing
processes play a crucial role in ensuring the financial health of organizations. This
abstract introduces a cutting-edge Billing Software designed to streamline and
enhance the entire billing lifecycle. The software aims to revolutionize the way
businesses manage their financial transactions, providing a user-friendly interface
and robust features for seamless invoicing, payment processing, and financial
reporting.
This abstract delves into the challenges faced by businesses in traditional
billing practices, emphasizing the need for a modern solution. It introduces key
features of the Billing Software, such as automated invoicing, customizable
templates, and real-time tracking of financial transactions.
This elaborates on the technical aspects of the Billing Software, showcasing
its security measures, integration capabilities with existing systems, and
adaptability to various industries. It discusses the software's analytics tools,
enabling users to gain valuable insights into their financial data. The abstract
concludes by emphasizing the potential impact of the Billing Software on
increasing efficiency, reducing errors, and ultimately contributing to the overall
success of businesses in the digital age.
TABLE OF CONTENTS
CHAPTER NO TITLE PAGE NO

ACKNOWLEDGEMENT i

ABSTRACT ii

LIST OF FIGURES iii

LIST OF ABBREVIATIONS iv

1 INTRODUCTION 1

2 EXISTING SYSTEM 3

3 PROBLEM STATEMENT 5

4 PROPOSED SYSTEM 7

4.1 System Architecture 9

4.2 System Description 10

5 SYSTEM SPECIFICATION 11

5.1 Hardware Specification 12

5.2 Software Specification 12

6 MODULE DESCRIPTION 13

6.1 Admin 14

6.2 Intelligent Basket 14

6.3 User Management 14

6.4 Discounts and Promotions 14

7 SYSTEM IMPLEMENTATION 15

7.1 C# 16
7.2 SQL SEVER MANAGEMENT STUDIO 17

8 SYSTEM TESTING 18

8.1 Unit Testing 19

8.2 Integration Testing 20

8.3 Validation Testing 20

8.4 System Testing 20

9 RESULT 21

10 CONCLUSION & FUTURE WORK 24

11 REFERENCES 25

12 APPENDICES 29

LIST OF FIGURES
FIG.NO. TITLE PAGE.NO
11.2.1 Login 26
11.2.2 Add Product 26
11.2.3 New Bill 27
11.2.4 Update Bill 27
11.2.5 ViewBill 28
INTRODUCTION

CHAPTER-1
INTRODUCTION

In the fast-paced and ever-evolving realm of business, the management of


financial transactions holds paramount importance. Efficient and accurate billing
processes are not only integral to maintaining a healthy cash flow but are also
instrumental in fostering positive client relationships. As organizations strive to
navigate through the complexities of billing, the introduction of innovative Billing
Software becomes imperative. This introduction sets the stage for understanding
the significance of such software in addressing the challenges posed by traditional
billing methods and introduces a comprehensive solution designed to revolutionize
financial operations.
The landscape of billing has undergone a paradigm shift in recent years,
marked by the digitization of financial processes. Traditional methods, often
manual and time-consuming, have proven to be inadequate in meeting the demands
of modern businesses. In this context, Billing Software emerges as a transformative
tool, promising not only to streamline the invoicing process but also to enhance
overall financial efficiency.
The purpose of this introduction is to provide a glimpse into the key features
and benefits of advanced Billing Software. By automating invoicing, improving
accuracy, and offering real-time insights into financial transactions, this software
promises to be a game-changer for organizations seeking to optimize their billing
procedures. As we delve deeper into the intricacies of this software, we will
explore its functionalities, security measures, and the potential impact it can have
on businesses across various industries.
In essence, the introduction serves as a gateway to understanding the crucial
role that Billing Software plays in contemporary financial management. It sets the
tone for exploring the multifaceted capabilities of the software, underscoring its
relevance in the modern business landscape and its potential to revolutionize the
way organizations handle their financial transactions.
EXISTING SYSTEM
CHAPTER-2

EXISTING SYSTEM

The present billing system typically involves the use of electronic cash
registers or point-of-sale (POS) systems to handle transactions and generate
customer receipts. These systems streamline the checkout process by
automatically calculating the total cost of items, applying discounts, and
providing a detailed receipt for the customer's reference. The present billing
system typically involves the use of electronic cash registers or point-of-sale
(POS) systems to handle transactions and generate customer receipts. These
systems streamline the checkout process by automatically calculating the total
cost of items, applying discounts, and providing a detailed receipt for the
customer's reference.

Understanding the limitations of the existing system, such as


inefficiencies, errors, and a lack of flexibility, underscores the need for a more
advanced and integrated billing software solution. The introduction of cutting-
edge billing software aims to address these shortcomings, offering automation,
customization, and real-time insights to enhance overall financial efficiency and
management
PROBLEM STATEMENT

CHAPTER-3
PROBLEM STATEMENT
In today's dynamic business landscape, managing billing processes
efficiently is crucial for the success and sustainability of any organization.
However, many businesses, especially small and medium-sized enterprises
(SMEs), continue to grapple with manual, time-consuming billing methods that are
prone to errors and inefficiencies. From generating invoices to tracking payments
and managing financial records, the traditional approach to billing is often
complex, labor-intensive, and susceptible to human error.

Furthermore, as businesses grow and scale, the complexity of billing


processes tends to increase exponentially. Managing multiple clients, handling
diverse payment methods, ensuring compliance with regulatory requirements, and
maintaining accurate financial records become formidable challenges that can
overwhelm even the most organized business operations.

Additionally, with the rise of remote work and global business transactions,
there is a growing demand for billing solutions that offer flexibility, accessibility,
and security. Businesses need a reliable billing software that can streamline
invoicing processes, facilitate seamless payment collection, provide real-time
insights into financial performance, and ensure compliance with taxation and
accounting standards.

Therefore, there is a pressing need for a comprehensive billing software


solution that addresses these challenges and empowers businesses to manage their
billing processes efficiently, accurately, and securely. This software should be
user-friendly, customizable, scalable, and equipped with advanced features such as
automated invoicing, recurring billing, payment tracking, reporting analytics, and
integration capabilities with existing business systems.

By developing such a billing software solution, we aim to revolutionize the


way businesses manage their billing processes, enabling them to save time, reduce
costs, minimize errors, improve cash flow, and ultimately enhance their overall
financial performance and competitiveness in the market.
PROPOSED SYSTEM

CHAPTER-4
PROPOSED SYSTEM
The proposed billing software system represents a significant advancement
over existing methodologies, offering a comprehensive and streamlined solution
to address the shortcomings of traditional billing processes. This proposed system
incorporates state-of-the-art features and functionalities to enhance efficiency,
reduce errors, and provide a more adaptable solution for businesses of varying
sizes and industries.
The software will offer a user-friendly interface for store employees to
efficiently search and register products, calculate prices, apply discounts, and
generate itemized bills and has Intelligent basket which provides suggestions for
customers to meet their expectations.
The proposed billing software system aims to revolutionize how
businesses handle their financial transactions. It offers a user-friendly interface,
reduces manual intervention, and enhances overall financial efficiency,
positioning itself as a comprehensive solution for the modern business landscape.

4.1 SYSTEM ARCHITECTURE


Start Admin or Customer Login

Check

Permissio
n

Add Product Create New Bill Update Bills View Bills

Exit

4.2 SYSTEM DESCRIPTION:


An environment is provided such that user can create new product with its Id
and Product Name easily. Also user can create new bills and apply discounts with
ease.
Additional features such as updating bills, promoting Vendors and has
feature called Intelligent Basket which suggest product that increase the discount
and so on.
SYSTEM SPECIFICATION

CHAPTER-5
SYSTEM SPECIFICATION

5.1HARDWARE SPECIFICATION:
PROCESSOR : Intel i3 Processor 2.5GHZ
HARD DISK CAPACITY : 400 GB
MONITOR : 15 “SAMTRON MONITOR
INTERNAL MEMORY CA : 4 GB
KEYBOARD : LOGITECH OF 104 KEYS
CPU CLOCK : 1.08 GHz
MOUSE : LOGITECH MOUSE

5.2 SOFTWARE SPECIFICATION:


OPERATING SYSTEM : WINDOWS 11
FRONT END : C#.NET
BACK END : SQL SERVER MANAGEMENT STUDIO
MODULE DESCRIPTION
CHAPTER-6
MODULES DESCRIPTION
.

6.1 Admin:
This module allows the shop owner to update product list, update price list,
etc,.

6.2 Intelligent Basket:


This module provides suggestions for customers to meet their expectations,
it also enhances the user experience.

6.3 User Management:


This module helps to improve user experience, produces points according
to history in users bought list and produces electronic-bills.

6.4 Discounts and Promotions:


Allow for the application of discounts, coupons, and promotions during the
billing process. Calculate and display the final amount due, including taxes.
SYSTEM IMPLEMENTATION
CHAPTER-7
SYSTEM IMPLEMENTATION
7.1 C#
C# is a versatile and object-oriented programming language developed by
Microsoft, integral to the .NET framework. Its syntax, reminiscent of other C-style
languages, is expressive and robust, supporting features like classes, inheritance,
polymorphism, and encapsulation. C# is platform-independent, owing to its
compatibility with .NET Core and later versions, facilitating cross-platform
development. Automatic memory management, facilitated by a garbage collector,
simplifies memory allocation and de-allocation. C# is strongly typed, enhancing
code clarity and error detection at compile time. Noteworthy features include
LINQ for efficient data querying, asynchronous programming through a
sync/await, extension methods for adding functionality to existing types, and
support for delegates and events, essential for event-driven programming.
Additionally, C# incorporates attributes and reflection, enabling metadata
annotations and dynamic runtime type inspection. As an evolving language, C#
continues to integrate improvements in each version, emphasizing developer-
friendly practices and empowering developers across various domains.
7.1 SQL SEVER MANAGEMENT STUDIO
SQL Server Management Studio (SSMS) is a powerful integrated
environment for managing SQL Server databases. It complements the functionality
of SQL Server by providing a graphical interface for database administrators and
developers to interact with their databases. With its rich feature set, SSMS aligns
well with the demands of C# development.
Firstly, SSMS facilitates seamless integration with C# applications through
SQL Server databases. Developers can use C# to interact with SQL Server
databases by executing SQL queries, stored procedures, and scripts directly within
their C# codebase. This integration streamlines database operations, data
manipulation, and retrieval processes, enhancing the efficiency of C# applications
that rely on SQL Server databases.
Secondly, SSMS offers comprehensive tools for database development and
administration, catering to the needs of C# developers. These tools include query
editors, database object explorers, schema designers, and performance monitoring
utilities. C# developers can leverage these features to design, develop, debug, and
optimize SQL Server databases within the familiar SSMS environment, enhancing
productivity and collaboration in database-centric C# projects.

Additionally, SSMS supports advanced database management tasks such as backup


and restore operations, replication configuration, user management, and security
administration. These capabilities empower C# developers to manage the entire
lifecycle of SQL Server databases effectively, ensuring data integrity, availability,
and security in C# applications.

Furthermore, SSMS provides integration with version control systems, enabling C#


developers to manage database schemas and scripts alongside their C# codebase.
This integration facilitates seamless collaboration, versioning, and deployment of
database changes in conjunction with C# application updates, promoting
consistency and reliability in database-driven C# projects.

Overall, SQL Server Management Studio complements C# development by


providing a comprehensive environment for managing SQL Server databases. Its
integration with C# applications streamlines database interactions, enhances
development productivity, and ensures the reliability and performance of database-
driven C# projects.
SYSTEM TESTING
CHAPTER-8
SYSTEM TESTING
It is the process of exercising software with the intent of finding and
ultimately correcting errors. This fundamental philosophy does not change for web
applications, because web based system and applications reside on network and
inter-operate with many different operating systems, browsers, hardware platforms
and communication protocols. Thus searching for errors is significant challenge for
web applications.
8.1Unit testing

Here each program is tested individually so any error apply unit is debugged.
The sample data are given for the unit testing. The unit test results are recorded for
further references. During unit testing the functions of the program unit validation
and the limitations are tested.
Unit testing is testing changes made in a existing or new program this test is
carried out during the programming and each module is found to be working
satisfactorily. For example in the registration form after entering all the fields we
click the submit button. When submit button is clicked, all the data in form are
validated. Only after validation entries will be added to the database.
Unit testing comprises the set of tests performed by an individual prior to
integration of the unit into large system. The situation is illustrated in as follows
Coding-> Debugging ->Unit testing -> Integration testing
The four categories of test that a programmer will typically perform on a
program unit
1.Functional test
2.Performance test
3.Stress Test
4.Structure test
Functional test involve exercising the code with nominal input values for
which the expected results are known as well as boundary values and special
values.
Performance testing determines the amount of execution time spent in various
parts of unit program through put and response time and device utilization by the
program.
A variation of stress testing called sensitivity testing in same situations a very
small range of data contained in a bound of valid data may cause extreme and even
erroneous processing or profound performance degradation.
Structured testing is concerned with a exercising the internal logic of a
program and traversing paths. Functional testing, stress testing performance testing
are referred as “black box” testing and structure testing is referred as “white box”
testing
8.2 Integration Testing:
Integrated testing is a systematic technique for constructing tests to uncover
errors associated with interface.
Objective is to take unit tested modules and build a program structure that
has been dictated by design.
8.3 Validation Testing:
Software validation is achieved through a series of test that demonstrates the
conformity and requirements. Thus the proposed system under consideration has to
be tested by validation and found to be working satisfactorily. For example in
customer enters phone number field should contain number otherwise it produces
an error message similarly in all the forms the fields are validated.
8.4 System Testing:
In the system testing the whole system is tested for interface
between each module and program units are tested and recorded. This
testing is done with sample data. The securities, communication between
interfaces are tested
System testing is actually a series of different tests whose primary
purpose is to fully exercise the computerbased system although each
test has a different purpose all work to verify that all system
elements properly integrated and perform allocate function.
RESULT
CHAPTER-9
RESULTS

Figure 9.1

Figure 9.2
Figure 9.3

Figure 9.4
Figure 9.5
CONCLUSION
CHAPTER-10
CONCLUSION AND FUTURE WORK
10.1 CONCLUSION
In conclusion, the billing software project represents a crucial tool for
businesses to efficiently manage their invoicing, billing, and financial processes.
Through the systematic development and rigorous testing of the software, we
have created a reliable and user-friendly solution that meets the specific needs of
our clients. Furthermore, we recognize the importance of ongoing support,
maintenance, and continuous improvement of the billing software. By fostering a
culture of responsiveness, agility, and innovation, we are committed to ensuring
the long-term success and satisfaction with the billing software. In essence, the
billing software project represents not only a technological solution but also a
strategic investment in optimizing business processes, improving financial
management, and driving organizational growth and success.

10.2 FUTURE WORK


In future work for the billing software project, we aim to focus on enhancing
scalability, flexibility, and adaptability to accommodate the evolving needs of our
clients. This includes further integration with third-party systems, such as
accounting software and payment gateways, to streamline data exchange and
improve interoperability. Additionally, we plan to prioritize the development of
advanced analytics and reporting features to provide deeper insights into financial
trends, customer behaviors, and business performance. Moreover, we will continue
to prioritize user experience enhancements, including mobile optimization and
accessibility improvements, to ensure seamless usability across various devices
and platforms. Through ongoing collaboration with stakeholders and agile
development methodologies, we are committed to delivering continuous
innovation and value to our clients with the billing software project. Finally
invoice bill printing and accepting all types of payments will be done in the future.
REFERENCES
REFERENCES
Book Reference:
1) C# 8.0 and .NET Core 3.0 by Mark J. Price
2) Head First C# by Andrew Stellman
WEBSITES:
1. https://www.w3schools.com/cs/index.php
2. https://dotnettutorials.net/course/csharp-dot-net-tutorials/
3. https://www.codecademy.com/learn/learn-c-sharp
4. https://www.javatpoint.com/sql-server-management-studio
5. https://www.tutorialsteacher.com/sqlserver/sql-server-management-studio
APPENDICES
APPENDICES
12 SAMPLE CODE:
Main.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Billing
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}

private void Login_Load(object sender, EventArgs e)


{

private void openDashboardToolStripMenuItem_Click(object sender, EventArgs e)


{
string username = textBox1.Text;
string password = textBox2.Text;

// Check if username and password are correct


if (username == "gptc" && password == "123")
{
// Open the main form
DashBoard mainForm = new DashBoard();
mainForm.MdiParent = this;
mainForm.Show();
}
else
{
MessageBox.Show("Invalid username or password. Please try again.");
}
}
}
}
DashBoard.cs
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;

namespace Billing
{
public partial class DashBoard : Form
{
public DashBoard()
{
InitializeComponent();
}

private void productsToolStripMenuItem_Click_1(object sender, EventArgs e)


{
// to open child form in mdi(main) form
Products p = new Products();
p.Show();
}

private void newBillToolStripMenuItem1_Click(object sender, EventArgs e)


{
NewBill nb = new NewBill();
nb.Show();
}

private void viewBillsToolStripMenuItem_Click_1(object sender, EventArgs e)


{
ViewBills vb = new ViewBills();
vb.Show();
}

private void printBillToolStripMenuItem_Click(object sender, EventArgs e)


{
PrintBill pb = new PrintBill();
pb.Show();
}
}
}

NewBill.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Billing
{
public partial class NewBill : Form
{
SqlConnection con = new SqlConnection(Properties.Settings.Default.BillingCon);
SqlCommand cmd;
SqlDataReader dr;

public NewBill()
{
InitializeComponent();
txtDeleUpdate.Visible = false;

private void NewBill_Load(object sender, EventArgs e)


{
DisplayProductBasedOnDay();
cmbProducts.Select();

cmbProducts.Items.Clear(); // clear combobox before load form


con.Open();
cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select ProName from TblProducts order by ProName asc";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);

foreach(DataRow dr in dt.Rows)
{
cmbProducts.Items.Add(dr["ProName"].ToString());
}
con.Close();

LoadBillNo();

dataGridView1.Columns[5].Visible = false;
dataGridView1.Columns[6].Visible = false;

}
public void LoadBillNo()
{
//load bill no from database
int a;
string constr = (Properties.Settings.Default.BillingCon);
con = new SqlConnection(constr);
con.Open();
string query = "Select Max(BillNo) from TblHeaderData";
cmd = new SqlCommand(query, con);

dr = cmd.ExecuteReader();
if (dr.Read())
{
string val = dr[0].ToString();
if (val == "")
{
txtBillNo.Text = "1";
}
else
{
a=Convert.ToInt32(dr[0].ToString());
a=a+1;
txtBillNo.Text=a.ToString();
}
con.Close();
}
}

private void btnAdd_Click(object sender, EventArgs e)


{
if (cmbProducts.Text == "")
{
MessageBox.Show("Product Name is Empty");
}
else if (txtPrice.Text=="")
{
MessageBox.Show("Product Price is Empty");
}
else if (txtQty.Text == "")
{
MessageBox.Show("Product Qty is Empty");
}
else
{
// for Add the row in the gridview
if (txtDeleUpdate.Text == "")
{
int row = 0;
dataGridView1.Rows.Add();
row = dataGridView1.Rows.Count - 1;
dataGridView1["ProductName", row].Value = cmbProducts.Text;
dataGridView1["Price", row].Value = txtPrice.Text;
dataGridView1["Qty", row].Value = txtQty.Text;
dataGridView1["Amount", row].Value = txtAmount.Text;
dataGridView1["BillNo", row].Value = txtBillNo.Text;
dataGridView1["Date", row].Value =
dateTimePicker1.Value.ToString("dd-MM-yyyy");

dataGridView1.Refresh();
cmbProducts.Focus();

if (dataGridView1.Rows.Count > 0)
{
dataGridView1.CurrentCell =
dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1];
}
}
else
{

// update rows from gridview to textbox and after edit textbox to


gridview
int i;
i = Convert.ToInt32(txtDeleUpdate.Text);
DataGridViewRow row = dataGridView1.Rows[i - 1];
row.Cells[1].Value = cmbProducts.Text;
row.Cells[2].Value = txtPrice.Text;
row.Cells[3].Value = txtQty.Text;
row.Cells[4].Value = txtAmount.Text;
btnAdd.Text = "Add";

}
cleartextbox();

gridTotal();

}
}

private void dataGridView1_RowPostPaint(object sender,


DataGridViewRowPostPaintEventArgs e)
{
this.dataGridView1.Rows[e.RowIndex].Cells[0].Value = (e.RowIndex +
1).ToString();

int i;
private void dataGridView1_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)
{
i = e.RowIndex;
DataGridViewRow row = dataGridView1.Rows[i];
cmbProducts.Text = row.Cells[1].Value.ToString();
txtPrice.Text = row.Cells[2].Value.ToString();
txtQty.Text = row.Cells[3].Value.ToString();
txtAmount.Text = row.Cells[4].Value.ToString();
txtDeleUpdate.Text = row.Cells[0].Value.ToString();

btnAdd.Text = "Update";

private void btnDelete_Click(object sender, EventArgs e)


{
if (txtDeleUpdate.Text == "")
{
MessageBox.Show("Select Product to Delete");
}
else
{
foreach(DataGridViewRow row in dataGridView1.SelectedRows)
{
if (!row.IsNewRow) dataGridView1.Rows.Remove(row);
}
}
btnAdd.Text = "Add";

gridTotal();
cleartextbox();
}

public void cleartextbox()


{
cmbProducts.Text = "";
txtPrice.Text = "";
txtQty.Text = "";
txtAmount.Text = "";
txtDeleUpdate.Text = "";
}

public void CalAmount()


{
double a1, b1, i;
double.TryParse(txtPrice.Text, out a1);
double.TryParse(txtQty.Text, out b1);
i = a1 * b1;
if(i>0)
{
txtAmount.Text = i.ToString("C").Remove(0, 1);
}
}

private void txtQty_Leave(object sender, EventArgs e)


{
CalAmount();
}

private void txtPrice_Leave(object sender, EventArgs e)


{
CalAmount();
}

public void gridTotal()


{
double sum = 0;
for (int i = 0; i < dataGridView1.Rows.Count; ++i)
{
sum += Convert.ToDouble(dataGridView1.Rows[i].Cells[4].Value);
}
txtBillTotal.Text = sum.ToString();
}

public void DisCal()


{
double a2, b2, i;
double.TryParse(txtBillTotal.Text, out a2);
double.TryParse(txtDisAmount.Text, out b2);
i = a2 - b2; // bill amount - discount amount
if (i > 0)
{
txtPay.Text = i.ToString("C").Remove(0, 1);
}
}

private void txtBillTotal_TextChanged(object sender, EventArgs e)


{
DisCal();
}

private void txtDisAmount_Leave(object sender, EventArgs e)


{
DisCal();
}
private void BtnSave_Click(object sender, EventArgs e)
{
if (dataGridView1.Rows.Count < 1)
{
MessageBox.Show("Add Minimum One Product to Bill");
}
else
{
// save header data
con.Open();
cmd = new SqlCommand("Insert into TblHeaderData (BillNo, BillDate,
BillAmount, DisAmount, NetPay)
values('"+txtBillNo.Text+"','"+dateTimePicker1.Value.ToString("MM-dd-yyyy")
+"','"+txtBillTotal.Text+"','"+txtDisAmount.Text+"','"+txtPay.Text+"')", con);
cmd.ExecuteNonQuery();

// save row data


for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
SqlCommand cmd1 = new SqlCommand("Insert into TblRowData (SlNo,
ProductName, Price, Qty, Amount, BillNo) values('" +
dataGridView1.Rows[i].Cells[0].Value.ToString() + "','" +
dataGridView1.Rows[i].Cells[1].Value.ToString() + "','" +
dataGridView1.Rows[i].Cells[2].Value.ToString() + "','" +
dataGridView1.Rows[i].Cells[3].Value.ToString() + "','" +
dataGridView1.Rows[i].Cells[4].Value.ToString() + "','" +
dataGridView1.Rows[i].Cells[5].Value.ToString() + "')", con);
cmd1.ExecuteNonQuery();
}

MessageBox.Show("Bill Saved");

con.Close();

LoadBillNo();
cleartextbox();

txtBillTotal.Text = "";
txtDisAmount.Text = "";
txtPay.Text = "";

cmbProducts.Select();

}
}

private void DisplayProductBasedOnDay()


{
// Get the current day of the week
DayOfWeek currentDay = DateTime.Today.DayOfWeek;

// Display different products based on the day


switch (currentDay)
{
case DayOfWeek.Sunday:
textBox1.Text = "Sunday Special: Sugar";
break;
case DayOfWeek.Monday:
textBox1.Text = "Monday Deal: Rice";
break;
case DayOfWeek.Tuesday:
textBox1.Text = "Tuesday Offer: Dall";
break;
case DayOfWeek.Wednesday:
textBox1.Text = "Wednesday Sale: Wheat";
break;
case DayOfWeek.Thursday:
textBox1.Text = "Thursday Promo: Masala";
break;
case DayOfWeek.Friday:
textBox1.Text = "Friday Flash Sale: Ghee";
break;
case DayOfWeek.Saturday:
textBox1.Text = "Saturday Special: Cheese";
break;
default:
textBox1.Text = "No product available for today";
break;
}
}

private void textBox1_TextChanged(object sender, EventArgs e)


{

private void pictureBox5_Click(object sender, EventArgs e)


{

}
}
}

Product.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Billing
{
public partial class Products : Form
{
SqlConnection con = new SqlConnection(Properties.Settings.Default.BillingCon);
SqlCommand cmd;
SqlDataAdapter da;
DataTable dt;
public Products()
{
InitializeComponent();
}

private void Products_Load(object sender, EventArgs e)


{
fillgrid();
}

private void btnSave_Click(object sender, EventArgs e)


{
// save product info
if (txtProName.Text == "")
{
MessageBox.Show("Please Enter Product Name");
}
else
{
try
{
con.Open();
cmd = new SqlCommand("INSERT INTO Tblproducts (ProName)VALUES('" +
txtProName.Text + "')", con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Product Info Saved...");
//after saving the new product show the recent saved product in the
gridview
fillgrid();
cleartext();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}

private void fillgrid()


{
// fill datagrid from datatable
con.Open();
da = new SqlDataAdapter("select * from TblProducts order by ProName asc",
con);
con.Close();
SqlCommandBuilder cd = new SqlCommandBuilder(da);
dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}

int i;
private void dataGridView1_CellDoubleClick(object sender,
DataGridViewCellEventArgs e)
{
i = e.RowIndex;
DataGridViewRow row = dataGridView1.Rows[i];
txtProID.Text = row.Cells[0].Value.ToString();
txtProName.Text = row.Cells[1].Value.ToString();
}

private void btnUpdate_Click(object sender, EventArgs e)


{
// before update check for product to update
if (txtProID.Text == "")
{
MessageBox.Show("Please Select Product to Update");
}
else
{
try
{
con.Open();
cmd = new SqlCommand("UPDATE Tblproducts SET ProName = '" +
txtProName.Text + "' where ProID = '" + txtProID.Text + "' ", con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Product Info Updated");
fillgrid();
cleartext();

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
private void cleartext()
{
txtProID.Text = "";
txtProName.Text = "";
}

private void btnDelete_Click(object sender, EventArgs e)


{
// check product is selected or not to delete

if (txtProID.Text == "")
{
MessageBox.Show("select product to delete");
}
else
{
try
{
con.Open();
cmd = new SqlCommand("Delete From Tblproducts where ProID = '" +
txtProID.Text + "' ", con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Product Info Deleted...");
fillgrid();
cleartext();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}

private void txtClear_Click(object sender, EventArgs e)


{
cleartext();
}
}
}

UpdateBill.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Billing
{
public partial class UpdateBill : Form
{
SqlConnection con = new SqlConnection(Properties.Settings.Default.BillingCon);
SqlCommand cmd;
SqlDataAdapter da;
DataTable dt;
public UpdateBill()
{
InitializeComponent();
}

private void UpdateBill_Load(object sender, EventArgs e)


{
con.Open();

cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select * from TblRowData where BillNo like ('"
+txtBillNo.Text+ "%' )";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();

dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

dataGridView1.Columns[5].Visible = false;
dataGridView1.Columns[6].Visible = false;
// fill products name form product table to products combobox
cmbProducts.Select();

cmbProducts.Items.Clear(); // clear combobox before load form


con.Open();
cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select ProName from TblProducts order by ProName asc";
cmd.ExecuteNonQuery();
dt = new DataTable();
da = new SqlDataAdapter(cmd);
da.Fill(dt);

foreach (DataRow dr in dt.Rows)


{
cmbProducts.Items.Add(dr["ProName"].ToString());
}
con.Close();
}

private void dataGridView1_RowPostPaint(object sender,


DataGridViewRowPostPaintEventArgs e)
{

private void txtPrice_Leave(object sender, EventArgs e)


{
CalAmount();
}

public void CalAmount()


{
double a1, b1, i;
double.TryParse(txtPrice.Text, out a1);
double.TryParse(txtQty.Text, out b1);
i = a1 * b1;
if(i>0)
{
txtAmount.Text = i.ToString("C").Remove(0, 1);
}
}

private void txtQty_Leave(object sender, EventArgs e)


{
CalAmount();
}

int i;
private void LoadSerialNo()
{
int i = 1;
foreach(DataGridViewRow row in dataGridView1.Rows)
{
row.Cells[0].Value = i; i++;
}
}
private void dataGridView1_RowsAdded(object sender,
DataGridViewRowsAddedEventArgs e)
{
LoadSerialNo();
}

private void dataGridView1_CellDoubleClick(object sender,


DataGridViewCellEventArgs e)
{
i = e.RowIndex;
DataGridViewRow row = dataGridView1.Rows[i];
txtDeleUpdate.Text = row.Cells[0].Value.ToString();
cmbProducts.Text = row.Cells[1].Value.ToString();
txtPrice.Text = row.Cells[2].Value.ToString();
txtQty.Text = row.Cells[3].Value.ToString();
txtAmount.Text = row.Cells[4].Value.ToString();

private void btnDelete_Click(object sender, EventArgs e)


{
foreach(DataGridViewRow row in dataGridView1.SelectedRows)
{
if (!row.IsNewRow) dataGridView1.Rows.Remove(row);

LoadSerialNo();
}
clearText();
gridTotal();
}

private void btnAdd_Click(object sender, EventArgs e)


{
// if txtDeleUpdate empty then add new row else update selected row
if (txtDeleUpdate.Text == "")
{
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
dataGridView1.Rows[1].Cells[1].Value = (i + 1).ToString();
}
DataTable dt = dataGridView1.DataSource as DataTable;

DataRow row1 = dt.NewRow();


row1[1] = cmbProducts.Text.ToString();
row1[2] = txtPrice.Text.ToString();
row1[3] = txtQty.Text.ToString();
row1[4] = txtAmount.Text.ToString();
row1[5] = txtBillNo.Text.ToString();
cmbProducts.Focus();
dt.Rows.Add(row1);

}
else
{
DataGridViewRow row = dataGridView1.Rows[i];
row.Cells[1].Value = cmbProducts.Text;
row.Cells[2].Value = txtPrice.Text;
row.Cells[3].Value = txtQty.Text;
row.Cells[4].Value = txtAmount.Text;
row.Cells[5].Value = txtBillNo.Text;
}
clearText();
gridTotal();
}

private void clearText()


{
cmbProducts.Text = "";
txtPrice.Text = "";
txtQty.Text = "";
txtAmount.Text = "";
txtDeleUpdate.Text = "";

private void txtBillTotal_TextChanged(object sender, EventArgs e)


{
DisCal();
}

public void gridTotal()


{
double sum = 0;
for (int i = 0; i < dataGridView1.Rows.Count; ++i)
{
sum += Convert.ToDouble(dataGridView1.Rows[i].Cells[4].Value);
}
txtBillTotal.Text = sum.ToString();
}

public void DisCal()


{
double a2, b2, i;
double.TryParse(txtBillTotal.Text, out a2);
double.TryParse(txtDisAmount.Text, out b2);
i = a2 - b2; // bill amount - discount amount
if (i > 0)
{
txtPay.Text = i.ToString("C").Remove(0, 1);
}
}

private void txtDisAmount_Leave(object sender, EventArgs e)


{
DisCal();
}

private void BtnSave_Click(object sender, EventArgs e)


{
// delete old (row data)bill data
try
{
con.Open();
cmd = new SqlCommand("Delete from TblRowData where BillNo =
'"+txtBillNo.Text+"' ", con);
cmd.ExecuteNonQuery();
con.Close();

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

try
{

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


{
con.Open();
SqlCommand cmd1 = new SqlCommand("Insert into TblRowData (SlNo,
ProductName. Price, Qty, Amount, BillNo, Date)values('" +
dataGridView1.Rows[i].Cells[0].Value.ToString() + "','" +
dataGridView1.Rows[i].Cells[1].Value.ToString() + "','" +
dataGridView1.Rows[i].Cells[2].Value.ToString() + "','" +
dataGridView1.Rows[i].Cells[3].Value.ToString() + "','" +
dataGridView1.Rows[i].Cells[4].Value.ToString() + "','" +
dataGridView1.Rows[i].Cells[5].Value.ToString() + "','" +
dataGridView1.Rows[i].Cells[6].Value.ToString() + "')", con);
cmd1.ExecuteNonQuery();
con.Close();
}

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

// now update bill amount, discount and final amount

try
{
con.Open();
cmd = new SqlCommand("Update TblHeaderData set BillDate =
'"+dateTimePicker1.Value.ToString("MM/dd/yyyy")+"', BillAmount = '"+txtBillTotal.Text+"',
DisAmount ='"+txtDisAmount.Text+"', NetPay = '"+txtPay.Text+"' ",con);
cmd.ExecuteNonQuery();
con.Close();

MessageBox.Show("bill updated");

txtBillTotal.Text = "";
txtDisAmount.Text= "";
txtPay.Text = "";

dataGridView1.Rows.Clear();

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

// hide this window (after complete the print layout we will open print form)
this.Hide();
}

}
}
ViewBills.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Billing
{
public partial class ViewBills : Form
{
SqlConnection con = new SqlConnection(Properties.Settings.Default.BillingCon);
SqlCommand cmd;
SqlDataAdapter da;
DataTable dt;

public ViewBills()
{
InitializeComponent();
}

private void ViewBills_Load(object sender, EventArgs e)


{
fillGrid();
totalBillSales();
}

private void btnViewBills_Click(object sender, EventArgs e)


{
con.Open();
da = new SqlDataAdapter("Select * from TblHeaderData where BillDate between
'" + dateTimePicker1.Value.ToString("MM/dd/yyyy") + "'and'" +
dateTimePicker2.Value.ToString("MM/dd/yyyy") + "' order by BillNo asc ", con);
DataSet ds = new DataSet();
da.Fill(ds, "TblHeaderData");
dataGridView1.DataSource = ds.Tables["TblHeaderData"];
con.Close();
totalBillSales();
}

private void dataGridView1_MouseClick(object sender, MouseEventArgs e)


{
DataGridViewRow dr = dataGridView1.SelectedRows[0];
textBox1.Text = dr.Cells[0].Value.ToString();
}

private void btnDeleteBills_Click(object sender, EventArgs e)


{
if (textBox1.Text == "")
{
MessageBox.Show("Select Bill No for delete");
}
else
{
DialogResult dialogResult = MessageBox.Show("You want Delete Bill",
"Deleteing Bill",MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
SqlCommand cmd = new SqlCommand();
SqlCommand cmd1 = new SqlCommand();
con.Open();
cmd = new SqlCommand("Delete From TblHeaderData Where BillNo ='" +
textBox1.Text + "' ", con);
cmd1 = new SqlCommand("Delete From TblHeaderData Where BillNo ='" +
textBox1.Text + "' ", con);

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

fillGrid();
totalBillSales();
}
else if (dialogResult == DialogResult.No)
{

}
}
}

public void fillGrid()


{
con.Open();
da = new SqlDataAdapter("Select * from TblHeaderData order by BillNo asc",
con);
con.Close();
SqlCommandBuilder cb = new SqlCommandBuilder(da);
dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}

// to show no of bills and total sales amount


public void totalBillSales()
{

// no.of bills
txtTotalBills.Text = dataGridView1.Rows.Count.ToString();

// total sales amount


double sum = 0;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
sum += Convert.ToDouble(dataGridView1.Rows[i].Cells[4].Value);
}

txtTotalSales.Text = sum.ToString();

private void dataGridView1_CellDoubleClick(object sender,


DataGridViewCellEventArgs e)
{
UpdateBill ub = new UpdateBill();
ub.txtBillNo.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
ub.txtBillTotal.Text =
this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
ub.txtDisAmount.Text =
this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
ub.txtPay.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString();

ub.Show(); // to open updatebill form


this.Hide();// to close viewbills
}
}
}

You might also like