Esempio n. 1
0
        public Users_BS GetOneUser(string connString, string UN, string PW)
        {
            try
            {
                string query = @"select user_id_,password_,user_name_,status_ from users where user_name_=
                  '" + UN + "' and password_='" + PW + "' ";

                SqlConnection conn = DBHelper.GetConnection(connString);

                conn.Open();
                BusinessObjects.Users_BS pObj = new BusinessObjects.Users_BS();

                SqlDataReader reader = DBHelper.ReadData(query, conn);
                while (reader.Read())
                {
                    pObj.user_id_   = Convert.ToInt32(reader[0].ToString());
                    pObj.password_  = reader[1].ToString();
                    pObj.user_name_ = reader[2].ToString();

                    pObj.status_ = reader[3].ToString();
                }
                conn.Close();
                return(pObj);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public List <BusinessObjects.Users_BS> GetAll(string connString)
        {
            try
            {
                List <BusinessObjects.Users_BS> CatetList = new List <BusinessObjects.Users_BS>();
                string query = "select user_id_,password_,user_name_,status_ from users";

                SqlConnection conn = DBHelper.GetConnection(connString);

                conn.Open();

                SqlDataReader reader = DBHelper.ReadData(query, conn);
                while (reader.Read())
                {
                    BusinessObjects.Users_BS pObj = new BusinessObjects.Users_BS();
                    pObj.user_id_   = Convert.ToInt32(reader[0].ToString());
                    pObj.password_  = reader[1].ToString();
                    pObj.user_name_ = reader[2].ToString();

                    pObj.status_ = reader[3].ToString();

                    CatetList.Add(pObj);
                }
                conn.Close();
                return(CatetList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }