The Milk Inventory Management System is developed using c#.net and sqlserver. The project is built to manage sales and transactions. To make a new transaction, fields such as: Milk type, qty,price and payment needs to be selected. If you like to learn point of sales systems step by step, this is the right place to learn from the beginning. In this tutorial, we will learn crystal reports step by step and design and print receipts for the payments.
Step1 : Create the database named with “milk “ on Sqlserver.establish the database connection
SqlConnection con = new SqlConnection("Data Source=.; Initial Catalog=millk; User ID=sa; password=admin123;");
The system shall be able to select the relevant milk type.
After selected milk type where the user has the option to add the qty by clicking the add button to see all products details which will be shown in the below table.
Paste this code inside the add button
private void button1_Click(object sender, EventArgs e) { string name; int price = 0; int qty; int tot = 0; if(chk1.Checked) { name = "Strawberry Milk"; qty = int.Parse(stwqty.Value.ToString()); price = 100; tot = qty * price; this.dataGridView1.Rows.Add(name, price,qty,tot); } if (chk2.Checked) { name = "Mango Milk"; qty = int.Parse(manqty.Value.ToString()); price = 80; tot = qty * price; this.dataGridView1.Rows.Add(name, price, qty, tot); } if (chk3.Checked) { name = "Vanilla Milk"; qty = int.Parse(vanqty.Value.ToString()); price = 50; tot = qty * price; this.dataGridView1.Rows.Add(name, price, qty, tot); } if (chk4.Checked) { name = "Chocolate Milk"; qty = int.Parse(choqty.Value.ToString()); price = 150; tot = qty * price; this.dataGridView1.Rows.Add(name, price, qty, tot); } if (chk5.Checked) { name = "Coffee Milk"; qty = int.Parse(cofqty.Value.ToString()); price = 70; tot = qty * price; this.dataGridView1.Rows.Add(name, price, qty, tot); } int sum = 0; for(int row= 0; row< dataGridView1.Rows.Count; row++) { sum = sum + Convert.ToInt32(dataGridView1.Rows[row].Cells[3].Value); } txttot.Text = sum.ToString(); }
if you want remove items from the datagridview. select the row of table which item need to be remove. then click delete button in the datagridview.
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if(e.ColumnIndex == dataGridView1.Columns["delete"].Index && e.RowIndex >= 0) { dataGridView1.Rows.Remove(dataGridView1.Rows[e.RowIndex]); int sum = 0; for (int row = 0; row < dataGridView1.Rows.Count; row++) { sum = sum + Convert.ToInt32(dataGridView1.Rows[row].Cells[3].Value); } txttot.Text = sum.ToString(); } }
After that create the method Salessave().we have to create two different tables to store data into the database. we also have to create the following tables from database..
sales tables consist of following colums – id,subtotal,pay,balance.
sales_products tables consist of following colums –id,sales_id,prodname,price,qty,total
public void salessave() { string tot = txttot.Text; string pay = txtpay.Text; string bal = txtbal.Text; string sql1; string sql2; sql1 = "insert into sales(subtotal,pay,balance)values(@subtotal,@pay,@balance) select @@identity; "; con.Open(); cmd1 = new SqlCommand(sql1,con); cmd1.Parameters.AddWithValue("@subtotal", tot); cmd1.Parameters.AddWithValue("@pay", pay); cmd1.Parameters.AddWithValue("@balance", bal); int lastinserid = int.Parse(cmd1.ExecuteScalar().ToString()); string prodname; int price = 0; int qty = 0; int total = 0; for(int row=0; row<dataGridView1.Rows.Count; row++) { prodname = dataGridView1.Rows[row].Cells[0].Value.ToString(); price = int.Parse(dataGridView1.Rows[row].Cells[1].Value.ToString()); qty = int.Parse(dataGridView1.Rows[row].Cells[2].Value.ToString()); total = int.Parse(dataGridView1.Rows[row].Cells[3].Value.ToString()); sql2 = "insert into sales_product(sales_id,prodname,price,qty,total)values(@sales_id,@prodname,@price,@qty,@total)"; cmd2 = new SqlCommand(sql2, con); cmd2.Parameters.AddWithValue("@sales_id", lastinserid); cmd2.Parameters.AddWithValue("@prodname", prodname); cmd2.Parameters.AddWithValue("@price", price); cmd2.Parameters.AddWithValue("@qty", qty); cmd2.Parameters.AddWithValue("@total", total); cmd2.ExecuteNonQuery(); } print p = new print(); p.SalesID = lastinserid; p.Show(); con.Close(); }
Call the Salessave() method inside the Print Invoice button. after calculating the total Print receipt will be released. This print receipt is design by crystal reports.
Paste this code inside the Print Invoice button
private void button2_Click(object sender, EventArgs e) { int pay = int.Parse(txtpay.Text); int total = int.Parse(txttot.Text); int bal = pay - total; txtbal.Text = bal.ToString(); salessave(); }
Initialize the employee number, Hourswork,and Hoursrate to calculate a grosswage use the following condition. if…
Act as a Java developer to create a program that calculates the gross wage for…
Initialize the employee number, Hourswork,and Hoursrate to calculate a grosswage use the following condition. if…
In this tutorial, we will teach you how to create a simple school management system…
I have design the Admin Basic templete using React MUI Design Admin Dashboard and Login.Here…
In this tutorial ,i am to going teach the Laravel Breeze.Laravel Breeze provides a simple…