using Newtonsoft.Json; using Swift.DAL.BL.Remit.Transaction; using Swift.DAL.Remittance.APIPartner; using Swift.DAL.Remittance.CustomerDeposits; using Swift.DAL.SwiftDAL; using Swift.web.Library; using System; using System.Data; using System.Text; using System.Threading; using System.Web; namespace Swift.web.Remit.ChangeCollMode { public partial class ChangeMode : System.Web.UI.Page { private string ViewFunctionId = "20114000"; private readonly RemittanceLibrary _sl = new RemittanceLibrary(); private readonly APIPartnerDao _dao = new APIPartnerDao(); private readonly StaticDataDdl _sdd = new StaticDataDdl(); private ApproveTransactionDao at = new ApproveTransactionDao(); private readonly CustomerDepositDao _dao1 = new CustomerDepositDao(); protected void Page_Load(object sender, EventArgs e) { _sl.CheckAuthentication(ViewFunctionId); _sl.CheckSession(); var MethodName = Request.Form["MethodName"]; if (MethodName == "getListData") PopulateData(); if (MethodName == "CheckAvialableBalance") CheckAvialableBalance(); if (MethodName == "UnMapData") UnMapData(); if (MethodName == "MapData") ProceedMapData(); if (MethodName == "SaveCollMode") SaveCollMode(); } private void SaveCollMode() { var controlno = Request.Form["controlno"]; DbResult _res = new DbResult(); if (!string.IsNullOrEmpty(controlno)) { _res = _dao1.SaveCollModeChange(GetStatic.GetUser(), controlno); } else { GetStatic.AlertMessage(this, "Please choose at least on record!"); } Response.ContentType = "text/plain"; Response.Write(JsonConvert.SerializeObject(_res)); Response.End(); } private void PopulateData() { try { string trnDate = Request.Form["tranDate"]; string particulars = Request.Form["particulars"]; string customerId = Request.Form["customerId"]; string amount = Request.Form["amount"]; DataSet dt = _dao1.GetDataForSendMapping(GetStatic.GetUser(), trnDate, particulars, customerId, amount); StringBuilder sb = new StringBuilder(); StringBuilder sb1 = new StringBuilder(); if (null == dt) { Response.ContentType = "application/text"; Response.Write("No Data To Display[[<<>>]]No Data To Display"); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } if (dt.Tables[0].Rows.Count == 0) { sb.AppendLine("No Data To Display"); } if (dt.Tables[1].Rows.Count == 0) { sb1.AppendLine("No Data To Display"); } int sNo = 1; int sNo1 = 1; foreach (DataRow item in dt.Tables[0].Rows) { sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine("" + item["particulars"].ToString() + ""); sb.AppendLine("" + item["tranDate"].ToString() + ""); sb.AppendLine("" + GetStatic.ShowDecimal(item["depositAmount"].ToString()) + ""); sb.AppendLine("" + GetStatic.ShowDecimal(item["paymentAmount"].ToString()) + ""); sb.AppendLine(""); sb.AppendLine(""); sNo++; } foreach (DataRow item in dt.Tables[1].Rows) { sb1.AppendLine(""); sb1.AppendLine(""); sb1.AppendLine("" + item["particulars"].ToString() + ""); sb1.AppendLine("" + item["tranDate"].ToString() + ""); sb1.AppendLine("" + GetStatic.ShowDecimal(item["depositAmount"].ToString()) + ""); sb1.AppendLine("" + GetStatic.ShowDecimal(item["paymentAmount"].ToString()) + ""); sb1.AppendLine(""); sb1.AppendLine(""); sNo1++; } string data = sb + "[[<<>>]]" + sb1; Response.ContentType = "application/text"; Response.Write(data); HttpContext.Current.Response.Flush(); // Sends all currently buffered output to the client. HttpContext.Current.Response.SuppressContent = true; // Gets or sets a value indicating whether to send HTTP content to the client. HttpContext.Current.ApplicationInstance.CompleteRequest(); // Causes ASP.NET to bypass all events and filtering in the HTTP pipeline chain of execution and directly execute the EndRequest event. } catch (ThreadAbortException ex) { string msg = ex.Message; } } private void CheckAvialableBalance() { string customerId = Request.Form["customerId"]; StringBuilder sb = new StringBuilder(); var result = _dao1.CheckAvailableBanalce(GetStatic.GetUser(), customerId); if (result != null) { sb.AppendLine(" Available Bal:  JPY"); } else { sb.AppendLine(" Available Bal:  JPY"); } Response.Write(sb); Response.End(); } protected void ProceedMapData() { var Ids = Request.Form["tranIds[]"]; var customerId = Request.Form["customerId"]; var mapDate = Request.Form["mapDate"]; DbResult _res = new DbResult(); if (!string.IsNullOrEmpty(Ids)) { _res = _dao1.SaveCustomerDepositNew(GetStatic.GetUser(), Ids, customerId, mapDate); } else { GetStatic.AlertMessage(this, "Please choose at least on record!"); } Response.ContentType = "text/plain"; Response.Write(JsonConvert.SerializeObject(_res)); Response.End(); } protected void UnMapData() { var Ids = Request.Form["tranIds[]"]; var customerId = Request.Form["customerId"]; DbResult _res = new DbResult(); if (!string.IsNullOrEmpty(Ids)) { _res = _dao1.UnMapCustomerDeposit(GetStatic.GetUser(), Ids, customerId); } else { GetStatic.AlertMessage(this, "Please choose at least on record!"); } Response.ContentType = "text/plain"; Response.Write(JsonConvert.SerializeObject(_res)); Response.End(); } } }