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.
 
 
 
 
 

391 lines
16 KiB

using Business.Configuration;
using Business.Customer;
using Common.Helper;
using Common.Model.BankModel;
using JMEAgentSystem.Library;
using Newtonsoft.Json;
using Repository.DAO;
using Repository.DAO.SendTxnIRHDao;
using Repository.Model;
using Repository.ThirdPartyApiServices;
using Swift.API.Common;
using Swift.API.Common.ExRate;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace JMEAgentSystem.WebPages.SendTxn
{
public partial class SendTxnRequest : System.Web.UI.Page
{
private readonly ICustomerServices _customerServices = AutoFacContainer.Resolve<ICustomerServices>();
private readonly StaticDataDdl _sdd = new StaticDataDdl();
private readonly SendTxnIRHDao st = new SendTxnIRHDao();
RemittanceDao _rdao = new RemittanceDao();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
GetStatic.PrintMessage(this.Page);
populateDdl();
var methodName = GetStatic.ReadFormData("MethodName", "");
switch (methodName)
{
case "PaymentModePcountry":
LoadDataFromDdl("pMode");
break;
case "loadAgentBank":
LoadDataFromDdl("agentByPmode");
break;
case "getPayoutPartner":
GetPayoutPartner();
break;
case "PopulateBranch":
GetBankBranch();
break;
case "CalculateTxn":
Calculate();
break;
case "loadCustomerDataSendPage":
LoadCustomerDataSendPage();
break;
case "getBenefeciaryDetails":
GetBenefeciaryDetails();
break;
}
}
catch (Exception ex)
{
}
}
}
private void GetBenefeciaryDetails()
{
string benefeciaryId = Request.Form["BenefeciaryId"];
if (string.IsNullOrWhiteSpace(benefeciaryId))
{
GetStatic.JsonResponse(new { errorCode = "1", Msg = "Invalid Receiver selected" }, this);
}
var receiverData = st.GetBenefeciaryDetails(GetStatic.GetUser(), benefeciaryId);
Response.ContentType = "text/plain";
var json = _rdao.DataTableToJson(receiverData);
Response.Write(json);
Response.End();
}
private void LoadCustomerDataSendPage()
{
string customerIdNumber = Request.Form["CustomerIdNumber"];
if (string.IsNullOrWhiteSpace(customerIdNumber))
{
GetStatic.JsonResponse(new { errorCode = "1", Msg = "Customer ID Number can not be blak" }, this);
}
var receiverList = st.ValidateData(GetStatic.GetUser(), customerIdNumber);
Response.ContentType = "text/plain";
var json = _rdao.DataTableToJson(receiverList);
Response.Write(json);
Response.End();
}
public void populateDdl()
{
LoadReceiverCountry(ref pCountry, "", "SELECT");
_sdd.SetDDL(ref relationship, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=2100", "valueId", "detailTitle", "", "Select..");
_sdd.SetDDL(ref purpose, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=3800", "valueId", "detailTitle", "8060", "Select..");
}
private void LoadDataFromDdl(string type)
{
var pAgentFv = Request.Form["pAgent"];
var pModeFv = Request.Form["pmode"];
var pCountryFv = Request.Form["pCountry"];
DataTable dt = null;
switch (type)
{
case "pMode":
dt = st.LoadDataFromDdl(GetStatic.GetCountryId(), pCountryFv, pModeFv, GetStatic.GetAgent(), "recModeByCountry", GetStatic.GetUser());
break;
case "agentByPmode":
if (string.IsNullOrWhiteSpace(pModeFv) || string.IsNullOrWhiteSpace(pCountryFv))
{
Response.Write(null);
Response.End();
return;
}
dt = st.LoadDataFromDdl(GetStatic.GetCountryId(), pCountryFv, pModeFv, GetStatic.GetAgent(), "recAgentByRecModeAjaxagent", GetStatic.GetUser());
break;
case "LoadScheme":
dt = st.LoadDataFromDdl(GetStatic.GetCountryId(), pCountryFv, pModeFv, pAgentFv, "schemeBysCountryrAgent", GetStatic.GetUser());
break;
}
Response.ContentType = "text/plain";
var json = _rdao.DataTableToJson(dt);
Response.Write(json);
Response.End();
}
private void LoadReceiverCountry(ref DropDownList ddl, string defaultValue, string label)
{
var sql = "EXEC proc_sendPageLoadData @flag='pCountry',@countryId='" + GetStatic.GetCountryId() + "',@agentid='" + GetStatic.GetAgentId() + "'";
_sdd.SetDDL(ref ddl, sql, "countryId", "countryName", defaultValue, label);
}
private void GetPayoutPartner()
{
string pCountry = Request.Form["pCountry"];
string pMode = Request.Form["pMode"];
//var dt = st.LoadCustomerData(searchType, searchValue, "s", GetStatic.GetCountryId(), GetStatic.GetSettlingAgent());
var dt = st.GetPayoutPartner(GetStatic.GetUser(), pCountry, pMode);
if (dt == null)
{
Response.Write("");
Response.End();
return;
}
Response.ContentType = "text/plain";
string json = DataTableToJson(dt);
Response.Write(json);
Response.End();
}
public static string DataTableToJson(DataTable table)
{
if (table == null)
return "";
var list = new List<Dictionary<string, object>>();
foreach (DataRow row in table.Rows)
{
var dict = new Dictionary<string, object>();
foreach (DataColumn col in table.Columns)
{
dict[col.ColumnName] = string.IsNullOrEmpty(row[col].ToString()) ? "" : row[col];
}
list.Add(dict);
}
var serializer = new JavaScriptSerializer();
string json = serializer.Serialize(list);
return json;
}
public string GetAPIPartnerId()
{
string partnerIds = GetStatic.ReadWebConfig("transfast", "") + "," + GetStatic.ReadWebConfig("jmeNepal", "") + "," + GetStatic.ReadWebConfig("donga", "");
return partnerIds;
}
protected void GetBankBranch()
{
string bank = Request.Form["Bank"];
string Country = Request.Form["Country"];
string searchText = Request.Form["searchText"];
string page = Request.Form["page"];
if (string.IsNullOrWhiteSpace(bank))
{
GetStatic.JsonResponse("", this);
}
BankSearchModel bankSearchModel = new BankSearchModel()
{
SearchType = "",
SearchValue = searchText,
PAgent = bank,
PAgentType = "I",
PCountryName = Country,
PayoutPartner = Request.Form["payoutPartner"],
PaymentMode = Request.Form["PayMode"]
};
IList<BranchModel> bankModelList = st.LoadBranchByAgent(bankSearchModel);
GetStatic.JsonResponse(bankModelList, this);
//JsonSerialize(bankModelList);
}
protected void Calculate()
{
DataTable dt = new DataTable();
ExRateRequest exRate = new ExRateRequest();
ExchangeRateAPIService ExService = new ExchangeRateAPIService();
exRate.RequestedBy = "core";
string a = Request.Form["IsExrateFromPartner"];
exRate.isExRateCalcByPartner = (Request.Form["IsExrateFromPartner"] == "true") ? true : false;
exRate.PCountry = Request.Form["pCountry"];
exRate.pCountryName = Request.Form["pCountrytxt"];
exRate.ServiceType = Request.Form["pMode"];
exRate.PaymentType = Request.Form["pModetxt"];
exRate.PAgent = Request.Form["pAgent"];
var pAgentBranch = Request.Form["pAgentBranch"];
exRate.CAmount = Request.Form["collAmt"];
exRate.PAmount = Request.Form["payAmt"];
exRate.SCurrency = Request.Form["collCurr"];
exRate.PCurrency = Request.Form["payCurr"];
exRate.CustomerId = Request.Form["senderId"];
exRate.SchemeId = Request.Form["schemeCode"];
exRate.ForexSessionId = Request.Form["couponId"];
exRate.IsManualSc = (Request.Form["isManualSc"] == "N" ? false : true);
exRate.ManualSc = Request.Form["sc"];
if (exRate.isExRateCalcByPartner)
{
exRate.SCountry = GetStatic.GetCountryId();
exRate.SSuperAgent = GetStatic.GetSuperAgent();
exRate.SAgent = GetStatic.GetAgent();
exRate.SBranch = GetStatic.GetBranch();
exRate.CollCurrency = Request.Form["collCurr"];
exRate.pCountryCode = Request.Form["PCountryCode"];
exRate.ProviderId = Request.Form["payoutPartner"];
string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":transfast:exRate";
exRate.ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40);
JsonResponse res = ExService.GetExchangeRate(exRate);
ExRateResponse _exrate = (ExRateResponse)res.Data;
//dt = st.GetExRateTP(GetStatic.GetUser()
// , GetStatic.GetCountryId()
// , GetStatic.GetSuperAgent()
// , GetStatic.GetAgent()
// , GetStatic.GetBranch()
// , exRate.SCurrency
// , exRate.PCountry
// , exRate.PAgent
// , exRate.PCurrency
// , exRate.ServiceType
// , exRate.CAmount
// , exRate.PAmount
// , exRate.SchemeId
// , exRate.CustomerId
// //, GetStatic.GetSessionId()
// , exRate.ForexSessionId
// , Request.Form["isManualSc"]
// , exRate.ManualSc
// , _exrate.exRate
// , exRate.PCurrency
// );
}
else
{
dt = st.GetExRate(GetStatic.GetUser()
, GetStatic.GetCountryId()
, "393877"
, "394390"
, "394390"
, exRate.SCurrency
, exRate.PCountry
, exRate.PAgent
, exRate.PCurrency
, exRate.ServiceType
, exRate.CAmount
, exRate.PAmount
, exRate.SchemeId
, exRate.CustomerId
//, GetStatic.GetSessionId()
, exRate.ForexSessionId
, "N"
, "N"
);
}
Response.ContentType = "text/plain";
var json = DataTableToJson(dt);
Response.Write(json);
Response.End();
}
protected void Save_Click(object sender, EventArgs e)
{
var idNumber = senderIdNumber.Text;
var receiverFullNameValue = receiverFullName.Text;
var receiveraddressValue = receiveraddress.Text;
var receiverMobileNumberValue = receiverMobileNumber.Text;
var pCountryId = pCountry.SelectedValue;
var pmodeId = hddPmode.Value;
var pagentId = hddPagent.Value;
var branchId = hddpBranch.Value;
var accountnoValue = accountNo.Text;
var cAmt = txtCollAmt.Text;
var tamt = hddTamt.Value;
var serviceCharge = hddServiceCharge.Value;
var purposeOfRemittanceId = purpose.SelectedValue;
var otherPurpose = purposeOther.Text;
var relationShipId = relationship.SelectedValue;
var otherRelation = otherRelationshipTextBox.Text;
var referralNameValue = referralName.Text;
var collectionMode = ddlCollMode.SelectedValue;
SendTransactionModel sendTxn = new SendTransactionModel()
{
IdNumber = idNumber,
ReceiverFullName = receiverFullNameValue,
Receiveraddress = receiveraddressValue,
ReceiverMobileNumber = receiverMobileNumberValue,
PCountryId = pCountryId,
PmodeId = pmodeId,
PagentId = pagentId,
BranchId = branchId,
AccountNumber = accountnoValue,
CAmt = cAmt,
Tamt = tamt,
ServiceCharge = serviceCharge,
PurposeOfRemittance = purposeOfRemittanceId,
OtherPurposeOfRemittance = otherPurpose,
RelationShip = relationShipId,
OtherRelationShip = otherRelation,
ReferralName = referralNameValue,
BranchManual = branch_manual.Text,
bankName = hddPagentName.Value,
branchName = hddPBranchName.Value,
collMode = collectionMode
};
var result = st.SaveSendRequest(GetStatic.GetUser(), sendTxn);
if(result.ErrorCode == "0")
{
if (result.ErrorCode == "0" && !string.IsNullOrEmpty(hddImgURL.Value) && !string.IsNullOrWhiteSpace(hddImgURL.Value))
{
var res = _customerServices.GetCustomerDetailsForFileUpload(result.Extra.Split('|')[0]).Split('|');
var customerId = res[0];
var membershipId = res[1];
var registerDate = res[2];
string signatureName = GetStatic.UploadSignatureImage(hddImgURL.Value, registerDate, membershipId, customerId);
if (signatureName != "1")
{
_customerServices.AddCustomerSignature(customerId, GetStatic.GetUser(), signatureName, "agent-upload-txn", result.Id);
}
}
var url = ("PrintSendMoneyRequestDetails.aspx?customerId=" + result.Extra.Split('|')[1] + "&rowId=" + result.Id);
Response.Redirect(url);
}
else
{
pCountry.SelectedValue = "";
GetStatic.AlertMessage(this.Page, result.Msg);
}
}
}
}