Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Services;
  6. using Utilities;
  7. using System.Data;
  8. using Project3Class;
  9. using System.Collections;
  10.  
  11. namespace Project3WS
  12. {
  13. /// <summary>
  14. /// Summary description for UBay
  15. /// </summary>
  16. [WebService(Namespace = "http://tempuri.org/")]
  17. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  18. [System.ComponentModel.ToolboxItem(false)]
  19. // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
  20. //[System.Web.Script.Services.ScriptService]
  21.  
  22. public class UBay : System.Web.Services.WebService
  23. {
  24. //Simple "Hello World" method. Left in as use for reference
  25. [WebMethod]
  26. public string HelloWorld()
  27. {
  28. return "Hello World";
  29. }
  30.  
  31. //This method retrieves all the records from the customer table
  32. [WebMethod]
  33. public DataSet GetCustomers()
  34. {
  35. DBConnect objDB = new DBConnect();
  36. String strSQL = "SELECT * FROM p3Account";
  37. DataSet myDS;
  38.  
  39. myDS = objDB.GetDataSet(strSQL);
  40.  
  41. return myDS;
  42. }
  43.  
  44. //This method retrieves all the records from the Product table
  45. [WebMethod]
  46. public DataSet GetProduct()
  47. {
  48. DBConnect objDB = new DBConnect();
  49. String strSQL = "SELECT * FROM p3Product";
  50. DataSet myDS;
  51. myDS = objDB.GetDataSet(strSQL);
  52.  
  53. return myDS;
  54. }
  55.  
  56. //This method retrieves all the records from the Product table in the chosen category
  57. [WebMethod]
  58. public DataSet GetProduct(string category)
  59. {
  60. DBConnect objDB = new DBConnect();
  61. string strSQL = "SELECT * FROM p3Product WHERE Category = '" + category + "'";
  62. DataSet myDS;
  63.  
  64. myDS = objDB.GetDataSet(strSQL);
  65.  
  66. return myDS;
  67. }
  68.  
  69. //This method retrieves adds a new customer to the database
  70. [WebMethod]
  71. public Boolean AddCustomer(Customer cust)
  72. {
  73. if (cust != null)
  74. {
  75. DBConnect objDB = new DBConnect();
  76. String strSQL = "SELECT * FROM p3Account";
  77. DataSet data = objDB.GetDataSet(strSQL);
  78.  
  79. String addUser = "INSERT into p3Account (AccountUsername, AccountName) VALUES ('" + cust.consumerAccount + "', '" + cust.consumerName + "')";
  80.  
  81. objDB.DoUpdate(addUser);
  82.  
  83. return true;
  84. }
  85. else
  86. return false;
  87. }
  88.  
  89. //This method adds a new product to the database
  90. [WebMethod]
  91. public Boolean AddProduct(Product prod)
  92. {
  93. if (prod != null)
  94. {
  95. DBConnect objDB = new DBConnect();
  96. String strSQL = "SELECT * FROM p3Product";
  97. DataSet data = objDB.GetDataSet(strSQL);
  98.  
  99. String addUser = "INSERT into p3Product (ProductName, Description, Category, ReservePrice, EndDate) VALUES ('" + prod.productName + "', '" + prod.description + "', '" + prod.category + "', '" + prod.reservePrice + "', '" + prod.endDate + "')";
  100.  
  101. objDB.DoUpdate(addUser);
  102.  
  103. return true;
  104. }
  105. else
  106. return false;
  107. }
  108.  
  109. //This method attempts to find if a user is in the database
  110. [WebMethod]
  111. public static Boolean FindUser(Customer cust)
  112. {
  113. DataSet dsUser;
  114. DataTable dtUser;
  115. DataRow drUser;
  116.  
  117. DBConnect objdb = new DBConnect();
  118. string sqlUser = "SELECT * FROM p3Account WHERE AccountUsername = '" + cust.consumerAccount + "'";
  119.  
  120. dsUser = objdb.GetDataSet(sqlUser);
  121. dtUser = dsUser.Tables[0];
  122. drUser = dtUser.Rows[0];
  123.  
  124. if (dtUser.Rows.Count != 0)
  125. {
  126. return true;
  127. }
  128. else
  129. return false;
  130. }
  131. }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement