private void autentificareBtn_Click(object sender, RoutedEventArgs e)
        {
            Cont   a = new Cont(getUsername(), getPassword(), 'X');
            Client b = null;

            Type myType = typeof(Cont);

            FieldInfo[] fields = myType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);

            try
            {
                a = ContBLL.findUser(a);
                b = ClientBLL.getClientByUser(a);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString());
            }

            /*foreach (FieldInfo info in fields)
             * {
             *  MessageBox.Show(info.Name + ", " + info.GetValue(a).ToString());
             * }*/

            if (a != null)
            {
                if (a.Rol == 'A')
                {
                    AdminWindow meniuAdministrator = new AdminWindow();
                    meniuAdministrator.Show();
                    this.Close();
                }
                else if (a.Rol == 'C')
                {
                    ClientWindow meniuClient = new ClientWindow(a, b);
                    meniuClient.Show();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Acest cont nu exista");
            }
        }
Exemplo n.º 2
0
        private void btnCreareCont_Click(object sender, RoutedEventArgs e)
        {
            //string nume = numeTextBox.Text;
            //string prenume = prenumeTextBox.Text;
            //string cnp = cnpTextBox.Text;
            //string adresa = adresaTextBox.Text;
            //string nrTelefon = nrTelefonTextBox.Text;
            //string email = emailTextBox.Text;

            Cont   contNou   = getCont();
            Client clientNou = getClient();

            int  iterator = 0;
            bool ok       = true;

            foreach (Border b in formular.Children.OfType <Border>())
            {
                if (iterator == 1)
                {
                    PasswordBox pb = b.Child as PasswordBox;
                    //MessageBox.Show(pb.Password);
                    if (!(pb.Password.Length > 0))
                    {
                        ok = false;
                        MessageBox.Show("Parola necompletata");
                    }
                }
                else
                {
                    TextBox t = b.Child as TextBox;
                    //MessageBox.Show(t.Text);
                    if (t.Text.Length == 0)
                    {
                        ok = false;
                        MessageBox.Show("Camp(uri) necompletat(e)");
                    }
                }

                iterator++;
            }

            if (ok == true)
            {
                try
                {
                    if (ContBLL.findUser(contNou) == null)
                    {
                        ClientBLL clientBLL = new ClientBLL();
                        if (clientBLL.validareClient(clientNou) == 1)
                        {
                            ContBLL.insertUser(contNou);
                            //contNou = ContBLL.findUser(contNou);
                            ClientBLL.insertClient(clientNou);

                            MessageBox.Show("Contul a fost creat cu succes!");
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Acest cont exista deja");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }