You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
8.4 KiB

  1. using Newtonsoft.Json;
  2. using Swift.DAL.BL.Remit.Transaction;
  3. using Swift.DAL.Remittance.APIPartner;
  4. using Swift.DAL.Remittance.CustomerDeposits;
  5. using Swift.DAL.SwiftDAL;
  6. using Swift.web.Library;
  7. using System;
  8. using System.Data;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Web;
  12. namespace Swift.web.Remit.ChangeCollMode
  13. {
  14. public partial class ChangeMode : System.Web.UI.Page
  15. {
  16. private string ViewFunctionId = "20114000";
  17. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  18. private readonly APIPartnerDao _dao = new APIPartnerDao();
  19. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  20. private ApproveTransactionDao at = new ApproveTransactionDao();
  21. private readonly CustomerDepositDao _dao1 = new CustomerDepositDao();
  22. protected void Page_Load(object sender, EventArgs e)
  23. {
  24. _sl.CheckAuthentication(ViewFunctionId);
  25. _sl.CheckSession();
  26. var MethodName = Request.Form["MethodName"];
  27. if (MethodName == "getListData")
  28. PopulateData();
  29. if (MethodName == "CheckAvialableBalance")
  30. CheckAvialableBalance();
  31. if (MethodName == "UnMapData")
  32. UnMapData();
  33. if (MethodName == "MapData")
  34. ProceedMapData();
  35. if (MethodName == "SaveCollMode")
  36. SaveCollMode();
  37. }
  38. private void SaveCollMode()
  39. {
  40. var controlno = Request.Form["controlno"];
  41. DbResult _res = new DbResult();
  42. if (!string.IsNullOrEmpty(controlno))
  43. {
  44. _res = _dao1.SaveCollModeChange(GetStatic.GetUser(), controlno);
  45. }
  46. else
  47. {
  48. GetStatic.AlertMessage(this, "Please choose at least on record!");
  49. }
  50. Response.ContentType = "text/plain";
  51. Response.Write(JsonConvert.SerializeObject(_res));
  52. Response.End();
  53. }
  54. private void PopulateData()
  55. {
  56. try
  57. {
  58. string trnDate = Request.Form["tranDate"];
  59. string particulars = Request.Form["particulars"];
  60. string customerId = Request.Form["customerId"];
  61. string amount = Request.Form["amount"];
  62. DataSet dt = _dao1.GetDataForSendMapping(GetStatic.GetUser(), trnDate, particulars, customerId, amount);
  63. StringBuilder sb = new StringBuilder();
  64. StringBuilder sb1 = new StringBuilder();
  65. if (null == dt)
  66. {
  67. Response.ContentType = "application/text";
  68. Response.Write("<tr><td colspan = \"7\" align=\"center\">No Data To Display</td></tr>[[<<>>]]<tr><td colspan = \"7\" align=\"center\">No Data To Display</td></tr>");
  69. HttpContext.Current.Response.Flush();
  70. HttpContext.Current.Response.SuppressContent = true;
  71. HttpContext.Current.ApplicationInstance.CompleteRequest();
  72. return;
  73. }
  74. if (dt.Tables[0].Rows.Count == 0)
  75. {
  76. sb.AppendLine("<tr><td colspan = \"7\" align=\"center\">No Data To Display</td></tr>");
  77. }
  78. if (dt.Tables[1].Rows.Count == 0)
  79. {
  80. sb1.AppendLine("<tr><td colspan = \"7\" align=\"center\">No Data To Display</td></tr>");
  81. }
  82. int sNo = 1;
  83. int sNo1 = 1;
  84. foreach (DataRow item in dt.Tables[0].Rows)
  85. {
  86. sb.AppendLine("<tr>");
  87. sb.AppendLine("<td><input type='checkbox' class='unmapped' name='chkDepositMapping' id='chkDepositMapping" + item["tranId"].ToString() + "' value='" + item["tranId"].ToString() + "' /></td>");
  88. sb.AppendLine("<td>" + item["particulars"].ToString() + "</td>");
  89. sb.AppendLine("<td>" + item["tranDate"].ToString() + "</td>");
  90. sb.AppendLine("<td align='right'>" + GetStatic.ShowDecimal(item["depositAmount"].ToString()) + "</td>");
  91. sb.AppendLine("<td align='right'>" + GetStatic.ShowDecimal(item["paymentAmount"].ToString()) + "</td>");
  92. sb.AppendLine("</tr>");
  93. sb.AppendLine("<tr id=\"addModel" + item["tranId"].ToString() + "\"></tr>");
  94. sNo++;
  95. }
  96. foreach (DataRow item in dt.Tables[1].Rows)
  97. {
  98. sb1.AppendLine("<tr>");
  99. sb1.AppendLine("<td><input type='checkbox' class='unapproved' name='chkDepositMappingUnmap' id='chkDepositMappingUnmap" + item["tranId"].ToString() + "' value='" + item["tranId"].ToString() + "'/></td>");
  100. sb1.AppendLine("<td>" + item["particulars"].ToString() + "</td>");
  101. sb1.AppendLine("<td>" + item["tranDate"].ToString() + "</td>");
  102. sb1.AppendLine("<td align='right'>" + GetStatic.ShowDecimal(item["depositAmount"].ToString()) + "</td>");
  103. sb1.AppendLine("<td align='right'>" + GetStatic.ShowDecimal(item["paymentAmount"].ToString()) + "</td>");
  104. sb1.AppendLine("</tr>");
  105. sb1.AppendLine("<tr id=\"addModel" + item["tranId"].ToString() + "\"></tr>");
  106. sNo1++;
  107. }
  108. string data = sb + "[[<<>>]]" + sb1;
  109. Response.ContentType = "application/text";
  110. Response.Write(data);
  111. HttpContext.Current.Response.Flush(); // Sends all currently buffered output to the client.
  112. HttpContext.Current.Response.SuppressContent = true; // Gets or sets a value indicating whether to send HTTP content to the client.
  113. HttpContext.Current.ApplicationInstance.CompleteRequest(); // Causes ASP.NET to bypass all events and filtering in the HTTP pipeline chain of execution and directly execute the EndRequest event.
  114. }
  115. catch (ThreadAbortException ex)
  116. {
  117. string msg = ex.Message;
  118. }
  119. }
  120. private void CheckAvialableBalance()
  121. {
  122. string customerId = Request.Form["customerId"];
  123. StringBuilder sb = new StringBuilder();
  124. var result = _dao1.CheckAvailableBanalce(GetStatic.GetUser(), customerId);
  125. if (result != null)
  126. {
  127. sb.AppendLine("<span style='background-color: yellow; font-weight: 600;padding: 4px;' id='availableBalSpan'> Available Bal: <label id=\"availableBal\" style=\"font-size: 14px;font-weight: 800;\">" + GetStatic.ShowDecimal(result.Rows[0]["avilableBalance"].ToString()) + " </label>&nbsp;JPY</span>");
  128. }
  129. else
  130. {
  131. sb.AppendLine("<span style='background-color: yellow; font-weight: 600;padding: 4px;' id='availableBalSpan'> Available Bal: <label id=\"availableBal\" style=\"font-size: 14px;font-weight: 800;\">Balance Not Available</label>&nbsp;JPY</span>");
  132. }
  133. Response.Write(sb);
  134. Response.End();
  135. }
  136. protected void ProceedMapData()
  137. {
  138. var Ids = Request.Form["tranIds[]"];
  139. var customerId = Request.Form["customerId"];
  140. var mapDate = Request.Form["mapDate"];
  141. DbResult _res = new DbResult();
  142. if (!string.IsNullOrEmpty(Ids))
  143. {
  144. _res = _dao1.SaveCustomerDepositNew(GetStatic.GetUser(), Ids, customerId, mapDate);
  145. }
  146. else
  147. {
  148. GetStatic.AlertMessage(this, "Please choose at least on record!");
  149. }
  150. Response.ContentType = "text/plain";
  151. Response.Write(JsonConvert.SerializeObject(_res));
  152. Response.End();
  153. }
  154. protected void UnMapData()
  155. {
  156. var Ids = Request.Form["tranIds[]"];
  157. var customerId = Request.Form["customerId"];
  158. DbResult _res = new DbResult();
  159. if (!string.IsNullOrEmpty(Ids))
  160. {
  161. _res = _dao1.UnMapCustomerDeposit(GetStatic.GetUser(), Ids, customerId);
  162. }
  163. else
  164. {
  165. GetStatic.AlertMessage(this, "Please choose at least on record!");
  166. }
  167. Response.ContentType = "text/plain";
  168. Response.Write(JsonConvert.SerializeObject(_res));
  169. Response.End();
  170. }
  171. }
  172. }