Example #1
0
        public void ButtonKupnjaClick(IBuyForm BuyFormView, DataGridView inDatagridView, decimal inKol)
        {
            int  index = 0;
            bool pom   = false;

            foreach (DataGridViewRow row in inDatagridView.Rows)
            {
                DataGridViewCheckBoxCell chk = row.Cells[0] as DataGridViewCheckBoxCell;

                if (Convert.ToBoolean(chk.Value) == true)
                {
                    pom = true;
                    break;
                }
                index++;
            }
            if (pom)
            {
                Event ev  = EventRepository.getInstance().getEventByIndex(index);
                int   kol = Convert.ToInt32(inKol);
                if (kol == 0)
                {
                    MessageBox.Show("Odaberite količinu karata");
                }
                else if (ev.Quantity < kol)
                {
                    MessageBox.Show("Nema dovoljno karata");
                }
                else
                {
                    DateTime time   = DateTime.Now;
                    string   str    = time.ToString();
                    byte[]   buffer = new byte[str.Length];
                    int      i      = 0;
                    foreach (char c in str.ToCharArray())
                    {
                        buffer[i] = (byte)c;
                        i++;
                    }
                    MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                    string md5string             = BitConverter.ToString(md5.ComputeHash(buffer)).Replace("-", "");


                    AddNewBill(md5string, kol, time, ev);
                    EventRepository.getInstance().RemoveTickets(kol, ev.Name);

                    List <Event> list = EventController.getInstance().GetEventList();
                    EventController.getInstance().NotifyObservers(list);

                    MessageBox.Show("Uspješna kupovina!\n\nRačun:\n\nŠifra: " + md5string + "\nDogađaj: " + ev.Name + "\nKoličina: " + kol.ToString());
                }
            }
            else
            {
                MessageBox.Show("Nije odabran niti jedan događaj!");
            }
        }
Example #2
0
        public void SetBuyFormParameters(IBuyForm BuyFormView, ref DataGridView inDataGrid)
        {
            Attach((IEvenTimeObserver)BuyFormView);

            DataGridViewCheckBoxColumn CheckBox1 = new DataGridViewCheckBoxColumn();

            CheckBox1.HeaderText = "Odabir";
            CheckBox1.Name       = "CheckBoxPass1";
            CheckBox1.FlatStyle  = FlatStyle.Standard;
            CheckBox1.ThreeState = false;
            CheckBox1.CellTemplate.Style.BackColor = System.Drawing.Color.LightBlue;
            inDataGrid.Columns.Insert(0, CheckBox1);

            List <Event> listEvent = GetEventList();

            SetEventList(listEvent, ref inDataGrid);
        }
        public void ButtonRezervacijaClick(IBuyForm BuyFormView, ref DataGridView inDatagridView, decimal inKol)
        {
            int  index = 0;
            bool pom   = false;

            foreach (DataGridViewRow row in inDatagridView.Rows)
            {
                DataGridViewCheckBoxCell chk = row.Cells[0] as DataGridViewCheckBoxCell;

                if (Convert.ToBoolean(chk.Value) == true)
                {
                    pom = true;
                    break;
                }
                index++;
            }
            if (pom)
            {
                Event ev  = EventRepository.getInstance().getEventByIndex(index);
                int   kol = Convert.ToInt32(inKol);

                if (DateTime.Compare(ev.Date, DateTime.Now.AddDays(2)) < 0)
                {
                    MessageBox.Show("Za ovaj događaj moguća je samo kupnja!");
                }
                else if (kol == 0)
                {
                    MessageBox.Show("Odaberite količinu karata");
                }
                else if (ev.Quantity < kol)
                {
                    MessageBox.Show("Nema dovoljno karata");
                }
                else
                {
                    BuyFormView.OpenCustomerForm(kol, ev);
                }
            }
            else
            {
                MessageBox.Show("Nije odabran niti jedan događaj!");
            }
        }