Exemple #1
0
        private void initialControl1_Load(object sender, EventArgs e)
        {
            CreateAccountControl createAccountControl = new CreateAccountControl();

            createAccountControl.Location = new Point(0, 0);

            DashboardControl dashboardControl = new DashboardControl();

            dashboardControl.Location = new Point(0, 0);

            InitialControl initialControl = new InitialControl();

            initialControl.Location = new Point(0, 0);

            LoginControl loginControl = new LoginControl();

            loginControl.Location = new Point(0, 0);

            ScheduleControl scheduleControl = new ScheduleControl();

            scheduleControl.Location = new Point(185, 0);

            SettingsControl settingsControl = new SettingsControl();

            settingsControl.Location = new Point(185, 0);

            ExhibitionsControl exhibitionsControl = new ExhibitionsControl();

            exhibitionsControl.Location = new Point(185, 0);

            MessagesControl messagesControl = new MessagesControl();

            messagesControl.Location = new Point(185, 0);

            newMessageControl newMessageControl = new newMessageControl();

            newMessageControl.Location = new Point(185, 0);

            SingleMessageControl singleMessageControl = new SingleMessageControl();

            singleMessageControl.Location = new Point(185, 0);
            //MessagesControl messagesControl = new MessagesControl();
            //messagesControl.Location = new Point(185, 0);

            this.Controls.Add(createAccountControl);
            this.Controls.Add(dashboardControl);
            this.Controls.Add(initialControl);
            this.Controls.Add(loginControl);
            this.Controls.Add(scheduleControl);
            this.Controls.Add(settingsControl);
            this.Controls.Add(exhibitionsControl);
            this.Controls.Add(messagesControl);
            this.Controls.Add(newMessageControl);
            this.Controls.Add(singleMessageControl);
        }
        private void CreateAccount_Click(object sender, EventArgs e)
        {
            bool fillParameters = true;

            if (UserName.Equals("") || UserPassword.Equals("") || UserMail.Equals("") || UserPhone.Equals(""))
            {
                fillParameters = false;
            }

            try
            {
                MailAddress mail = new MailAddress(UserMail);
            }
            catch (FormatException)
            {
                fillParameters = false;
            }

            if (!radioEmployee.Checked && !radioExhibitor.Checked)
            {
                fillParameters = false;
            }

            if (fillParameters)
            {
                var    FactoryUsers = FactoryCreator.Instance.CreateFactory(FactoryCreator.PersonFactory);
                Person user         = null;
                string role;
                if (radioExhibitor.Checked)
                {
                    user = (Exhibitor)FactoryUsers.Create(PersonFactory.exhibitor);
                    role = nameof(Exhibitor);
                }
                else
                {
                    user = (Employee)FactoryUsers.Create(PersonFactory.employee);
                    role = nameof(Employee);
                }
                Dictionary <string, string> dictionary = new Dictionary <string, string>();

                dictionary.Add(Person.MailProperty, UserMail);
                dictionary.Add(Person.NameProperty, UserName);
                dictionary.Add(Person.PhoneProperty, UserPhone);
                dictionary.Add(Person.PasswordProperty, UserPassword);

                if (user.CreateAccountMethod(dictionary))
                {
                    Console.WriteLine("Correu tudo bem");
                    var index = this.ParentForm.Controls.IndexOfKey(AppForms.Dashboard_Control);
                    DashboardControl dashboardControl = (DashboardControl)this.ParentForm.Controls[index];
                    dashboardControl.Person = user;
                    dashboardControl.Role   = role;
                    dashboardControl.BringToFront();
                }
                else
                {
                    Console.WriteLine("Algo falhou");
                }
            }
            else
            {
                Console.WriteLine("Falta preencher coisas!!!!");
            }
        }