Inventory Management System in C# – Project Code
Functional requirements of Inventory Management System in C#
- Â The user can search Category
- The admin can insert, delete, view, update and search Warehouse
- Easy dashboard
- Item insert, delete, view, update and search by the admin
- The admin can add Category
- The admin can delete Category
- The admin can update Category
- The user can view Category
- The admin can insert, delete, view, update and search Product
- The admin can insert, delete, view, update and search Order
- The admin can Manage Stock
- File Export
- User Permission
- User Management
Admin Access Information:
Username:Â admin
Password:Â admin
frmReport.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
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; using InventorySystem1._0.Includes; namespace InventorySystem1._0 { public partial class frmReport : Form { public frmReport() { InitializeComponent(); } SQLConfig config = new SQLConfig(); string sql; private void reports(string sql, string rptname) { try { config.loadReports(sql); string reportname = rptname; CrystalDecisions.CrystalReports.Engine.ReportDocument reportdoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); ; string strReportPath = Application.StartupPath + "\\reports\\" + reportname + ".rpt"; reportdoc.Load(strReportPath); reportdoc.SetDataSource(config.dt); crystalReportViewer1.ReportSource = reportdoc; } catch (Exception ex) { MessageBox.Show(ex.Message + "No crystal reports installed. Pls. contact administrator."); } } private void frmReport_Load(object sender, EventArgs e) { } private void btnitemlisat_Click(object sender, EventArgs e) { sql = "SELECT * FROM `tblitems`"; reports(sql, "allitems"); } private void btnListStockin_Click(object sender, EventArgs e) { switch (cbooption.Text) { case "Daily Report": sql = "SELECT i.`ITEMID`, `NAME`, `DESCRIPTION`, `TYPE`, `PRICE`,so.`QTY`, `UNIT`,TRANSACTIONDATE FROM `tblitems` i ,`tblstock_in_out` so WHERE i.`ITEMID`=so.`ITEMID` AND `REMARKS`='StockIn' AND DATE(`TRANSACTIONDATE`)=CURDATE()"; reports(sql, "itemlist"); break; case "Weekly Report": sql = "SELECT i.`ITEMID`, `NAME`, `DESCRIPTION`, `TYPE`, `PRICE`,so.`QTY`, `UNIT`,TRANSACTIONDATE FROM `tblitems` i ,`tblstock_in_out` so WHERE i.`ITEMID`=so.`ITEMID` AND `REMARKS`='StockIn' AND WEEKDAY(`TRANSACTIONDATE`) >=0 AND WEEKDAY(`TRANSACTIONDATE`) <=4"; reports(sql, "itemlist"); break; case "Monthly Report": sql = "SELECT i.`ITEMID`, `NAME`, `DESCRIPTION`, `TYPE`, `PRICE`,so.`QTY`, `UNIT`,TRANSACTIONDATE FROM `tblitems` i ,`tblstock_in_out` so WHERE i.`ITEMID`=so.`ITEMID` AND `REMARKS`='StockIn' AND MONTH(`TRANSACTIONDATE`)=MONTH(CURDATE())"; reports(sql, "itemlist"); break; } } private void btnStockOut_Click(object sender, EventArgs e) { switch (cbooption.Text) { case "Daily Report": sql = "SELECT `TRANSACTIONNUMBER` , concat(`FIRSTNAME`,' ', `LASTNAME`) as 'Customer', `NAME` AS 'Item', io.`QTY` , `TOTALPRICE` , `TRANSACTIONDATE` " + " FROM `tblitems` i, `tblstock_in_out` io,`tblperson` p" + " WHERE i.`ITEMID` = io.`ITEMID` AND io.`SUPLIERCUSTOMERID`=p.`SUPLIERCUSTOMERID` AND REMARKS ='StockOut' AND DATE(`TRANSACTIONDATE`)=CURDATE()"; reports(sql, "soldList"); break; case "Weekly Report": sql = "SELECT `TRANSACTIONNUMBER` , concat(`FIRSTNAME`,' ', `LASTNAME`) as 'Customer', `NAME` AS 'Item', io.`QTY` , `TOTALPRICE` , `TRANSACTIONDATE` " + " FROM `tblitems` i, `tblstock_in_out` io,`tblperson` p" + " WHERE i.`ITEMID` = io.`ITEMID` AND io.`SUPLIERCUSTOMERID`=p.`SUPLIERCUSTOMERID` AND REMARKS ='StockOut' AND WEEKDAY(`TRANSACTIONDATE`) >=0 AND WEEKDAY(`TRANSACTIONDATE`) <=4"; reports(sql, "soldList"); break; case "Monthly Report": sql = "SELECT `TRANSACTIONNUMBER` , concat(`FIRSTNAME`,' ', `LASTNAME`) as 'Customer', `NAME` AS 'Item', io.`QTY` , `TOTALPRICE` , `TRANSACTIONDATE` " + " FROM `tblitems` i, `tblstock_in_out` io,`tblperson` p" + " WHERE i.`ITEMID` = io.`ITEMID` AND io.`SUPLIERCUSTOMERID`=p.`SUPLIERCUSTOMERID` AND REMARKS ='StockOut' AND MONTH(`TRANSACTIONDATE`)=MONTH(CURDATE())"; reports(sql, "soldList"); break; } } private void btnStockReturn_Click(object sender, EventArgs e) { switch (cbooption.Text) { case "Daily Report": sql = "SELECT `STOCKRETURNNUMBER`,`NAME` AS 'Item', `RETURNDATE`, r.`QTY` as 'Quantity' FROM `tblstock_return` r,`tblitems` i WHERE r.`ITEMID`=i.`ITEMID` AND DATE(`RETURNDATE`)=CURDATE()"; reports(sql, "returnList"); break; case "Weekly Report": sql = "SELECT `STOCKRETURNNUMBER`,`NAME` AS 'Item', `RETURNDATE`, r.`QTY` as 'Quantity' FROM `tblstock_return` r,`tblitems` i WHERE r.`ITEMID`=i.`ITEMID` AND WEEKDAY(`RETURNDATE`) >=0 AND WEEKDAY(`RETURNDATE`) <=4"; reports(sql, "returnList"); break; case "Monthly Report": sql = "SELECT `STOCKRETURNNUMBER`,`NAME` AS 'Item', `RETURNDATE`, r.`QTY` as 'Quantity' FROM `tblstock_return` r,`tblitems` i WHERE r.`ITEMID`=i.`ITEMID` AND MONTH(`RETURNDATE`)=MONTH(CURDATE())"; reports(sql, "returnList"); break; } } private void button1_Click(object sender, EventArgs e) { sql = "SELECT `NAME` , `DESCRIPTION` , `TYPE` , i.`QTY` AS 'Stock-In', `UNIT` , o.`QTY` AS 'Stock-Out', `TRANSACTIONDATE` , `REMARKS` " + "FROM `tblitems` i" + " LEFT JOIN `tblstock_in_out` o ON i.`ITEMID` = o.`ITEMID` " + " AND REMARKS = 'StockOut' and TRANSACTIONDATE between '" + dptfrom.Text + "' and '" + dtpto.Text + "'"; reports(sql, "inventory"); } } } |
frmStockOut.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
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; using InventorySystem1._0.Includes; namespace InventorySystem1._0 { public partial class frmStockOut : Form { public frmStockOut(string cus_id) { InitializeComponent(); txt_cusid.Text = cus_id; } SQLConfig config = new SQLConfig(); usableFunction funct = new usableFunction(); string sql; private void txt_cusid_TextChanged(object sender, EventArgs e) { sql = "SELECT * FROM `tblperson` WHERE `SUPLIERCUSTOMERID`='" + txt_cusid.Text + "'"; config.singleResult(sql); if(config.dt.Rows.Count > 0) { txtCus_fname.Text = config.dt.Rows[0].Field<string>("FIRSTNAME"); txtCus_lname.Text = config.dt.Rows[0].Field<string>("LASTNAME"); }else { txtCus_fname.Clear(); txtCus_lname.Clear(); } } private void frmStockOut_Load(object sender, EventArgs e) { sql = "SELECT SUPLIERCUSTOMERID FROM tblperson WHERE TYPE = 'CUSTOMER'"; config.autocomplete(sql, txt_cusid); sql = "SELECT `ITEMID` as 'Item Id', `NAME` as 'Name', `DESCRIPTION` as 'Description', `PRICE` as 'Price', `QTY` as 'Available Quantity' FROM `tblitems`"; config.Load_DTG(sql, dtgCus_itemlist); funct.ResponsiveDtg(dtgCus_itemlist); } private void txtsearch_TextChanged(object sender, EventArgs e) { sql = "SELECT `ITEMID` as 'Item Id', `NAME` as 'Name', `DESCRIPTION` as 'Description', `PRICE` as 'Price', `QTY` as 'Available Quantity' FROM `tblitems` WHERE `NAME` like '%" + txtsearch.Text + "%' or `ITEMID` = '" + txtsearch.Text + "'"; config.Load_DTG(sql, dtgCus_itemlist); funct.ResponsiveDtg(dtgCus_itemlist); } private void dtgCus_itemlist_DoubleClick(object sender, EventArgs e) { double tot; int qty; if(dtCus_addedlist.RowCount == 0) { qty = 1; tot = double.Parse(dtgCus_itemlist.CurrentRow.Cells[3].Value.ToString()) * 1; string[] row = new string[] { dtgCus_itemlist.CurrentRow.Cells[0].Value.ToString(), dtgCus_itemlist.CurrentRow.Cells[1].Value.ToString(), dtgCus_itemlist.CurrentRow.Cells[2].Value.ToString(), dtgCus_itemlist.CurrentRow.Cells[3].Value.ToString(), qty.ToString(), tot.ToString()}; dtCus_addedlist.Rows.Add(row); } else { foreach(DataGridViewRow r in dtCus_addedlist.Rows) { if(dtgCus_itemlist.CurrentRow.Cells[0].Value == r.Cells[0].Value) { MessageBox.Show("Item is already in the cart", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } if (dtCus_addedlist.CurrentRow.Cells[0].Value != dtgCus_itemlist.CurrentRow.Cells[0].Value) { qty = 1; tot = double.Parse(dtgCus_itemlist.CurrentRow.Cells[3].Value.ToString()) * 1; string[] row = new string[] { dtgCus_itemlist.CurrentRow.Cells[0].Value.ToString(), dtgCus_itemlist.CurrentRow.Cells[1].Value.ToString(), dtgCus_itemlist.CurrentRow.Cells[2].Value.ToString(), dtgCus_itemlist.CurrentRow.Cells[3].Value.ToString(), qty.ToString(), tot.ToString()}; dtCus_addedlist.Rows.Add(row); } else { MessageBox.Show("Item is already in the cart", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } } private void dtCus_addedlist_CellEndEdit(object sender, DataGridViewCellEventArgs e) { double total; if (dtCus_addedlist.CurrentCell.ColumnIndex == 4) { foreach (DataGridViewRow row in dtCus_addedlist.Rows) { total = double.Parse(row.Cells[4].Value.ToString()) * double.Parse(row.Cells[3].Value.ToString()); row.Cells[5].Value = total; } } } private void btnCus_save_Click(object sender, EventArgs e) { string stockoutID; config.singleResult("SELECT concat(STRT,END) FROM tblautonumber WHERE ID = 5"); stockoutID = config.dt.Rows[0].Field<string>(0); if (txt_cusid.Text == "") { MessageBox.Show("There are empty fields left that must be fill up!", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if(dtCus_addedlist.RowCount == 0) { MessageBox.Show("Cart is empty!", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } sql = "SELECT ITEMID,`QTY` FROM `tblitems`"; config.singleResult(sql); foreach(DataRow row in config.dt.Rows) { for(int i = 0;i < dtCus_addedlist.Rows.Count; i++) { if (dtCus_addedlist.Rows[i].Cells[0].Value.ToString() == row.Field<string>(0)) { if(int.Parse( dtCus_addedlist.Rows[i].Cells[4].Value.ToString()) > row.Field<int>(1)) { MessageBox.Show("The Quantity of the item ( " + dtCus_addedlist.Rows[i].Cells[1].Value.ToString() + " ) is greater than the available quantity of it.", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } if (dtCus_addedlist.Rows[i].Cells[4].Value.ToString() == "") { MessageBox.Show("Set your purpose.", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } } foreach(DataGridViewRow r in dtCus_addedlist.Rows) { sql = "INSERT INTO `tblstock_in_out` ( `TRANSACTIONNUMBER`, `ITEMID`, `TRANSACTIONDATE`, `QTY`, `TOTALPRICE`, `SUPLIERCUSTOMERID`,REMARKS)" + " VALUES ('" + stockoutID + "','" + r.Cells[0].Value + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "','" + r.Cells[4].Value + "','" + r.Cells[5].Value + "','" + txt_cusid.Text + "','StockOut')"; config.Execute_Query(sql); sql = "UPDATE `tblitems` SET `QTY`= QTY - '" + r.Cells[4].Value + "' WHERE ITEMID='" + r.Cells[0].Value + "'"; config.Execute_Query(sql); } sql = "INSERT INTO `tbltransaction` (`TRANSACTIONNUMBER`, `TRANSACTIONDATE`, `TYPE`, `SUPLIERCUSTOMERID`)" + " VALUES ('" + stockoutID + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "','StockOut','" + txt_cusid.Text + "')"; config.Execute_Query(sql); // '-----------------------------------------------update autonumber config.Execute_Query("UPDATE tblautonumber SET END= END + INCREMENT WHERE ID = 5"); // '------------------------------------------------------------ MessageBox.Show("Item(s) has been save in the database."); // '------------------------------------------------------------clearing funct.clearTxt(Panel1); dtCus_addedlist.Rows.Clear(); frmStockOut_Load(sender, e); } private void btnCus_Remove_Click(object sender, EventArgs e) { dtCus_addedlist.Rows.Remove(dtCus_addedlist.CurrentRow); } private void btnCus_clear_Click(object sender, EventArgs e) { dtCus_addedlist.Rows.Clear(); } private void Button2_Click(object sender, EventArgs e) { this.Close(); } private void btnviewStockout_Click(object sender, EventArgs e) { frmListStockout frm=new frmListStockout(); frm.Show(); } } } |
frmListReturned.Designer.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
namespace InventorySystem1._0 { partial class frmListReturned { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Label1 = new System.Windows.Forms.Label(); this.txtsearch = new System.Windows.Forms.TextBox(); this.dtglist = new System.Windows.Forms.DataGridView(); ((System.ComponentModel.ISupportInitialize)(this.dtglist)).BeginInit(); this.SuspendLayout(); // // Label1 // this.Label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.Label1.AutoSize = true; this.Label1.Location = new System.Drawing.Point(397, 15); this.Label1.Name = "Label1"; this.Label1.Size = new System.Drawing.Size(47, 13); this.Label1.TabIndex = 21; this.Label1.Text = "Search: "; // // txtsearch // this.txtsearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.txtsearch.Location = new System.Drawing.Point(450, 12); this.txtsearch.Name = "txtsearch"; this.txtsearch.Size = new System.Drawing.Size(330, 20); this.txtsearch.TabIndex = 20; this.txtsearch.TextChanged += new System.EventHandler(this.txtsearch_TextChanged); // // dtglist // this.dtglist.AllowUserToAddRows = false; this.dtglist.AllowUserToDeleteRows = false; this.dtglist.AllowUserToResizeColumns = false; this.dtglist.AllowUserToResizeRows = false; this.dtglist.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dtglist.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dtglist.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dtglist.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dtglist.Location = new System.Drawing.Point(4, 38); this.dtglist.Name = "dtglist"; this.dtglist.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dtglist.Size = new System.Drawing.Size(776, 394); this.dtglist.TabIndex = 19; // // frmListReturned // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(792, 444); this.Controls.Add(this.Label1); this.Controls.Add(this.txtsearch); this.Controls.Add(this.dtglist); this.Name = "frmListReturned"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "List of Returned Items"; this.Load += new System.EventHandler(this.frmListReturned_Load); ((System.ComponentModel.ISupportInitialize)(this.dtglist)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion internal System.Windows.Forms.Label Label1; internal System.Windows.Forms.TextBox txtsearch; internal System.Windows.Forms.DataGridView dtglist; } } |
Exercise
You must practice on the followings;
functional requirements of Inventory Management System, Future scope of Inventory Management System, non functional requirements of Inventory Management System, tools & technologies of Inventory Management System, use case diagram of Inventory Management System, class diagram of Inventory Management System, activity diagram of Inventory Management System, sequence diagram of Inventory Management System, DFD of Inventory Management System, use case descriptions of Inventory Management System, test cases and testing of Inventory Management System.
Download Full code of inventory Management System in C# – Project Code