private void AddAgent()
        {
            new System.Threading.Thread(() =>
            {
                Classes.AgentManager agentManager = new Classes.AgentManager();

                if (agentManager.CanAddAgent(GetEmail()))
                {
                    SetLoadingState(true);

                    if (agentManager.AddAgent(GetName(), GetSurname(), GetPhone(), GetEmail(), GetPassword()))
                    {
                        DisplayNotifyBox("Agent Added", GetName() + " has been successfully added", 2);
                    }
                    else
                    {
                        DisplayNotifyBox("ERROR", "Could not add " + GetName(), 2);
                    }

                    ClearForm();
                }
                else
                {
                    DisplayNotifyBox("Username Exists Already", "Cannot add " + GetName() + ", the email " + GetEmail() + " exits already", 3);
                }

                SetLoadingState(false);
            }).Start();
        }
Beispiel #2
0
        private void EditEmail(string email, string newEmail)
        {
            Classes.AgentManager agentManager = new Classes.AgentManager();

            if (agentManager.CanAddAgent(newEmail))
            {
                new System.Threading.Thread(() =>
                {
                    SetLoadingState(true);

                    if (agentManager.EditEmail(email, newEmail))
                    {
                        DisplayNotifyBox("Edited", "Email changed to " + newEmail, 5);
                    }
                    else
                    {
                        edited = false;
                        DisplayNotifyBox("Could not edit", "En error occured while trying to change email. Please try again later", 5);
                    }
                    SetLoadingState(false);
                }).Start();
            }
            else
            {
                edited = false;
                DisplayNotifyBox("Could not edit", "Cannot change " + email + " to " + newEmail + " because " + newEmail + " already exists", 4);
            }
        }
        private void AddAgent()
        {
            new System.Threading.Thread(() =>
            {
                Classes.AgentManager agentManager = new Classes.AgentManager();

                if (agentManager.CanAddAgent(GetEmail()))
                {
                    SetLoadingState(true);

                    Classes.Validation valid = new Classes.Validation();
                    if (valid.TextIsShorterThan(GetName(), 32) && valid.TextIsShorterThan(GetSurname(), 32) && valid.TextIsShorterThan(GetPhone(), 12))
                    {
                        if (valid.IsTextNumeric(GetPhone()))
                        {
                            if (agentManager.AddAgent(GetName(), GetSurname(), GetPhone(), GetEmail(), GetPassword()))
                            {
                                DisplayNotifyBox("Agent Added", GetName() + " has been successfully added", 5);

                            }
                            else
                            {
                                DisplayNotifyBox("ERROR", "Could not add " + GetName(), 2);
                            }
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please use a valid cellphone number with local 099 999 999 format", 10);
                        }
                    }
                    else
                    {
                        DisplayNotifyBox("ERROR", "Please ensure all fields have lengths shorter than 32 characters", 10);
                    }
                    ClearForm();
                }
                else
                {
                    DisplayNotifyBox("Username Exists Already", "Cannot add " + GetName() + ", the email " + GetEmail() + " exits already", 3);
                }

                SetLoadingState(false);
            }).Start();
        }
        private void AddAgent()
        {
            new System.Threading.Thread(() =>
            {
                Classes.AgentManager agentManager = new Classes.AgentManager();

                if (agentManager.CanAddAgent(GetEmail()))
                {
                    SetLoadingState(true);

                    Classes.Validation valid = new Classes.Validation();
                    if (valid.TextIsShorterThan(GetName(), 32) && valid.TextIsShorterThan(GetSurname(), 32) && valid.TextIsShorterThan(GetPhone(), 12))
                    {
                        if (valid.IsTextNumeric(GetPhone()))
                        {
                            if (agentManager.AddAgent(GetName(), GetSurname(), GetPhone(), GetEmail(), GetPassword()))
                            {
                                DisplayNotifyBox("Agent Added", GetName() + " has been successfully added", 5);
                            }
                            else
                            {
                                DisplayNotifyBox("ERROR", "Could not add " + GetName(), 2);
                            }
                        }
                        else
                        {
                            DisplayNotifyBox("ERROR", "Please use a valid cellphone number with local 099 999 999 format", 10);
                        }
                    }
                    else
                    {
                        DisplayNotifyBox("ERROR", "Please ensure all fields have lengths shorter than 32 characters", 10);
                    }
                    ClearForm();
                }
                else
                {
                    DisplayNotifyBox("Username Exists Already", "Cannot add " + GetName() + ", the email " + GetEmail() + " exits already", 3);
                }

                SetLoadingState(false);
            }).Start();
        }
        private void EditEmail(string email, string newEmail)
        {
            Classes.AgentManager agentManager = new Classes.AgentManager();

            if (agentManager.CanAddAgent(newEmail))
            {
                new System.Threading.Thread(() =>
                {
                    SetLoadingState(true);

                    if (agentManager.EditEmail(email, newEmail))
                    {
                        DisplayNotifyBox("Edited", "Email changed to " + newEmail, 5);
                    }
                    else
                    {
                        edited = false;
                        DisplayNotifyBox("Could not edit", "En error occured while trying to change email. Please try again later", 5);
                    }
                    SetLoadingState(false);

                }).Start();
            }
            else
            {
                edited = false;
                DisplayNotifyBox("Could not edit", "Cannot change " + email + " to " + newEmail + " because " + newEmail + " already exists", 4);
            }
        }