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.

160 lines
5.7 KiB

  1. using Swift.DAL.BL.Remit.CreditRiskManagement.CreditLimit;
  2. using Swift.DAL.SwiftDAL;
  3. using Swift.web.Library;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Web;
  9. using System.Web.UI;
  10. using System.Web.UI.WebControls;
  11. namespace Swift.web.Remit.InternationalOperation.CreditLimit
  12. {
  13. public partial class Manage : System.Web.UI.Page
  14. {
  15. private const string ViewFunctionId = "30011000";
  16. private const string AddEditFunctionId = "30011010";
  17. private readonly CreditLimitIntDao obj = new CreditLimitIntDao();
  18. private readonly StaticDataDdl sdd = new StaticDataDdl();
  19. private readonly RemittanceLibrary sl = new RemittanceLibrary();
  20. protected void Page_Load(object sender, EventArgs e)
  21. {
  22. msg.Visible = false;
  23. Authenticate();
  24. if (!IsPostBack)
  25. {
  26. expiryDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
  27. expiryDate.Attributes.Add("readonly", "readonly");
  28. //PopulateAgentAcDetail();
  29. MakeNumericTextBox();
  30. if (GetId() > 0)
  31. {
  32. PopulateDataById();
  33. }
  34. else
  35. {
  36. PopulateDdl(null);
  37. }
  38. }
  39. }
  40. //private void PopulateAgentAcDetail()
  41. //{
  42. // var dr = obj.SelectAgentAcDetail(GetStatic.GetUser(), GetAgentId().ToString());
  43. // if (dr == null)
  44. // return;
  45. // currentBal.Text = GetStatic.FormatData(dr["currentBalance"].ToString(), "M");
  46. // currentBalCurr.Text = dr["acBalCurr"].ToString();
  47. // currentAvailable.Text = GetStatic.FormatData(dr["currentAvailable"].ToString(), "M");
  48. // currentAvailableCurr.Text = dr["acBalCurr"].ToString();
  49. // sentCount.Text = dr["todaysSentCount"].ToString();
  50. // sentAmount.Text = GetStatic.FormatData(dr["todaysSentAmount"].ToString(), "M");
  51. // sentAmountCurr.Text = dr["sentAmountCurr"].ToString();
  52. // paidCount.Text = dr["todaysPaidCount"].ToString();
  53. // paidAmount.Text = GetStatic.FormatData(dr["todaysPaidAmount"].ToString(), "M");
  54. // paidAmountCurr.Text = dr["paidAmountCurr"].ToString();
  55. // cancelledCount.Text = dr["todaysCancelledCount"].ToString();
  56. // cancelledAmount.Text = GetStatic.FormatData(dr["todaysCancelledAmount"].ToString(), "M");
  57. // cancelledAmountCurr.Text = dr["cancelledAmountCurr"].ToString();
  58. //}
  59. private void MakeNumericTextBox()
  60. {
  61. Misc.MakeNumericTextbox(ref limitAmt);
  62. Misc.MakeNumericTextbox(ref maxLimitAmt);
  63. Misc.MakeNumericTextbox(ref perTopUpLimit);
  64. Misc.MakeAmountTextBox(ref limitAmt);
  65. Misc.MakeAmountTextBox(ref maxLimitAmt);
  66. Misc.MakeAmountTextBox(ref perTopUpLimit);
  67. }
  68. protected void btnDelete_Click(object sender, EventArgs e)
  69. {
  70. DeleteRow();
  71. }
  72. #region Method
  73. protected string GetAgentName()
  74. {
  75. return "Agent Name : " + sl.GetAgentName(GetAgentId().ToString());
  76. }
  77. private long GetId()
  78. {
  79. return GetStatic.ReadNumericDataFromQueryString("crLimitId");
  80. }
  81. protected long GetAgentId()
  82. {
  83. return GetStatic.ReadNumericDataFromQueryString("agentId");
  84. }
  85. protected long GetAgentCountryId()
  86. {
  87. return GetStatic.ReadNumericDataFromQueryString("countryId");
  88. }
  89. private void Authenticate()
  90. {
  91. sl.CheckAuthentication(ViewFunctionId + "," + AddEditFunctionId);
  92. }
  93. private void PopulateDdl(DataRow dr)
  94. {
  95. sdd.SetDDL(ref currency, "EXEC proc_dropDownLists2 @flag = 'sCountryWiseCurr',@param=" + GetAgentId() + "", "currencyCode", "currencyCode",
  96. GetStatic.GetRowData(dr, "currency"), "");
  97. }
  98. private void PopulateDataById()
  99. {
  100. DataRow dr = obj.SelectById(GetStatic.GetUser(), GetId().ToString());
  101. if (dr == null)
  102. return;
  103. limitAmt.Text = GetStatic.FormatDataForForm(dr["limitAmt"].ToString(), "M");
  104. maxLimitAmt.Text = GetStatic.FormatDataForForm(dr["maxLimitAmt"].ToString(), "M");
  105. perTopUpLimit.Text = GetStatic.FormatDataForForm(dr["perTopUpAmt"].ToString(), "M");
  106. expiryDate.Text = dr["expiryDate1"].ToString();
  107. PopulateDdl(dr);
  108. }
  109. private void Update()
  110. {
  111. DbResult dbResult = obj.Update(GetStatic.GetUser(), GetId().ToString(), GetAgentId().ToString(),
  112. currency.Text, limitAmt.Text, perTopUpLimit.Text, maxLimitAmt.Text,
  113. expiryDate.Text);
  114. ManageMessage(dbResult);
  115. }
  116. private void DeleteRow()
  117. {
  118. DbResult dbResult = obj.Delete(GetStatic.GetUser(), GetId().ToString());
  119. ManageMessage(dbResult);
  120. }
  121. private void ManageMessage(DbResult dbResult)
  122. {
  123. var mes = GetStatic.ParseResultJsPrint(dbResult);
  124. mes = mes.Replace("<center>", "");
  125. mes = mes.Replace("</center>", "");
  126. msg.Visible = true;
  127. msg.Text = mes;
  128. var scriptName = "CallBack";
  129. var functionName = "CallBack('" + mes + "');";
  130. GetStatic.CallBackJs1(Page, scriptName, functionName);
  131. }
  132. #endregion
  133. #region Element Method
  134. protected void btnSave_Click(object sender, EventArgs e)
  135. {
  136. Update();
  137. }
  138. #endregion
  139. }
  140. }