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

Registration with image upload Java Jdbc(Download Source code)

Introduction In this section, we will guide you step by step in the development of an image upload registration system in Java using MySQL and JDBC. In the application, users register…

2 weeks ago

Touchable shop Pos system using Java

The Touchable Shop POS (Point of Sale) system is a sophisticated software solution developed using…

1 month ago

Build Your First Responsive Login Form Using HTML and CSS FlexBox

Creating a responsive login form is a crucial skill for any web developer. In this…

1 month ago

Build Crud API with Laravel 12

In this tutorial will teach  Laravel 12 CRUD API  by step. Laravel  10 CRUD Application …

1 month ago

laravel 12 image upload tutorial

In this lesson we talk about laravel 12 image uploading and display the image step…

2 months ago

Laravel 12 CRUD Application

In this tutorial will teach Laravel 12 CRUD Application step by step. Laravel  12 CRUD…

2 months ago