Пример #1
0
        public bool loginCheck(loginBLL l)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstring);

            try
            {
                string     sql = "SELECT * FROM tbl_users WHERE username=@username AND password=@password AND user_type=@user_type";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@username", l.username);
                cmd.Parameters.AddWithValue("@password", l.password);
                cmd.Parameters.AddWithValue("@user_type", l.user_type);

                SqlDataAdapter        adapter = new SqlDataAdapter(cmd);
                System.Data.DataTable dt      = new DataTable();
                adapter.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
            }
            return(isSuccess);
        }
Пример #2
0
        public DataTable   loginCheck(loginBLL l)
        {
            //Create a boolean variable and set its value to false and return it
            DataTable dt = new DataTable();
            //Connecting To DAtabase
            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                //SQL Query to check login
                string sql = "SELECT * FROM tbl_users WHERE username=@username AND password=@password AND user_type=@user_type";

                //Creating SQL Command to pass value
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@username", l.username);
                cmd.Parameters.AddWithValue("@password", l.password);
                cmd.Parameters.AddWithValue("@user_type", l.user_type);

                SqlDataAdapter adapter = new SqlDataAdapter(cmd);


                adapter.Fill(dt);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(dt);
        }
Пример #3
0
        public bool loginCheck(loginBLL l) //----Here login BLL is connnected through word l----//
        {
            // Create a boolean variable and set its value to false and return to it
            bool isSuccess = false;
            //Connecting to Database
            SqlConnection conn = new SqlConnection(myconnstring);

            try
            {
                //SQL Query to check login
                string sql =
                    "SELECT * FROM tbl_users WHERE username=@username AND password = @password AND user_type = @user_type";
                //Creating SQL command to Pass the value
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@username", l.username);
                cmd.Parameters.AddWithValue("@password", l.password);
                cmd.Parameters.AddWithValue("user_type", l.user_type);

                SqlDataAdapter adapter = new SqlDataAdapter(cmd);

                DataTable dt = new DataTable();

                adapter.Fill(dt);

                //Checking the rows in Datatable
                if (dt.Rows.Count > 0)
                {
                    //Login Successful
                    isSuccess = true;
                }
                else
                {
                    //Login Failed
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(isSuccess);
        }
Пример #4
0
        public bool loginCheck(loginBLL l)
        {
            // create a boolen variable and set it value to false and return it value;
            bool isSuccess = false;

            //Connecting to Database
            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                //SQL quary to check login
                string sql = "SELECT * FROM tbl_user WHERE username=@username AND password=@password AND user_type=@user_type";

                // create SQL command to pass value
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@username", l.username);
                cmd.Parameters.AddWithValue("@password", l.password);
                cmd.Parameters.AddWithValue("@user_type", l.user_type);

                SqlDataAdapter adapter = new SqlDataAdapter(cmd);

                DataTable dt = new DataTable();

                adapter.Fill(dt);

                // checking the row in the Table
                if (dt.Rows.Count > 0)
                {
                    // Login successful
                    isSuccess = true;
                }
                else
                {
                    // Login Fail
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
Пример #5
0
        public bool loginCheck(loginBLL l)
        {
            //Create a boolean and set its value to false and retrunt it

            bool isSuccess = false;

            //Connection to Database
            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                //SQL Query to check login
                string sql = "select *from tbl_users where username=@username AND password=@password AND user_type=@user_type";

                //Creatng Command to pass value
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@username", l.username);
                cmd.Parameters.AddWithValue("@password", l.password);
                cmd.Parameters.AddWithValue("@user_type", l.user_type);

                SqlDataAdapter adapter = new SqlDataAdapter(cmd);

                DataTable dt = new DataTable();
                adapter.Fill(dt);
                //Checkng the rows in DataTable
                if (dt.Rows.Count > 0)
                {
                    //Login Successfully
                    isSuccess = true;
                }
                else
                {
                    //login Failed
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
Пример #6
0
        // we will write a method to check our login
        public bool loginCheck(loginBLL l)
        {
            // Step 2: create a boolean variable and set its value to false and return it
            bool isSuccess = false;

            // we need to connect to database
            // Step 3: Static Method to connect Database

            SqlConnection conn = new SqlConnection(myconnstring);

            // Step 4: we will add try catch block to check login

            try
            {
                // Step 5:here we will add query to check login

                string sql = "SELECT * FROM tbl_users WHERE username=@username AND password=@password AND user_type=@user_type";

                // Step 6 : For Executing Command , we will create SQL Command to pass values
                SqlCommand cmd = new SqlCommand(sql, conn);

                // Step 7: set the parameters , same a step5 entries
                cmd.Parameters.AddWithValue("@username", l.username);
                cmd.Parameters.AddWithValue("@password", l.password);
                cmd.Parameters.AddWithValue("@user_type", l.user_type);

                //  Step 8: Getting Data from Database
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);

                // Step 9: we will create a data table to hold temporary data
                DataTable dt = new DataTable();

                // Step 10: Fill Data in our Data Table
                adapter.Fill(dt);

                //Step 11: checking the rows in Data Table

                if (dt.Rows.Count > 0)
                {
                    // login Successful
                    isSuccess = true;
                }
                else
                {
                    // not Successful
                    isSuccess = false;
                }
            }

            catch (Exception ex)
            {
                // Throw Message if any error occurs
                MessageBox.Show(ex.Message);
            }

            finally
            {
                // Close connection
                conn.Close();
            }
            return(isSuccess);
        }