Exemple #1
0
        public void BindControl()
        {
            SS.Standard.WorkFlow.DTO.WorkFlow workflow = null;
            long workFlowID = 0;

            if (!string.IsNullOrEmpty(Request.Params["wfid"]) && UIHelper.ParseInt(Request.Params["wfid"]) > 0)
            {
                workFlowID = UIHelper.ParseLong(Request.Params["wfid"]);
                workflow   = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(workFlowID);
            }

            if (DocumentType.Equals(ZoneType.Foreign) || this.IsRepOffice)
            {
                ctlAddMilage.Style["display"] = "none";
            }
            else
            {
                ctlAddMilage.Style["display"] = string.Empty;
            }

            if (!InitialFlag.Equals(FlagEnum.ViewFlag) && (workflow == null || (workflow != null && !workflow.CurrentState.Name.Equals(WorkFlowStateFlag.Hold))))
            {
                ctlAddGeneralExpense.Enabled = true;
                ctlAddPerdiem.Enabled        = true;
                ctlAddMilage.Enabled         = true;
            }
            else
            {
                ctlAddGeneralExpense.Enabled = false;
                ctlAddPerdiem.Enabled        = false;
                ctlAddMilage.Enabled         = false;
            }
            ctlSimpleExpense.DocumentType = this.DocumentType;
            ctlPerdiemPopupCaller.URL     = ShowPerdiemPopup(InitialFlag, null);
            ctlInvoicePopupCaller.URL     = String.Format(invoiceURL.Replace("[mode]", FlagEnum.NewFlag), this.TransactionId, this.ExpDocumentID, this.DocumentType, this.DocumentID, string.Empty);
            ctlMileagePopupCaller.URL     = ShowMileagePopup(InitialFlag);

            ExpenseDataSet expDs = (ExpenseDataSet)TransactionService.GetDS(this.TransactionId);

            ExpenseDataSet.FnExpenseDocumentRow expenseDocumentRow = expDs.FnExpenseDocument.FindByExpenseID(this.ExpDocumentID);
            this.DocumentID = expenseDocumentRow.DocumentID;

            ctlDivExchangeRateLocalInfo.Style["display"] = "none";
            ctlDivExchangeRateMainInfo.Style["display"]  = "none";

            if (!InitialFlag.Equals(FlagEnum.NewFlag) && IsRepOffice)
            {
                try
                {
                    if ((workflow != null && workflow.CurrentState.Ordinal >= 5) && (UserAccount.IsAccountant || UserAccount.IsPayment))
                    {
                        string mainCurrencySymbol  = string.Empty;
                        string localCurrencySymbol = string.Empty;
                        if (!expenseDocumentRow.IsLocalCurrencyIDNull())
                        {
                            DbCurrency localCurrency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(expenseDocumentRow.LocalCurrencyID);
                            localCurrencySymbol = localCurrency.Symbol;
                        }

                        if (!expenseDocumentRow.IsMainCurrencyIDNull())
                        {
                            DbCurrency mainCurrency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(expenseDocumentRow.MainCurrencyID);
                            mainCurrencySymbol = mainCurrency.Symbol;
                        }

                        ctlExRateMainCurrencyLabel.Text = GetProgramMessage("DisplayExchangeRateInfo");
                        ctlExchangeRateMain.Text        = UIHelper.BindExchangeRate(expenseDocumentRow.IsExchangeRateMainToTHBCurrencyNull() ? string.Empty : expenseDocumentRow.ExchangeRateMainToTHBCurrency.ToString());
                        ctlExchangeRateMainUnit.Text    = CurrencySymbol.THB + "/" + mainCurrencySymbol;

                        ctlExRateLocalCurrencyLabel.Text = GetProgramMessage("DisplayExchangeRateInfo");
                        ctlExchangeRateLocal.Text        = UIHelper.BindExchangeRate(expenseDocumentRow.IsExchangeRateForLocalCurrencyNull() ? string.Empty : expenseDocumentRow.ExchangeRateForLocalCurrency.ToString());
                        ctlExchangeRateLocalUnit.Text    = localCurrencySymbol + "/" + mainCurrencySymbol;

                        ctlDivExchangeRateMainInfo.Style["display"] = "block";
                        if (!expenseDocumentRow.IsMainCurrencyIDNull() && !expenseDocumentRow.IsLocalCurrencyIDNull() && (expenseDocumentRow.MainCurrencyID != expenseDocumentRow.LocalCurrencyID))
                        {
                            ctlDivExchangeRateLocalInfo.Style["display"] = "block";
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }