예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
            RenterHome a = new RenterHome();

            a.Show();
        }
예제 #2
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection conn = new SqlConnection(@"Server=.\SQLEXPRESS;Database=House;Integrated Security=true");
                conn.Open();
                SqlCommand     cmd = new SqlCommand("SELECT * FROM Login WHERE id= '" + txtid.Text + "' AND Password= '******'AND UserType= '" + comboBox1.Text + "'", conn);
                SqlDataAdapter da  = new SqlDataAdapter(cmd);

                DataTable dt = new DataTable();
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    SqlCommand     cmd1 = new SqlCommand("SELECT UserType FROM Login WHERE id= '" + txtid.Text + "' AND Password= '******'", conn);
                    SqlDataAdapter da1  = new SqlDataAdapter(cmd1);
                    DataTable      dt1  = new DataTable();
                    da1.Fill(dt1);
                    if (dt1.Rows[0][0].ToString() == "Admin")
                    {
                        this.Hide();
                        Admin a = new Admin();
                        a.Show();
                    }

                    else if (dt1.Rows[0][0].ToString() == "Renter")
                    {
                        this.Hide();
                        RenterHome r = new RenterHome();
                        r.Show();
                    }
                    else if (dt1.Rows[0][0].ToString() == "Care Taker")
                    {
                        this.Hide();
                        CareTakerHome c = new CareTakerHome();
                        c.Show();
                    }
                }
                else
                {
                    MessageBox.Show("Invalid Id or Password!!!\n    Please try again!", "Message");
                }

                conn.Close();
            }

            catch (Exception c)
            {
                MessageBox.Show(c.Message);
            }
        }