private void textBoxScannedCode_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                //porovnaj s datami v subore.
                customer = new CustomerControl();
                string[] temp = customer.SearchRecord(textBoxScannedCode.Text);
                if (temp != null)
                {
                    if (temp[2].Split(' ')[1] != "vstupov")
                    {
                        MessageBox.Show("Zlý typ karty! Preukázaná karta nie je vydaná na fixný počet vstupov. Skúste použiť " +
                                        "tlačidlo: Kontrola časovej permanentky");
                        return;
                    }

                    textBoxNamAndSurname.Text = temp[1];
                    textBoxDate.Text          = temp[3];
                    comboBoxNoEntry.Text      = temp[2].Split(' ')[0];
                    buttonOdratat.Enabled     = true;
                    if (manazment)
                    {
                        comboBoxNoEntry.Enabled = true;
                    }
                }
                else
                {
                    MessageBox.Show("Nenašiel sa zákaznik.");
                }
            }
        }
Beispiel #2
0
        private void textBoxScannedCode_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                //porovnaj s datami v subore.
                CustomerControl customer = new CustomerControl();
                string[]        temp     = customer.SearchRecord(textBoxScannedCode.Text);
                if (temp != null)
                {
                    if (temp[2].Split(' ')[1] != "mesačný")
                    {
                        MessageBox.Show("Zlý typ karty! Preukázaná karta nie je vydaná na časove obdobie. Skúste použiť " +
                                        "tlačidlo: Kontrola vstupnej permanentky");
                        return;
                    }

                    textBoxNamAndSurname.Text = temp[1];
                    textBoxDate.Text          = temp[3];
                    labelIsValid.Text         = "Valid!";

                    // zisti platnost karty
                    DateTime timeOfRegistration = DateTime.Parse(temp[3]);
                    string   months             = temp[2].Split(' ')[0];

                    DateTime expirationDate = timeOfRegistration.AddMonths(int.Parse(months));

                    int result = DateTime.Compare(expirationDate, DateTime.Today);

                    //-1 = expirovalo
                    //0 - dnes expiruje ale je platna
                    //1 - este je platna
                    if (result == 1 || result == 0)
                    {
                        labelIsValid.Text = "Valid!";
                    }
                    else if (result == -1)
                    {
                        MessageBox.Show("Platnosť karty vypršala.");
                        labelIsValid.Text = "Invalid!";
                    }
                }
                else
                {
                    MessageBox.Show("Nenašiel sa zákaznik.");
                    labelIsValid.Text = "Invalid!";
                }
            }
        }
Beispiel #3
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            Boolean isOk = true;

            try
            {
                if (textBoxScannedCode.Text != "")
                {
                    NewCustomer.CardCode = textBoxScannedCode.Text;
                }
                else
                {
                    isOk = false;
                    MessageBox.Show("Nie je naskenovany Čiarovy kód.");
                    textBoxScannedCode.Focus();
                }

                if (dateTimePicker.Checked)
                {
                    NewCustomer.RegistrationDate = dateTimePicker.Value;
                }
                else
                {
                    isOk = false;
                    MessageBox.Show("Vyberte validný dátum.");
                    dateTimePicker.Focus();
                }

                if (textBoxNameAndSurname.Text != "")
                {
                    NewCustomer.Name = textBoxNameAndSurname.Text;
                }
                else
                {
                    isOk = false;
                    MessageBox.Show("Pole s menom zákazníka nie je vzplnené!");
                    textBoxNameAndSurname.Focus();
                }

                if (comboBoxTypeOfCard.SelectedIndex > -1)
                {
                    NewCustomer.CardType = comboBoxTypeOfCard.Text;
                }
                else
                {
                    isOk = false;
                    MessageBox.Show("Vyžaduje sa vybratie typu karty!");
                    comboBoxTypeOfCard.Focus();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            if (isOk)
            {
                CustomerControl customer = new CustomerControl();
                customer.AddRecord(NewCustomer.CardCode, NewCustomer.Name, NewCustomer.CardType, NewCustomer.RegistrationDate);
                this.Close();
                Form1.Form1Instance.Show();
            }
        }