Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM Users WHERE Employee_ID = '" + textBox1.Text.Trim() + "' AND Password = '******'", con);
            SqlCommand     cmd = new SqlCommand("SELECT * FROM Users WHERE Employee_ID = '" + textBox1.Text.Trim() + "' AND Password = '******'", con);
            SqlDataReader  dr;
            DataTable      dt = new DataTable();

            try
            {
                con.Open();
                sda.Fill(dt);
                if (dt.Rows.Count == 1)
                {
                    dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        role = dr.GetValue(4).ToString().Trim();
                        name = dr.GetValue(1).ToString() + " " + dr.GetValue(2).ToString();
                        if (role == "Manage")
                        {
                            this.Hide();
                            Manage dlg1 = new Manage();
                            dlg1.Show();
                            dlg1.BringToFront();
                        }
                        else if (role == "Social")
                        {
                            this.Hide();
                            Social dlg = new Social();
                            dlg.Show();
                            dlg.BringToFront();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please make sure you have entered the correct information", "Invalid Details", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                con.Close();
            }
            catch (Exception er)
            {
                MessageBox.Show("Error!!", "" + er);
            }
        }