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.

202 lines
8.1 KiB

  1. using Swift.DAL.Remittance.Transaction;
  2. using Swift.web.Library;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. namespace Swift.web.AgentNew.SendTxn
  10. {
  11. public partial class Calculator : System.Web.UI.Page
  12. {
  13. private TranCalculator st = new TranCalculator();
  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. populateCollCurr();
  22. PopulateDdl();
  23. //Misc.MakeNumericTextbox(ref txtCollAmt);
  24. Misc.MakeNumericTextbox(ref txtPayAmt);
  25. }
  26. }
  27. private void populateCollCurr()
  28. {
  29. string currencyCode = st.GetCollCurrency(GetStatic.GetUser(), GetStatic.GetCountryId());
  30. lblCollCurr.Text = currencyCode;
  31. lblSendCurr.Text = currencyCode;
  32. lblServiceChargeCurr.Text = currencyCode;
  33. }
  34. private string GetCountry()
  35. {
  36. return GetStatic.ReadQueryString("pCountry", "");
  37. }
  38. private string GetMode()
  39. {
  40. return GetStatic.ReadQueryString("pMode", "");
  41. }
  42. private string GetAgent()
  43. {
  44. return GetStatic.ReadQueryString("pAgent", "");
  45. }
  46. private void PopulateDdl()
  47. {
  48. LoadRecCountry(ref pCountry, GetCountry(), "Select");
  49. LoadReceivingMode(GetMode());
  50. LoadReceivingAgent(GetAgent());
  51. }
  52. private void LoadRecCountry(ref DropDownList ddl, string defaultValue, string label)
  53. {
  54. var sql = "EXEC proc_sendPageLoadData @flag='pCountry', @countryId='" + GetStatic.GetCountryId() + "', @agentid='" + GetStatic.GetAgentId() + "'";
  55. _sdd.SetDDL(ref ddl, sql, "countryId", "countryName", defaultValue, label);
  56. }
  57. protected void Calculate()
  58. {
  59. string pAgentFv = Request.Form["pAgent"];
  60. var calculateBy = "";
  61. if (txtPayAmt.Enabled)
  62. calculateBy = "pAmt";
  63. else if (txtCollAmt.Enabled)
  64. calculateBy = "cAmt";
  65. string currencyCode = st.GetCollCurrency(GetStatic.GetUser(), GetStatic.GetCountryId());
  66. var dt = st.GetExRate(GetStatic.GetUser(), GetStatic.GetSuperAgent(), GetStatic.GetCountryId(), GetStatic.GetAgent(), GetStatic.GetBranch(),
  67. currencyCode, pCountry.Text, pAgentFv, "", pMode.Text, txtCollAmt.Text, txtPayAmt.Text, calculateBy);
  68. var dr = dt.Rows[0];
  69. lblPayCurr.Text = "";
  70. lblSendAmt.Text = "0.00";
  71. lblServiceChargeAmt.Text = "0.00";
  72. lblExRate.Text = "0.00";
  73. if (dr["ErrCode"].ToString() == "1")
  74. {
  75. GetStatic.AlertMessage(Page, dr["Msg"].ToString());
  76. return;
  77. }
  78. txtCollAmt.Text = dr["CollAmt"].ToString();
  79. //txtCollAmt.Text = txtCollAmt.Text.Substring(0, txtCollAmt.Text.Length - cDecimal);
  80. txtPayAmt.Text = dr["pAmt"].ToString();
  81. txtPayAmt.Text = txtPayAmt.Text.Substring(0, txtPayAmt.Text.Length - 2);
  82. lblPayCurr.Text = dr["pCurr"].ToString();
  83. lblExCurr.Text = dr["pCurr"].ToString();
  84. lblSendAmt.Text = dr["sAmt"].ToString();
  85. lblServiceChargeAmt.Text = GetStatic.ShowDecimal(dr["scCharge"].ToString());
  86. lblExRate.Text = dr["exRate"].ToString();
  87. }
  88. protected void pCountry_SelectedIndexChanged(object sender, EventArgs e)
  89. {
  90. if (string.IsNullOrWhiteSpace(pCountry.Text))
  91. {
  92. pMode.Items.Clear();
  93. return;
  94. }
  95. var sql = "EXEC proc_sendPageLoadData @flag ='recModeByCountry'";
  96. sql += ", @countryId = " + _sdd.FilterString(GetStatic.GetCountryId());
  97. sql += ", @pCountryId = " + _sdd.FilterString(pCountry.Text);
  98. sql += ", @param = " + _sdd.FilterString("");
  99. sql += ", @agentId = " + _sdd.FilterString(GetStatic.GetAgentId());
  100. sql += ", @user = " + _sdd.FilterString(GetStatic.GetUser());
  101. _sdd.SetDDL(ref pMode, sql, "serviceTypeId", "typeTitle", "", "Select");
  102. }
  103. protected void pMode_SelectedIndexChanged(object sender, EventArgs e)
  104. {
  105. if (string.IsNullOrWhiteSpace(pMode.Text))
  106. {
  107. pAgent.Items.Clear();
  108. return;
  109. }
  110. string pCountry = Request.Form["pCountry"];
  111. var sql = "EXEC proc_sendPageLoadData @flag ='recAgentByRecModeAjaxagent'";
  112. sql += ", @countryId = " + _sdd.FilterString(GetStatic.GetCountryId());
  113. sql += ", @pCountryId = " + _sdd.FilterString(pCountry);
  114. sql += ", @param = " + _sdd.FilterString(pMode.SelectedItem.Text);
  115. sql += ", @agentId = " + _sdd.FilterString(GetStatic.GetAgentId());
  116. sql += ", @user = " + _sdd.FilterString(GetStatic.GetUser());
  117. _sdd.SetDDL(ref pAgent, sql, "bankId", "AGENTNAME", "", "");
  118. }
  119. private void LoadReceivingMode(string p_Mode)
  120. {
  121. var sql = "EXEC proc_sendPageLoadData @flag ='recModeByCountry'";
  122. sql += ", @countryId = " + _sdd.FilterString(GetStatic.GetCountryId());
  123. sql += ", @pCountryId = " + _sdd.FilterString(pCountry.Text);
  124. sql += ", @param = " + _sdd.FilterString("");
  125. sql += ", @agentId = " + _sdd.FilterString(GetStatic.GetAgentId());
  126. sql += ", @user = " + _sdd.FilterString(GetStatic.GetUser());
  127. _sdd.SetDDL(ref pMode, sql, "serviceTypeId", "typeTitle", p_Mode, "Select");
  128. }
  129. private void LoadReceivingAgent(string p_agent)
  130. {
  131. var sql = "EXEC proc_sendPageLoadData @flag ='recAgentByRecModeAjaxagent'";
  132. sql += ", @countryId = " + _sdd.FilterString(GetStatic.GetCountryId());
  133. sql += ", @pCountryId = " + _sdd.FilterString(pCountry.Text);
  134. sql += ", @param = " + _sdd.FilterString(pMode.SelectedItem.Text);
  135. sql += ", @agentId = " + _sdd.FilterString(GetStatic.GetAgentId());
  136. sql += ", @user = " + _sdd.FilterString(GetStatic.GetUser());
  137. _sdd.SetDDL(ref pAgent, sql, "bankId", "AGENTNAME", p_agent, "");
  138. }
  139. protected void btnCalculate_Click(object sender, EventArgs e)
  140. {
  141. lblErr.Text = "";
  142. if (byPayOutAmt.Checked && txtPayAmt.Text == "")
  143. {
  144. GetStatic.AlertMessage(Page, "Please, Enter the Payout Amount !");
  145. lblErr.Text = "Please, Enter the Payout Amount !";
  146. return;
  147. }
  148. if (bySendAmt.Checked && txtCollAmt.Text == "")
  149. {
  150. GetStatic.AlertMessage(Page, "Please, Enter the Collection Amount !");
  151. lblErr.Text = "Please, Enter the Collection Amount !";
  152. return;
  153. }
  154. if (!string.IsNullOrWhiteSpace(txtCollAmt.Text) && Convert.ToDouble(txtCollAmt.Text) > 0)
  155. Calculate();
  156. else if (!string.IsNullOrWhiteSpace(txtPayAmt.Text) && Convert.ToDouble(txtPayAmt.Text) > 0)
  157. Calculate();
  158. else
  159. {
  160. lblPayCurr.Text = "0.00";
  161. lblSendAmt.Text = "0.00";
  162. lblServiceChargeAmt.Text = "0.00";
  163. lblExRate.Text = "0.00";
  164. GetStatic.AlertMessage(Page, "Need Collection Amount or Payout Amount For Calculation");
  165. }
  166. }
  167. protected void bySendAmt_CheckedChanged(object sender, EventArgs e)
  168. {
  169. txtCollAmt.Enabled = true;
  170. txtPayAmt.Enabled = false;
  171. txtPayAmt.Text = "";
  172. }
  173. protected void byPayOutAmt_CheckedChanged(object sender, EventArgs e)
  174. {
  175. txtCollAmt.Enabled = false;
  176. txtPayAmt.Enabled = true;
  177. txtCollAmt.Text = "";
  178. }
  179. }
  180. }