コード例 #1
0
 private void tbCode_TextChanged(object sender, EventArgs e)
 {
     if (lstBilten.Items.Count > 0)
     {
         foreach (object obj in lstBilten.Items)
         {
             Game       g    = obj as Game;
             TicketItem item = new TicketItem();
             if (cbTip.SelectedIndex != -1)
             {
                 if (g.Code.Equals(tbCode.Text))
                 {
                     item.Game = g;
                     if (!containsItem(item))
                     {
                         lstTicket.Items.Add(item);
                         calculateTotal();
                         tbCode.Text = null;
                     }
                     else
                     {
                         MessageBox.Show("Овој натпревар е веќе типуван!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
                 }
             }
             else
             {
                 MessageBox.Show("Изберете тип!", "Информација!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 cbTip.Focus();
             }
         }
     }
 }
コード例 #2
0
 private void btnAddGame_Click(object sender, EventArgs e)
 {
     if (lstBilten.SelectedIndex != -1)
     {
         if (cbTip.SelectedIndex != -1)
         {
             Game       g  = lstBilten.SelectedItem as Game;
             TicketItem ti = new TicketItem();
             ti.Game = g;
             ti.Tip  = cbTip.SelectedIndex;
             if (!containsItem(ti))
             {
                 lstTicket.Items.Add(ti);
                 cbTip.SelectedIndex = -1;
                 lstBilten.ClearSelected();
                 calculateTotal();
             }
             else
             {
                 MessageBox.Show("Овој натпревар е веќе типуван!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 lstBilten.ClearSelected();
             }
         }
         else
         {
             MessageBox.Show("Изберете тип!", "Информација!", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         cbTip.Focus();
     }
     else
     {
         MessageBox.Show("Немате избрано натпревар!", "Грешка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #3
0
 private bool containsItem(TicketItem t)
 {
     foreach (object obj in lstTicket.Items)
     {
         TicketItem i = obj as TicketItem;
         if (i.Game.Code.Equals(t.Game.Code))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #4
0
        private void calculateTotal()
        {
            float totalCoeficient = 1;
            float dobivka         = 1;

            foreach (object obj in lstTicket.Items)
            {
                TicketItem t = obj as TicketItem;
                totalCoeficient *= t.Game.Coefitients[t.Tip];//ja zema vrednosta na koeficientot od game i ja stava vo nizata na koeficienti
            }
            dobivka           = totalCoeficient * (int)numUplata.Value;
            tbVkupnoKoef.Text = string.Format("{0:0.0000}", totalCoeficient.ToString());
            tbDobivka.Text    = string.Format("{0:0.000} ден.", dobivka.ToString());
        }