//retrieved product information to be displayed on the product page public List <PRODUTCT_DATA> retrieve_product(string search, string userid) { List <PRODUTCT_DATA> product_list = new List <PRODUTCT_DATA>(); Database_Connection con = new Database_Connection(); string query = "SELECT * FROM DBO.PRODUCT_DISPLAY_INFO"; //he base query //checking if the user is search for anything if (search != "") { query += " WHERE PROUCT_NAME LIKE '%" + search + "%'"; } SqlDataReader reader; //checking if the user has a user id if (userid == "") { reader = con.ExecuteQueries(query); } else { reader = con.ExecuteQueries(query, userid); } //reading data that has been returned from the executed process while (reader.Read()) { //storing the data that has been received into an model PRODUTCT_DATA temp = new PRODUTCT_DATA ( reader[2].ToString(), decimal.Parse(reader[5].ToString()), reader[4].ToString(), reader[6].ToString(), reader[0].ToString(), int.Parse(reader[7].ToString()) , 0, reader[3].ToString() ); //adding each row of data that has been read to data model list product_list.Add(temp); } con.closeSqlData(); //closing sql data stream return(product_list); //returning the data model list of data }
//function that handles getting the cart summary information public List <CART_INFO_SUMMARY> get_cart_summary(string user_id) { List <CART_INFO_SUMMARY> cart_summary = new List <CART_INFO_SUMMARY>(); Database_Connection con = new Database_Connection(); string query = "SELECT * FROM GET_CART_SUMMARY('" + user_id + "')"; SqlDataReader reader = con.ExecuteQueries(query, user_id); while (reader.Read()) { CART_INFO_SUMMARY item_sum = new CART_INFO_SUMMARY ( reader[0].ToString(), int.Parse(reader[1].ToString()), decimal.Parse(reader[2].ToString()), reader[3].ToString() ); cart_summary.Add(item_sum); } reader.Close(); con.closeSqlData(); return(cart_summary); }
//function that retrive the information to handle the tracking of the product public List <USER_SHIPPING_INFO> retrieve_shipping_info(string user_id) { List <USER_SHIPPING_INFO> list_of_card = new List <USER_SHIPPING_INFO>(); Database_Connection con = new Database_Connection(); string query = "SELECT * FROM GET_SHIPPING_INFO('" + user_id + "')"; SqlDataReader reader = con.ExecuteQueries(query, user_id); while (reader.Read()) { USER_SHIPPING_INFO card = new USER_SHIPPING_INFO ( reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), reader[7].ToString() ); list_of_card.Add(card); } reader.Close(); con.closeSqlData(); return(list_of_card); }
//functionn that handles the retrieval of users addresses public List <USER_ADDRESS_DETAIL> retrieve_customer_addresses(string user_id) { //declaring list to store all the customer addresses available on the database List <USER_ADDRESS_DETAIL> add = new List <USER_ADDRESS_DETAIL>(); Database_Connection con = new Database_Connection(); //putting together the query that handles the retrieval of the address information string query = "SELECT * FROM GET_ADDRESSES('" + user_id + "')"; SqlDataReader reader = con.ExecuteQueries(query, user_id); //reading data from the database while (reader.Read()) { //storing an user address in the data model that was created to host it USER_ADDRESS_DETAIL info = new USER_ADDRESS_DETAIL ( reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString(), reader[6].ToString() ); add.Add(info);// adding the user address to the user list of addresses if more than one exists } reader.Close(); //closing the data reader con.closeSqlData(); // closing data connection return(add); }
//retrieving cart information whether historical or current information public List <CART_INFORMATION> retrieve_cart_data(string type, string userid) { Database_Connection con = new Database_Connection(); List <CART_INFORMATION> cart_list = new List <CART_INFORMATION> (); string query = ""; SqlDataReader reader = null; //checking which base query data will be pulling from if (type == "his") { query = "SELECT * FROM [dbo].[VIEW_CART_HISTORY]('" + userid + "')"; //retrieving data reader = con.ExecuteQueries(query, userid); //reading data while (reader.Read()) { //storing information into a class model CART_INFORMATION cart = new CART_INFORMATION ( reader[0].ToString(), reader[1].ToString(), int.Parse(reader[2].ToString()), decimal.Parse(reader[3].ToString()), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), decimal.Parse(reader[7].ToString()), reader[8].ToString() ); //adding the model to a list of models cart_list.Add(cart); } } else { query = "SELECT * FROM [dbo].[VIEW_CART]('" + userid + "')"; //retrieving data reader = con.ExecuteQueries(query, userid); //reading data while (reader.Read()) { //storing information into a class model CART_INFORMATION cart = new CART_INFORMATION ( reader[0].ToString(), reader[1].ToString(), int.Parse(reader[2].ToString()), decimal.Parse(reader[3].ToString()), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), decimal.Parse(reader[7].ToString()) ); //adding the model to a list of models cart_list.Add(cart); } } reader.Close(); con.closeSqlData(); //closing sql data stream return(cart_list); // returning the list }