Exemplo n.º 1
0
        /*
         *
         * Metoda przekazująca produkt do listy produktów do kupienia.
         */
        public void Addbtn_Click(object sender, EventArgs e)
        {
            if (ProductList.SelectedItems.Count == 0)
            {
                MessageBox.Show("Nie wybrano produktu!");
            }
            else if (ProductList.SelectedItems.Count != 0)
            {
                string BJ = ProductList.SelectedItems[0].SubItems[3].Text;
                type = ProductList.SelectedItems[0].SubItems[1].Text;
                if (VATbox.SelectedValue == null)
                {
                    Needed.Visible = true;
                    VATbox.Focus();
                }
                if (VATbox.SelectedItem != null)
                {
                    if (BJ.Equals("BJ"))//Bilet Jednorazowy
                    {
                        Needed.Visible = false;
                        string       ticketCounter = Convert.ToString(IloscBiletow.Value);
                        ListViewItem itemClone;
                        foreach (System.Windows.Forms.ListViewItem item in ProductList.SelectedItems)
                        {
                            itemClone = item.Clone() as System.Windows.Forms.ListViewItem;
                            ProductsToSell.Items.Add(itemClone);
                            itemClone.SubItems.Add((ticketCounter));
                        }
                        Counter();
                        Addbtn.Visible = false;
                    }
                    else
                    {
                        productID = ProductList.SelectedItems[0].SubItems[0].Text;
                        if (type.Equals("7DI"))//7 - NDAY TICKET
                        {
                            TicketActivePanel.Visible = true;
                            day7 = true;
                        }
                        else if (type.Equals("30DI"))//30 - NDAY TICKET
                        {
                            TicketActivePanel.Visible = true;
                            day30 = true;
                        }
                        else if (type.Equals("1Y"))//YEAR TICKET
                        {
                            year = true;
                            TicketActivePanel.Visible = true;
                        }
                        else if (type.Equals("MONTH"))//NMONTH TICKET
                        {
                            month = true;
                            TicketActivePanel.Visible = true;
                        }
                        else
                        {
                            day30 = true;
                            day7  = false;
                            year  = false;
                            month = false;
                            TicketActivePanel.Visible = false;
                        }

                        IloscBiletow.Value = 1;
                        Needed.Visible     = false;
                        //przekazanie z jednej listview do następnej.
                        //int b = 1;
                        ListViewItem itemClone;
                        foreach (ListViewItem item in ProductList.SelectedItems)
                        {
                            itemClone = item.Clone() as ListViewItem;
                            //ListaProduktów.Items.Remove(item);
                            ProductsToSell.Items.Add(itemClone);
                            itemClone.SubItems.Add((IloscBiletow.Value.ToString(CultureInfo.InvariantCulture)));
                        }
                        //IloscBiletow.Value = b;
                        Counter();
                        Addbtn.Visible = false;
                    }
                }
                IloscBiletow.Visible = false;
                Quantity.Visible     = false;
                IloscBiletow.Value   = 1;
            }
        }