Professional Documents
Culture Documents
C#.Net AAT Report
C#.Net AAT Report
COLLEGE OF ENGINEERING
Bengaluru-560019
C#.Net AAT
SUBMITTED BY
Gautam Raj Kumawat
(USN-1BM19MCA16)
Shubhra Debnath
(USN-1BF19MCA15)
COURSE CODE
18MCA5PCWP
UNDER THE GUIDANCE OF
Dr. Ch. Ram Mohan Reddy
CERTIFICATE
This is to certify that, the Record is a Bonafede work carried out by Gautam
Raj Kumawat and Shubhra Debnath, students of Master of Computer
Applications Department, B. M. S. Collage of Engineering for C#.Net AAT. This
report has been submitted during the academic year 2021-22 in partial
fulfilment of the requirement of the degree of Master of Computer
Applications 5th Semester.
Abstract 5
Modules 10
Coding 11-57
Screenshots 58-62
Conclusion 63
Bibliography 64
ABSTRACT
This Bakery Inventory System was developed using C# and MS Access
Database in .NET Framework. The system has a security feature that requires
user credentials in order for business management or the system's person in
charge can manage the data in the system. The user can manage the list of
products (bread, cake, and pastries) along with some details that are relevant
for this system. The products should have available stock in order for them to
be stock out. The system has also an error trapping feature that prevents the
user from stock out the product without sufficient stock availability. The
bakery inventory system generates printable Inventory reports for all the
products. It is easy to use and has user-friendly functionalities.
HARDWARE AND
SOFTWARE
REQUIREMENTS
Hardware Requirements:
Processor – i3 7th gen at 3.3 Ghz or above
RAM – 4 GB or above
Hard Disk – 500 GB or above
Software Requirements:
namespace BakeryInventorySystem
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void shwfrm( Form frm)
{
frm.ShowDialog();
}
}
private void Form1_Load(object sender, EventArgs e)
{
disable_menu();
}
}
}
}
frmEditProduct.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BakeryInventorySystem
{
public partial class frmEditProduct : Form
{
SQLConfig config = new SQLConfig();
usableFunction func = new usableFunction();
string sql;
int maxrow;
frmListofProducts frm;
retrieveProduct(id);
this.frm = frm;
}
private void retrieveProduct(string id)
{
if(maxrow > 0)
{
foreach(DataRow r in config.dt.Rows)
{
txtPROCODE.Text = r.Field<string>(0);
TXTPRONAME.Text = r.Field<string>(1);
TXTDESC.Text = r.Field<string>(2);
cboCateg.Text = r.Field<string>(3);
TXTPRICE.Text = r.Field<decimal>(4).ToString();
}
}
private void frmEditProduct_Load(object sender, EventArgs e)
{
namespace BakeryInventorySystem
{
public partial class frmInventoryReports : Form
{
public frmInventoryReports()
{
InitializeComponent();
}
SQLConfig config = new SQLConfig();
usableFunction func = new usableFunction();
string query;
int maxrow;
break;
case "Stock-In":
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATERECEIVED) AS
[ReceivedDate], (PRONAME + ' ' + PRODESC) AS [Product], PROPRICE AS [Price],RECEIVEDQTY AS
[Quantity],(ROUND(RECEIVEDQTY * PROPRICE)) AS [TotalPrice] " +
" FROM tblStockIn AS S, tblProductInfo AS P WHERE S.PROCODE=P.PROCODE AND
CATEGORY ='" + cboCateg.Text + "' AND PRONAME LIKE '%" + txtSearch.Text + "%'";
break;
case "Sold" :
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATEOUT) AS
[TransactionDate], (PRONAME + ' ' + PRODESC) AS [Product], PROPRICE AS [Price],OUTQTY AS
[Quantity],(ROUND(OUTQTY * PROPRICE)) AS [TotalPrice] " +
" FROM tblStockOut AS S, tblProductInfo AS P WHERE S.PROCODE=P.PROCODE AND
CATEGORY ='" + cboCateg.Text + "' AND PRONAME LIKE '%" + txtSearch.Text + "%'";
break;
case "Today":
}
else if (RDO.Text == "Sold")
{
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATEOUT) AS
[TransactionDate], (PRONAME + ' ' + PRODESC) AS [Product],('Net/VolWt:' + PRONETWT ) AS
[Description],PROPRICE as Price,(OUTQTY + PROUNIT) AS [Quantity],(ROUND(OUTQTY * PROPRICE)) AS
[TotalPrice] " +
" FROM tblStockOut AS S, tblProductInfo AS P WHERE S.PROCODE=P.PROCODE AND
DATEVALUE(DATERECEIVED) = NOW() AND CATEGORY ='" + cboCateg.Text + "' AND PRONAME LIKE '%"
+ txtSearch.Text + "%'";
}
break;
case "Weekly":
if (RDO.Text == "Stock-In") {
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATERECEIVED) AS
[ReceivedDate], (PRONAME + ' ' + PRODESC) AS [Product],PROPRICE AS [Price],RECEIVEDQTY AS
[Quantity],(ROUND(RECEIVEDQTY * PROPRICE)) AS [TotalPrice] " +
" FROM tblStockIn AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND MONTH(DATERECEIVED) = MONTH(NOW())
AND DATEVALUE(DATEPART(ww,DATEOUT)) = DATEVALUE(DATEPART(ww,NOW())) AND PRODESC LIKE
'%" + txtSearch.Text + "%' AND PRONAME LIKE '%" + txtSearch.Text + "%'";
}
else if (RDO.Text == "Sold")
{
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATEOUT) AS
[TransactionDate], (PRONAME + ' ' + PRODESC) AS [Product],('Net/VolWt:' + PRONETWT) AS
[Description],PROPRICE as Price,(OUTQTY + PROUNIT) AS [Quantity],(ROUND(OUTQTY * PROPRICE)) AS
[TotalPrice] " +
" FROM tblStockOut AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND MONTH(DATERECEIVED) = MONTH(NOW()) AND
CATEGORY ='" + cboCateg.Text + "' AND PRONAME LIKE '%" + txtSearch.Text + "%'";
}
break;
config.Load_DTG(query, dtglist);
}
}
if( rdo.Text != "Today" && rdo.Text != "21 days" && rdo.Text != "Weekly" && rdo.Text !=
"Monthly")
{
LBLLIST.Text = "List of " + rdo.Text + " (" + cboCateg.Text + ")";
}
}
}
private void RDOCLEARDATE()
{
rdoMonthly.Checked = false;
rdoWeekly.Checked = false;
rdoToday.Checked = false;
}
RDOSELECT(rdoProduct);
}
RDOSELECT(rdoProduct);
}
if(rdoStockIn.Checked)
{
RDOCLEAR("Product", rdoStockIn);
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATERECEIVED) AS
[ReceivedDate], (PRONAME + ' ' + PRODESC) AS [Product],PROPRICE AS [Price],RECEIVEDQTY AS
[Quantity],(ROUND(RECEIVEDQTY * PROPRICE)) AS [TotalPrice] " +
" FROM tblStockIn AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND DATEVALUE(DATERECEIVED) = DATEVALUE(NOW())
AND PRODESC LIKE '%" + txtSearch.Text + "%' AND PRONAME LIKE '%" + txtSearch.Text + "%'";
config.Load_DTG(query, dtglist);
}
else if (rdoStockOut.Checked)
{
RDOCLEAR("Product", rdoStockOut);
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATEOUT) AS [TransactionDate],
(PRONAME + ' ' + PRODESC) AS [Product],PROPRICE AS [Price],OUTQTY AS [Quantity],(ROUND(OUTQTY
* PROPRICE)) AS [TotalPrice] " +
" FROM tblStockOut AS S, tblProductInfo AS P WHERE S.PROCODE=P.PROCODE AND
DATEVALUE(DATEOUT) =DATEVALUE(NOW()) AND CATEGORY ='" + cboCateg.Text + "' AND PRONAME
LIKE '%" + txtSearch.Text + "%'";
config.Load_DTG(query, dtglist);
}
}
if (rdoStockIn.Checked)
{
RDOCLEAR("Product", rdoStockIn);
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATERECEIVED) AS
[ReceivedDate], (PRONAME + ' ' + PRODESC) AS [Product],PROPRICE AS [Price],RECEIVEDQTY AS
[Quantity],(ROUND(RECEIVEDQTY * PROPRICE)) AS [TotalPrice] " +
" FROM tblStockIn AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND MONTH(DATERECEIVED) = MONTH(NOW()) AND
PRODESC LIKE '%" + txtSearch.Text + "%' AND PRONAME LIKE '%" + txtSearch.Text + "%'";
config.Load_DTG(query, dtglist);
}
else if (rdoStockOut.Checked)
{
RDOCLEAR("Product", rdoStockOut);
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATEOUT) AS [TransactionDate],
(PRONAME + ' ' + PRODESC) AS [Product],PROPRICE AS [Price],OUTQTY AS [Quantity],(ROUND(OUTQTY
* PROPRICE)) AS [TotalPrice] " +
" FROM tblStockOut AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND MONTH(DATEOUT) = MONTH(NOW()) AND
DatePart('ww',DATEVALUE(DATEOUT))= DatePart('ww',DATEVALUE(NOW())) AND CATEGORY ='" +
cboCateg.Text + "' AND PRONAME LIKE '%" + txtSearch.Text + "%'";
config.Load_DTG(query, dtglist);
}
if (rdoStockIn.Checked)
{
RDOCLEAR("Product", rdoStockIn);
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATERECEIVED) AS
[ReceivedDate], (PRONAME + ' ' + PRODESC) AS [Product],PROPRICE AS [Price],RECEIVEDQTY AS
[Quantity],(ROUND(RECEIVEDQTY * PROPRICE)) AS [TotalPrice] " +
" FROM tblStockIn AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND MONTH(DATERECEIVED) = MONTH(NOW()) AND
PRODESC LIKE '%" + txtSearch.Text + "%' AND PRONAME LIKE '%" + txtSearch.Text + "%'";
config.Load_DTG(query, dtglist);
}
else if (rdoStockOut.Checked)
{
RDOCLEAR("Product", rdoStockOut);
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATEOUT) AS [TransactionDate],
(PRONAME + ' ' + PRODESC) AS [Product],PROPRICE AS [Price],OUTQTY AS [Quantity],(ROUND(OUTQTY
* PROPRICE)) AS [TotalPrice] " +
" FROM tblStockOut AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND MONTH(DATEOUT) = MONTH(NOW()) AND CATEGORY
='" + cboCateg.Text + "' AND PRONAME LIKE '%" + txtSearch.Text + "%'";
config.Load_DTG(query, dtglist);
}
}
if( rdoStockIn.Checked)
{
LBLLIST.Text = "Stock of " + cboCateg.Text + " from " + dfrom + " to " + dto;
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATERECEIVED) AS
[ReceivedDate], (PRONAME + ' ' + PRODESC) AS [Product],PROPRICE AS [Price],RECEIVEDQTY AS
[Quantity],(ROUND(RECEIVEDQTY * PROPRICE)) AS [TotalPrice] " +
" FROM tblStockIn AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND DATEVALUE(DATERECEIVED) BETWEEN #" + dfrom +
"# AND #" + dto + "# AND PRODESC LIKE '%" + txtSearch.Text + "%' AND PRONAME LIKE '%" +
txtSearch.Text + "%'";
config.Load_DTG(query, dtglist);
}
else if (rdoStockOut.Checked)
{
LBLLIST.Text = "Sold " + cboCateg.Text + " from " + dfrom + " to " + dto;
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATEOUT) AS [TransactionDate],
(PRONAME + ' ' + PRODESC) AS [Product],PROPRICE AS [Price],OUTQTY AS [Quantity],(ROUND(OUTQTY
* PROPRICE)) AS [TotalPrice] " +
" FROM tblStockOut AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND DATEVALUE(DATEOUT) BETWEEN #" + dfrom + "#
AND #" + dto + "# AND CATEGORY ='" + cboCateg.Text + "' AND PRONAME LIKE '%" + txtSearch.Text +
"%'";
config.Load_DTG(query, dtglist);
}
RDOSELECT(rdoProduct);
}
}
}
}
frmListofProducts.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BakeryInventorySystem
{
public partial class frmListofProducts : Form
{
public frmListofProducts()
{
InitializeComponent();
}
SQLConfig config = new SQLConfig();
usableFunction func = new usableFunction();
string sql;
int maxrow;
private void btnNew_Click(object sender, EventArgs e)
{
Form frm = new frmProduct();
frm.ShowDialog();
}
DTGLIST.Columns.Clear();
}
}
}
frmListStockin.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BakeryInventorySystem
{
public partial class frmListStockin : Form
{
public frmListStockin()
{
InitializeComponent();
}
SQLConfig config = new SQLConfig();
usableFunction func = new usableFunction();
string sql;
int maxrow;
private void btnNew_Click(object sender, EventArgs e)
{
this.Close();
}
btnRefresh_Click(sender, e);
}
frmListStockout.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BakeryInventorySystem
{
public partial class frmListStockout : Form
{
public frmListStockout()
{
InitializeComponent();
}
SQLConfig config = new SQLConfig();
usableFunction func = new usableFunction();
string query;
int maxrow;
frmLogin.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BakeryInventorySystem
{
public partial class frmLogin : Form
{
Form1 frm;
public frmLogin(Form1 frm)
{
InitializeComponent();
this.frm = frm;
}
SQLConfig config = new SQLConfig();
usableFunction func = new usableFunction();
string query;
int maxrow;
}
private void OK_Click(object sender, EventArgs e)
{
query = "SELECT * FROM tblUser WHERE U_UNAME ='" + UsernameTextBox.Text + "' AND
U_PASS = '" + PasswordTextBox.Text + "'";
maxrow = config.maxrow(query);
if(maxrow > 0)
{
MessageBox.Show("User successfully logged in");
frm.enable_menu();
this.Close();
}
else
{
MessageBox.Show("Account does not
exist!","Invalid",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
frmPrint.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BakeryInventorySystem
{
public partial class frmPrint : Form
{
SQLConfig config = new SQLConfig();
usableFunction func = new usableFunction();
string query;
int maxrow;
try
{
config.loadReports(sql);
reportdoc.Load(strReportPath);
reportdoc.SetDataSource(config.dt);
crystalReportViewer1.ReportSource = reportdoc;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "No crystal reports installed. Pls. contact administrator.");
}
if (lbllist == "Stock of " + category + " from " + dfrom + " to " + dto)
{
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATERECEIVED) AS
[ReceivedDate], (PRONAME + ' ' + PRODESC) AS [Product],(PROPRICE) AS [Price],RECEIVEDQTY AS
[Quantity],((ROUND(RECEIVEDQTY * PROPRICE)) ) AS [TotalPrice] " +
" FROM tblStockIn AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND DATEVALUE(DATERECEIVED) BETWEEN #" + dfrom + "#
AND #" + dto + "# AND PRODESC LIKE '%" + txtsearch + "%' AND PRONAME LIKE '%" + txtsearch + "%'";
reports(query, "stockinasof");
}
else if (lbllist == "Sold " + category + " from " + dfrom + " to " + dto)
{
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATEOUT) AS [TransactionDate],
(PRONAME + ' ' + PRODESC) AS [Product],(PROPRICE) AS [Price],OUTQTY AS [Quantity],
((ROUND(OUTQTY * PROPRICE))) AS [TotalPrice] " +
" FROM tblStockOut AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND DATEVALUE(DATEOUT) BETWEEN #" + dfrom + "#
AND #" + dto + "# AND CATEGORY ='" + category + "' AND PRONAME LIKE '%" + txtsearch + "%'";
reports(query, "stockoutasof");
}
else
{
if (rdoToday.Checked)
{
if(rdoStockIn.Checked)
{
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATERECEIVED) AS
[ReceivedDate], (PRONAME + ' ' + PRODESC) AS [Product],(PROPRICE) AS [Price],RECEIVEDQTY AS
[Quantity],(ROUND(RECEIVEDQTY * PROPRICE)) AS [TotalPrice] " +
" FROM tblStockIn AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND DATEVALUE(DATERECEIVED) =
DATEVALUE(NOW()) AND PRODESC LIKE '%" + txtsearch + "%' AND PRONAME LIKE '%" + txtsearch +
"%'";
reports(query, "dailystockin");
}
else
{
query = "SELECT TRANSNUM, P.PROCODE AS [ProductCode],DATEVALUE(DATEOUT) AS
[TransactionDate], (PRONAME + ' ' + PRODESC) AS [Product], (OUTQTY) AS [Quantity],PROPRICE as
[Price], (ROUND(OUTQTY * PROPRICE)) AS [TotalPrice] " +
" FROM tblStockOut AS S, tblProductInfo AS P WHERE S.PROCODE=P.PROCODE
AND DATEVALUE(DATEOUT) = DATEVALUE(NOW()) AND CATEGORY ='" + category + "' AND PRONAME
LIKE '%" + txtsearch + "%'";
reports(query, "dailystockout");
}
}
else if (rdoWeekly.Checked)
{
if (rdoStockIn.Checked)
{
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATERECEIVED) AS
[ReceivedDate], (PRONAME + ' ' + PRODESC) AS [Product],PROPRICE AS [Price],RECEIVEDQTY AS
[Quantity],(ROUND(RECEIVEDQTY * PROPRICE)) AS [TotalPrice] " +
" FROM tblStockIn AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND MONTH(DATERECEIVED) = MONTH(NOW())
AND DATEPART('ww',DATEVALUE(DATERECEIVED)) = DATEPART('ww',DATEVALUE(NOW())) AND
PRODESC LIKE '%" + txtsearch + "%' AND PRONAME LIKE '%" + txtsearch + "%'";
reports(query, "weeklystockins");
}
else
{
query = "SELECT TRANSNUM, P.PROCODE AS [ProductCode],DATEVALUE(DATEOUT) AS
[TransactionDate], (PRONAME + ' ' + PRODESC) AS [Product], OUTQTY AS [Quantity],PROPRICE as
[Price], (ROUND(OUTQTY * PROPRICE)) AS [TotalPrice] " +
" FROM tblStockOut AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND MONTH(DATEOUT) = MONTH(NOW()) AND
DATEPART('ww',DATEVALUE(DATEOUT)) = DATEPART('ww',DATEVALUE(NOW())) AND CATEGORY ='" +
category + "' AND PRONAME LIKE '%" + txtsearch + "%'";
reports(query, "weeklystockout");
}
}
else if (rdoMonthly.Checked)
{
if (rdoStockIn.Checked)
{
query = "SELECT P.PROCODE AS [ProductCode],DATEVALUE(DATERECEIVED) AS
[ReceivedDate], (PRONAME + ' ' + PRODESC) AS [Product],PROPRICE,RECEIVEDQTY AS [Quantity],
(ROUND(RECEIVEDQTY * PROPRICE)) AS [TotalPrice] " +
" FROM tblStockIn AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND MONTH(DATERECEIVED) = MONTH(NOW())
AND PRODESC LIKE '%" + txtsearch + "%' AND PRONAME LIKE '%" + txtsearch + "%'";
reports(query, "monthlystockin");
}
else
{
query = "SELECT TRANSNUM, P.PROCODE AS [ProductCode],DATEVALUE(DATEOUT) AS
[TransactionDate], (PRONAME + ' ' + PRODESC) AS [Product], (OUTQTY) AS [Quantity],PROPRICE as
[Price], (ROUND(OUTQTY * PROPRICE)) AS [TotalPrice] " +
" FROM tblStockOut AS S, tblProductInfo AS P " +
" WHERE S.PROCODE=P.PROCODE AND MONTH(DATEOUT) = MONTH(NOW()) AND
CATEGORY ='" + category + "' AND PRONAME LIKE '%" + txtsearch + "%'";
reports(query, "monthlystockout");
}
}
else
{
if( rdoProduct.Checked)
{
query = "SELECT * " +
" FROM tblProductInfo WHERE CATEGORY ='" + category + "' AND PRONAME LIKE
'%" + txtsearch + "%'";
reports(query, "listofproducts");
}
else if (rdoStockIn.Checked)
{
query = "SELECT * " +
" FROM tblStockIn AS S, tblProductInfo AS P WHERE S.PROCODE=P.PROCODE AND
CATEGORY ='" + category +
"' AND PRONAME LIKE '%" + txtsearch + "%'";
reports(query, "stockinCMD");
}
else if (rdoStockOut.Checked)
{
query = "SELECT * FROM tblStockOut AS S, tblProductInfo AS P WHERE
S.PROCODE=P.PROCODE AND CATEGORY ='" + category +
"' AND PRONAME LIKE '%" + txtsearch + "%'";
reports(query, "stockoutCMD");
}
}
}
}
}
}
frmProduct.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BakeryInventorySystem
{
public partial class frmProduct : Form
{
public frmProduct()
{
InitializeComponent();
}
SQLConfig config = new SQLConfig();
usableFunction func = new usableFunction();
string sql;
int maxrow;
if (maxrow > 0)
{
sql = "UPDATE tblProductInfo SET PRONAME='" + TXTPRONAME.Text +
"' ,PRODESC='" + TXTDESC.Text +
"',CATEGORY='" + cboCateg.Text +
"',PROPRICE=" + TXTPRICE.Text + " WHERE PROCODE='" + txtPROCODE.Text + "'";
config.Execute_CUD(sql, "Error to update Bread", "Bread Has Been Updated.");
}
else
{
sql = "INSERT INTO tblProductInfo
(PROCODE,PRONAME,PRODESC,CATEGORY,PROPRICE,PROQTY)"
+ " VALUES ( '" + txtPROCODE.Text + "', '" + TXTPRONAME.Text + "','" + TXTDESC.Text + "','"
+ cboCateg.Text + "','" + TXTPRICE.Text + "',0)";
config.Execute_CUD(sql, "Error to save Product.", "New Bread Has Been Saved.");
config.update_Autonumber(2);
}
Button1_Click(sender, e);
}
}
}
frmStockin.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BakeryInventorySystem
{
public partial class frmStockin : Form
{
public frmStockin()
{
InitializeComponent();
}
SQLConfig config = new SQLConfig();
usableFunction func = new usableFunction();
string sql;
int maxrow;
private void frmStockin_Load(object sender, EventArgs e)
{
BTNNEW_Click(sender, e);
}
config.autonumber_transaction(1, LBLTRANSNUM);
LBLMSG.Text = "The " + TXTPRODUCT.Text + " has been added into the inventory.";
LBLMSG.BackColor = Color.Aquamarine;
LBLMSG.ForeColor = Color.Black;
config.update_Autonumber(1);
BTNNEW_Click(sender, e);
}
else
{
LBLMSG.Text = "Fill up the correct product in the empty fields inorder to save.";
LBLMSG.BackColor = Color.Red;
LBLMSG.ForeColor = Color.White;
}
if(maxrow > 0)
{
foreach(DataRow r in config.dt.Rows)
{
TXTPRODUCT.Text = r.Field<string>("PRONAME");
TXTDESC.Text = r.Field<string>("PRODESC") + " [" + r.Field<string>("CATEGORY") + "]";
TXTPRICE.Text = r.Field<decimal>("PROPRICE").ToString();
}
}
else
{
TXTPRODUCT.Clear();
TXTDESC.Clear();
TXTPRICE.Clear();
TXTQTY.Clear();
TXTTOT.Clear();
}
}
namespace BakeryInventorySystem
{
public partial class frmStockout : Form
{
public frmStockout()
{
InitializeComponent();
}
SQLConfig config = new SQLConfig();
usableFunction func = new usableFunction();
string query;
int maxrow;
private void BTNNEW_Click(object sender, EventArgs e)
{
func.clearTxt(GroupBox1);
func.clearTxt(GroupBox2);
LBLMSG.Text = "";
LBLMSG.BackColor = Color.Transparent;
config.autonumber_transaction(1, LBLTRANSNUM);
if (maxrow > 0)
{
foreach (DataRow r in config.dt.Rows)
{
TXTPRODUCT.Text = r.Field<string>("PRONAME");
TXTDESC.Text = r.Field<string>("PRODESC") + " [" + r.Field<string>("CATEGORY") + "]";
TXTPRICE.Text = r.Field<decimal>("PROPRICE").ToString();
TXTAVAILQTY.Text = r.Field<int>("PROQTY").ToString();
}
}
else
{
TXTPRODUCT.Clear();
TXTDESC.Clear();
TXTPRICE.Clear();
TXTQTY.Clear();
TXTTOT.Clear();
TXTAVAILQTY.Clear();
}
}
query = "UPDATE tblProductInfo SET PROQTY = PROQTY - " + TXTQTY.Text + " WHERE
PROCODE = '" + txtPROCODE.Text + "'";
config.Execute_Query(query);
LBLMSG.Text = "The " + TXTPRODUCT.Text + " has been deducted into the inventory.";
LBLMSG.BackColor = Color.Aquamarine;
LBLMSG.ForeColor = Color.Black;
;
config.update_Autonumber(1);
BTNNEW_Click(sender, e);
}
}
else
{
LBLMSG.Text = "Fill up the correct product in the empty fields inorder to save.";
LBLMSG.BackColor = Color.Red;
LBLMSG.ForeColor = Color.White;
}
frmUser.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BakeryInventorySystem
{
public partial class frmUser : Form
{
public frmUser()
{
InitializeComponent();
}
SQLConfig config = new SQLConfig();
usableFunction func = new usableFunction();
string query;
int maxrow;
btnnew_Click(sender, e);
}
}
}
}
SQLConfig.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using MySql.Data.MySqlClient;
using System.Data;
using System.Windows.Forms;
using System.Data.OleDb;
namespace BakeryInventorySystem
{
class SQLConfig
{
if(result > 0)
{
MessageBox.Show(msg_true);
}
else
{
MessageBox.Show(msg_false);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
}
}
public void Execute_Query(string sql)
{
try
{
if (con.State != ConnectionState.Open)
{
con.Open();
}
//con.Open();
cmd = new OleDbCommand();
cmd.Connection = con;
cmd.CommandText = sql;
result = cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
}
}
public void Load_DTG(string sql,DataGridView dtg)
{
try
{
//con.Open();
if (con.State != ConnectionState.Open)
{
con.Open();
}
cmd = new OleDbCommand();
da = new OleDbDataAdapter();
dt = new DataTable();
cmd.Connection = con;
cmd.CommandText = sql;
da.SelectCommand = cmd;
da.Fill(dt);
dtg.DataSource = dt;
funct.ResponsiveDtg(dtg);
dtg.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dtg.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
da.Dispose();
con.Close();
}
}
public void fiil_CBO(string sql, ComboBox cbo)
{
try
{
if (con.State != ConnectionState.Open)
{
con.Open();
}
cmd.Connection = con;
cmd.CommandText = sql;
da.SelectCommand = cmd;
da.Fill(dt);
cbo.DataSource = dt;
cbo.ValueMember = dt.Columns[0].ColumnName;
cbo.DisplayMember = dt.Columns[1].ColumnName;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
da.Dispose();
}
}
public void combo(string sql, ComboBox cbo)
{
try
{
if (con.State != ConnectionState.Open)
{
con.Open();
}
cmd.Connection = con;
cmd.CommandText = sql;
da.SelectCommand = cmd;
da.Fill(dt);
cbo.Items.Clear();
cbo.Text = "Select";
foreach(DataRow r in dt.Rows)
{
cbo.Items.Add(r.Field<string>(0));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
da.Dispose();
}
}
public void singleResult(string sql)
{
try
{
con.Open();
cmd = new OleDbCommand();
da = new OleDbDataAdapter();
dt = new DataTable();
cmd.Connection = con;
cmd.CommandText = sql;
da.SelectCommand = cmd;
da.Fill(dt);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
da.Dispose();
con.Close();
}
}
{
int maxrow = 0;
try
{
con.Open();
cmd = new OleDbCommand();
da = new OleDbDataAdapter();
dt = new DataTable();
cmd.Connection = con;
cmd.CommandText = sql;
da.SelectCommand = cmd;
da.Fill(dt);
maxrow = dt.Rows.Count;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
da.Dispose();
con.Close();
}
return maxrow;
{
try
{
con.Open();
cmd = new OleDbCommand();
da = new OleDbDataAdapter();
dt = new DataTable();
cmd.Connection = con;
cmd.CommandText = sql;
da.SelectCommand = cmd;
da.Fill(dt);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
da.Dispose();
}
}
cmd.Connection = con;
cmd.CommandText = sql;
da.SelectCommand = cmd;
da.Fill(dt);
txt.AutoCompleteCustomSource.Clear();
txt.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
txt.AutoCompleteSource = AutoCompleteSource.CustomSource;
foreach (DataRow r in dt.Rows)
{
txt.AutoCompleteCustomSource.Add(r.Field<string>(0));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
da.Dispose();
}
}
if (con.State != ConnectionState.Open)
{
con.Open();
}
cmd = new OleDbCommand();
da = new OleDbDataAdapter();
dt = new DataTable();
cmd.Connection = con;
cmd.CommandText = "SELECT (STARTNUM + INCNUM) FROM tblAutoNumber WHERE ID=" +
ID;
da.SelectCommand = cmd;
da.Fill(dt);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
da.Dispose();
}
}
public void autonumber_transaction(int ID, Label txt)
{
try
{
if (con.State != ConnectionState.Open)
{
con.Open();
}
cmd = new OleDbCommand();
da = new OleDbDataAdapter();
dt = new DataTable();
cmd.Connection = con;
cmd.CommandText = "SELECT (STARTNUM + INCNUM) FROM tblAutoNumber WHERE ID=" +
ID;
da.SelectCommand = cmd;
da.Fill(dt);
txt.Text = dt.Rows[0].Field<string>(0);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
da.Dispose();
}
}
public void update_Autonumber(int id)
{
Execute_Query("UPDATE tblAutoNumber SET INCNUM=INCNUM + 1 WHERE ID=" + id);
}
}
}
usableFunction.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BakeryInventorySystem
{
class usableFunction
{
public void clearTxt(Control container)
{
try
{
//'for each txt as control in this(object).control
foreach (Control txt in container.Controls)
{
//conditioning the txt as control by getting it's type.
//the type of txt as control must be textbox.
if (txt is TextBox)
{
//if the object(textbox) is present. The result is, the textbox will be cleared.
txt.Text = "";
}
if (txt is RichTextBox)
{
txt.Text = "";
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public string checkOption(CheckBox chk)
{
string yesno;
if (chk.Checked)
{
yesno = "Yes";
}
else
{
yesno = "No";
}
return yesno;
}
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BakeryInventorySystem
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
SCREENSHOTS
CONCLUSION
Here, in this application we have been able to gain a deep insight into
how to work with windows forms application along with ADO.NET to
integrate the application with databases. The windows application
provides an easy user interface which will help a user to automate his
bakery inventory system. The user can manage all the tasks related to a
bakery inventory with ease and in an efficient manner. This project helped
us to deal with the real-life GUI-based windows application development
and how to fulfill a client’s requirements with respect to a specific
business scenario. It also helped us to develop the skill to think as per the
user perspective and application developer’s perspective.
BIBLIOGRAPHY
https://www.sourcecodester.com/c/13369/bakery-inventory-
system-using-c-and-ms-access-database.html
https://www.youtube.com/watch?v=pMl2yukTG74