private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
            DashboardPage dashboardPage = new DashboardPage(Id);

            dashboardPage.Show();
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string usr = comboBox1.Text;

            if (usr == "Student")
            {
                try
                {
                    SqlConnection con = new SqlConnection("Data Source=DESKTOP-JT5TE1G\\SQLEXPRESS;Initial Catalog=signup;User ID=your_id;Password=you_pass");
                    con.Open();

                    //string newcon = "insert into signuptable(Name,ID,Year, Semester, Password) VALUES ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "', '" + textBox4.Text + "','" + textBox5.Text + "')";

                    string newcon = "select ID from signuptable1 where ID='" + textBox1.Text + "' and Password='******'";

                    SqlDataAdapter adp = new SqlDataAdapter(newcon, con);
                    DataSet        ds  = new DataSet();

                    adp.Fill(ds);

                    DataTable dt = ds.Tables[0];

                    if (dt.Rows.Count >= 1)
                    {
                        id = textBox1.Text;
                        //  MessageBox.Show(id);
                        DashboardPage dashboardPage = new DashboardPage(id);
                        dashboardPage.Show();
                        this.Hide();
                    }
                    else
                    {
                        label4.Text = "Wrong ID or Password";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (usr == "Admin")
            {
                string str = textBox1.Text;
                string pas = textBox2.Text;
                if (str == "Admin" && pas == "Admin")
                {
                    this.Hide();
                    AdminPanel adminPanel = new AdminPanel();
                    adminPanel.Show();
                }
                else
                {
                    MessageBox.Show("Wrong ID or Password");
                }
            }
            else
            {
                MessageBox.Show("Please Select a User");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string pas1 = textBox5.Text;
            string pas2 = textBox6.Text;

            if (pas1 == pas2)
            {
                try
                {
                    SqlConnection con = new SqlConnection("Data Source=DESKTOP-JT5TE1G\\SQLEXPRESS;Initial Catalog=signup;User ID=your_id;Password=you_pass");
                    con.Open();

                    string newcon = "update signuptable1 set Name='" + textBox1.Text + "',ID='" + textBox2.Text + "',Year='" + textBox3.Text + "', Semester='" + textBox4.Text + "', Password='******' where ID='" + Id + "';";

                    SqlCommand cmd = new SqlCommand(newcon, con);

                    SqlDataReader dr = cmd.ExecuteReader();

                    con.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                Id = textBox2.Text;

                this.Hide();
                MessageBox.Show("Your Profile Successfully Saved!");
                DashboardPage dashboardPage = new DashboardPage(Id);
                dashboardPage.Show();
            }
            else
            {
                MessageBox.Show("Your Password do not Match!");
            }
        }