Beispiel #1
0
        private void AddItems_Click(object sender, EventArgs e)
        {
            using (FormItems newForm = new FormItems()
            {
            })
            {
                newForm.ShowDialog();
                bool check = InsertErrorManager.AddItemsChecker(newForm.getItem().getName(), newForm.getItem().getQuantity());
                if (check == true)
                {
                    int errorPrice = newForm.getItem().getTotalprice();
                    if (errorPrice == 0)
                    {
                        MessageBox.Show("Item name entered invalid");
                    }
                    else
                    {
                        datGridView_Items.Rows.Add(newForm.getItem().getName(), newForm.getItem().getQuantity(), newForm.getItem().getTotalprice(),
                                                   "Delete");

                        int Total = datGridView_Items.Rows.Cast <DataGridViewRow>()
                                    .Sum(t => Convert.ToInt32(t.Cells[2].Value));
                        txt_Total.Text = Total.ToString();
                    }
                }
            }
        }
Beispiel #2
0
 private void btn_add_Click(object sender, EventArgs e)
 {
     if (InsertErrorManager.AddItemsChecker(txt_Item.Text, (int)numericUpDown.Value))
     {
         item.setItem((string)txt_Item.Text);
         item.setQuantity((int)numericUpDown.Value);
         item.setTotalprice((string)txt_Item.Text, (int)numericUpDown.Value);
         this.Close();
     }
     else
     {
         MessageBox.Show("All field must be filled up!");
     }
 }