Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            String        conString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
            SqlConnection con       = new SqlConnection(conString);

            con.Open();
            String        query = String.Format(@"Select * from [User] where login = '******' and password = '******'", textBox1.Text, textBox2.Text);
            SqlCommand    cmd   = new SqlCommand(query, con);
            SqlDataReader rdr   = cmd.ExecuteReader();

            if (rdr.Read())
            {
                bool mngr  = rdr.GetBoolean(3);
                bool recep = rdr.GetBoolean(4);
                if (mngr)
                {
                    this.Hide();
                    Manager m = new Manager();
                    m.Show();
                }

                else if (recep)
                {
                    this.Hide();
                    Receptionist r = new Receptionist();
                    r.Show();
                }
            }
            else
            {
                MessageBox.Show("Wrong username/Password");
            }
            con.Close();
        }
        private void button4_Click(object sender, EventArgs e)
        {
            this.Hide();
            Receptionist r = new Receptionist();

            r.Show();
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\ME\Downloads\RMS\RMS\Database1.mdf;Integrated Security=True;Connect Timeout=30");

            con.Open();
            if (textBox1.Text == "Manager" || textBox1.Text == "manager")
            {
                string         query = "Select Count(*) From Manager where mgr_pswd ='" + textBox2.Text + "'";
                SqlDataAdapter sda   = new SqlDataAdapter(query, con);
                sda.SelectCommand.ExecuteNonQuery();
                DataTable dt = new DataTable();
                sda.Fill(dt);
                if (dt.Rows.Count == 1)
                {
                    this.Hide();
                    Manager m = new Manager();
                    m.Show();
                }
                else
                {
                    MessageBox.Show("Try Again");
                }
            }
            else if (textBox1.Text == "Receptionist" || textBox1.Text == "receptionist")
            {
                string         query = "Select Count(*) From Receptionist where recep_pswd ='" + textBox2.Text + "'";
                SqlDataAdapter sda   = new SqlDataAdapter(query, con);
                sda.SelectCommand.ExecuteNonQuery();
                DataTable dt = new DataTable();
                sda.Fill(dt);
                if (dt.Rows.Count == 1)
                {
                    this.Hide();
                    Receptionist r = new Receptionist();
                    r.Show();
                }
                else
                {
                    MessageBox.Show("Try Again");
                }
            }
            else if (textBox1.Text == "Customer" || textBox1.Text == "customer" && textBox2.Text == "123")
            {
                this.Hide();
                Customer cust = new Customer();
                cust.Show();
            }
            else
            {
                MessageBox.Show("Invalid Id or Password");
            }
            con.Close();
        }