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.
 
 
 
 
 

223 lines
8.3 KiB

using Newtonsoft.Json;
using Swift.API.Common;
using Swift.API.ThirdPartyApiServices;
using Swift.DAL.BL.Remit.Transaction;
using Swift.DAL.Remittance.CustomerDeposits;
using Swift.DAL.SwiftDAL;
using Swift.web.Library;
using System;
using System.Data;
using System.Threading.Tasks;
namespace Swift.web.Remit.Transaction.ApproveTxn
{
public partial class Manage : System.Web.UI.Page
{
private const string ViewFunctionId = "20122800";
private readonly StaticDataDdl _sdd = new StaticDataDdl();
private readonly ApproveTransactionDao atd = new ApproveTransactionDao();
private readonly CustomerDepositDao _dao = new CustomerDepositDao();
protected void Page_Load(object sender, EventArgs e)
{
Authenticate();
// GetStatic.AttachConfirmMsg(ref btnApprove, "Are you sure to APPROVE this transaction?");
if (!IsPostBack)
{
}
LoadTransaction();
if (GetRequest() == "v")
{
btnApprove.Text = "Verify";
GetStatic.AttachConfirmMsg(ref btnApprove, "Are you sure to verify this transaction?");
}
else
{
GetStatic.AttachConfirmMsg(ref btnApprove, "Are you sure to approve this transaction?");
}
}
private void Authenticate()
{
_sdd.CheckAuthentication(ViewFunctionId);
}
private void LoadTransaction()
{
string tranNo = GetTranNo();
ucTran.SearchData(tranNo, "", "", "", "APPROVE", "ADMIN: VIEW TXN TO APPROVE");
ucTran.isFromApproveTxn = "Y";
divTranDetails.Visible = ucTran.TranFound;
if (!ucTran.TranFound)
{
divControlno.InnerHtml = "<h2>No Transaction Found</h2>";
return;
}
}
protected string GetTranNo()
{
return GetStatic.ReadQueryString("id", "");
}
protected string GetRequest()
{
return GetStatic.ReadQueryString("requestFrom", "");
}
private void Approve()
{
DbResult _dbRes = atd.GetTxnApproveDataIMEPay(GetStatic.GetUser(), GetTranNo());
if (_dbRes.ErrorCode != "0")
{
GetStatic.PrintMessage(Page, _dbRes);
return;
}
if (_dbRes.Extra2 == "True")//is realtime
{
SendTransactionServices _tpSend = new SendTransactionServices();
string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":" + _dbRes.Extra1 + ":releaseTxn";
var result = _tpSend.ReleaseTransaction(new TFReleaseTxnRequest()
{
TfPin = _dbRes.Id,
TxnId = _dbRes.Extra,
RequestBy = GetStatic.GetUser(),
ProviderId = _dbRes.Extra1,
ProcessId = ProcessId.Substring(ProcessId.Length - 40, 40)
});
_dbRes.ErrorCode = result.ResponseCode;
_dbRes.Msg = result.Msg;
_dbRes.Id = "";
if (_dbRes.ErrorCode != "0")
{
GetStatic.AlertMessage(Page, _dbRes.ErrorCode + " " + _dbRes.Msg);
GetStatic.CallJSFunction(Page, "window.returnValue = true; window.close();");
LoadTransaction();
return;
}
else
{
var dr = atd.ApproveHoldedTXN(GetStatic.GetUser(), GetTranNo());
GetStatic.AlertMessage(Page, dr.Msg);
if (dr.ErrorCode.Equals("0"))
{
GetStatic.CallJSFunction(Page, "window.returnValue = true; window.close();");
LoadTransaction();
return;
}
}
}
else
{
var dr = atd.ApproveHoldedTXN(GetStatic.GetUser(), GetTranNo());
// SendApprovalMailToCustomers();
GetStatic.AlertMessage(Page, dr.Msg);
if (dr.ErrorCode.Equals("0"))
{
//GetStatic.CallJSFunction(Page, "window.returnValue = true; window.close();");
Response.Redirect("/Remit/Transaction/ApproveTxn/holdTxnListMobile.aspx");
LoadTransaction();
return;
}
}
}
private void Verify()
{
var tranId = GetTranNo();
DbResult _res = new DbResult();
if (!string.IsNullOrEmpty(tranId))
{
_res = _dao.VerifyCashCollect(GetStatic.GetUser(), tranId);
}
else
{
GetStatic.AlertMessage(this, "Please choose at least on record!");
}
GetStatic.AlertMessage(Page, _res.Msg);
if (_res.ErrorCode.Equals("0"))
{
GetStatic.CallJSFunction(Page, "window.returnValue = true; window.close();");
LoadTransaction();
}
}
private void SendApprovalMailToCustomers()
{
Task.Factory.StartNew(() => { SendEmail(); });
}
private void SendEmail()
{
DataTable mailDetails = atd.GetMailDetails("system");
if (mailDetails.Rows.Count == 0 || mailDetails == null)
{
return;
}
foreach (DataRow item in mailDetails.Rows)
{
string res = SendEmailNotification(item);
if (res != "Mail Send")
{
atd.ErrorEmail("system", item["rowId"].ToString());
}
}
}
private string SendEmailNotification(DataRow item)
{
string msgSubject = "JME Control No.: " + item["controlNoDec"].ToString();
string toEmailId = item["createdBy"].ToString();
string msgBody = "Dear " + item["SenderName"];
msgBody += "<br/><br/>This is to acknowledge that you have successfully completed your transaction through JME Online Remit System.";
msgBody += "<br/><br/>Kindly take a note of the following transaction details for your record.";
msgBody += "<br/><br/>JME Number: " + item["controlNoDec"].ToString();
msgBody += "<br/>Amount sent: " + item["collCurr"].ToString() + " " + GetStatic.ShowDecimal(item["tAmt"].ToString());
msgBody += "<br/>Payment method: " + item["paymentMethod"].ToString();
msgBody += "<br/>Pay-out country: " + item["pcountry"].ToString();
msgBody += "<br/>Account holding bank Name: " + item["payountBankOrAgent"].ToString();
msgBody += "<br/>Account number: " + item["accNo"].ToString();
msgBody += "<br/>Account holder’s name: " + item["receiverName"].ToString();
msgBody += "<br/>Payout Amount: " + item["payoutCurr"].ToString() + " " + GetStatic.ShowDecimal(item["pAmt"].ToString());
msgBody += "<br/><br/>You can keep track of your payment status by https://online.gmeremit.com/.";
msgBody +=
"<br><br>If you need further assistance kindly email us at support@jme.com.np or call us at 03-5475-3913. or visit our website <a href=\"http://japanremit.com/\">japanremit.com</a>";
msgBody +=
"<br><br><br>We look forward to provide you excellent service.";
msgBody +=
"<br><br>Thank You.";
msgBody +=
"<br><br><br>Regards,";
msgBody +=
"<br>JME Online Team";
msgBody +=
"<br>Tokyo, Japan ";
msgBody +=
"<br>Phone number 15886864 ";
SmtpMailSetting mail = new SmtpMailSetting
{
MsgBody = msgBody,
MsgSubject = msgSubject,
ToEmails = toEmailId
};
return mail.SendSmtpMail(mail);
}
protected void btnApprove_Click(object sender, EventArgs e)
{
if (GetRequest() == "v")
{
Verify();
}
else
{
Approve();
}
}
}
}