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.

60 lines
2.1 KiB

  1. using Swift.DAL.Remittance.CashAndVault;
  2. using Swift.DAL.SwiftDAL;
  3. using Swift.web.Library;
  4. using System;
  5. namespace Swift.web.AgentPanel.TransferToVault
  6. {
  7. public partial class TransferToVault : System.Web.UI.Page
  8. {
  9. protected const string GridName = "TransferToVault";
  10. private string ViewFunctionId = "20179000";
  11. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  12. private CashAndVaultDao cavDao = new CashAndVaultDao();
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. if (!IsPostBack)
  16. {
  17. Authenticate();
  18. Misc.MakeNumericTextbox(ref amount);
  19. transferDate.Text = DateTime.Today.ToString("yyyy-MM-dd");
  20. PopulateBranchDetails();
  21. }
  22. }
  23. private void PopulateBranchDetails()
  24. {
  25. var row = cavDao.GetBranchCashDetails(GetStatic.GetUser(), GetStatic.GetBranch(), "");
  26. cashAtCounter.Text = GetStatic.ShowDecimal(row["cashAtCounterUser"].ToString());
  27. }
  28. private void Authenticate()
  29. {
  30. _sl.CheckAuthentication(ViewFunctionId);
  31. }
  32. protected void Transfer_Click(object sender, EventArgs e)
  33. {
  34. var amountVal = amount.Text;
  35. var tDateVal = transferDate.Text;
  36. var userIdAndAgentId = cavDao.GetUserIdAndBranch(GetStatic.GetUser(), amountVal, "counter");
  37. if (userIdAndAgentId["errorCode"].ToString() != "0")
  38. {
  39. GetStatic.AlertMessage(this, userIdAndAgentId["msg"].ToString());
  40. return;
  41. }
  42. var res = cavDao.SaveTransferToVault(GetStatic.GetUser(), amountVal, tDateVal, userIdAndAgentId["userId"].ToString(), userIdAndAgentId["agentId"].ToString());
  43. if (res == null)
  44. {
  45. var dbRes = new DbResult()
  46. {
  47. ErrorCode = "0",
  48. Msg = "Transfer to vault saved successfully"
  49. };
  50. GetStatic.SetMessage(dbRes);
  51. Response.Redirect("RequestedTransferToVaultList.aspx");
  52. }
  53. }
  54. }
  55. }