Ejemplo n.º 1
0
        public int CompareTo(object obj)
        {
            AbonatTelefonic at = (AbonatTelefonic)obj;

            if (nrTelefon > at.nrTelefon)
            {
                return(1);
            }
            else if (nrTelefon < at.nrTelefon)
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (tbCNP.Text == "")
            {
                errorProvider1.SetError(tbCNP, "Introduceti CNP-ul!");
            }
            else if (tbNume.Text == "")
            {
                errorProvider1.SetError(tbNume, "Introduceti Numele!");
            }
            else if (tbAdresa.Text == "")
            {
                errorProvider1.SetError(tbAdresa, "Introduceti Adresa!");
            }
            else if (tbNumar.Text == "")
            {
                errorProvider1.SetError(tbNumar, "Introduceti Numarul");
            }
            else if (tbTip.Text == "")
            {
                errorProvider1.SetError(tbTip, "Introdcueti tipul abonatului!");
            }
            else if (tbVector.Text == "")
            {
                errorProvider1.SetError(tbVector, "Introduceti datele referitoarele la minutele vorbite!");
            }
            else
            {
                try
                {
                    errorProvider1.Clear();
                    long   c   = Convert.ToInt64(tbCNP.Text);
                    string n   = tbNume.Text;
                    string a   = tbAdresa.Text;
                    long   nr  = Convert.ToInt64(tbNumar.Text);
                    string tip = tbTip.Text;

                    string[] vector = tbVector.Text.Trim().Split(',');
                    double[] minute = new double[vector.Length];
                    for (int i = 0; i < vector.Length; i++)
                    {
                        minute[i] = Convert.ToDouble(vector[i]);
                    }
                    AbonatTelefonic abonat = new AbonatTelefonic(c, n, a, nr, tip, minute);
                    lista.Add(abonat);
                    lista.Sort();
                    MessageBox.Show("Abonat adaugat cu succes!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    tbCNP.Clear();
                    tbNumar.Clear();
                    tbNume.Clear();
                    tbAdresa.Clear();
                    tbTip.Clear();
                    tbVector.Clear();
                    errorProvider1.Clear();
                }
            }
        }