Esempio n. 1
0
        private void Home_Load(object sender, EventArgs e)
        {
            Location = inheritJsonStorage.HomeWindowLocation;
            Size     = inheritJsonStorage.HomeWindowSize;

            responsive();

            if (userInformations.GetType() == typeof(EnterpriseUser))
            {
                displayEnterpriseLists();
            }
            updateInfos();
        }
Esempio n. 2
0
        private void tryLogin()
        {
            lblError.Text         = "";
            txtEmail.BackColor    = Color.FromArgb(255, 255, 255);
            txtPassword.BackColor = Color.FromArgb(255, 255, 255);

            try
            {
                DatabaseManagement database = new DatabaseManagement();
                database.OpenConnection();

                bool allowConnection = database.VerifyUser(txtEmail.Text.ToLower().Trim(), password.Trim());

                database.CloseConnection();

                if (allowConnection)
                {
                    database = new DatabaseManagement();
                    database.OpenConnection();

                    PublicUser loggedUserInfos = (PublicUser)database.GetUser(txtEmail.Text.ToLower().Trim());

                    database.CloseConnection();

                    Visible = false;

                    Form homeForm;
                    if (loggedUserInfos.GetType() == typeof(AdminUser))
                    {
                        homeForm = new FrmHomeAdmin((AdminUser)loggedUserInfos, jsonStorage);
                        homeForm.ShowDialog();
                    }
                    else
                    {
                        homeForm = new FrmHome(loggedUserInfos, jsonStorage);
                        homeForm.ShowDialog();
                    }

                    jsonStorage.HomeWindowLocation = homeForm.Location;
                    jsonStorage.HomeWindowSize     = homeForm.Size;
                    jsonFile.InsertData(jsonStorage);

                    Close();
                }
                else
                {
                    //User and password doesn't match case
                    lblError.Text         = "Login incorrect";
                    txtEmail.BackColor    = Color.FromArgb(255, 128, 128);
                    txtPassword.BackColor = Color.FromArgb(255, 128, 128);
                }
            }
            catch (UnableToJoinDatabase)
            {
                lblError.Text         = "La base de données est injoignable";
                txtEmail.BackColor    = Color.FromArgb(255, 128, 128);
                txtPassword.BackColor = Color.FromArgb(255, 128, 128);
            }
            catch (UserDoesNotExistsException)
            {
                lblError.Text         = "Login incorrect";
                txtEmail.BackColor    = Color.FromArgb(255, 128, 128);
                txtPassword.BackColor = Color.FromArgb(255, 128, 128);
            }
        }