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.

188 lines
6.9 KiB

  1. using Swift.DAL.BL.Remit.Transaction;
  2. using Swift.web.Component.Grid;
  3. using Swift.web.Component.Grid.gridHelper;
  4. using Swift.web.Library;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.IO;
  9. using System.Text;
  10. using System.Xml;
  11. namespace Swift.web.AgentNew.Modify
  12. {
  13. public partial class ModifyTran : System.Web.UI.Page
  14. {
  15. private const string ViewFunctionId = "40101700";
  16. private const string ProcessFunctionId = "40101710";
  17. private readonly StaticDataDdl sd = new StaticDataDdl();
  18. private readonly SwiftGrid _grid = new SwiftGrid();
  19. private readonly RemittanceLibrary rl = new RemittanceLibrary();
  20. protected void Page_Load(object sender, EventArgs e)
  21. {
  22. string tran = GetStatic.ReadQueryString("clickFunction", "");
  23. showTranDetail.Value = tran;
  24. if (tran == "Y")
  25. {
  26. pageWrapper.Style.Add("min-height", "auto");
  27. pageWrapper.Style.Add("padding-bottom", "inherit");
  28. btnBack.Visible = false;
  29. string controlNo = GetStatic.ReadQueryString("controlNo", "");
  30. hdnControlNo.Value = controlNo;
  31. ClientScript.RegisterStartupScript(GetType(), "key", "javascript: document.getElementById('navBar').style.visibility = 'hidden';", true);
  32. }
  33. if (!IsPostBack)
  34. {
  35. Authenticate();
  36. //fromDate.Text= DateTime.Now.ToString("yyyy-MM-dd");
  37. }
  38. GetStatic.ResizeFrame(Page);
  39. Misc.MakeNumericTextbox(ref tranId);
  40. }
  41. private void Authenticate()
  42. {
  43. sd.CheckAuthentication(ViewFunctionId + "," + ProcessFunctionId);
  44. }
  45. protected void btnSearchDetail_Click(object sender, EventArgs e)
  46. {
  47. if (!string.IsNullOrEmpty(controlNo.Text))
  48. LoadGridView(controlNo.Text, "", "", "", "");
  49. else if (!string.IsNullOrEmpty(tranId.Text))
  50. LoadGridView("", tranId.Text, "", "", "");
  51. //else
  52. //{
  53. // //if (fromDate.Text == "")
  54. // //{
  55. // // PrintMessage("Please enter date!");
  56. // // return;
  57. // //}
  58. // //else
  59. // LoadGridView("", "", null, null, fromDate.Text);
  60. //}
  61. }
  62. protected void btnClick_Click(object sender, EventArgs e)
  63. {
  64. LoadByControlNo(hdnControlNo.Value, hdnStatus.Value);
  65. }
  66. private void LoadGridView(string cNo, string txnId, string searchByText, string serachBy, string date)
  67. {
  68. var obj = new TranViewDao();
  69. var ds = obj.DisplayMatchTran(GetStatic.GetUser(), searchByText, serachBy, date, cNo, txnId);
  70. if (ds == null)
  71. {
  72. divLoadGrid.Visible = false;
  73. PrintMessage("Transaction not found!");
  74. rl.ManageInvalidControlNoAttempt(Page, GetStatic.GetUser(), "N");
  75. return;
  76. }
  77. if (ds.Tables[0].Rows.Count > 0)
  78. {
  79. var dt = ds.Tables[0];
  80. int cols = dt.Columns.Count;
  81. DataRow a = dt.Rows[0];
  82. var str = new StringBuilder("<div class='panel panel-default'><div class='panel-heading' style=\"font-weight: bolder; \">Search Result</div><div class='panel-body'><div class='table-responsive'><table class='table table-bordered' border=\"0\" cellspacing=0 cellpadding=\"3\"></div></div>");
  83. str.Append("<tr>");
  84. for (int i = 0; i < cols; i++)
  85. {
  86. str.Append("<th><div align=\"left\">" + dt.Columns[i].ColumnName + "</div></th>");
  87. }
  88. str.Append("</tr>");
  89. foreach (DataRow dr in dt.Rows)
  90. {
  91. str.Append("<tr>");
  92. for (int i = 0; i < cols; i++)
  93. {
  94. str.Append("<td align=\"left\">" + dr[i].ToString() + "</td>");
  95. }
  96. str.Append("</tr>");
  97. }
  98. str.Append("</table></div></fieldset>");
  99. divLoadGrid.Visible = true;
  100. divLoadGrid.InnerHtml = str.ToString();
  101. }
  102. }
  103. private void LoadByControlNo(string cNo, string tranStatus)
  104. {
  105. if (sd.HasRight(ProcessFunctionId) && tranStatus == "Payment")
  106. ucTran.SearchData("", cNo, "u", "", "SEARCH", "AGT: VIEW TXN (SEARCH TRANSACTION)");
  107. else
  108. ucTran.SearchData("", cNo, "", "", "SEARCH", "AGT: VIEW TXN (SEARCH TRANSACTION)");
  109. if (!ucTran.TranFound)
  110. {
  111. PrintMessage("Transaction not found!");
  112. return;
  113. }
  114. //if (ucTran.TranStatus != "Payment")
  115. //{
  116. // string status = ucTran.TranStatus;
  117. // divTranDetails.Visible = false;
  118. // PrintMessage("Transaction not authorised for modification; Status:" + status + "!");
  119. // return;
  120. //}
  121. //var createdBy = ucTran.CreatedBy;
  122. //if (GetStatic.GetUser() != createdBy)
  123. //{
  124. // GetStatic.AlertMessage(Page, "You are not authorized to view this transaction");
  125. // return;
  126. //}
  127. divTranDetails.Visible = ucTran.TranFound;
  128. divSearch.Visible = !ucTran.TranFound;
  129. }
  130. private void LoadByControlNo(string cNo)
  131. {
  132. if (sd.HasRight(ProcessFunctionId))
  133. ucTran.SearchData("", cNo, "u", "", "SEARCH", "AGT: VIEW TXN (SEARCH TRANSACTION)");
  134. else
  135. ucTran.SearchData("", cNo, "", "", "SEARCH", "AGT: VIEW TXN (SEARCH TRANSACTION)");
  136. if (!ucTran.TranFound)
  137. {
  138. PrintMessage("Transaction not found!");
  139. return;
  140. }
  141. if (ucTran.TranStatus != "Payment")
  142. {
  143. string status = ucTran.TranStatus;
  144. divTranDetails.Visible = false;
  145. PrintMessage("Transaction not authorised for modification; Status:" + status + "!");
  146. return;
  147. }
  148. /*
  149. var createdBy = ucTran.CreatedBy;
  150. if (GetStatic.GetUser() != createdBy)
  151. {
  152. GetStatic.AlertMessage(Page, "You are not authorized to view this transaction");
  153. return;
  154. }
  155. * */
  156. divTranDetails.Visible = ucTran.TranFound;
  157. divSearch.Visible = !ucTran.TranFound;
  158. }
  159. private void PrintMessage(string msg)
  160. {
  161. GetStatic.CallBackJs1(Page, "Msg", "alert('" + msg + "');");
  162. }
  163. protected void btnReloadDetail_Click(object sender, EventArgs e)
  164. {
  165. LoadByControlNo(ucTran.CtrlNo);
  166. }
  167. }
  168. }