Esempio n. 1
0
        // start button for admin and user

        private void button5_Click(object sender, EventArgs e)
        {
            labelerror.Visible = false;
            //Username Text
            if (adminUser.Text == "")
            {
                adminUser.Text      = "Username";
                adminUser.ForeColor = Color.LightGray;
            }

            //Password Text
            if (adminPass.Text == "")
            {
                adminPass.Text      = "Password";
                adminPass.ForeColor = Color.LightGray;
            }
            string req = "";

            if ((adminUser.Text != "" || adminUser.Text != "Username") && (adminPass.Text != "" || adminUser.Text != "Password") && comboBox2.Text != "")
            {
                try
                {
                    req = client.DownloadString("https://studentid.000webhostapp.com/Sloginform.php?employee_username="******"&employee_password="******"Admin")// if(true)
                {
                    Employee.getInstance().setUserName(adminUser.Text);
                    Employee.getInstance().setPassword(adminPass.Text);

                    appForm.loadPanel.Controls.Remove(this);
                    admin adminform;
                    adminform          = new admin(appForm, comboBox2.SelectedItem.ToString());
                    adminform.TopLevel = false;
                    appForm.loadPanel.Controls.Add(adminform);
                    adminform.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                    adminform.Dock            = DockStyle.Fill;
                    adminform.Show();
                }
                else if (req == "User")
                {
                    Employee.getInstance().setUserName(adminUser.Text);
                    Employee.getInstance().setPassword(adminPass.Text);

                    appForm.loadPanel.Controls.Remove(this);
                    studentForm stuform;
                    stuform          = new studentForm(appForm, comboBox2.SelectedItem.ToString());
                    stuform.TopLevel = false;
                    appForm.loadPanel.Controls.Add(stuform);
                    stuform.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                    stuform.Dock            = DockStyle.Fill;
                    stuform.Show();
                }
                else
                {
                    labelerror.Visible = true;
                }
            }
            else
            {
                if (adminUser.Text == "Username" || adminUser.Text == "")
                {
                    r1error.Visible = true;
                    p1error.Visible = true;
                }

                if (adminPass.Text == "Password" || adminPass.Text == "********")
                {
                    r2error.Visible = true;
                    p2error.Visible = true;
                }
                if (comboBox2.Text == "")
                {
                    r3error.Visible = true;
                    p3error.Visible = true;
                }
                labelerror.Visible = false;
            }
        }