C#.net

Fried Rice Shop Inventory using C#.NET sqlserver

The Fried Rice shop Inventory Management System is developed using C#.NET and SQL SERVER. The project is built to manage sales and transactions. To make a new transaction, fields such as: Fried Rice 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.

Establish the Database Connection

SqlConnection con = new SqlConnection("Data Source=KOBINATH-PC; Initial Catalog=posnew; User Id=sa; Password=admin123");
SqlCommand cmd;
SqlCommand cmd1;
SqlDataReader read;
SqlDataAdapter drr;
string sql;
string sql1;
string name;
int price;
int tot;

After selected relevant product details click ADD button. Product details added into the below table.

  private void button1_Click(object sender, EventArgs e)
        {
            if(chkthfrice.Checked)
            {
                name = "Thai Fried Rice";
                int qty = int.Parse(numericUpDown1.Value.ToString());
                price = 100;
                tot = qty * price;
                this.dataGridView1.Rows.Add(name, price, qty, tot);
            }
            if (chkchi.Checked)
            {
                name = "Chicken Fried Rice";
                int qty = int.Parse(numericUpDown2.Value.ToString());
                price = 200;
                tot = qty * price;
                this.dataGridView1.Rows.Add(name, price, qty, tot);
            }
            if (chkfish.Checked)
            {
                name = "Fish Fried Rice";
                int qty = int.Parse(numericUpDown3.Value.ToString());
                price = 150;
                tot = qty * price;
                this.dataGridView1.Rows.Add(name, price, qty, tot);
            }

            //Drink

            if (chkveg.Checked)
            {
                name = "Veg Fried Rice";
                int qty = int.Parse(numericUpDown4.Value.ToString());
                price = 120;
                tot = qty * price;
                this.dataGridView1.Rows.Add(name, price, qty, tot);
            }
             if (chkpine.Checked)
            {
                name = "Pineapple Fried Rice";
                int qty = int.Parse(numericUpDown5.Value.ToString());
                price = 150;
                tot = qty * price;
                this.dataGridView1.Rows.Add(name, price, qty, tot);
            }

           if (chkcrab.Checked)
            {
                name = "Crab Fried Rice";
                int qty = int.Parse(numericUpDown6.Value.ToString());
                price = 130;
                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);
            }

            txtSub.Text = sum.ToString();

        }

Save Button

 private void button2_Click(object sender, EventArgs e)
        {
            string bal = txtBal.Text;
            string sub = txtSub.Text;
            string pay = textBox1.Text;
            sql = "insert into sales(subtoal,pay,bal) values(@subtoal,@pay,@bal); select @@identity;";
            con.Open();
            cmd = new SqlCommand(sql, con);
            cmd.Parameters.AddWithValue("@subtoal", sub);
            cmd.Parameters.AddWithValue("@pay", pay);
            cmd.Parameters.AddWithValue("@bal", bal);
            int lastinsertID = int.Parse(cmd.ExecuteScalar().ToString());

            string proddname = "";
            int price = 0;
            int qty = 0;
            int tot = 0;


            for (int row = 0; row < dataGridView1.Rows.Count; row++)
            {
                proddname = 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());
                 int total = int.Parse(dataGridView1.Rows[row].Cells[3].Value.ToString());
                 sql1 = "insert into sales_product(sales_id,prodname,price,qty,total) values(@sales_id,@prodname,@price,@qty,@total)";
                 cmd1 = new SqlCommand(sql1, con);
                 cmd1.Parameters.AddWithValue("@sales_id", lastinsertID);
                 cmd1.Parameters.AddWithValue("@prodname", proddname);
                 cmd1.Parameters.AddWithValue("@price", price);
                 cmd1.Parameters.AddWithValue("@qty", qty);
                 cmd1.Parameters.AddWithValue("@total", total);
                 cmd1.ExecuteNonQuery();
            }
            MessageBox.Show("Record Addddedddd");
            con.Close();

        }

Delete Button

if the want to delete item from the table click the item row delete button then item has been deleted.

 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);
                }
                txtSub.Text = sum.ToString();
            }
        }

i have attached the video link below. which will do this tutorials step by step.

 

 

admin

Recent Posts

Conditional Statements in Python

Conditional statements in Python allow us to control the flow of execution based on conditions.…

23 hours ago

Java Beans

A Java Bean is a reusable software component that follows a specific set of conventions.…

6 days ago

Java String Methods

Java provides a rich set of built-in methods for handling String operations efficiently. Since strings…

6 days ago

Java Developer Jobs

Java remains one of the most in-demand programming languages worldwide, powering everything from enterprise applications…

6 days ago

Converting Integer to String in Java

Java provides multiple ways to convert an integer (int) to a string (String). Whether you're…

6 days ago

JSP to JSP Communication: A Complete Guide to Dynamic Java Web Development

Java Server Pages (JSP) is a powerful technology used to develop dynamic web applications by…

2 weeks ago