Beispiel #1
0
 private void ADD_button_Click(object sender, EventArgs e)
 {
     if (IsCustomer)
     {
         CheckBarCode();
     }
     if (IsCustomer == false)
     {
         string message5 = "Please enter confirmed customer";
         string title5   = "Error";
         MessageBox.Show(message5, title5);
     }
     if (IsCustomer && IsBarCode)
     {
         bool isIn = false;
         for (int i = 0; i < textBoxes.Count(); i = i + 4)
         {
             if (textBoxes[i].Text.Equals(record.getQrCode().ToString()))
             {
                 textBoxes[i + 3].Text = (int.Parse(textBoxes[i + 3].Text) + 1).ToString();
                 isIn = true;
                 records.Add(record);
                 record.setQuantityInStock(record.getQuantityInStock() - 1);
                 break;
             }
         }
         if (isIn == false)
         {
             for (int i = 0; i < textBoxes.Count(); i = i + 4)
             {
                 if (textBoxes[i].Text == "")
                 {
                     textBoxes[i].Text     = record.getQrCode().ToString();
                     textBoxes[i + 1].Text = record.getRecordName();
                     textBoxes[i + 2].Text = record.getArtist();
                     textBoxes[i + 3].Text = "1";
                     records.Add(record);
                     record.setQuantityInStock(record.getQuantityInStock() - 1);
                     break;
                 }
             }
         }
     }
 }
Beispiel #2
0
 private void Remove_button5_Click(object sender, EventArgs e)
 {
     if (textBox17.Text != "")
     {
         Record r = Program.GetRecordByQR(int.Parse(textBox17.Text));
         records.RemoveAll(x => x.getQrCode() == r.getQrCode());
         r.setQuantityInStock(r.getQuantityInStock() + int.Parse(textBox20.Text));
         for (int i = 16; i < 20; i++)
         {
             textBoxes[i].Clear();
         }
     }
 }
Beispiel #3
0
        private void ADD_button_Click(object sender, EventArgs e)
        {
            if (IsCustomer)
            {
                CheckBarCode();
            }

            if (!IsCustomer)
            {
                string message7 = "Please fill ID number";
                string title7   = "Error";
                MessageBox.Show(message7, title7);
            }


            if (IsBarCode && IsCustomer)
            {
                ID_TextBox.ReadOnly = true;
                Rquantity           = numericUpDown1.Value;
                quantity            = (int)Rquantity;
                customer            = Program.GetCustomerByID(int.Parse(ID_TextBox.Text));
                Record record = Program.GetRecordByQR(int.Parse(barcode_textbox.Text));


                if (quantity <= record.getQuantityInStock())
                {
                    string s = "";
                    s.Replace("\n", Environment.NewLine);
                    richTextBox1.Text  = richTextBox1.Text + "\n" + "Name: " + record.getRecordName().ToString() + "   x " + quantity + "     By: " + record.getArtist().ToString() + ",    " + "Price: " + (quantity * record.getPrice());
                    totalPrice         = totalPrice + quantity * record.getPrice();
                    price_textbox.Text = totalPrice.ToString();
                    record.setQuantityInStock(record.getQuantityInStock() - quantity);
                    if (!records.Contains(record))
                    {
                        map.Add(record, quantity);
                    }
                    else
                    {
                        foreach (var item in map)
                        {
                            int q = item.Value;
                            if (map.ContainsKey(record))
                            {
                                q = q + 1;
                            }
                            else
                            {
                                map.Add(record, quantity);
                            }
                        }
                    }



                    records.Add(record);
                    IsBarCode = false;
                }

                if (quantity > record.getQuantityInStock() && record.getQuantityInStock() != 0)
                {
                    string message4 = "There are only " + record.getQuantityInStock() + " records in stock";
                    string title4   = "Error";
                    MessageBox.Show(message4, title4);
                }
            }
        }