Example #1
0
        private void backBtn_Click(object sender, EventArgs e)
        {
            this.Hide();
            DashBoard dsf = new DashBoard();

            dsf.Show();
        }
Example #2
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            /*=====SQL server connection*/
            SqlConnection con = new SqlConnection("Data Source=SHAMIM-PC\\MSSQLSERVER1;Initial Catalog=GMSDB;Integrated Security=True");

            if (userNameTxt.Text == "" || passwordTxt.Text == "")
            {
                MessageBox.Show("Failed ! Fill up all Mendatory");
            }
            else
            {
                try
                {
                    SqlCommand     cmd      = new SqlCommand();
                    string         role     = roleCombo.SelectedItem.ToString();
                    string         username = userNameTxt.Text.ToString();
                    string         pass     = passwordTxt.Text.ToString();
                    string         qry      = "Select Username, Password, Role from UserInfo where Username='******' and  Password='******' and Role='" + role + "'";
                    SqlDataAdapter sda      = new SqlDataAdapter(qry, con);
                    DataTable      dt       = new DataTable();
                    sda.Fill(dt);
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (dt.Rows[i]["Role"].ToString() == role)
                            {
                                MessageBox.Show("You are Log in as " + dt.Rows[i][2]);
                                if (roleCombo.SelectedIndex == 1)
                                {
                                    MainForm f = new MainForm();
                                    f.Show();
                                    this.Hide();
                                }
                                else
                                {
                                    DashBoard p = new DashBoard();
                                    p.Show();
                                    this.Hide();
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalied User Login ! Try again.");
                    }
                }

                catch (Exception exp)
                {
                    MessageBox.Show(exp.Message);
                }
            }
        }