Download as pdf or txt
Download as pdf or txt
You are on page 1of 170

DEPARTMENT OF INFORMATION TECHNOLOGY

ST. XAVIER’S COLLEGE-AUTONOMOUS


YEAR: 2019-2020

CRM ERP

A Project Report
Submitted in partial fulfillment of the
Requirements for the award of the Degree of

BACHELOR OF SCIENCE (INFORMATION TECHNOLOGY)


By

Chirag Manoj Jain (175029)

Malhar Ghadiali (175026)

Rohan Patil (175047)

Under the esteemed guidance of


Prof. Roy Thomas
HOD (BSc.IT Department)

1|Page
CERTIFICATE

This to certify that Chirag Jain (175029), Malhar Ghadiali (175026), Rohan Patil (175047) has
submitted their project entitled CRM ERP (Enterprise Resource Planning Desktop
Application) in partial fulfillment of requirements of Bachelor of Science in Information
Technology course in satisfactory manner within the permission of Prof Roy Thomas during
the academic year 2019-2020.

(INTERNAL EXAMINER) (EXTERNAL EXAMINER)

Prof. Roy Thomas

(HEAD OF DEPARTMENT) COLLEGE STAMP

Prof. Roy Thomas

2|Page
Declaration

We, Chirag Jain (175029), Malhar Ghadiali (175026) , Rohan Patil (175047) hereby, declare
that the project report titled, “CRM ERP” which is being submitted in partial fulfilment
of the requirements for the Degree of Bachelor of Science with a specialization in
Information Technology is the result of the original work carried out by us under the
guidance of Prof. Roy Thomas of St Xavier’s College (Autonomous), Mumbai. This project has
not previously formed the basis for the award of any degree, diploma, or certificate of this
college or of any other college or university.

_________________ _________________ _________________


Chirag Jain Malhar Ghadiali Rohan Patil

3|Page
Table of Contents

Acknowledgement ................................................................................................................................. 5
Chapter 1 - Introduction......................................................................................................................... 6
Definition of ERP ................................................................................................................................. 6
Benefits of ERP .................................................................................................................................... 6
Overview ............................................................................................................................................. 7
Appealing Features ............................................................................................................................. 8
Feasibility Study .................................................................................................................................. 9
Stake Holders .................................................................................................................................... 11
Applicability ....................................................................................................................................... 12
Chapter 2 - Survey of Technologies ..................................................................................................... 13
Chapter 3 – Life Cycle of Project .......................................................................................................... 15
Software Development Methodology .............................................................................................. 15
Planning and Scheduling ................................................................................................................... 17
Gantt Chart........................................................................................................................................ 18

Use Case Diagram ............................................................................................................................. 19


Entity Relationship Diagram.............................................................................................................. 21
Activity Diagram ................................................................................................................................ 23

Data Flow Diagram………………………………………………………………………………………………………………………24

Chapter 4 – Database Design………………………………………………………………………………………………………....26


Database Normalization………………………………………………………………………………………………………………26
Table Structures ................................................................................................................................ 28
Stored Procedures ............................................................................................................................ 31

Chapter 5 – Coding and Implementation ……………………………………………………………………………………… 36


Chapter 6 – Reports and its Implementation ……………………………………………………………………………… 146
Chapter 7 – Software Testing………………………………………………………………………………………………………. 156
Test Cases………………………………………………………………………………………………………………………………….157

Chapter 8 – Future Enhancements and Conclusion……………………………………………………………………. .169

Future Scope ................................................................................................................................... 169


Conclusion ....................................................................................................................................... 169
Chapter 9 – References and Bibliography ......................................................................................... 170

4|Page
ACKNOWLEDGEMENT

I would like to take this opportunity to express my gratitude for the support, guidance and
inspiration provided by my mentor Prof. Roy Thomas. I would also like to acknowledge the
Professors of BSc.IT Department (St. Xavier’s College-Autonomous) for navigating my
thoughts into an entire new dimension of research which would have remained uncharted
without their advice.

I would also like to thank the CEO of Stalwart Tex. International LLP. (Mumbai-02),
Mr. Ankur Jain for allowing us to develop a software for his Trading Company and always
guiding us throughout the project, which has truly been indispensable for completion of this
project. This project has been a thought-provoking experience and the same would have
been not likely without the backing and direction of our Friends.

Last, but not least, my parents are also important inspiration for me. So, with due regards, I
express my gratitude to them.

5|Page
Chapter 1
INTRODUCTION
A rise in culture of automation and digitization, a lot of scope has been created in the
software industry to bring about customization.
Lately, this has become a driving force within the industry for companies to register growth
for themselves and scout for talent and synergies to capitalize on this rising trend.

Considering the fact that 90.00 per cent of SME organization in our country are either in the
unorganized sector or have no technology driven manifest to amplify their efforts.
Thus, we decided to gain cues and inspiration from such tech-based companies to develop a
customized software product for an entity in need.

This inspiration helped us to translate our education, course knowledge, assimilated


information from faculty and online resources along with observation skills to design a
software from scratch with an objective to provide customized tech-based solutions.

Definition of ERP

Enterprise resource planning systems have a host of applications that manage the core
business functions in a unified manner. It facilitates seamless task flow in sales, inventory,
customer relationship management, human resources, and finance. ERP tools serve as
integrated platforms that have the ability to streamline all major organizational functions.
They help to automate administrative back-office work and enhance the efficiency of cross-
departmental workflow. ERP software can interpret, store, edit and transfer large amounts of
vital company data easily and improve strategic decision making.

Benefits of ERP

- Increases Productivity
- Promotes a Culture of Collaboration
- Stringent Data Protection
- Enhances Compliance
- Accurate business forecasting

6|Page
Overview:
CRM ERP as the name highlights is an ERP (Enterprise Resource Planning) software, tailor
made for STALWART TEX.INETRNATIONAL LLP, Mumbai-02, a Textile Trading Company
which trades in SAREES. This Desktop Application consists of various modules such as
Purchase, Sales, Reporting, Master, HR Management etc. which helps in the digitization of
the SME organization and enhances the functioning of the company.

The Design and Implementation of this application is carrying out various activities involved
in the domain of a Trading business. The System is to provide a comprehensive platform for
replacing the paper-hand work into a digital form and provide a User Interface which is
adaptive and very appealing.

The Employees of the Organization can log in through their credentials provided by the
developers which can later be changed accordingly with the help of secured OTP system.
Once logged in the User is provided with various modules to work on such purchase, sales,
accounting, reporting etc.

Module 1: Master

The master module provides a way to maintaining the records in database regarding
product, employees, department, designation, suppliers, customers, brokers etc. The user
can perform all the basic CRUD operations and these operations are then reflected in the
database. The entire schema of the Database is provided in the following sections of this
Report.

Module 2: Purchase

The purchase module provides an option to record all the details pertaining to a vendor and
these details are the master data for vendors who supply goods to the company. The
purchase department is entrusted with the task of purchasing materials which is later sold
to different customers.
The purchase department is also responsible for purchasing materials in the right quantities
of the right quality at the right time. The purchase module assists the department with the
right information inputs to in this task.

The purchase department initiates the purchase process by raising the Purchase order.
Purchase orders are created when there is a requirement of materials for production of
finished products. The vendor supplies goods based on the purchase order. All purchase
orders are treated as pending purchase orders till the time material is received from the
vendors.

7|Page
Module 3: Sales

The sales module provides an option to record all the details pertaining to a customer and
these details are the master data for customers to whom the products are supplied from the
company. The sales departments is responsible for taking care of selling the products to the
customers.
The Sales department initiates the process by raising a Sales order.

Module 4: Company profile


This Module consists of the information pertaining to the Company such as the details of
the owner (name, contact, email etc.). This module also stores variety of other information
of the company such as their logo, address etc. This Module can only be viewed by the
employees of the organization whereas it can be edited/updated only by the owner (Admin)
of the organization.

Module 5: Reporting

Reporting is one of the most demanding and easily understood module in an ERP system, in
this project we have made use of RDLC reporting tool to generate reports such as Purchase
Order, Sales Order, Sales between a period of time, Stock report etc. This module assists the
organization to keep the track of the purchases and sales of products.

Appealing features:

- Computerization: Data storage is very large in a computer system. This means that
all the files that were being stored in the multiple registers can now be transferred
to the new system in the database and more information can be stored easily and
efficiently.

- Appealing and User-friendly Interface: The application would provide a user-


friendly interface and thus would be easy for the users to use it without much of
technical knowledge. User will find it easy to use and they will be able to update
information easily. It is faster and automatic process eliminating duplication of the
data.

- News Feed: This application also contains News Feed Section on the rightmost side
of the Dashboard Screen (Home). The feed is Automatically generated and gets
updated after every half an hour. The main purpose of this feed is to make sure that
all the employees of the organization are well acquainted with the current
happenings across the globe.

8|Page
- Automated SMS System: One of the most appealing features of this desktop
application is automated messages to the concerned party along with the dynamic
information generated from the database. For instance, if a Purchase order is
created then the details of the respective purchase order are sent to the respective
supplier in the form of a text message.

- Secured OTP System: In order to deal with the situation of Forget Password, we
make use of the secured OTP system to allow the employee to further change
his/her password. This prevents employees of the organization to log in with the
credentials of other employees and hence enhances Security.

- RDLC Reports: This Application Consists of generation of Reports, these reports are
generated automatically and all the data is fetched from the database itself making it
more dynamic and secured.

Feasibility Study:
The feasibility study is undertaken to determine the possibility of either improving the
present system or developing a completely new system. It helps to obtain an overview of
the problem and get an idea whether a feasible solution exists. The purpose of feasibility
study is to investigate deeply the recommended system. Feasibility study is carried out to
describe and evaluate the proposed system. Feasibility analysis essentially identifies all the
risks of failure. Therefore, a feasibility study of the proposed system needs to be carried out
in order to: -

- Provide a better understanding of the system.


- Clarify objectives if the proposed system.
- Assess and recommend what course of action should be taken for the solution
proposed.
- Describe the outputs: In our case, the new system is created based on the
requirement provided by the organization and collected by using the various
factfinding techniques. There are many factors to assess when analyzing whether the
proposed system is feasible and should be adopted. These factors are-
• Operational Feasibility
• Technical Feasibility
• Economic Feasibility

9|Page
The detailed study of each type of feasibility is discussed below:

Operational Feasibility

For operational feasibility we measured how well the project will support the stakeholders
during the operational phase. While analyzing this we tried to understand whether the
system will be used if it is developed and implemented.

The following are our observations from the operational feasibility analysis of the developed
system:

- Our project is feasible to operate as it is very handy and increases the accessibility
and management of the information that is required by our stakeholders.
- The system’s current mode of operation provides adequate throughput and
response time. It has quick functioning and saves both time and efforts for the users.
- The current mode of operation offers effective controls to protect against fraud and
to guarantee accuracy and security of data and information. The concept of
authentication secures all the user’s data and creates a safe space for the
stakeholder to deliver and receive information.
- The current work practices and procedures adequate to supports any future
advancement which might prove beneficial or the stakeholders.
- The system does not violate any government or private rules and regulations and
completely abides by the laws.
- The proposed system will really benefit the organization.

Technical Feasibility

This Assessment was focused on gaining an understanding of the present technical


resources that were available with us and their applicability to the expected need of the
proposed system. After evaluating the technical feasibility of the system, we came to the
following conclusions:

- Our project was feasible within the limits of the current technology available with
us.
- The manpower available with us was sufficient to successfully implement the
proposed system.
- We possessed the necessary technical expertise to execute the idea of this system
and turn it into reality.
- We also thoroughly assessed the technology which we currently possessed and
whether it would be efficient to create the system that was being planned and
following is an analysis of the technical hardware and software resources used for
the development of the system.

10 | P a g e
Economic Feasibility

The economic feasibility study determines whether the project goal is achieved within the
resource limit allocated to it. Cost-benefit analysis is a frequently used method for
evaluating the effectiveness of the proposed system. It is important because management
must authorize the budget of the project. The different types of costs that are incurred are
as follows:

- Manpower Cost: Taking care that there is no extra manpower cost as such, the
development of the project is done. In fact, manpower is saved, as the duplication of
work will be eliminated.
- Hardware and Software Cost: As the necessary hardware and software are already
available, as depicted in the technical feasibility study, there is no such additional
cost.
- Behavioral Feasibility: The organization unit remains intact and on-line reports keep
the organization conflict-free! “Hence the proposed system is also economically
feasible.”

Stakeholders
Stakeholders are individuals or group of people within an organization whose support is
required to launch an ERP project. These stakeholders need to actively participate. Silent
participation of any stakeholder means an invitation to the failure of the ERP project.

- CEO: Every business has a boss/leader that plays an important role in laying out
strategies and policies for an organization. The CEO/leader is an important
stakeholder due to the fact that he/she needs information of all kinds, related to
business. Though the CEO will not actively participate in the selection or
implementation of the ERP project, he needs to approve the project and also ensure
other stakeholders actively participate in the ERP requirement analysis.

- Production, Sales, Marketing Department: Some departments in the organization


those are likely to gain the most from the ERP system are Production, Marketing and
Sales. An ERP system helps the production department to increase production levels
and control costs more efficiently.

- Engineering Department: One of the objectives of ERP system is to give real-time


visibility in production, enable process improvement and quality. Majority of the
times the engineering department has to take the risks and ensure the process
functions smoothly within metrics defined by the ERP system.

11 | P a g e
APPICABILITY: -

TOOLS:

• FRONT-END : Microsoft Visual Studio (2015)


• BACK-END : SQL Management Studio
PLATFORM:

• Microsoft Visual Studio


• Microsoft SQL Server Management Studio

HARDWARE AND SOFTWARE ENVIRONMENT

HARDWARE ENVIRONMENT:

• PROCESSOR : i3 Processor
• RAM : 4 GB
• STORAGE CAPACITY : 500 GB
• DRIVERS : . netfx45 (Framework)
• 52X CD : 1.44 MB FDD

SOFTWARE ENVIRONMENT

• OPERATING SYSTEM : WINDOWS XP,7, or above, MAC OS


• RDBMS : My SQL SERVER

12 | P a g e
Chapter 2
Survey of Technologies

Introduction:
Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It
is used to develop computer programs, as well as websites, web apps, web
services and mobile apps. Visual Studio uses Microsoft software development platforms
such as Windows API, Windows Forms, Windows Presentation Foundation, Windows
Store etc. It can produce both native code and managed code.

Visual Studio supports 36 different programming languages and allows the code editor and
debugger to support (to varying degrees) nearly any programming language, provided a
language-specific service exists. Built-in languages include C, C++, C++/CLI, Visual Basic
.NET, C#, F#, JavaScript, TypeScript, XML, XSLT, HTML, and CSS. Support for other languages
such as Python, Ruby, Node.js, and M among others is available via plug-ins. Java (and J#) were
supported in the past.

The most basic edition of Visual Studio, the Community edition, is available free of charge.
The slogan for Visual Studio Community edition is "Free, fully-featured IDE for students,
open-source and individual developers".

Architecture:
Visual Studio does not support any programming language, solution or tool intrinsically;
instead, it allows the plugging of functionality coded as a VSPackage. When installed, the
functionality is available as a Service.

The IDE provides three services:


- SVs Solution: It provides the ability to enumerate projects and solutions.
- SVs UIShell: It provides windowing and UI functionality (including tabs, toolbars etc)
- SVs Shell: It deals with registration of VSPackages.

13 | P a g e
Features:
- Code Editor:
Like any other IDE, it includes a code editor that supports syntax highlighting and
code completion using IntelliSense for variables, functions, methods, loops,
and LINQ queries. Visual Studio features background compilation (also called
incremental compilation). As code is being written, Visual Studio compiles it in the
background in order to provide feedback about syntax and compilation errors, which
are flagged with a red wavy underline. Warnings are marked with a green underline.

- Debugger:
Visual Studio includes a debugger that works both as a source-level debugger and as
a machine-level debugger. It works with both managed code as well as native
code and can be used for debugging applications written in any language supported
by Visual Studio. In addition, it can also attach to running processes, monitor, and
debug those processes

- Extensibility:
Visual Studio allows developers to write extensions for Visual Studio to extend its
capabilities. These extensions "plug into" Visual Studio and extend its functionality.
Extensions come in the form of macros, add-ins, and packages.
Macros represent repeatable tasks and actions that developers can record
programmatically for saving, replaying, and distributing. Macros, however, cannot
implement new commands or create tool windows. They are written using Visual
Basic and are not compiled.
Add-Ins provide access to the Visual Studio object model and can interact with the
IDE tools.

Editions:
- Community
- Professional
- Enterprise
- Test Professional

14 | P a g e
Chapter 3
Life Cycle of Project
Software Development Methodology
In software engineering, a software development process is the process of
dividing software development work into distinct phases to improve design, product
management, and project management. It is also known as a software development life
cycle (SDLC). The methodology may include the pre-definition of specific deliverables and
artifacts that are created and completed by a project team to develop or maintain an
application. Most modern development processes can be vaguely described as agile. Other
methodologies include waterfall, prototyping, iterative and incremental development, spiral
development, rapid application development, and extreme programming.

Waterfall Model:
One such approach/process used in Software Development is "The Waterfall Model".
Waterfall approach was first Process Model to be introduced and followed widely in
Software Engineering to ensure success of the project.

The phases in Waterfall model are: Requirement Specifications phase, Software Design,
Implementation and Testing & Maintenance. All these phases are cascaded to each other so
that second phase is started as and when defined set of goals are achieved for first phase
and it is signed off, so the name "Waterfall Model". All the methods and processes
undertaken in Waterfall Model are more visible.

15 | P a g e
The Steps are as Followed:

- Requirement, Analysis & Definition: We Captured all possible requirements of the


system to be developed in this phase. Requirements are set of functionalities and
constraints that the end-user (who will be using the system) expects from the
system. The requirements were gathered from the end-user by consultation, these
requirements were then analyzed for their validity and the possibility of
incorporating the requirements in the system to be development was also studied.

- System & Software Design: Before starting for actual coding, it is highly important to
understand what we are going to create and what it should look like? The
requirement specifications from first phase were studied in this phase and system
design was prepared. System Design helps in specifying hardware and system
requirements and also helps in defining overall system architecture. The system
design specifications serve as input for then expanse of the model.

- Coding: After analysis and designing the software, we started with actual coding
which is quite important. Coding was taken up according to the design specified.

- Implementation & Unit Testing: On receiving system design documents, the work
was divided in modules/units and actual coding started. The system was first
developed in small programs called units, which were then integrated in the next
phase. Each unit is developed and tested for its functionality; this is referred to as
Unit Testing. Unit testing mainly verifies if the modules/units meet their
specifications.

- Operations & Maintenance: This phase of "The Waterfall Model" is virtually never-
ending phase (Very long). Generally, problems with the system developed (which are
not found during the development life cycle) come up after its practical use starts, so
the issues related to the system are solved after deployment of the system. Not all
the problems come in picture directly but they arise time to time and needs to be
solved; hence this process is referred as Maintenance.

16 | P a g e
There are some disadvantages of the Waterfall Model:

▪ As it is very important to gather all possible requirements during the Requirement


Gathering and Analysis phase in order to properly design the system, not all
requirements are received at once.
▪ The problems with one phase are never solved completely during that phase and
in fact many problems regarding a particular phase arise after the phase is signed
off, these results in badly structured system as not all the problems (related to a
phase) are solved during the same phase.

Planning and Scheduling:

TASK DESCRIPTION RESPONSIBILITIES


Requirement Study of existing system, Chirag Jain
Gathering advantages, working on it like Malhar Ghadiali
where automation is needed. Rohan Patil

Designing User interface form, Malhar Ghadiali


(Front End) User modification form etc.
Designing Table Designing: Deciding Columns, Chirag Jain
(Back End) Data types etc. Rohan Patil

Coding Coding using c# in Visual Studio Chirag Jain


Malhar Ghadiali
Rohan Patil

Testing Testing each and every module. Malhar Ghadiali


Rohan Patil

Documentation Generating timely reports regarding Chirag Jain


activities.

17 | P a g e
- Gantt Chart:

18 | P a g e
- Use Case Diagram

A use case is a description of a sequence of actions, including variants, which a


system performs to yield an observable result of values to an actor.

19 | P a g e
-

20 | P a g e
Entity Relationship Diagram

21 | P a g e
22 | P a g e
- Activity Diagram

23 | P a g e
- Data Flow Diagram

DFD graphically represents the functions, or processes, which capture, manipulate, store,
and distribute data between a system and its environment and between components of a
system. The visual representation makes it a good communication tool between User and
System designer.

The DFD also provides information about the outputs and inputs of each entity and the
process itself. A data-flow diagram has no control flow, there are no decision rules and no
loops. Specific operations based on the data can be represented by a flowchart. Structure of
DFD allows starting from a broad overview and expand it to a hierarchy of detailed
diagrams. DFD has often been used due to the following reasons:

• Logical information flow of the system


• Determination of physical system construction requirements
• Simplicity of notation
• Establishment of manual and automated systems requirements

1) Context Level DFD

24 | P a g e
2) Level-1 DFD

3) Level-2 DFD

25 | P a g e
Chapter 4
Database Design
Microsoft SQL is a popular Relational Database Management System (RDBMS) developed by
Microsoft. Being a database server, its primary function is to store and retrieve the data as
and when requested by other software applications.

WHY MS SQL?
- Installation is streamlined
- Security Features are Better
- Enhanced Performance

Database Normalization
Normalization is a technique of separating redundant fields and breaking up a large table
into smaller ones. All the tables have been normalized up to the second normal form.

Normalization is the process of simplifying the relationship between the data elements in
the record. Through this technique, a collection of the data in a record structure is replaced
by successive record structure that is simpler and more predictable and therefore more
manageable.

Normalization is carried for following reasons:

▪ To structure the data so that any pertinent relationship between entities can be
represented.
▪ To permit simple retrieval of data in response to query and report requests.
▪ To simplify the maintenance of the data through updates, insertions and
deletions…
▪ To reduce the need to restructure or recognize data when new application
requirements arise.
▪ These attempts to remove redundant data avoid data inconsistencies and
prevent update anomalies. This results in a simpler or more natural data model.
A normalized database more clearly reflects the entities and relationships in the
real world.

Relational data theory outlines five normal forms, of which three normal forms are used
popularly for designing for designing relation tables.

The rules and methods of first three normal forms are given below.

26 | P a g e
1. FIRST NORMAL FORM (1NF)

A relation is said to be in 1NF if all the underline domain of attributes contains simple
indivisible values.

2. SECOND NORMAL FORM (2NF)

The 2NF is based on the concept of full functional dependency. A relation is said to be in
2NF and every non key attribute is functionally dependency on candidate key of the table.

3. THIRD NORMAL FORM (3NF)

The 3NF is based on the concept of transitive dependency. A relation in 2NF is said to be in
3NF if every non key attribute is non-transitively dependent on the primary key.

DATA-DICTIONARY

After carefully understanding the requirements of the client, the entire data storage
requirements are divided into tables. The below tables are normalized to avoid any
anomalies during the course of data entry.

Layout of the Backend:

27 | P a g e
Employee Master Table

Login Master Table

Department Master Table

Pin code Master Table

28 | P a g e
Customer Master Table

Supplier Master Table

29 | P a g e
Broker Master Table

Product Master Table

Transaction Master Table

30 | P a g e
PO Master Table

PO Product Master Table

31 | P a g e
SO Master Table

SO Product Master Table

32 | P a g e
Stock Master Table

STORED PROCEDURES:

- Purchase Order Details Procedure:

- Sales Order Details

33 | P a g e
- Purchase Order Between Range:

- Sales Order Between Range:

- STOCK Report

34 | P a g e
- SMS Procedure

1. ALTER procedure [dbo].[SSendSmsSQLP]


2. @MobileNo varchar(12),
3. @smstext as varchar(300),
4. @sResponse varchar(1000)
5. as
6. BEGIN
7. Declare @iReq int,@hr int
8. Declare @sUrl as varchar(500)
9. DECLARE @errorSource VARCHAR(8000)
10. DECLARE @errorDescription VARCHAR(8000)
11.
12. EXEC @hr = sp_OACreate 'Microsoft.XMLHTTP', @iReq OUT
13.
14. --print @hr
15.
16. IF @hr <> 0
17. Raiserror('sp_OACreate Microsoft.XMLHTTP FAILED!', 16, 1)
18. SET @smstext = REPLACE(@smstext, '&', '%26')
19. SET @smstext = REPLACE(@smstext, ' ', '%20')
20. SET @sUrl= 'http://alots.in/sms-
panel/api/http/index.php?username=PRINCE&apikey=E1588-
7021D&apirequest=Text&sender=CRMERP&mobile=@MobileNo&message=@Text&route=TR
ANS&format=JSON'
21.
22.
23. SET @sUrl=REPLACE(@sUrl,'@MobileNo',@MobileNo)
24. SET @sUrl=REPLACE(@sUrl,'@Text',@smstext)
25. EXEC @hr = sp_OAMethod @iReq, 'Open', NULL, 'GET', @sUrl, true
26. IF @hr <> 0
27. Raiserror('sp_OAMethod Open FAILED!', 16, 1)
28. EXEC @hr = sp_OAMethod @iReq, 'send'
29.
30. IF @hr <> 0
31. BEGIN
32. EXEC sp_OAGetErrorInfo @iReq, @errorSource OUTPUT, @errorDescrip
tion OUTPUT
33. SELECT [Error Source] = @errorSource, [Description] = @errorDesc
ription
34. Raiserror('sp_OAMethod Send FAILED!', 16, 1)
35. END
36. ELSE
37. BEGIN
38. EXEC @hr = sp_OAGetProperty @iReq,'responseText', @sResponse
39. END
40. END

35 | P a g e
Chapter 5
Coding and implementation

- Login Form

1) namespace CRMERP
2) {
3) public partial class loginform : Form
4) {
5) internal static string name;
6) Boolean b = true;
7) public loginform()
8) {
9) InitializeComponent();
10)
11) }
12) private void loginform_Load(object sender, EventArgs e)
13) {
14) bool con = NetworkInterface.GetIsNetworkAvailable();
15) if (con == false)
16) {
17) MessageBox.Show("Internet connection not available", "CRM-ERP");
18) Application.Exit();
19) }
20) }
21) private void button1_Click(object sender, EventArgs e)
22) {
23)
24) String username = bunifuMaterialTextbox1.Text.Trim();
25) String pass = textBox1.Text.Trim();
26) SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
27) string q = "Select * from LoginMaster where Username='" + @username + "
' and Password='" + @pass + "'";

36 | P a g e
28) con.Open();
29) SqlCommand cmd = new SqlCommand(q, con);
30) SqlDataReader r = cmd.ExecuteReader();
31)
32) decimal id;
33) if (r.HasRows)
34) {
35) while (r.Read())
36) {
37) name = r["EmpName"].ToString();
38) id = (decimal)r["EmpID"];
39) }
40) this.Hide();
41) home h = new home();
42) h.Closed += (s, args) => this.Close();
43) h.Show();
44) }
45) else
46) {
47) MessageBox.Show("Invalid Username or Password", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
48) }
49) con.Close();
50) }
51) private void pass_hover(object sender, EventArgs e)
52) {
53) panel2.BackColor = Color.CornflowerBlue;
54) }
55)
56) private void pass_leave(object sender, EventArgs e)
57) {
58) panel2.BackColor = Color.White;
59)
60) }
61)
62) private void pass_hover(object sender, MouseEventArgs e)
63) {
64) panel2.BackColor = Color.CornflowerBlue;
65)
66) }
67)
68) private void panel1_Paint(object sender, PaintEventArgs e)
69) { }
70) private void button3_Click(object sender, EventArgs e)
71) {
72) if(textBox1.UseSystemPasswordChar==true || b==true)
73) {
74) textBox1.UseSystemPasswordChar = false;
75) b = false;
76)
77) }
78) else if(b==false)
79) {
80) textBox1.UseSystemPasswordChar = true;
81) b = true;
82) }
83)
84) }
85) private void label4_Click(object sender, EventArgs e)
86) {
87) if (bunifuMaterialTextbox1.Text == null)
88) {
89) MessageBox.Show("Enter username", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
90) bunifuMaterialTextbox1.Focus();
91) }

37 | P a g e
92) else
93) {
94) SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
95) string q = "Select * from LoginMaster where Username='" + bunifuMat
erialTextbox1.Text + "';";
96) con.Open();
97) SqlCommand cmd = new SqlCommand(q, con);
98) SqlDataReader r = cmd.ExecuteReader();
99) while (r.Read())
100) {
101) name = r["EmpName"].ToString();
102) }
103) r.Close();
104) resetpassword h = new resetpassword();
105) h.Closed += (s, args) => this.Close();
106) h.Show();
107) }
108) }
109)
110) private void forgetpassword_hover(object sender, EventArgs e)
111) {
112) label4.ForeColor = Color.CornflowerBlue;
113)
114) }
115) }
116) }

- Reset Password Form

38 | P a g e
1. using System;
2. using System.Collections.Generic;
3. using System.ComponentModel;
4. using System.Data;
5. using System.Data.SqlClient;
6. using System.Drawing;
7. using System.Linq;
8. using System.Text;
9. using System.Threading;
10. using System.Threading.Tasks;
11. using System.Windows.Forms;
12. namespace CRMERP
13. {
14. public partial class resetpassword : Form
15. {
16. int otp;
17. string username;
18. string mobno;
19. public resetpassword()
20. {
21. InitializeComponent();
22. }
23. public int GenerateRandomNo()
24. {
25. int _min = 1000;
26. int _max = 9999;
27. Random _rdm = new Random();
28. return _rdm.Next(_min, _max);
29. }
30. public String sendMsg(String username,String text)
31. {
32. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
33.
34. con.Open();
35.
36. string s = "select * from LoginMaster where EmpName='" + username + "';
";
37. SqlCommand cmd2 = new SqlCommand(s, con);
38.
39. SqlDataReader dr = cmd2.ExecuteReader();
40. while (dr.Read())
41. {
42. mobno = dr["MobileNo"].ToString();
43. }
44.
45. dr.Close();
46.
47. SqlCommand cmd = new SqlCommand("SSendSmsSQLP", con);
48. cmd.CommandType = CommandType.StoredProcedure;
49. cmd.Parameters.Add("@MobileNo", SqlDbType.VarChar).Value = mobno;
50. cmd.Parameters.Add("@smstext", SqlDbType.VarChar).Value = text;
51. cmd.Parameters.Add("@sResponse", SqlDbType.VarChar).Value = "test";
52.
53. cmd.ExecuteNonQuery();
54. con.Close();
55. return mobno;
56.
57. }
58. private void resetpassword_Load(object sender, EventArgs e)
59. {
60. panel1.Enabled = false;
61. username = loginform.name;
62. string mobno = "";
63. otp = GenerateRandomNo();
64. // string text = "Hey '" + username + "', your OTP is '" + otp + "'";

39 | P a g e
65. string text = "Hey, " + username + ", use this OTP " + otp + ", to chan
ge your password.";
66. mobno=sendMsg(username, text);
67. char[] str = mobno.ToArray();
68. label5.Text = "******" + str[6] + str[7] + str[8] + str[9];
69. }
70. private void button1_Click(object sender, EventArgs e)
71. {
72. if(textBox1.Text!=null && textBox3.Text!=null)
73. {
74. if(textBox3.Text == textBox1.Text)
75. {
76. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
77. con.Open();
78. string s = "update LoginMaster set Password=@t1 where EmpName='"
+username+"'";
79. SqlCommand cmd2 = new SqlCommand(s, con);
80. cmd2.Parameters.AddWithValue("@t1", textBox3.Text);
81. cmd2.ExecuteNonQuery();
82. MessageBox.Show("Password changed successfully", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
83. con.Close();
84. string p = "The password of your CRMERP account has been change
d successfully.";
85. sendMsg(username, p);
86. this.Hide();
87. }
88. }
89. else
90. {
91. MessageBox.Show("Please enter password", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
92. }
93. }
94.
95. private void button2_Click(object sender, EventArgs e)
96. {
97. if(decimal.Parse(textBox2.Text)==otp)
98. {
99. label8.Visible = true;
100. label8.ForeColor = Color.Green;
101. label8.Text = "OTP matched";
102. panel1.Enabled = true;
103. }
104. else
105. {
106. label8.Visible = true;
107. label8.ForeColor = Color.Red;
108. label8.Text = "OTP didn't match";
109. }
110. }
111. private void password_leave(object sender, EventArgs e)
112. {
113. if(textBox3.Text==textBox1.Text)
114. {
115. label7.Visible = true;
116. label7.ForeColor = Color.Green;
117. label7.Text = "Password matched";
118. button1.Enabled = true;
119. }
120. if (textBox3.Text != textBox1.Text)
121. {
122. label7.Visible = true;
123. label7.ForeColor = Color.Red;
124. label7.Text = "Password didn't match";

40 | P a g e
125. button1.Enabled = false;
126. }
127. }
128.
129.
130. }
131. }

- Home (Dashboard)

41 | P a g e
1. using System;
2. namespace CRMERP
3. {
4. public partial class home : Form
5. {
6. internal static string table_name;
7. public home()
8. {
9. InitializeComponent();
10.
11. }
12. private void Form1_Load(object sender, EventArgs e)
13. {
14. // bunifuFormFadeTransition1.ShowAsyc(this);
15. PopulateRssFeed();
16.
17. this.WindowState = FormWindowState.Maximized;
18. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
19. con.Open();
20. int d = 0;
21.
22. label3.Text = loginform.name;
23.
24. string q = "Select count(*) from EmpMaster";
25. SqlCommand cmd = new SqlCommand(q, con);
26. d = (int)cmd.ExecuteScalar();
27. label6.Text = d.ToString();
28.
29. string q1 = "Select count(*) from DeptMaster";
30. SqlCommand cmd1 = new SqlCommand(q1, con);
31. int d1 = (int)cmd1.ExecuteScalar();
32. label9.Text = d1.ToString();
33.
34. string q2 = "Select count(*) from DesigMaster";
35. SqlCommand cmd2 = new SqlCommand(q2, con);
36. int d2 = (int)cmd2.ExecuteScalar();
37. label11.Text = d2.ToString();
38.
39. string q3 = "Select count(*) from SuppMaster";
40. SqlCommand cmd3 = new SqlCommand(q3, con);
41. int d3 = (int)cmd3.ExecuteScalar();
42. label21.Text = d3.ToString();
43.
44. string q4 = "Select count(*) from CustMaster";
45. SqlCommand cmd4 = new SqlCommand(q4, con);
46. int d4 = (int)cmd4.ExecuteScalar();
47. label23.Text = d4.ToString();
48.
49. }
50. private void viewFun()
51. {
52. Form1 h = new Form1();
53. h.Closed += (s, args) => this.Close();
54. h.Show();
55. }
56.
57. private void label1_Click(object sender, EventArgs e)
58. {
59.
60. }
61.
62. private void button1_Click(object sender, EventArgs e)
63. {
64. if (MessageBox.Show("Are you sure you want to exit?", "CRM ERP", Messag
eBoxButtons.OKCancel) == DialogResult.OK)

42 | P a g e
65. {
66. Application.Exit();
67. }
68. }
69.
70. private void button2_Click(object sender, EventArgs e)
71. {
72. this.WindowState = FormWindowState.Minimized;
73. }
74.
75. private void button5_Click(object sender, EventArgs e)
76. {
77. this.Hide();
78. masters m = new masters();
79. m.Show();
80. }
81. private void button14_Click(object sender, EventArgs e)
82. {
83. companyprofile cp = new companyprofile();
84. cp.Show();
85. }
86.
87. private void logout(object sender, EventArgs e)
88. {
89. this.Hide();
90. loginform h = new loginform();
91. h.Closed += (s, args) => this.Close();
92. h.Show();
93. }
94. private void PopulateRssFeed()
95. {
96. string RssFeedUrl = "http://feeds.feedburner.com/NDTV-LatestNews";
97. List<Class1> feeds = new List<Class1>();
98.
99. try
100. {
101. XDocument xDoc = new XDocument();
102. xDoc = XDocument.Load(RssFeedUrl);
103. var items = (from x in xDoc.Descendants("item")
104. select new
105. {
106. title = x.Element("title").Value,
107. link = x.Element("link").Value,
108. pubDate = x.Element("pubDate").Value,
109. description = x.Element("description").Value

110. });
111. if (items != null)
112. {
113. foreach (var i in items)
114. {
115. ;
116. Class1 f = new Class1
117. {
118. Title = i.title,
119. Link = i.link,
120. PublishDate = i.pubDate,
121. Description = i.description
122. };
123. feeds.Add(f);
124.
125. }
126. }
127. dataGridView1.DataSource = feeds;
128. int k = 0;

43 | P a g e
129. Label[] lray = { label25, linkLabel26, label27, label28,labe
l30,linkLabel1,label26,label29,label33,linkLabel2, label31, label32, label42, linkL
abel5, label40, label41, label48, linkLabel7, label46, label47 };
130.
131. for (int i = 0; i < 5; i++)
132. {
133. for (int j = 0; j < 4; j++)
134. {
135.
136. if (k < 20)
137. {
138. lray[k].Text = dataGridView1.Rows[i].Cells[j].Va
lue.ToString();
139. k = k + 1;
140. }
141. }
142. }
143.
144. linkLabel26.Text = "Read more..";
145. linkLabel1.Text = "Read more..";
146. linkLabel2.Text = "Read more..";
147. linkLabel5.Text = "Read more..";
148. linkLabel7.Text = "Read more..";
149.
150. String Text = dataGridView1.Rows[0].Cells[3].Value.ToString(
);
151.
152. String[] str_array = Text.Split('<');
153. String stringa = str_array[0];
154. String stringb = str_array[1];
155.
156. label28.Text = stringa;
157.
158. Text = dataGridView1.Rows[1].Cells[3].Value.ToString();
159.
160. str_array = Text.Split('<');
161. stringa = str_array[0];
162. stringb = str_array[1];
163.
164. label29.Text = stringa;
165.
166. Text = dataGridView1.Rows[2].Cells[3].Value.ToString();
167.
168. str_array = Text.Split('<');
169. stringa = str_array[0];
170. stringb = str_array[1];
171.
172. label32.Text = stringa;
173.
174. Text = dataGridView1.Rows[3].Cells[3].Value.ToString();
175.
176. str_array = Text.Split('<');
177. stringa = str_array[0];
178. stringb = str_array[1];
179.
180. label41.Text = stringa;
181.
182. Text = dataGridView1.Rows[4].Cells[3].Value.ToString();
183.
184. str_array = Text.Split('<');
185. stringa = str_array[0];
186. stringb = str_array[1];
187.
188. label47.Text = stringa;
189.
190. }

44 | P a g e
191. catch (Exception ex)
192. {
193. MessageBox.Show("No Internet Connection");
194. Application.Exit();
195. }
196. }
197.
198. private void linkLabel26_LinkClicked(object sender, LinkLabelLinkCli
ckedEventArgs e)
199. {
200. linkLabel26.LinkVisited = true;
201. System.Diagnostics.Process.Start(dataGridView1.Rows[0].Cells[1].
Value.ToString());
202. }
203.
204. private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClic
kedEventArgs e)
205. {
206. linkLabel1.LinkVisited = true;
207. System.Diagnostics.Process.Start(dataGridView1.Rows[1].Cells[1].
Value.ToString());
208.
209.
210. }
211.
212. private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClic
kedEventArgs e)
213. {
214. linkLabel1.LinkVisited = true;
215. System.Diagnostics.Process.Start(dataGridView1.Rows[2].Cells[1].
Value.ToString());
216.
217. }
218.
219. private void linkLabel5_LinkClicked(object sender, LinkLabelLinkClic
kedEventArgs e)
220. {
221. linkLabel1.LinkVisited = true;
222. System.Diagnostics.Process.Start(dataGridView1.Rows[3].Cells[1].
Value.ToString());
223.
224. }
225.
226. private void linkLabel7_LinkClicked(object sender, LinkLabelLinkClic
kedEventArgs e)
227. {
228. linkLabel1.LinkVisited = true;
229. System.Diagnostics.Process.Start(dataGridView1.Rows[4].Cells[1].
Value.ToString());
230.
231. }
232.
233. private void button6_Click(object sender, EventArgs e)
234. {
235. purchase pc = new purchase();
236. pc.Show();
237. }
238.
239. private void button15_Click_1(object sender, EventArgs e)
240. {
241. table_name = "EmpMaster";
242. viewFun();
243. }
244.
245. private void button16_Click(object sender, EventArgs e)
246. {

45 | P a g e
247. table_name = "DeptMaster";
248. viewFun();
249. }
250.
251. private void button17_Click(object sender, EventArgs e)
252. {
253. table_name = "DesigMaster";
254. viewFun();
255. }
256.
257. private void button21_Click(object sender, EventArgs e)
258. {
259. table_name = "CustMaster";
260. viewFun();
261. }
262.
263. private void button20_Click(object sender, EventArgs e)
264. {
265. table_name = "SuppMaster";
266. viewFun();
267. }
268.
269. private void button7_Click(object sender, EventArgs e)
270. {
271. salesorder pc = new salesorder();
272. pc.Show();
273. }
274. }
275. }

46 | P a g e
- Master Form

1. namespace CRMERP
2. {
3. public partial class masters : Form
4. {
5. public masters()
6. {
7. InitializeComponent();
8. }
9. private void masters_Load(object sender, EventArgs e)
10. {
11. bunifuFormFadeTransition1.ShowAsyc(this);
12.
13. this.WindowState = FormWindowState.Maximized;
14. }
15.
16. private void label2_Click(object sender, EventArgs e)
17. {
18. employeemaster em = new employeemaster();
19. em.Show();
20. }
21.
22. private void button1_Click(object sender, EventArgs e)
23. {
24. this.Hide();
25. home h = new home();
26. h.Closed += (s, args) => this.Close();
27. h.Show();
28. }
29.
30. private void button3_Click(object sender, EventArgs e)
31. {
32. pmaster pm = new pmaster();
33. pm.Show();

47 | P a g e
34. }
35. private void button6_Click(object sender, EventArgs e)
36. {
37. employeemaster em = new employeemaster();
38. em.Show();
39. }
40.
41. private void button5_Click(object sender, EventArgs e)
42. {
43. employeemaster em = new employeemaster();
44. em.Show();
45. }
46.
47. private void button9_Click(object sender, EventArgs e)
48. {
49. suppliermaster sm = new suppliermaster();
50. sm.Show();
51. }
52.
53. private void button12_Click(object sender, EventArgs e)
54. {
55. customermaster cm = new customermaster();
56. cm.Show();
57. }
58.
59. private void button8_Click(object sender, EventArgs e)
60. {
61. brokermaster bm = new brokermaster();
62. bm.Show();
63. }
64.
65. private void button19_Click(object sender, EventArgs e)
66. {
67. departmentmaster dm = new departmentmaster();
68. dm.Show();
69. }
70.
71. private void button22_Click(object sender, EventArgs e)
72. {
73. designationmaster dm = new designationmaster();
74. dm.Show();
75. }
76.
77. }
78. }

48 | P a g e
- Employee Master Form

49 | P a g e
1. namespace CRMERP
2. {
3. public partial class employeemaster : Form
4. {
5. public employeemaster()
6. {
7. InitializeComponent();
8. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
9.
10. con.Open();
11. string Sql = "select distinct DeptName from DeptMaster";
12. SqlCommand cmd = new SqlCommand(Sql, con);
13. SqlDataReader DR = cmd.ExecuteReader();
14.
15. while (DR.Read())
16. {
17. EmpDept.Items.Add(DR[0]);
18.
19. }
20. con.Close();
21. con.Open();
22. Sql = "select distinct DesigName from DesigMaster";
23. cmd = new SqlCommand(Sql, con);
24. DR = cmd.ExecuteReader();
25.
26. while (DR.Read())
27. {
28. EmpDesignation.Items.Add(DR[0]);
29.
30. }
31.
32. con.Close();
33. EmpFName.KeyPress += new KeyPressEventHandler(richTextBox1_KeyPress);
34. EmpMName.KeyPress += new KeyPressEventHandler(richTextBox1_KeyPress);
35. EmpLName.KeyPress += new KeyPressEventHandler(richTextBox1_KeyPress);
36.
37. }
38. void richTextBox1_KeyPress(object sender, KeyPressEventArgs e)
39. {
40. e.KeyChar = Char.ToUpper(e.KeyChar);
41. }
42.
43. private void button1_Click(object sender, EventArgs e)
44. {
45. this.Close();
46. }
47. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
48.
49. private void employeemaster_Load(object sender, EventArgs e)
50. {
51. bunifuFormFadeTransition1.ShowAsyc(this);
52. dataGridView1.ReadOnly = true;
53. this.WindowState = FormWindowState.Maximized;
54. con.Open();
55. string query = "select EmpID,EmpFName,EmpMName,EmpLName,EmpMobileNo1,Em
pEmailID1,EmpDept1 from EmpMaster";
56.
57. DataSet ds = new DataSet();
58. SqlDataAdapter dap = new SqlDataAdapter(query, con);
59. dap.Fill(ds);
60.
61. dataGridView1.DataSource = ds.Tables[0];
62.
63. con.Close();

50 | P a g e
64. }
65.
66. private void button2_Click(object sender, EventArgs e)
67. {
68. con.Open();
69.
70. string q = "update EmpMaster set EmpID=@t1,EmpFName=@t2,EmpMName=@t3,Em
pLName=@t4,EmpDOB=@t5,EmpMobileNo1=@t6,EmpMobileNo2=@t7,EmpEmailID1=@t8,EmpEmailID2
=@t9,Address1=@t10,Address2=@t11,Landmark=@t12,Pincode=@t13,City=@t14,State=@t15,Co
untry=@t16,EmpDept1=@t17,EmpDept2=@t18,EntryID=@t20,PAN_No=@t21,Aadhar_No=@t22 wher
e EmpID=@t1";
71.
72. SqlCommand cmd = new SqlCommand(q, con);
73. cmd.Parameters.AddWithValue("@t1", decimal.Parse(EmpID.Text));
74. cmd.Parameters.AddWithValue("@t2", (EmpFName.Text));
75. cmd.Parameters.AddWithValue("@t3", (EmpMName.Text));
76. cmd.Parameters.AddWithValue("@t4", (EmpLName.Text));
77. cmd.Parameters.AddWithValue("@t5", (EmpDOB.Value.Date));
78. cmd.Parameters.AddWithValue("@t6", decimal.Parse(EmpMobile1.Text));
79. cmd.Parameters.AddWithValue("@t7", (EmpMobile2.Text));
80. cmd.Parameters.AddWithValue("@t8", (EmpEmailID1.Text));
81. cmd.Parameters.AddWithValue("@t9", (EmpEmailID2.Text));
82. cmd.Parameters.AddWithValue("@t10", (Address1.Text));
83. cmd.Parameters.AddWithValue("@t11", (Address2.Text));
84. cmd.Parameters.AddWithValue("@t12", (Landmark.Text));
85. cmd.Parameters.AddWithValue("@t13", decimal.Parse(Pincode.Text));
86. cmd.Parameters.AddWithValue("@t14", (City.Text));
87. cmd.Parameters.AddWithValue("@t15", (State.Text));
88. cmd.Parameters.AddWithValue("@t16", (Country.Text));
89. cmd.Parameters.AddWithValue("@t17", (EmpDept.Text));
90. cmd.Parameters.AddWithValue("@t18", (EmpDesignation.Text));
91. cmd.Parameters.AddWithValue("@t20", (11));
92. cmd.Parameters.AddWithValue("@t21", (Emp_PAN_No.Text));
93. cmd.Parameters.AddWithValue("@t22", decimal.Parse(Emp_Aadhar_No.Text));

94. cmd.ExecuteNonQuery();
95. con.Close();
96. MessageBox.Show("Data Updated");
97. string query = "select * from EmpMaster";
98.
99. DataSet ds = new DataSet();
100. SqlDataAdapter dap = new SqlDataAdapter(query, con);
101. dap.Fill(ds);
102.
103. dataGridView1.DataSource = ds.Tables[0];
104.
105. con.Close();
106. button7_Click(sender, e);
107. }
108. private void Save_Click(object sender, EventArgs e)
109. {
110. if (string.IsNullOrWhiteSpace(EmpID.Text) || string.IsNullOrWhit
eSpace(EmpFName.Text) || string.IsNullOrWhiteSpace(EmpDOB.Value.Date.ToString()) ||
string.IsNullOrWhiteSpace(EmpMobile1.Text) || string.IsNullOrWhiteSpace(EmpEmailID
1.Text) || string.IsNullOrWhiteSpace(Pincode.Text) || string.IsNullOrWhiteSpace(Emp
_Aadhar_No.Text) || string.IsNullOrWhiteSpace(Emp_PAN_No.Text))
111. {
112. MessageBox.Show("Enter Valid Record", "Error");
113. }
114. else
115. {
116.
117. con.Open();
118.
119. decimal t1 = decimal.Parse(EmpID.Text);

51 | P a g e
120. string q = "select * from EmpMaster where EmpID='" + @t1 + "
'";
121.
122. SqlCommand cmd = new SqlCommand(q, con);
123. SqlDataReader myreader = cmd.ExecuteReader();
124. if (myreader.HasRows)
125. {
126. MessageBox.Show("Employee ID is already taken", "Error")
;
127. }
128. else
129. {
130. myreader.Close();
131. string q1 = "insert into EmpMaster values (@t1,@t2,@t3,@
t4,@t5,@t6,@t7,@t8,@t9,@t10,@t11,@t12,@t13,@t14,@t15,@t16,@t17,@t18,@t20,@t21,@t22)
";
132.
133. cmd = new SqlCommand(q1, con);
134.
135. cmd.Parameters.AddWithValue("@t1", decimal.Parse(EmpID.T
ext));
136. cmd.Parameters.AddWithValue("@t2", (EmpFName.Text));
137. cmd.Parameters.AddWithValue("@t3", (EmpMName.Text));
138. cmd.Parameters.AddWithValue("@t4", (EmpLName.Text));
139. cmd.Parameters.AddWithValue("@t5", (EmpDOB.Value.Date));

140. cmd.Parameters.AddWithValue("@t6", decimal.Parse(EmpMobi


le1.Text));
141. cmd.Parameters.AddWithValue("@t7", (EmpMobile2.Text));
142. cmd.Parameters.AddWithValue("@t8", (EmpEmailID1.Text));

143. cmd.Parameters.AddWithValue("@t9", (EmpEmailID2.Text));

144. cmd.Parameters.AddWithValue("@t10", (Address1.Text));


145. cmd.Parameters.AddWithValue("@t11", (Address2.Text));
146. cmd.Parameters.AddWithValue("@t12", (Landmark.Text));
147. cmd.Parameters.AddWithValue("@t13", decimal.Parse(Pincod
e.Text));
148. cmd.Parameters.AddWithValue("@t14", (City.Text));
149. cmd.Parameters.AddWithValue("@t15", (State.Text));
150. cmd.Parameters.AddWithValue("@t16", (Country.Text));
151. cmd.Parameters.AddWithValue("@t17", (EmpDept.Text));
152. cmd.Parameters.AddWithValue("@t18", (EmpDesignation.Text
));
153.
154. cmd.Parameters.AddWithValue("@t20", (11));
155. cmd.Parameters.AddWithValue("@t21", (Emp_PAN_No.Text));

156. cmd.Parameters.AddWithValue("@t22", decimal.Parse(Emp_Aa


dhar_No.Text));
157.
158. cmd.ExecuteNonQuery();
159. con.Close();
160. MessageBox.Show("Data Inserted");
161. string query = "select * from EmpMaster";
162.
163. DataSet ds = new DataSet();
164. SqlDataAdapter dap = new SqlDataAdapter(query, con);
165. dap.Fill(ds);
166.
167. dataGridView1.DataSource = ds.Tables[0];
168.
169. con.Close();
170. }
171. }
172. }

52 | P a g e
173. private void Delete_Click(object sender, EventArgs e)
174. {
175. con.Open();
176. decimal t1 =decimal.Parse(EmpID.Text);
177.
178. string q = "select * from EmpMaster where EmpID='" + @t1 + "'";

179.
180. SqlCommand cmd = new SqlCommand(q, con);
181. SqlDataReader myreader = cmd.ExecuteReader();
182. if (myreader.HasRows)
183. {
184. myreader.Close();
185. q = "delete from EmpMaster where EmpID=@t1";
186. cmd = new SqlCommand(q, con);
187.
188. cmd.Parameters.AddWithValue("@t1", int.Parse(EmpID.Text));
189. cmd.ExecuteNonQuery();
190. con.Close();
191. MessageBox.Show("Data Deleted");
192.
193. EmpID.Text = "";
194. EmpFName.Text = "";
195. EmpMName.Text = "";
196. EmpLName.Text = "";
197. EmpDOB.Text = "";
198. EmpMobile1.Text = "";
199. EmpMobile2.Text = "";
200. EmpEmailID1.Text = "";
201. EmpEmailID2.Text = "";
202. Address1.Text = "";
203. Address2.Text = "";
204. Landmark.Text = "";
205. Pincode.Text = "";
206. City.Text = "";
207. State.Text = "";
208. Country.Text = "";
209. EmpDept.Text = "";
210. EmpDesignation.Text = "";
211. Emp_PAN_No.Text = "";
212. Emp_Aadhar_No.Text = "";
213. string query = "select * from EmpMaster";
214.
215. DataSet ds = new DataSet();
216. SqlDataAdapter dap = new SqlDataAdapter(query, con);
217. dap.Fill(ds);
218.
219. dataGridView1.DataSource = ds.Tables[0];
220. }
221. else
222. {
223. MessageBox.Show("Employee ID not found", "Error");
224.
225. }
226. con.Close();
227. }
228.
229. private void button7_Click(object sender, EventArgs e)
230. {
231. SqlCommand cmd;
232.
233. con.Open();
234.
235. if (string.IsNullOrWhiteSpace(EmpID.Text))
236. {
237. MessageBox.Show("Enter Employee ID");

53 | P a g e
238. }
239. else
240. {
241. decimal t1 = decimal.Parse(EmpID.Text);
242. string q = "select * from EmpMaster where EmpID='" + @t1 + "
'";
243.
244. cmd = new SqlCommand(q, con);
245. SqlDataReader myreader = cmd.ExecuteReader();
246.
247. if (myreader.HasRows)
248. {
249. while (myreader.Read())
250. {
251. EmpID.Text = myreader["EmpID"].ToString();
252. EmpFName.Text = myreader["EmpFName"].ToString();
253. EmpMName.Text = myreader["EmpMName"].ToString();
254. EmpLName.Text = myreader["EmpLName"].ToString();
255. EmpDOB.Text = myreader["EmpDOB"].ToString();
256. EmpMobile1.Text = myreader["EmpMobileNo1"].ToString(
);
257. EmpMobile2.Text = myreader["EmpMobileNo2"].ToString(
);
258. EmpEmailID1.Text = myreader["EmpEmailID1"].ToString(
);
259. EmpEmailID2.Text = myreader["EmpEmailID2"].ToString(
);
260. Address1.Text = myreader["Address1"].ToString();
261. Address2.Text = myreader["Address2"].ToString();
262. Landmark.Text = myreader["Landmark"].ToString();
263. Pincode.Text = myreader["Pincode"].ToString();
264. City.Text = myreader["City"].ToString();
265. State.Text = myreader["State"].ToString();
266. Country.Text = myreader["Country"].ToString();
267. EmpDept.Text = myreader["EmpDept1"].ToString();
268. EmpDesignation.Text = myreader["EmpDept2"].ToString(
);
269. Emp_PAN_No.Text = myreader["PAN_No"].ToString();
270. Emp_Aadhar_No.Text = myreader["Aadhar_No"].ToString(
);
271. }
272. }
273. else
274. {
275. MessageBox.Show("Employee ID not found");
276.
277. }
278. con.Close();
279. }
280. }
281. private void button5_Click(object sender, EventArgs e)
282. {
283. SqlCommand cmd;
284. con.Open();
285. int t1 = int.Parse(EmpID.Text);
286. string sql = "Select * from EmpMaster where EmpID='" + @t1 + "';
";
287. cmd = new SqlCommand(sql, con);
288. using (SqlDataReader myreader = cmd.ExecuteReader())
289. {
290. myreader.NextResult();
291. while (myreader.Read())
292. {
293. EmpID.Text = myreader["EmpID"].ToString();
294. EmpFName.Text = myreader["EmpFName"].ToString();
295. EmpMName.Text = myreader["EmpMName"].ToString();

54 | P a g e
296. EmpLName.Text = myreader["EmpLName"].ToString();
297. EmpDOB.Text = myreader["EmpDOB"].ToString();
298. EmpMobile1.Text = myreader["EmpMobileNo1"].ToString();
299. EmpMobile2.Text = myreader["EmpMobileNo2"].ToString();
300. EmpEmailID1.Text = myreader["EmpEmailID1"].ToString();
301. EmpEmailID2.Text = myreader["EmpEmailID2"].ToString();
302. Address1.Text = myreader["Address1"].ToString();
303. Address2.Text = myreader["Address2"].ToString();
304. Landmark.Text = myreader["Landmark"].ToString();
305. Pincode.Text = myreader["Pincode"].ToString();
306. City.Text = myreader["City"].ToString();
307. State.Text = myreader["State"].ToString();
308. Country.Text = myreader["Country"].ToString();
309. EmpDept.Text = myreader["EmpDept1"].ToString();
310. EmpDesignation.Text = myreader["EmpDept2"].ToString();
311. Emp_PAN_No.Text = myreader["PAN_No"].ToString();
312. Emp_Aadhar_No.Text = myreader["Aadhar_No"].ToString();
313. }
314. }
315. con.Close();
316. }
317.
318. private void empid_validate(object sender, EventArgs e)
319. {
320. if (string.IsNullOrWhiteSpace(EmpID.Text))
321. {
322.
323. errorProvider1.SetError(EmpID, "Please Enter the Value!");
324.
325. }
326. else
327. {
328. errorProvider1.SetError(EmpID, "");
329. Regex r = new Regex("^[0-9]+$");
330. if (r.IsMatch(EmpID.Text))
331. {
332. errorProvider1.SetError(EmpID, "");
333. }
334. else
335. {
336. errorProvider1.SetError(EmpID, "Please Enter Valid Input
!");
337. }
338.
339. }
340. }
341.
342. private void name_validate(object sender, EventArgs e)
343. {
344. if (string.IsNullOrWhiteSpace(EmpFName.Text))
345. {
346.
347. errorProvider1.SetError(EmpFName, "Name should not be left b
lank!");
348. }
349. else
350. {
351. errorProvider1.SetError(EmpFName, "");
352.
353. Regex r = new Regex("^[a-z A-Z]+$");
354. if (r.IsMatch(EmpFName.Text))
355. {
356. errorProvider1.SetError(EmpFName, "");
357. }
358. else
359. {

55 | P a g e
360. errorProvider1.SetError(EmpFName, "Please Enter Valid In
put!");
361. }
362. }
363. }
364. private void pin_validate(object sender, EventArgs e)
365. {
366. if (string.IsNullOrWhiteSpace(Pincode.Text))
367. {
368.
369. errorProvider1.SetError(Pincode, "Please Enter the Pincode!"
);
370.
371. }
372. else
373. {
374. errorProvider1.SetError(Pincode, "");
375.
376. Regex r = new Regex("^[1-9][0-9]{5}$");
377. if (r.IsMatch(Pincode.Text))
378. {
379. errorProvider1.SetError(Pincode, "");
380.
381. SqlCommand cmd;
382. SqlConnection con;
383.
384. con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
385. con.Open();
386. decimal t1 = decimal.Parse(Pincode.Text);
387. string q = "select * from pincode where pincode='" + @t1
+ "'";
388.
389. cmd = new SqlCommand(q, con);
390. SqlDataReader myreader = cmd.ExecuteReader();
391. if (myreader.HasRows)
392. {
393. while (myreader.Read())
394. {
395. City.Text = myreader["city"].ToString();
396. State.Text = myreader["state"].ToString();
397. Country.Text = "India";
398.
399. }
400. }
401. else
402. {
403. errorProvider1.SetError(Pincode, "Enter Proper Pinco
de");
404. }
405. con.Close();
406. }
407. else
408. {
409. errorProvider1.SetError(Pincode, "Please Enter Valid Inp
ut!");
410. }
411.
412. }
413. }
414.
415. private void mname_validate(object sender, EventArgs e)
416. {
417. if (string.IsNullOrWhiteSpace(EmpMName.Text))
418. {
419. errorProvider1.SetError(EmpMName, "");

56 | P a g e
420. }
421. else
422. {
423. errorProvider1.SetError(EmpMName, "");
424.
425. Regex r = new Regex("^[a-z A-Z]+$");
426. if (r.IsMatch(EmpMName.Text))
427. {
428. errorProvider1.SetError(EmpMName, "");
429. }
430. else
431. {
432. errorProvider1.SetError(EmpMName, "Please Enter Valid In
put!");
433. }
434. }
435. }
436.
437. private void lname_validate(object sender, EventArgs e)
438. {
439. if (string.IsNullOrWhiteSpace(EmpLName.Text))
440. {
441.
442. errorProvider1.SetError(EmpLName, "");
443. }
444. else
445. {
446. errorProvider1.SetError(EmpLName, "");
447.
448. Regex r = new Regex("^[a-z A-Z]+$");
449. if (r.IsMatch(EmpLName.Text))
450. {
451. errorProvider1.SetError(EmpLName, "");
452. }
453. else
454. {
455. errorProvider1.SetError(EmpLName, "Please Enter Valid In
put!");
456. }
457. }
458. }
459.
460. private void pan_validate(object sender, EventArgs e)
461. {
462. if (string.IsNullOrWhiteSpace(Emp_PAN_No.Text))
463. {
464.
465. errorProvider1.SetError(Emp_PAN_No, "Enter PAN Number!");
466. }
467. else
468. {
469. errorProvider1.SetError(Emp_PAN_No, "");
470.
471. Regex r = new Regex("^[a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}$");
472. if (r.IsMatch(Emp_PAN_No.Text))
473. {
474. errorProvider1.SetError(Emp_PAN_No, "");
475.
476. con.Open();
477. string t1 = (Emp_PAN_No.Text);
478. string q = "select * from EmpMaster where PAN_No='" + @t
1 + "'";
479.
480. SqlCommand cmd = new SqlCommand(q, con);
481. SqlDataReader d = cmd.ExecuteReader();
482. if(d.HasRows)

57 | P a g e
483. {
484. MessageBox.Show("PAN ID is already taken");
485. errorProvider1.SetError(Emp_PAN_No, "PAN ID is alrea
dy taken");
486. Emp_PAN_No.Focus();
487. }
488. else
489. {
490. errorProvider1.SetError(Emp_PAN_No, "");
491. }
492. con.Close();
493.
494. }
495. else
496. {
497. errorProvider1.SetError(Emp_PAN_No, "Please Enter Valid
Input!");
498. }
499. }
500. }
501.
502. private void adhar_validate(object sender, EventArgs e)
503. {
504. if (string.IsNullOrWhiteSpace(Emp_Aadhar_No.Text))
505. {
506.
507. errorProvider1.SetError(Emp_Aadhar_No, "Enter Adhar card Num
ber!");
508. }
509. else
510. {
511. errorProvider1.SetError(Emp_Aadhar_No, "");
512.
513. Regex r = new Regex("^[0-9]{12}$");
514. if (r.IsMatch(Emp_Aadhar_No.Text))
515. {
516. errorProvider1.SetError(Emp_Aadhar_No, "");
517.
518.
519. con.Open();
520. decimal t1 = decimal.Parse(Emp_Aadhar_No.Text);
521. string q = "select * from EmpMaster where Aadhar_No='" +
@t1 + "'";
522.
523. SqlCommand cmd = new SqlCommand(q, con);
524. SqlDataReader d = cmd.ExecuteReader();
525. if (d.HasRows)
526. {
527. MessageBox.Show("Aadhar No is already taken");
528. errorProvider1.SetError(Emp_Aadhar_No, "Aadhar No is
already taken");
529. Emp_Aadhar_No.Focus();
530.
531. }
532. else
533. {
534. errorProvider1.SetError(Emp_Aadhar_No, "");
535. }
536. con.Close();
537. }
538. else
539. {
540. errorProvider1.SetError(Emp_Aadhar_No, "Please Enter Val
id Input!");
541. }
542. }

58 | P a g e
543. }
544.
545. private void mob1_validate(object sender, EventArgs e)
546. {
547. if (string.IsNullOrWhiteSpace(EmpMobile1.Text))
548. {
549.
550. errorProvider1.SetError(EmpMobile1, "Enter Mobile Number!");

551. }
552. else
553. {
554. errorProvider1.SetError(EmpMobile1, "");
555.
556. Regex r = new Regex("^[6-9]{1}[0-9]{9}$");
557. if (r.IsMatch(EmpMobile1.Text))
558. {
559. errorProvider1.SetError(EmpMobile1, "");
560. con.Open();
561. string t1 = (EmpMobile1.Text);
562. string q = "select * from EmpMaster where EmpMobileNo1='
" + @t1 + "'";
563.
564. SqlCommand cmd = new SqlCommand(q, con);
565. SqlDataReader d = cmd.ExecuteReader();
566. if (d.HasRows)
567. {
568. MessageBox.Show("Mobile No is already taken");
569. errorProvider1.SetError(EmpMobile1, "Mobile No is al
ready taken");
570. EmpMobile1.Focus();
571. }
572. else
573. {
574. errorProvider1.SetError(EmpMobile1, "");
575. }
576. con.Close();
577.
578. }
579. else
580. {
581. errorProvider1.SetError(EmpMobile1, "Please Enter Valid
Input!");
582. }
583.
584. }
585.
586. }
587.
588. private void mob2_validate(object sender, EventArgs e)
589. {
590. if (string.IsNullOrWhiteSpace(EmpMobile2.Text))
591. {
592. errorProvider1.SetError(EmpMobile2, "");
593. }
594. else
595. {
596. errorProvider1.SetError(EmpMobile2, "");
597.
598. Regex r = new Regex("^[6-9]{1}[0-9]{9}$");
599. if (r.IsMatch(EmpMobile2.Text))
600. {
601. errorProvider1.SetError(EmpMobile2, "");
602. }
603. else
604. {

59 | P a g e
605. errorProvider1.SetError(EmpMobile2, "Please Enter Valid
Input!");
606. }
607.
608. }
609. }
610.
611. private void email1_validate(object sender, EventArgs e)
612. {
613. if (string.IsNullOrWhiteSpace(EmpEmailID1.Text))
614. {
615. errorProvider1.SetError(EmpEmailID1, "Enter Email!");
616. }
617. else
618. {
619. errorProvider1.SetError(EmpEmailID1, "");
620. string pattern = @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-
9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$";
621. // Match emailAddressMatch = Regex.Match(emailAddress, patter
n);
622. Regex r = new Regex(pattern);
623. if (r.IsMatch(EmpEmailID1.Text))
624. {
625. errorProvider1.SetError(EmpEmailID1, "");
626.
627. con.Open();
628. string t1 = (EmpEmailID1.Text);
629. string q = "select * from EmpMaster where EmpEmailID1='"
+ @t1 + "'";
630.
631. SqlCommand cmd = new SqlCommand(q, con);
632. SqlDataReader d = cmd.ExecuteReader();
633. if (d.HasRows)
634. {
635. MessageBox.Show("Email ID is already taken");
636. errorProvider1.SetError(EmpEmailID1, "Email ID is al
ready taken");
637. EmpEmailID1.Focus();
638.
639. }
640. else
641. {
642. errorProvider1.SetError(EmpEmailID1, "");
643. }
644. con.Close();
645.
646. }
647. else
648. {
649. errorProvider1.SetError(EmpEmailID1, "Please Enter Valid
Input!");
650. }
651. }
652. }
653.
654. private void email2_validate(object sender, EventArgs e)
655. {
656. if (string.IsNullOrWhiteSpace(EmpEmailID2.Text))
657. {
658. errorProvider1.SetError(EmpEmailID2, "");
659. }
660. else
661. {
662. errorProvider1.SetError(EmpEmailID2, "");
663.

60 | P a g e
664. Regex r = new Regex("^[a-zA-Z0-9]+@[a-zA-Z_]+?.[a-zA-
Z]{2,3}");
665. if (r.IsMatch(EmpEmailID2.Text))
666. {
667. errorProvider1.SetError(EmpEmailID2, "");
668. }
669. else
670. {
671. errorProvider1.SetError(EmpEmailID2, "Please Enter Valid
Input!");
672. }
673. }
674. }
675. private void button9_Click(object sender, EventArgs e)
676. {
677. this.Hide();
678. home h = new home();
679. h.Closed += (s, args) => this.Close();
680. h.Show();
681. }
682. private void check(object sender, EventArgs e)
683. {
684. string year = EmpDOB.Value.Year.ToString();
685. string ch= DateTime.Now.Year.ToString();
686. int y = int.Parse(year);
687. int c = int.Parse(ch);
688. if ((c - y) < 14)
689. {
690. MessageBox.Show("Avoid Child Labour");
691. }
692.
693. }
694. }
695. }

61 | P a g e
- Supplier Master Form

62 | P a g e
1. namespace CRMERP
2. {
3. public partial class suppliermaster : Form
4. {
5. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
6.
7. public suppliermaster()
8. {
9. InitializeComponent();
10. }
11. private void suppliermaster_Load(object sender, EventArgs e)
12. {
13. bunifuFormFadeTransition1.ShowAsyc(this);
14.
15. this.WindowState = FormWindowState.Maximized;
16. errorProvider1.ContainerControl = this;
17. con.Open();
18. string query = "select * from SuppMaster";
19.
20. DataSet ds = new DataSet();
21. SqlDataAdapter dap = new SqlDataAdapter(query, con);
22. dap.Fill(ds);
23.
24. dataGridView1.DataSource = ds.Tables[0];
25. con.Close();
26.
27. }
28.
29.
30.
31. private void Save_Click(object sender, EventArgs e)
32. {
33. if (string.IsNullOrWhiteSpace(SuppID.Text) || string.IsNullOrWhiteSpace
(SuppName.Text) || string.IsNullOrWhiteSpace(SuppMobile1.Text) || string.IsNullOrWh
iteSpace(SuppEmail1.Text) || string.IsNullOrWhiteSpace(Pincode.Text) || string.IsNu
llOrWhiteSpace(Supp_PAN_No.Text))
34. {
35. MessageBox.Show("Enter Valid Record", "Error");
36. }
37. else
38. {
39.
40. con.Open();
41.
42.
43.
44. decimal t1 = decimal.Parse(SuppID.Text);
45. string q = "select * from SuppMaster where SuppID='" + @t1 + "'";
46.
47. SqlCommand cmd = new SqlCommand(q, con);
48. SqlDataReader myreader = cmd.ExecuteReader();
49. if (myreader.HasRows)
50. {
51. MessageBox.Show("Supplier Code is already taken", "Error");
52. }
53. else
54. {
55. myreader.Close();
56. string q1 = "insert into SuppMaster values (@t1,@t2,@t3,@t4,@t5
,@t6,@t7,@t8,@t9,@t10,@t11,@t12,@t13,@t14,@t15,@t16,@t17,@t18,@t19,@t20,@t21,@t22,@
t23,@t24,@t25,@t26)";
57.

63 | P a g e
58. cmd = new SqlCommand(q1, con);
59.
60. cmd.Parameters.AddWithValue("@t1", decimal.Parse(SuppID.Text));

61. cmd.Parameters.AddWithValue("@t2", (SuppName.Text));


62. cmd.Parameters.AddWithValue("@t3", (SuppCategory.Text));
63. cmd.Parameters.AddWithValue("@t4", decimal.Parse(SuppMobile1.Te
xt));
64. cmd.Parameters.AddWithValue("@t5", (SuppMobile2.Text));
65. cmd.Parameters.AddWithValue("@t6", (SuppEmail1.Text));
66. cmd.Parameters.AddWithValue("@t7", (SuppEmail2.Text));
67. cmd.Parameters.AddWithValue("@t8", (SuppWebsite.Text));
68. cmd.Parameters.AddWithValue("@t9", (OfficeNo.Text));
69. cmd.Parameters.AddWithValue("@t10", (BuildingName.Text));
70.
71. cmd.Parameters.AddWithValue("@t11", (Address1.Text));
72. cmd.Parameters.AddWithValue("@t12", (Address2.Text));
73. cmd.Parameters.AddWithValue("@t13", (Landmark.Text));
74.
75. cmd.Parameters.AddWithValue("@t14", decimal.Parse(Pincode.Text)
);
76. cmd.Parameters.AddWithValue("@t15", (City.Text));
77. cmd.Parameters.AddWithValue("@t16", (State.Text));
78. cmd.Parameters.AddWithValue("@t17", (Country.Text));
79. cmd.Parameters.AddWithValue("@t18", (ContactPersonName.Text));

80. cmd.Parameters.AddWithValue("@t19", (ContactPersonMobileNo.Text


));
81. cmd.Parameters.AddWithValue("@t20", (ContactPersonEmailID.Text)
);
82. cmd.Parameters.AddWithValue("@t21", (Currency.Text));
83. cmd.Parameters.AddWithValue("@t22", (CreditLimit.Text));
84. cmd.Parameters.AddWithValue("@t23", (Supp_PAN_No.Text));
85. cmd.Parameters.AddWithValue("@t24", (Supp_GST_No.Text));
86. cmd.Parameters.AddWithValue("@t25", (11));
87. cmd.Parameters.AddWithValue("@t26", DateTime.Today);
88. cmd.ExecuteNonQuery();
89.
90. MessageBox.Show("Data Inserted Successfully");
91. string query = "select * from SuppMaster";
92.
93. DataSet ds = new DataSet();
94. SqlDataAdapter dap = new SqlDataAdapter(query, con);
95. dap.Fill(ds);
96.
97. dataGridView1.DataSource = ds.Tables[0];
98. con.Close();
99. }
100. }
101. }
102.
103. private void button2_Click(object sender, EventArgs e)
104. {
105. con.Open();
106. string q = "update SuppMaster set SuppID=@t1,SuppName=@t2,SuppCa
tegory=@t3,SuppMobile1=@t4,SuppMobile2=@t5,SuppEmail1=@t6,SuppEmail2=@t7,SuppWebsit
e=@t8,OfficeNo=@t9,BuildingName=@t10,Address1=@t11,Address2=@t12,Landmark=@t13,Pinc
ode=@t14,City=@t15,State=@t16,Country=@t17,ContactPersonName=@t18,ContactPersonMobi
leNo=@t19,ContactPersonEmailID=@t20,Currency=@t21,CreditLimit=@t22,Supp_PAN_No=@t23
, Supp_GST_No=@t24,EntryID=@t25,Timestamp=@t26 where SuppID=@t1";
107. SqlCommand cmd = new SqlCommand(q, con);
108. cmd.Parameters.AddWithValue("@t1", decimal.Parse(SuppID.Text));

109. cmd.Parameters.AddWithValue("@t2", (SuppName.Text));


110. cmd.Parameters.AddWithValue("@t3", (SuppCategory.Text));

64 | P a g e
111. cmd.Parameters.AddWithValue("@t4", decimal.Parse(SuppMobile1.Tex
t));
112. cmd.Parameters.AddWithValue("@t5", (SuppMobile2.Text));
113. cmd.Parameters.AddWithValue("@t6", (SuppEmail1.Text));
114. cmd.Parameters.AddWithValue("@t7", (SuppEmail2.Text));
115. cmd.Parameters.AddWithValue("@t8", (SuppWebsite.Text));
116. cmd.Parameters.AddWithValue("@t9", (OfficeNo.Text));
117. cmd.Parameters.AddWithValue("@t10", (BuildingName.Text));
118.
119. cmd.Parameters.AddWithValue("@t11", (Address1.Text));
120. cmd.Parameters.AddWithValue("@t12", (Address2.Text));
121. cmd.Parameters.AddWithValue("@t13", (Landmark.Text));
122.
123. cmd.Parameters.AddWithValue("@t14", decimal.Parse(Pincode.Text))
;
124. cmd.Parameters.AddWithValue("@t15", (City.Text));
125. cmd.Parameters.AddWithValue("@t16", (State.Text));
126. cmd.Parameters.AddWithValue("@t17", (Country.Text));
127. cmd.Parameters.AddWithValue("@t18", (ContactPersonName.Text));
128. cmd.Parameters.AddWithValue("@t19", (ContactPersonMobileNo.Text)
);
129. cmd.Parameters.AddWithValue("@t20", (ContactPersonEmailID.Text))
;
130. cmd.Parameters.AddWithValue("@t21", (Currency.Text));
131. cmd.Parameters.AddWithValue("@t22", (CreditLimit.Text));
132. cmd.Parameters.AddWithValue("@t23", (Supp_PAN_No.Text));
133. cmd.Parameters.AddWithValue("@t24", (Supp_GST_No.Text));
134. cmd.Parameters.AddWithValue("@t25", (11));
135. cmd.Parameters.AddWithValue("@t26", DateTime.Today);
136. cmd.ExecuteNonQuery();
137. con.Close();
138. MessageBox.Show("Data Updated");
139. string query = "select * from SuppMaster";
140.
141. DataSet ds = new DataSet();
142. SqlDataAdapter dap = new SqlDataAdapter(query, con);
143. dap.Fill(ds);
144.
145. dataGridView1.DataSource = ds.Tables[0];
146.
147. con.Close();
148.
149. }
150.
151. private void panel2_Paint(object sender, PaintEventArgs e)
152. {
153.
154. }
155.
156. private void button1_Click(object sender, EventArgs e)
157. {
158. this.Close();
159. }
160.
161. private void Delete_Click(object sender, EventArgs e)
162. {
163. con.Open();
164. string q = "delete from SuppMaster where SuppID=@t1";
165. SqlCommand cmd = new SqlCommand(q, con);
166.
167. cmd.Parameters.AddWithValue("@t1", int.Parse(SuppID.Text));
168. cmd.ExecuteNonQuery();
169. con.Close();
170. MessageBox.Show("Data Deleted");
171. string query = "select * from SuppMaster";
172.

65 | P a g e
173. DataSet ds = new DataSet();
174. SqlDataAdapter dap = new SqlDataAdapter(query, con);
175. dap.Fill(ds);
176.
177. dataGridView1.DataSource = ds.Tables[0];
178.
179. con.Close();
180.
181.
182.
183.
184. }
185.
186. private void button7_Click(object sender, EventArgs e)
187. {
188. SqlCommand cmd;
189.
190. con.Open();
191.
192. if (string.IsNullOrWhiteSpace(SuppID.Text))
193. {
194. MessageBox.Show("Enter Supplier ID");
195. }
196. else
197. {
198. decimal t1 = decimal.Parse(SuppID.Text);
199. string q = "select * from SuppMaster where SuppID='" + @t1 +
"'";
200.
201. cmd = new SqlCommand(q, con);
202. SqlDataReader myreader = cmd.ExecuteReader();
203.
204. if (myreader.HasRows)
205. {
206. while (myreader.Read())
207. {
208. SuppID.Text = myreader["SuppID"].ToString();
209. SuppName.Text = myreader["SuppName"].ToString();
210. SuppCategory.Text = myreader["SuppCategory"].ToStrin
g();
211. SuppMobile1.Text = myreader["SuppMobile1"].ToString(
);
212. SuppMobile2.Text = myreader["SuppMobile2"].ToString(
);
213.
214. SuppEmail1.Text = myreader["SuppEmail1"].ToString();

215.
216. SuppEmail2.Text = myreader["SuppEmail2"].ToString();

217.
218. SuppWebsite.Text = myreader["SuppWebsite"].ToString(
);
219. OfficeNo.Text = myreader["OfficeNo"].ToString();
220.
221. BuildingName.Text = myreader["BuildingName"].ToStrin
g();
222.
223. Address1.Text = myreader["Address1"].ToString();
224. Address2.Text = myreader["Address2"].ToString();
225. Landmark.Text = myreader["Landmark"].ToString();
226.
227. Pincode.Text = myreader["Pincode"].ToString();
228. City.Text = myreader["City"].ToString();
229.
230. State.Text = myreader["State"].ToString();

66 | P a g e
231. Country.Text = myreader["Country"].ToString();
232.
233. ContactPersonEmailID.Text = myreader["ContactPersonE
mailID"].ToString();
234. ContactPersonMobileNo.Text = myreader["ContactPerson
MobileNo"].ToString();
235. ContactPersonName.Text = myreader["ContactPersonName
"].ToString();
236. Currency.Text = myreader["Currency"].ToString();
237. CreditLimit.Text = myreader["CreditLimit"].ToString(
);
238.
239. Supp_PAN_No.Text = myreader["Supp_PAN_No"].ToString(
);
240. Supp_GST_No.Text = myreader["Supp_GST_No"].ToString(
);
241.
242.
243. }
244. }
245. else
246. {
247. MessageBox.Show("Supplier ID not found");
248.
249. }
250. con.Close();
251. }
252. }
253.
254. private void button5_Click(object sender, EventArgs e)
255. {
256.
257. }
258.
259.
260.
261.
262.
263.
264. private void button9_Click(object sender, EventArgs e)
265. {
266. this.Close();
267. }
268.
269.
270.
271. private void suppid_validate(object sender, EventArgs e)
272. {
273. if (string.IsNullOrWhiteSpace(SuppID.Text))
274. {
275.
276. errorProvider1.SetError(SuppID, "Please Enter the Value!");

277.
278. }
279. else
280. {
281. errorProvider1.SetError(SuppID, "");
282. Regex r = new Regex("^[0-9]+$");
283. if (r.IsMatch(SuppID.Text))
284. {
285.
286. }
287. else
288. {

67 | P a g e
289. errorProvider1.SetError(SuppID, "Please Enter Valid Inpu
t!");
290. }
291.
292. }
293.
294. }
295.
296. private void name_validator(object sender, EventArgs e)
297. {
298.
299. if (string.IsNullOrWhiteSpace(SuppName.Text))
300. {
301.
302. errorProvider1.SetError(SuppName, "Name should not be left b
lank!");
303. }
304. else
305. {
306. errorProvider1.SetError(SuppName, "");
307.
308. Regex r = new Regex("^[a-z A-Z]+$");
309. if (r.IsMatch(SuppName.Text))
310. {
311.
312. }
313. else
314. {
315. errorProvider1.SetError(SuppName, "Please Enter Valid In
put!");
316. }
317. }
318.
319. }
320.
321. private void pan_validate(object sender, EventArgs e)
322. {
323. if (string.IsNullOrWhiteSpace(Supp_PAN_No.Text))
324. {
325.
326. errorProvider1.SetError(Supp_PAN_No, "Enter PAN Number!");
327. }
328. else
329. {
330. errorProvider1.SetError(Supp_PAN_No, "");
331.
332. Regex r = new Regex("^[a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}$");
333. if (r.IsMatch(Supp_PAN_No.Text))
334. {
335. errorProvider1.SetError(Supp_PAN_No, "");
336.
337. con.Open();
338. string t1 = (Supp_PAN_No.Text);
339. string q = "select * from SuppMaster where Supp_PAN_No='
" + @t1 + "'";
340.
341. SqlCommand cmd = new SqlCommand(q, con);
342. SqlDataReader d = cmd.ExecuteReader();
343. if (d.HasRows)
344. {
345. MessageBox.Show("PAN ID is already taken");
346. errorProvider1.SetError(Supp_PAN_No, "PAN ID is alre
ady taken");
347. Supp_PAN_No.Focus();
348. }
349. else

68 | P a g e
350. {
351. errorProvider1.SetError(Supp_PAN_No, "");
352. }
353. con.Close();
354. }
355. else
356. {
357. errorProvider1.SetError(Supp_PAN_No, "Please Enter Valid
Input!");
358. }
359. }
360. }
361.
362. private void gst_validate(object sender, EventArgs e)
363. {
364. if (string.IsNullOrWhiteSpace(Supp_GST_No.Text))
365. {
366.
367. errorProvider1.SetError(Supp_GST_No, "Enter GST Number!");
368. }
369. else
370. {
371. errorProvider1.SetError(Supp_GST_No, "");
372.
373. Regex r = new Regex("^^([0]{1}[1-9]{1}|[1-2]{1}[0-
9]{1}|[3]{1}[0-7]{1})([a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9a-zA-Z]{1}[zZ]{1}[0-9a-zA-
Z]{1})+$");
374. if (r.IsMatch(Supp_GST_No.Text))
375. {
376. errorProvider1.SetError(Supp_GST_No, "");
377.
378. con.Open();
379. string t1 = (Supp_GST_No.Text);
380. string q = "select * from SuppMaster where Supp_GST_No='
" + @t1 + "'";
381.
382. SqlCommand cmd = new SqlCommand(q, con);
383. SqlDataReader d = cmd.ExecuteReader();
384. if (d.HasRows)
385. {
386. MessageBox.Show("GST is already taken");
387. errorProvider1.SetError(Supp_GST_No, "GST is already
taken");
388. Supp_GST_No.Focus();
389. }
390. else
391. {
392. errorProvider1.SetError(Supp_GST_No, "");
393. }
394. con.Close();
395.
396. }
397. else
398. {
399. errorProvider1.SetError(Supp_GST_No, "Please Enter Valid
Input!");
400. }
401. }
402.
403. }
404.
405. private void mob_validate(object sender, EventArgs e)
406. {
407.
408. if (string.IsNullOrWhiteSpace(SuppMobile1.Text))
409. {

69 | P a g e
410.
411. errorProvider1.SetError(SuppMobile1, "Enter Mobile Number!")
;
412. }
413. else
414. {
415. errorProvider1.SetError(SuppMobile1, "");
416.
417. Regex r = new Regex("^[6-9]{1}[0-9]{9}$");
418. if (r.IsMatch(SuppMobile1.Text))
419. {
420. errorProvider1.SetError(SuppMobile1, "");
421. con.Open();
422. decimal t1 = decimal.Parse(SuppMobile1.Text);
423. string q = "select * from SuppMaster where SuppMobile1='
" + @t1 + "'";
424.
425. SqlCommand cmd = new SqlCommand(q, con);
426. SqlDataReader d = cmd.ExecuteReader();
427. if (d.HasRows)
428. {
429. MessageBox.Show("Mobile No is already taken");
430. errorProvider1.SetError(SuppMobile1, "Mobile No is a
lready taken");
431. SuppMobile1.Focus();
432. }
433. else
434. {
435. errorProvider1.SetError(SuppMobile1, "");
436. }
437. con.Close();
438. }
439. else
440. {
441. errorProvider1.SetError(SuppMobile1, "Please Enter Valid
Input!");
442. }
443.
444. }
445. }
446.
447. private void emai_validate(object sender, EventArgs e)
448. {
449. if (string.IsNullOrWhiteSpace(SuppEmail1.Text))
450. {
451. errorProvider1.SetError(SuppEmail1, "Enter Email!");
452. }
453. else
454. {
455. errorProvider1.SetError(SuppEmail1, "");
456.
457. Regex r = new Regex("^[a-zA-Z0-9]+@[a-zA-Z_]+?.[a-zA-
Z]{2,3}");
458. if (r.IsMatch(SuppEmail1.Text))
459. {
460. errorProvider1.SetError(SuppEmail1, "");
461.
462. con.Open();
463. string t1 = (SuppEmail1.Text);
464. string q = "select * from SuppMaster where SuppEmail1='"
+ @t1 + "'";
465.
466. SqlCommand cmd = new SqlCommand(q, con);
467. SqlDataReader d = cmd.ExecuteReader();
468. if (d.HasRows)
469. {

70 | P a g e
470. MessageBox.Show("Email ID already taken");
471. errorProvider1.SetError(SuppEmail1, "Email ID is alr
eady taken");
472. SuppEmail1.Focus();
473. }
474. else
475. {
476. errorProvider1.SetError(SuppEmail1, "");
477. }
478. con.Close();
479. }
480. else
481. {
482. errorProvider1.SetError(SuppEmail1, "Please Enter Valid
Input!");
483. }
484. }
485. }
486.
487. private void pin_validate(object sender, EventArgs e)
488. {
489. if (string.IsNullOrWhiteSpace(Pincode.Text))
490. {
491.
492. errorProvider1.SetError(Pincode, "Please Enter the Pincode!"
);
493.
494. }
495. else
496. {
497.
498. Regex r = new Regex("^[1-9][0-9]{5}$");
499. if (r.IsMatch(Pincode.Text))
500. {
501. SqlCommand cmd;
502. SqlConnection con;
503.
504. con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
505. con.Open();
506. decimal t1 = decimal.Parse(Pincode.Text);
507. string q = "select * from pincode where pincode='" + @t1
+ "'";
508.
509. cmd = new SqlCommand(q, con);
510. SqlDataReader myreader = cmd.ExecuteReader();
511.
512. while (myreader.Read())
513. {
514. City.Text = myreader["city"].ToString();
515. State.Text = myreader["state"].ToString();
516. Country.Text = "India";
517.
518. }
519. con.Close();
520. }
521. else
522. {
523. errorProvider1.SetError(Pincode, "Please Enter Valid Inp
ut!");
524. }
525.
526. }
527.
528. }
529.

71 | P a g e
530. private void contactpersonname_validate(object sender, EventArgs e)

531. {
532. if (string.IsNullOrWhiteSpace(ContactPersonName.Text))
533. {
534. errorProvider1.SetError(ContactPersonName, "");
535. }
536. else
537. {
538. errorProvider1.SetError(ContactPersonName, "");
539.
540. Regex r = new Regex("^[a-zA-Z ]+$");
541. if (r.IsMatch(ContactPersonName.Text))
542. {
543. errorProvider1.SetError(ContactPersonName, "");
544.
545. }
546. else
547. {
548. errorProvider1.SetError(ContactPersonName, "Please Enter
Valid Input!");
549. }
550.
551. }
552. }
553.
554.
555.
556. private void contactpersonno_validate(object sender, EventArgs e)
557. {
558. if (string.IsNullOrWhiteSpace(ContactPersonMobileNo.Text))
559. {
560. errorProvider1.SetError(ContactPersonMobileNo, "");
561. }
562. else
563. {
564. errorProvider1.SetError(ContactPersonMobileNo, "");
565. Regex r = new Regex("^[6-9]{1}[0-9]{9}$");
566. if (r.IsMatch(ContactPersonMobileNo.Text))
567. {
568. errorProvider1.SetError(ContactPersonMobileNo, "");
569.
570. }
571. else
572. {
573. errorProvider1.SetError(ContactPersonMobileNo, "Please E
nter Valid Input!");
574. }
575.
576. }
577. }
578.
579. private void contactpersonemail_validate(object sender, EventArgs e)

580. {
581. if (string.IsNullOrWhiteSpace(ContactPersonEmailID.Text))
582. {
583. errorProvider1.SetError(ContactPersonEmailID, "");
584.
585. }
586. else
587. {
588. errorProvider1.SetError(ContactPersonEmailID, "");
589.
590. Regex r = new Regex("^[a-zA-Z0-9]+@[a-zA-Z_]+?.[a-zA-
Z]{2,3}");

72 | P a g e
591. if (r.IsMatch(ContactPersonEmailID.Text))
592. {
593. errorProvider1.SetError(ContactPersonEmailID, "");
594. }
595. else
596. {
597. errorProvider1.SetError(ContactPersonEmailID, "Please En
ter Valid Input!");
598. }
599.
600. }
601. }
602.
603. private void mob2_validate(object sender, EventArgs e)
604. {
605. if (string.IsNullOrWhiteSpace(SuppMobile2.Text))
606. {
607. errorProvider1.SetError(SuppMobile2, "");
608. }
609. else
610. {
611. errorProvider1.SetError(SuppMobile2, "");
612.
613. Regex r = new Regex("^[6-9]{1}[0-9]{9}$");
614. if (r.IsMatch(SuppMobile2.Text))
615. {
616. errorProvider1.SetError(SuppMobile2, "");
617.
618. }
619. else
620. {
621. errorProvider1.SetError(SuppMobile2, "Please Enter Valid
Input!");
622. }
623.
624. }
625. }
626.
627. private void button8_Click(object sender, EventArgs e)
628. {
629. this.Hide();
630. home h = new home();
631. h.Closed += (s, args) => this.Close();
632. h.Show();
633. }
634. }
635. }

73 | P a g e
- Customer Master Form

74 | P a g e
1. namespace CRMERP
2. {
3. public partial class customermaster : Form
4. {
5. public customermaster()
6. {
7. InitializeComponent();
8. }
9.
10. private void customermaster_Load(object sender, EventArgs e)
11. {
12. bunifuFormFadeTransition1.ShowAsyc(this);
13.
14. this.WindowState = FormWindowState.Maximized;
15. this.KeyPreview = true;
16.
17. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
18. con.Open();
19.
20. string query = "select * from CustMaster";
21.
22. DataSet ds = new DataSet();
23. SqlDataAdapter dap = new SqlDataAdapter(query, con);
24. dap.Fill(ds);
25.
26. dataGridView1.DataSource = ds.Tables[0];
27.
28. con.Close();
29. }
30.
31. private void button1_Click(object sender, EventArgs e)
32. {
33. this.Hide();
34. home h = new home();
35. h.Closed += (s, args) => this.Close();
36. h.Show();
37. }
38.
39. private void Save_Click(object sender, EventArgs e)
40. {
41. if (string.IsNullOrWhiteSpace(CustID.Text) || string.IsNullOrWhiteSpace(
CustName.Text) || string.IsNullOrWhiteSpace(CustMobile1.Text) || string.IsNullOrWhit
eSpace(CustEmail1.Text) || string.IsNullOrWhiteSpace(Pincode.Text))
42. {
43. MessageBox.Show("Enter Valid Record", "Error");
44. }
45. else
46. {
47.
48. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
49. con.Open();
50.
51. decimal t1 = decimal.Parse(CustID.Text);
52. string q = "select * from CustMaster where CustID='" + @t1 + "'";
53.
54. SqlCommand cmd = new SqlCommand(q, con);
55. SqlDataReader myreader = cmd.ExecuteReader();
56. if (myreader.HasRows)
57. {
58. MessageBox.Show("Customer ID is already taken", "Error");
59. }

75 | P a g e
60. else
61. {
62. myreader.Close();
63. string q1 = "insert into CustMaster values (@t1,@t2,@t3,@t4,@t5,
@t6,@t7,@t8,@t9,@t10,@t11,@t12,@t13,@t14,@t15,@t16,@t17,@t18,@t19,@t20,@t21,@t22,@t2
3,@t24,@t25)";
64.
65. cmd = new SqlCommand(q1, con);
66.
67. cmd.Parameters.AddWithValue("@t1", decimal.Parse(CustID.Text));

68. cmd.Parameters.AddWithValue("@t2", (CustName.Text));


69. cmd.Parameters.AddWithValue("@t3", (CustCategory.Text));
70. cmd.Parameters.AddWithValue("@t4", decimal.Parse(CustMobile1.Tex
t));
71. cmd.Parameters.AddWithValue("@t5", (CustMobile2.Text));
72. cmd.Parameters.AddWithValue("@t6", (CustEmail1.Text));
73. cmd.Parameters.AddWithValue("@t7", (CustEmail2.Text));
74. cmd.Parameters.AddWithValue("@t8", (Website.Text));
75. cmd.Parameters.AddWithValue("@t9", (OfficeNo.Text));
76. cmd.Parameters.AddWithValue("@t10", (BuildingName.Text));
77.
78. cmd.Parameters.AddWithValue("@t11", (Address1.Text));
79. cmd.Parameters.AddWithValue("@t12", (Address2.Text));
80. cmd.Parameters.AddWithValue("@t13", (Landmark.Text));
81. cmd.Parameters.AddWithValue("@t14", decimal.Parse(Pincode.Text))
;
82. cmd.Parameters.AddWithValue("@t15", (City.Text));
83. cmd.Parameters.AddWithValue("@t16", (State.Text));
84. cmd.Parameters.AddWithValue("@t17", (Country.Text));
85. cmd.Parameters.AddWithValue("@t18", (ContactPersonName.Text));
86. cmd.Parameters.AddWithValue("@t19", (ContactPersonMobileNo.Text)
);
87. cmd.Parameters.AddWithValue("@t20", (ContactPersonEmailID.Text))
;
88. cmd.Parameters.AddWithValue("@t21", (Currency.Text));
89. cmd.Parameters.AddWithValue("@t22", (Cust_PAN_No.Text));
90. cmd.Parameters.AddWithValue("@t23", (Cust_GST_No.Text));
91.
92. cmd.Parameters.AddWithValue("@t24", 11);
93. cmd.Parameters.AddWithValue("@t25", DateTime.Today);
94.
95. cmd.ExecuteNonQuery();
96. con.Close();
97. MessageBox.Show("Data Inserted");
98. string query = "select * from CustMaster";
99.
100. DataSet ds = new DataSet();
101. SqlDataAdapter dap = new SqlDataAdapter(query, con);
102. dap.Fill(ds);
103.
104. dataGridView1.DataSource = ds.Tables[0];
105.
106. con.Close();
107. }
108. }
109. }
110.
111. private void button2_Click(object sender, EventArgs e)
112. {
113. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
114. con.Open();
115. string q = "update CustMaster set CustID=@t1,CustName=@t2,CustCategory=
@t3,CustMobile1=@t4,CustMobile2=@t5,CustEmail1=@t6,CustEmail2=@t7,Website=@t8,Office
No=@t9,BuildingName=@t10,Address1=@t11,Address2=@t12,Landmark=@t13,Pincode=@t14,City

76 | P a g e
=@t15,State=@t16,Country=@t17,ContactPersonName=@t18,ContactPersonMobileNo=@t19,Cont
actPersonEmailID=@t20,Currency=@t21,Cust_PAN_No=@t22, Cust_GST_No=@t23,EntryID=@t24,
Timestamp=@t25 where CustID=@t1";
116. SqlCommand cmd = new SqlCommand(q, con);
117.
118. cmd.Parameters.AddWithValue("@t1", decimal.Parse(CustID.Text));
119. cmd.Parameters.AddWithValue("@t2", (CustName.Text));
120. cmd.Parameters.AddWithValue("@t3", (CustCategory.Text));
121. cmd.Parameters.AddWithValue("@t4", decimal.Parse(CustMobile1.Text));
122. cmd.Parameters.AddWithValue("@t5", (CustMobile2.Text));
123. cmd.Parameters.AddWithValue("@t6", (CustEmail1.Text));
124. cmd.Parameters.AddWithValue("@t7", (CustEmail2.Text));
125. cmd.Parameters.AddWithValue("@t8", (Website.Text));
126. cmd.Parameters.AddWithValue("@t9", (OfficeNo.Text));
127. cmd.Parameters.AddWithValue("@t10", (BuildingName.Text));
128.
129. cmd.Parameters.AddWithValue("@t11", (Address1.Text));
130. cmd.Parameters.AddWithValue("@t12", (Address2.Text));
131. cmd.Parameters.AddWithValue("@t13", (Landmark.Text));
132. cmd.Parameters.AddWithValue("@t14", decimal.Parse(Pincode.Text));
133. cmd.Parameters.AddWithValue("@t15", (City.Text));
134. cmd.Parameters.AddWithValue("@t16", (State.Text));
135. cmd.Parameters.AddWithValue("@t17", (Country.Text));
136. cmd.Parameters.AddWithValue("@t18", (ContactPersonName.Text));
137. cmd.Parameters.AddWithValue("@t19", (ContactPersonMobileNo.Text));
138. cmd.Parameters.AddWithValue("@t20", (ContactPersonEmailID.Text));
139. cmd.Parameters.AddWithValue("@t21", (Currency.Text));
140. cmd.Parameters.AddWithValue("@t22", (Cust_PAN_No.Text));
141. cmd.Parameters.AddWithValue("@t23", (Cust_GST_No.Text));
142.
143. cmd.Parameters.AddWithValue("@t24", 11);
144. cmd.Parameters.AddWithValue("@t25", DateTime.Today);
145.
146. cmd.ExecuteNonQuery();
147. con.Close();
148. MessageBox.Show("Data Updated");
149. string query = "select * from CustMaster";
150.
151. DataSet ds = new DataSet();
152. SqlDataAdapter dap = new SqlDataAdapter(query, con);
153. dap.Fill(ds);
154.
155. dataGridView1.DataSource = ds.Tables[0];
156.
157. con.Close();
158. }
159.
160. private void Delete_Click(object sender, EventArgs e)
161. {
162. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
163. con.Open();
164. string q = "delete from CustMaster where CustID=@t1";
165. SqlCommand cmd = new SqlCommand(q, con);
166.
167. cmd.Parameters.AddWithValue("@t1", int.Parse(CustID.Text));
168. cmd.ExecuteNonQuery();
169. con.Close();
170. MessageBox.Show("Data Deleted");
171. string query = "select * from CustMaster";
172.
173. DataSet ds = new DataSet();
174. SqlDataAdapter dap = new SqlDataAdapter(query, con);
175. dap.Fill(ds);
176.
177. dataGridView1.DataSource = ds.Tables[0];

77 | P a g e
178.
179. con.Close();
180.
181. }
182.
183. private void button7_Click(object sender, EventArgs e)
184. {
185. SqlCommand cmd;
186. SqlConnection con;
187.
188. con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
189. con.Open();
190.
191. if (string.IsNullOrWhiteSpace(CustID.Text))
192. {
193. MessageBox.Show("Enter Customer ID");
194. }
195. else
196. {
197. decimal t1 = decimal.Parse(CustID.Text);
198. string q = "select * from CustMaster where CustID='" + @t1 + "'";
199.
200. cmd = new SqlCommand(q, con);
201. SqlDataReader myreader = cmd.ExecuteReader();
202.
203. if (myreader.HasRows)
204. {
205. while (myreader.Read())
206. {
207. CustID.Text = myreader["CustID"].ToString();
208. CustName.Text = myreader["CustName"].ToString();
209. CustCategory.Text = myreader["CustCategory"].ToString();
210. CustMobile1.Text = myreader["CustMobile1"].ToString();
211. CustMobile2.Text = myreader["CustMobile2"].ToString();
212.
213. CustEmail1.Text = myreader["CustEmail1"].ToString();
214.
215. CustEmail2.Text = myreader["CustEmail2"].ToString();
216.
217. Website.Text = myreader["Website"].ToString();
218. OfficeNo.Text = myreader["OfficeNo"].ToString();
219.
220. BuildingName.Text = myreader["BuildingName"].ToString();
221.
222. Address1.Text = myreader["Address1"].ToString();
223. Address2.Text = myreader["Address2"].ToString();
224. Landmark.Text = myreader["Landmark"].ToString();
225.
226. Pincode.Text = myreader["Pincode"].ToString();
227. City.Text = myreader["City"].ToString();
228.
229. State.Text = myreader["State"].ToString();
230. Country.Text = myreader["Country"].ToString();
231.
232. ContactPersonEmailID.Text = myreader["ContactPersonEmailID"
].ToString();
233. ContactPersonMobileNo.Text = myreader["ContactPersonMobileN
o"].ToString();
234. ContactPersonName.Text = myreader["ContactPersonName"].ToSt
ring();
235. Currency.Text = myreader["Currency"].ToString();
236.
237. Cust_PAN_No.Text = myreader["Cust_PAN_No"].ToString();
238. Cust_GST_No.Text = myreader["Cust_GST_No"].ToString();
239.

78 | P a g e
240. }
241. }
242. else
243. {
244. MessageBox.Show("Customer ID not found");
245. }
246. }
247.
248. con.Close();
249. }
250.
251. private void button9_Click(object sender, EventArgs e)
252. {
253. this.Close();
254. }
255.
256. private void id_validate(object sender, EventArgs e)
257. {
258. if (string.IsNullOrWhiteSpace(CustID.Text))
259. {
260.
261. errorProvider1.SetError(CustID, "Please Enter the Value!");
262.
263. }
264. else
265. {
266. errorProvider1.SetError(CustID, "");
267. Regex r = new Regex("^[0-9]+$");
268. if (r.IsMatch(CustID.Text))
269. {
270. errorProvider1.SetError(CustID, "");
271. }
272. else
273. {
274. errorProvider1.SetError(CustID, "Please Enter Valid Input!");
275. }
276.
277. }
278.
279. }
280.
281. private void name_validate(object sender, EventArgs e)
282. {
283. if (string.IsNullOrWhiteSpace(CustName.Text))
284. {
285.
286. errorProvider1.SetError(CustName, "Name should not be left blank!")
;
287. }
288. else
289. {
290. errorProvider1.SetError(CustName, "");
291.
292. Regex r = new Regex("^[a-z A-Z]+$");
293. if (r.IsMatch(CustName.Text))
294. {
295. errorProvider1.SetError(CustName, "");
296. }
297. else
298. {
299. errorProvider1.SetError(CustName, "Please Enter Valid Input!");

300. }
301. }
302. }
303.

79 | P a g e
304. private void mobile_validate(object sender, EventArgs e)
305. {
306. if (string.IsNullOrWhiteSpace(CustMobile1.Text))
307. {
308. errorProvider1.SetError(CustMobile1, "Enter Mobile Number!");
309. }
310. else
311. {
312. errorProvider1.SetError(CustMobile1, "");
313.
314. Regex r = new Regex("^[6-9]{1}[0-9]{9}$");
315. if (r.IsMatch(CustMobile1.Text))
316. {
317. errorProvider1.SetError(CustMobile1, "");
318. }
319. else
320. {
321. errorProvider1.SetError(CustMobile1, "Please Enter Valid Input!
");
322. }
323.
324. }
325. }
326.
327. private void email_validate(object sender, EventArgs e)
328. {
329. if (string.IsNullOrWhiteSpace(CustEmail1.Text))
330. {
331. errorProvider1.SetError(CustEmail1, "Enter Email!");
332. }
333. else
334. {
335. errorProvider1.SetError(CustEmail1, "");
336.
337. Regex r = new Regex("^[a-zA-Z0-9]+@[a-zA-Z_]+?.[a-zA-Z]{2,3}");
338. if (r.IsMatch(CustEmail1.Text))
339. {
340. errorProvider1.SetError(CustEmail1, "");
341. }
342. else
343. {
344. errorProvider1.SetError(CustEmail1, "Please Enter Valid Input!"
);
345. }
346. }
347. }
348.
349. private void pin(object sender, EventArgs e)
350. {
351. if (string.IsNullOrWhiteSpace(Pincode.Text))
352. {
353. errorProvider1.SetError(Pincode, "Please Enter the Pincode!");
354. }
355. else
356. {
357. errorProvider1.SetError(Pincode, "");
358.
359. Regex r = new Regex("^[1-9][0-9]{5}$");
360. if (r.IsMatch(Pincode.Text))
361. {
362. SqlCommand cmd;
363. SqlConnection con;
364.
365. con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
366. con.Open();

80 | P a g e
367. decimal t1 = decimal.Parse(Pincode.Text);
368. string q = "select * from pincode where pincode='" + @t1 + "'";

369.
370. cmd = new SqlCommand(q, con);
371. SqlDataReader myreader = cmd.ExecuteReader();
372.
373. while (myreader.Read())
374. {
375. City.Text = myreader["city"].ToString();
376. State.Text = myreader["state"].ToString();
377. Country.Text = "India";
378.
379. }
380. con.Close();
381. }
382. else
383. {
384. errorProvider1.SetError(Pincode, "Please Enter Valid Input!");

385. }
386.
387. }
388. }
389.
390.
391.
392. private void gst_validate(object sender, EventArgs e)
393. {
394. if (string.IsNullOrWhiteSpace(Cust_GST_No.Text))
395. {
396. errorProvider1.SetError(Cust_GST_No, "Enter GST Number!");
397. }
398. else
399. {
400. errorProvider1.SetError(Cust_GST_No, "");
401.
402. Regex r = new Regex("^^([0]{1}[1-9]{1}|[1-2]{1}[0-9]{1}|[3]{1}[0-
7]{1})([a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9a-zA-Z]{1}[zZ]{1}[0-9a-zA-Z]{1})+$");
403. if (r.IsMatch(Cust_GST_No.Text))
404. {
405. errorProvider1.SetError(Cust_GST_No, "");
406. }
407. else
408. {
409. errorProvider1.SetError(Cust_GST_No, "Please Enter Valid Input!
");
410. }
411. }
412. }
413.
414. private void pan_validate(object sender, EventArgs e)
415. {
416. if (string.IsNullOrWhiteSpace(Cust_PAN_No.Text))
417. {
418. errorProvider1.SetError(Cust_PAN_No, "Enter PAN Number!");
419. }
420. else
421. {
422. errorProvider1.SetError(Cust_PAN_No, "");
423.
424. Regex r = new Regex("^[a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}$");
425. if (r.IsMatch(Cust_PAN_No.Text))
426. {
427. errorProvider1.SetError(Cust_PAN_No, "");
428. }

81 | P a g e
429. else
430. {
431. errorProvider1.SetError(Cust_PAN_No, "Please Enter Valid Input!
");
432. }
433. }
434. }
435.
436. private void cp_validate(object sender, EventArgs e)
437. {
438. if (string.IsNullOrWhiteSpace(ContactPersonName.Text))
439. {
440. errorProvider1.SetError(ContactPersonName, "");
441. }
442. else
443. {
444. errorProvider1.SetError(ContactPersonName, "");
445. Regex r = new Regex("^[a-zA-Z ]+$");
446. if (r.IsMatch(ContactPersonName.Text))
447. {
448. errorProvider1.SetError(ContactPersonName, "");
449. }
450. else
451. {
452. errorProvider1.SetError(ContactPersonName, "Please Enter Valid
Input!");
453. }
454.
455. }
456. }
457.
458. private void cpmob_validate(object sender, EventArgs e)
459. {
460. if (string.IsNullOrWhiteSpace(ContactPersonMobileNo.Text))
461. {
462. errorProvider1.SetError(ContactPersonMobileNo, "");
463. }
464. else
465. {
466. errorProvider1.SetError(ContactPersonMobileNo, "");
467. Regex r = new Regex("^[6-9]{1}[0-9]{9}$");
468. if (r.IsMatch(ContactPersonMobileNo.Text))
469. {
470. errorProvider1.SetError(ContactPersonMobileNo, "");
471. }
472. else
473. {
474. errorProvider1.SetError(ContactPersonMobileNo, "Please Enter Va
lid Input!");
475. }
476.
477. }
478. }
479.
480. private void cpemail_validate(object sender, EventArgs e)
481. {
482. if (string.IsNullOrWhiteSpace(ContactPersonEmailID.Text))
483. {
484. errorProvider1.SetError(ContactPersonEmailID, "");
485. }
486. else
487. {
488. errorProvider1.SetError(ContactPersonEmailID, "");
489.
490. Regex r = new Regex("^[a-zA-Z0-9]+@[a-zA-Z_]+?.[a-zA-Z]{2,3}");
491. if (r.IsMatch(ContactPersonEmailID.Text))

82 | P a g e
492. {
493. errorProvider1.SetError(ContactPersonEmailID, "");
494.
495. }
496. else
497. {
498. errorProvider1.SetError(ContactPersonEmailID, "Please Enter Val
id Input!");
499. }
500.
501. }
502. }
503.
504. private void email2_validate(object sender, EventArgs e)
505. {
506. if (string.IsNullOrWhiteSpace(CustEmail2.Text))
507. {
508. errorProvider1.SetError(CustEmail2, "");
509. }
510. else
511. {
512. errorProvider1.SetError(CustEmail2, "");
513.
514. Regex r = new Regex("^[a-zA-Z0-9]+@[a-zA-Z_]+?.[a-zA-Z]{2,3}");
515. if (r.IsMatch(CustEmail2.Text))
516. {
517. errorProvider1.SetError(CustEmail2, "");
518. }
519. else
520. {
521. errorProvider1.SetError(CustEmail2, "Please Enter Valid Inpu);
522. }
523. }
524. }
525.
526. private void mob2_validate(object sender, EventArgs e)
527. {
528. if (string.IsNullOrWhiteSpace(CustMobile2.Text))
529. {
530. errorProvider1.SetError(CustMobile2, "");
531. }
532. else
533. {
534. errorProvider1.SetError(CustMobile2, "");
535. Regex r = new Regex("^[6-9]{1}[0-9]{9}$");
536. if (r.IsMatch(CustMobile2.Text))
537. {
538. errorProvider1.SetError(CustMobile2, "");
539. }
540. else
541. {
542. errorProvider1.SetError(CustMobile2, "Please Enter Valid In");
543. }
544.
545. }
546. }
547.
548. private void cust_keydown(object sender, KeyEventArgs e)
549. {
550. if(e.Control==true && e.KeyCode==Keys.S)
551. {
552. Save_Click(sender, e);
553. }

83 | P a g e
- Broker Master Form

84 | P a g e
1. namespace CRMERP
2. {
3. public partial class brokermaster : Form
4. {
5. public brokermaster()
6. {
7. InitializeComponent();
8. }
9.
10.
11. private void button9_Click(object sender, EventArgs e)
12. {
13. this.Close();
14. }
15.
16. private void brokermaster_Load(object sender, EventArgs e)
17. {
18. bunifuFormFadeTransition1.ShowAsyc(this);
19.
20. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
21. con.Open();
22. this.WindowState = FormWindowState.Maximized;
23. string query = "select * from BrokerMaster";
24.
25. DataSet ds = new DataSet();
26. SqlDataAdapter dap = new SqlDataAdapter(query, con);
27. dap.Fill(ds);
28.
29. dataGridView1.DataSource = ds.Tables[0];
30.
31. con.Close();
32. }
33.
34. private void Save_Click(object sender, EventArgs e)
35. {
36. if (string.IsNullOrWhiteSpace(BrokerID.Text) || string.IsNullOrWhiteSpa
ce(BrokerName.Text) || string.IsNullOrWhiteSpace(BrokerCategory.Text) || string.IsN
ullOrWhiteSpace(BrokerEmailID.Text) || string.IsNullOrWhiteSpace(BrokerMobileNo.Tex
t) || string.IsNullOrWhiteSpace(Pincode.Text))
37. {
38. MessageBox.Show("Enter Valid Record", "Error");
39. }
40. else
41. {
42. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
43. con.Open();
44. decimal t1 = decimal.Parse(BrokerID.Text);
45. string q = "select * from BrokerMaster where BrokerID='" + @t1 + "'
";
46.
47. SqlCommand cmd = new SqlCommand(q, con);
48. SqlDataReader myreader = cmd.ExecuteReader();
49. if (myreader.HasRows)
50. {
51. MessageBox.Show("Broker ID is already taken", "Error");
52. }
53. else
54. {
55. myreader.Close();
56. string q1 = "insert into BrokerMaster values (@t1,@t2,@t3,@t4,@
t5,@t6,@t7,@t8,@t9,@t10,@t11,@t12,@t13,@t14,@t15,@t16)";
57.
58. cmd = new SqlCommand(q1, con);
59.

85 | P a g e
60. cmd.Parameters.AddWithValue("@t1", decimal.Parse(BrokerID.Text)
);
61. cmd.Parameters.AddWithValue("@t2", (BrokerName.Text));
62. cmd.Parameters.AddWithValue("@t3", (BrokerCategory.Text));
63. cmd.Parameters.AddWithValue("@t4", decimal.Parse(BrokerMobileNo
.Text));
64. cmd.Parameters.AddWithValue("@t5", (BrokerEmailID.Text));
65.
66.
67. cmd.Parameters.AddWithValue("@t6", (Address1.Text));
68. cmd.Parameters.AddWithValue("@t7", (Address2.Text));
69. cmd.Parameters.AddWithValue("@t8", (Landmark.Text));
70. cmd.Parameters.AddWithValue("@t9", decimal.Parse(Pincode.Text))
;
71. cmd.Parameters.AddWithValue("@t10", (City.Text));
72. cmd.Parameters.AddWithValue("@t11", (State.Text));
73. cmd.Parameters.AddWithValue("@t12", (Country.Text));
74.
75. cmd.Parameters.AddWithValue("@t13", (Broker_PAN_No.Text));
76. cmd.Parameters.AddWithValue("@t14", (Broker_GST_No.Text));
77.
78. cmd.Parameters.AddWithValue("@t15", 11);
79. cmd.Parameters.AddWithValue("@t16", DateTime.Today);
80.
81. cmd.ExecuteNonQuery();
82. con.Close();
83. MessageBox.Show("Data Inserted");
84. string query = "select * from BrokerMaster";
85.
86. DataSet ds = new DataSet();
87. SqlDataAdapter dap = new SqlDataAdapter(query, con);
88. dap.Fill(ds);
89.
90. dataGridView1.DataSource = ds.Tables[0];
91.
92. con.Close();
93. }
94. }
95. }
96. private void id_validate(object sender, EventArgs e)
97. {
98. if (string.IsNullOrWhiteSpace(BrokerID.Text))
99. {
100.
101. errorProvider1.SetError(BrokerID, "Please Enter the Value!")
;
102.
103. }
104. else
105. {
106. errorProvider1.SetError(BrokerID, "");
107. Regex r = new Regex("^[0-9]+$");
108. if (r.IsMatch(BrokerID.Text))
109. {
110. errorProvider1.SetError(BrokerID, "");
111.
112. }
113. else
114. {
115. errorProvider1.SetError(BrokerID, "Please Enter Valid In
put!");
116. }
117.
118. }
119.
120. }

86 | P a g e
121.
122. private void name_validate(object sender, EventArgs e)
123. {
124. if (string.IsNullOrWhiteSpace(BrokerName.Text))
125. {
126.
127. errorProvider1.SetError(BrokerName, "Name should not be left
blank!");
128. }
129. else
130. {
131. errorProvider1.SetError(BrokerName, "");
132.
133. Regex r = new Regex("^[a-z A-Z]+$");
134. if (r.IsMatch(BrokerName.Text))
135. {
136. errorProvider1.SetError(BrokerName, "");
137. }
138. else
139. {
140. errorProvider1.SetError(BrokerName, "Please Enter Valid
Input!");
141. }
142. }
143. }
144.
145. private void mobile_validate(object sender, EventArgs e)
146. {
147. if (string.IsNullOrWhiteSpace(BrokerMobileNo.Text))
148. {
149.
150. errorProvider1.SetError(BrokerMobileNo, "Enter Mobile Number
!");
151. }
152. else
153. {
154. errorProvider1.SetError(BrokerMobileNo, "");
155.
156. Regex r = new Regex("^[6-9]{1}[0-9]{9}$");
157. if (r.IsMatch(BrokerMobileNo.Text))
158. {
159. errorProvider1.SetError(BrokerMobileNo, "");
160. }
161. else
162. {
163. errorProvider1.SetError(BrokerMobileNo, "Please Enter Va
lid Input!");
164. }
165.
166. }
167. }
168.
169. private void email_validate(object sender, EventArgs e)
170. {
171. if (string.IsNullOrWhiteSpace(BrokerEmailID.Text))
172. {
173.
174. errorProvider1.SetError(BrokerEmailID, "Enter Email!");
175. }
176. else
177. {
178. errorProvider1.SetError(BrokerEmailID, "");
179.
180. Regex r = new Regex("^[a-zA-Z0-9]+@[a-zA-Z_]+?.[a-zA-
Z]{2,3}");
181. if (r.IsMatch(BrokerEmailID.Text))

87 | P a g e
182. {
183. errorProvider1.SetError(BrokerEmailID, "");
184. }
185. else
186. {
187. errorProvider1.SetError(BrokerEmailID, "Please Enter Val
id Input!");
188. }
189. }
190. }
191.
192. private void pin(object sender, EventArgs e)
193. {
194. if (string.IsNullOrWhiteSpace(Pincode.Text))
195. {
196.
197. errorProvider1.SetError(Pincode, "Please Enter the Pincode!"
);
198.
199. }
200. else
201. {
202. errorProvider1.SetError(Pincode, "");
203.
204. Regex r = new Regex("^[1-9][0-9]{5}$");
205. if (r.IsMatch(Pincode.Text))
206. {
207. SqlCommand cmd;
208. SqlConnection con;
209.
210. con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
211. con.Open();
212. decimal t1 = decimal.Parse(Pincode.Text);
213. string q = "select * from pincode where pincode='" + @t1
+ "'";
214.
215. cmd = new SqlCommand(q, con);
216. SqlDataReader myreader = cmd.ExecuteReader();
217.
218. while (myreader.Read())
219. {
220. City.Text = myreader["city"].ToString();
221. State.Text = myreader["state"].ToString();
222. Country.Text = "India";
223.
224. }
225. con.Close();
226. }
227. else
228. {
229. errorProvider1.SetError(Pincode, "Please Enter Valid Inp
ut!");
230. }
231.
232. }
233. }
234. private void pan_validate(object sender, EventArgs e)
235. {
236. if (string.IsNullOrWhiteSpace(Broker_PAN_No.Text))
237. {
238. errorProvider1.SetError(Broker_PAN_No, "");
239. }
240. else
241. {
242. Regex r = new Regex("^[a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}$");

88 | P a g e
243. if (r.IsMatch(Broker_PAN_No.Text))
244. {
245. errorProvider1.SetError(Broker_PAN_No, "");
246. }
247. else
248. {
249. errorProvider1.SetError(Broker_PAN_No, "Please Enter Val
id Input!");
250. }
251. }
252. }
253.
254. private void gst_validate(object sender, EventArgs e)
255. {
256. if (string.IsNullOrWhiteSpace(Broker_GST_No.Text))
257. {
258. errorProvider1.SetError(Broker_GST_No, "");
259. }
260. else
261. {
262.
263.
264. Regex r = new Regex("^^([0]{1}[1-9]{1}|[1-2]{1}[0-
9]{1}|[3]{1}[0-7]{1})([a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9a-zA-Z]{1}[zZ]{1}[0-9a-zA-
Z]{1})+$");
265. if (r.IsMatch(Broker_GST_No.Text))
266. {
267. errorProvider1.SetError(Broker_GST_No, "");
268. }
269. else
270. {
271. errorProvider1.SetError(Broker_GST_No, "Please Enter Val
id Input!");
272. }
273. }
274.
275. }
276.
277. private void button7_Click(object sender, EventArgs e)
278. {
279. SqlCommand cmd;
280. SqlConnection con;
281.
282. con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
283. con.Open();
284.
285. if (string.IsNullOrWhiteSpace(BrokerID.Text))
286. {
287. MessageBox.Show("Enter Broker ID");
288. }
289. else
290. {
291. decimal t1 = decimal.Parse(BrokerID.Text);
292. string q = "select * from BrokerMaster where BrokerID='" + @
t1 + "'";
293.
294. cmd = new SqlCommand(q, con);
295. SqlDataReader myreader = cmd.ExecuteReader();
296.
297. if(myreader.HasRows)
298. {
299. while (myreader.Read())
300. {
301. BrokerID.Text = myreader["BrokerID"].ToString();
302. BrokerName.Text = myreader["BrokerName"].ToString();

89 | P a g e
303. BrokerCategory.Text = myreader["BrokerCategory"].ToString();
304. Broker_PAN_No.Text = myreader["Broker_PAN_No"].ToString();
305. Broker_GST_No.Text = myreader["Broker_GST_No"].ToString();
306.
307. BrokerMobileNo.Text = myreader["BrokerMobile1"].ToString();
308.
309. BrokerEmailID.Text = myreader["BrokerEmail1"].ToString();
310.
311.
312.
313. Address1.Text = myreader["Address1"].ToString();
314.
315. Address2.Text = myreader["Address2"].ToString();
316. Landmark.Text = myreader["Landmark"].ToString();
317.
318. Pincode.Text = myreader["Pincode"].ToString();
319. City.Text = myreader["City"].ToString();
320.
321. State.Text = myreader["State"].ToString();
322. Country.Text = myreader["Country"].ToString();
323. }
324. }
325. else
326. {
327. MessageBox.Show("Broker ID not found");
328.
329. }
330. }
331. con.Close();
332. }
333.
334. private void Delete_Click(object sender, EventArgs e)
335. {
336. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
337. con.Open();
338. string q = "delete from BrokerMaster where BrokerID=@t1";
339. SqlCommand cmd = new SqlCommand(q, con);
340.
341. cmd.Parameters.AddWithValue("@t1", int.Parse(BrokerID.Text));
342. cmd.ExecuteNonQuery();
343. con.Close();
344. MessageBox.Show("Data Deleted");
345. string query = "select * from BrokerMaster";
346.
347. DataSet ds = new DataSet();
348. SqlDataAdapter dap = new SqlDataAdapter(query, con);
349. dap.Fill(ds);
350.
351. dataGridView1.DataSource = ds.Tables[0];
352.
353. con.Close();
354.
355. }
356.
357. private void Update_Click(object sender, EventArgs e)
358. {
359. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
360. con.Open();
361.
362. string q = "update BrokerMaster set BrokerID=@t1,BrokerName=@t2,
BrokerCategory=@t3,BrokerMobile1=@t4,BrokerEmail1=@t5,Address1=@t6,Address2=@t7,Lan
dmark=@t8,Pincode=@t9,City=@t10,State=@t11,Country=@t12,Broker_PAN_No=@t13,Broker_G
ST_No=@t14,EntryID=@t15,Timestamp=@t16 where BrokerID=@t1";
363.

90 | P a g e
364. SqlCommand cmd = new SqlCommand(q, con);
365. cmd.Parameters.AddWithValue("@t1", decimal.Parse(BrokerID.Text))
;
366. cmd.Parameters.AddWithValue("@t2", (BrokerName.Text));
367. cmd.Parameters.AddWithValue("@t3", (BrokerCategory.Text));
368. cmd.Parameters.AddWithValue("@t4", decimal.Parse(BrokerMobileNo.
Text));
369. cmd.Parameters.AddWithValue("@t5", (BrokerEmailID.Text));
370.
371.
372. cmd.Parameters.AddWithValue("@t6", (Address1.Text));
373. cmd.Parameters.AddWithValue("@t7", (Address2.Text));
374. cmd.Parameters.AddWithValue("@t8", (Landmark.Text));
375. cmd.Parameters.AddWithValue("@t9", decimal.Parse(Pincode.Text));

376. cmd.Parameters.AddWithValue("@t10", (City.Text));


377. cmd.Parameters.AddWithValue("@t11", (State.Text));
378. cmd.Parameters.AddWithValue("@t12", (Country.Text));
379.
380. cmd.Parameters.AddWithValue("@t13", (Broker_PAN_No.Text));
381. cmd.Parameters.AddWithValue("@t14", (Broker_GST_No.Text));
382.
383. cmd.Parameters.AddWithValue("@t15", 11);
384. cmd.Parameters.AddWithValue("@t16", DateTime.Today);
385.
386.
387. cmd.ExecuteNonQuery();
388. con.Close();
389. MessageBox.Show("Data Updated");
390. string query = "select * from BrokerMaster";
391.
392. DataSet ds = new DataSet();
393. SqlDataAdapter dap = new SqlDataAdapter(query, con);
394. dap.Fill(ds);
395.
396. dataGridView1.DataSource = ds.Tables[0];
397.
398. con.Close();
399. }
400.
401. private void panel6_Paint(object sender, PaintEventArgs e)
402. {
403.
404. }
405.
406. private void button1_Click(object sender, EventArgs e)
407. {
408. this.Hide();
409. masters m = new masters();
410. m.Close();
411. home h = new home();
412. h.Closed += (s, args) => this.Close();
413. h.Show();
414.
415. }
416.
417. private void panel2_Paint(object sender, PaintEventArgs e)
418. {
419.
420. }
421. }
422. }

91 | P a g e
- Department Master Form

1. namespace CRMERP
2. {
3. public partial class departmentmaster : Form
4. {
5. public departmentmaster()
6. {
7. InitializeComponent();
8. }
9.
10. private void button1_Click(object sender, EventArgs e)
11. {
12. if (MessageBox.Show("Are you sure you want to exit?", "CRM ERP", Messag
eBoxButtons.OKCancel) == DialogResult.OK)
13. {
14. this.Close();
15. }
16.
17.
18. }
19.
20. private void departmentmaster_Load(object sender, EventArgs e)
21. {
22. bunifuFormFadeTransition1.ShowAsyc(this);
23.
24. this.WindowState = FormWindowState.Maximized;
25. this.KeyPreview = true;
26. string query = "select * from DeptMaster";
27.
28. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
29. con.Open();
30. DataSet ds = new DataSet();

92 | P a g e
31. SqlDataAdapter dap = new SqlDataAdapter(query, con);
32. dap.Fill(ds);
33.
34. dataGridView1.DataSource = ds.Tables[0];
35.
36. con.Close();
37. }
38.
39. private void Save_Click(object sender, EventArgs e)
40. {
41. if (string.IsNullOrWhiteSpace(DeptID.Text) || string.IsNullOrWhiteSpace
(DeptName.Text))
42. {
43. MessageBox.Show("Enter Valid Record", "Error");
44. }
45. else
46. {
47.
48. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
49. con.Open();
50.
51. decimal t1 = decimal.Parse(DeptID.Text);
52. string q = "select * from DeptMaster where DeptID='" + @t1 + "'";
53.
54. SqlCommand cmd = new SqlCommand(q, con);
55. SqlDataReader myreader = cmd.ExecuteReader();
56. if (myreader.HasRows)
57. {
58. MessageBox.Show("Department ID is already taken", "Error");
59. }
60. else
61. {
62. myreader.Close();
63. string q1 = "insert into DeptMaster values (@t1,@t2,@t3)";
64.
65. cmd = new SqlCommand(q1, con);
66.
67. cmd.Parameters.AddWithValue("@t1", decimal.Parse(DeptID.Text));

68. cmd.Parameters.AddWithValue("@t2", (DeptName.Text));


69. cmd.Parameters.AddWithValue("@t3", (DateTime.Today));
70.
71.
72.
73.
74. cmd.ExecuteNonQuery();
75. con.Close();
76. MessageBox.Show("Data Inserted");
77. string query = "select * from DeptMaster";
78.
79. DataSet ds = new DataSet();
80. SqlDataAdapter dap = new SqlDataAdapter(query, con);
81. dap.Fill(ds);
82.
83. dataGridView1.DataSource = ds.Tables[0];
84.
85. con.Close();
86. }
87. }
88. }
89.
90. private void DeptID_Leave(object sender, EventArgs e)
91. {
92. if (string.IsNullOrWhiteSpace(DeptID.Text))
93. {

93 | P a g e
94.
95. errorProvider1.SetError(DeptID, "Please Enter the Value!");
96.
97. }
98. else
99. {
100. errorProvider1.SetError(DeptID, "");
101. Regex r = new Regex("^[0-9]+$");
102. if (r.IsMatch(DeptID.Text))
103. {
104. errorProvider1.SetError(DeptID, "");
105. }
106. else
107. {
108. errorProvider1.SetError(DeptID, "Please Enter Valid Inpu
t!");
109. }
110.
111. }
112. }
113.
114. private void DeptName_Validate(object sender, EventArgs e)
115. {
116. if (string.IsNullOrWhiteSpace(DeptName.Text))
117. {
118.
119. errorProvider1.SetError(DeptName, "Name should not be left b
lank!");
120. }
121. else
122. {
123. errorProvider1.SetError(DeptName, "");
124.
125. Regex r = new Regex("^[a-z A-Z]+$");
126. if (r.IsMatch(DeptName.Text))
127. {
128. errorProvider1.SetError(DeptName, "");
129. }
130. else
131. {
132. errorProvider1.SetError(DeptName, "Please Enter Valid In
put!");
133. }
134. }
135. }
136.
137. private void Update_Click(object sender, EventArgs e)
138. {
139. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
140. con.Open();
141.
142. string q = "update DeptMaster set DeptID=@t1,DeptName=@t2,Timest
amp=@t3 where DeptID=@t1";
143.
144. SqlCommand cmd = new SqlCommand(q, con);
145. cmd.Parameters.AddWithValue("@t1", decimal.Parse(DeptID.Text));

146. cmd.Parameters.AddWithValue("@t2", (DeptName.Text));


147. cmd.Parameters.AddWithValue("@t3", (DateTime.Today));
148.
149.
150. cmd.ExecuteNonQuery();
151. con.Close();
152. MessageBox.Show("Data Updated");
153. string query = "select * from DeptMaster";

94 | P a g e
154.
155. DataSet ds = new DataSet();
156. SqlDataAdapter dap = new SqlDataAdapter(query, con);
157. dap.Fill(ds);
158.
159. dataGridView1.DataSource = ds.Tables[0];
160.
161. con.Close();
162. }
163.
164. private void Delete_Click(object sender, EventArgs e)
165. {
166. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
167. con.Open();
168. string q = "delete from DeptMaster where DeptID=@t1";
169. SqlCommand cmd = new SqlCommand(q, con);
170.
171. cmd.Parameters.AddWithValue("@t1", int.Parse(DeptID.Text));
172. cmd.ExecuteNonQuery();
173. con.Close();
174. MessageBox.Show("Data Deleted");
175. string query = "select * from DeptMaster";
176.
177. DataSet ds = new DataSet();
178. SqlDataAdapter dap = new SqlDataAdapter(query, con);
179. dap.Fill(ds);
180.
181. dataGridView1.DataSource = ds.Tables[0];
182.
183. con.Close();
184. }
185.
186. private void DeptMaster_KeyDown(object sender, KeyEventArgs e)
187. {
188. if (e.Control == true && e.KeyCode == Keys.S) {
189.
190. Save_Click(sender, e);
191.
192. }
193. if (e.Control == false && e.KeyCode == Keys.Escape)
194. {
195.
196. button1_Click(sender, e);
197.
198. }
199. }
200.
201. private void button7_Click(object sender, EventArgs e)
202. {
203. SqlCommand cmd;
204. SqlConnection con;
205.
206. con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
207. con.Open();
208.
209. if (string.IsNullOrWhiteSpace(DeptID.Text))
210. {
211. MessageBox.Show("Enter Department ID");
212. }
213. else
214. {
215. decimal t1 = decimal.Parse(DeptID.Text);
216. string q = "select * from DeptMaster where DeptID='" + @t1 +
"'";

95 | P a g e
217.
218. cmd = new SqlCommand(q, con);
219. SqlDataReader myreader = cmd.ExecuteReader();
220.
221. if (myreader.HasRows)
222. {
223. while (myreader.Read())
224. {
225. DeptID.Text = myreader["DeptID"].ToString();
226. DeptName.Text = myreader["DeptName"].ToString();
227.
228. }
229. }
230. else
231. {
232. MessageBox.Show("Department ID not found");
233. }
234. }
235.
236. con.Close();
237. }
238.
239. private void button8_Click(object sender, EventArgs e)
240. {
241. this.Hide();
242. home h = new home();
243. h.Closed += (s, args) => this.Close();
244. h.Show();
245. }
246. }
247. }

96 | P a g e
- Product Master

1. namespace CRMERP
2. {
3. public partial class pmaster : Form
4. {
5. OpenFileDialog dialog = new OpenFileDialog();
6.
7. ImageFormat format = ImageFormat.Jpeg;
8. public pmaster()
9. {
10. InitializeComponent();
11. }
12.
13. private void productmaster_Load(object sender, EventArgs e)
14. {
15. bunifuFormFadeTransition1.ShowAsyc(this);
16.
17. this.WindowState = FormWindowState.Maximized;
18. }
19.
20. private void button1_Click(object sender, EventArgs e)
21. {
22. this.Close();
23. }
24. string imagelocation1 = "";
25.
26. private void button9_Click(object sender, EventArgs e)
27. {
28.
29. if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
30. {
31.

97 | P a g e
32. imagelocation1 = dialog.FileName.ToString();
33. image.Image = Image.FromFile(imagelocation1);
34.
35.
36.
37.
38. }
39. }
40.
41. private void Save_Click(object sender, EventArgs e)
42. {
43. try
44. {
45. MemoryStream ms = new MemoryStream();
46. byte[] im = null;
47.
48. switch (dialog.Filter)
49. {
50. case ".jpg":
51.
52. format = ImageFormat.Png;
53. break;
54.
55. case ".bmp":
56.
57. format = ImageFormat.Bmp;
58. break;
59. }
60.
61.
62. image.Image.Save(ms, format);
63.
64.
65.
66. im = ms.ToArray();
67.
68.
69.
70. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
71. con.Open();
72. string q = "insert into ProductMaster values (@t1,@t2,@t3,@t4,@t5,@
t6,@t7,@t8,@t9,@im,@t11)";
73.
74. SqlCommand cmd = new SqlCommand(q, con);
75.
76. cmd.Parameters.AddWithValue("@t1", decimal.Parse(ProductID.Text));

77. cmd.Parameters.AddWithValue("@t2", (ProductName.Text));


78. cmd.Parameters.AddWithValue("@t3", (ProductAlias.Text));
79. cmd.Parameters.AddWithValue("@t4", ProductCategoryName.Text);
80. cmd.Parameters.AddWithValue("@t5", UOM.Text);
81. cmd.Parameters.AddWithValue("@t6", decimal.Parse(Rate.Text));
82. cmd.Parameters.AddWithValue("@t7", decimal.Parse(ProductLength.Text
));
83. cmd.Parameters.AddWithValue("@t8", (decimal.Parse(ProductHeight.Tex
t)));
84. cmd.Parameters.AddWithValue("@t9", (decimal.Parse(Range.Text)));
85. cmd.Parameters.AddWithValue("im", im);
86. cmd.Parameters.AddWithValue("@t11", DateTime.Now);
87. cmd.ExecuteNonQuery();
88. con.Close();
89. MessageBox.Show("Data Inserted");
90. string query = "select * from ProductMaster";
91.
92. DataSet ds = new DataSet();

98 | P a g e
93. SqlDataAdapter dap = new SqlDataAdapter(query, con);
94. dap.Fill(ds);
95.
96. dataGridView1.DataSource = ds.Tables[0];
97.
98. con.Close();
99.
100. }
101. catch(Exception ex)
102. {
103. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
104. }
105.
106.
107.
108. }
109.
110. private void button7_Click(object sender, EventArgs e)
111. {
112. SqlCommand cmd;
113. SqlConnection con;
114.
115. image.Image = null;
116. con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
117. con.Open();
118. decimal t1 = decimal.Parse(ProductID.Text);
119. string q = "select * from ProductMaster where ProductID='" + @t1
+ "'";
120.
121.
122. cmd = new SqlCommand(q, con);
123. SqlDataReader myreader = cmd.ExecuteReader();
124.
125.
126.
127. while (myreader.Read())
128. {
129. decimal n=decimal.Parse(myreader["ProductID"].ToString());
130. ProductID.Text = myreader["ProductID"].ToString();
131. ProductName.Text = myreader["ProductName"].ToString();
132. ProductCategoryName.Text = myreader["ProductCategoryName"].T
oString();
133. ProductAlias.Text = myreader["ProductAlias"].ToString();
134. Rate.Text = myreader["Rate"].ToString();
135.
136. UOM.Text = myreader["UOM"].ToString();
137.
138. ProductLength.Text = myreader["ProductLength"].ToString();
139.
140. ProductHeight.Text = myreader["ProductHeight"].ToString();
141. Range.Text = myreader["Range"].ToString();
142.
143. byte[] getImg = new byte[0];
144. getImg = ((byte[])myreader["ProductImage"]);
145.
146.
147.
148. MemoryStream ms = new MemoryStream(getImg);
149.
150.
151. image.Image = Image.FromStream(ms);
152.
153.
154.

99 | P a g e
155. }
156. }
157.
158. public Image byteArrayToImage(byte[] byteArrayIn)
159. {
160.
161. System.Drawing.ImageConverter converter = new System.Drawing.Ima
geConverter();
162. Image img = (Image)converter.ConvertFrom(byteArrayIn);
163.
164. return img;
165. }
166.
167. private void button10_Click(object sender, EventArgs e)
168. {
169. this.Hide();
170. home h = new home();
171. h.Closed += (s, args) => this.Close();
172. h.Show();
173. }
174. }
175. }

100 | P a g e
- Designation Master Form

1. namespace CRMERP
2. {
3. public partial class designationmaster : Form
4. {
5. public designationmaster()
6. {
7. InitializeComponent();
8. }
9.
10. private void designationmaster_Load(object sender, EventArgs e)
11. {
12. bunifuFormFadeTransition1.ShowAsyc(this);
13.
14. this.WindowState = FormWindowState.Maximized;
15. }
16.
17. private void button1_Click(object sender, EventArgs e)
18. {
19. this.Close();
20.
21. }
22.
23. private void desigid_validate(object sender, EventArgs e)
24. {
25. if (string.IsNullOrWhiteSpace(DesigID.Text))
26. {
27.
28. errorProvider1.SetError(DesigID, "Please Enter the Value!");

101 | P a g e
29.
30. }
31. else
32. {
33. errorProvider1.SetError(DesigID, "");
34. Regex r = new Regex("^[0-9]+$");
35. if (r.IsMatch(DesigID.Text))
36. {
37. errorProvider1.SetError(DesigID, "");
38. }
39. else
40. {
41. errorProvider1.SetError(DesigID, "Please Enter Valid Input!");
42. }
43.
44. }
45. }
46.
47. private void designame_validate(object sender, EventArgs e)
48. {
49. if (string.IsNullOrWhiteSpace(DesigName.Text))
50. {
51.
52. errorProvider1.SetError(DesigName, "Name should not be left blank!");

53. }
54. else
55. {
56. errorProvider1.SetError(DesigName, "");
57.
58. Regex r = new Regex("^[a-z A-Z]+$");
59. if (r.IsMatch(DesigName.Text))
60. {
61. errorProvider1.SetError(DesigName, "");
62. }
63. else
64. {
65. errorProvider1.SetError(DesigName, "Please Enter Valid Input!");
66. }
67. }
68. }
69.
70. private void Save_Click(object sender, EventArgs e)
71. {
72. if (string.IsNullOrWhiteSpace(DesigID.Text) || string.IsNullOrWhiteSpac
e(DesigName.Text))
73. {
74. MessageBox.Show("Enter Valid Record", "Error");
75. }
76. else
77. {
78.
79. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
80. con.Open();
81.
82. decimal t1 = decimal.Parse(DesigID.Text);
83. string q = "select * from DesigMaster where DesigID='" + @t1 + "'";
84.
85. SqlCommand cmd = new SqlCommand(q, con);
86. SqlDataReader myreader = cmd.ExecuteReader();
87. if (myreader.HasRows)
88. {
89. MessageBox.Show("Designation ID is already taken", "Error");
90. }
91. else

102 | P a g e
92. {
93. myreader.Close();
94. string q1 = "insert into DesigMaster values (@t1,@t2,@t3)";
95.
96. cmd = new SqlCommand(q1, con);
97. cmd.Parameters.AddWithValue("@t1", decimal.Parse(DesigID.Text));
98. cmd.Parameters.AddWithValue("@t2", (DesigName.Text));
99. cmd.Parameters.AddWithValue("@t3", (DateTime.Today));
100.
101.
102.
103.
104. cmd.ExecuteNonQuery();
105. con.Close();
106. MessageBox.Show("Data Inserted");
107. string query = "select * from DesigMaster";
108.
109. DataSet ds = new DataSet();
110. SqlDataAdapter dap = new SqlDataAdapter(query, con);
111. dap.Fill(ds);
112.
113. dataGridView1.DataSource = ds.Tables[0];
114.
115. con.Close();
116. }
117. }
118. }
119.
120. private void Update_Click(object sender, EventArgs e)
121. {
122. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
123. con.Open();
124.
125. string q = "update DesigMaster set DesigID=@t1,DesigName=@t2,Tim
estamp=@t3 where DesigID=@t1";
126.
127. SqlCommand cmd = new SqlCommand(q, con);
128. cmd.Parameters.AddWithValue("@t1", decimal.Parse(DesigID.Text));

129. cmd.Parameters.AddWithValue("@t2", (DesigName.Text));


130. cmd.Parameters.AddWithValue("@t3", (DateTime.Today));
131.
132.
133. cmd.ExecuteNonQuery();
134. con.Close();
135. MessageBox.Show("Data Updated");
136. string query = "select * from DesigMaster";
137.
138. DataSet ds = new DataSet();
139. SqlDataAdapter dap = new SqlDataAdapter(query, con);
140. dap.Fill(ds);
141.
142. dataGridView1.DataSource = ds.Tables[0];
143.
144. con.Close();
145. }
146.
147. private void Delete_Click(object sender, EventArgs e)
148. {
149. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
150. con.Open();
151. string q = "delete from DesigMaster where DesigID=@t1";
152. SqlCommand cmd = new SqlCommand(q, con);
153.

103 | P a g e
154. cmd.Parameters.AddWithValue("@t1", int.Parse(DesigID.Text));
155. cmd.ExecuteNonQuery();
156. con.Close();
157. MessageBox.Show("Data Deleted");
158. string query = "select * from DesigMaster";
159.
160. DataSet ds = new DataSet();
161. SqlDataAdapter dap = new SqlDataAdapter(query, con);
162. dap.Fill(ds);
163.
164. dataGridView1.DataSource = ds.Tables[0];
165.
166. con.Close();
167. }
168.
169. private void button7_Click(object sender, EventArgs e)
170. {
171. SqlCommand cmd;
172. SqlConnection con;
173.
174. con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
175. con.Open();
176.
177. if (string.IsNullOrWhiteSpace(DesigID.Text))
178. {
179. MessageBox.Show("Enter Designation ID");
180. }
181.
182. else
183. {
184. decimal t1 = decimal.Parse(DesigID.Text);
185.
186. string q = "select * from DesigMaster where DesigID='" + @t1 + "'";

187.
188. cmd = new SqlCommand(q, con);
189. SqlDataReader myreader = cmd.ExecuteReader();
190.
191. if (myreader.HasRows)
192. {
193. while (myreader.Read())
194. {
195. DesigID.Text = myreader["DesigID"].ToString();
196. DesigName.Text = myreader["DesigName"].ToString();
197. }
198. }
199. else
200. {
201. MessageBox.Show("Designation ID not found");
202. }
203. }
204.
205. con.Close();
206. }
207.
208. private void button8_Click(object sender, EventArgs e)
209. {
210. this.Hide();
211. home h = new home();
212. h.Closed += (s, args) => this.Close();
213. h.Show();
214. }
215. }
216. }

104 | P a g e
- Purchase Form

105 | P a g e
1. namespace CRMERP
2. {
3. public partial class purchase : Form
4. {
5. string productID;
6. decimal caltotal;
7. string VAddress;
8. string BAddress;
9. string SAddress;
10. decimal t1;
11. string p;
12. decimal d;
13. decimal d2;
14. decimal r;
15. bool counter;
16. internal static string psend;
17.
18. public purchase()
19. {
20. InitializeComponent();
21. }
22. public SqlConnection Connection()
23. {
24. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
25. return con;
26. }
27. public void fetch()
28. {
29. SqlConnection con = Connection();
30. con.Open();
31.
32. string Sql = "select distinct SuppName from SuppMaster";

106 | P a g e
33. SqlCommand cmd = new SqlCommand(Sql, con);
34. SqlDataReader DR = cmd.ExecuteReader();
35.
36. while (DR.Read())
37. {
38. SuppName.Items.Add(DR[0]);
39.
40. }
41. DR.Close();
42. Sql = "select distinct ProductName from ProductMaster";
43. cmd = new SqlCommand(Sql, con);
44. DR = cmd.ExecuteReader();
45.
46. while (DR.Read())
47. {
48. ItemName.Items.Add(DR[0]);
49.
50. }
51. DR.Close();
52. Sql = "select distinct CustName from CustMaster";
53. cmd = new SqlCommand(Sql, con);
54. DR = cmd.ExecuteReader();
55. while (DR.Read())
56. {
57. ShipTo.Items.Add(DR[0]);
58. // BillTo.Items.Add(DR[0]);
59. }
60.
61. DR.Close();
62. Sql = "select distinct CustName from CustMaster";
63. cmd = new SqlCommand(Sql, con);
64. DR = cmd.ExecuteReader();
65. while (DR.Read())
66. {
67. // ShipTo.Items.Add(DR[0]);
68. BillTo.Items.Add(DR[0]);
69. }
70.
71.
72. con.Close();
73. }
74. public void disable()
75. {
76.
77. ProductView.Enabled = false;
78. groupBox1.Enabled = false;
79. groupBox2.Enabled = false;
80. groupBox3.Enabled = false;
81. ItemName.Enabled = false;
82. Quantity.Enabled = false;
83. Rate.Enabled = false;
84. ItemTotal.Enabled = false;
85. Uom.Enabled = false;
86. Total.Enabled = false;
87. Select_GST.Enabled = false;
88. Tax_Total.Enabled = false;
89. GrandTotal.Enabled = false;
90. Terms_Con.Enabled = false;
91.
92. }
93.
94.
95. private void purchase_Load(object sender, EventArgs e)
96. {
97. // TODO: This line of code loads data into the 'cRMERPDataSet.POProduct
Master' table. You can move, or remove it, as needed.

107 | P a g e
98. // this.pOProductMasterTableAdapter.Fill(this.cRMERPDataSet.POProductMa
ster);
99. this.WindowState = FormWindowState.Maximized;
100. // ProductView.ReadOnly = true;
101.
102. counter = false;
103.
104. fetch();
105.
106. disable();
107.
108. }
109.
110. public void transactionInsertTrigger()
111. {
112. SqlConnection con = Connection();
113. con.Open();
114. try
115. {
116. string s = "insert into TransactionMaster values(@t1,@t2,@t3
)";
117. SqlCommand cmd = new SqlCommand(s, con);
118. cmd.Parameters.AddWithValue("@t1", PoNO.Text);
119. cmd.Parameters.AddWithValue("@t2", 0);
120. cmd.Parameters.AddWithValue("@t3", DateTime.Now);
121. cmd.ExecuteNonQuery();
122.
123.
124.
125. con.Close();
126.
127. }
128. catch (Exception ex)
129. {
130. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
131. }
132. }
133. public void insertTrigger()
134. {
135.
136. SqlConnection con = Connection();
137. con.Open();
138. try
139. {
140.
141. decimal iq = 0;
142. bool pa;
143. string q = "select * from StockMaster where ProductID='" + p
roductID + "';";
144. SqlCommand cmd = new SqlCommand(q, con);
145. SqlDataReader DR = cmd.ExecuteReader();
146. if (DR.Read())
147. {
148. iq = decimal.Parse(DR["Quantity"].ToString());
149. pa = true;
150.
151. }
152. else
153. {
154. pa = false;
155. }
156. DR.Close();
157. decimal fq = iq + decimal.Parse(Quantity.Text);
158.
159. if (pa==true)

108 | P a g e
160. {
161. q = "update StockMaster set Quantity='" + fq + "' where
ProductID='"+productID+"';";
162. cmd = new SqlCommand(q, con);
163. cmd.ExecuteNonQuery();
164.
165. }
166. else
167. {
168. q = "insert into StockMaster values(@t1,@t2,@t3)";
169. cmd = new SqlCommand(q, con);
170. cmd.Parameters.AddWithValue("@t1", productID);
171. cmd.Parameters.AddWithValue("@t2", ItemName.Text);
172. cmd.Parameters.AddWithValue("@t3", fq);
173. cmd.ExecuteNonQuery();
174.
175. }
176.
177.
178.
179. con.Close();
180.
181. }
182. catch (Exception ex)
183. {
184. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
185. }
186.
187. }
188. public void updateTrigger()
189. {
190.
191. SqlConnection con = Connection();
192. con.Open();
193. try
194. {
195. string s1="select * from POProductMaster where PoNO='"+PoNO.
Text+"' and ProductID='"+productID+ "';";
196. decimal oldq = 0;
197. decimal newq = 0;
198. decimal fq = 0;
199. SqlCommand cmd = new SqlCommand(s1, con);
200. SqlDataReader DR = cmd.ExecuteReader();
201. if (DR.Read())
202. {
203. oldq =decimal.Parse(DR["Quantity"].ToString());
204.
205. }
206. DR.Close();
207. newq = decimal.Parse(Quantity.Text);
208. bool check;
209. if (oldq > newq)
210. {
211. fq = oldq - newq;
212. check = true;
213. }
214. else
215. {
216. fq = newq-oldq;
217. check = false;
218. }
219.
220.
221.
222. decimal iq = 0;

109 | P a g e
223.
224. string q = "select * from StockMaster where ProductID='" + p
roductID + "';";
225. cmd = new SqlCommand(q, con);
226. DR = cmd.ExecuteReader();
227. if (DR.Read())
228. {
229. iq = decimal.Parse(DR["Quantity"].ToString());
230.
231. }
232.
233.
234. DR.Close();
235.
236. decimal ffq = 0;
237. if (check == true)
238. {
239. ffq = iq - fq;
240. }
241. else if(check==false)
242. {
243. ffq = fq + iq;
244.
245. }
246.
247. string s = "update StockMaster set Quantity='" + ffq + "' wh
ere ProductID='" + productID + "';";
248. cmd = new SqlCommand(s, con);
249. cmd.ExecuteNonQuery();
250. con.Close();
251.
252. }
253. catch (Exception ex)
254. {
255. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
256. }
257.
258. }
259.
260.
261. public void deletePOTrigger(SqlConnection con)
262. {
263.
264.
265. string s = "delete from TransactionMaster where PoNO='" + PoNO.T
ext + "'; ";
266. SqlCommand cmd = new SqlCommand(s, con);
267.
268. cmd.ExecuteNonQuery();
269.
270.
271. s = "select ProductID,Quantity from POProductMaster where PoNO='
" + PoNO.Text + "'; ";
272. cmd = new SqlCommand(s, con);
273.
274. SqlDataReader dr = cmd.ExecuteReader();
275.
276. decimal oldq = 0;
277. decimal iq = 0;
278. decimal fq = 0;
279.
280. while (dr.Read())
281. {
282. productID = dr["ProductID"].ToString();
283. oldq = decimal.Parse(dr["Quantity"].ToString());

110 | P a g e
284.
285. iq = getstock(productID);
286.
287.
288. fq = iq - oldq;
289. updatestock(fq);
290. }
291.
292. dr.Close();
293. s = "delete from POProductMaster where PoNO='" + PoNO.Text + "';
";
294. cmd = new SqlCommand(s, con);
295.
296. cmd.ExecuteNonQuery();
297.
298.
299.
300. con.Close();
301.
302.
303.
304.
305. }
306.
307. public decimal getstock(string productID)
308. {
309. SqlConnection con = Connection();
310. con.Open();
311. decimal iq = 0;
312. string q = "select * from StockMaster where ProductID='" + produ
ctID + "';";
313. SqlCommand cmd = new SqlCommand(q, con);
314. SqlDataReader DR = cmd.ExecuteReader();
315. if (DR.Read())
316. {
317. iq = decimal.Parse(DR["Quantity"].ToString());
318. }
319. DR.Close();
320. con.Close();
321. return iq;
322. }
323.
324. public void updatestock(decimal fq)
325. {
326. SqlConnection con = Connection();
327. con.Open();
328. string s = "update StockMaster set Quantity=@t1 where ProductID=
'" + productID + "';";
329.
330. SqlCommand cmd = new SqlCommand(s, con);
331.
332. cmd.Parameters.AddWithValue("@t1", fq);
333. cmd.ExecuteNonQuery();
334. con.Close();
335. }
336.
337. public void deleteTrigger()
338. {
339.
340. SqlConnection con = Connection();
341. con.Open();
342. try
343. {
344. //string s = "select * from POProductMaster where PoNO='" +
PoNO.Text + "'and ProductID='"+productID+"';";
345. //SqlCommand cmd = new SqlCommand(s, con);

111 | P a g e
346. //SqlDataReader DR = cmd.ExecuteReader();
347. //decimal dq = 0;
348. //if (DR.Read())
349. //{
350. // dq = decimal.Parse(DR["Quantity"].ToString());
351.
352. //}
353.
354.
355.
356. decimal iq = 0;
357. string q = "select * from StockMaster where ProductID='" + p
roductID + "';";
358. SqlCommand cmd = new SqlCommand(q, con);
359. SqlDataReader DR = cmd.ExecuteReader();
360. if (DR.Read())
361. {
362. iq = decimal.Parse(DR["Quantity"].ToString());
363. }
364. DR.Close();
365. decimal fq = iq - decimal.Parse(Quantity.Text);
366.
367. q = "update StockMaster set Quantity=@t1 where ProductID='"
+ productID + "';";
368.
369. cmd = new SqlCommand(q, con);
370.
371. cmd.Parameters.AddWithValue("@t1", fq);
372. cmd.ExecuteNonQuery();
373. con.Close();
374.
375. }
376. catch (Exception ex)
377. {
378. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
379. }
380.
381. }
382. private void label2_Click(object sender, EventArgs e)
383. {
384.
385. }
386.
387. private void EmpDOB_onValueChanged(object sender, EventArgs e)
388. {
389.
390. }
391.
392. private void button1_Click(object sender, EventArgs e)
393. {
394. if (PoNO.Text == "" || counter==true)
395. {
396. this.Close();
397. }
398.
399. else
400. {
401. SqlConnection con = Connection();
402. con.Open();
403. string q = "select * from POMaster where PoNo='" + PoNO.Text
+ "';";
404. SqlCommand cmd = new SqlCommand(q, con);
405. SqlDataReader DR = cmd.ExecuteReader();
406. if (DR.Read())
407. {

112 | P a g e
408. DR.Close();
409. this.Close();
410. }
411. else if (MessageBox.Show("The Details Entered will be delet
ed...Are you sure you want to exit?", "CRM ERP", MessageBoxButtons.OKCancel) == Dia
logResult.OK)
412. {
413. try
414. {
415. DR.Close();
416. deletePOTrigger(con);
417. this.Close();
418.
419. }
420. catch (Exception ex)
421. {
422. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
423. }
424.
425. }
426. }
427. }
428.
429. public void enable()
430. {
431.
432. ProductView.Enabled = true;
433. groupBox1.Enabled = true;
434. groupBox2.Enabled = true;
435. groupBox3.Enabled = true;
436. ItemName.Enabled = true;
437. Quantity.Enabled = true;
438. Rate.Enabled = true;
439. ItemTotal.Enabled = true;
440. Uom.Enabled = true;
441. Total.Enabled = true;
442. Select_GST.Enabled = true;
443. Tax_Total.Enabled = true;
444. GrandTotal.Enabled = true;
445. Terms_Con.Enabled = true;
446.
447. }
448.
449. public void resetData()
450. {
451. PoNO.Text = "";
452. PoDate.Text = "";
453. BillTo.Text = "";
454. BGstNo.Text = "";
455. BEmailId.Text = "";
456.
457. BMobileNo.Text = "";
458.
459. SuppName.Text = "";
460.
461. SuppMobileNo.Text = "";
462. SuppGstNo.Text = "";
463.
464. SuppEmailId.Text = "";
465.
466. PartyONo.Text = "";
467. ValidFrom.Text = "";
468.
469. ValidTo.Text = "";
470. ShipTo.Text = "";

113 | P a g e
471. SGstNo.Text = "";
472. SMobileNo.Text = "";
473.
474. SEmailId.Text = "";
475. ItemName.Text = "";
476.
477. Quantity.Text = "";
478. Rate.Text = "";
479. ItemTotal.Text = "";
480. Uom.Text = "";
481. Total.Text = "";
482. Select_GST.Text = "";
483. Tax_Total.Text = "";
484. GrandTotal.Text = "";
485. Terms_Con.Text = "";
486. }
487.
488. private void Save_Click(object sender, EventArgs e)
489. {
490. counter = true;
491. SqlConnection con = Connection();
492. try
493. {
494. con.Open();
495. t1 = decimal.Parse(PoNO.Text);
496. string q = "select * from POMaster where PoNo='" + @t1 + "'"
;
497.
498. SqlCommand cmd = new SqlCommand(q, con);
499. SqlDataReader myreader = cmd.ExecuteReader();
500. if (myreader.HasRows)
501. {
502. MessageBox.Show("Purchase order number is already taken"
, "CRM-ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
503. }
504. else
505. {
506. myreader.Close();
507.
508. q = "select sum(ProductTotal) from POProductMaster where
PONo='" + t1 + "';";
509. cmd = new SqlCommand(q, con);
510. caltotal = (decimal)cmd.ExecuteScalar();
511. string q1 = "insert into POMaster values (@t1,@t2,@t3,@t
4,@t5,@t6,@t7,@t8,@t9,@t10,@t11,@t12,@t13,@t14,@t15,@t16,@t17,@t18,@t19,@t20,@t21,@
t22,@t23,@t24,@t25)";
512.
513. cmd = new SqlCommand(q1, con);
514.
515.
516. cmd.Parameters.AddWithValue("@t1", (PoNO.Text));
517. cmd.Parameters.AddWithValue("@t2", (PoDate.Value.Date));

518. cmd.Parameters.AddWithValue("@t3", (BillTo.Text));


519. cmd.Parameters.AddWithValue("@t4", (BGstNo.Text));
520. cmd.Parameters.AddWithValue("@t5", decimal.Parse(BMobile
No.Text));
521. cmd.Parameters.AddWithValue("@t6", (BEmailId.Text));
522. cmd.Parameters.AddWithValue("@t7", (ShipTo.Text));
523. cmd.Parameters.AddWithValue("@t8", (SGstNo.Text));
524. cmd.Parameters.AddWithValue("@t9", decimal.Parse(SMobile
No.Text));
525. cmd.Parameters.AddWithValue("@t10", (SEmailId.Text));
526. cmd.Parameters.AddWithValue("@t11", (SuppName.Text));
527. cmd.Parameters.AddWithValue("@t12", (SuppGstNo.Text));

114 | P a g e
528. cmd.Parameters.AddWithValue("@t13", decimal.Parse(SuppMo
bileNo.Text));
529. cmd.Parameters.AddWithValue("@t14", (SuppEmailId.Text));

530. cmd.Parameters.AddWithValue("@t15", (PartyONo.Text));


531. cmd.Parameters.AddWithValue("@t16", (ValidFrom.Value.Dat
e));
532. cmd.Parameters.AddWithValue("@t17", (ValidTo.Value.Date)
);
533.
534.
535. cmd.Parameters.AddWithValue("@t18", (caltotal));
536. cmd.Parameters.AddWithValue("@t19", (Select_GST.Text));

537. cmd.Parameters.AddWithValue("@t20", decimal.Parse(Tax_To


tal.Text));
538.
539. cmd.Parameters.AddWithValue("@t21", decimal.Parse(GrandT
otal.Text));
540. cmd.Parameters.AddWithValue("@t22", (Terms_Con.Text));
541. cmd.Parameters.AddWithValue("@t23", BAddress);
542. cmd.Parameters.AddWithValue("@t24", VAddress);
543. cmd.Parameters.AddWithValue("@t25", SAddress);
544.
545.
546.
547.
548.
549. cmd.ExecuteNonQuery();
550. con.Close();
551. transactionInsertTrigger();
552.
553. MessageBox.Show("Data inserted successfully", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
554.
555. string mobno = (SuppMobileNo.Text);
556. string otp = PoNO.Text;
557. // string text = "Hey '" + username + "', your OTP is '"
+ otp + "'";
558.
559. string text = " Dear Customer \n Purchase Order Having P
ONumber :" + otp + "is generated. \n Regards \n Stalwart Tex International LLP,Mumb
ai-02";
560.
561.
562. con.Open();
563. cmd = new SqlCommand("SSendSmsSQLP", con);
564. cmd.CommandType = CommandType.StoredProcedure;
565. cmd.Parameters.Add("@MobileNo", SqlDbType.VarChar).Value
= mobno;
566. cmd.Parameters.Add("@smstext", SqlDbType.VarChar).Value
= text;
567. cmd.Parameters.Add("@sResponse", SqlDbType.VarChar).Valu
e = "test";
568.
569. cmd.ExecuteNonQuery();
570. con.Close();
571. }
572. }
573. catch (Exception ex)
574. {
575. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
576.
577. }
578. }

115 | P a g e
579.
580. private void BillTo_Leave(object sender, EventArgs e)
581. {
582. SqlConnection con = Connection();
583. con.Open();
584. string x = BillTo.Text;
585. string Sql = "select * from CustMaster where CustName='" + x + "
';";
586. SqlCommand cmd = new SqlCommand(Sql, con);
587. SqlDataReader DR = cmd.ExecuteReader();
588.
589. while (DR.Read())
590. {
591. BGstNo.Text = DR["Cust_GST_No"].ToString();
592. BMobileNo.Text = DR["CustMobile1"].ToString();
593. BEmailId.Text = DR["CustEmail1"].ToString();
594. BAddress =DR["OfficeNo"].ToString()+", "+ DR["BuildingName"]
.ToString() + ", " + DR["Address1"].ToString() + ", " + DR["Address2"].ToString() +
", " + DR["Landmark"].ToString() + ", " + DR["City"].ToString() + " - " + DR["Pinc
ode"].ToString() + ", " + DR["State"].ToString();
595.
596. }
597. }
598.
599.
600. private void Shipto(object sender, EventArgs e)
601. {
602. string str = ShipTo.Text;
603.
604. SqlConnection con = Connection();
605. con.Open();
606.
607. string Sql = "select * from CustMaster where CustName='" + str +
"';";
608. SqlCommand cmd = new SqlCommand(Sql, con);
609. SqlDataReader DR = cmd.ExecuteReader();
610.
611. while (DR.Read())
612. {
613. SGstNo.Text = DR["Cust_GST_No"].ToString();
614. SMobileNo.Text = DR["CustMobile1"].ToString();
615. SEmailId.Text = DR["CustEmail1"].ToString();
616. SAddress = DR["OfficeNo"].ToString() + ", " + DR["BuildingNa
me"].ToString() + ", " + DR["Address1"].ToString() + ", " + DR["Address2"].ToString
() + ", " + DR["Landmark"].ToString() + ", " + DR["City"].ToString() + " - " + DR["
Pincode"].ToString() + ", " + DR["State"].ToString();
617.
618. }
619. }
620.
621. private void selectGST(object sender, EventArgs e)
622. {
623. string x = Select_GST.Text;
624.
625. decimal total = decimal.Parse(Total.Text);
626.
627. if (x != null)
628. {
629. decimal t = 5;
630.
631. Tax_Total.Text = t.ToString();
632. GrandTotal.Text = (total + t).ToString();
633.
634. }
635. }
636.

116 | P a g e
637. private void suppname(object sender, EventArgs e)
638. {
639. SqlConnection con = Connection();
640. con.Open();
641. string x = SuppName.Text;
642. string Sql = "select * from SuppMaster where SuppName='" + x + "
';";
643. SqlCommand cmd = new SqlCommand(Sql, con);
644. SqlDataReader DR = cmd.ExecuteReader();
645.
646. while (DR.Read())
647. {
648. SuppGstNo.Text = DR["Supp_GST_No"].ToString();
649. SuppMobileNo.Text = DR["SuppMobile1"].ToString();
650. SuppEmailId.Text = DR["SuppEmail1"].ToString();
651. VAddress = DR["OfficeNo"].ToString() + ", " + DR["BuildingNa
me"].ToString() + ", "+DR["Address1"].ToString() + ", " + DR["Address2"].ToString()
+ ", " + DR["Landmark"].ToString() + ", " + DR["City"].ToString() + " - " + DR["Pi
ncode"].ToString() + ", " + DR["State"].ToString() + "";
652.
653. }
654. }
655.
656. private void Delete_Click(object sender, EventArgs e)
657. {
658. SqlConnection con = Connection();
659. try
660. {
661. con.Open();
662. decimal t1 = decimal.Parse(PoNO.Text);
663.
664. string q = "select * from POMaster where PoNO='" + @t1 + "'"
;
665.
666. SqlCommand cmd = new SqlCommand(q, con);
667. SqlDataReader myreader = cmd.ExecuteReader();
668. if (myreader.HasRows)
669. {
670. myreader.Close();
671. deletePOTrigger(con);
672. con.Open();
673. q = "delete from POMaster where PoNO=@t1";
674. cmd = new SqlCommand(q, con);
675.
676. cmd.Parameters.AddWithValue("@t1", int.Parse(PoNO.Text))
;
677. cmd.ExecuteNonQuery();
678. con.Close();
679. MessageBox.Show("Data deleted successfully", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
680.
681. resetData();
682.
683. }
684. else
685. {
686. MessageBox.Show("Purchase order number not found", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
687.
688. }
689. con.Close();
690. }
691. catch (Exception ex)
692. {
693. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);

117 | P a g e
694.
695. }
696. }
697.
698. private void ItemNameLeave(object sender, EventArgs e)
699. {
700. SqlConnection con = Connection();
701. con.Open();
702.
703. string x = ItemName.Text;
704.
705. string Sql = "select * from POProductMaster where ProductName='"
+ x + "' and PoNO='" + PoNO.Text + "';";
706. SqlCommand cmd = new SqlCommand(Sql, con);
707. SqlDataReader DR = cmd.ExecuteReader();
708.
709. if (DR.Read())
710. {
711. button9.Enabled = false;
712. MessageBox.Show("Product already exists, please update the p
roduct", "CRM-ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
713. }
714. else
715. {
716. button9.Enabled = true;
717. }
718.
719. DR.Close();
720.
721. Sql = "select ProductID,Rate,UOM from ProductMaster where Produc
tName='" + x + "';";
722. cmd = new SqlCommand(Sql, con);
723. DR = cmd.ExecuteReader();
724.
725. while (DR.Read())
726. {
727. productID = DR["ProductID"].ToString();
728. Rate.Text = DR["Rate"].ToString();
729. Uom.Text = DR["UOM"].ToString();
730.
731. }
732. con.Close();
733. }
734.
735. private void button9_Click(object sender, EventArgs e)
736. {
737. SqlConnection con = Connection();
738. try
739. {
740. con.Open();
741.
742.
743. decimal t1 = decimal.Parse(PoNO.Text);
744.
745. string sql = "select * from POProductMaster where PoNO='"+t1
+"' and ProductID='"+productID+"';";
746. SqlCommand cmd = new SqlCommand(sql, con);
747.
748. SqlDataReader dr= cmd.ExecuteReader();
749. bool a;
750. if(dr.Read())
751. {
752. a = true;
753. }
754. else
755. {

118 | P a g e
756. a = false;
757. }
758. dr.Close();
759. if (a == false)
760. {
761. sql = "insert into POProductMaster values(@t1,@t2,@t3,@t
4,@t5,@t6,@t7)";
762. cmd = new SqlCommand(sql, con);
763. cmd.Parameters.AddWithValue("@t1", PoNO.Text);
764. cmd.Parameters.AddWithValue("@t2", productID);
765. cmd.Parameters.AddWithValue("@t3", ItemName.Text);
766. cmd.Parameters.AddWithValue("@t4", Quantity.Text);
767. cmd.Parameters.AddWithValue("@t5", Rate.Text);
768. cmd.Parameters.AddWithValue("@t6", Uom.Text);
769. cmd.Parameters.AddWithValue("@t7", ItemTotal.Text);
770. cmd.ExecuteNonQuery();
771. MessageBox.Show("Item Added Successfully", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
772.
773. insertTrigger();
774.
775. }
776. string query = "select * from POProductMaster where PoNO='"
+ PoNO.Text + "';"
777. DataSet ds = new DataSet();
778. SqlDataAdapter dap = new SqlDataAdapter(query, con);
779. dap.Fill(ds);
780.
781.
782. ProductView.DataSource = ds.Tables[0];
783.
784.
785. t1 = decimal.Parse(PoNO.Text);
786. String q = "select sum(ProductTotal) from POProductMast
er where PONo='" + t1 + "';";
787. cmd = new SqlCommand(q, con);
788. caltotal = (decimal)cmd.ExecuteScalar();
789. Total.Text = caltotal.ToString();
790. GrandTotal.Text = caltotal.ToString();
791.
792.
793. con.Close();
794. ItemName.Text = "";
795. Quantity.Text = "";
796. Rate.Text = "";
797. ItemTotal.Text = "";
798. Uom.Text = "";
799.
800. }
801. catch (Exception ex)
802. {
803. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
804. }
805.
806.
807. }
808.
809. private void calItem(object sender, EventArgs e)
810. {
811. decimal rate = Decimal.Parse(Rate.Text);
812. decimal quantity = Decimal.Parse(Quantity.Text);
813. decimal total = rate * quantity;
814. ItemTotal.Text = total.ToString();
815. }
816. private void button10_Click(object sender, EventArgs e)

119 | P a g e
817. {
818.
819. SqlConnection con = Connection();
820. try
821. {
822. con.Open();
823. if (string.IsNullOrWhiteSpace(ItemName.Text))
824. {
825. MessageBox.Show("Enter ItemName");
826. }
827. else
828. {
829. updateTrigger();
830. string x = ItemName.Text;
831. string Sql = "select ProductID from ProductMaster where
ProductName='" + x + "';";
832. SqlCommand cmd = new SqlCommand(Sql, con);
833.
834. SqlDataReader DR = cmd.ExecuteReader();
835. while (DR.Read())
836. {
837. productID = DR["ProductID"].ToString();
838. }
839. DR.Close();
840. decimal t1 = decimal.Parse(PoNO.Text);
841. string sql = "update POProductMaster set ProductID=@t2,Q
uantity=@t3,Rate=@t4,Uom=@t5,ProductTotal=@t6 where ProductName=@t7 and PoNO=@t1";

842.
843. cmd = new SqlCommand(sql, con);
844. cmd.Parameters.AddWithValue("@t1", PoNO.Text);
845. cmd.Parameters.AddWithValue("@t2", productID);
846. cmd.Parameters.AddWithValue("@t3", Quantity.Text);
847. cmd.Parameters.AddWithValue("@t4", Rate.Text);
848. cmd.Parameters.AddWithValue("@t5", Uom.Text);
849. cmd.Parameters.AddWithValue("@t6", ItemTotal.Text);
850. cmd.Parameters.AddWithValue("@t7", ItemName.Text);
851. cmd.ExecuteNonQuery();
852. MessageBox.Show("Item Updated Successfully", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
853.
854.
855. string query = "select * from POProductMaster where PoNO
='" + PoNO.Text + "';";
856.
857.
858. DataSet ds = new DataSet();
859. SqlDataAdapter dap = new SqlDataAdapter(query, con);
860. dap.Fill(ds);
861. ProductView.DataSource = ds.Tables[0];
862.
863. string q = "select sum(ProductTotal) from POProductMaste
r where PoNO='" + t1 + "';";
864. cmd = new SqlCommand(q, con);
865. caltotal = (decimal)cmd.ExecuteScalar();
866. Total.Text = caltotal.ToString();
867. GrandTotal.Text = caltotal.ToString();
868.
869.
870. con.Close();
871. ItemName.Text = "";
872. Quantity.Text = "";
873. Rate.Text = "";
874. ItemTotal.Text = "";
875. Uom.Text = "";
876. }

120 | P a g e
877.
878. }
879. catch (Exception ex)
880. {
881. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
882. }
883.
884. }
885.
886. private void productViewMouseClick(object sender, MouseEventArgs e)

887. {
888.
889. productID= ProductView.SelectedRows[0].Cells[1].Value.ToString()
;
890. ItemName.Text = ProductView.SelectedRows[0].Cells[2].Value.ToStr
ing();
891. Quantity.Text = ProductView.SelectedRows[0].Cells[3].Value.ToStr
ing();
892. Rate.Text = ProductView.SelectedRows[0].Cells[4].Value.ToString(
);
893. Uom.Text = ProductView.SelectedRows[0].Cells[5].Value.ToString()
;
894. ItemTotal.Text = ProductView.SelectedRows[0].Cells[6].Value.ToSt
ring();
895. }
896.
897. private void button11_Click(object sender, EventArgs e)
898.
899. {
900.
901. string pono = ProductView.SelectedRows[0].Cells[0].Value.ToStrin
g();
902. string pid = ProductView.SelectedRows[0].Cells[1].Value.ToString
();
903. string quan = ProductView.SelectedRows[0].Cells[3].Value.ToStrin
g();
904. deleteTrigger();
905. SqlConnection con = Connection();
906. con.Open();
907.
908. string Sql = "delete from POProductMaster where PoNO='" + pono +
"'and ProductID='" + pid + "'and Quantity='" + quan + "';";
909. SqlCommand cmd = new SqlCommand(Sql, con);
910. cmd.ExecuteNonQuery();
911. MessageBox.Show("Item deleted successfully", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
912.
913.
914. string query = "select * from POProductMaster where PoNO='" + Po
NO.Text + "';";
915.
916.
917. DataSet ds = new DataSet();
918. SqlDataAdapter dap = new SqlDataAdapter(query, con);
919. dap.Fill(ds);
920. ProductView.DataSource = ds.Tables[0];
921.
922. string q= "select * from POProductMaster where PoNO='" + PoNO.Te
xt + "';";
923. cmd = new SqlCommand(q, con);
924. SqlDataReader dr = cmd.ExecuteReader();
925. Boolean b;
926. if (dr.Read())
927. {

121 | P a g e
928. b = true;
929. }
930. else
931. {
932. b = false;
933. }
934. dr.Close();
935. if (b == true)
936. {
937. q = "select sum(ProductTotal) from POProductMaster where PoN
O='" + PoNO.Text + "';";
938. cmd = new SqlCommand(q, con);
939. caltotal = (decimal)cmd.ExecuteScalar();
940. }
941. else
942. {
943. caltotal = 0;
944. }
945. Total.Text = caltotal.ToString();
946. GrandTotal.Text = caltotal.ToString();
947. con.Close();
948. ItemName.Text = "";
949. Quantity.Text = "";
950. Rate.Text = "";
951. ItemTotal.Text = "";
952. Uom.Text = "";
953. con.Close();
954. }
955. private void button7_Click(object sender, EventArgs e)
956. {
957. SqlCommand cmd;
958. try
959. {
960. SqlConnection con = Connection();
961. con.Open();
962.
963. if (string.IsNullOrWhiteSpace(PoNO.Text))
964. {
965. MessageBox.Show("Enter purchase order number", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
966. }
967. else
968. {
969. decimal t1 = decimal.Parse(PoNO.Text);
970. string q = "select * from POMaster where PoNO='" + PoNO.Text
+ "'";
971.
972. cmd = new SqlCommand(q, con);
973. SqlDataReader myreader = cmd.ExecuteReader();
974.
975. if (myreader.HasRows)
976. {
977.
978. while (myreader.Read())
979. {
980. PoNO.Text = myreader["PoNO"].ToString();
981. PoDate.Text = myreader["PoDate"].ToString();
982. BillTo.Text = myreader["BillTo"].ToString();
983. BGstNo.Text = myreader["BGstNo"].ToString();
984. BMobileNo.Text = myreader["BMobileNo"].ToString();
985.
986. BEmailId.Text = myreader["BEmailId"].ToString();
987.
988. SuppName.Text = myreader["SuppName"].ToString();
989.

122 | P a g e
990. SuppMobileNo.Text = myreader["SuppMobileNo"].ToStrin
g();
991. SuppGstNo.Text = myreader["SuppGstNo"].ToString();
992.
993. SuppEmailId.Text = myreader["SuppEmailId"].ToString(
);
994.
995. PartyONo.Text = myreader["PartyONo"].ToString();
996. ValidFrom.Text = myreader["ValidFrom"].ToString();
997.
998. ValidTo.Text = myreader["ValidTo"].ToString();
999. ShipTo.Text = myreader["ShipTo"].ToString();
1000.
1001. SGstNo.Text = myreader["SGstNo"].ToString();
1002. SMobileNo.Text = myreader["SMobileNo"].ToString();
1003.
1004. SEmailId.Text = myreader["SEmailId"].ToString();
1005.
1006. Total.Text = myreader["Total"].ToString();
1007.
1008. Select_GST.Text = myreader["Select_GST"].ToString();

1009.
1010. Tax_Total.Text = myreader["Tax_Total"].ToString();
1011. GrandTotal.Text = myreader["GrandTotal"].ToString();

1012.
1013. Terms_Con.Text = myreader["Terms_Con"].ToString();
1014.
1015. BAddress = myreader["BAddress"].ToString();
1016. VAddress = myreader["VAddress"].ToString();
1017. SAddress = myreader["SAddress"].ToString();
1018.
1019. }
1020. myreader.Close();
1021. string query = "select * from POProductMaster where
PoNO='" + PoNO.Text + "';";
1022.
1023.
1024. DataSet ds = new DataSet();
1025. SqlDataAdapter dap = new SqlDataAdapter(query, con);

1026. dap.Fill(ds);
1027.
1028.
1029. ProductView.DataSource = ds.Tables[0];
1030.
1031.
1032. }
1033. else
1034. {
1035. MessageBox.Show("Purchase order number not found", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
1036.
1037. }
1038. con.Close();
1039. }
1040. }catch(Exception ex)
1041. {
1042. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
1043. }
1044.
1045. }
1046.
1047. private void button5_Click(object sender, EventArgs e)

123 | P a g e
1048. {
1049. counter = true;
1050. try
1051. {
1052. SqlConnection con = Connection();
1053. con.Open();
1054.
1055. BillTo_Leave(sender, e);
1056. suppname(sender, e);
1057. Shipto(sender, e);
1058.
1059. string q = "update POMaster set PoNO=@t1,PoDate=@t2,BillTo=@
t3,BGstNo=@t4,BMobileNo=@t5,BEmailId=@t6,ShipTo=@t7,SGstNo=@t8,SMobileNo=@t9,SEmail
Id=@t10,SuppName=@t11,SuppGstNo=@t12,SuppMobileNo=@t13,SuppEmailId=@t14,PartyONo=@t
15,ValidFrom=@t16,ValidTo=@t17,Total=@t18,Select_GST=@t19,Tax_Total=@t20,GrandTotal
=@t21,Terms_Con=@t22,BAddress=@t23,VAddress=@t24,SAddress=@t25 where PoNO=@t1";
1060.
1061. SqlCommand cmd = new SqlCommand(q, con);
1062. cmd.Parameters.AddWithValue("@t1", (PoNO.Text));
1063. cmd.Parameters.AddWithValue("@t2", (PoDate.Value.Date));
1064. cmd.Parameters.AddWithValue("@t3", (BillTo.Text));
1065. cmd.Parameters.AddWithValue("@t4", (BGstNo.Text));
1066. cmd.Parameters.AddWithValue("@t5", decimal.Parse(BMobileNo.T
ext));
1067. cmd.Parameters.AddWithValue("@t6", (BEmailId.Text));
1068. cmd.Parameters.AddWithValue("@t7", (ShipTo.Text));
1069. cmd.Parameters.AddWithValue("@t8", (SGstNo.Text));
1070. cmd.Parameters.AddWithValue("@t9", decimal.Parse(SMobileNo.T
ext));
1071. cmd.Parameters.AddWithValue("@t10", (SEmailId.Text));
1072. cmd.Parameters.AddWithValue("@t11", (SuppName.Text));
1073. cmd.Parameters.AddWithValue("@t12", (SuppGstNo.Text));
1074. cmd.Parameters.AddWithValue("@t13", decimal.Parse(SuppMobile
No.Text));
1075. cmd.Parameters.AddWithValue("@t14", (SuppEmailId.Text));
1076. cmd.Parameters.AddWithValue("@t15", (PartyONo.Text));
1077. cmd.Parameters.AddWithValue("@t16", (ValidFrom.Value.Date));

1078. cmd.Parameters.AddWithValue("@t17", (ValidTo.Value.Date));


1079.
1080.
1081. cmd.Parameters.AddWithValue("@t18", (caltotal));
1082. cmd.Parameters.AddWithValue("@t19", (Select_GST.Text));
1083. cmd.Parameters.AddWithValue("@t20", decimal.Parse(Tax_Total.
Text));
1084.
1085. cmd.Parameters.AddWithValue("@t21", decimal.Parse(GrandTotal
.Text));
1086. cmd.Parameters.AddWithValue("@t22", (Terms_Con.Text));
1087. cmd.Parameters.AddWithValue("@t23", BAddress);
1088. cmd.Parameters.AddWithValue("@t24", VAddress);
1089. cmd.Parameters.AddWithValue("@t25", SAddress);
1090.
1091.
1092. cmd.ExecuteNonQuery();
1093. con.Close();
1094. MessageBox.Show("Data updated successfully", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
1095.
1096. }
1097. catch (Exception ex)
1098. {
1099. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
1100. }
1101.

124 | P a g e
1102. }
1103.
1104. private void button12_Click(object sender, EventArgs e)
1105. {
1106. psend = PoNO.Text;
1107.
1108.
1109. PO h = new PO();
1110. h.Closed += (s, args) => this.Close();
1111. h.Show();
1112.
1113. }
1114. private void PoNO_leave(object sender, EventArgs e)
1115. {
1116. if (PoNO.Text != null)
1117. {
1118. enable();
1119. }
1120. }
1121. }
1122. }

125 | P a g e
- Sales Form

126 | P a g e
1. namespace CRMERP
2. {
3. public partial class salesorder : Form
4. {
5. string CustAddress;
6. string SAddress;
7. string productID;
8. bool counter;
9.
10. decimal caltotal;
11. internal static string psend;
12.
13. public salesorder()
14. {
15. InitializeComponent();
16. }
17. public SqlConnection Connection()
18. {
19. SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-
UPGUJCC\ROHANSQL;Initial Catalog=CRMERP;Integrated Security=True");
20. return con;
21. }
22. public void insertTrigger()
23. {
24.
25. SqlConnection con = Connection();
26. con.Open();
27. try
28. {
29.
30. decimal iq = 0;
31. bool pa;

127 | P a g e
32. string q = "select * from StockMaster where ProductID='" + productI
D + "';";
33. SqlCommand cmd = new SqlCommand(q, con);
34. SqlDataReader DR = cmd.ExecuteReader();
35. if (DR.Read())
36. {
37. iq = decimal.Parse(DR["Quantity"].ToString());
38. pa = true;
39.
40. }
41. else
42. {
43. pa = false;
44. }
45. DR.Close();
46. decimal fq = iq - decimal.Parse(Quantity.Text);
47.
48. if (pa == true)
49. {
50. q = "update StockMaster set Quantity='" + fq + "' where Product
ID='" + productID + "';";
51. cmd = new SqlCommand(q, con);
52. cmd.ExecuteNonQuery();
53.
54. }
55. else
56. {
57. q = "insert into StockMaster values(@t1,@t2,@t3)";
58. cmd = new SqlCommand(q, con);
59. cmd.Parameters.AddWithValue("@t1", productID);
60. cmd.Parameters.AddWithValue("@t2", ProductName.Text);
61. cmd.Parameters.AddWithValue("@t3", fq);
62. cmd.ExecuteNonQuery();
63.
64. }
65.
66.
67.
68. con.Close();
69.
70. }
71. catch (Exception ex)
72. {
73. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
74. }
75.
76.
77. }
78.
79. public void deletePOTrigger(SqlConnection con)
80. {
81.
82.
83. string s = "delete from TransactionMaster where SoNO='" + SoNO.Text + "
'; ";
84. SqlCommand cmd = new SqlCommand(s, con);
85.
86. cmd.ExecuteNonQuery();
87.
88.
89. s = "select ProductID,Quantity from SOProductMaster where SoNO='" + SoN
O.Text + "'; ";
90. cmd = new SqlCommand(s, con);
91.
92. SqlDataReader dr = cmd.ExecuteReader();

128 | P a g e
93.
94. decimal oldq = 0;
95. decimal iq = 0;
96. decimal fq = 0;
97.
98. while (dr.Read())
99. {
100. productID = dr["ProductID"].ToString();
101. oldq = decimal.Parse(dr["Quantity"].ToString());
102.
103. iq = getstock(productID);
104.
105.
106. fq = iq + oldq;
107. updatestock(fq);
108. }
109.
110. dr.Close();
111. s = "delete from SOProductMaster where SoNO='" + SoNO.Text + "';
";
112. cmd = new SqlCommand(s, con);
113.
114. cmd.ExecuteNonQuery();
115.
116.
117.
118. con.Close();
119.
120.
121.
122.
123. }
124.
125. public decimal getstock(string productID)
126. {
127. SqlConnection con = Connection();
128. con.Open();
129. decimal iq = 0;
130. string q = "select * from StockMaster where ProductID='" + produ
ctID + "';";
131. SqlCommand cmd = new SqlCommand(q, con);
132. SqlDataReader DR = cmd.ExecuteReader();
133. if (DR.Read())
134. {
135. iq = decimal.Parse(DR["Quantity"].ToString());
136. }
137. DR.Close();
138. con.Close();
139. return iq;
140. }
141.
142. public void updatestock(decimal fq)
143. {
144. SqlConnection con = Connection();
145. con.Open();
146. string s = "update StockMaster set Quantity=@t1 where ProductID=
'" + productID + "';";
147.
148. SqlCommand cmd = new SqlCommand(s, con);
149.
150. cmd.Parameters.AddWithValue("@t1", fq);
151. cmd.ExecuteNonQuery();
152. con.Close();
153. }
154.
155.

129 | P a g e
156.
157. public void resetData()
158. {
159. SoNO.Text = "";
160. PoNO.Text = "";
161. SoDate.Text = "";
162. Customer.Text = "";
163. CustGstNo.Text = "";
164. CustEmailId.Text = "";
165.
166. CustMobileNo.Text = "";
167.
168. Broker.Text = "";
169.
170. BroMobileNo.Text = "";
171. BroGstNo.Text = "";
172.
173. BroEmailId.Text = "";
174.
175.
176.
177. ShipTo.Text = "";
178. SGstNo.Text = "";
179. SMobileNo.Text = "";
180.
181. SEmailId.Text = "";
182. ProductName.Text = "";
183.
184. Quantity.Text = "";
185. Rate.Text = "";
186. ProductTotal.Text = "";
187. Uom.Text = "";
188. Total.Text = "";
189. Select_GST.Text = "";
190. Tax_Total.Text = "";
191. GrandTotal.Text = "";
192. Terms_Con.Text = "";
193. }
194.
195. public void updateTrigger()
196. {
197.
198. SqlConnection con = Connection();
199. con.Open();
200. try
201. {
202. string s1 = "select * from SOProductMaster where SoNO='" + S
oNO.Text + "' and ProductID='" + productID + "';";
203. decimal oldq = 0;
204. decimal newq = 0;
205. decimal fq = 0;
206. SqlCommand cmd = new SqlCommand(s1, con);
207. SqlDataReader DR = cmd.ExecuteReader();
208. if (DR.Read())
209. {
210. oldq = decimal.Parse(DR["Quantity"].ToString());
211.
212. }
213. DR.Close();
214. newq = decimal.Parse(Quantity.Text);
215. bool check;
216. if (oldq > newq)
217. {
218. fq = oldq - newq;
219. check = true;
220. }

130 | P a g e
221. else
222. {
223. fq = newq - oldq;
224. check = false;
225. }
226.
227.
228.
229. decimal iq = 0;
230.
231. string q = "select * from StockMaster where ProductID='" + p
roductID + "';";
232. cmd = new SqlCommand(q, con);
233. DR = cmd.ExecuteReader();
234. if (DR.Read())
235. {
236. iq = decimal.Parse(DR["Quantity"].ToString());
237.
238. }
239.
240.
241. DR.Close();
242.
243. decimal ffq = 0;
244. if (check == true)
245. {
246. ffq = iq + fq;
247. }
248. else if (check == false)
249. {
250. ffq = iq-fq;
251.
252. }
253.
254. string s = "update StockMaster set Quantity='" + ffq + "' wh
ere ProductID='" + productID + "';";
255. cmd = new SqlCommand(s, con);
256. cmd.ExecuteNonQuery();
257. con.Close();
258.
259. }
260. catch (Exception ex)
261. {
262. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
263. }
264.
265. }
266.
267. public void deleteTrigger()
268. {
269.
270. SqlConnection con = Connection();
271. con.Open();
272. try
273. {
274.
275. decimal iq = 0;
276. string q = "select * from StockMaster where ProductID='" + p
roductID + "';";
277. SqlCommand cmd = new SqlCommand(q, con);
278. SqlDataReader DR = cmd.ExecuteReader();
279. if (DR.Read())
280. {
281. iq = decimal.Parse(DR["Quantity"].ToString());
282. }

131 | P a g e
283. DR.Close();
284. decimal fq = iq + decimal.Parse(Quantity.Text);
285.
286. q = "update StockMaster set Quantity=@t1 where ProductID='"
+ productID + "';";
287.
288. cmd = new SqlCommand(q, con);
289.
290. cmd.Parameters.AddWithValue("@t1", fq);
291. cmd.ExecuteNonQuery();
292. con.Close();
293.
294. }
295. catch (Exception ex)
296. {
297. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
298. }
299.
300. }
301.
302. public void transactionInsertTrigger()
303. {
304. SqlConnection con = Connection();
305. con.Open();
306. try
307. {
308. string s = "insert into TransactionMaster values(@t1,@t2,@t3
)";
309. SqlCommand cmd = new SqlCommand(s, con);
310. cmd.Parameters.AddWithValue("@t1", PoNO.Text);
311. cmd.Parameters.AddWithValue("@t2", SoNO.Text);
312. cmd.Parameters.AddWithValue("@t3", DateTime.Now);
313. cmd.ExecuteNonQuery();
314.
315.
316.
317. con.Close();
318.
319. }
320. catch (Exception ex)
321. {
322. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
323. }
324. }
325.
326. public void fetch()
327. {
328. SqlConnection con = Connection();
329. con.Open();
330.
331.
332. String Sql = "select distinct ProductName from ProductMaster";
333. SqlCommand cmd = new SqlCommand(Sql, con);
334. SqlDataReader DR = cmd.ExecuteReader();
335.
336. while (DR.Read())
337. {
338. ProductName.Items.Add(DR[0]);
339.
340. }
341. DR.Close();
342. Sql = "select distinct CustName from CustMaster";
343. cmd = new SqlCommand(Sql, con);
344. DR = cmd.ExecuteReader();

132 | P a g e
345.
346. while (DR.Read())
347. {
348. Customer.Items.Add(DR[0]);
349. ShipTo.Items.Add(DR[0]);
350. }
351.
352. DR.Close();
353.
354. Sql = "select distinct BrokerName from BrokerMaster";
355. cmd = new SqlCommand(Sql, con);
356. DR = cmd.ExecuteReader();
357.
358. while (DR.Read())
359. {
360. Broker.Items.Add(DR[0]);
361.
362. }
363. DR.Close();
364.
365. con.Close();
366. }
367.
368. private void salesorder_Load(object sender, EventArgs e)
369. {
370. this.WindowState = FormWindowState.Maximized;
371. fetch();
372. }
373.
374.
375. private void panel3_Paint(object sender, PaintEventArgs e)
376. {
377.
378. }
379.
380. private void button1_Click(object sender, EventArgs e)
381. {
382. if (SoNO.Text == "" || counter == true)
383. {
384. this.Close();
385. }
386.
387. else
388. {
389. SqlConnection con = Connection();
390. con.Open();
391. string q = "select * from SOMaster where SoNO='" + SoNO.Text
+ "';";
392. SqlCommand cmd = new SqlCommand(q, con);
393. SqlDataReader DR = cmd.ExecuteReader();
394. if (DR.Read())
395. {
396. DR.Close();
397. this.Close();
398. }
399. else if (MessageBox.Show("The Details Entered will be delete
d...Are you sure you want to exit?", "CRM ERP", MessageBoxButtons.OKCancel) == Dial
ogResult.OK)
400. {
401. try
402. {
403. DR.Close();
404. deletePOTrigger(con);
405. this.Close();
406.
407. }

133 | P a g e
408. catch (Exception ex)
409. {
410. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
411. }
412.
413. }
414. }
415. }
416.
417. private void button12_Click(object sender, EventArgs e)
418. {
419. SqlConnection con = Connection();
420. try
421. {
422. con.Open();
423. if (string.IsNullOrWhiteSpace(ProductName.Text))
424. {
425. MessageBox.Show("Enter ItemName");
426. }
427. else
428. {
429. updateTrigger();
430. string x = ProductName.Text;
431. string Sql = "select ProductID from ProductMaster where
ProductName='" + x + "';";
432. SqlCommand cmd = new SqlCommand(Sql, con);
433.
434. SqlDataReader DR = cmd.ExecuteReader();
435. while (DR.Read())
436. {
437. productID = DR["ProductID"].ToString();
438. }
439. DR.Close();
440. decimal t1 = decimal.Parse(SoNO.Text);
441. string sql = "update SOProductMaster set ProductID=@t2,Q
uantity=@t3,Rate=@t4,Uom=@t5,ProductTotal=@t6 where ProductName=@t7 and SoNO=@t1";

442.
443. cmd = new SqlCommand(sql, con);
444. cmd.Parameters.AddWithValue("@t1", SoNO.Text);
445. cmd.Parameters.AddWithValue("@t2", productID);
446. cmd.Parameters.AddWithValue("@t3", Quantity.Text);
447. cmd.Parameters.AddWithValue("@t4", Rate.Text);
448. cmd.Parameters.AddWithValue("@t5", Uom.Text);
449. cmd.Parameters.AddWithValue("@t6", ProductTotal.Text);
450. cmd.Parameters.AddWithValue("@t7", ProductName.Text);
451. cmd.ExecuteNonQuery();
452. MessageBox.Show("Item Updated Successfully", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
453.
454. string query = "select * from SOProductMaster where SoNO
='" + SoNO.Text + "';";
455.
456.
457. DataSet ds = new DataSet();
458. SqlDataAdapter dap = new SqlDataAdapter(query, con);
459. dap.Fill(ds);
460. ProductView.DataSource = ds.Tables[0];
461.
462. string q = "select sum(ProductTotal) from SOProductMaste
r where SoNO='" + t1 + "';";
463. cmd = new SqlCommand(q, con);
464. caltotal = (decimal)cmd.ExecuteScalar();
465. Total.Text = caltotal.ToString();
466. GrandTotal.Text = caltotal.ToString();

134 | P a g e
467.
468.
469. con.Close();
470. ProductName.Text = "";
471. Quantity.Text = "";
472. Rate.Text = "";
473. ProductTotal.Text = "";
474. Uom.Text = "";
475. }
476.
477. }
478. catch (Exception ex)
479. {
480. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
481. }
482.
483. }
484.
485. private void Cust_Leave(object sender, EventArgs e)
486. {
487. SqlConnection con = Connection();
488. con.Open();
489. string x = Customer.Text;
490. string Sql = "select * from CustMaster where CustName='" + x + "
';";
491. SqlCommand cmd = new SqlCommand(Sql, con);
492. SqlDataReader DR = cmd.ExecuteReader();
493.
494. while (DR.Read())
495. {
496. CustGstNo.Text = DR["Cust_GST_No"].ToString();
497. CustMobileNo.Text = DR["CustMobile1"].ToString();
498. CustEmailId.Text = DR["CustEmail1"].ToString();
499. CustAddress = DR["OfficeNo"].ToString() + ", " + DR["Buildin
gName"].ToString() + ", " + DR["Address1"].ToString() + ", " + DR["Address2"].ToStr
ing() + ", " + DR["Landmark"].ToString() + ", " + DR["City"].ToString() + " - " + D
R["Pincode"].ToString() + ", " + DR["State"].ToString();
500.
501. }
502. }
503.
504. private void shipto_Leave(object sender, EventArgs e)
505. {
506. string str = ShipTo.Text;
507.
508. SqlConnection con = Connection();
509. con.Open();
510.
511. string Sql = "select * from CustMaster where CustName='" + str +
"';";
512. SqlCommand cmd = new SqlCommand(Sql, con);
513. SqlDataReader DR = cmd.ExecuteReader();
514.
515. while (DR.Read())
516. {
517. SGstNo.Text = DR["Cust_GST_No"].ToString();
518. SMobileNo.Text = DR["CustMobile1"].ToString();
519. SEmailId.Text = DR["CustEmail1"].ToString();
520. SAddress = DR["OfficeNo"].ToString() + ", " + DR["BuildingNa
me"].ToString() + ", " + DR["Address1"].ToString() + ", " + DR["Address2"].ToString
() + ", " + DR["Landmark"].ToString() + ", " + DR["City"].ToString() + " - " + DR["
Pincode"].ToString() + ", " + DR["State"].ToString();
521.
522. }
523. }

135 | P a g e
524.
525. private void Brokername_leave(object sender, EventArgs e)
526. {
527. string str = Broker.Text;
528.
529. SqlConnection con = Connection();
530. con.Open();
531.
532. string Sql = "select * from BrokerMaster where BrokerName='" + s
tr + "';";
533. SqlCommand cmd = new SqlCommand(Sql, con);
534. SqlDataReader DR = cmd.ExecuteReader();
535.
536. while (DR.Read())
537. {
538. BroGstNo.Text = DR["Broker_GST_No"].ToString();
539. BroMobileNo.Text = DR["BrokerMobile1"].ToString();
540. BroEmailId.Text = DR["BrokerEmail1"].ToString();
541.
542. }
543. }
544.
545. private void itemname_leave(object sender, EventArgs e)
546. {
547. SqlConnection con = Connection();
548. con.Open();
549.
550.
551. string x = ProductName.Text;
552.
553. string Sql = "select * from SOProductMaster where ProductName='"
+ x + "' and SoNO='" + SoNO.Text + "';";
554. SqlCommand cmd = new SqlCommand(Sql, con);
555. SqlDataReader DR = cmd.ExecuteReader();
556.
557. if (DR.Read())
558. {
559. button9.Enabled = false;
560. MessageBox.Show("Product already exists, please update the p
roduct", "CRM-ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
561. }
562. else
563. {
564. button9.Enabled = true;
565. }
566. DR.Close();
567.
568. Sql = "select ProductID,Rate,UOM from ProductMaster where Produc
tName='" + x + "';";
569. cmd = new SqlCommand(Sql, con);
570. DR = cmd.ExecuteReader();
571.
572. while (DR.Read())
573. {
574. productID = DR["ProductID"].ToString();
575. Rate.Text = DR["Rate"].ToString();
576. Uom.Text = DR["UOM"].ToString();
577.
578. }
579. DR.Close();
580. con.Close();
581. }
582.
583. private void selectgst_Leave(object sender, EventArgs e)
584. {
585. string x = Select_GST.Text;

136 | P a g e
586.
587. decimal total = decimal.Parse(Total.Text);
588.
589. if (x != null)
590. {
591. decimal t = 5;
592.
593. Tax_Total.Text = t.ToString();
594. GrandTotal.Text = (total + t).ToString();
595.
596. }
597. }
598.
599. private void calitem(object sender, EventArgs e)
600. {
601.
602.
603. SqlConnection con = Connection();
604. con.Open();
605. String sql = "Select * from StockMaster where ProductID='" + pro
ductID + "';";
606. SqlCommand cmd = new SqlCommand(sql, con);
607. SqlDataReader dr = cmd.ExecuteReader();
608. decimal stockquantity = 0;
609. if (dr.Read())
610. {
611. stockquantity = decimal.Parse(dr["Quantity"].ToString());
612. }
613. dr.Close();
614.
615. sql = "Select * from SOProductMaster where ProductID='" + produc
tID + "' and SoNO='" + SoNO.Text + "';";
616. cmd = new SqlCommand(sql, con);
617. dr = cmd.ExecuteReader();
618. decimal SOProductMasterquantity = 0;
619. if (dr.Read())
620. {
621. SOProductMasterquantity = decimal.Parse(dr["Quantity"].ToStr
ing());
622. }
623. dr.Close();
624.
625. decimal checkQuantity = stockquantity + SOProductMasterquantity;

626. decimal rate = Decimal.Parse(Rate.Text);


627. decimal quantity = Decimal.Parse(Quantity.Text);
628. if (quantity > checkQuantity)
629. {
630. MessageBox.Show("No Stock Available", "CRMERP", MessageBoxBu
ttons.OK, MessageBoxIcon.Error);
631. }
632. else
633. {
634.
635. decimal total = rate * quantity;
636. ProductTotal.Text = total.ToString();
637. }
638.
639. con.Close();
640. }
641.
642. private void button9_Click(object sender, EventArgs e)
643. {
644. SqlConnection con = Connection();
645. try
646. {

137 | P a g e
647. con.Open();
648. decimal t1 = decimal.Parse(SoNO.Text);
649.
650.
651.
652. string sql = "insert into SOProductMaster values(@t1,@t2,@t3
,@t4,@t5,@t6,@t7)";
653. SqlCommand cmd = new SqlCommand(sql, con);
654. cmd.Parameters.AddWithValue("@t1", SoNO.Text);
655. cmd.Parameters.AddWithValue("@t2", productID);
656. cmd.Parameters.AddWithValue("@t3", ProductName.Text);
657. cmd.Parameters.AddWithValue("@t4", Quantity.Text);
658. cmd.Parameters.AddWithValue("@t5", Rate.Text);
659. cmd.Parameters.AddWithValue("@t6", Uom.Text);
660. cmd.Parameters.AddWithValue("@t7", ProductTotal.Text);
661. cmd.ExecuteNonQuery();
662. MessageBox.Show("Item Added Successfully", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
663.
664. insertTrigger();
665.
666. string query = "select * from SOProductMaster where SoNO='"
+ SoNO.Text + "';";
667.
668.
669. DataSet ds = new DataSet();
670. SqlDataAdapter dap = new SqlDataAdapter(query, con);
671. dap.Fill(ds);
672.
673.
674. ProductView.DataSource = ds.Tables[0];
675.
676.
677. t1 = decimal.Parse(SoNO.Text);
678. String q = "select sum(ProductTotal) from SOProductMaster wh
ere SoNO='" + t1 + "';";
679. cmd = new SqlCommand(q, con);
680. caltotal = (decimal)cmd.ExecuteScalar();
681. Total.Text = caltotal.ToString();
682. GrandTotal.Text = caltotal.ToString();
683.
684.
685. con.Close();
686. ProductName.Text = "";
687. Quantity.Text = "";
688. Rate.Text = "";
689. ProductTotal.Text = "";
690. Uom.Text = "";
691.
692. }
693. catch (Exception ex)
694. {
695. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
696. }
697.
698. }
699.
700. private void productViewMouseClick(object sender, MouseEventArgs e)

701. {
702. ProductName.Text = ProductView.SelectedRows[0].Cells[2].Value.To
String();
703. Quantity.Text = ProductView.SelectedRows[0].Cells[3].Value.ToStr
ing();

138 | P a g e
704. Rate.Text = ProductView.SelectedRows[0].Cells[4].Value.ToString(
);
705. Uom.Text = ProductView.SelectedRows[0].Cells[5].Value.ToString()
;
706. ProductTotal.Text = ProductView.SelectedRows[0].Cells[6].Value.T
oString();
707. }
708.
709. private void button10_Click(object sender, EventArgs e)
710. {
711. string sono = ProductView.SelectedRows[0].Cells[0].Value.ToStrin
g();
712. string pid = ProductView.SelectedRows[0].Cells[1].Value.ToString
();
713. string quan = ProductView.SelectedRows[0].Cells[3].Value.ToStrin
g();
714. deleteTrigger();
715. SqlConnection con = Connection();
716. con.Open();
717.
718. string Sql = "delete from SOProductMaster where SoNO='" + sono +
"'and ProductID='" + pid + "'and Quantity='" + quan + "';";
719. SqlCommand cmd = new SqlCommand(Sql, con);
720. cmd.ExecuteNonQuery();
721. MessageBox.Show("Item deleted successfully", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
722.
723.
724. string query = "select * from SOProductMaster where SoNO='" + So
NO.Text + "';";
725.
726.
727. DataSet ds = new DataSet();
728. SqlDataAdapter dap = new SqlDataAdapter(query, con);
729. dap.Fill(ds);
730.
731.
732. ProductView.DataSource = ds.Tables[0];
733.
734. string q = "select * from SOProductMaster where SoNO='" + SoNO.T
ext + "';";
735. cmd = new SqlCommand(q, con);
736. SqlDataReader dr = cmd.ExecuteReader();
737. Boolean b;
738. if (dr.Read())
739. {
740. b = true;
741. }
742. else
743. {
744. b = false;
745. }
746. dr.Close();
747. if (b == true)
748. {
749. q = "select sum(ProductTotal) from SOProductMaster where SoN
O='" + SoNO.Text + "';";
750. cmd = new SqlCommand(q, con);
751. caltotal = (decimal)cmd.ExecuteScalar();
752. }
753. else
754. {
755. caltotal = 0;
756. }
757.
758. Total.Text = caltotal.ToString();

139 | P a g e
759. GrandTotal.Text = caltotal.ToString();
760.
761.
762. con.Close();
763. ProductName.Text = "";
764. Quantity.Text = "";
765. Rate.Text = "";
766. ProductTotal.Text = "";
767. Uom.Text = "";
768.
769. con.Close();
770.
771. }
772.
773. private void Save_Click(object sender, EventArgs e)
774. {
775. try
776. {
777. SqlConnection con = Connection();
778.
779. con.Open();
780. counter = true;
781. decimal t1 = decimal.Parse(SoNO.Text);
782. string q = "select * from SOMaster where SoNo='" + @t1 + "'"
;
783.
784. SqlCommand cmd = new SqlCommand(q, con);
785. SqlDataReader myreader = cmd.ExecuteReader();
786. if (myreader.HasRows)
787. {
788. MessageBox.Show("Sales order number is already taken", "
CRM-ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
789. }
790. else
791. {
792. myreader.Close();
793.
794. q = "select sum(ProductTotal) from SOProductMaster where
SoNO='" + t1 + "';";
795. cmd = new SqlCommand(q, con);
796. caltotal = (decimal)cmd.ExecuteScalar();
797. string q1 = "insert into SOMaster values (@t1,@t2,@t3,@t
4,@t5,@t6,@t7,@t8,@t9,@t10,@t11,@t12,@t13,@t14,@t15,@t16,@t17,@t18,@t19,@t20,@t21,@
t22)";
798.
799. cmd = new SqlCommand(q1, con);
800.
801.
802. cmd.Parameters.AddWithValue("@t1", (SoNO.Text));
803. cmd.Parameters.AddWithValue("@t2", (SoDate.Value.Date));

804. cmd.Parameters.AddWithValue("@t3", (Customer.Text));


805. cmd.Parameters.AddWithValue("@t4", (CustGstNo.Text));
806. cmd.Parameters.AddWithValue("@t5", decimal.Parse(CustMob
ileNo.Text));
807. cmd.Parameters.AddWithValue("@t6", (CustEmailId.Text));

808. cmd.Parameters.AddWithValue("@t7", (CustAddress));


809. cmd.Parameters.AddWithValue("@t8", (PoNO.Text));
810. cmd.Parameters.AddWithValue("@t9", (ShipTo.Text));
811. cmd.Parameters.AddWithValue("@t10", (SGstNo.Text));
812. cmd.Parameters.AddWithValue("@t11", decimal.Parse(SMobil
eNo.Text));
813. cmd.Parameters.AddWithValue("@t12", (SAddress));
814. cmd.Parameters.AddWithValue("@t13", (SEmailId.Text));
815. cmd.Parameters.AddWithValue("@t14", (Broker.Text));

140 | P a g e
816. cmd.Parameters.AddWithValue("@t15", (BroGstNo.Text));
817. cmd.Parameters.AddWithValue("@t16", (BroEmailId.Text));

818. cmd.Parameters.AddWithValue("@t17", decimal.Parse(BroMob


ileNo.Text));
819. cmd.Parameters.AddWithValue("@t18", decimal.Parse(Total.
Text));
820. cmd.Parameters.AddWithValue("@t19", (Select_GST.Text));

821.
822.
823. cmd.Parameters.AddWithValue("@t20", decimal.Parse(Tax_To
tal.Text));
824.
825. cmd.Parameters.AddWithValue("@t21", decimal.Parse(GrandT
otal.Text));
826. cmd.Parameters.AddWithValue("@t22", (Terms_Con.Text));
827.
828.
829.
830.
831.
832.
833. cmd.ExecuteNonQuery();
834. con.Close();
835. transactionInsertTrigger();
836. MessageBox.Show("Data inserted successfully", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
837.
838.
839.
840. string mobno = (CustMobileNo.Text);
841. string otp = SoNO.Text;
842. // string text = "Hey '" + username + "', your OTP is '"
+ otp + "'";
843.
844. string text = " Dear Customer \n Sales Order Having SONu
mber :" + otp + "is generated \n Regards \n Stalwart Tex International LLP,Mumbai-
02";
845.
846.
847. con.Open();
848. cmd = new SqlCommand("SSendSmsSQLP", con);
849. cmd.CommandType = CommandType.StoredProcedure;
850. cmd.Parameters.Add("@MobileNo", SqlDbType.VarChar).Value
= mobno;
851. cmd.Parameters.Add("@smstext", SqlDbType.VarChar).Value
= text;
852. cmd.Parameters.Add("@sResponse", SqlDbType.VarChar).Valu
e = "test";
853.
854. cmd.ExecuteNonQuery();
855. con.Close();
856.
857.
858.
859. }
860. }
861. catch (Exception ex)
862. {
863. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
864. }
865.
866. }
867.

141 | P a g e
868. private void button7_Click(object sender, EventArgs e)
869. {
870. SqlCommand cmd;
871. try
872. {
873. SqlConnection con = Connection();
874. con.Open();
875.
876. if (string.IsNullOrWhiteSpace(SoNO.Text))
877. {
878. MessageBox.Show("Enter sales order number", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
879. }
880. else
881. {
882. decimal t1 = decimal.Parse(SoNO.Text);
883. string q = "select * from SOMaster where SoNO='" + @t1 +
"'";
884.
885. cmd = new SqlCommand(q, con);
886. SqlDataReader myreader = cmd.ExecuteReader();
887.
888. if (myreader.HasRows)
889. {
890.
891. while (myreader.Read())
892. {
893. SoNO.Text = myreader["SoNO"].ToString();
894. SoDate.Text = myreader["SoDate"].ToString();
895. Customer.Text = myreader["Customer"].ToString();

896. CustGstNo.Text = myreader["CustGstNo"].ToString(


);
897. CustEmailId.Text = myreader["CustEmailId"].ToStr
ing();
898.
899. CustMobileNo.Text = myreader["CustMobileNo"].ToS
tring();
900.
901.
902. PoNO.Text = myreader["PoNO"].ToString();
903.
904. ShipTo.Text = myreader["ShipTo"].ToString();
905. SGstNo.Text = myreader["SGstNo"].ToString();
906.
907. SMobileNo.Text = myreader["SMobileNo"].ToString(
);
908.
909. SEmailId.Text = myreader["SEmailId"].ToString();

910.
911. Broker.Text = myreader["Broker"].ToString();
912. BroGstNo.Text = myreader["BroGstNo"].ToString();

913.
914. BroMobileNo.Text = myreader["BroMobileNo"].ToStr
ing();
915. BroEmailId.Text = myreader["BroEmailId"].ToStrin
g();
916.
917. Total.Text = myreader["Total"].ToString();
918.
919.
920. Select_GST.Text = myreader["Select_GST"].ToStrin
g();
921.

142 | P a g e
922. Tax_Total.Text = myreader["Tax_Total"].ToString(
);
923. GrandTotal.Text = myreader["GrandTotal"].ToStrin
g();
924.
925. Terms_Con.Text = myreader["Terms_Con"].ToString(
);
926.
927.
928.
929. }
930. myreader.Close();
931. string query = "select * from SOProductMaster where
SoNO='" + SoNO.Text + "';";
932.
933.
934. DataSet ds = new DataSet();
935. SqlDataAdapter dap = new SqlDataAdapter(query, con);

936. dap.Fill(ds);
937.
938.
939. ProductView.DataSource = ds.Tables[0];
940. }
941. else
942. {
943. MessageBox.Show("Sales order number not found", "CRM
-ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
944.
945. }
946. con.Close();
947. }
948. }
949. catch (Exception ex)
950. {
951. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
952. }
953.
954. }
955.
956. private void pono_leave(object sender, EventArgs e)
957. {
958. SqlConnection con = Connection();
959. con.Open();
960. string x = PoNO.Text;
961. string Sql = "select * from POMaster where PoNO='" + x + "';";
962. SqlCommand cmd = new SqlCommand(Sql, con);
963. SqlDataReader DR = cmd.ExecuteReader();
964.
965. if (!(DR.Read()))
966. {
967. MessageBox.Show("Purchase order number dosen't exist", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
968.
969. }
970. con.Close();
971.
972. }
973.
974. private void button11_Click(object sender, EventArgs e)
975. {
976. psend = SoNO.Text;
977.
978. this.Hide();
979. SO h = new SO();

143 | P a g e
980. h.Closed += (s, args) => this.Close();
981. h.Show();
982.
983. }
984.
985. private void button5_Click(object sender, EventArgs e)
986. {
987. try
988. {
989. SqlConnection con = Connection();
990. con.Open();
991. counter = true;
992.
993. Cust_Leave(sender, e);
994. shipto_Leave(sender, e);
995.
996. string q = "update SOMaster set SoNO=@t1,SoDate=@t2,Customer
=@t3,CustGstNo=@t4,CustMobileNo=@t5,CustEmailId=@t6,CustAddress=@t7,PoNO=@t8,ShipTo
=@t9,SGstNo=@t10,SMobileNo=@t11,SAddress=@t12,SEmailId=@t13,Broker=@t14,BroGstNo=@t
15,BroEmailId=@t16,BroMobileNo=@t17,Total=@t18,Select_GST=@t19,Tax_Total=@t20,Grand
Total=@t21,Terms_Con=@t22 where SoNO=@t1";
997.
998. SqlCommand cmd = new SqlCommand(q, con);
999.
1000. cmd.Parameters.AddWithValue("@t1", (SoNO.Text));
1001. cmd.Parameters.AddWithValue("@t2", (SoDate.Value.Date));
1002. cmd.Parameters.AddWithValue("@t3", (Customer.Text));
1003. cmd.Parameters.AddWithValue("@t4", (CustGstNo.Text));
1004. cmd.Parameters.AddWithValue("@t5", decimal.Parse(CustMobileN
o.Text));
1005. cmd.Parameters.AddWithValue("@t6", (CustEmailId.Text));
1006. cmd.Parameters.AddWithValue("@t7", (CustAddress));
1007. cmd.Parameters.AddWithValue("@t8", (PoNO.Text));
1008. cmd.Parameters.AddWithValue("@t9", (ShipTo.Text));
1009. cmd.Parameters.AddWithValue("@t10", (SGstNo.Text));
1010. cmd.Parameters.AddWithValue("@t11", decimal.Parse(SMobileNo.
Text));
1011. cmd.Parameters.AddWithValue("@t12", (SAddress));
1012. cmd.Parameters.AddWithValue("@t13", (SEmailId.Text));
1013. cmd.Parameters.AddWithValue("@t14", (Broker.Text));
1014. cmd.Parameters.AddWithValue("@t15", (BroGstNo.Text));
1015. cmd.Parameters.AddWithValue("@t16", (BroEmailId.Text));
1016. cmd.Parameters.AddWithValue("@t17", decimal.Parse(BroMobileN
o.Text));
1017. cmd.Parameters.AddWithValue("@t18", decimal.Parse(Total.Text
));
1018. cmd.Parameters.AddWithValue("@t19", (Select_GST.Text));
1019.
1020.
1021. cmd.Parameters.AddWithValue("@t20", decimal.Parse(Tax_Total.
Text));
1022.
1023. cmd.Parameters.AddWithValue("@t21", decimal.Parse(GrandTotal
.Text));
1024. cmd.Parameters.AddWithValue("@t22", (Terms_Con.Text));
1025.
1026.
1027.
1028. cmd.ExecuteNonQuery();
1029. con.Close();
1030. MessageBox.Show("Data updated successfully", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
1031.
1032. }
1033. catch (Exception ex)
1034. {

144 | P a g e
1035. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
1036. }
1037. }
1038.
1039. private void Delete_Click(object sender, EventArgs e)
1040. {
1041. SqlConnection con = Connection();
1042. try
1043. {
1044. con.Open();
1045. decimal t1 = decimal.Parse(SoNO.Text);
1046.
1047. string q = "select * from SOMaster where SoNO='" + @t1 + "'"
;
1048.
1049. SqlCommand cmd = new SqlCommand(q, con);
1050. SqlDataReader myreader = cmd.ExecuteReader();
1051. if (myreader.HasRows)
1052. {
1053. myreader.Close();
1054. deletePOTrigger(con);
1055. con.Open();
1056. q = "delete from SOMaster where SoNO=@t1";
1057. cmd = new SqlCommand(q, con);
1058.
1059. cmd.Parameters.AddWithValue("@t1", int.Parse(SoNO.Text))
;
1060. cmd.ExecuteNonQuery();
1061. con.Close();
1062. MessageBox.Show("Data deleted successfully", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Information);
1063.
1064. resetData();
1065.
1066. }
1067. else
1068. {
1069. MessageBox.Show("Purchase order number not found", "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
1070.
1071. }
1072. con.Close();
1073. }
1074. catch (Exception ex)
1075. {
1076. MessageBox.Show(ex.Message, "CRM-
ERP", MessageBoxButtons.OK, MessageBoxIcon.Error);
1077.
1078. }
1079. }
1080. }
1081. }

145 | P a g e
Chapter 6
Reports and its Implementation

- Purchase Order

146 | P a g e
- Purchase Order Coding

1. namespace CRMERP
2. {
3. public partial class PO : Form
4. {
5. public PO()
6. {
7. InitializeComponent();
8. }
9.
10. private void PO_Load(object sender, EventArgs e)
11. {
12. this.WindowState = FormWindowState.Maximized;
13. this.reportViewer1.RefreshReport();
14. string a = purchase.psend;
15. using (CRMERPEntities1 db = new CRMERPEntities1())
16. {
17. getPurchaseOrderDetails_ResultBindingSource.DataSource = db.getPurc
haseOrderDetails(a).ToList();
18. Microsoft.Reporting.WinForms.ReportParameter[] rparams = new Micros
oft.Reporting.WinForms.ReportParameter[]
19. {
20.
21. new Microsoft.Reporting.WinForms.ReportParameter("PoNO", a)
22.
23. };
24. reportViewer1.LocalReport.SetParameters(rparams);
25. reportViewer1.RefreshReport();
26. }
27. }
28.
29. private void button1_Click(object sender, EventArgs e)
30. {
31. this.Hide();
32.
33. }
34. }
35. }

147 | P a g e
- Sales Order

148 | P a g e
- Sales Order (Coding)

1. namespace CRMERP
2. {
3. public partial class SO : Form
4. {
5. public SO()
6. {
7. InitializeComponent();
8. }
9.
10. private void SO_Load(object sender, EventArgs e)
11. {
12. this.WindowState = FormWindowState.Maximized;
13. this.reportViewer1.RefreshReport();
14.
15. string a = salesorder.psend;
16.
17. using (CRMERPEntities3 db = new CRMERPEntities3())
18. {
19. getSalesOrderDetails_ResultBindingSource.DataSource = db.getSalesOr
derDetails(a).ToList();
20. Microsoft.Reporting.WinForms.ReportParameter[] rparams = new Micros
oft.Reporting.WinForms.ReportParameter[]
21. {
22.
23. new Microsoft.Reporting.WinForms.ReportParameter("SoNO",a)
24. };
25.
26. reportViewer1.LocalReport.SetParameters(rparams);
27. reportViewer1.RefreshReport();
28. }
29. }
30.
31. private void button1_Click(object sender, EventArgs e)
32. {
33. this.Hide();
34. }
35. }
36. }
37. }

149 | P a g e
- Purchase Order within Range

150 | P a g e
- Purchase Order Withing Range (Coding)

1. namespace CRMERP
2. {
3. public partial class PObetweenDate : Form
4. {
5. DateTime from = reportpobyporange.from;
6. DateTime to = reportpobyporange.to;
7. public PObetweenDate()
8. {
9. InitializeComponent();
10. }
11.
12. private void label1_Click(object sender, EventArgs e)
13. {
14.
15. }
16.
17. private void PObetweenDate_Load(object sender, EventArgs e)
18. {
19. this.WindowState = FormWindowState.Maximized;
20. this.reportViewer1.RefreshReport();
21. using (CRMERPEntities4 db = new CRMERPEntities4())
22. {
23. getPObetweenDates_ResultBindingSource.DataSource = db.getPObetweenD
ates(from, to).ToList();
24. Microsoft.Reporting.WinForms.ReportParameter[] rparam = new Microso
ft.Reporting.WinForms.ReportParameter[]
25. {
26. new Microsoft.Reporting.WinForms.ReportParameter("fromdate",fro
m.Date.ToShortDateString()),
27. new Microsoft.Reporting.WinForms.ReportParameter("todate",to.Da
te.ToShortDateString())
28. };
29. reportViewer1.LocalReport.SetParameters(rparam);
30. reportViewer1.RefreshReport();
31. }
32. }
33.
34. private void button1_Click_1(object sender, EventArgs e)
35. {
36. this.Hide();
37. }
38. }
39. }

151 | P a g e
- Sales Order within Range

152 | P a g e
- Sales Order Withing Range (Coding)

1. namespace CRMERP
2. {
3. public partial class SObetweenDates : Form
4. {
5. DateTime from = reportsobyrange.from;
6. DateTime to = reportsobyrange.to;
7. public SObetweenDates()
8. {
9. InitializeComponent();
10. }
11.
12. private void SObetweenDates_Load(object sender, EventArgs e)
13. {
14. this.WindowState = FormWindowState.Maximized;
15.
16. this.reportViewer1.RefreshReport();
17. using (CRMERPEntities5 db = new CRMERPEntities5())
18. {
19. getSObtweenDates_ResultBindingSource.DataSource = db.getSObtweenDat
es(from, to).ToList();
20. Microsoft.Reporting.WinForms.ReportParameter[] rparam = new Microso
ft.Reporting.WinForms.ReportParameter[]
21. {
22. new Microsoft.Reporting.WinForms.ReportParameter("fromdate",fro
m.Date.ToShortDateString()),
23. new Microsoft.Reporting.WinForms.ReportParameter("todate",to.Da
te.ToShortDateString())
24. };
25. reportViewer1.LocalReport.SetParameters(rparam);
26. reportViewer1.RefreshReport();
27. }
28. }
29.
30. private void button1_Click_1(object sender, EventArgs e)
31. {
32. this.Hide();
33. }
34. }
35. }

153 | P a g e
- All Items List

154 | P a g e
- All Items Report (Coding)

1. namespace CRMERP
2. {
3. public partial class AllitemDetails : Form
4. {
5. public AllitemDetails()
6. {
7. InitializeComponent();
8. }
9.
10. private void AllitemDetails_Load(object sender, EventArgs e)
11. {
12.
13. this.WindowState = FormWindowState.Maximized;
14. this.reportViewer1.RefreshReport();
15.
16. using (CRMERPEntities9 db = new CRMERPEntities9())
17. {
18. getAllItemDetails_ResultBindingSource.DataSource = db.getAllItemDet
ails();
19.
20. reportViewer1.RefreshReport();
21. }
22. }
23.
24. private void button1_Click(object sender, EventArgs e)
25. {
26. this.Hide();
27. }
28. }
29. }

155 | P a g e
Chapter 7
Software Testing
What is Software Testing?
A process of analyzing a software item to detect the differences between existing and
required conditions (i.e., defects) and to evaluate the features of the software item.

Testing Methods:
Static Testing: It is also known as Verification in Software Testing. Verification is a static
method of checking documents and files. Verification is the process, to ensure that whether
we are building the product right i.e., to verify the requirements which we have and to
verify whether we are developing the product accordingly or not. Activities involved here
are Inspections, Reviews, Walkthroughs
Dynamic Testing: It is also known as Validation in Software Testing. Validation is a dynamic
process of testing the real product. Validation is the process, whether we are building the
right product i.e., to validate the product which we have developed is right or not.

Testing Approaches:

There are three types of software testing approaches.

- White Box Testing


- Black Box Testing
- Grey Box Testing
-
White Box Testing: It is also called as Glass Box, Clear Box, Structural Testing. White Box
Testing is based on applications internal code structure. In white-box testing, an internal
perspective of the system, as well as programming skills, are used to design test cases. This
testing is usually done at the unit level.

Black Box Testing: It is also called as Behavioural/Specification-Based/Input-Output Testing.


Black Box Testing is a software testing method in which testers evaluate the functionality of
the software under test without looking at the internal code structure.

Grey Box Testing: Grey box is the combination of both White Box and Black Box Testing. The
tester who works on this type of testing needs to have access to design documents. This
helps to create better test cases in this process.

156 | P a g e
Test Cases
- Log in Form:

Sr. Expected Result


Test Case Actual Output
No Output

Invalid
No values
username Passed
1. entered by
or
user
password

Only Invalid
username username Passed
2.
entered by or
the user password

Invalid
If user does
username Passed
3. not exist in
or
database
password

157 | P a g e
Wrong
Invalid
Password
username Passed
4. enter by
or
registered
password
user

User will
Valid
be
information Passed
5. redirected
entered by
to the
user
Dashboard

If user want
to view his
password,
on click of Displaying Passed
6.
show Password
password
button (eye
icon)

158 | P a g e
- Login Form – Forget Password

Sr. Expected Result


Test Case Actual Output
No Output

If
username
Enter Passed
1. is not
username
entered
by user

User will be
redirected
to reset
password
window and
If
OTP will be
username Passed
2. sent to the
is entered
phone
by user
number
which is
registered
with
username

If OTP is
OTP didn’t Passed
3. not
match
matched

159 | P a g e
OTP
matched,
and user
If OTP is Passed
4. will be
matched
allowed to
change
password

If new
password
Enter Passed
5. is not
password
entered
by user

If re-enter
new
password Enter Passed
6.
is not password
entered
by user

160 | P a g e
If new
Password
passwords Passed
7. didn’t
are not
match
matched

Password
changed
If
successfully,
passwords Passed
8. and will be
are
redirected
matched.
to login
page.

161 | P a g e
- Master: Employee Master {Save, Update, Delete, Search}

Sr. Expected Result


Test Case Actual Output
No Output

If
Enter
Employee Passed
1. Employee
code is not
Code
entered

If
Employee Enter
2. first name Employee Passed
is not First Name
entered

If
Employee Avoid
3. Age is less Child Passed
than 18 Labor
years

Check
Pattern
pattern for Passed
4. did not
Pan and
match
Aadhar

Please
If mobile
enter Passed
5. no. 1 is not
Mobile
entered
Number

162 | P a g e
If mobile Please
no. 1 is not enter valid Passed
6.
in proper mobile
format number

If Email ID
Enter Passed
7. 1 is not
Email ID
entered

If Email ID
Please
1 is not in Passed
8. enter valid
proper
Email ID
format

If pin code
Enter Pin Passed
9. is not
code
entered

If pin code
Please
is not in Passed
10. enter valid
proper
pin code
format

Duplicating Employee
11. Employee Already Passed
Code Exist

163 | P a g e
If emp Please
code is not enter Passed
12.
entered Employee
for search Code

If emp Please
code is not enter Passed
13.
entered Employee
for delete Code

If emp Please
code is not enter Passed
14.
entered Employee
for update Code

Duplicating
Mandatory
Details
e.g.: PAN Mandatory
Number, Details Passed
15.
Aadhar already
Number, exist
Mobile
Number,
Email ID

164 | P a g e
- Purchase Order:

Sr. Expected Result


Test Case Actual Output
No Output

If PO
All field
number is Passed
1. will be
not
disabled
entered

Basic
Details
Select Bill Passed
2. should
To
be
fetched

Basic
Details
Select Passed
3. should
Supplier
be
fetched

Basic
Details
Select Passed
4. should
Ship To
be
fetched

165 | P a g e
Basic
Details
Select Passed
5. should
Item
be
fetched

Selected
item
from
Delete Passed
6. table
Item
should
be
deleted

Select To fetch
7. GST from taxable Passed
dropdown amount

Overall
total
Grand Passed
8. including
total
taxable
amount

166 | P a g e
If PO
Number is Please
9. not enter PO Passed
entered Number
for search

If PO
Number is
Please
not Passed
10. enter PO
entered
Number
for
update

If PO
Number is Please
11. not enter PO Passed
entered Number
for delete

If PO
Number is Please
12. not enter PO Passed
entered Number
for report

167 | P a g e
- Sales Order:

Sr. Expected Result


Test Case Actual Output
No Output

If
Customer PO
PO number Passed
1.
number does not
exist or exist
not

If user
enters
Stock
excess Passed
2. not
quantity
available
of
products

168 | P a g e
Chapter 8
Future Enhancements and Conclusion
Future Scope:
- Integration of TALLY (Accounting Software) with the current system - This module
keeps track of all account-related transactions like expenditures, Balance sheet,
account ledgers, budgeting, bank statements, payment receipts, tax management
etc.

- Focus on CRM (Customer Relationship Management) module which will have


features to manage & track detailed information of the customer like
communication history, calls, meetings, details of purchases made by the customer,
contract duration etc. CRM module can be integrated with the Sales module to
enhance sales opportunities.

- Integration of Analysis Module which helps in visualization of company’s


performance throughout and its relationship with its vendors and customers. This
Module will include visualization tools such as Bar Graph, Pie Chart etc which will act
as a backbone for the organization to take decisions ahead in future.

Conclusion:
This Desktop Application is reliable, time saving, and user friendly. It can be used for
managing the business transactions of a trading company (Stalwart Tex. International LLP.)
such as purchase, sales, inventory management, reporting etc. A variety of features such as
NEWS FEED, OTP, SMS, REPORTS etc helps the user to handle the business transactions in a
effective and optimized manner. This project is Tailor made for the above-mentioned firm
and takes in considerations all the aspects specified by them in the Requirement analysis
and gathering phase.

169 | P a g e
Chapter 9
References and Bibliography

- https://www.javatpoint.com/c-sharp-tutorial
- https://www.c-sharpcorner.com/article/create-rdlc-report-in-C-Sharp-Asp-Net/
- https://online.visual-paradigm.com/
- https://stackoverflow.com/

Books referred
- Microsoft Visual C# Step by Step: John Sharp
- SQL Server Management Studio, A beginner’s guide: Dusan Petkovic

170 | P a g e

You might also like