Example #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            this.Close();
            adminhome a = new adminhome();

            a.Show();
        }
        private void admin_Click(object sender, EventArgs e)
        {
            this.Hide();
            adminhome a = new adminhome();

            a.Show();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            OracleConnection con = new OracleConnection(constr);

            try
            {
                if (comboBox1.Text == "User")
                {
                    string sql = "select count(*) from userinfo where user_id='" + textBox1.Text + "'and password='******'";

                    OracleDataAdapter adapter = new OracleDataAdapter(sql, con);

                    DataTable dt = new DataTable();
                    adapter.Fill(dt);


                    if (textBox1.Text != "" && textBox2.Text != "")
                    {
                        if (dt.Rows[0][0].ToString() == "1")
                        {
                            this.Hide();

                            userhome1 u = new userhome1();
                            u.passname = textBox1.Text;
                            u.Show();
                        }



                        else
                        {
                            MessageBox.Show("Incorrect user_Id and password");
                        }
                    }


                    else
                    {
                        if (textBox1.Text == "" && textBox2.Text == "")
                        {
                            MessageBox.Show("User_Id & password both required");
                        }
                        if (textBox1.Text == "" && textBox2.Text != "")
                        {
                            MessageBox.Show("User_Id required");
                        }
                        if (textBox1.Text != "" && textBox2.Text == "")
                        {
                            MessageBox.Show("Password is required");
                        }
                    }
                }



                else if (comboBox1.Text == "Admin")
                {
                    string sql = "select count(*) from admininfo where id='" + textBox1.Text + "'and password='******'";

                    OracleDataAdapter adapter = new OracleDataAdapter(sql, con);

                    DataTable dt = new DataTable();
                    adapter.Fill(dt);


                    if (textBox1.Text != "" && textBox2.Text != "")
                    {
                        if (dt.Rows[0][0].ToString() == "1")
                        {
                            this.Hide();

                            adminhome a = new adminhome();

                            a.Show();
                        }



                        else
                        {
                            MessageBox.Show("Incorrect Id and password");
                        }
                    }


                    else
                    {
                        if (textBox1.Text == "" && textBox2.Text == "")
                        {
                            MessageBox.Show("Id & password both required");
                        }
                        if (textBox1.Text == "" && textBox2.Text != "")
                        {
                            MessageBox.Show("Id required");
                        }
                        if (textBox1.Text != "" && textBox2.Text == "")
                        {
                            MessageBox.Show("Password is required");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Select Login as from combobox...!!!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }