Exemplo n.º 1
0
        public BasicUserPanel(BasicUserPanelVM basicUserPanelVM)
        {
            InitializeComponent();

            // Set information about login panel
            loginPanel = basicUserPanelVM.loginPanel;

            // Set basic user data
            this.basicUser = basicUserPanelVM.basicUser;

            // Show basic user information
            BasicUserInformationLabel.Text = $"Witaj {basicUser._Name._Value } " +
                                             $"{basicUser._Surname._Value}";
        }
Exemplo n.º 2
0
        private void AcceptButton_Click(object sender, EventArgs e)
        {
            // Pin Code
            PinVAL pinCode = null;

            // Validate Pin Code
            try
            {
                pinCode = new PinVAL(PinCodeTextBox.Text);
            }
            catch (PinVAL_Exception p_e)
            {
                ErrorLabel.Text = p_e.What();
                ErrorLabel.Show();
            }

            if (pinCode != null)
            {
                // Login basic user
                if (pinCode._Value.Length == 4)
                {
                    try
                    {
                        // Connect with basic users database
                        MockBasicUsersRepository mockBasicUsersRepository =
                            new MockBasicUsersRepository(SystemSettings._PlatformType);

                        // Get information about basic user with respectively pin code
                        // from database
                        BasicUserPanelVM basicUserPanelVM = new BasicUserPanelVM
                        {
                            basicUser = mockBasicUsersRepository.GetAll().FirstOrDefault(
                                (singleBasicUser) => singleBasicUser._Pin._Value == pinCode._Value)
                        };

                        // Check basic user's find result
                        if (basicUserPanelVM.basicUser != null)
                        {
                            // Redirect to Basic User Panel
                            basicUserPanelVM.loginPanel = this;

                            BasicUserPanel basicUserPanel = new BasicUserPanel(basicUserPanelVM);

                            this.PinCodeTextBox.Clear();
                            this.ErrorLabel.Hide();
                            basicUserPanel.Show();
                            this.Hide();
                        }
                        else
                        {
                            ErrorLabel.Text = "!!! Użytkownik O Podanym Pinie Nie Istnieje !!!";
                            ErrorLabel.Show();
                        }
                    }
                    catch (MockBasicUsersRepository_Exception mbur_e)
                    {
                        ErrorLabel.Text = mbur_e.What();
                        ErrorLabel.Show();
                    }
                }
                // Login administrator
                else if (pinCode._Value.Length == 6)
                {
                    try
                    {
                        // Connect with administrators database
                        MockAdministratorsRepository mockAdministratorsRepository =
                            new MockAdministratorsRepository(SystemSettings._PlatformType);

                        // Get information about administrator with respectively pin code
                        // from database
                        AdministratorPanelVM administratorPanelVM = new AdministratorPanelVM
                        {
                            administrator = mockAdministratorsRepository.GetAll().
                                            FirstOrDefault((singleAdministrator) =>
                                                           singleAdministrator._Pin._Value == pinCode._Value)
                        };

                        // Check administrator's find result
                        if (administratorPanelVM.administrator != null)
                        {
                            // Redirect to administrator panel
                            administratorPanelVM.loginPanel = this;

                            AdministratorPanel administratorPanel =
                                new AdministratorPanel(administratorPanelVM);

                            this.PinCodeTextBox.Clear();
                            this.ErrorLabel.Hide();
                            administratorPanel.Show();
                            this.Hide();
                        }
                        else
                        {
                            ErrorLabel.Text = "!!! Użytkownik O Podanym Pinie Nie Istnieje !!!";
                            ErrorLabel.Show();
                        }
                    }
                    catch (MockAdministratorsRepository_Exception mar_e)
                    {
                        ErrorLabel.Text = mar_e.What();
                        ErrorLabel.Show();
                    }
                }
            }
        }