示例#1
0
        private void SubmitOrderBtn_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count <= 0)
            {
                MessageBox.Show("No items submitted", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    int    uplength = row.Cells[1].Value.ToString().Length;
                    String upstr    = row.Cells[1].Value.ToString().Remove(uplength - 1);
                    int    uprice   = Convert.ToInt32(upstr);

                    int    tplength = row.Cells[3].Value.ToString().Length;
                    String tpstr    = row.Cells[3].Value.ToString().Remove(tplength - 1);
                    int    tprice   = Convert.ToInt32(upstr);



                    query = "insert into SingleOrder (Item,UnitPrice,Quantity,TotalPrice,ID) values('" + row.Cells[0].Value + "','" + uprice + "','" + row.Cells[2].Value + "','" + tprice + "','" + row.Cells[4].Value + "')";
                    db.setData(query);
                }

                query = "insert into TotalOrders (ID,TotalCost) values('" + orderID + "','" + totalprice + "')";
                db.setData(query);

                MessageBox.Show("Data Processed Succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                dataGridView1.Rows.Clear();
                orderID     += 1;
                ValueLb.Text = "0€";
            }
        }
示例#2
0
        private void DeleteBtn_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 1)
            {
                query = "delete from items where name = '" + name + "'";
                db.setData(query);
                MessageBox.Show("Data Processed Succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                loadData();

                SearchTextBox.Text = "Search Item";
            }
            else
            {
                MessageBox.Show("No item is selected", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void UpdateBtn_Click(object sender, EventArgs e)
        {
            if (ItemTxtLb.Text == "")
            {
                MessageBox.Show("Choose an item to update", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (CategoryTB.Text == "" || PriceTB.Text == "")
            {
                MessageBox.Show("Complete all the values", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                query = "update items set category = '" + CategoryTB.Text + "', price = '" + PriceTB.Text + "' where name = '" + ItemTxtLb.Text + "'";
                db.setData(query);
                MessageBox.Show("Data Processed Succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                loadData();

                SearchTextBox.Text = "Search Item";
                ItemTxtLb.Text     = "";
                CategoryTB.Clear();
                PriceTB.Clear();
            }
        }
示例#4
0
        private void AddBtn_Click(object sender, EventArgs e)
        {
            String  querycheck = "select name from items";
            DataSet ds         = db.getData(querycheck);
            bool    check      = false;

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (ds.Tables[0].Rows[i][0].ToString() == ItemTextBox.Text)
                {
                    MessageBox.Show("This item exists already", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    check = true;
                    break;
                }
            }

            if (check == false)
            {
                query = "insert into items (name,category,price) values('" + ItemTextBox.Text + "','" + CategoryBox.Text + "','" + PriceTextBox.Text + "')";
                if (ItemTextBox.Text == "" || PriceTextBox.Text == "" || CategoryBox.Text == "")
                {
                    MessageBox.Show("Add more data", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    db.setData(query);
                    MessageBox.Show("Data Processed Succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (!CategoryBox.Items.Contains(CategoryBox.Text))
                    {
                        CategoryBox.Items.Add(CategoryBox.Text);
                    }
                }
            }

            clear();
        }