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.

838 lines
36 KiB

  1. using Swift.DAL.BL.Remit.Transaction;
  2. using Swift.DAL.BL.System.GeneralSettings;
  3. using Swift.DAL.SwiftDAL;
  4. using Swift.web.Library;
  5. using System;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Text;
  9. namespace Swift.web.Remit.UserControl
  10. {
  11. public partial class UcTransactionInt : System.Web.UI.UserControl
  12. {
  13. private RemittanceLibrary sl = new RemittanceLibrary();
  14. private SmtpMailSetting smtpMailSetting = new SmtpMailSetting();
  15. public bool ShowDetailBlock { get; set; }
  16. public bool ShowLogBlock { get; set; }
  17. private bool _showCommentBlock = true;
  18. public bool ShowCommentBlock
  19. {
  20. get { return _showCommentBlock; }
  21. set { _showCommentBlock = value; }
  22. }
  23. public bool ShowBankDetail { get; set; }
  24. public bool ShowOfac { get; set; }
  25. public bool ShowCompliance { get; set; }
  26. public bool ShowApproveButton { get; set; }
  27. public bool ShowSettlment { get; set; }
  28. public string PAgent
  29. {
  30. get { return pAgent.Value; }
  31. set { pAgent.Value = value; }
  32. }
  33. public string TranNo
  34. {
  35. get { return hddTranId.Value; }
  36. set { hddTranId.Value = value; }
  37. }
  38. public string trnStatusBeforeCnlReq
  39. {
  40. get { return hddTrnSatusBeforeCnlReq.Value; }
  41. set { hddTrnSatusBeforeCnlReq.Value = value; }
  42. }
  43. public string pCountry
  44. {
  45. get { return rCountry.Text; }
  46. set { rCountry.Text = value; }
  47. }
  48. public string CtrlNo
  49. {
  50. get { return lblControlNo.Text; }
  51. set { lblControlNo.Text = value; }
  52. }
  53. public string PayTokenId
  54. {
  55. get { return hddPayTokenId.Value; }
  56. set { hddPayTokenId.Value = value; }
  57. }
  58. public string TranStatus
  59. {
  60. get { return tranStatus.Text; }
  61. set { tranStatus.Text = value; }
  62. }
  63. public string PayStatus
  64. {
  65. get { return payStatus.Text; }
  66. set { payStatus.Text = value; }
  67. }
  68. public string ModeOfPayment
  69. {
  70. get { return modeOfPayment.Text; }
  71. set { modeOfPayment.Text = value; }
  72. }
  73. public string CreatedBy
  74. {
  75. get { return createdBy.Text; }
  76. set { createdBy.Text = value; }
  77. }
  78. public string ApprovedBy
  79. {
  80. get { return approvedBy.Text; }
  81. set { approvedBy.Text = value; }
  82. }
  83. public string PaidBy
  84. {
  85. get { return paidBy.Text; }
  86. set { paidBy.Text = value; }
  87. }
  88. public string CancelRequestedBy
  89. {
  90. get { return cancelRequestedBy.Text; }
  91. set { cancelRequestedBy.Text = value; }
  92. }
  93. public string CancelApprovedBy
  94. {
  95. get { return cancelApprovedBy.Text; }
  96. set { cancelApprovedBy.Text = value; }
  97. }
  98. public bool TranFound { get; set; }
  99. public void SearchData(string tranNo, string ctrlNo, string mode, string lockMode)
  100. {
  101. SearchData(tranNo, ctrlNo, mode, lockMode, "SEARCH", "ADM:SEARCH TXN");
  102. }
  103. public void SearchData(string tranNo, string ctrlNo, string mode, string lockMode, string viewType, string viewMsg)
  104. {
  105. tranNoName.Text = GetStatic.GetTranNoName();
  106. TranNo = tranNo;
  107. CtrlNo = ctrlNo;
  108. TranFound = false;
  109. var obj = new TranViewDao();
  110. var ds = obj.SelectTransactionInt(GetStatic.GetUser(), ctrlNo, TranNo, lockMode, viewType, viewMsg, GetStatic.GetIp(), GetStatic.GetDcInfo());
  111. if (ds == null)
  112. {
  113. sl.ManageInvalidControlNoAttempt(Page, GetStatic.GetUser(), "N");
  114. return;
  115. }
  116. if (ds.Tables.Count > 1)
  117. {
  118. if (ds.Tables[0].Rows.Count > 0)
  119. {
  120. TranFound = true;
  121. sl.ManageInvalidControlNoAttempt(Page, GetStatic.GetUser(), "Y");
  122. var tRow = ds.Tables[0].Rows[0];
  123. lblControlNo.Text = tRow["controlNo"].ToString();
  124. lblTranNo.Text = tRow["holdTranId"].ToString();
  125. lblTranRefId.Text = tRow["tranId"].ToString();
  126. hddTranId.Value = tRow["tranId"].ToString();
  127. hddTrnSatusBeforeCnlReq.Value = tRow["trnStatusBeforeCnlReq"].ToString();
  128. if (tRow["sMemId"].ToString() == "")
  129. sDisMemId.Visible = false;
  130. else
  131. {
  132. sDisMemId.Visible = true;
  133. sMemId.Text = tRow["sMemId"].ToString();
  134. }
  135. if (tRow["rMemId"].ToString() == "")
  136. rDisMemId.Visible = false;
  137. else
  138. {
  139. rDisMemId.Visible = true;
  140. rMemId.Text = tRow["rMemId"].ToString();
  141. }
  142. PAgent = tRow["pAgent"].ToString();
  143. if (tRow["tranStatus"].ToString().ToUpper() == "LOCK")
  144. {
  145. lockAudit.Visible = true;
  146. var html = new StringBuilder("Locked By ");
  147. html.Append(tRow["lockedBy"] + " on " + tRow["lockedDate"]);
  148. lockAudit.InnerHtml = html.ToString();
  149. }
  150. if (mode == "u") // mode: modification transaction
  151. {
  152. sAddress.Text = GetLinkTextForModification("Sender Address", "sAddress", tRow);
  153. sContactNo.Text = GetLinkTextForModification("Sender Contact No", "sContactNo", tRow);
  154. rName.Text = GetLinkTextForModification("Receiver Name", "receiverName", tRow);
  155. rAddress.Text = GetLinkTextForModification("Receiver Address", "rAddress", tRow);
  156. rContactNo.Text = GetLinkTextForModification("Receiver Contact No", "rContactNo", tRow);
  157. rIdType.Text = GetLinkTextForModification("Receiver Id Type", "rIdType", tRow);
  158. rIdNo.Text = GetLinkTextForModification("Receiver Id No", "rIdNo", tRow);
  159. relationship.Text = GetLinkTextForModification("Relationship With Sender", "relationship", tRow);
  160. rCity.Text = GetLinkTextForModification("Reciver City/State", "rCity", tRow);
  161. sCity.Text = GetLinkTextForModification("Sender City/State", "sCity", tRow);
  162. }
  163. else
  164. {
  165. sAddress.Text = tRow["sAddress"].ToString();
  166. sContactNo.Text = tRow["sContactNo"].ToString();
  167. sValidityDate.Text = tRow["sValidDate"].ToString();
  168. rCity.Text = tRow["rCity"].ToString();
  169. sCity.Text = tRow["sCity"].ToString();
  170. rName.Text = tRow["receiverName"].ToString();
  171. rAddress.Text = tRow["rAddress"].ToString();
  172. rContactNo.Text = tRow["rContactNo"].ToString();
  173. rIdType.Text = tRow["rIdType"].ToString();
  174. rIdNo.Text = tRow["rIdNo"].ToString();
  175. relationship.Text = tRow["relationship"].ToString();
  176. }
  177. sName.Text = tRow["senderName"].ToString();
  178. sIdType.Text = tRow["sIdType"].ToString();
  179. sIdNo.Text = tRow["sIdNo"].ToString();
  180. sTelNo.Text = tRow["sTelNo"].ToString();
  181. rTelNo.Text = tRow["rTelNo"].ToString();
  182. if (tRow["tranStatus"].ToString().ToUpper() == "CANCEL")
  183. {
  184. showHideTranStatus.Visible = true;
  185. highLightTranStatus.InnerText = "CANCELLED Transaction";
  186. }
  187. if (tRow["tranStatus"].ToString().ToUpper() == "BLOCK")
  188. {
  189. showHideTranStatus.Visible = true;
  190. highLightTranStatus.InnerText = "Block Transaction";
  191. }
  192. if (tRow["tranStatus"].ToString().ToUpper() == "CANCELREQUEST")
  193. {
  194. showHideTranStatus.Visible = true;
  195. highLightTranStatus.InnerText = "Cancel Requested !";
  196. }
  197. if (tRow["tranStatus"].ToString().ToUpper() == "LOCK")
  198. {
  199. showHideTranStatus.Visible = true;
  200. highLightTranStatus.InnerText = "Locked Transaction!";
  201. }
  202. if (tRow["tranStatus"].ToString().ToUpper() == "COMPLIANCE")
  203. {
  204. showHideTranStatus.Visible = true;
  205. highLightTranStatus.InnerText = "Compliance Transaction!";
  206. }
  207. if (tRow["tranStatus"].ToString().ToUpper() == "OFAC")
  208. {
  209. showHideTranStatus.Visible = true;
  210. highLightTranStatus.InnerText = "OFAC Transaction!";
  211. }
  212. sCountry.Text = tRow["sCountryName"].ToString();
  213. sEmail.Text = tRow["sEmail"].ToString();
  214. sNativeCountry.Text = tRow["nativeCountry"].ToString();
  215. rCountry.Text = tRow["rCountryName"].ToString();
  216. //Sending Agent Detail
  217. sAgentName.Text = tRow["sAgentName"].ToString();
  218. sBranchName.Text = tRow["sBranchName"].ToString();
  219. sAgentCountry.Text = tRow["sCountryName"].ToString();
  220. sAgentAddress.Text = tRow["sAgentAddress"].ToString();
  221. //Payout Agent Detail
  222. pAgentCountry.Text = tRow["pAgentCountry"].ToString();
  223. pAgentAddress.Text = tRow["pAgentAddress"].ToString();
  224. bankName.Text = tRow["BankName"].ToString();
  225. pBranchName.Text = tRow["pBranchName"].ToString();
  226. if (mode == "u" && tRow["paymentMethod"].ToString().ToUpper() == "BANK DEPOSIT" && tRow["payStatus"].ToString().ToUpper() == "POST" && tRow["tranStatus"].ToString().ToUpper() == "PAYMENT") //modify mode & bank deposit mode
  227. {
  228. accountNo.Text = GetLinkPayoutLocation("Account Number", "accountNo", tRow);
  229. }
  230. else if (mode == "u" && tRow["paymentMethod"].ToString().ToUpper() == "BANK DEPOSIT" && tRow["payStatus"].ToString().ToUpper() == "UNPAID" && tRow["tranStatus"].ToString().ToUpper() == "PAYMENT")
  231. {
  232. accountNo.Text = GetLinkPayoutLocation("Account Number", "accountNo", tRow);
  233. branchName.Text = GetLinkPayoutLocation("Branch Name", "BranchName", tRow);
  234. }
  235. else
  236. {
  237. accountNo.Text = tRow["accountNo"].ToString();
  238. branchName.Text = tRow["BranchName"].ToString();
  239. }
  240. pAgentName.Text = tRow["pAgentName"].ToString();
  241. sAgentComm.Text = GetStatic.FormatData(tRow["sAgentComm"].ToString(), "M");
  242. sAgentCommCurr.Text = tRow["sAgentCommCurrency"].ToString();
  243. if (payStatus.Text == "Paid")
  244. {
  245. payAgentComm.Visible = true;
  246. pAgentComm.Text = GetStatic.FormatData(tRow["pAgentComm"].ToString(), "M");
  247. pAgentCommCurr.Text = tRow["pAgentCommCurrency"].ToString();
  248. }
  249. //Transaction Information
  250. pnlShowBankDetail.Visible = tRow["CashOrBank"].ToString().ToUpper().Equals("BANK");
  251. modeOfPayment.Text = tRow["paymentMethod"].ToString();
  252. lblStatus.Text = tRow["payStatus"].ToString();
  253. tranStatus.Text = tRow["tranStatus"].ToString();
  254. lbltrnsubStatus.Text = tRow["tranStatus"].ToString();
  255. payStatus.Text = tRow["payStatus"].ToString();
  256. payoutMsg.Text = tRow["payoutMsg"].ToString();
  257. sourceOfFund.Text = tRow["sourceOfFund"].ToString();
  258. reasonOfRemit.Text = tRow["purposeOfRemit"].ToString();
  259. //Payout Amount
  260. custRate.Text = tRow["custRate"].ToString();
  261. settRate.Text = tRow["settRate"].ToString();
  262. transferAmount.Text = GetStatic.FormatData(tRow["tAmt"].ToString(), "M");
  263. serviceCharge.Text = GetStatic.FormatData(tRow["serviceCharge"].ToString(), "M");
  264. total.Text = GetStatic.FormatData(tRow["cAmt"].ToString(), "M");
  265. payoutAmt.Text = GetStatic.FormatData(tRow["pAmt"].ToString(), "M");
  266. hdnRName.Value = tRow["receiverName"].ToString();
  267. hdnSName.Value = tRow["senderName"].ToString();
  268. tAmtCurr.Text = tRow["collCurr"].ToString();
  269. scCurr.Text = tRow["collCurr"].ToString();
  270. totalCurr.Text = tRow["collCurr"].ToString();
  271. pAmtCurr.Text = tRow["payoutCurr"].ToString();
  272. //Transaction Log Information
  273. createdBy.Text = tRow["createdBy"].ToString();
  274. createdDate.Text = tRow["createdDate"].ToString();
  275. approvedBy.Text = tRow["approvedBy"].ToString();
  276. approvedDate.Text = tRow["approvedDate"].ToString();
  277. paidBy.Text = tRow["paidBy"].ToString();
  278. paidDate.Text = tRow["paidDate"].ToString();
  279. cancelRequestedBy.Text = tRow["cancelRequestBy"].ToString();
  280. cancelRequestedDate.Text = tRow["cancelRequestDate"].ToString();
  281. cancelApprovedBy.Text = tRow["cancelApprovedBy"].ToString();
  282. cancelApprovedDate.Text = tRow["cancelApprovedDate"].ToString();
  283. hddPayTokenId.Value = tRow["payTokenId"].ToString();
  284. tblCreatedLog.Visible = createdBy.Text != "";
  285. tblApprovedLog.Visible = approvedBy.Text != "";
  286. tblPaidLog.Visible = paidBy.Text != "";
  287. tblCancelRequestedLog.Visible = cancelRequestedBy.Text != "";
  288. tblCancelApprovedLog.Visible = cancelApprovedBy.Text != "";
  289. }
  290. if (ds.Tables[1].Rows.Count > 0)
  291. {
  292. pnlLog.Visible = true;
  293. var dt = ds.Tables[1];
  294. var str = new StringBuilder("<table class='table table-bordered' border=\"1\" cellspacing=0 cellpadding=\"3\">");
  295. str.Append("<tr>");
  296. str.Append("<th>Updated By</th>");
  297. str.Append("<th>Updated Date</th>");
  298. str.Append("<th>Message</th>");
  299. str.Append("</tr>");
  300. foreach (DataRow dr in dt.Rows)
  301. {
  302. str.Append("<tr>");
  303. str.Append("<td align='left'>" + dr["createdBy"] + "</td>");
  304. str.Append("<td align='left'>" + dr["createdDate"] + "</td>");
  305. if (dr["fileType"].ToString() == "")
  306. {
  307. str.Append("<td align='left'>" + dr["message"] + "</td>");
  308. }
  309. else
  310. {
  311. str.Append("<td align='left'><a title='View Deposit Slip' target='_blank' href='/doc/" + lblControlNo.Text + "/" + dr["rowId"].ToString() + "." + dr["fileType"].ToString() + "'>" + dr["message"] + "</a></td>");
  312. }
  313. //str.Append("<td align='left'>" + dr["msgType"] + "</td>");
  314. str.Append("</tr>");
  315. }
  316. str.Append("</table>");
  317. rptLog.InnerHtml = str.ToString();
  318. }
  319. //if (ds.Tables[2].Rows.Count > 0)
  320. //{
  321. // var sb = new StringBuilder("");
  322. // sb.AppendLine("<table class='table table' style=\"width: 100%\" border=\"1\" cellspacing=0 cellpadding=\"3\"><tr>");
  323. // sb.AppendLine("<th nowrap='nowrap' align='left'>BANK/CASH</th>");
  324. // sb.AppendLine("<th nowrap='nowrap' align='left'>Voucher No</th>");
  325. // sb.AppendLine("<th nowrap='nowrap' align='left'>Amount</th>");
  326. // sb.AppendLine("<th nowrap='nowrap' align='left'>Deposit Date</th>");
  327. // sb.AppendLine("<th nowrap='nowrap' align='left'>Narration</th></tr>");
  328. // for (int a = 0; a < ds.Tables[2].Rows.Count; a++)
  329. // {
  330. // sb.AppendLine("<tr>");
  331. // sb.AppendLine("<td align='left'>" + ds.Tables[2].Rows[a]["bankName"] + "</td>");
  332. // sb.AppendLine("<td align='left'>" + ds.Tables[2].Rows[a]["voucherNo"] + "</td>");
  333. // sb.AppendLine("<td align='left'>" + GetStatic.ShowDecimal(ds.Tables[2].Rows[a]["Amt"].ToString()) + "</td>");
  334. // sb.AppendLine("<td align='left'>" + ds.Tables[2].Rows[a]["collDate"] + "</td>");
  335. // sb.AppendLine("<td align='left'>" + ds.Tables[2].Rows[a]["narration"] + "</td>");
  336. // sb.AppendLine("</tr>");
  337. // }
  338. // sb.AppendLine("</table>");
  339. // Ddetail.InnerHtml = sb.ToString();
  340. //}
  341. }
  342. }
  343. public void SearchData(string tranNo, string ctrlNo)
  344. {
  345. SearchData(tranNo, ctrlNo, "");
  346. }
  347. public void SearchData(string tranNo, string ctrlNo, string lockMode)
  348. {
  349. SearchData(tranNo, ctrlNo, "", lockMode);
  350. }
  351. public string GetLinkTextForModification(string label, string fieldName, DataRow dr)
  352. {
  353. var str = "<a href=# title='Edit Record'><div class = \"link\" onclick = \"EditData('" + label + "', '" + fieldName + "', '" + dr[fieldName] + "','" + hddTranId.Value + "')\">" +
  354. dr[fieldName] + "<img border=0 src=\"" + GetStatic.GetUrlRoot() + "/Images/edit.gif\"/></a></div>";
  355. return str;
  356. }
  357. public string GetLinkPayoutLocation(string label, string fieldName, DataRow dr)
  358. {
  359. var str = "<a href=# title='Edit Record'><div class = \"link\" onclick = \"EditPayoutLocation('" + label + "', '" + fieldName + "', '" + dr[fieldName] + "','" + hddTranId.Value + "')\">" +
  360. dr[fieldName] + "<img border=0 src=\"" + GetStatic.GetUrlRoot() + "/Images/edit.gif\"/></a></div>";
  361. return str;
  362. }
  363. public void SearchData()
  364. {
  365. //if TranNo is not blank, search by tranNo
  366. //if CtrlNo is not blank, search by ctrlNo
  367. }
  368. private void ManageMessage(DbResult dbResult)
  369. {
  370. GetStatic.SetMessage(dbResult);
  371. GetStatic.AlertMessage(Page);
  372. }
  373. protected void Page_Load(object sender, EventArgs e)
  374. {
  375. Authenticate();
  376. pnlDetail.Visible = ShowDetailBlock;
  377. pnlReleaseBtn.Visible = ShowApproveButton;
  378. pnlComment.Visible = ShowCommentBlock;
  379. lblAddComp.Visible = ShowCommentBlock;
  380. lblSettl.Visible = ShowSettlment;
  381. ShowOFACList();
  382. ShowComplianceList();
  383. ShowCashLimitHoldList();
  384. }
  385. private void Authenticate()
  386. {
  387. sl.CheckSession();
  388. }
  389. protected void btnAdd_Click(object sender, EventArgs e)
  390. {
  391. if (GetStatic.GetIsApiFlag() == "Y")
  392. AddCommentApi();
  393. else
  394. AddComment();
  395. comments.Text = "";
  396. ShowLog();
  397. }
  398. #region for desplaying a transaction comments log
  399. public void ShowLog()
  400. {
  401. var obj = new TranViewDao();
  402. var ds = obj.DisplayLog(GetStatic.GetUser(), lblControlNo.Text, hddTranId.Value, "");
  403. if (ds == null)
  404. return;
  405. if (ds.Tables[0].Rows.Count > 0)
  406. {
  407. pnlLog.Visible = true;
  408. var dt = ds.Tables[0];
  409. var str = new StringBuilder("<table class='trnLog' border=\"1\" cellspacing=0 cellpadding=\"3\">");
  410. str.Append("<tr>");
  411. str.Append("<th>Updated By</th>");
  412. str.Append("<th width='130px'>Updated Date</th>");
  413. str.Append("<th>Message</th>");
  414. //str.Append("<th>Msg Type</th>");
  415. str.Append("</tr>");
  416. foreach (DataRow dr in dt.Rows)
  417. {
  418. str.Append("<tr>");
  419. str.Append("<td align='left'>" + dr["createdBy"] + "</td>");
  420. str.Append("<td align='left'>" + dr["createdDate"] + "</td>");
  421. if (dr["fileType"].ToString() == "")
  422. {
  423. str.Append("<td align='left'>" + dr["message"] + "</td>");
  424. }
  425. else
  426. {
  427. str.Append("<td align='left'><a title='View Deposit Slip' target='_blank' href='/doc/" + lblControlNo.Text + "/" + dr["rowId"].ToString() + "." + dr["fileType"].ToString() + "'>" + dr["message"] + "</a></td>");
  428. }
  429. //str.Append("<td align='left'>" + dr["msgType"] + "</td>");
  430. str.Append("</tr>");
  431. }
  432. str.Append("</table>");
  433. rptLog.InnerHtml = str.ToString();
  434. }
  435. }
  436. #endregion for desplaying a transaction comments log
  437. public void ShowOFACList()
  438. {
  439. var obj = new TranViewDao();
  440. var ds = obj.DisplayOFAC(GetStatic.GetUser(), lblControlNo.Text, hddTranId.Value, "");
  441. if (ds == null)
  442. {
  443. pnlOFAC.Visible = false;
  444. return;
  445. }
  446. var senderName = hdnSName.Value;
  447. var recName = hdnRName.Value;
  448. var name = senderName + ' ' + recName;
  449. if (ds.Tables[0].Rows[0]["isJsonData"].ToString() == "Y")
  450. {
  451. string res = GetStatic.ParseOfacJson(ds.Tables[0].Rows[0]["ofacRemarks"].ToString(), name);
  452. if (!string.IsNullOrEmpty(res))
  453. {
  454. pnlOFAC.Visible = true;
  455. displayOFAC.InnerHtml = res;
  456. string checkFlag = obj.checkFlagOFAC(GetStatic.GetUser(), lblControlNo.Text, hddTranId.Value, "");
  457. if (checkFlag == "Y")
  458. {
  459. pnlReleaseBtn.Visible = false;
  460. }
  461. GetStatic.AlertMessage(Page);
  462. }
  463. return;
  464. }
  465. if (ds.Tables[0].Rows.Count > 0)
  466. {
  467. pnlOFAC.Visible = true;
  468. var dt = ds.Tables[0];
  469. int cols = dt.Columns.Count;
  470. var str = new StringBuilder("<table class='trnLog' border=\"1\" cellspacing=0 cellpadding=\"3\">");
  471. str.Append("<tr>");
  472. for (int i = 0; i < cols; i++)
  473. {
  474. str.Append("<th><div align=\"left\">" + dt.Columns[i].ColumnName + "</div></th>");
  475. }
  476. str.Append("</tr>");
  477. foreach (DataRow dr in dt.Rows)
  478. {
  479. str.Append("<tr>");
  480. str.Append("<td align=\"left\">" + dr[0] + "</td>");
  481. var strArr = name.Split(' ');
  482. var arrlen = strArr.Length;
  483. string value = dr[1].ToString();
  484. for (int j = 0; j < arrlen; j++)
  485. {
  486. if (!string.IsNullOrWhiteSpace(strArr[j]))
  487. {
  488. if (strArr[j].Length > 2)
  489. {
  490. value = value.ToUpper().Replace(strArr[j], GetStatic.PutRedBackGround(strArr[j]));
  491. }
  492. }
  493. }
  494. str.Append("<td align=\"left\">" + value + "</td>");
  495. str.Append("</tr>");
  496. }
  497. str.Append("</table>");
  498. displayOFAC.InnerHtml = str.ToString();
  499. string checkFlag = obj.checkFlagOFAC(GetStatic.GetUser(), lblControlNo.Text, hddTranId.Value, "");
  500. if (checkFlag == "Y")
  501. {
  502. pnlReleaseBtn.Visible = false;
  503. }
  504. GetStatic.AlertMessage(Page);
  505. }
  506. }
  507. public void ShowComplianceList()
  508. {
  509. var obj = new TranViewDao();
  510. var ds = obj.DisplayCompliance(GetStatic.GetUser(), lblControlNo.Text, hddTranId.Value, "");
  511. if (ds == null)
  512. {
  513. pnlCompliance.Visible = false;
  514. return;
  515. }
  516. if (ds.Tables[0].Rows.Count > 0)
  517. {
  518. var dt = ds.Tables[0];
  519. int cols = dt.Columns.Count;
  520. var str = new StringBuilder("<table class='trnLog' border=\"1\" cellspacing=0 cellpadding=\"3\">");
  521. str.Append("<tr>");
  522. for (int i = 2; i < cols; i++)
  523. {
  524. str.Append("<th><div align=\"left\">" + dt.Columns[i].ColumnName + "</div></th>");
  525. }
  526. str.Append("</tr>");
  527. foreach (DataRow dr in dt.Rows)
  528. {
  529. str.Append("<tr>");
  530. for (int i = 2; i < cols; i++)
  531. {
  532. if (i == 4)
  533. {
  534. var strArr = dr["Matched ControlNo"].ToString().Split(',');
  535. var arrlen = strArr.Length;
  536. str.Append("<td>");
  537. for (int j = 0; j < arrlen; j++)
  538. {
  539. str.Append("<a href=\"#\" onclick=\"OpenInNewWindow('" + GetStatic.GetUrlRoot() + "/Remit/Transaction/Reports/SearchTransaction.aspx?tranId=" + strArr[j] + "')\">" + strArr[j] + "</a> &nbsp;");
  540. }
  541. str.Append("</td>");
  542. }
  543. else if (i == 3)
  544. {
  545. str.Append("<td align=\"left\"><a href=\"#\" onclick=\"OpenInNewWindow('" + GetStatic.GetUrlRoot() + "/Remit/OFACManagement/ComplianceDetail.aspx?id=" + dr["rowId"].ToString() + "&csID=" + dr["csDetailRecId"] + "')\">" + dr[i].ToString() + "</a></td>");
  546. }
  547. else
  548. {
  549. str.Append("<td align=\"left\">" + dr[i].ToString() + "</td>");
  550. }
  551. }
  552. str.Append("</tr>");
  553. }
  554. str.Append("</table>");
  555. displayCompliance.InnerHtml = str.ToString();
  556. string checkFlag = obj.checkFlagCompliance(GetStatic.GetUser(), lblControlNo.Text, hddTranId.Value, "");
  557. if (checkFlag == "Y")
  558. pnlReleaseBtn.Visible = false;
  559. GetStatic.AlertMessage(Page);
  560. }
  561. }
  562. protected void btnApproveCompliance_Click(object sender, EventArgs e)
  563. {
  564. SaveComplianceApproveRemarks();
  565. }
  566. public void ShowCashLimitHoldList()
  567. {
  568. var obj = new TranViewDao();
  569. var ds = obj.DisplayCashLimitHold(GetStatic.GetUser(), lblControlNo.Text, hddTranId.Value, "");
  570. if (ds == null)
  571. {
  572. pnlCashLimitHold.Visible = false;
  573. return;
  574. }
  575. if (ds.Tables[0].Rows.Count > 0)
  576. {
  577. var dt = ds.Tables[0];
  578. int cols = dt.Columns.Count;
  579. var str = new StringBuilder("<table class='table table-responsive table-bordered table-striped'>");
  580. str.Append("<tr>");
  581. for (int i = 2; i < cols; i++)
  582. {
  583. str.Append("<th><div align=\"left\">" + dt.Columns[i].ColumnName + "</div></th>");
  584. }
  585. str.Append("</tr>");
  586. foreach (DataRow dr in dt.Rows)
  587. {
  588. str.Append("<tr>");
  589. for (int i = 2; i < cols; i++)
  590. {
  591. if (i == 4)
  592. {
  593. var strArr = dr["Matched Tran ID"].ToString().Split(',');
  594. var arrlen = strArr.Length;
  595. str.Append("<td>");
  596. for (int j = 0; j < arrlen; j++)
  597. {
  598. str.Append("<a href=\"#\" onclick=\"OpenInNewWindow('/Remit/Transaction/Reports/SearchTransaction.aspx?tranId=" + strArr[j] + "')\">" + strArr[j] + "</a> &nbsp;");
  599. }
  600. str.Append("</td>");
  601. }
  602. else if (i == 3)
  603. {
  604. str.Append("<td align=\"left\"><a href=\"#\" onclick=\"OpenInNewWindow('/Remit/OFACManagement/ComplianceDetail.aspx?id=" + dr["rowId"].ToString() + "')\">" + dr[i].ToString() + "</a></td>");
  605. }
  606. else
  607. {
  608. str.Append("<td align=\"left\">" + dr[i].ToString() + "</td>");
  609. }
  610. }
  611. str.Append("</tr>");
  612. }
  613. str.Append("</table>");
  614. displayCashLimitHold.InnerHtml = str.ToString();
  615. string checkFlag = obj.checkFlagCashLimitHold(GetStatic.GetUser(), lblControlNo.Text, hddTranId.Value, "");
  616. if (checkFlag == "Y")
  617. pnlCashLimitHold.Visible = false;
  618. GetStatic.AlertMessage(Page);
  619. }
  620. }
  621. public void SaveComplianceApproveRemarks()
  622. {
  623. var app = new ApproveTransactionDao();
  624. var obj = new TranViewDao();
  625. //DbResult dbResult = app.PushToApi(GetStatic.GetUser(), lblControlNo.Text, "", true);
  626. //if (dbResult.ErrorCode.Equals("0"))
  627. var dbResult = obj.SaveApproveRemarksComplaince(GetStatic.GetUser(), lblControlNo.Text, hddTranId.Value, remarksCompliance.Text, remarksOFAC.Text, remarksCashLimitHold.Text);
  628. GetStatic.SetMessage(dbResult);
  629. if (dbResult.ErrorCode != "0")
  630. {
  631. GetStatic.AlertMessage(Page);
  632. return;
  633. }
  634. else
  635. {
  636. string url = GetStatic.GetUrlRoot() + "/Remit/Transaction/ApproveOFAC/List.aspx";
  637. Response.Redirect(url);
  638. }
  639. }
  640. public void AddComment()
  641. {
  642. var obj = new TranViewDao();
  643. DbResult dbResult = obj.AddComment(GetStatic.GetUser(), lblControlNo.Text, hddTranId.Value, comments.Text);
  644. ManageMessage(dbResult);
  645. if (dbResult.ErrorCode != "0")
  646. {
  647. GetStatic.CallBackJs1(Page, "Result", "alert('" + dbResult.Msg + "')");
  648. return;
  649. }
  650. else
  651. {
  652. SetupEmailSetting();
  653. SendMail();
  654. }
  655. }
  656. public void AddCommentApi()
  657. {
  658. //GetStatic.AddTroubleTicket(Page, lblControlNo.Text, comments.Text, 2);
  659. AddComment();
  660. }
  661. private delegate void DoStuff(); //delegate for the action
  662. private void SendMail()
  663. {
  664. var myAction = new DoStuff(AsyncMailProcessing);
  665. //invoke it asynchrnously, control passes to next statement
  666. myAction.BeginInvoke(null, null);
  667. }
  668. private void AsyncMailProcessing()
  669. {
  670. var bw = new BackgroundWorker();
  671. // this allows our worker to report progress during work
  672. bw.WorkerReportsProgress = true;
  673. // what to do in the background thread
  674. bw.DoWork += new DoWorkEventHandler(
  675. delegate (object o, DoWorkEventArgs args)
  676. {
  677. var b = o as BackgroundWorker;
  678. smtpMailSetting.SendSmtpMail(smtpMailSetting);
  679. });
  680. // what to do when progress changed (update the progress bar for example)
  681. bw.ProgressChanged += new ProgressChangedEventHandler(
  682. delegate (object o, ProgressChangedEventArgs args)
  683. {
  684. //label1.Text = string.Format("{0}% Completed", args.ProgressPercentage);
  685. });
  686. // what to do when worker completes its task (notify the user)
  687. bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
  688. delegate (object o, RunWorkerCompletedEventArgs args)
  689. {
  690. var dbResult = new DbResult();
  691. dbResult.SetError("0", "Mail Sent Successfully", "");
  692. GetStatic.PrintMessage(Page, dbResult);
  693. });
  694. bw.RunWorkerAsync();
  695. }
  696. private void SetupEmailSetting()
  697. {
  698. var obj = new SystemEmailSetupDao();
  699. var ds = obj.GetDataForEmail(GetStatic.GetUser(), "Trouble", lblControlNo.Text, comments.Text);
  700. if (ds == null)
  701. return;
  702. if (ds.Tables.Count == 0)
  703. return;
  704. if (ds.Tables.Count > 1)
  705. {
  706. //Email Server Settings
  707. if (ds.Tables[0].Rows.Count > 0)
  708. {
  709. var dr1 = ds.Tables[0].Rows[0];
  710. smtpMailSetting.SmtpServer = dr1["smtpServer"].ToString();
  711. smtpMailSetting.SmtpPort = Convert.ToInt32(dr1["smtpPort"]);
  712. smtpMailSetting.SendEmailId = dr1["sendID"].ToString();
  713. smtpMailSetting.SendEmailPwd = dr1["sendPSW"].ToString();
  714. smtpMailSetting.EnableSsl = GetStatic.GetCharToBool(dr1["enableSsl"].ToString());
  715. }
  716. if (ds.Tables[1].Rows.Count == 0)
  717. return;
  718. //Email Receiver
  719. if (ds.Tables[1].Rows.Count > 0)
  720. {
  721. var dt = ds.Tables[1];
  722. foreach (DataRow dr2 in dt.Rows)
  723. {
  724. if (!string.IsNullOrEmpty(smtpMailSetting.ToEmails))
  725. smtpMailSetting.ToEmails = smtpMailSetting.ToEmails + ",";
  726. smtpMailSetting.ToEmails = smtpMailSetting.ToEmails + dr2["email"].ToString();
  727. }
  728. }
  729. //Email Subject and Body
  730. if (ds.Tables[2].Rows.Count > 0)
  731. {
  732. var dr3 = ds.Tables[2].Rows[0];
  733. if (dr3 == null)
  734. return;
  735. smtpMailSetting.MsgSubject = dr3[0].ToString();
  736. smtpMailSetting.MsgBody = dr3[1].ToString();
  737. }
  738. }
  739. }
  740. protected void lbtnTxnAuditTrail_Click(object sender, EventArgs e)
  741. {
  742. Response.Redirect(GetStatic.GetUrlRoot() + "/Remit/Transaction/TxnAuditTrail/View.aspx?controlNo=" + lblControlNo.Text);
  743. }
  744. }
  745. }