Example #1
0
        private void SignIn_Click(object sender, EventArgs e)
        {
            //con.Close();

            String aid = Convert.ToString(NameSI.Text);

            try
            {
                con.Open();
                com = new SqlCommand("SELECT * FROM SignUp WHERE Id= '" + NameSI.Text.ToString() + "'and Password='******'", con);
                da  = new SqlDataAdapter(com);
                DataTable dt = new DataTable();
                da.Fill(dt);
                SqlDataReader dr = com.ExecuteReader();
                if (dt.Rows.Count > 0)
                {
                    con.Close();
                    con.Open();
                    SqlCommand com = new SqlCommand("SELECT * FROM SignUp WHERE Id= " + int.Parse(NameSI.Text), con);

                    dr = com.ExecuteReader();
                    if (dr.Read())
                    {
                        try
                        {
                            String v = (dr["UserType"].ToString());
                            if (v == "Employee")
                            {
                                Empo empo = new Empo();
                                empo.Show();
                                // this.Close();
                            }
                            else if (v == "Customer")
                            {
                                ViewItem viewItem = new ViewItem();
                                viewItem.Show();
                                //this.Close();
                            }
                            else
                            {
                                Admin admin = new Admin();
                                admin.Show();
                                //this.Close();
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                            Close();
                        }
                    }
                    con.Close();
                }
                else
                {
                    MessageBox.Show("Your Id is not found");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Close();
            }
        }