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.

185 lines
6.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.SendingLimit
  8. {
  9. public partial class Manage : Page
  10. {
  11. private const string ViewFunctionId = "30011400";
  12. private const string AddEditFunctionId = "30011410";
  13. private readonly SendTranLimitDao obj = new SendTranLimitDao();
  14. private readonly StaticDataDdl sdd = new StaticDataDdl();
  15. private readonly SwiftLibrary sl = new SwiftLibrary();
  16. protected void Page_Load(object sender, EventArgs e)
  17. {
  18. sl.CheckSession();
  19. if (!IsPostBack)
  20. {
  21. //Authenticate();
  22. MakeNumericTextBox();
  23. if (GetId() > 0)
  24. {
  25. btnApplyForAllCountry.Visible = false;
  26. PopulateDataById();
  27. }
  28. else
  29. {
  30. PopulateDdl(null);
  31. }
  32. }
  33. }
  34. private void MakeNumericTextBox()
  35. {
  36. Misc.MakeNumericTextbox(ref minLimitAmt);
  37. Misc.MakeAmountTextBox(ref minLimitAmt);
  38. Misc.MakeAmountTextBox(ref maxLimitAmt);
  39. Misc.MakeAmountTextBox(ref maxLimitAmt);
  40. }
  41. protected void btnDelete_Click(object sender, EventArgs e)
  42. {
  43. DeleteRow();
  44. }
  45. #region Method
  46. protected string GetCountryName()
  47. {
  48. return "Country : " + GetCountry();
  49. }
  50. private string GetCountry()
  51. {
  52. return GetStatic.ReadQueryString("countryName", "");
  53. }
  54. private long GetId()
  55. {
  56. return GetStatic.ReadNumericDataFromQueryString("stlId");
  57. }
  58. protected string GetCountryId()
  59. {
  60. return GetStatic.ReadQueryString("countryId", "");
  61. }
  62. private void Authenticate()
  63. {
  64. sdd.CheckAuthentication(ViewFunctionId + "," + AddEditFunctionId);
  65. }
  66. private void PopulateDdl(DataRow dr)
  67. {
  68. sdd.SetDDL(ref receivingCountry, "EXEC proc_countryMaster @flag = 'rcl'", "countryId", "countryName",
  69. GetStatic.GetRowData(dr, "receivingCountry"), "Select");
  70. //sdd.SetStaticDdl3(ref collMode, "2200", GetStatic.GetRowData(dr, "tranType"), "Any");
  71. LoadCollMode(GetCountryId(), GetStatic.GetRowData(dr, "collMode"));
  72. LoadReceivingMode(receivingCountry.Text, GetStatic.GetRowData(dr, "tranType"));
  73. //sdd.SetDDL3(ref receivingMode, "EXEC proc_serviceTypeMaster @flag = 'l2'", "serviceTypeId", "typeTitle", GetStatic.GetRowData(dr, "paymentType"), "Any");
  74. sdd.SetDDL(ref currency, "EXEC proc_countryCurrency @flag = 'l2', @countryId=" + sdd.FilterString(GetCountryId()), "currencyId", "currencyCode",
  75. GetStatic.GetRowData(dr, "currency"), "");
  76. sdd.SetStaticDdl(ref customerType, "4700", GetStatic.GetRowData(dr, "customerType"), "Any");
  77. }
  78. private void PopulateDataById()
  79. {
  80. DataRow dr = obj.SelectById(GetStatic.GetUser(), GetId().ToString());
  81. if (dr == null)
  82. return;
  83. minLimitAmt.Text = GetStatic.FormatData(dr["minLimitAmt"].ToString(), "M");
  84. maxLimitAmt.Text = GetStatic.FormatData(dr["maxlimitAmt"].ToString(), "M");
  85. PopulateDdl(dr);
  86. }
  87. private void LoadCollMode(string countryId, string defaultValue)
  88. {
  89. sdd.SetDDL(ref collMode, "EXEC proc_dropDownLists @flag = 'collModeByCountry', @param = " + sdd.FilterString(countryId), "valueId", "detailTitle", defaultValue, "Any");
  90. }
  91. private void LoadReceivingMode(string countryId, string defaultValue)
  92. {
  93. sdd.SetDDL(ref receivingMode, "EXEC proc_dropDownLists @flag = 'recModeByCountry', @param = " + sdd.FilterString(countryId), "serviceTypeId", "typeTitle", defaultValue, "Any");
  94. }
  95. private void Update()
  96. {
  97. DbResult dbResult = obj.Update(GetStatic.GetUser()
  98. , GetId().ToString()
  99. , ""
  100. , GetCountryId().ToString()
  101. , ""
  102. , receivingCountry.Text
  103. ,""
  104. , minLimitAmt.Text
  105. , maxLimitAmt.Text
  106. , currency.Text
  107. , collMode.Text
  108. , receivingMode.Text
  109. , customerType.Text);
  110. ManageMessage(dbResult);
  111. }
  112. private void ApplyForAllCountry()
  113. {
  114. var dbResult = obj.ApplyForAllCountry(GetStatic.GetUser()
  115. , ""
  116. , GetCountryId().ToString()
  117. , ""
  118. , receivingCountry.Text
  119. , minLimitAmt.Text
  120. , maxLimitAmt.Text
  121. , currency.Text
  122. , collMode.Text
  123. , receivingMode.Text
  124. , customerType.Text);
  125. ManageMessage(dbResult);
  126. }
  127. private void DeleteRow()
  128. {
  129. DbResult dbResult = obj.Delete(GetStatic.GetUser(), GetId().ToString());
  130. ManageMessage(dbResult);
  131. }
  132. private void ManageMessage(DbResult dbResult)
  133. {
  134. GetStatic.SetMessage(dbResult);
  135. if (dbResult.ErrorCode == "0")
  136. {
  137. Response.Redirect("List.aspx?countryId=" + GetCountryId());
  138. }
  139. else
  140. {
  141. GetStatic.PrintMessage(Page);
  142. }
  143. }
  144. #endregion
  145. #region Element Method
  146. protected void btnSave_Click(object sender, EventArgs e)
  147. {
  148. Update();
  149. }
  150. #endregion
  151. protected void receivingCountry_SelectedIndexChanged(object sender, EventArgs e)
  152. {
  153. LoadReceivingMode(receivingCountry.Text, "");
  154. receivingCountry.Focus();
  155. }
  156. protected void btnApplyForAllCountry_Click(object sender, EventArgs e)
  157. {
  158. ApplyForAllCountry();
  159. }
  160. }
  161. }