public List <shoppingcartDAO> GetAllShoppingCarts()
        {
            List <shoppingcartDAO> _cartList = new List <shoppingcartDAO>();

            try
            {
                using (SqlConnection _connection = new SqlConnection(connectionstring))
                {
                    using (SqlCommand _command = new SqlCommand("Sp_ViewAllShoppingCarts", _connection))
                    {
                        _command.CommandType = CommandType.StoredProcedure;
                        _connection.Open();
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            while (_reader.Read())
                            {
                                shoppingcartDAO _cartToList = new shoppingcartDAO();
                                _cartToList.ShoppingCart_ID = _reader.GetInt32(0);
                                _cartToList.Albums_ID       = _reader.GetInt32(1);
                                _cartToList.Clothing_ID     = _reader.GetInt32(2);
                                _cartToList.Instruments_ID  = _reader.GetInt32(3);
                                _cartToList.User_ID         = _reader.GetInt32(4);
                                _cartList.Add(_cartToList);
                            }
                        }
                    }
                }
            }
            catch (Exception _Error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(_Error);
            }
            return(_cartList);
        }
        public List <shoppingcartDAO> GetPrices()
        {
            List <shoppingcartDAO> _ListPrices = new List <shoppingcartDAO>();

            try
            {
                using (SqlConnection _connection = new SqlConnection(connectionstring))
                {
                    using (SqlCommand _command = new SqlCommand("Sp_PricePull", _connection))
                    {
                        _command.CommandType = CommandType.StoredProcedure;
                        _connection.Open();
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            while (_reader.Read())
                            {
                                shoppingcartDAO _PriceToList = new shoppingcartDAO();
                                _PriceToList.AlbumPrice       = _reader.GetDecimal(0);
                                _PriceToList.ClothingPrice    = _reader.GetDecimal(1);
                                _PriceToList.InstrumentsPrice = _reader.GetDecimal(2);
                                _ListPrices.Add(_PriceToList);
                            }
                        }
                    }
                }
            }
            catch (Exception _Error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(_Error);
            }
            return(_ListPrices);
        }
 public void CreateMember(bandmembersDAO memberToCreate)
 {
     try
     {
         using (SqlConnection _connection = new SqlConnection(connectionstring))
         {
             using (SqlCommand _command = new SqlCommand("Sp_CreateBandMembers", _connection))
             {
                 _command.CommandType = CommandType.StoredProcedure;
                 _command.Parameters.AddWithValue("@Name", memberToCreate.MemberName);
                 _command.Parameters.AddWithValue("@Bio", memberToCreate.MemberBio);
                 _command.Parameters.AddWithValue("@DateOfBirth", memberToCreate.DateOfBirth);
                 _command.Parameters.AddWithValue("@BirthLocation", memberToCreate.BirthLocation);
                 _connection.Open();
                 _command.ExecuteNonQuery();
                 _connection.Close();
                 _connection.Dispose();
             }
         }
     }
     catch (Exception _Error)
     {
         Error_Logger Log = new Error_Logger();
         Log.Errorlogger(_Error);
     }
 }
 public void CreateAlbum(albumDAO albumToCreate)
 {
     try
     {
         using (SqlConnection _connection = new SqlConnection(connectionstring))
         {
             using (SqlCommand _command = new SqlCommand("Sp_CreateAlbum", _connection))
             {
                 _command.CommandType = CommandType.StoredProcedure;
                 _command.Parameters.AddWithValue("@Name", albumToCreate.AlbumName);
                 _command.Parameters.AddWithValue("@Description", albumToCreate.AlbumDescription);
                 _command.Parameters.AddWithValue("@Price", albumToCreate.AlbumPrice);
                 _command.Parameters.AddWithValue("@YearReleased", albumToCreate.YearReleased);
                 _command.Parameters.AddWithValue("@NumberOfSongs", albumToCreate.NumberOfSongs);
                 _command.Parameters.AddWithValue("@AlbumQuantity", albumToCreate.AlbumQuantity);
                 _connection.Open();
                 _command.ExecuteNonQuery();
                 _connection.Close();
                 _connection.Dispose();
             }
         }
     }
     catch (Exception _Error)
     {
         Error_Logger Log = new Error_Logger();
         Log.Errorlogger(_Error);
     }
 }
 public void CreateShoppingCart(shoppingcartDAO shoppingcartToCreate)
 {
     try
     {
         using (SqlConnection _connection = new SqlConnection(connectionstring))
         {
             using (SqlCommand _command = new SqlCommand("Sp_CreateShoppingCart", _connection))
             {
                 _command.CommandType = CommandType.StoredProcedure;
                 _command.Parameters.AddWithValue("@Albums_ID", shoppingcartToCreate.Albums_ID);
                 _command.Parameters.AddWithValue("@Clothing_ID", shoppingcartToCreate.Clothing_ID);
                 _command.Parameters.AddWithValue("@Instruments_ID", shoppingcartToCreate.Instruments_ID);
                 _command.Parameters.AddWithValue("@User_ID", shoppingcartToCreate.User_ID);
                 _connection.Open();
                 _command.ExecuteNonQuery();
                 _connection.Close();
                 _connection.Dispose();
             }
         }
     }
     catch (Exception _Error)
     {
         Error_Logger Log = new Error_Logger();
         Log.Errorlogger(_Error);
     }
 }
Example #6
0
 public void Createuser(userDAO userToCreate)
 {
     try
     {
         using (SqlConnection _connection = new SqlConnection(connectionstring))
         {
             using (SqlCommand _command = new SqlCommand("Sp_CreateUser", _connection))
             {
                 _command.CommandType = CommandType.StoredProcedure;
                 _command.Parameters.AddWithValue("@Username", userToCreate.Username);
                 _command.Parameters.AddWithValue("@Password", userToCreate.Password);
                 _command.Parameters.AddWithValue("@Role_ID", userToCreate.Role_ID);
                 _connection.Open();
                 _command.ExecuteNonQuery();
                 _connection.Close();
                 _connection.Dispose();
             }
         }
     }
     catch (Exception _Error)
     {
         Error_Logger Log = new Error_Logger();
         Log.Errorlogger(_Error);
     }
 }
Example #7
0
        public List <userDAO> GetAllUsers()
        {
            List <userDAO> _userlist = new List <userDAO>();

            try
            {
                using (SqlConnection _connection = new SqlConnection(connectionstring))
                {
                    using (SqlCommand _command = new SqlCommand("Sp_ViewUsers", _connection))
                    {
                        _command.CommandType = CommandType.StoredProcedure;
                        _connection.Open();
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            while (_reader.Read())
                            {
                                userDAO _userToList = new userDAO();
                                _userToList.User_ID  = _reader.GetInt32(0);
                                _userToList.Username = _reader.GetString(1);
                                _userToList.Password = _reader.GetString(2);
                                _userToList.Role_ID  = _reader.GetInt32(3);
                                _userlist.Add(_userToList);
                            }
                        }
                    }
                }
            }
            catch (Exception _Error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(_Error);
            }
            return(_userlist);
        }
        public List <instrumentsDAO> GetAllInstruments()
        {
            List <instrumentsDAO> _instrumentslist = new List <instrumentsDAO>();

            try
            {
                using (SqlConnection _connection = new SqlConnection(connectionstring))
                {
                    using (SqlCommand _command = new SqlCommand("Sp_ViewInstruments", _connection))
                    {
                        _command.CommandType = CommandType.StoredProcedure;
                        _connection.Open();
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            while (_reader.Read())
                            {
                                instrumentsDAO _instrumentsToList = new instrumentsDAO();
                                _instrumentsToList.Instruments_ID        = _reader.GetInt32(0);
                                _instrumentsToList.InstrumentName        = _reader.GetString(1);
                                _instrumentsToList.InstrumentDescription = _reader.GetString(2);
                                _instrumentsToList.InstrumentPrice       = _reader.GetDecimal(3);
                                _instrumentsToList.InstrumentsQuantity   = _reader.GetInt32(4);
                                _instrumentslist.Add(_instrumentsToList);
                            }
                        }
                    }
                }
            }
            catch (Exception _Error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(_Error);
            }
            return(_instrumentslist);
        }
 public void CreateInstruments(instrumentsDAO instrumentsToCreate)
 {
     try
     {
         using (SqlConnection _connection = new SqlConnection(connectionstring))
         {
             using (SqlCommand _command = new SqlCommand("Sp_CreateInstrument", _connection))
             {
                 _command.CommandType = CommandType.StoredProcedure;
                 _command.Parameters.AddWithValue("@Name", instrumentsToCreate.InstrumentName);
                 _command.Parameters.AddWithValue("@Description", instrumentsToCreate.InstrumentDescription);
                 _command.Parameters.AddWithValue("@Price", instrumentsToCreate.InstrumentPrice);
                 _command.Parameters.AddWithValue("@InstrumentsQuantity", instrumentsToCreate.InstrumentsQuantity);
                 _connection.Open();
                 _command.ExecuteNonQuery();
                 _connection.Close();
                 _connection.Dispose();
             }
         }
     }
     catch (Exception _Error)
     {
         Error_Logger Log = new Error_Logger();
         Log.Errorlogger(_Error);
     }
 }
 public void CreateClothing(clothingDAO clothingToCreate)
 {
     try
     {
         using (SqlConnection _connection = new SqlConnection(connectionstring))
         {
             using (SqlCommand _command = new SqlCommand("Sp_CreateClothing", _connection))
             {
                 _command.CommandType = CommandType.StoredProcedure;
                 _command.Parameters.AddWithValue("@TypeOFClothing", clothingToCreate.TypeOFClothing);
                 _command.Parameters.AddWithValue("@Description", clothingToCreate.ClothingDescription);
                 _command.Parameters.AddWithValue("@Sizes", clothingToCreate.Sizes);
                 _command.Parameters.AddWithValue("@Price", clothingToCreate.ClothingPrice);
                 _command.Parameters.AddWithValue("@Name", clothingToCreate.ClothingName);
                 _command.Parameters.AddWithValue("@ClothingQuantity", clothingToCreate.ClothingQuantity);
                 _connection.Open();
                 _command.ExecuteNonQuery();
                 _connection.Close();
                 _connection.Dispose();
             }
         }
     }
     catch (Exception _Error)
     {
         Error_Logger Log = new Error_Logger();
         Log.Errorlogger(_Error);
     }
 }
        public void SendInstrumentID(shoppingcartDAO instrumentidToSend)
        {
            int SendInstrumentID = new int();

            try
            {
                using (SqlConnection _connection = new SqlConnection(connectionstring))
                {
                    using (SqlCommand _command = new SqlCommand("Sp_SendInstrumentID", _connection))
                    {
                        _command.CommandType = CommandType.StoredProcedure;
                        _command.Parameters.AddWithValue("@Instruments_ID", instrumentidToSend.Instruments_ID);
                        _command.Parameters.AddWithValue("@User_ID", instrumentidToSend.User_ID);
                        _connection.Open();
                        _command.ExecuteNonQuery();
                        _connection.Close();
                    }
                }
            }
            catch (Exception _Error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(_Error);
            }
        }
Example #12
0
        public void createShirt(ShirtsDAO shirtToCreate)
        {
            try
            {
                //This is creating a connection to the database
                using (SqlConnection _connection = new SqlConnection(connectionString))
                {
                    //This specifies what type of command
                    using (SqlCommand _command = new SqlCommand("SP_Shirt_Create", _connection))
                    {
                        //This specifies what type of command is being used
                        _command.CommandType = CommandType.StoredProcedure;
                        //Here is where the Values will be passed to the command
                        _command.Parameters.AddWithValue("@Size", shirtToCreate.Size);
                        _command.Parameters.AddWithValue("@Color", shirtToCreate.Color);
                        _command.Parameters.AddWithValue("@ShirtPrice", shirtToCreate.ShirtPrice);
                        //Here is where the connection is opened
                        _connection.Open();
                        //This will excute the command
                        _command.ExecuteNonQuery();

                        _connection.Close();
                    }
                }
            }
            catch (Exception error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(error);
            }
        }
        public void GetClothingID(shoppingcartDAO clothingidToGet)
        {
            int GetClothingID = new int();

            try
            {
                using (SqlConnection _connection = new SqlConnection(connectionstring))
                {
                    using (SqlCommand _command = new SqlCommand("Sp_GetClothingID", _connection))
                    {
                        _command.CommandType = CommandType.StoredProcedure;
                        _command.Parameters.AddWithValue("@Clothing_ID", clothingidToGet.Clothing_ID);
                        _command.Parameters.AddWithValue("@User_ID", clothingidToGet.User_ID);
                        _connection.Open();
                        _command.ExecuteNonQuery();
                        _connection.Close();
                    }
                }
            }
            catch (Exception _Error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(_Error);
            }
        }
        public bool DeleteMember(bandmembersDAO memberToDelete)
        {
            bool yes = false;

            try
            {
                using (SqlConnection _connection = new SqlConnection(connectionstring))
                {
                    using (SqlCommand _command = new SqlCommand("Sp_DeleteBandMember", _connection))
                    {
                        _command.CommandType = CommandType.StoredProcedure;
                        _command.Parameters.AddWithValue("@BandMembers_ID", memberToDelete.BandMembers_ID);
                        _connection.Open();
                        _command.ExecuteNonQuery();
                        yes = true;
                        _connection.Close();
                    }
                }
            }
            catch (Exception _Error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(_Error);
            }
            if (yes == true)
            {
            }
            return(yes);
        }
        public List <bandmembersDAO> GetAllMembers()
        {
            List <bandmembersDAO> _MemberList = new List <bandmembersDAO>();

            try
            {
                using (SqlConnection _connection = new SqlConnection(connectionstring))
                {
                    using (SqlCommand _command = new SqlCommand("Sp_ViewBandMembers", _connection))
                    {
                        _command.CommandType = CommandType.StoredProcedure;
                        _connection.Open();
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            while (_reader.Read())
                            {
                                bandmembersDAO _memberToList = new bandmembersDAO();
                                _memberToList.BandMembers_ID = _reader.GetInt32(0);
                                _memberToList.MemberName     = _reader.GetString(1);
                                _memberToList.MemberBio      = _reader.GetString(2);
                                _memberToList.DateOfBirth    = _reader.GetDateTime(3);
                                _memberToList.BirthLocation  = _reader.GetString(4);
                                _MemberList.Add(_memberToList);
                            }
                        }
                    }
                }
            }
            catch (Exception _Error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(_Error);
            }
            return(_MemberList);
        }
Example #16
0
 public userDAO CreateShoppingCartOnRegister1(userDAO shoppingCartFromRegister1)
 {
     try
     {
         using (SqlConnection _connection = new SqlConnection(connectionstring))
         {
             using (SqlCommand _command = new SqlCommand("Sp_CreateCartOnRegisterPart1", _connection))
             {
                 _command.CommandType = CommandType.StoredProcedure;
                 _command.Parameters.AddWithValue("Username", shoppingCartFromRegister1.Username);
                 using (SqlDataReader _reader = _command.ExecuteReader())
                 {
                     while (_reader.Read())
                     {
                         userDAO _dataToRead = new userDAO();
                         _dataToRead.User_ID       = _reader.GetInt32(0);
                         _dataToRead.Username      = _reader.GetString(1);
                         _dataToRead.Password      = _reader.GetString(2);
                         _dataToRead.Role_ID       = _reader.GetInt32(3);
                         shoppingCartFromRegister1 = _dataToRead;
                     }
                 }
             }
         }
     }
     catch (Exception _Error)
     {
         Error_Logger Log = new Error_Logger();
         Log.Errorlogger(_Error);
     }
     return(shoppingCartFromRegister1);
 }
Example #17
0
        public bool deleteUser(UsersDAO userToDelete)
        {
            bool yes = false;

            try
            {
                //This is creating a connection to the database
                using (SqlConnection _connection = new SqlConnection(connectionString))
                {
                    //This specifies what type of command
                    using (SqlCommand _command = new SqlCommand("SP_User_Delete", _connection))
                    {
                        //This specifies what type of command is being used
                        _command.CommandType = CommandType.StoredProcedure;
                        //Here is where the Values will be passed to the command
                        _command.Parameters.AddWithValue("@UserID", userToDelete.UserID);
                        //Here is where the connection is opened
                        _connection.Open();
                        //This will excute the command
                        _command.ExecuteNonQuery();
                        yes = true;
                        _connection.Close();
                    }
                }
            }
            catch (Exception error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(error);
            }
            if (yes == true)
            {
            }
            return(yes);
        }
Example #18
0
        public void UpdateCart(CartDAO cartToUpdate)
        {
            try
            {
                //This is creating a connection to the database


                //This specifies what type of command
                using (SqlConnection _connection = new SqlConnection(connectionString))
                    using (SqlCommand _command = new SqlCommand("SP_Cart_Update", _connection))
                    {
                        //This specifies what type of command is being used
                        _command.CommandType = CommandType.StoredProcedure;
                        //Here is where the Values will be passed to the command
                        _command.Parameters.AddWithValue("@CartID", cartToUpdate.CartID);
                        _command.Parameters.AddWithValue("@PantsID", cartToUpdate.PantsID);
                        _command.Parameters.AddWithValue("@ShirtsID", cartToUpdate.ShirtsID);
                        _command.Parameters.AddWithValue("@UserID", cartToUpdate.UserID);
                        _command.Parameters.AddWithValue("@ShirtQuanity", cartToUpdate.ShirtQuanity);
                        _command.Parameters.AddWithValue("@PantQuanity", cartToUpdate.PantQuanity);
                        _command.Parameters.AddWithValue("@TotalPrice", cartToUpdate.TotalPrice);
                        _command.Parameters.AddWithValue("@ShirtPrice", cartToUpdate.ShirtPrice);
                        _command.Parameters.AddWithValue("@PantPrice", cartToUpdate.PantPrice);

                        //Here is where the connection is opened
                        _connection.Open();
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            while (_reader.Read())
                            {
                                cartToUpdate.CartID       = _reader.GetInt32(0);
                                cartToUpdate.PantsID      = _reader.GetInt32(1);
                                cartToUpdate.ShirtsID     = _reader.GetInt32(2);
                                cartToUpdate.UserID       = _reader.GetInt32(3);
                                cartToUpdate.ShirtQuanity = _reader.GetInt32(4);
                                cartToUpdate.PantQuanity  = _reader.GetInt32(5);
                                cartToUpdate.TotalPrice   = _reader.GetInt32(6);
                                cartToUpdate.ShirtPrice   = _reader.GetInt32(7);
                                cartToUpdate.PantPrice    = _reader.GetInt32(8);
                            }
                            _connection.Close();
                        }

                        //This will excute the command
                        _command.ExecuteNonQuery();
                        _connection.Close();
                    }
            }
            catch (Exception error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(error);
            }
        }
Example #19
0
        public void UpdateUser(UsersDAO userToUpdate)
        {
            try
            {
                //This is creating a connection to the database


                //This specifies what type of command
                using (SqlConnection _connection = new SqlConnection(connectionString))
                    using (SqlCommand _command = new SqlCommand("SP_User_Update", _connection))
                    {
                        //This specifies what type of command is being used
                        _command.CommandType = CommandType.StoredProcedure;
                        //Here is where the Values will be passed to the command
                        _command.Parameters.AddWithValue("@UserID", userToUpdate.UserID);
                        _command.Parameters.AddWithValue("@Firstname", userToUpdate.Firstname);
                        _command.Parameters.AddWithValue("@Lastname", userToUpdate.Lastname);
                        _command.Parameters.AddWithValue("@Address", userToUpdate.Address);
                        _command.Parameters.AddWithValue("@Zipcode", userToUpdate.Zipcode);
                        _command.Parameters.AddWithValue("@Phonenumber", userToUpdate.Phonenumber);
                        _command.Parameters.AddWithValue("@Username", userToUpdate.Username);
                        _command.Parameters.AddWithValue("@RoleID", userToUpdate.RoleID);

                        //Here is where the connection is opened
                        _connection.Open();
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            while (_reader.Read())
                            {
                                userToUpdate.UserID      = _reader.GetInt32(0);
                                userToUpdate.Firstname   = _reader.GetString(1);
                                userToUpdate.Lastname    = _reader.GetString(2);
                                userToUpdate.Address     = _reader.GetString(3);
                                userToUpdate.Zipcode     = _reader.GetInt32(4);
                                userToUpdate.Phonenumber = _reader.GetString(5);
                                userToUpdate.Username    = _reader.GetString(6);
                                userToUpdate.RoleID      = _reader.GetInt32(7);
                            }
                            _connection.Close();
                        }

                        //This will excute the command
                        _command.ExecuteNonQuery();
                        _connection.Close();
                    }
            }
            catch (Exception error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(error);
            }
        }
Example #20
0
        public List <CartDAO> GetAllCarts()

        {//Create a method that will get all my Books and place them in a list named _booklist
            List <CartDAO> _cartlist = new List <CartDAO>();


            try
            {
                //Establishing the connection for the database
                using (SqlConnection _connection = new SqlConnection(connectionString))
                {
                    using (SqlCommand _command = new SqlCommand("SP_CartView", _connection))
                    {
                        //Establishing the command to pass to the database
                        //and defining the command
                        _command.CommandType = CommandType.StoredProcedure;
                        //connect to the database
                        _connection.Open();
                        //Open the sql data reader
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            //Loop through the data sets or command and write each element
                            //to the _bookToList using the book object
                            while (_reader.Read())
                            {
                                CartDAO _cartToList = new CartDAO();
                                _cartToList.CartID       = _reader.GetInt32(0);
                                _cartToList.PantsID      = _reader.GetInt32(1);
                                _cartToList.ShirtsID     = _reader.GetInt32(2);
                                _cartToList.UserID       = _reader.GetInt32(3);
                                _cartToList.ShirtQuanity = _reader.GetInt32(4);
                                _cartToList.PantQuanity  = _reader.GetInt32(5);
                                _cartToList.PantPrice    = _reader.GetInt32(6);
                                _cartToList.ShirtPrice   = _reader.GetInt32(7);
                                _cartToList.TotalPrice   = _reader.GetInt32(8);

                                _cartlist.Add(_cartToList);
                            }
                        }
                    }
                }
            }

            catch (Exception error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(error);
            }
            return(_cartlist);
        }
Example #21
0
        public List <UsersDAO> GetAllUsers()
        {//Create a method that will get all my Books and place them in a list named _booklist
            List <UsersDAO> _userlist = new List <UsersDAO>();


            try
            {
                //Establishing the connection for the database
                using (SqlConnection _connection = new SqlConnection(connectionString))
                {
                    using (SqlCommand _command = new SqlCommand("SP_User_Read", _connection))
                    {
                        //Establishing the command to pass to the database
                        //and defining the command
                        _command.CommandType = CommandType.StoredProcedure;
                        //connect to the database
                        _connection.Open();
                        //Open the sql data reader
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            //Loop through the data sets or command and write each element
                            //to the _bookToList using the book object
                            while (_reader.Read())
                            {
                                UsersDAO _userToList = new UsersDAO();
                                _userToList.Firstname   = _reader.GetString(0);
                                _userToList.Lastname    = _reader.GetString(1);
                                _userToList.Address     = _reader.GetString(2);
                                _userToList.Zipcode     = _reader.GetInt32(3);
                                _userToList.Phonenumber = _reader.GetString(4);
                                _userToList.Password    = _reader.GetString(5);
                                _userToList.Username    = _reader.GetString(6);
                                _userToList.UserID      = _reader.GetInt32(7);
                                _userToList.RoleID      = _reader.GetInt32(8);
                                _userlist.Add(_userToList);
                            }
                        }
                    }
                }
            }

            catch (Exception error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(error);
            }
            return(_userlist);
        }
Example #22
0
        public CartDAO _createCart(CartDAO _cartCreate)
        {
            CartDAO _createCart = new CartDAO();

            try
            {
                using (SqlConnection _connection = new SqlConnection(connectionString))
                {
                    using (SqlCommand _command = new SqlCommand("SP_Cart_Create", _connection))
                    {
                        _command.CommandType = CommandType.StoredProcedure;
                        _command.Parameters.AddWithValue("@CartID", _cartCreate.CartID);
                        _command.Parameters.AddWithValue("@PantsID", _cartCreate.PantsID);
                        _command.Parameters.AddWithValue("@ShirtsID", _cartCreate.ShirtsID);
                        _command.Parameters.AddWithValue("@UserID", _cartCreate.UserID);
                        _command.Parameters.AddWithValue("@ShirtQuanity", _cartCreate.ShirtQuanity);
                        _command.Parameters.AddWithValue("@PantQuanity", _cartCreate.PantQuanity);
                        _command.Parameters.AddWithValue("@TotalPrice", _cartCreate.TotalPrice);
                        _command.Parameters.AddWithValue("@ShirtPrice", _cartCreate.ShirtPrice);
                        _command.Parameters.AddWithValue("@PantPrice", _cartCreate.PantPrice);
                        _connection.Open();
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            while (_reader.Read())
                            {
                                _createCart.CartID       = _reader.GetInt32(0);
                                _createCart.PantsID      = _reader.GetInt32(1);
                                _createCart.ShirtsID     = _reader.GetInt32(2);
                                _createCart.UserID       = _reader.GetInt32(3);
                                _createCart.ShirtQuanity = _reader.GetInt32(4);
                                _createCart.PantQuanity  = _reader.GetInt32(5);
                                _createCart.TotalPrice   = _reader.GetInt32(6);
                                _createCart.ShirtPrice   = _reader.GetInt32(6);
                                _createCart.PantPrice    = _reader.GetInt32(6);
                            }
                            _connection.Close();
                        }
                    }
                }
            }
            catch (Exception error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(error);
            }
            return(_createCart);
        }
Example #23
0
        public CartDAO GetCartById(int CartID)

        {//Create a method that will get all my Books and place them in a list named _booklist
            CartDAO _cartReturn = new CartDAO();

            try
            {
                //Establishing the connection for the database
                using (SqlConnection _connection = new SqlConnection(connectionString))
                {
                    using (SqlCommand _command = new SqlCommand("SP_Get_Cart_By_CartID", _connection))
                    {
                        //Establishing the command to pass to the database
                        //and defining the command
                        _command.CommandType = CommandType.StoredProcedure;
                        _command.Parameters.AddWithValue("@CartID", CartID);
                        //connect to the database
                        _connection.Open();
                        //Open the sql data reader
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            //Loop through the data sets or command and write each element
                            //to the _bookToList using the book object
                            while (_reader.Read())
                            {
                                _cartReturn.CartID       = _reader.GetInt32(0);
                                _cartReturn.PantsID      = _reader.GetInt32(1);
                                _cartReturn.ShirtsID     = _reader.GetInt32(2);
                                _cartReturn.UserID       = _reader.GetInt32(3);
                                _cartReturn.ShirtQuanity = _reader.GetInt32(4);
                                _cartReturn.PantQuanity  = _reader.GetInt32(4);
                                _cartReturn.TotalPrice   = _reader.GetInt32(5);
                                _cartReturn.ShirtPrice   = _reader.GetInt32(5);
                                _cartReturn.PantPrice    = _reader.GetInt32(5);
                            }
                        }
                    }
                }
            }
            catch (Exception error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(error);
            }
            return(_cartReturn);
        }
Example #24
0
        public UsersDAO GetUserByID(int userID)
        {//Create a method that will get all my Books and place them in a list named _booklist
            UsersDAO _userReturn = new UsersDAO();


            try
            {
                //Establishing the connection for the database
                using (SqlConnection _connection = new SqlConnection(connectionString))
                {
                    using (SqlCommand _command = new SqlCommand("SP_Get_User_By_UserID", _connection))
                    {
                        //Establishing the command to pass to the database
                        //and defining the command
                        _command.CommandType = CommandType.StoredProcedure;
                        _command.Parameters.AddWithValue("@UserID", userID);
                        //connect to the database
                        _connection.Open();
                        //Open the sql data reader
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            //Loop through the data sets or command and write each element
                            //to the _bookToList using the book object
                            while (_reader.Read())
                            {
                                _userReturn.UserID      = _reader.GetInt32(0);
                                _userReturn.Firstname   = _reader.GetString(1);
                                _userReturn.Lastname    = _reader.GetString(2);
                                _userReturn.Address     = _reader.GetString(3);
                                _userReturn.Zipcode     = _reader.GetInt32(4);
                                _userReturn.Phonenumber = _reader.GetString(5);
                                _userReturn.Username    = _reader.GetString(6);
                                _userReturn.RoleID      = _reader.GetInt32(7);
                            }
                        }
                    }
                }
            }

            catch (Exception error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(error);
            }
            return(_userReturn);
        }
Example #25
0
        public PantsDAO createPant(PantsDAO pantToCreate)
        {
            PantsDAO createPant = new PantsDAO();

            try
            {
                //This is creating a connection to the database
                using (SqlConnection _connection = new SqlConnection(connectionString))
                {
                    //This specifies what type of command
                    using (SqlCommand _command = new SqlCommand("SP_Pant_Create", _connection))
                    {
                        //This specifies what type of command is being used
                        _command.CommandType = CommandType.StoredProcedure;
                        //Here is where the Values will be passed to the command
                        _command.Parameters.AddWithValue("@Size", pantToCreate.Size);
                        _command.Parameters.AddWithValue("@Color", pantToCreate.Color);
                        _command.Parameters.AddWithValue("@PantPrice", pantToCreate.PantPrice);
                        //Here is where the connection is opened
                        _connection.Open();
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            while (_reader.Read())
                            {
                                pantToCreate.Size      = _reader.GetInt32(1);
                                pantToCreate.Color     = _reader.GetString(2);
                                pantToCreate.PantPrice = _reader.GetInt32(3);
                            }
                            //This will excute the command
                            _command.ExecuteNonQuery();

                            _connection.Close();
                        }
                    }
                }
            }
            catch (Exception error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(error);
            }
            return(pantToCreate);
        }
Example #26
0
        public UsersDAO _createUser(UsersDAO _userCreate)
        {
            UsersDAO _createUser = new UsersDAO();

            try
            {
                using (SqlConnection _connection = new SqlConnection(connectionString))
                {
                    using (SqlCommand _command = new SqlCommand("SP_User_Create1", _connection))
                    {
                        _command.CommandType = CommandType.StoredProcedure;
                        _command.Parameters.AddWithValue("@Firstname", _userCreate.Firstname);
                        _command.Parameters.AddWithValue("@Lastname", _userCreate.Lastname);
                        _command.Parameters.AddWithValue("@Address", _userCreate.Address);
                        _command.Parameters.AddWithValue("@Zipcode", _userCreate.Zipcode);
                        _command.Parameters.AddWithValue("@Phonenumber", _userCreate.Phonenumber);
                        _command.Parameters.AddWithValue("@Password", _userCreate.Password);
                        _command.Parameters.AddWithValue("@Username", _userCreate.Username);
                        _connection.Open();
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            while (_reader.Read())
                            {
                                _createUser.Firstname   = _reader.GetString(2);
                                _createUser.Lastname    = _reader.GetString(3);
                                _createUser.Address     = _reader.GetString(6);
                                _createUser.Zipcode     = _reader.GetInt32(9);
                                _createUser.Phonenumber = _reader.GetString(7);
                                _createUser.Password    = _reader.GetString(1);
                                _createUser.Username    = _reader.GetString(0);
                            }
                            _connection.Close();
                        }
                    }
                }
            }
            catch (Exception error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(error);
            }
            return(_createUser);
        }
Example #27
0
        public List <RoleDAO> GetAllRoles()
        {//Create a method that will get all my Books and place them in a list named _booklist
            List <RoleDAO> _rolelist = new List <RoleDAO>();


            try
            {
                //Establishing the connection for the database
                using (SqlConnection _connection = new SqlConnection(connectionString))
                {
                    using (SqlCommand _command = new SqlCommand("SP_Role_View", _connection))
                    {
                        //Establishing the command to pass to the database
                        //and defining the command
                        _command.CommandType = CommandType.StoredProcedure;
                        //connect to the database
                        _connection.Open();
                        //Open the sql data reader
                        using (SqlDataReader _reader = _command.ExecuteReader())
                        {
                            //Loop through the data sets or command and write each element
                            //to the _bookToList using the book object
                            while (_reader.Read())
                            {
                                RoleDAO _roleToList = new RoleDAO();
                                _roleToList.RoleID   = _reader.GetInt32(0);
                                _roleToList.Descript = _reader.GetString(1);
                                _rolelist.Add(_roleToList);
                            }
                        }
                    }
                }
            }

            catch (Exception error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(error);
            }
            return(_rolelist);
        }
 public void CreateShoppingCartOnRegister2(shoppingcartDAO shoppingCartFromRegister2)
 {
     try
     {
         using (SqlConnection _connection = new SqlConnection(connectionstring))
         {
             using (SqlCommand _command = new SqlCommand("Sp_CreateCartOnRegisterPart2", _connection))
             {
                 _command.CommandType = CommandType.StoredProcedure;
                 _command.Parameters.AddWithValue("@User_ID", shoppingCartFromRegister2.User_ID);
                 _connection.Open();
                 _command.ExecuteNonQuery();
                 _connection.Close();
                 _connection.Dispose();
             }
         }
     }
     catch (Exception _Error)
     {
         Error_Logger Log = new Error_Logger();
         Log.Errorlogger(_Error);
     }
 }
Example #29
0
        // This is the method used to delete a book
        public bool deleteShirt(ShirtsDAO shirtToDelete)
        {
            bool yes = false;

            try
            {
                //This is creating a connection to the database
                using (SqlConnection _connection = new SqlConnection(connectionString))
                {
                    //This specifies what type of command
                    using (SqlCommand _command = new SqlCommand("SP_Shirt_Delete", _connection))
                    {
                        //This specifies what type of command is being used
                        _command.CommandType = CommandType.StoredProcedure;
                        //Here is where the Values will be passed to the command
                        _command.Parameters.AddWithValue("@ShirtsID", shirtToDelete.ShirtsID);
                        //Here is where the connection is opened
                        _connection.Open();
                        //This will excute the command
                        _command.ExecuteNonQuery();
                        yes = true;
                        _connection.Close();
                    }
                }
            }
            catch (Exception error)
            {
                Error_Logger Log = new Error_Logger();
                Log.Errorlogger(error);
            }
            if (yes == true)
            {
                //Console.WriteLine("You have successfully deleted a Book");
                // Console.ReadLine();
            }
            return(yes);
        }
Example #30
0
 public userDAO Login(userDAO _userLogin)
 {
     try
     {
         using (SqlConnection _connection = new SqlConnection(connectionstring))
         {
             using (SqlCommand _command = new SqlCommand("Sp_UserLogin", _connection))
             {
                 _command.CommandType = CommandType.StoredProcedure;
                 _command.Parameters.AddWithValue("@Username", _userLogin.Username);
                 _command.Parameters.AddWithValue("@Password", _userLogin.Password);
                 _connection.Open();
                 _command.ExecuteNonQuery();
                 using (SqlDataReader _reader = _command.ExecuteReader())
                 {
                     while (_reader.Read())
                     {
                         userDAO _userToView = new userDAO();
                         _userToView.User_ID  = _reader.GetInt32(0);
                         _userToView.Username = _reader.GetString(1);
                         _userToView.Password = _reader.GetString(2);
                         _userToView.Role_ID  = _reader.GetInt32(3);
                         _userLogin           = _userToView;
                     }
                 }
                 _connection.Close();
                 _connection.Dispose();
             }
         }
     }
     catch (Exception errorCaught)
     {
         Error_Logger LogError = new Error_Logger();
         LogError.Errorlogger(errorCaught);
     }
     return(_userLogin);
 }