using Swift.DAL.BL.Remit.ExchangeRate; using Swift.web.Component.Tab; using Swift.web.Library; using System; using System.Collections.Generic; using System.Data; using System.Text; namespace Swift.web.Remit.ExchangeRate.ExRateTreasury { public partial class CopySummary : System.Web.UI.Page { private ExRateReportDao obj = new ExRateReportDao(); private readonly StaticDataDdl _sdd = new StaticDataDdl(); private readonly SwiftTab _tab = new SwiftTab(); private const string GridName = "grd_cs"; protected void Page_Load(object sender, EventArgs e) { Authenticate(); if (!IsPostBack) { LoadTab(); } LoadGrid(); } private string GetApplyAgent() { return GetStatic.ReadQueryString("applyAgent", ""); } private string GetApplyFor() { return GetStatic.ReadQueryString("applyFor", ""); } private string GetExRateTreasuryIds() { return GetStatic.ReadSession("exRateTreasuryIds", ""); } private string autoSelect(string str1, string str2) { if (str1 == str2) return "selected=\"selected\""; else return ""; } private void Authenticate() { _sdd.CheckSession(); } private string GetIsFw() { return GetStatic.ReadQueryString("isFw", ""); } private void LoadTab() { var isFw = GetIsFw(); var queryStrings = "?isFw=" + isFw; _tab.NoOfTabPerRow = 8; _tab.TabList = new List { new TabField("Treasury Rate", "List.aspx" + queryStrings), new TabField("Add New", "Manage.aspx" + queryStrings), new TabField("Approve", "ApproveList.aspx" + queryStrings), new TabField("Reject", "RejectList.aspx" + queryStrings), new TabField("My changes", "MyChangeList.aspx" + queryStrings), new TabField("Copy Rate", "CopyAgentWiseRate.aspx" + queryStrings, true), }; divTab.InnerHtml = _tab.CreateTab(); } private string GetPagingBlock(int _total_record, int _page, int _page_size) { var str = new StringBuilder(""); str.Append(""); str.Append(""); str.AppendLine(""); str.AppendLine("
Result : " + _total_record.ToString() + " records "); str.Append("  per page  "); str.AppendLine(""); if (_page > 1) str.AppendLine("   "); else str.AppendLine("   "); if (_page * _page_size < _total_record) str.AppendLine("   "); else str.AppendLine("   "); //str.AppendLine("  "); str.AppendLine("
"); return str.ToString(); } private string loadPagingBlock(DataTable dtPaging) { string pagingTable = ""; foreach (DataRow row in dtPaging.Rows) { pagingTable = GetPagingBlock(int.Parse(row["totalRow"].ToString()), int.Parse(row["pageNumber"].ToString()), int.Parse(row["pageSize"].ToString())); } return pagingTable; } private void LoadGrid() { var dt = obj.GetCopySummary(GetStatic.GetUser(), GetExRateTreasuryIds(), GetApplyAgent(), GetApplyFor()); var html = new StringBuilder(); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); //Head Office html.Append(""); html.Append(""); //Tolerance html.Append(""); html.Append(""); //Sending Agent html.Append(""); html.Append(""); //Customer html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); //Head Office html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); //Agent FX html.Append(""); html.Append(""); //Tolerance html.Append(""); html.Append(""); //Sending Agent html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); //Cust. Tol. html.Append(""); html.Append(""); //Customer html.Append(""); html.Append(""); html.Append(""); html.Append(""); var i = 0; var countryName = ""; foreach (DataRow dr in dt.Rows) { var id = dr["exRateTreasuryId"].ToString(); if (GetApplyFor().ToLower() == "c") { if (countryName != dr["pCountryName"].ToString()) { html.Append( ""); countryName = dr["pCountryName"].ToString(); } } else { if (countryName != dr["cCountryName"].ToString()) { html.Append( ""); countryName = dr["cCountryName"].ToString(); } } html.Append(++i % 2 == 1 ? "" : ""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); //Head Office Rate, Margin, Offer to Agent html.Append(""); html.Append(ComposeLabel(dr, "cMargin", "tdhorate", true)); html.Append(ComposeLabel(dr, "cHoMargin", "tdhorate", true)); html.Append(""); html.Append(""); html.Append(ComposeLabel(dr, "pMargin", "tdhorate", true)); html.Append(ComposeLabel(dr, "pHoMargin", "tdhorate", true)); html.Append(""); //Agent Fx html.Append(""); html.Append(""); //Tolerance html.Append(""); html.Append(""); html.Append(""); //Sending Agent Rate, Margin, Offer to Customer html.Append(""); html.Append(ComposeLabel(dr, "cAgentMargin", "tdsendagentrate", true)); html.Append(ComposeLabelWithValue((Convert.ToDecimal(dr["cRate"]) + Convert.ToDecimal(dr["cMargin"]) + Convert.ToDecimal(dr["cHoMargin"]) + Convert.ToDecimal(dr["cAgentMargin"])).ToString(), "tdsendagentrate", true)); html.Append(""); html.Append(ComposeLabel(dr, "pAgentMargin", "tdsendagentrate", true)); html.Append(ComposeLabelWithValue((Convert.ToDecimal(dr["pRate"]) - Convert.ToDecimal(dr["pMargin"]) - Convert.ToDecimal(dr["pHoMargin"]) - Convert.ToDecimal(dr["pAgentMargin"])).ToString(), "tdsendagentrate", true)); //Customer Tol html.Append(""); html.Append(""); //Customer html.Append(""); html.Append(""); html.Append(""); html.Append(""); html.Append(""); } html.Append("
Send
Receive
Service TypeSend
Curr.
Receive
Curr.
Head Office
Agent FX
Tolerance
Sending Agent
Cust. Tol.
Cross Rate
Last Update/Approve
USD vs Send Curr.
USD vs Receive Curr.
On
Agent
USD vs Send Curr.
USD vs Receive Curr.
Send Curr. vs Receive Curr.
CountryAgent
CountryAgent
RateMargin(I)MarginOfferRateMargin(I)MarginOfferValueTypeMinMaxRateMarginOfferRateMarginOfferMinMaxMax RateAgent RateCustomer Rate
Receiving Country : " + GetStatic.GetCountryFlag(dr["pCountryCode"].ToString()) + dr["pCountryName"] + "
Sending Country : " + GetStatic.GetCountryFlag(dr["cCountryCode"].ToString()) + dr["cCountryName"] + "
" + GetStatic.GetCountryFlag(dr["cCountryCode"].ToString()) + dr["cCountryName"] + "" + dr["cAgentName"] + "" + GetStatic.GetCountryFlag(dr["pCountryCode"].ToString()) + dr["pCountryName"] + "" + dr["pAgentName"] + "" + dr["tranType"] + "" + dr["cCurrency"] + "" + dr["pCurrency"] + "" + dr["cRate"] + "" + (Convert.ToDecimal(dr["cRate"]) + Convert.ToDecimal(dr["cMargin"]) + Convert.ToDecimal(dr["cHoMargin"])) + "" + dr["pRate"] + "" + (Convert.ToDecimal(dr["pRate"]) - Convert.ToDecimal(dr["pMargin"]) - Convert.ToDecimal(dr["pHoMargin"])) + "" + dr["sharingValue"] + "" + dr["sharingType"] + "" + dr["toleranceOn"] + "" + dr["agentTolMin"] + "" + dr["agentTolMax"] + "" + (Convert.ToDecimal(dr["cRate"]) + Convert.ToDecimal(dr["cMargin"]) + Convert.ToDecimal(dr["cHoMargin"])) + "" + (Convert.ToDecimal(dr["pRate"]) - Convert.ToDecimal(dr["pMargin"]) - Convert.ToDecimal(dr["pHoMargin"])) + "" + dr["customerTolMin"] + "" + dr["customerTolMax"] + "" + dr["maxCrossRate"] + "" + dr["crossRate"] + "" + dr["customerRate"] + "" + dr["modifiedBy"] + " " + dr["modifiedDate"] + "
" + dr["approvedBy"] + " " + dr["approvedDate"] + "
"); rpt_grid.InnerHtml = html.ToString(); GetStatic.CallBackJs1(Page, "Show Hide", "ShowHideDetail();"); } private string AppendRowSelectionProperty(string rowSelectedClass, string defaultClass, string onhoverclass) { return " class=\"" + defaultClass + "\" ondblclick=\"if(this.className=='" + rowSelectedClass + "'){this.className='" + defaultClass + "';}else{this.className='" + rowSelectedClass + "';}\" onMouseOver=\"if(this.className=='" + defaultClass + "'){this.className='" + onhoverclass + "';}\" onMouseOut=\"if(this.className=='" + rowSelectedClass + "'){}else{this.className='" + defaultClass + "';}\" "; } private string ComposeLabel(DataRow dr, string valueField, string cssClass, bool showDistinctMinusValue) { var html = new StringBuilder(); var styleAttr = ""; if (showDistinctMinusValue) { styleAttr = Convert.ToDouble(dr[valueField]) < 0 ? " style=\"color: red !important;\" " : " style=\"color: green !important;\" "; } html.Append("" + dr[valueField] + ""); return html.ToString(); } private string ComposeLabelWithValue(string value, string cssClass, bool showDistinctMinusValue) { var html = new StringBuilder(); var styleAttr = ""; if (showDistinctMinusValue) { styleAttr = Convert.ToDouble(value) < 0 ? " style=\"color: red !important;\" " : " style=\"color: green !important;\" "; } html.Append("" + value + ""); return html.ToString(); } protected void btnHidden_Click(object sender, EventArgs e) { LoadGrid(); } protected void countryOrderBy_SelectedIndexChanged(object sender, EventArgs e) { LoadGrid(); } } }