コード例 #1
0
        private async void btn_Register_Click(object sender, EventArgs e)
        {
            Core.Helper.CampsController controller = new Core.Helper.CampsController();

            bool response = controller.Registration(txtUsrR, txtPswR, txtRpswR, txtMail);

            if (response)
            {
                return;
            }

            DoRegister register = new DoRegister();

            try
            {
                registerStatus = await register.Register(txtUsrR.Text, txtPsw.Text, txtMail.Text, StdConfig.MYSQLCONNECTION);

                if (registerStatus == Cfg.RegisterStatus.Registered)
                {
                    txtUsrR.Clear();
                    txtPswR.Clear();
                    txtRpswR.Clear();
                    txtMail.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        private async void btn_Login_Click(object sender, EventArgs e)
        {
            try
            {
                Core.Helper.CampsController controller = new Core.Helper.CampsController();

                bool response = controller.Login(txtUsr, txtPsw);

                if (response)
                {
                    return;
                }

                DoLogin       login         = new DoLogin();
                DoPermissions DoPermissions = new DoPermissions();

                try
                {
                    loginStatus = await login.PasswordCheck(txtUsr.Text, txtPsw.Text, StdConfig.MYSQLCONNECTION);
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show("Error: " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    if (loginStatus == Config.Cfg.LoginStatus.LoggedIn)
                    {
                        btn_Login.Enabled = false;
                        txtUsr.Enabled    = false;
                        txtPsw.Enabled    = false;
                        btn_Login.Text    = "Logged";

                        System.Windows.Forms.MessageBox.Show("Account " + txtUsr.Text + " successfully logged in!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        //Check User Permissions
                        try
                        {
                            permissions = await DoPermissions.PermissionsCheck(txtUsr.Text, StdConfig.MYSQLCONNECTION);

                            this.Text    = "CloudNoty - ID: " + Config.Cfg.UID.ToString() + " - Permissions: " + permissions.ToString();
                            Cfg.LoggedIn = true;
                            Core.Forms.landingForm lForm = new Core.Forms.landingForm();
                            this.Hide();
                            saveLocalConfig();
                            lForm.Show();
                        }
                        catch (Exception ex)
                        {
                            System.Windows.Forms.MessageBox.Show("Error: " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else if (loginStatus == Config.Cfg.LoginStatus.WrongPassword)
                    {
                        System.Windows.Forms.MessageBox.Show("The password does not match for the account " + txtUsr.Text + "." + Environment.NewLine + "Contact an administrator for more informations!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (loginStatus == Config.Cfg.LoginStatus.InvalidAccount)
                    {
                        System.Windows.Forms.MessageBox.Show("Account " + txtUsr.Text + " does not exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            { System.Windows.Forms.MessageBox.Show(ex.ToString()); }
        }