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.

163 lines
5.7 KiB

  1. using System;
  2. using System.Data;
  3. using System.Web.UI;
  4. using Swift.DAL.BL.Remit.CreditRiskManagement.TransactionLimit;
  5. using Swift.DAL.SwiftDAL;
  6. using Swift.web.Library;
  7. namespace Swift.web.Remit.CreditRiskManagement.TransactionLimit.Countrywise.ReceivingLimit
  8. {
  9. public partial class Manage : Page
  10. {
  11. private const string ViewFunctionId = "20181000";
  12. private const string AddEditFunctionId = "20181010";
  13. private readonly ReceiveTranLimitDao obj = new ReceiveTranLimitDao();
  14. private readonly StaticDataDdl sdd = new StaticDataDdl();
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. Authenticate();
  18. if (!IsPostBack)
  19. {
  20. MakeNumericTextBox();
  21. if (GetId() > 0)
  22. {
  23. PopulateDataById();
  24. }
  25. else
  26. {
  27. PopulateDdl(null);
  28. }
  29. }
  30. }
  31. private void MakeNumericTextBox()
  32. {
  33. Misc.MakeNumericTextbox(ref maxLimitAmt);
  34. Misc.MakeNumericTextbox(ref agMaxLimitAmt);
  35. Misc.MakeAmountTextBox(ref maxLimitAmt);
  36. Misc.MakeAmountTextBox(ref agMaxLimitAmt);
  37. }
  38. protected void btnDelete_Click(object sender, EventArgs e)
  39. {
  40. DeleteRow();
  41. }
  42. #region Method
  43. protected string GetCountryName()
  44. {
  45. return "Country : " + GetCountry();
  46. }
  47. private long GetId()
  48. {
  49. return GetStatic.ReadNumericDataFromQueryString("rtlId");
  50. }
  51. private string GetCountry()
  52. {
  53. return GetStatic.ReadQueryString("countryName", "");
  54. }
  55. protected string GetCountryId()
  56. {
  57. return GetStatic.ReadQueryString("countryId", "");
  58. }
  59. private void Authenticate()
  60. {
  61. sdd.CheckAuthentication(ViewFunctionId + "," + AddEditFunctionId);
  62. }
  63. private void PopulateDdl(DataRow dr)
  64. {
  65. sdd.SetDDL(ref sendingCountry, "EXEC proc_countryMaster @flag = 'scl'", "countryId", "countryName",
  66. GetStatic.GetRowData(dr, "sendingCountry"), "Any");
  67. LoadReceivingMode(GetCountryId(), GetStatic.GetRowData(dr, "tranType"));
  68. //sdd.SetDDL3(ref tranType, "EXEC proc_serviceTypeMaster @flag = 'l2'", "serviceTypeId", "typeTitle",
  69. // GetStatic.GetRowData(dr, "tranType"), "Any");
  70. sdd.SetDDL(ref currency, "EXEC proc_countryCurrency @flag = 'l2', @countryId=" + sdd.FilterString(GetCountryId()), "currencyId", "currencyCode",
  71. GetStatic.GetRowData(dr, "currency"), "");
  72. sdd.SetStaticDdl(ref customerType, "4700", GetStatic.GetRowData(dr, "customerType"), "Any");
  73. }
  74. private void PopulateDataById()
  75. {
  76. DataRow dr = obj.SelectById(GetStatic.GetUser(), GetId().ToString());
  77. if (dr == null)
  78. return;
  79. maxLimitAmt.Text = dr["maxLimitAmt"].ToString();
  80. agMaxLimitAmt.Text = dr["agMaxLimitAmt"].ToString();
  81. branchSelection.SelectedValue = dr["branchSelection"].ToString();
  82. benificiaryIdreq.SelectedValue = dr["benificiaryIdReq"].ToString();
  83. relationshipReq.SelectedValue = dr["relationshipReq"].ToString();
  84. benificiaryContactReq.SelectedValue = dr["benificiaryContactReq"].ToString();
  85. PopulateDdl(dr);
  86. }
  87. private void Update()
  88. {
  89. if (Convert.ToDecimal(maxLimitAmt.Text) < 0)
  90. {
  91. GetStatic.PrintErrorMessage(Page, "Max limit amount cannot be less than zero");
  92. return;
  93. }
  94. DbResult dbResult = obj.UpdateCountryWise(GetStatic.GetUser()
  95. , GetId().ToString()
  96. , ""
  97. , GetCountryId().ToString()
  98. , ""
  99. , sendingCountry.Text
  100. , maxLimitAmt.Text
  101. , agMaxLimitAmt.Text
  102. , currency.Text
  103. , receivingMode.Text
  104. , customerType.Text
  105. , branchSelection.Text
  106. , benificiaryIdreq.Text
  107. , relationshipReq.Text
  108. , benificiaryContactReq.Text);
  109. ManageMessage(dbResult);
  110. }
  111. private void DeleteRow()
  112. {
  113. DbResult dbResult = obj.Delete(GetStatic.GetUser(), GetId().ToString());
  114. ManageMessage(dbResult);
  115. }
  116. private void ManageMessage(DbResult dbResult)
  117. {
  118. GetStatic.SetMessage(dbResult);
  119. if (dbResult.ErrorCode == "0")
  120. {
  121. Response.Redirect("List.aspx?countryId=" + GetCountryId());
  122. }
  123. else
  124. {
  125. GetStatic.PrintMessage(Page);
  126. }
  127. }
  128. #endregion
  129. #region Element Method
  130. protected void btnSave_Click(object sender, EventArgs e)
  131. {
  132. Update();
  133. }
  134. #endregion
  135. private void LoadReceivingMode(string countryId, string defaultValue)
  136. {
  137. sdd.SetDDL(ref receivingMode, "EXEC proc_dropDownLists @flag = 'recModeByCountry', @param = " + sdd.FilterString(countryId), "serviceTypeId", "typeTitle", defaultValue, "Any");
  138. }
  139. }
  140. }