public void BindDifferenceAmountSummary() { FnExpenseDocumentService.CalculateTotalExpense(this.TransactionId, this.ExpDocumentID, IsRepOffice); FnExpenseDocumentService.CalculateDifferenceAmount(this.TransactionId, this.ExpDocumentID, IsRepOffice); ExpenseDataSet expDS = (ExpenseDataSet)TransactionService.GetDS(this.TransactionId); if (expDS != null) { ExpenseDataSet.FnExpenseDocumentRow expRow = expDS.FnExpenseDocument.FindByExpenseID(this.ExpDocumentID); if (expRow != null) { if (!IsRepOffice) { DivTotalSummaryForThailand.Style["display"] = "block"; DivTotalSummaryForRepOffice.Style["display"] = "none"; ctlTotalExpense.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalExpense.ToString()); ctlTotalExpense.ForeColor = expRow.TotalExpense < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlTotalAdvance.Text = UIHelper.BindDecimalNumberAccountFormat((-1 * expRow.TotalAdvance).ToString()); ctlTotalAdvance.ForeColor = (-1 * expRow.TotalAdvance) < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlTotalRemitted.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalRemittance.ToString()); ctlTotalRemitted.ForeColor = expRow.TotalRemittance < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlDifferenceAmount.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.DifferenceAmount.ToString()); ctlDifferenceAmount.ForeColor = expRow.DifferenceAmount < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; } else { DivTotalSummaryForThailand.Style["display"] = "none"; DivTotalSummaryForRepOffice.Style["display"] = "block"; ctlTHBCurrencyTab.Visible = false; ctlMainCurrencyTab.Visible = false; if (CounterCashierID.HasValue) { Dbpb pb = ScgDbQueryProvider.DbPBQuery.FindByIdentity(CounterCashierID.Value); DbCurrency localCurrency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(LocalCurrencyID.HasValue ? LocalCurrencyID.Value : (short)0); DbCurrency mainCurrency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(pb.MainCurrencyID.HasValue ? pb.MainCurrencyID.Value : (short)0); if (localCurrency != null) { ctlLocalCurrencyTab.HeaderText = localCurrency.Symbol; } if (mainCurrency != null) { ctlMainCurrencyTab.HeaderText = mainCurrency.Symbol; } } #region Amount LocalCurrency Tab ctlLocalCurrencyTab.Visible = true; ctlTotalExpenseLocal.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalExpenseLocalCurrency.ToString()); ctlTotalExpenseLocal.ForeColor = expRow.TotalExpenseLocalCurrency < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; if (!expRow.IsTotalAdvanceLocalCurrencyNull()) { ctlTotalAdvanceLocal.Text = UIHelper.BindDecimalNumberAccountFormat((-1 * expRow.TotalAdvanceLocalCurrency).ToString()); ctlTotalAdvanceLocal.ForeColor = (-1 * expRow.TotalAdvanceLocalCurrency) < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; } if (!expRow.IsTotalRemittanceLocalCurrencyNull()) { ctlTotalRemittanceLocal.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalRemittanceLocalCurrency.ToString()); ctlTotalRemittanceLocal.ForeColor = expRow.TotalRemittanceLocalCurrency < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; } if (!expRow.IsDifferenceAmountLocalCurrencyNull()) { ctlDifferenceAmtLocal.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.DifferenceAmountLocalCurrency.ToString()); ctlDifferenceAmtLocal.ForeColor = expRow.DifferenceAmountLocalCurrency < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; } #endregion SS.Standard.WorkFlow.DTO.WorkFlow workflow = SS.Standard.WorkFlow.Query.WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(expRow.DocumentID); if (workflow != null && workflow.CurrentState.Ordinal >= 5) { if (UserAccount.IsAccountant || UserAccount.IsPayment) { #region Amount MainCurrency Tab if (expRow.LocalCurrencyID != expRow.MainCurrencyID) { ctlMainCurrencyTab.Visible = true; } ctlTotalExpenseMainCurrency.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalExpenseMainCurrency.ToString()); ctlTotalExpenseMainCurrency.ForeColor = expRow.TotalExpenseMainCurrency < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlTotalAdvanceMainCurrency.Text = UIHelper.BindDecimalNumberAccountFormat((-1 * expRow.TotalAdvanceMainCurrency).ToString()); ctlTotalAdvanceMainCurrency.ForeColor = (-1 * expRow.TotalAdvanceMainCurrency) < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlTotalRemittanceMainCurrency.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalRemittanceMainCurrency.ToString()); ctlTotalRemittanceMainCurrency.ForeColor = expRow.TotalRemittanceMainCurrency < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlDifferenceAmtMainCurrency.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.DifferenceAmountMainCurrency.ToString()); ctlDifferenceAmtMainCurrency.ForeColor = expRow.DifferenceAmountMainCurrency < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; #endregion #region Amount THB Currency Tab ctlTHBCurrencyTab.Visible = true; ctlTotalExpenseTHB.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalExpense.ToString()); ctlTotalExpenseTHB.ForeColor = expRow.TotalExpense < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlTotalAdvanceTHB.Text = UIHelper.BindDecimalNumberAccountFormat((-1 * expRow.TotalAdvance).ToString()); ctlTotalAdvanceTHB.ForeColor = (-1 * expRow.TotalAdvance) < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlTotalRemittanceTHB.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.TotalRemittance.ToString()); ctlTotalRemittanceTHB.ForeColor = expRow.TotalRemittance < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; ctlDifferenceAmtTHB.Text = UIHelper.BindDecimalNumberAccountFormat(expRow.DifferenceAmount.ToString()); ctlDifferenceAmtTHB.ForeColor = expRow.DifferenceAmount < 0 ? System.Drawing.Color.Red : System.Drawing.Color.Black; #endregion } } } } } }