Guest User

Untitled

a guest
Feb 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.30 KB | None | 0 0
  1. public class DoLogin extends AsyncTask<String,String,String>
  2. {
  3. ResultSet rs2;
  4. String z = "";
  5. Boolean isSuccess = false;
  6. TextView DateOfBooking,Product,CustomerName,
  7. Quantity,Destination,DealerName,Remarks,DueDate;
  8.  
  9. ArrayList DateOfBooking1 = new ArrayList();
  10. ArrayList Product1 = new ArrayList();
  11. ArrayList CustomerName1 = new ArrayList();
  12. ArrayList Quantity1 = new ArrayList();
  13. ArrayList Destination1 = new ArrayList();
  14. ArrayList DealerName1 = new ArrayList();
  15. ArrayList Remarks1 = new ArrayList();
  16. ArrayList DueDate1 = new ArrayList();
  17.  
  18.  
  19. @Override
  20. protected void onPreExecute() {
  21.  
  22. }
  23.  
  24. @Override
  25. protected void onPostExecute(String r) {
  26. Toast.makeText(OrderRequest.this, r, Toast.LENGTH_SHORT).show();
  27. if(isSuccess) {
  28.  
  29. try {
  30. addHeaders();
  31.  
  32. do{
  33. s1 = rs2.getString(1);
  34. DateOfBooking1.add(s1);
  35. s2 = rs2.getString(2);
  36. CustomerName1.add(s2);
  37. s3 = rs2.getString(3);
  38. Destination1.add(s3);
  39. s4 = rs2.getString(4);
  40. DealerName1.add(s4);
  41. s5 = rs2.getString(5);
  42. Product1.add(s5);
  43. s6 = rs2.getString(6);
  44. Quantity1.add(s6);
  45. s7 =rs2.getString(7);
  46. Remarks1.add(s7);
  47. s8 =rs2.getString(8);
  48. DueDate1.add(s8);
  49.  
  50. }while(rs2.next());
  51.  
  52. if (DateOfBooking1.size() != 0) {
  53. for (int j = 0; j < DateOfBooking1.size(); j++) {
  54.  
  55. /** Create a TableRow dynamically **/
  56. tr = new TableRow(OrderRequest.this);
  57. tr.setLayoutParams(new TableRow.LayoutParams(
  58. TableRow.LayoutParams.FILL_PARENT,
  59. TableRow.LayoutParams.WRAP_CONTENT));
  60.  
  61.  
  62. /** Creating a TextView to add to the row **/
  63. DateOfBooking = new TextView(OrderRequest.this);
  64.  
  65. DateOfBooking.setText(DateOfBooking1.get(j).toString());
  66. DateOfBooking.setTextColor(Color.BLACK);
  67. DateOfBooking.setTypeface(Typeface.DEFAULT,
  68. Typeface.ITALIC);
  69. DateOfBooking.setLayoutParams(new
  70. TableRow.LayoutParams
  71. (TableRow.LayoutParams.FILL_PARENT,
  72. TableRow.LayoutParams.WRAP_CONTENT));
  73. DateOfBooking.setPadding(5, 5, 5, 5);
  74. DateOfBooking.setId(j);
  75. tr.addView(DateOfBooking); // Adding textView to
  76. tablerow.
  77.  
  78.  
  79. CustomerName = new TextView(OrderRequest.this);
  80.  
  81. CustomerName.setText(CustomerName1.get(j).toString());
  82. CustomerName.setTextColor(Color.BLACK);
  83. CustomerName.setTypeface(Typeface.DEFAULT,
  84. Typeface.ITALIC);
  85. CustomerName.setLayoutParams(new
  86. TableRow.LayoutParams
  87. (TableRow.LayoutParams.FILL_PARENT,
  88. TableRow.LayoutParams.WRAP_CONTENT));
  89. CustomerName.setPadding(5, 5, 5, 5);
  90. CustomerName.setId(j);
  91. tr.addView(CustomerName); // Adding textView to
  92. tablerow.
  93.  
  94.  
  95. Destination = new TextView(OrderRequest.this);
  96. Destination.setText(Destination1.get(j).toString());
  97. Destination.setTextColor(Color.BLACK);
  98. Destination.setTypeface(Typeface.DEFAULT,
  99. Typeface.ITALIC);
  100. Destination.setLayoutParams(new
  101. TableRow.LayoutParams
  102. (TableRow.LayoutParams.FILL_PARENT,
  103. TableRow.LayoutParams.WRAP_CONTENT));
  104. Destination.setPadding(5, 5, 5, 5);
  105. Destination.setId(j);
  106. tr.addView(Destination); // Adding textView to
  107. tablerow.
  108.  
  109. DealerName = new TextView(OrderRequest.this);
  110. DealerName.setText(DealerName1.get(j).toString());
  111. DealerName.setTextColor(Color.BLACK);
  112. DealerName.setTypeface(Typeface.DEFAULT,
  113. Typeface.ITALIC);
  114. DealerName.setLayoutParams(new TableRow.LayoutParams
  115. (TableRow.LayoutParams.FILL_PARENT,
  116. TableRow.LayoutParams.WRAP_CONTENT));
  117. DealerName.setPadding(5, 5, 5, 5);
  118. DealerName.setId(j);
  119. tr.addView(DealerName); // Adding textView to
  120. tablerow.
  121.  
  122. Product = new TextView(OrderRequest.this);
  123. Product.setText(Product1.get(j).toString());
  124. Product.setTextColor(Color.BLACK);
  125. Product.setTypeface(Typeface.DEFAULT,
  126. Typeface.ITALIC);
  127. Product.setLayoutParams(new TableRow.LayoutParams
  128. (TableRow.LayoutParams.FILL_PARENT,
  129. TableRow.LayoutParams.WRAP_CONTENT));
  130. Product.setPadding(5, 5, 5, 5);
  131. Product.setId(j);
  132. tr.addView(Product); // Adding textView to
  133. tablerow.
  134.  
  135.  
  136. Quantity = new TextView(OrderRequest.this);
  137. Quantity.setText(Quantity1.get(j).toString());
  138. Quantity.setTextColor(Color.BLACK);
  139. Quantity.setTypeface(Typeface.DEFAULT,
  140. Typeface.ITALIC);
  141. Quantity.setLayoutParams(new TableRow.LayoutParams
  142. (TableRow.LayoutParams.FILL_PARENT,
  143. TableRow.LayoutParams.WRAP_CONTENT));
  144. Quantity.setPadding(5, 5, 5, 5);
  145. Quantity.setId(j);
  146. tr.addView(Quantity); // Adding textView to
  147. tablerow.
  148.  
  149. Remarks = new TextView(OrderRequest.this);
  150. Remarks.setText(Remarks1.get(j).toString());
  151. Remarks.setTextColor(Color.BLACK);
  152. Remarks.setTypeface(Typeface.DEFAULT,
  153. Typeface.ITALIC);
  154. Remarks.setLayoutParams(new TableRow.LayoutParams
  155. (TableRow.LayoutParams.FILL_PARENT,
  156. TableRow.LayoutParams.WRAP_CONTENT));
  157. Remarks.setPadding(5, 5, 5, 5);
  158. Remarks.setId(j);
  159. tr.addView(Remarks); // Adding textView to
  160. tablerow.
  161.  
  162. DueDate = new TextView(OrderRequest.this);
  163. DueDate.setText(DueDate1.get(j).toString());
  164. DueDate.setTextColor(Color.BLACK);
  165. DueDate.setTypeface(Typeface.DEFAULT,
  166. Typeface.ITALIC);
  167. DueDate.setLayoutParams(new
  168. TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,
  169. TableRow.LayoutParams.WRAP_CONTENT));
  170. DueDate.setPadding(5, 5, 5, 5);
  171. DueDate.setId(j);
  172. tr.addView(DueDate); // Adding textView to
  173. tablerow.
  174.  
  175. tl.addView(tr, new TableLayout.LayoutParams(
  176. TableRow.LayoutParams.FILL_PARENT,
  177. TableRow.LayoutParams.WRAP_CONTENT));
  178.  
  179. }
  180. } else {
  181. Toast.makeText(OrderRequest.this,
  182. DateOfBooking1+""+Product1+""+DealerName1
  183. +""+Destination1+""+DueDate1+""+CustomerName1
  184. +""+Quantity1+""+Remarks1+"Sorry.....",
  185. Toast.LENGTH_LONG).show();
  186. }
  187.  
  188.  
  189.  
  190.  
  191. }catch(Exception e)
  192. {
  193. Log.e("showing",e+"");
  194. }
  195.  
  196. }
  197.  
  198. }
  199.  
  200. @Override
  201. protected String doInBackground(String... params) {
  202.  
  203. try {
  204. Connection con = (Connection) connectionClass.CONN();
  205. if (con == null) {
  206. z = "Error in connection with SQL server";
  207. } else {
  208. String query = "select
  209. DocDate,CustomerName,Destination,DealerName,
  210. ProductName,Quantity,Remarks,DueDate from [Dealer].[dbo].
  211. [BookingOrder]";
  212. Statement stmt = con.createStatement();
  213. rs2 = stmt.executeQuery(query);
  214. try {
  215.  
  216. if (rs2.next()) {
  217.  
  218. isSuccess = true;
  219. z = "Successfully Viewed";
  220. }
  221. }catch (Exception n)
  222. {
  223. z = "selecting";
  224. Log.e("selecting",n+"");
  225. }
  226. }
  227.  
  228. }
  229. catch (Exception ex)
  230. {
  231. isSuccess = false;
  232. z = "Exceptions";
  233. Log.e("Exc", ex + "");
  234. return null;
  235. }
  236.  
  237. return z;
  238. }
  239. }
Add Comment
Please, Sign In to add comment