Пример #1
0
        private void bunifuThinButton24_Click(object sender, EventArgs e)
        {
            if (txtUser.Text.Trim() != "" && !hint)
            {
                if (txtPassword.Text.Trim() != "" && !hint2)
                {
                    System.Configuration.Configuration c = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
                    User us;
                    try
                    {
                        if (UserCurrent.getCurrentUser() != null)
                        {
                            usController = new UserController();
                        }

                        us = usController.Logar(txtUser.Text, txtPassword.Text);
                        if (us != null)
                        {
                            SystemInfoCurrent.initialize();

                            UserCurrent.initialize(us);
                            if (us.FlagFirstLogin)
                            {
                                new FrmUserFirstLogin(us, this).Show();
                            }
                            else
                            {
                                new Main(this).Show();
                            }
                            txtUser.Focus();
                            txtUser.Select(0, 0);
                            Hide();
                            txtPassword.Clear();
                            txtUser.Clear();
                        }
                        else
                        {
                            MessageBox.Show("usuario ou senha incorrestos,\n TRY AGAIN");
                            txtPassword.Clear();
                            txtUser.Clear();
                            txtUser.Focus();
                        }
                    }
                    catch (Exception error)
                    {
                        MessageBox.Show(error.Message);
                        us = null;
                    }
                }
                else
                {
                    MessageBox.Show("Insira a senha");
                    txtPassword.Focus();
                }
            }
            else
            {
                MessageBox.Show("Insira o usuario");
            }
        }