Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Services;
- using Utilities;
- using System.Data;
- using Project3Class;
- using System.Collections;
- namespace Project3WS
- {
- /// <summary>
- /// Summary description for UBay
- /// </summary>
- [WebService(Namespace = "http://tempuri.org/")]
- [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
- [System.ComponentModel.ToolboxItem(false)]
- // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
- //[System.Web.Script.Services.ScriptService]
- public class UBay : System.Web.Services.WebService
- {
- //Simple "Hello World" method. Left in as use for reference
- [WebMethod]
- public string HelloWorld()
- {
- return "Hello World";
- }
- //This method retrieves all the records from the customer table
- [WebMethod]
- public DataSet GetCustomers()
- {
- DBConnect objDB = new DBConnect();
- String strSQL = "SELECT * FROM p3Account";
- DataSet myDS;
- myDS = objDB.GetDataSet(strSQL);
- return myDS;
- }
- //This method retrieves all the records from the Product table
- [WebMethod]
- public DataSet GetProduct()
- {
- DBConnect objDB = new DBConnect();
- String strSQL = "SELECT * FROM p3Product";
- DataSet myDS;
- myDS = objDB.GetDataSet(strSQL);
- return myDS;
- }
- //This method retrieves all the records from the Product table in the chosen category
- [WebMethod]
- public DataSet GetProduct(string category)
- {
- DBConnect objDB = new DBConnect();
- string strSQL = "SELECT * FROM p3Product WHERE Category = '" + category + "'";
- DataSet myDS;
- myDS = objDB.GetDataSet(strSQL);
- return myDS;
- }
- //This method retrieves adds a new customer to the database
- [WebMethod]
- public Boolean AddCustomer(Customer cust)
- {
- if (cust != null)
- {
- DBConnect objDB = new DBConnect();
- String strSQL = "SELECT * FROM p3Account";
- DataSet data = objDB.GetDataSet(strSQL);
- String addUser = "INSERT into p3Account (AccountUsername, AccountName) VALUES ('" + cust.consumerAccount + "', '" + cust.consumerName + "')";
- objDB.DoUpdate(addUser);
- return true;
- }
- else
- return false;
- }
- //This method adds a new product to the database
- [WebMethod]
- public Boolean AddProduct(Product prod)
- {
- if (prod != null)
- {
- DBConnect objDB = new DBConnect();
- String strSQL = "SELECT * FROM p3Product";
- DataSet data = objDB.GetDataSet(strSQL);
- String addUser = "INSERT into p3Product (ProductName, Description, Category, ReservePrice, EndDate) VALUES ('" + prod.productName + "', '" + prod.description + "', '" + prod.category + "', '" + prod.reservePrice + "', '" + prod.endDate + "')";
- objDB.DoUpdate(addUser);
- return true;
- }
- else
- return false;
- }
- //This method attempts to find if a user is in the database
- [WebMethod]
- public static Boolean FindUser(Customer cust)
- {
- DataSet dsUser;
- DataTable dtUser;
- DataRow drUser;
- DBConnect objdb = new DBConnect();
- string sqlUser = "SELECT * FROM p3Account WHERE AccountUsername = '" + cust.consumerAccount + "'";
- dsUser = objdb.GetDataSet(sqlUser);
- dtUser = dsUser.Tables[0];
- drUser = dtUser.Rows[0];
- if (dtUser.Rows.Count != 0)
- {
- return true;
- }
- else
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement