private void button5_Click(object sender, EventArgs e)
        {
            this.Hide();
            ManagerHome f1 = new ManagerHome();

            f1.ShowDialog();
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string        query = null;
            SqlConnection con   = new SqlConnection(@"Data Source=.;Initial Catalog=MyProject;Integrated Security=True");

            query = "select * from loginInfo where username='******'and password='******'";
            con.Open();
            SqlDataAdapter sda = new SqlDataAdapter(query, con);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);
            string cmbItemValue = comboBox1.SelectedItem.ToString();

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["usertype"].ToString() == cmbItemValue)
                    {
                        MessageBox.Show("you are logged in as " + dt.Rows[i][2]);
                        if (comboBox1.SelectedIndex == 0)
                        {
                            ManagerHome mh = new ManagerHome();
                            this.Hide();
                            mh.ShowDialog();
                        }
                        else
                        {
                            CustomerForm m = new CustomerForm();
                            this.Hide();
                            m.ShowDialog();
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("error");
            }
            con.Close();
        }