示例#1
0
        private void AddBtn_Click(object sender, EventArgs e)
        {
            if (QuantityUpDown.Value != 0)
            {
                bool sameItem = false;

                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    string item = row.Cells[0].Value.ToString();
                    if (item == ItemTxtLb.Text)
                    {
                        sameItem = true;
                    }
                }


                if (sameItem == false)
                {
                    var index = dataGridView1.Rows.Add();

                    dataGridView1.Rows[index].Cells[0].Value = ItemTxtLb.Text;
                    dataGridView1.Rows[index].Cells[1].Value = UnitPriceTxtLb.Text;
                    dataGridView1.Rows[index].Cells[2].Value = QuantityUpDown.Value;
                    dataGridView1.Rows[index].Cells[3].Value = TotalPriceTxtLb.Text;
                    dataGridView1.Rows[index].Cells[4].Value = orderID;

                    dataGridView1.ClearSelection();

                    string TPtxt = TotalPriceTxtLb.Text.Replace("€", "");
                    totalprice  += Convert.ToInt32(TPtxt);
                    ValueLb.Text = totalprice.ToString() + "€";

                    QuantityUpDown.Value = 0;
                    UnitPriceTxtLb.ResetText();
                    TotalPriceTxtLb.ResetText();
                    ItemTxtLb.ResetText();
                    QuantityUpDown.Hide();
                    listBox.ClearSelected();
                }
                else
                {
                    MessageBox.Show("You cant add the same item", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("You cant add 0 items", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#2
0
        private void PlaceOrderUC_Load(object sender, EventArgs e)
        {
            ItemTxtLb.Hide();
            TotalPriceTxtLb.Hide();
            TotalPriceTxtLb.Text = "";
            UnitPriceTxtLb.Hide();
            QuantityUpDown.Hide();



            query = "select distinct category from items";
            DataSet ds = db.getData(query);

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                CategoryBox.Items.Add(ds.Tables[0].Rows[i][0].ToString());
            }
        }