Exemple #1
0
        //Add by Nutnicha C. 21/07/2011
        /// <summary>
        /// Generate approval status combobox
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="id"></param>
        /// <param name="attribute"></param>
        /// <returns></returns>
        public static MvcHtmlString ApprovalStatusComboBox(this HtmlHelper helper, string id, object attribute = null)
        {
            #region GetMisc
            //List<View_dtMiscTypeCode> lst = new List<View_dtMiscTypeCode>();
            //try
            //{
            //    List<dtMiscTypeCode> miscs = new List<dtMiscTypeCode>()
            //    {
            //        new dtMiscTypeCode()
            //        {
            //            FieldName = MiscType.C_APPROVE_STATUS,
            //            ValueCode = "%"
            //        }
            //    };

            //    ICommonHandler hand = ServiceContainer.GetService<ICommonHandler>() as ICommonHandler;
            //    lst = hand.GetMiscTypeCodeListByLanguage(miscs);
            //}
            //catch
            //{
            //}

            //if (lst == null)
            //    lst = new List<View_dtMiscTypeCode>();
            #endregion

            ICommonHandler handlerComm  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            List <string>  lsFieldNames = new List <string>();
            lsFieldNames.Add(MiscType.C_APPROVE_STATUS);
            List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);
            return(CommonUtil.CommonComboBox <doMiscTypeCode>(id, MiscTypeList, "ValueCodeDisplay", "ValueCode", attribute));
        }
Exemple #2
0
        // Add by Natthavat S. 26/10/2011
        /// <summary>
        /// Generate install process manage status combobox
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="id"></param>
        /// <param name="attribute"></param>
        /// <returns></returns>
        public static MvcHtmlString InstallProcessMgmtStatusComboBox(this HtmlHelper helper, string id, object attribute = null)
        {
            ICommonHandler handlerComm  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            List <string>  lsFieldNames = new List <string>();

            lsFieldNames.Add(MiscType.C_SALE_PROC_MANAGE_STATUS);
            List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);

            return(CommonUtil.CommonComboBox <doMiscTypeCode>(id, MiscTypeList, "ValueCodeDisplay", "ValueCode", attribute));
        }
Exemple #3
0
        ///// <summary>
        ///// Generate sale type combobox
        ///// </summary>
        ///// <param name="helper"></param>
        ///// <param name="id"></param>
        ///// <param name="attribute"></param>
        ///// <returns></returns>
        //public static MvcHtmlString SaleTypeComboBox(this HtmlHelper helper, string id, object attribute = null)
        //{
        //    ICommonHandler handlerComm = ServiceContainer.GetService<ICommonHandler>() as ICommonHandler;
        //    List<string> lsFieldNames = new List<string>();
        //    lsFieldNames.Add(MiscType.C_SALE_TYPE);
        //    List<doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);

        //    return CommonUtil.CommonComboBox<doMiscTypeCode>(id, MiscTypeList, "ValueCodeDisplay", "ValueCode", attribute);
        //}

        /// <summary>
        /// Generate doc audit result combobox
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="id"></param>
        /// <param name="attribute"></param>
        /// <returns></returns>
        public static MvcHtmlString DocAuditResultComboBox(this HtmlHelper helper, string id, object attribute = null)
        {
            ICommonHandler handlerComm  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            List <string>  lsFieldNames = new List <string>();

            lsFieldNames.Add(MiscType.C_DOC_AUDIT_RESULT);
            List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);

            return(CommonUtil.CommonComboBox <doMiscTypeCode>(id, MiscTypeList, "ValueCodeDisplay", "ValueCode", attribute));
        }
Exemple #4
0
        /// <summary>
        /// Generate acquisition type combobox
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="id"></param>
        /// <param name="attribute"></param>
        /// <returns></returns>
        public static MvcHtmlString AcquisitionTypeComboBox(this HtmlHelper helper, string id, object attribute = null)
        {
            ICommonHandler handlerComm  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            List <string>  lsFieldNames = new List <string>();

            lsFieldNames.Add(MiscType.C_ACQUISITION_TYPE);
            List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);

            return(CommonUtil.CommonComboBox <doMiscTypeCode>(id, MiscTypeList, "ValueCodeDisplay", "ValueCode", attribute));
        }
        /// <summary>
        /// Perform purge log
        /// </summary>
        /// <returns></returns>
        public ActionResult CMS240_PurgeLog()
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                CMS240_Status cms240_status_param = GetScreenObject <CMS240_Status>();

                //Write log for start purging log
                ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                hand.WriteWindowLog(EventType.C_EVENT_TYPE_INFORMATION, "Purge log process is started", EventID.C_EVENT_ID_REPORT_PURGE_LOG);

                //Call CMP030: Purge log process
                DateTime            dtime = cms240_status_param.MonthYear.HasValue ? cms240_status_param.MonthYear.Value : DateTime.Now;
                List <tbt_PurgeLog> pl    = hand.DeleteLog(cms240_status_param.MonthYear.Value);


                if (pl.Count > 0)
                {
                    if (pl[0].PurgeStatus == BatchStatus.C_BATCH_STATUS_SUCCEEDED)
                    {
                        cms240_status_param.IsPurgeSucceeded = true;
                        hand.WriteWindowLog(EventType.C_EVENT_TYPE_INFORMATION, "Purge log is finish", EventID.C_EVENT_ID_REPORT_PURGE_LOG);
                    }
                    else
                    {
                        cms240_status_param.IsPurgeSucceeded = false;
                        hand.WriteWindowLog(EventType.C_EVENT_TYPE_ERROR, "There are some error at purge log", EventID.C_EVENT_ID_REPORT_PURGE_LOG);
                    }


                    // update status
                    cms240_status_param.PurgeStatus     = pl[0].PurgeStatus;
                    cms240_status_param.PurgeStatusName = "";


                    // Misc Mapping (#2)
                    ICommonHandler        handlerComm  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                    List <doMiscTypeCode> MiscTypeCode = new List <doMiscTypeCode>();
                    List <string>         lsFieldNames = new List <string>();
                    lsFieldNames.Add(MiscType.C_BATCH_STATUS);
                    List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);

                    cms240_status_param.PurgeStatusName = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_BATCH_STATUS, cms240_status_param.PurgeStatus);
                }

                res.ResultData = cms240_status_param;
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
        /// <summary>
        /// Debt tracing result
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="id"></param>
        /// <param name="attribute"></param>
        /// <returns></returns>
        public static MvcHtmlString DebtTracingPostponeReasonCombo(this HtmlHelper helper, string id, object attribute = null)
        {
            ICommonHandler comh = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            List <string>  lst  = new List <string>();

            lst.Add(MiscType.C_DEBT_TRACING_POSTPONE_REASON);
            List <doMiscTypeCode> dtTransportType = comh.GetMiscTypeCodeListByFieldName(lst);

            CommonUtil.eFirstElementType idx0_type = CommonUtil.eFirstElementType.Select;
            return(CommonUtil.CommonComboBox <doMiscTypeCode>(id, dtTransportType, "ValueCodeDisplay", "ValueCode", attribute, true, idx0_type));
        }
Exemple #7
0
 /// <summary>
 /// Mapping description for payment type of specific payment information
 /// </summary>
 /// <param name="doPayment">payment information</param>
 private void ICS010_FillPaymentType(tbt_Payment doPayment)
 {
     if (doPayment != null && !(string.IsNullOrEmpty(doPayment.PaymentType)))
     {
         List <string> listFieldName = new List <string>();
         listFieldName.Add(MiscType.C_PAYMENT_TYPE);
         ICommonHandler        commonHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
         List <doMiscTypeCode> listMisc      = commonHandler.GetMiscTypeCodeListByFieldName(listFieldName).Where(d => d.ValueCode == doPayment.PaymentType).ToList(); // This result has language mapping already
         if (listMisc != null && listMisc.Count > 0)
         {
             doPayment.PaymentTypeDisplay = listMisc[0].ValueDisplay;
         }
     }
 }
        /// <summary>
        /// Debt tracing result
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="id"></param>
        /// <param name="attribute"></param>
        /// <returns></returns>
        public static MvcHtmlString DebtTracingResultCombo(this HtmlHelper helper, string id, object attribute = null)
        {
            ICommonHandler comh = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            List <string>  lst  = new List <string>();

            lst.Add(MiscType.C_DEBT_TRACING_RESULT);
            List <doMiscTypeCode> dtMisc = comh.GetMiscTypeCodeListByFieldName(lst);

            if (CommonUtil.dsTransData != null)
            {
                if (!CommonUtil.dsTransData.ContainsPermission(ScreenID.C_SCREEN_ID_DEBT_TRACING, FunctionID.C_FUNC_ID_TRANSFER_TO_BRANCH))
                {
                    dtMisc = dtMisc.Where(d =>
                                          d.ValueCode != DebtTracingResult.C_DEBT_TRACE_RESULT_TRANSFER_TO_BRANCH &&
                                          d.ValueCode != DebtTracingResult.C_DEBT_TRACE_RESULT_TRANSFER_TO_HQ
                                          ).ToList();
                }
            }

            CommonUtil.eFirstElementType idx0_type = CommonUtil.eFirstElementType.Select;
            return(CommonUtil.CommonComboBox <doMiscTypeCode>(id, dtMisc, "ValueCodeDisplay", "ValueCode", attribute, true, idx0_type));
        }
        /// <summary>
        /// Generate Unit comboitem list
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        public ActionResult IVS250_GetUnit(string id)
        {
            try
            {
                ICommonHandler comh   = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                var            lstAll = comh.GetMiscTypeCodeListByFieldName(new List <string>()
                {
                    MiscType.C_UNIT
                });
                var lstFilter = lstAll.ToList <doMiscTypeCode>();
                CommonUtil.MappingObjectLanguage <doMiscTypeCode>(lstFilter);

                ComboBoxModel cboModel = new ComboBoxModel();
                cboModel.SetList <doMiscTypeCode>(lstFilter, "ValueDisplay", "ValueCode", true, CommonUtil.eFirstElementType.Select);

                return(Json(cboModel));
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Exemple #10
0
        /// <summary>
        /// Get sentry guard detail
        /// </summary>
        /// <param name="strContractCode"></param>
        /// <param name="strOCC"></param>
        /// <returns></returns>
        public ActionResult CMS140_GetSentryGuardDetail(string strContractCode, string strOCC)
        {
            CommonUtil c = new CommonUtil();

            List <dtTbt_RentalSentryGuardDetailsListForView> list = new List <dtTbt_RentalSentryGuardDetailsListForView>();

            ObjectResultData res = new ObjectResultData();

            try
            {
                strContractCode = c.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                IRentralContractHandler handler       = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
                ICommonHandler          comHand       = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode>   tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_CURRENCT,
                        ValueCode = "%"
                    }
                }).ToList();

                list = handler.GetTbt_RentalSentryGuardDetailsListForView(strContractCode, strOCC, null);
                //Add Currency
                for (int i = 0; i < list.Count(); i++)
                {
                    if (list[i].TimeUnitPriceCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        list[i].TimeUnitPrice = list[i].TimeUnitPriceUsd;
                    }

                    list[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                }

                ICommonHandler handlerComm  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <string>  lsFieldNames = new List <string>();
                lsFieldNames.Add(MiscType.C_SG_TYPE);
                lsFieldNames.Add(MiscType.C_SG_AREA_TYPE);

                // Get Misc type
                List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);


                string strDisplayValue = "";
                foreach (var item in list)
                {
                    strDisplayValue      = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_SG_TYPE, item.SentryGuardTypeCode);
                    item.SentryGuardType = strDisplayValue;//CommonUtil.TextCodeName(item.SentryGuardTypeCode, strDisplayValue);
                    item.strStartTime    = (item.SecurityStartTime.HasValue ? string.Format("{0}:{1}", item.SecurityStartTime.Value.ToString("hh"), item.SecurityStartTime.Value.ToString("mm")) : "-");
                    item.strFinishTime   = (item.SecurityFinishTime.HasValue ? string.Format("{0}:{1}", item.SecurityFinishTime.Value.ToString("hh"), item.SecurityFinishTime.Value.ToString("mm")) : "-");
                }



                // Order by first column (SentryGuardType)
                list = (from t in list orderby t.SentryGuardType select t).ToList <dtTbt_RentalSentryGuardDetailsListForView>();
            }
            catch (Exception ex)
            {
                list = new List <dtTbt_RentalSentryGuardDetailsListForView>();
                res.AddErrorMessage(ex);
            }

            res.ResultData = CommonUtil.ConvertToXml <dtTbt_RentalSentryGuardDetailsListForView>(list, "Common\\CMS140_SentryGuardDetail");
            return(Json(res));
        }
        /// <summary>
        /// Get purge log status
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ActionResult CMS240_GetStatus(CMS240_ScreenParameter cond)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            List <CMS240_PurgeLogDataDetail> listPurgeLogFailDetail = new List <CMS240_PurgeLogDataDetail>();

            CMS240_Status status = new CMS240_Status();

            try
            {
                if (ModelState.IsValid == false)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                    if (res.IsError)
                    {
                        return(Json(res));
                    }
                }

                ICommonHandler hand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <DataEntity.Common.doSystemStatus> lstSystemStatus = hand.GetSystemStatus();
                bool bSuspendFlag = false;
                if (lstSystemStatus.Count > 0)
                {
                    bSuspendFlag = (lstSystemStatus[0].SuspendFlag == FlagType.C_FLAG_ON);
                }

                status.SuspendFlag = bSuspendFlag;
                status.MonthYear   = cond.MonthYear;


                ILogHandler  logHandler   = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                List <dtTPL> lstLogHeader = logHandler.GetTbt_Purgelog(cond.MonthYear);


                List <dtMonthYear> lstLogMonthYear = logHandler.GetLogMonthYear();
                status.IsExistInTransLog = true;
                if (lstLogMonthYear.Count > 0)
                {
                    List <dtMonthYear> t = (from p in lstLogMonthYear where p.MonthYear.Value.CompareTo(cond.MonthYear.Value) == 0
                                            select p).ToList <dtMonthYear>();

                    if (t.Count == 0) // 0 mean not exist
                    {
                        status.IsExistInTransLog = false;
                    }
                }


                if (lstLogHeader.Count > 0)
                {
                    //// Misc Mapping (#1)
                    //MiscTypeMappingList miscList = new MiscTypeMappingList();
                    //miscList.AddMiscType(lstLogHeader.ToArray());
                    //ICommonHandler comHandler = ServiceContainer.GetService<ICommonHandler>() as ICommonHandler;
                    //comHandler.MiscTypeMappingList(miscList);

                    // Misc Mapping (#2)
                    ICommonHandler        handlerComm  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                    List <doMiscTypeCode> MiscTypeCode = new List <doMiscTypeCode>();
                    List <string>         lsFieldNames = new List <string>();
                    lsFieldNames.Add(MiscType.C_BATCH_STATUS);
                    List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);

                    lstLogHeader[0].PurgeStatusName = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_BATCH_STATUS, lstLogHeader[0].PurgeStatus);

                    // 1. Keep purge status , fail****
                    // 2. Create data list (PurgeLogDataDetail) from xml (column ErrorDescription)

                    bool isShowPurgeLogDataDetail = (lstLogHeader[0].PurgeStatus == BatchStatus.C_BATCH_STATUS_FAILED);

                    status.isShowPurgeLogDataDetail = isShowPurgeLogDataDetail;
                    status.PurgeStatusName          = lstLogHeader[0].PurgeStatusName;
                    status.PurgeStatus = lstLogHeader[0].PurgeStatus;
                    status.xml         = lstLogHeader[0].ErrorDescription;
                }

                UpdateScreenObject(status);
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            res.ResultData = status;

            return(Json(res));
        }
        public ActionResult CMS190()
        {
            string strContractCode    = "";
            string strServiceTypeCode = "";

            try
            {
                CMS190_ScreenParameter param = GetScreenObject <CMS190_ScreenParameter>();
                strContractCode    = param.ContractCode;
                strServiceTypeCode = param.ServiceTypeCode;
            }
            catch
            {
            }

            /* ----- Set grobal variable for javascript side ---- */
            ViewBag._ServiceTypeCode = strServiceTypeCode;
            ViewBag._ContractCode    = strContractCode;

            CommonUtil c = new CommonUtil();


            List <dtTbt_RentalContractBasicForView> vw_dtRentalContract = new List <dtTbt_RentalContractBasicForView>();
            List <dtTbt_SaleBasicForView>           vw_dtSaleContract   = new List <dtTbt_SaleBasicForView>();
            List <dtTbt_RentalSecurityBasicForView> vw_dtRentalSecurity = new List <dtTbt_RentalSecurityBasicForView>();

            //List<dtContractTargetInfoByRelated> vw_dtMaintenanceContractInfo = new List<dtContractTargetInfoByRelated>();

            ViewBag.Currency = CommonValue.CURRENCY_UNIT;
            string dateFormat        = "dd-MMM-yyyy";
            string numberFormat      = "N0";
            string floatNumberFormat = "N2";

            // default ViewBag
            ViewBag.chkFire_monitoring      = false;
            ViewBag.chkCrime_prevention     = false;
            ViewBag.chkEmergency_report     = false;
            ViewBag.chkFacility_monitoring  = false;
            ViewBag.bOutOfRegulationDocFlag = false;



            try
            {
                strContractCode = c.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                ICommonHandler handlerComm = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

                /******  get misc display value ******/
                List <string> lsFieldNames = new List <string>();
                lsFieldNames.Add(MiscType.C_RENTAL_CHANGE_TYPE);
                lsFieldNames.Add(MiscType.C_SALE_CHANGE_TYPE);
                lsFieldNames.Add(MiscType.C_SALE_TYPE);
                lsFieldNames.Add(MiscType.C_SALE_PROC_MANAGE_STATUS);

                List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);
                /************************************/



                // Rental
                IRentralContractHandler handlerR = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
                // Sale
                ISaleContractHandler handlerS = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
                // Online
                IViewContractHandler handlerVC = ServiceContainer.GetService <IViewContractHandler>() as IViewContractHandler;

                IInstallationHandler iHandler = ServiceContainer.GetService <IInstallationHandler>() as IInstallationHandler;

                ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

                string strInstallationStatusCode = "-";
                string strInstallationStatusName = "-";

                List <dtTbt_RentalContractBasicForView> dtRentalContract          = new List <dtTbt_RentalContractBasicForView>();
                List <dtTbt_SaleBasicForView>           dtSaleContract            = new List <dtTbt_SaleBasicForView>();
                List <dtTbt_RentalSecurityBasicForView> dtRentalSecurity          = new List <dtTbt_RentalSecurityBasicForView>();
                List <dtContractTargetInfoByRelated>    dtOnlineContractInfo      = new List <dtContractTargetInfoByRelated>();
                List <dtContractTargetInfoByRelated>    dtMaintenanceContractInfo = new List <dtContractTargetInfoByRelated>();
                ICommonHandler        comHand       = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_CURRENCT,
                        ValueCode = "%"
                    }
                }).ToList();

                if (strServiceTypeCode == ServiceType.C_SERVICE_TYPE_RENTAL)
                {
                    dtRentalContract = handlerR.GetTbt_RentalContractBasicForView(strContractCode);
                    //Check Currency *For view
                    if (dtRentalContract[0].NormalDepositFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalContract[0].NormalDepositFee = dtRentalContract[0].NormalDepositFeeUsd;
                    }
                    if (dtRentalContract[0].OrderDepositFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalContract[0].OrderDepositFee = dtRentalContract[0].OrderDepositFeeUsd;
                    }
                    if (dtRentalContract[0].LastOrderContractFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalContract[0].LastOrderContractFee = dtRentalContract[0].LastOrderContractFeeUsd;
                    }
                    if (dtRentalContract[0].ExemptedDepositFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalContract[0].ExemptedDepositFee = dtRentalContract[0].ExemptedDepositFeeUsd;
                    }
                    //Add currency to List
                    for (int i = 0; i < dtRentalContract.Count(); i++)
                    {
                        dtRentalContract[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                    }
                }
                else if (strServiceTypeCode == ServiceType.C_SERVICE_TYPE_SALE)
                {
                    dtSaleContract = handlerS.GetTbt_SaleBasicForView(strContractCode, null, true);
                    if (dtSaleContract[0].NormalInstallFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtSaleContract[0].NormalInstallFee = dtSaleContract[0].NormalInstallFeeUsd;
                    }
                    if (dtSaleContract[0].OrderInstallFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtSaleContract[0].OrderInstallFee = dtSaleContract[0].OrderInstallFeeUsd;
                    }
                    if (dtSaleContract[0].InstallFeePaidBySECOMCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtSaleContract[0].InstallFeePaidBySECOM = dtSaleContract[0].InstallFeePaidBySECOMUsd;
                    }
                    if (dtSaleContract[0].InstallFeeRevenueBySECOMCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtSaleContract[0].InstallFeeRevenueBySECOM = dtSaleContract[0].InstallFeeRevenueBySECOMUsd;
                    }
                    if (dtSaleContract[0].OrderProductPriceCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtSaleContract[0].OrderProductPrice = dtSaleContract[0].OrderProductPriceUsd;
                    }
                    if (dtSaleContract[0].NormalProductPriceCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtSaleContract[0].NormalProductPrice = dtSaleContract[0].NormalProductPriceUsd;
                    }
                    if (dtSaleContract[0].BidGuaranteeAmount1CurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtSaleContract[0].BidGuaranteeAmount1 = dtSaleContract[0].BidGuaranteeAmount1Usd;
                    }
                    if (dtSaleContract[0].BidGuaranteeAmount2CurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtSaleContract[0].BidGuaranteeAmount2 = dtSaleContract[0].BidGuaranteeAmount2Usd;
                    }
                    if (dtSaleContract[0].NewBldMgmtCostCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtSaleContract[0].NewBldMgmtCost = dtSaleContract[0].NewBldMgmtCostUsd;
                    }
                    //Add Currency to List
                    for (int i = 0; i < dtSaleContract.Count(); i++)
                    {
                        dtSaleContract[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                    }
                }


                if (dtRentalContract.Count > 0)
                {
                    // Get related data
                    dtRentalSecurity = handlerR.GetTbt_RentalSecurityBasicForView(strContractCode, dtRentalContract[0].LastOCC);

                    for (int i = 0; i < dtRentalSecurity.Count(); i++)
                    {
                        dtRentalSecurity[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                    }
                    //Must get InstallationInterfaceHandler.GetInstallationStatus (Next phase)
                    strInstallationStatusCode = iHandler.GetInstallationStatus(strContractCode);
                    //======== GET INSTALLATION STATUS NAME =============================
                    List <doMiscTypeCode> lst   = new List <doMiscTypeCode>();
                    List <doMiscTypeCode> miscs = new List <doMiscTypeCode>()
                    {
                        new doMiscTypeCode()
                        {
                            FieldName = MiscType.C_INSTALL_STATUS,
                            ValueCode = strInstallationStatusCode
                        }
                    };
                    lst = chandler.GetMiscTypeCodeList(miscs);
                    if (lst != null && lst.Count > 0)
                    {
                        strInstallationStatusName = lst[0].ValueDisplay;
                    }
                    //================================================================

                    // Select language
                    vw_dtRentalContract = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalContractBasicForView, dtTbt_RentalContractBasicForView>(dtRentalContract, "Quo_OfficeName", "Con_OfficeName", "Op_OfficeName");
                    vw_dtRentalSecurity = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalSecurityBasicForView, dtTbt_RentalSecurityBasicForView>(dtRentalSecurity,
                                                                                                                                                  "ProductName",
                                                                                                                                                  "DocumentName",
                                                                                                                                                  "DocumentNoName",
                                                                                                                                                  "SalesMan1_EmpFirstName",
                                                                                                                                                  "SalesMan1_EmpFirstName",
                                                                                                                                                  "SalesMan1_EmpLastName",
                                                                                                                                                  "SalesMan2_EmpFirstName",
                                                                                                                                                  "SalesMan2_EmpLastName",
                                                                                                                                                  "SalesSupport_EmpFirstName",
                                                                                                                                                  "SalesSupport_EmpLastName",
                                                                                                                                                  "Alm_EmpFirstName",
                                                                                                                                                  "Alm_EmpLastName",
                                                                                                                                                  "NegStaff1_EmpFirstName",
                                                                                                                                                  "NegStaff1_EmpLastName",
                                                                                                                                                  "NegStaff2_EmpFirstName",
                                                                                                                                                  "NegStaff2_EmpLastName",
                                                                                                                                                  "CompStaff_EmpFirstName",
                                                                                                                                                  "CompStaff_EmpLastName",
                                                                                                                                                  "Planner_EmpFirstName",
                                                                                                                                                  "Planner_EmpLastName",
                                                                                                                                                  "PlanChecker_EmpFirstName",
                                                                                                                                                  "PlanChecker_EmpLastName",
                                                                                                                                                  "PlanApprover_EmpFirstName",
                                                                                                                                                  "PlanApprover_EmpLastName"
                                                                                                                                                  );



                    /**** Convert code to short format *****/
                    foreach (var item in vw_dtRentalContract)
                    {
                        // contract code
                        item.ContractCode    = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        item.OldContractCode = c.ConvertContractCode(item.OldContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);

                        // customer code
                        item.ContractTargetCustCode = c.ConvertCustCode(item.ContractTargetCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        item.RealCustomerCustCode   = c.ConvertCustCode(item.RealCustomerCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT);


                        //site code
                        item.SiteCode = c.ConvertSiteCode(item.SiteCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    }

                    // dtOnlineContractInfo
                    foreach (var item in dtOnlineContractInfo)
                    {
                        item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    }
                }

                // Sale
                if (dtSaleContract.Count > 0)
                {
                    // Get related data
                    //dtOnlineContractInfo = handlerVC.GetContractTargetInfoByRelated(strContractCode, RelationType.C_RELATION_TYPE_SALE, dtSaleContract[0].OCC, ProductType.C_PROD_TYPE_SALE, ProductType.C_PROD_TYPE_AL, ProductType.C_PROD_TYPE_ONLINE, dtSaleContract[0].ProductTypeCode,
                    //                                                                 RelationType.C_RELATION_TYPE_MA, RelationType.C_RELATION_TYPE_SALE);
                    //dtMaintenanceContractInfo = handlerVC.GetContractTargetInfoByRelated(strContractCode, RelationType.C_RELATION_TYPE_MA, dtSaleContract[0].OCC, ProductType.C_PROD_TYPE_SALE, ProductType.C_PROD_TYPE_AL, ProductType.C_PROD_TYPE_ONLINE, dtSaleContract[0].ProductTypeCode,
                    //                                                                     RelationType.C_RELATION_TYPE_MA, RelationType.C_RELATION_TYPE_SALE);
                    dtOnlineContractInfo      = handlerVC.GetContractTargetInfoByRelated(strContractCode, RelationType.C_RELATION_TYPE_SALE, dtSaleContract[0].OCC, dtSaleContract[0].ProductTypeCode);
                    dtMaintenanceContractInfo = handlerVC.GetContractTargetInfoByRelated(strContractCode, RelationType.C_RELATION_TYPE_MA, dtSaleContract[0].OCC, dtSaleContract[0].ProductTypeCode);


                    //Must get InstallationInterfaceHandler.GetInstallationStatus (Next phase)
                    strInstallationStatusCode = iHandler.GetInstallationStatus(strContractCode);
                    //======== GET INSTALLATION STATUS NAME =============================
                    List <doMiscTypeCode> lst   = new List <doMiscTypeCode>();
                    List <doMiscTypeCode> miscs = new List <doMiscTypeCode>()
                    {
                        new doMiscTypeCode()
                        {
                            FieldName = MiscType.C_INSTALL_STATUS,
                            ValueCode = strInstallationStatusCode
                        }
                    };
                    lst = chandler.GetMiscTypeCodeList(miscs);
                    if (lst != null && lst.Count > 0)
                    {
                        strInstallationStatusName = lst[0].ValueDisplay;
                    }
                    //================================================================

                    // select language
                    vw_dtSaleContract = CommonUtil.ConvertObjectbyLanguage <dtTbt_SaleBasicForView, dtTbt_SaleBasicForView>(dtSaleContract,
                                                                                                                            "PurCust_CustName",
                                                                                                                            "PurCust_CustFullName",
                                                                                                                            "RealCust_CustName",
                                                                                                                            "RealCust_CustFullName",
                                                                                                                            "site_SiteName",
                                                                                                                            "QuoEmp_EmpFirstName",
                                                                                                                            "QuoEmp_EmpLastName",
                                                                                                                            "DocTemp_DocumentName",
                                                                                                                            "DocTemp_DocumentNoName",
                                                                                                                            "PlanEmp_EmpFirstName",
                                                                                                                            "PlanEmp_EmpLastName",
                                                                                                                            "planAppEmp_EmpFirstName",
                                                                                                                            "planAppEmp_EmpLastName",
                                                                                                                            "PlanChkrEmp_EmpFirstName",
                                                                                                                            "PlanChkrEmp_EmpLastName",
                                                                                                                            "ProductName",
                                                                                                                            "SalesMan1_EmpFirstName",
                                                                                                                            "SalesMan1_EmpLastName",
                                                                                                                            "Quo_OfficeName", "Con_OfficeName", "Sale_OfficeName", "Op_OfficeName");



                    /**** Convert code to short format *****/

                    // vw_dtSaleContract
                    foreach (var item in vw_dtSaleContract)
                    {
                        // contract code
                        item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);

                        // customer code

                        item.CustCode_PurCust     = c.ConvertCustCode(item.CustCode_PurCust, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        item.CustCode_RealCust    = c.ConvertCustCode(item.CustCode_RealCust, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        item.RealCustomerCustCode = c.ConvertCustCode(item.RealCustomerCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT);

                        // site code
                        item.SiteCode = c.ConvertSiteCode(item.SiteCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    }


                    // dtMaintenanceContractInfo
                    foreach (var item in dtMaintenanceContractInfo)
                    {
                        item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    }

                    // Online contract
                    foreach (var item in dtOnlineContractInfo)
                    {
                        item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    }
                }


                // Rental
                if (vw_dtRentalContract.Count > 0)
                {
                    /*  --- global variable for javascript side --*/

                    ViewBag._ContractCode       = vw_dtRentalContract[0].ContractCode;
                    ViewBag._OCC                = vw_dtRentalContract[0].LastOCC;
                    ViewBag._ContractTargetCode = vw_dtRentalContract[0].ContractTargetCustCode;
                    ViewBag._RealCustomerCode   = vw_dtRentalContract[0].RealCustomerCustCode;
                    ViewBag._SiteCode           = vw_dtRentalContract[0].SiteCode;
                    ViewBag._ServiceTypeCode    = vw_dtRentalContract[0].ServiceTypeCode;
                    ViewBag._OldContractCode    = vw_dtRentalContract[0].OldContractCode;

                    ViewBag.ProductTypeCode = vw_dtRentalContract[0].ProductTypeCode;
                    ViewBag.SiteCodeList    = vw_dtRentalContract[0].SiteCode;
                    ViewBag.ContractCode    = vw_dtRentalContract[0].ContractCode;

                    ViewBag.txtContractCode  = vw_dtRentalContract[0].ContractCode;
                    ViewBag.txtOccurrence    = vw_dtRentalContract[0].LastOCC;
                    ViewBag.txtUserCode      = vw_dtRentalContract[0].UserCode;
                    ViewBag.lnkCustomerCodeC = vw_dtRentalContract[0].ContractTargetCustCode;


                    ViewBag.lnkCustomerCodeR = vw_dtRentalContract[0].RealCustomerCustCode;
                    ViewBag.lnkSiteCode      = vw_dtRentalContract[0].SiteCode;

                    ViewBag.txtContractNameEng = vw_dtRentalContract[0].CustFullNameEN_Cust; // ContractTargetFullNameEN
                    ViewBag.txtContractAddrEng = vw_dtRentalContract[0].AddressFullEN_Cust;
                    ViewBag.txtSiteNameEng     = vw_dtRentalContract[0].SiteNameEN_Site;
                    ViewBag.txtSiteAddrEng     = vw_dtRentalContract[0].AddressFullEN_Site;

                    ViewBag.txtContractNameLocal = vw_dtRentalContract[0].CustFullNameLC_Cust; // ContractTargetFullNameLC
                    ViewBag.txtContractAddrLocal = vw_dtRentalContract[0].AddressFullLC_Cust;
                    ViewBag.txtSiteNameLocal     = vw_dtRentalContract[0].SiteNameLC_Site;
                    ViewBag.txtSiteAddrLocal     = vw_dtRentalContract[0].AddressFullLC_Site;

                    //Add by Jutarat A. on 26032014
                    ViewBag.txtCustomerContact = vw_dtRentalContract[0].ContactPersonName_Cust;
                    ViewBag.txtTelephoneNoCust = vw_dtRentalContract[0].PhoneNo_Cust;
                    ViewBag.txtFaxNo           = vw_dtRentalContract[0].FaxNo_Cust;

                    ViewBag.txtPersonInCharge  = vw_dtRentalContract[0].PersonInCharge_Site;
                    ViewBag.txtTelephoneNoSite = vw_dtRentalContract[0].PhoneNo_Site;
                    //End Add

                    //ViewBag.txtContactPoint = vw_dtRentalContract[0].ContactPoint;
                    ViewBag.txtContactPoint = CommonUtil.IsNullOrEmpty(vw_dtRentalContract[0].ContactPoint) == true ? "-" : vw_dtRentalContract[0].ContactPoint;



                    // section: contract detail info

                    //ViewBag.txtReceived_deposit_fee = vw_dtRentalContract[0].BilledDepositFee != null ? vw_dtRentalContract[0].BilledDepositFee.Value.ToString(floatNumberFormat) : "-";
                    // SA request to chagnge :31/Jan/2012  ref. UCCM1-8
                    //ViewBag.txtReceived_deposit_fee = vw_dtRentalContract[0].PaidDepositFee.HasValue ? vw_dtRentalContract[0].PaidDepositFee.Value.ToString(floatNumberFormat) : "-";
                    // SA request to chagnge#2 :15/Mar/2012 ref. UCCM1-75
                    ViewBag.txtReceived_deposit_fee = vw_dtRentalContract[0].TextTransferOrderDepositFee;
                    //ViewBag.txtReceived_deposit_fee = vw_dtRentalContract[0].OrderDepositFee.HasValue ? vw_dtRentalContract[0].OrderDepositFee.Value.ToString(floatNumberFormat) : "-";


                    ViewBag.txtOperation_office     = CommonUtil.TextCodeName(vw_dtRentalContract[0].OperationOfficeCode, vw_dtRentalContract[0].Op_OfficeName);
                    ViewBag.txtFirst_operation_date = vw_dtRentalContract[0].FirstSecurityStartDate != null ? vw_dtRentalContract[0].FirstSecurityStartDate.Value.ToString(dateFormat) : "-";
                    ViewBag.txtContract_fee         = vw_dtRentalContract[0].TextTransferLastOrderContractFee;
                    //ViewBag.txtContract_fee = vw_dtRentalContract[0].LastOrderContractFee != null ? vw_dtRentalContract[0].LastOrderContractFee.Value.ToString(floatNumberFormat) : "-";
                    ViewBag.txtContract_office     = CommonUtil.TextCodeName(vw_dtRentalContract[0].OfficeCode_Con, vw_dtRentalContract[0].Con_OfficeName);
                    ViewBag.txtLast_operation_date = vw_dtRentalContract[0].LastChangeImplementDate != null ? vw_dtRentalContract[0].LastChangeImplementDate.Value.ToString(dateFormat) : "-";
                    //ViewBag.txtProcessing_installation = "-";  Get value from InstallInterfaceHandler.GetInstallationSatatus (ContractCode)

                    if (strInstallationStatusCode != InstallationStatus.C_INSTALL_STATUS_NO_INSTALLATION)
                    {
                        ViewBag.txtProcessing_installation = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_COMMON, "CMS190", "lblYes");
                    }
                    else
                    {
                        ViewBag.txtProcessing_installation = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_COMMON, "CMS190", "lblNo");
                    }
                    //ViewBag.txtProcessing_installation = strInstallationStatusCode+" : "+strInstallationStatusName;

                    string strLastChangeTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList,
                                                                                           MiscType.C_RENTAL_CHANGE_TYPE,
                                                                                           vw_dtRentalContract[0].LastChangeType);
                    ViewBag.txtLast_change_type = CommonUtil.TextCodeName(vw_dtRentalContract[0].LastChangeType, strLastChangeTypeDisplayValue);
                    //ViewBag.txtProcessing_installation_status = "-"; Get value from InstallInterfaceHandler.GetInstallationSatatus (ContractCode)
                    ViewBag.txtProcessing_installation_status = strInstallationStatusCode + " : " + strInstallationStatusName;

                    ViewBag.lnkOld_contract_codeC = vw_dtRentalContract[0].OldContractCode;


                    //** // Change bOutOfRegulationDocFlag  --> to RentalContract[0].IrregurationDocUsageFlag (old: vw_dtRentalSecurity[0].DocAuditResult )
                    ViewBag.bOutOfRegulationDocFlag = vw_dtRentalContract[0].IrregurationDocUsageFlag.HasValue == true ? vw_dtRentalContract[0].IrregurationDocUsageFlag.Value : false;

                    ViewBag.txtRentalAttachImportanceFlag = vw_dtRentalContract[0].SpecialCareFlag;
                }

                if (vw_dtRentalSecurity.Count > 0)
                {
                    // section: contract detail info
                    ViewBag.txtProduct            = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ProductCode, vw_dtRentalSecurity[0].ProductName);
                    ViewBag.txtSecurity_type_code = vw_dtRentalSecurity[0].SecurityTypeCode;

                    // ContractStartDate - ContractEndDate
                    string strContractStartDate = vw_dtRentalSecurity[0].ContractStartDate != null ? vw_dtRentalSecurity[0].ContractStartDate.Value.ToString(dateFormat) : string.Empty;
                    //string strContractEndDate = vw_dtRentalSecurity[0].ContractEndDate != null ? vw_dtRentalSecurity[0].ContractEndDate.Value.ToString(dateFormat) : string.Empty;
                    string strContractEndDate = vw_dtRentalSecurity[0].CalContractEndDate != null ? vw_dtRentalSecurity[0].CalContractEndDate.Value.ToString(dateFormat) : string.Empty;

                    ViewBag.strContractStartDate = strContractStartDate;
                    ViewBag.strContractEndDate   = strContractEndDate;
                    if (CommonUtil.IsNullOrEmpty(strContractStartDate) == false && CommonUtil.IsNullOrEmpty(strContractEndDate) == false)
                    {
                        ViewBag.txtContract_duration = string.Format("{0} <span style='color:black;'> ~ </span> {1}", strContractStartDate, strContractEndDate);
                    }
                    else if (CommonUtil.IsNullOrEmpty(strContractStartDate) == false)
                    {
                        ViewBag.txtContract_duration = string.Format("{0} <span style='color:black;'> ~ </span> {1}", strContractStartDate, "-");
                    }
                    else if (CommonUtil.IsNullOrEmpty(strContractEndDate) == false)
                    {
                        ViewBag.txtContract_duration = string.Format("{0} <span style='color:black;'> ~ </span> {1}", "-", strContractEndDate);
                    }
                    else
                    {
                        ViewBag.txtContract_duration = string.Empty;
                    }



                    ViewBag.txtSalesman1 = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].SalesmanEmpNo1, string.Format("{0} {1}", vw_dtRentalSecurity[0].SalesMan1_EmpFirstName, vw_dtRentalSecurity[0].SalesMan1_EmpLastName));;
                    ViewBag.txtContract_duration_month = vw_dtRentalSecurity[0].ContractDurationMonth != null ? vw_dtRentalSecurity[0].ContractDurationMonth.Value.ToString(numberFormat) : "-";
                    ViewBag.txtAuto_renew_months       = vw_dtRentalSecurity[0].AutoRenewMonth != null ? vw_dtRentalSecurity[0].AutoRenewMonth.Value.ToString(numberFormat) : "-";

                    // Change bOutOfRegulationDocFlag  --> to RentalContract[0].IrregurationDocUsageFlag
                    //ViewBag.bOutOfRegulationDocFlag = vw_dtRentalSecurity[0].DocAuditResult == "1" ? true : false  ;

                    ViewBag.chkFire_monitoring     = vw_dtRentalSecurity[0].FireMonitorFlag.HasValue == true ? vw_dtRentalSecurity[0].FireMonitorFlag.Value : false;
                    ViewBag.chkCrime_prevention    = vw_dtRentalSecurity[0].CrimePreventFlag.HasValue == true ? vw_dtRentalSecurity[0].CrimePreventFlag.Value : false;;
                    ViewBag.chkEmergency_report    = vw_dtRentalSecurity[0].EmergencyReportFlag.HasValue == true ? vw_dtRentalSecurity[0].EmergencyReportFlag.Value : false;;
                    ViewBag.chkFacility_monitoring = vw_dtRentalSecurity[0].FacilityMonitorFlag.HasValue == true ? vw_dtRentalSecurity[0].FacilityMonitorFlag.Value : false;;
                }

                // Sale
                if (vw_dtSaleContract.Count > 0)
                {
                    /*  --- global variable for javascript side --*/
                    ViewBag._ContractCode      = vw_dtSaleContract[0].ContractCode;
                    ViewBag._OCC               = vw_dtSaleContract[0].OCC;
                    ViewBag._PurchaserCustCode = vw_dtSaleContract[0].CustCode_PurCust;
                    ViewBag._RealCustomerCode  = vw_dtSaleContract[0].RealCustomerCustCode;
                    ViewBag._SiteCode          = vw_dtSaleContract[0].SiteCode;
                    ViewBag._ServiceTypeCode   = vw_dtSaleContract[0].ServiceTypeCode;
                    ViewBag.SiteCodeList       = vw_dtSaleContract[0].SiteCode;
                    ViewBag.ContractCode       = vw_dtSaleContract[0].ContractCode;
                    ViewBag.ProductTypeCode    = vw_dtSaleContract[0].ProductTypeCode;

                    ViewBag.txtContractCode = vw_dtSaleContract[0].ContractCode;
                    ViewBag.txtOccurrence   = vw_dtSaleContract[0].OCC;

                    ViewBag.lnkCustomerCodeC_Purchaser = vw_dtSaleContract[0].CustCode_PurCust;
                    ViewBag.lnkCustomerCodeR           = vw_dtSaleContract[0].RealCustomerCustCode;
                    ViewBag.lnkSiteCode = vw_dtSaleContract[0].SiteCode;

                    ViewBag.txtContractNameEng = vw_dtSaleContract[0].PurCust_CustFullNameEN;
                    ViewBag.txtContractAddrEng = vw_dtSaleContract[0].AddressFullEN_PurCust;
                    ViewBag.txtSiteNameEng     = vw_dtSaleContract[0].site_SiteNameEN;
                    ViewBag.txtSiteAddrEng     = vw_dtSaleContract[0].AddressFullEN_site;

                    ViewBag.txtContractNameLocal = vw_dtSaleContract[0].PurCust_CustFullNameLC;
                    ViewBag.txtContractAddrLocal = vw_dtSaleContract[0].AddressFullLC_PurCust;
                    ViewBag.txtSiteNameLocal     = vw_dtSaleContract[0].site_SiteNameLC;
                    ViewBag.txtSiteAddrLocal     = vw_dtSaleContract[0].AddressFullLC_site;

                    //Add by Jutarat A. on 26032014
                    ViewBag.txtCustomerContact = vw_dtSaleContract[0].ContactPersonName_PurCust;
                    ViewBag.txtTelephoneNoCust = vw_dtSaleContract[0].PhoneNo_PurCust;
                    ViewBag.txtFaxNo           = vw_dtSaleContract[0].FaxNo_PurCust;

                    ViewBag.txtPersonInCharge  = vw_dtSaleContract[0].PersonInCharge_site;
                    ViewBag.txtTelephoneNoSite = vw_dtSaleContract[0].PhoneNo_site;
                    //End Add

                    //ViewBag.txtContactPoint = vw_dtSaleContract[0].ContactPoint;
                    ViewBag.txtContactPoint = CommonUtil.IsNullOrEmpty(vw_dtSaleContract[0].ContactPoint) == true ? "-" : vw_dtSaleContract[0].ContactPoint;


                    // section : sale contract detail info
                    ViewBag.txtProduct = CommonUtil.TextCodeName(vw_dtSaleContract[0].ProductCode, vw_dtSaleContract[0].ProductName);

                    string strSaleTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList,
                                                                                     MiscType.C_SALE_TYPE,
                                                                                     vw_dtSaleContract[0].SalesType);
                    ViewBag.txtSale_type        = CommonUtil.TextCodeName(vw_dtSaleContract[0].SalesType, strSaleTypeDisplayValue);
                    ViewBag.txtProduct_Price    = vw_dtSaleContract[0].TextTransferOrderProductPrice;
                    ViewBag.txtInstallation_Fee = vw_dtSaleContract[0].TextTransferOrderInstallFee;
                    //ViewBag.txtBilling_amount = vw_dtSaleContract[0].TextTransferOrderSalePrice;
                    //ViewBag.txtBilling_amount = vw_dtSaleContract[0].OrderSalePrice != null ? vw_dtSaleContract[0].OrderSalePrice.Value.ToString(floatNumberFormat) : "-";

                    string SaleProdessManagementStatusDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList,
                                                                                                     MiscType.C_SALE_PROC_MANAGE_STATUS,
                                                                                                     vw_dtSaleContract[0].SaleProcessManageStatus);
                    ViewBag.txtProcess_management_status = CommonUtil.TextCodeName(vw_dtSaleContract[0].SaleProcessManageStatus, SaleProdessManagementStatusDisplayValue);

                    ViewBag.txtLast_operation_date = vw_dtSaleContract[0].ChangeImplementDate != null ? vw_dtSaleContract[0].ChangeImplementDate.Value.ToString(dateFormat) : "-";

                    //ViewBag.txtProcessing_installation = "-";Get value from InstallInterfaceHandler.GetInstallationSatatus (ContractCode)
                    if (strInstallationStatusCode != InstallationStatus.C_INSTALL_STATUS_NO_INSTALLATION)
                    {
                        ViewBag.txtProcessing_installation = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_COMMON, "CMS190", "lblYes");
                    }
                    else
                    {
                        ViewBag.txtProcessing_installation = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_COMMON, "CMS190", "lblNo");
                    }
                    //ViewBag.txtProcessing_installation = strInstallationStatusCode + " : " + strInstallationStatusName;

                    string strChangeTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList,
                                                                                       MiscType.C_SALE_CHANGE_TYPE,
                                                                                       vw_dtSaleContract[0].ChangeType);
                    ViewBag.txtLast_change_type = CommonUtil.TextCodeName(vw_dtSaleContract[0].ChangeType, strChangeTypeDisplayValue);
                    //ViewBag.txtProcessing_installation_status = "-"; Get value from InstallInterfaceHandler.GetInstallationSatatus (ContractCode)
                    ViewBag.txtProcessing_installation_status = strInstallationStatusCode + " : " + strInstallationStatusName;

                    ViewBag.txtApprove_date = vw_dtSaleContract[0].FirstContractDate != null ? vw_dtSaleContract[0].FirstContractDate.Value.ToString(dateFormat) : "-";
                    ViewBag.txtSalesman1    = CommonUtil.TextCodeName(vw_dtSaleContract[0].SalesmanEmpNo1, string.Format("{0} {1}", vw_dtSaleContract[0].SalesMan1_EmpFirstName, vw_dtSaleContract[0].SalesMan1_EmpLastName));

                    ViewBag.txtInstrument_stock_out_date = vw_dtSaleContract[0].InstrumentStockOutDate != null ? vw_dtSaleContract[0].InstrumentStockOutDate.Value.ToString(dateFormat) : "-";
                    ViewBag.txtContract_office           = CommonUtil.TextCodeName(vw_dtSaleContract[0].ContractOfficeCode, vw_dtSaleContract[0].Con_OfficeName);

                    ViewBag.txtComplete_installation_date = vw_dtSaleContract[0].InstallCompleteDate != null ? vw_dtSaleContract[0].InstallCompleteDate.Value.ToString(dateFormat) : "-";
                    ViewBag.txtSales_office             = CommonUtil.TextCodeName(vw_dtSaleContract[0].SalesOfficeCode, vw_dtSaleContract[0].Sale_OfficeName);
                    ViewBag.txtCustomer_acceptance_date = vw_dtSaleContract[0].CustAcceptanceDate != null ? vw_dtSaleContract[0].CustAcceptanceDate.Value.ToString(dateFormat) : "-";
                    ViewBag.txtOperation_office         = CommonUtil.TextCodeName(vw_dtSaleContract[0].OperationOfficeCode, vw_dtSaleContract[0].Op_OfficeName);

                    ViewBag.txtSaleAttachImportanceFlag = vw_dtSaleContract[0].SpecialCareFlag;
                }

                if (dtOnlineContractInfo.Count > 0)
                {
                    ViewBag.lnkOnline_contract_code = dtOnlineContractInfo[0].ContractCode;
                    ViewBag._OnlineContractCode     = dtOnlineContractInfo[0].ContractCode;
                }

                if (dtMaintenanceContractInfo.Count > 0)
                {
                    ViewBag.lnkMaintenance_contract_code = dtMaintenanceContractInfo[0].ContractCode;
                    ViewBag._MaintenanceContractCode     = dtMaintenanceContractInfo[0].ContractCode;
                }

                return(View());
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
        public ActionResult CMS220()
        {
            CMS220_ScreenParameter cond = new CMS220_ScreenParameter();

            try
            {
                cond = GetScreenObject <CMS220_ScreenParameter>();
            }
            catch
            {
            }

            // Conver to long format
            CommonUtil c = new CommonUtil();

            cond.ContractCode       = c.ConvertContractCode(cond.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);
            cond.ContractTargetCode = c.ConvertCustCode(cond.ContractTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG);
            cond.PurchaserCustCode  = c.ConvertCustCode(cond.PurchaserCustCode, CommonUtil.CONVERT_TYPE.TO_LONG);
            cond.RealCustomerCode   = c.ConvertCustCode(cond.RealCustomerCode, CommonUtil.CONVERT_TYPE.TO_LONG);
            cond.SiteCode           = c.ConvertSiteCode(cond.SiteCode, CommonUtil.CONVERT_TYPE.TO_LONG);


            // Keep data to ViewBag
            ViewBag.isShowContractTarget = false;
            ViewBag.isShowPurchaser      = false;
            ViewBag.isShowRealCustomer   = false;
            ViewBag.isShowSite           = false;


            string CustomerCode = string.Empty;
            string OCC          = string.Empty;
            string ContractCode = string.Empty;


            // Assign value of CSCustCode , RCCustCode
            if (!CommonUtil.IsNullOrEmpty(cond.ContractTargetCode))
            {
                cond.CSCustCode = cond.ContractTargetCode;
            }
            else if (!CommonUtil.IsNullOrEmpty(cond.PurchaserCustCode))
            {
                cond.CSCustCode = cond.PurchaserCustCode;
            }
            else if (!CommonUtil.IsNullOrEmpty(cond.RealCustomerCode))
            {
                cond.RCCustCode = cond.RealCustomerCode;
            }


            // View mode
            if (cond.Mode == "Contract")
            {
                ViewBag.isShowContractTarget = true;

                ContractCode = cond.ContractCode;
                OCC          = cond.OCC;
                CustomerCode = cond.ContractTargetCode;
            }
            else if (cond.Mode == "Purchaser")
            {
                ViewBag.isShowPurchaser = true;

                ContractCode = cond.ContractCode;
                OCC          = cond.OCC;
                CustomerCode = cond.PurchaserCustCode;
            }
            else if (cond.Mode == "Customer")
            {
                ViewBag.isShowRealCustomer = true;

                ContractCode = "NotSpecify";
                OCC          = "NotSpecify";
                CustomerCode = cond.RealCustomerCode;
            }
            else if (cond.Mode == "Site")
            {
                ViewBag.isShowSite = true;
            }



            try
            {
                ICommonHandler handlerComm  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <string>  lsFieldNames = new List <string>();
                lsFieldNames.Add(MiscType.C_CONTRACT_SIGNER_TYPE);
                lsFieldNames.Add(MiscType.C_CUST_STATUS);
                lsFieldNames.Add(MiscType.C_CUST_TYPE);
                lsFieldNames.Add(MiscType.C_FINANCIAL_MARKET_TYPE);

                List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);


                //IViewContractHandler handler = ServiceContainer.GetService<IViewContractHandler>() as IViewContractHandler;
                //List<dtChangedCustHistList2> list = handler.GetChangedCustHistList2(cond);

                // *******

                ICustomerMasterHandler handlerCM = ServiceContainer.GetService <ICustomerMasterHandler>() as ICustomerMasterHandler;
                IViewContractHandler   handlerVC = ServiceContainer.GetService <IViewContractHandler>() as IViewContractHandler;
                ISiteMasterHandler     handlerSM = ServiceContainer.GetService <ISiteMasterHandler>() as ISiteMasterHandler;



                List <doCustomer>           listCustomer = new List <doCustomer>();
                List <doSite>               listSite     = new List <doSite>();
                List <dtContractSignerType> listSigner   = new List <dtContractSignerType>();

                listCustomer = handlerCM.GetCustomer(CustomerCode);
                listSigner   = handlerVC.GetContractSignerType(MiscType.C_CONTRACT_SIGNER_TYPE, ContractCode, OCC);
                listSite     = handlerSM.GetSite(cond.SiteCode, null);

                // select language
                listCustomer = CommonUtil.ConvertObjectbyLanguage <doCustomer, doCustomer>(listCustomer,
                                                                                           "BusinessTypeName",
                                                                                           "Nationality",
                                                                                           "CustStatusName",
                                                                                           "CustTypeName",
                                                                                           "FinancialMaketTypeName"
                                                                                           );


                // select language
                listSite = CommonUtil.ConvertObjectbyLanguage <doSite, doSite>(listSite, "BuildingUsageName");

                // select language
                listSigner = CommonUtil.ConvertObjectbyLanguage <dtContractSignerType, dtContractSignerType>(listSigner, "ContractSignerTypeName");



                // Convert code to short format
                foreach (doCustomer item in listCustomer)
                {
                    item.CustCode = c.ConvertCustCode(item.CustCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                }

                foreach (var item in listSite)
                {
                    item.SiteCode = c.ConvertSiteCode(item.SiteCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                }


                if (listCustomer.Count > 0)
                {
                    if (!CommonUtil.IsNullOrEmpty(cond.ContractTargetCode))
                    {
                        ViewBag.txtCTCustomerCode = listCustomer[0].CustCode;

                        if (listSigner.Count > 0)
                        {
                            ViewBag.txtCTContractSignerType = CommonUtil.TextCodeName(listSigner[0].ContractSignerTypeCode, listSigner[0].ContractSignerTypeName);
                        }


                        ViewBag.txtCTCustomerStatus = CommonUtil.TextCodeName(listCustomer[0].CustStatus, listCustomer[0].CustStatusName);

                        ViewBag.txtCTCustomerType             = CommonUtil.TextCodeName(listCustomer[0].CustTypeCode, listCustomer[0].CustTypeName);
                        ViewBag.txtCTName_English             = listCustomer[0].CustFullNameEN;
                        ViewBag.txtCTAddress_English          = listCustomer[0].AddressFullEN;
                        ViewBag.txtCTName_Local               = listCustomer[0].CustFullNameLC;
                        ViewBag.txtCTAddress_Local            = listCustomer[0].AddressFullLC;
                        ViewBag.txtCTRepresentativePersonName = listCustomer[0].RepPersonName;
                        ViewBag.txtCTContactPersonName        = listCustomer[0].ContactPersonName;
                        ViewBag.txtCTNationality              = listCustomer[0].Nationality;
                        ViewBag.txtCTTelephoneNo              = listCustomer[0].PhoneNo;
                        ViewBag.txtCTFinancialMarketType      = CommonUtil.TextCodeName(listCustomer[0].FinancialMarketTypeCode, listCustomer[0].FinancialMaketTypeName);
                        ViewBag.txtCTBusinessType             = listCustomer[0].BusinessTypeName;
                        ViewBag.txtCTIDTax = listCustomer[0].IDNo;
                        ViewBag.txtCTSECOMContactPerson = listCustomer[0].SECOMContactPerson;
                        ViewBag.txtCTURL = listCustomer[0].URL;

                        // ** Old version
                        //ViewBag.txtCTBranchName_English = listCustomer[0].BranchNameEN;
                        //ViewBag.txtCTBranchAddress_English = listCustomer[0].BranchAddressEN;
                        //ViewBag.txtCTBranchName_Local = listCustomer[0].BranchNameLC;
                        //ViewBag.txtCTBranchAddress_Local = listCustomer[0].BranchAddressLC;
                    }

                    if (!CommonUtil.IsNullOrEmpty(cond.PurchaserCustCode))
                    {
                        ViewBag.txtPUCustomerCode = listCustomer[0].CustCode;

                        if (listSigner.Count > 0)
                        {
                            ViewBag.txtPUContractSignerType = CommonUtil.TextCodeName(listSigner[0].ContractSignerTypeCode, listSigner[0].ContractSignerTypeName);
                        }

                        ViewBag.txtPUCustomerStatus = CommonUtil.TextCodeName(listCustomer[0].CustStatus, listCustomer[0].CustStatusName);


                        ViewBag.txtPUCustomerType             = CommonUtil.TextCodeName(listCustomer[0].CustTypeCode, listCustomer[0].CustTypeName);
                        ViewBag.txtPUName_English             = listCustomer[0].CustFullNameEN;
                        ViewBag.txtPUAddress_English          = listCustomer[0].AddressFullEN;
                        ViewBag.txtPUName_Local               = listCustomer[0].CustFullNameLC;
                        ViewBag.txtPUAddress_Local            = listCustomer[0].AddressFullLC;
                        ViewBag.txtPURepresentativePersonName = listCustomer[0].RepPersonName;
                        ViewBag.txtPUContactPersonName        = listCustomer[0].ContactPersonName;
                        ViewBag.txtPUNationality              = listCustomer[0].Nationality;
                        ViewBag.txtPUTelephoneNo              = listCustomer[0].PhoneNo;

                        ViewBag.txtPUFinancialMarketType = CommonUtil.TextCodeName(listCustomer[0].FinancialMarketTypeCode, listCustomer[0].FinancialMaketTypeName);
                        ViewBag.txtPUBusinessType        = listCustomer[0].BusinessTypeName;
                        ViewBag.txtPUIDTax = listCustomer[0].IDNo;
                        ViewBag.txtPUSECOMContactPerson = listCustomer[0].SECOMContactPerson;
                        ViewBag.txtPUURL = listCustomer[0].URL;

                        // ** Old version
                        //ViewBag.txtPUBranchName_English = listCustomer[0].BranchNameEN;
                        //ViewBag.txtPUBranchAddress_English = listCustomer[0].BranchAddressEN;
                        //ViewBag.txtPUBranchName_Local = listCustomer[0].BranchNameLC;
                        //ViewBag.txtPUBranchAddress_Local = listCustomer[0].BranchAddressLC;
                    }


                    if (!CommonUtil.IsNullOrEmpty(cond.RealCustomerCode))
                    {
                        ViewBag.txtRCCustomerCode = listCustomer[0].CustCode;

                        ViewBag.txtRCCustomerStatus           = CommonUtil.TextCodeName(listCustomer[0].CustStatus, listCustomer[0].CustStatusName);
                        ViewBag.txtRCCustomerType             = CommonUtil.TextCodeName(listCustomer[0].CustTypeCode, listCustomer[0].CustTypeName);
                        ViewBag.txtRCName_English             = listCustomer[0].CustFullNameEN;
                        ViewBag.txtRCAddress_English          = listCustomer[0].AddressFullEN;
                        ViewBag.txtRCName_Local               = listCustomer[0].CustFullNameLC;
                        ViewBag.txtRCAddress_Local            = listCustomer[0].AddressFullLC;
                        ViewBag.txtRCRepresentativePersonName = listCustomer[0].RepPersonName;
                        ViewBag.txtRCContactPersonName        = listCustomer[0].ContactPersonName;
                        ViewBag.txtRCNationality              = listCustomer[0].Nationality;
                        ViewBag.txtRCTelephoneNo              = listCustomer[0].PhoneNo;

                        ViewBag.txtRCFinancialMarketType = CommonUtil.TextCodeName(listCustomer[0].FinancialMarketTypeCode, listCustomer[0].FinancialMaketTypeName);
                        ViewBag.txtRCBusinessType        = listCustomer[0].BusinessTypeName;
                        ViewBag.txtRCIDTax = listCustomer[0].IDNo;
                        ViewBag.txtRCSECOMContactPerson = listCustomer[0].SECOMContactPerson;
                        ViewBag.txtRCURL = listCustomer[0].URL;

                        //** old version
                        //ViewBag.txtRCBranchName_English = listCustomer[0].BranchNameEN;
                        //ViewBag.txtRCBranchAddress_English = listCustomer[0].BranchAddressEN;
                        //ViewBag.txtRCBranchName_Local = listCustomer[0].BranchNameLC;
                        //ViewBag.txtRCBranchAddress_Local = listCustomer[0].BranchAddressLC;
                    }
                }
                if (listSite.Count > 0)
                {
                    if (!CommonUtil.IsNullOrEmpty(cond.SiteCode))
                    {
                        ViewBag.txtSiteCode            = listSite[0].SiteCode;
                        ViewBag.txtSiteName_English    = listSite[0].SiteNameEN;
                        ViewBag.txtSiteAddress_English = listSite[0].AddressFullEN;
                        ViewBag.txtSiteName_Local      = listSite[0].SiteNameLC;
                        ViewBag.txtSiteAddress_Local   = listSite[0].AddressFullLC;
                        ViewBag.txtSiteTelephoneNo     = listSite[0].PhoneNo;
                        ViewBag.txtSiteUsage           = listSite[0].BuildingUsageName;

                        ViewBag.txtAttachImportanceFlag = listSite[0].SpecialCareFlag;
                    }
                }
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }


            return(View());
        }
Exemple #14
0
        public ActionResult CMS130()
        {
            string strContractCode = "";
            string strOCC          = "";

            try
            {
                CMS130_ScreenParameter param = GetScreenObject <CMS130_ScreenParameter>();
                strContractCode = param.ContractCode;
                strOCC          = param.OCC;
            }
            catch
            {
            }

            /* ----- Set grobal variable for javascript side ---- */
            ViewBag.strContractCode = strContractCode;

            CommonUtil c = new CommonUtil();

            strContractCode = c.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);

            List <dtTbt_RentalContractBasicForView> vw_dtRentalContract = new List <dtTbt_RentalContractBasicForView>();
            List <dtTbt_RentalSecurityBasicForView> vw_dtRentalSecurity = new List <dtTbt_RentalSecurityBasicForView>();

            ViewBag.Currency = CommonValue.CURRENCY_UNIT;
            string dateFormat        = "dd-MMM-yyyy";
            string numberFormat      = "N0";
            string floatNumberFormat = "N2";

            // default ViewBag
            ViewBag.chkFire_monitoring     = false;
            ViewBag.chkCrime_prevention    = false;
            ViewBag.chkEmergency_report    = false;
            ViewBag.chkFacility_monitoring = false;

            ViewBag.chkOut_of_regulation_document_usage_flag = false;

            try
            {
                ICommonHandler handlerComm = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

                List <string> lsFieldNames = new List <string>();
                lsFieldNames.Add(MiscType.C_RENTAL_CHANGE_TYPE);
                lsFieldNames.Add(MiscType.C_CHANGE_NAME_REASON_TYPE);
                lsFieldNames.Add(MiscType.C_REASON_TYPE);
                lsFieldNames.Add(MiscType.C_STOP_CANCEL_REASON_TYPE);
                lsFieldNames.Add(MiscType.C_MA_TARGET_PROD_TYPE);
                lsFieldNames.Add(MiscType.C_MA_TYPE);
                lsFieldNames.Add(MiscType.C_MA_FEE_TYPE);
                lsFieldNames.Add(MiscType.C_NUM_OF_DATE);
                lsFieldNames.Add(MiscType.C_OPERATION_TYPE);
                lsFieldNames.Add(MiscType.C_INSURANCE_TYPE);
                lsFieldNames.Add(MiscType.C_DOC_AUDIT_RESULT);
                lsFieldNames.Add(MiscType.C_RENTAL_INSTALL_TYPE);
                lsFieldNames.Add(MiscType.C_CHANGE_REASON_TYPE);

                // Get Misc type
                List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);

                // Rental
                IRentralContractHandler handler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;

                List <dtTbt_RentalContractBasicForView>     dtRentalContract  = handler.GetTbt_RentalContractBasicForView(strContractCode);
                List <dtTbt_RentalSecurityBasicForView>     dtRentalSecurity  = new List <dtTbt_RentalSecurityBasicForView>();
                List <dtTbt_RentalOperationTypeListForView> dtRentalOperation = new List <dtTbt_RentalOperationTypeListForView>();
                ICommonHandler        comHand       = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_CURRENCT,
                        ValueCode = "%"
                    }
                }).ToList();

                if (dtRentalContract.Count > 0)
                {
                    // Get related data
                    dtRentalSecurity  = handler.GetTbt_RentalSecurityBasicForView(strContractCode, (CommonUtil.IsNullOrEmpty(strOCC) == false ? strOCC : dtRentalContract[0].LastOCC));
                    dtRentalOperation = handler.GetTbt_RentalOperationTypeListForView(strContractCode, (dtRentalSecurity.Count > 0 ? dtRentalSecurity[0].OCC : strOCC));

                    for (int i = 0; i < dtRentalSecurity.Count(); i++)
                    {
                        dtRentalSecurity[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                    }

                    //Check Currency
                    if (dtRentalSecurity[0].NormalContractFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].NormalContractFee = dtRentalSecurity[0].NormalContractFeeUsd;
                    }
                    if (dtRentalSecurity[0].OrderContractFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].OrderContractFee = dtRentalSecurity[0].OrderContractFeeUsd;
                    }
                    if (dtRentalSecurity[0].NormalInstallFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].NormalInstallFee = dtRentalSecurity[0].NormalInstallFeeUsd;
                    }
                    if (dtRentalSecurity[0].OrderInstallFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].OrderInstallFee = dtRentalSecurity[0].OrderInstallFeeUsd;
                    }
                    if (dtRentalSecurity[0].NewBldMgmtCostCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].NewBldMgmtCost = dtRentalSecurity[0].NewBldMgmtCostUsd;
                    }
                    if (dtRentalSecurity[0].ContractFeeOnStopCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].ContractFeeOnStop = dtRentalSecurity[0].ContractFeeOnStopUsd;
                    }
                    if (dtRentalSecurity[0].InsuranceCoverageAmountCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].InsuranceCoverageAmount = dtRentalSecurity[0].InsuranceCoverageAmountUsd;
                    }
                    if (dtRentalSecurity[0].MonthlyInsuranceFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].MonthlyInsuranceFee = dtRentalSecurity[0].MonthlyInsuranceFeeUsd;
                    }
                    if (dtRentalSecurity[0].MaintenanceFee1CurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].MaintenanceFee1 = dtRentalSecurity[0].MaintenanceFee1Usd;
                    }
                    if (dtRentalSecurity[0].AdditionalFee1CurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].AdditionalFee1 = dtRentalSecurity[0].AdditionalFee1Usd;
                    }
                    if (dtRentalSecurity[0].AdditionalFee2CurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].AdditionalFee2 = dtRentalSecurity[0].AdditionalFee2Usd;
                    }
                    if (dtRentalSecurity[0].AdditionalFee3CurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].AdditionalFee3 = dtRentalSecurity[0].AdditionalFee3Usd;
                    }
                    if (dtRentalSecurity[0].OrderInstallFee_ApproveContractCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].OrderInstallFee_ApproveContract = dtRentalSecurity[0].OrderInstallFee_ApproveContractUsd;
                    }
                    if (dtRentalSecurity[0].OrderInstallFee_CompleteInstallCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].OrderInstallFee_CompleteInstall = dtRentalSecurity[0].OrderInstallFee_CompleteInstallUsd;
                    }
                    if (dtRentalSecurity[0].OrderInstallFee_StartServiceCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].OrderInstallFee_StartService = dtRentalSecurity[0].OrderInstallFee_StartServiceUsd;
                    }
                    if (dtRentalSecurity[0].InstallFeePaidBySECOMCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].InstallFeePaidBySECOM = dtRentalSecurity[0].InstallFeePaidBySECOMUsd;
                    }
                    if (dtRentalSecurity[0].InstallFeeRevenueBySECOMCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        dtRentalSecurity[0].InstallFeeRevenueBySECOM = dtRentalSecurity[0].InstallFeeRevenueBySECOMUsd;
                    }

                    /* ----- Set grobal variable for javascript side ---- */
                    ViewBag.strOCC = (dtRentalSecurity.Count > 0 ? dtRentalSecurity[0].OCC : strOCC);

                    // Select language
                    vw_dtRentalContract = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalContractBasicForView, dtTbt_RentalContractBasicForView>(dtRentalContract, "Quo_OfficeName", "Con_OfficeName", "Op_OfficeName");
                    vw_dtRentalSecurity = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalSecurityBasicForView, dtTbt_RentalSecurityBasicForView>(dtRentalSecurity,
                                                                                                                                                  "ProductName",
                                                                                                                                                  "DocumentName",
                                                                                                                                                  "DocumentNoName",
                                                                                                                                                  "SalesMan1_EmpFirstName",
                                                                                                                                                  "SalesMan1_EmpFirstName",
                                                                                                                                                  "SalesMan1_EmpLastName",
                                                                                                                                                  "SalesMan2_EmpFirstName",
                                                                                                                                                  "SalesMan2_EmpLastName",
                                                                                                                                                  "SalesSupport_EmpFirstName",
                                                                                                                                                  "SalesSupport_EmpLastName",
                                                                                                                                                  "Alm_EmpFirstName",
                                                                                                                                                  "Alm_EmpLastName",
                                                                                                                                                  "NegStaff1_EmpFirstName",
                                                                                                                                                  "NegStaff1_EmpLastName",
                                                                                                                                                  "NegStaff2_EmpFirstName",
                                                                                                                                                  "NegStaff2_EmpLastName",
                                                                                                                                                  "CompStaff_EmpFirstName",
                                                                                                                                                  "CompStaff_EmpLastName",
                                                                                                                                                  "Planner_EmpFirstName",
                                                                                                                                                  "Planner_EmpLastName",
                                                                                                                                                  "PlanChecker_EmpFirstName",
                                                                                                                                                  "PlanChecker_EmpLastName",
                                                                                                                                                  "PlanApprover_EmpFirstName",
                                                                                                                                                  "PlanApprover_EmpLastName"
                                                                                                                                                  );

                    /**** Convert code to short format *****/

                    // vw_dtRentalContract
                    foreach (var item in vw_dtRentalContract)
                    {
                        // contractcode
                        item.ContractCode    = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        item.OldContractCode = c.ConvertContractCode(item.OldContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        item.CounterBalanceOriginContractCode = c.ConvertContractCode(item.CounterBalanceOriginContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        // customercode
                        item.ContractTargetCustCode = c.ConvertCustCode(item.ContractTargetCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        item.RealCustomerCustCode   = c.ConvertCustCode(item.RealCustomerCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT);

                        // sitecode
                        item.SiteCode = c.ConvertSiteCode(item.SiteCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    }

                    // vw_dtRentalSecurity
                    foreach (var item in vw_dtRentalSecurity)
                    {
                        // contractcode
                        item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        // quotation target code
                        item.QuotationTargetCode = c.ConvertQuotationTargetCode(item.QuotationTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    }


                    if (vw_dtRentalContract.Count > 0)
                    {
                        /* ----- Set grobal variable for javascript side ---- */

                        ViewBag.ProductTypeCode    = vw_dtRentalContract[0].ProductTypeCode;
                        ViewBag.ContractTargetCode = vw_dtRentalContract[0].ContractTargetCustCode;
                        ViewBag.RealCustomerCode   = vw_dtRentalContract[0].RealCustomerCustCode;
                        ViewBag.SiteCode           = vw_dtRentalContract[0].SiteCode;
                        ViewBag.ServiceTypeCode    = vw_dtRentalContract[0].ServiceTypeCode;

                        ViewBag.SiteCodeList = dtRentalContract[0].SiteCode;        // for parameter of generate link function ;
                        ViewBag.ContractCode = vw_dtRentalContract[0].ContractCode; // for parameter of generate link function ;

                        ViewBag.txtContractCode  = vw_dtRentalContract[0].ContractCode;
                        ViewBag.txtUserCode      = vw_dtRentalContract[0].UserCode;
                        ViewBag.lnkCustomerCodeC = vw_dtRentalContract[0].ContractTargetCustCode;
                        ViewBag.lnkCustomerCodeR = vw_dtRentalContract[0].RealCustomerCustCode;
                        ViewBag.lnkSiteCode      = vw_dtRentalContract[0].SiteCode;

                        ViewBag.txtContractNameEng = vw_dtRentalContract[0].CustFullNameEN_Cust; // ContractTargetFullNameEN
                        ViewBag.txtContractAddrEng = vw_dtRentalContract[0].AddressFullEN_Cust;
                        ViewBag.txtSiteNameEng     = vw_dtRentalContract[0].SiteNameEN_Site;
                        ViewBag.txtSiteAddrEng     = vw_dtRentalContract[0].AddressFullEN_Site;

                        ViewBag.txtContractNameLocal = vw_dtRentalContract[0].CustFullNameLC_Cust; // ContractTargetFullNameLC
                        ViewBag.txtContractAddrLocal = vw_dtRentalContract[0].AddressFullLC_Cust;
                        ViewBag.txtSiteNameLocal     = vw_dtRentalContract[0].SiteNameLC_Site;
                        ViewBag.txtSiteAddrLocal     = vw_dtRentalContract[0].AddressFullLC_Site;

                        ViewBag.txtContactPoint = CommonUtil.IsNullOrEmpty(vw_dtRentalContract[0].ContactPoint) == true ? "-" : vw_dtRentalContract[0].ContactPoint;

                        //ViewBag.txtContactPoint = vw_dtRentalContract[0].ContactPoint;


                        //

                        ViewBag.chkOut_of_regulation_document_usage_flag = vw_dtRentalContract[0].IrregurationDocUsageFlag != null ?
                                                                           vw_dtRentalContract[0].IrregurationDocUsageFlag.Value : false;
                        ViewBag.txtAttachImportanceFlag = vw_dtRentalContract[0].SpecialCareFlag;
                    }
                }

                // RentalSecurityBasicForView (RSB)
                if (vw_dtRentalSecurity.Count > 0)
                {
                    /* ----- Set grobal variable for javascript side ---- */
                    ViewBag.QuotationTargetCode = vw_dtRentalSecurity[0].QuotationTargetCode;
                    ViewBag.QuotationAlphabet   = vw_dtRentalSecurity[0].QuotationAlphabet;
                    ViewBag.InstallationSlipNo  = vw_dtRentalSecurity[0].InstallationSlipNo;

                    // OCC
                    ViewBag.txtOccurrence = vw_dtRentalSecurity[0].OCC;

                    // Product information

                    ViewBag.txtContractFee = vw_dtRentalSecurity[0].TextTransferOrderContractFee;
                    //ViewBag.txtContractFee = vw_dtRentalSecurity[0].OrderContractFee != null ? vw_dtRentalSecurity[0].OrderContractFee.Value.ToString(floatNumberFormat) : "-";
                    ViewBag.txtChange_operation_date = (vw_dtRentalSecurity[0].ChangeImplementDate != null ? vw_dtRentalSecurity[0].ChangeImplementDate.Value.ToString(dateFormat) : "-");

                    ViewBag.txtStopFee = vw_dtRentalSecurity[0].TextTransferContractFeeOnStop;
                    //ViewBag.txtStopFee = vw_dtRentalSecurity[0].ContractFeeOnStop != null ? vw_dtRentalSecurity[0].ContractFeeOnStop.Value.ToString(floatNumberFormat) : "-";

                    ViewBag.txtSecurity_type_code = vw_dtRentalSecurity[0].SecurityTypeCode;
                    ViewBag.txtProduct            = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ProductCode, vw_dtRentalSecurity[0].ProductName);

                    string strChangeTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_RENTAL_CHANGE_TYPE, vw_dtRentalSecurity[0].ChangeType);
                    ViewBag.txtChange_type = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ChangeType, strChangeTypeDisplayValue);

                    string strDisvplayValue = "";
                    if (vw_dtRentalSecurity[0].ChangeType == "24" || vw_dtRentalSecurity[0].ChangeType == "35")
                    {
                        strDisvplayValue  = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_CHANGE_NAME_REASON_TYPE, vw_dtRentalSecurity[0].ChangeNameReasonType);
                        ViewBag.txtReason = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ChangeNameReasonType, strDisvplayValue);
                    }
                    else if (vw_dtRentalSecurity[0].ChangeType == "21")
                    {
                        strDisvplayValue  = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_CHANGE_REASON_TYPE, vw_dtRentalSecurity[0].ChangeReasonType);
                        ViewBag.txtReason = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ChangeReasonType, strDisvplayValue);
                    }
                    else if (vw_dtRentalSecurity[0].ChangeType == "31" ||
                             vw_dtRentalSecurity[0].ChangeType == "32" ||
                             vw_dtRentalSecurity[0].ChangeType == "33" ||
                             vw_dtRentalSecurity[0].ChangeType == "34" ||
                             vw_dtRentalSecurity[0].ChangeType == "36" ||
                             vw_dtRentalSecurity[0].ChangeType == "38" ||
                             vw_dtRentalSecurity[0].ChangeType == "39"
                             )
                    {
                        strDisvplayValue  = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_STOP_CANCEL_REASON_TYPE, vw_dtRentalSecurity[0].StopCancelReasonType);
                        ViewBag.txtReason = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].StopCancelReasonType, strDisvplayValue);
                    }
                    else
                    {
                        ViewBag.txtReason = "-";
                    }

                    ViewBag.txtNegotiation_staff_1 = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].NegotiationStaffEmpNo1, string.Format("{0} {1}",
                                                                                                                                          vw_dtRentalSecurity[0].NegStaff1_EmpFirstName,
                                                                                                                                          vw_dtRentalSecurity[0].NegStaff1_EmpLastName));
                    ViewBag.txtNegotiation_staff_2 = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].NegotiationStaffEmpNo2, string.Format("{0} {1}",
                                                                                                                                          vw_dtRentalSecurity[0].NegStaff2_EmpFirstName,
                                                                                                                                          vw_dtRentalSecurity[0].NegStaff2_EmpLastName));

                    ViewBag.txtApprove_no1 = vw_dtRentalSecurity[0].ApproveNo1;
                    ViewBag.txtApprove_no2 = vw_dtRentalSecurity[0].ApproveNo2;
                    ViewBag.txtChange_operation_register_date = (vw_dtRentalSecurity[0].CompleteChangeOperationDate != null ?
                                                                 vw_dtRentalSecurity[0].CompleteChangeOperationDate.Value.ToString(dateFormat) : "-");
                    ViewBag.txtChange_operation_registrant = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].CompleteChangeOperationEmpNo, string.Format("{0} {1}",
                                                                                                                                                        vw_dtRentalSecurity[0].CompStaff_EmpFirstName,
                                                                                                                                                        vw_dtRentalSecurity[0].CompStaff_EmpLastName));
                    ViewBag.txtSecurity_memo = vw_dtRentalSecurity[0].SecurityMemo;



                    // Alam provide service type
                    ViewBag.chkFire_monitoring     = (vw_dtRentalSecurity[0].FireMonitorFlag != null ? vw_dtRentalSecurity[0].FireMonitorFlag.Value : false);
                    ViewBag.chkCrime_prevention    = (vw_dtRentalSecurity[0].CrimePreventFlag != null ? vw_dtRentalSecurity[0].CrimePreventFlag.Value : false);
                    ViewBag.chkEmergency_report    = (vw_dtRentalSecurity[0].EmergencyReportFlag != null ? vw_dtRentalSecurity[0].EmergencyReportFlag.Value : false);
                    ViewBag.chkFacility_monitoring = (vw_dtRentalSecurity[0].FacilityMonitorFlag != null ? vw_dtRentalSecurity[0].FacilityMonitorFlag.Value : false);


                    // section: insurance information

                    string strInsuranceTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_INSURANCE_TYPE, vw_dtRentalSecurity[0].InsuranceTypeCode);
                    ViewBag.txtInsuranceType             = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].InsuranceTypeCode, strInsuranceTypeDisplayValue);
                    ViewBag.txtInsurance_coverage_amount = vw_dtRentalSecurity[0].TextTransferInsuranceCoverageAmount;
                    //ViewBag.txtInsurance_coverage_amount = (vw_dtRentalSecurity[0].InsuranceCoverageAmount != null ? vw_dtRentalSecurity[0].InsuranceCoverageAmount.Value.ToString(floatNumberFormat) : "-");
                    ViewBag.txtMonthly_insurance_fee = vw_dtRentalSecurity[0].TextTransferMonthlyInsuranceFee;
                    //ViewBag.txtMonthly_insurance_fee = (vw_dtRentalSecurity[0].MonthlyInsuranceFee != null ? vw_dtRentalSecurity[0].MonthlyInsuranceFee.Value.ToString(floatNumberFormat) : "-");

                    // section: contract document information

                    string strDocAuditResultDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_DOC_AUDIT_RESULT, vw_dtRentalSecurity[0].DocAuditResult);
                    ViewBag.txtDocument_audit_result  = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].DocAuditResult, strDocAuditResultDisplayValue);
                    ViewBag.txtContract_document_type = vw_dtRentalSecurity[0].DocumentName;


                    // section: future date information
                    ViewBag.txtExpected_resume_service_date = vw_dtRentalSecurity[0].ExpectedResumeDate != null ? vw_dtRentalSecurity[0].ExpectedResumeDate.Value.ToString(dateFormat) : "-";
                    ViewBag.txtReturn_date_to_original_fee  = vw_dtRentalSecurity[0].ReturnToOriginalFeeDate != null ? vw_dtRentalSecurity[0].ReturnToOriginalFeeDate.Value.ToString(dateFormat) : "-";


                    // section: quotaion information
                    ViewBag.lnkQuotationCode       = (CommonUtil.IsNullOrEmpty(vw_dtRentalSecurity[0].QuotationTargetCode) == true || CommonUtil.IsNullOrEmpty(vw_dtRentalSecurity[0].QuotationAlphabet) == true) ? string.Empty : (string.Format("{0}-{1}", vw_dtRentalSecurity[0].QuotationTargetCode, vw_dtRentalSecurity[0].QuotationAlphabet));
                    ViewBag.txtPlan_code           = vw_dtRentalSecurity[0].PlanCode;
                    ViewBag.txtQuatationNo         = vw_dtRentalContract[0].QuotationNo;
                    ViewBag.txtPlan_approving_date = vw_dtRentalSecurity[0].PlanApproveDate != null ? vw_dtRentalSecurity[0].PlanApproveDate.Value.ToString(dateFormat) : "-";
                    ViewBag.txtPlan_approver       = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].PlanApproverEmpNo, string.Format("{0} {1}",
                                                                                                                                     vw_dtRentalSecurity[0].PlanApprover_EmpFirstName
                                                                                                                                     , vw_dtRentalSecurity[0].PlanApprover_EmpLastName));

                    ViewBag.txtNormal_contract_fee = vw_dtRentalSecurity[0].TextTransferNormalContractFee;
                    //ViewBag.txtNormal_contract_fee = vw_dtRentalSecurity[0].NormalContractFee != null ? vw_dtRentalSecurity[0].NormalContractFee.Value.ToString(floatNumberFormat) : "-";


                    ViewBag.txtOutsourcing_fee = vw_dtRentalSecurity[0].TextTransferMaintenanceFee1;
                    //ViewBag.txtOutsourcing_fee = vw_dtRentalSecurity[0].MaintenanceFee1 != null ? vw_dtRentalSecurity[0].MaintenanceFee1.Value.ToString(floatNumberFormat) : "-";

                    ViewBag.txtAdditional_contract_fee1 = vw_dtRentalSecurity[0].TextTransferAdditionalFee1;
                    ViewBag.txtAdditional_contract_fee2 = vw_dtRentalSecurity[0].TextTransferAdditionalFee2;
                    ViewBag.txtAdditional_contract_fee3 = vw_dtRentalSecurity[0].TextTransferAdditionalFee3;

                    //ViewBag.txtAdditional_contract_fee1 = vw_dtRentalSecurity[0].AdditionalFee1 != null ? vw_dtRentalSecurity[0].AdditionalFee1.Value.ToString(floatNumberFormat) : "-";
                    //ViewBag.txtAdditional_contract_fee2 = vw_dtRentalSecurity[0].AdditionalFee2 != null ? vw_dtRentalSecurity[0].AdditionalFee2.Value.ToString(floatNumberFormat) : "-";
                    //ViewBag.txtAdditional_contract_fee3 = vw_dtRentalSecurity[0].AdditionalFee3 != null ? vw_dtRentalSecurity[0].AdditionalFee3.Value.ToString(floatNumberFormat) : "-";



                    // section: installation information

                    string strIntallationtypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_RENTAL_INSTALL_TYPE, vw_dtRentalSecurity[0].InstallationTypeCode);
                    ViewBag.txtInstallation_type = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].InstallationTypeCode, strIntallationtypeDisplayValue);

                    ViewBag.txtComplete_installation_date = vw_dtRentalSecurity[0].InstallationCompleteDate != null ? vw_dtRentalSecurity[0].InstallationCompleteDate.Value.ToString(dateFormat) : "-";

                    ViewBag.txtNormal_installation_fee = vw_dtRentalSecurity[0].TextTransferNormalInstallFee;
                    //ViewBag.txtNormal_installation_fee = vw_dtRentalSecurity[0].NormalInstallFee != null ? vw_dtRentalSecurity[0].NormalInstallFee.Value.ToString(floatNumberFormat) : "-";

                    ViewBag.txtOrder_installation_fee = vw_dtRentalSecurity[0].TextTransferOrderInstallFee;
                    //ViewBag.txtOrder_installation_fee = vw_dtRentalSecurity[0].OrderInstallFee != null ? vw_dtRentalSecurity[0].OrderInstallFee.Value.ToString(floatNumberFormat) : "-";

                    ViewBag.txtOrder_installation_fee_Approve_contract = vw_dtRentalSecurity[0].TextTransferOrderInstallFee_ApproveContract;
                    //ViewBag.txtOrder_installation_fee_Approve_contract = vw_dtRentalSecurity[0].OrderInstallFee_ApproveContract != null ? vw_dtRentalSecurity[0].OrderInstallFee_ApproveContract.Value.ToString(floatNumberFormat) : "-";

                    ViewBag.txtOrder_installation_fee_Complete_installation = vw_dtRentalSecurity[0].TextTransferOrderInstallFee_CompleteInstall;
                    //ViewBag.txtOrder_installation_fee_Complete_installation = vw_dtRentalSecurity[0].OrderInstallFee_CompleteInstall != null ? vw_dtRentalSecurity[0].OrderInstallFee_CompleteInstall.Value.ToString(floatNumberFormat) : "-";

                    ViewBag.txtOrder_installation_fee_Start_service = vw_dtRentalSecurity[0].TextTransferOrderInstallFee_StartService;
                    //ViewBag.txtOrder_installation_fee_Start_service = vw_dtRentalSecurity[0].OrderInstallFee_StartService != null ? vw_dtRentalSecurity[0].OrderInstallFee_StartService.Value.ToString(floatNumberFormat) : "-";

                    ViewBag.txtSECOM_payment = vw_dtRentalSecurity[0].TextTransferInstallFeePaidBySECOM;
                    //ViewBag.txtSECOM_payment = vw_dtRentalSecurity[0].InstallFeePaidBySECOM != null ? vw_dtRentalSecurity[0].InstallFeePaidBySECOM.Value.ToString(floatNumberFormat) : "-";
                    ViewBag.txtSECOM_revenue = vw_dtRentalSecurity[0].TextTransferInstallFeeRevenueBySECOM;
                    //ViewBag.txtSECOM_revenue = vw_dtRentalSecurity[0].InstallFeeRevenueBySECOM != null ? vw_dtRentalSecurity[0].InstallFeeRevenueBySECOM.Value.ToString(floatNumberFormat) : "-";
                    ViewBag.lnkInstallation_slip_no = vw_dtRentalSecurity[0].InstallationSlipNo;
                }

                //dtRentalOperation
                if (dtRentalOperation.Count > 0)
                {
                    //string strOperationtypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_OPERATION_TYPE, dtRentalOperation[0].OperationTypeCode );
                    //ViewBag.txtOperation_type = CommonUtil.TextCodeName(dtRentalOperation[0].OperationTypeCode, strOperationtypeDisplayValue);

                    List <string> lstOperationType = new List <string>();
                    foreach (var item in dtRentalOperation)
                    {
                        lstOperationType.Add(item.OperationTypeCode);
                    }

                    ViewBag.chkOperationTypeList = lstOperationType.ToArray();
                }


                return(View());
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
        /// <summary>
        /// Get billing temporary list by condition
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ActionResult CMS200_GetBillingTempList(doContractInfoCondition cond)
        {
            CommonUtil c = new CommonUtil();

            List <View_dtTbt_BillingTempListForView> nlst = new List <View_dtTbt_BillingTempListForView>();

            ObjectResultData res = new ObjectResultData();

            try
            {
                cond.ContractCode = c.ConvertContractCode(cond.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                ICommonContractHandler handler       = ServiceContainer.GetService <ICommonContractHandler>() as ICommonContractHandler;
                ICommonHandler         comHand       = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode>  tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_CURRENCT,
                        ValueCode = "%"
                    }
                }).ToList();

                List <dtTbt_BillingTempListForView> list = handler.GetTbt_BillingTempListForView(cond.ContractCode, null);

                //Add Currency
                for (int i = 0; i < list.Count(); i++)
                {
                    if (list[i].BillingAmtCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                    {
                        list[i].BillingAmt = list[i].BillingAmtUsd;
                    }
                    list[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                }

                // clone object to View
                foreach (dtTbt_BillingTempListForView l in list)
                {
                    nlst.Add(CommonUtil.CloneObject <dtTbt_BillingTempListForView, View_dtTbt_BillingTempListForView>(l));
                }


                // select language
                nlst = CommonUtil.ConvertObjectbyLanguage <View_dtTbt_BillingTempListForView, View_dtTbt_BillingTempListForView>(nlst, "BillingOffice");

                // get misc display value
                ICommonHandler handlerComm  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <string>  lsFieldNames = new List <string>();
                lsFieldNames.Add(MiscType.C_BILLING_TIMING);
                lsFieldNames.Add(MiscType.C_CONTRACT_BILLING_TYPE);
                lsFieldNames.Add(MiscType.C_PAYMENT_METHOD);

                List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);

                string strDisplayValue = string.Empty;
                foreach (var item in nlst)
                {
                    strDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList,
                                                                      MiscType.C_BILLING_TIMING,
                                                                      item.BillingTiming)
                    ;
                    item.BillingTiming_EX = strDisplayValue; // CommonUtil.TextCodeName(item.BillingTiming, strDisplayValue);

                    strDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList,
                                                                      MiscType.C_CONTRACT_BILLING_TYPE,
                                                                      item.BillingType);
                    item.BillingType_EX = strDisplayValue; // CommonUtil.TextCodeName(item.BillingType, strDisplayValue);

                    strDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList,
                                                                      MiscType.C_PAYMENT_METHOD,
                                                                      item.PayMethod);
                    item.Paymethod_EX = strDisplayValue; // CommonUtil.TextCodeName(item.PayMethod, strDisplayValue);
                }

                // Sorting , order by BillingOCC
                nlst = (from p in nlst orderby p.BillingOCC ascending select p).ToList <View_dtTbt_BillingTempListForView>();
            }
            catch (Exception ex)
            {
                nlst = new List <View_dtTbt_BillingTempListForView>();
                res.AddErrorMessage(ex);
            }

            res.ResultData = CommonUtil.ConvertToXml <View_dtTbt_BillingTempListForView>(nlst, "Common\\CMS200");
            return(Json(res));
        }
        /// <summary>
        /// - Check system suspending.<br />
        /// - Check user permission for screen IVS140.<br />
        /// - Check freezed data.<br />
        /// - Check started stock checking.<br />
        /// - Get inventory head office.
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult IVS140_Authority(IVS140_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                // Is suspend ?
                ICommonHandler handler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                if (handler.IsSystemSuspending())
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049);
                    return(Json(res));
                }

                // Check permission
                if (CheckUserPermission(ScreenID.C_INV_SCREEN_ID_CHECKING_RETURN, FunctionID.C_FUNC_ID_OPERATE) == false)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                    return(Json(res));
                }

                // Check freezed data
                IInventoryHandler handlerInventory = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;
                if (handlerInventory.CheckFreezedData() == 0)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4002);
                    return(Json(res));
                }

                // Check for the stock is started
                if (handlerInventory.CheckStartedStockChecking() == 0)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4003);
                    return(Json(res));
                }

                //Get Inventory head office
                List <doOffice> headerOffice = handlerInventory.GetInventoryHeadOffice();
                param.HeaderOffice = headerOffice;

                if (headerOffice == null || headerOffice.Count <= 0 || CommonUtil.IsNullOrEmpty(headerOffice[0].OfficeCode))
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4016);
                    return(Json(res));
                }


                ICommonHandler handlerCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <string>  listFieldName = new List <string>();
                listFieldName.Add(MiscType.C_INV_LOC);
                List <doMiscTypeCode> listMisc = handlerCommon.GetMiscTypeCodeListByFieldName(listFieldName); // This result has language mapping already

                param.Miscellaneous = listMisc;
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(InitialScreenEnvironment <IVS140_ScreenParameter>("IVS140", param, res));
        }
Exemple #17
0
        public ActionResult CMS140()
        {
            string strContractCode = "";
            string strOCC          = "";

            try
            {
                CMS140_ScreenParameter param = GetScreenObject <CMS140_ScreenParameter>();
                strContractCode = param.ContractCode;
                strOCC          = param.OCC;
            }
            catch
            {
            }

            /* ----- Set grobal variable for javascript side ---- */
            ViewBag.strContractCode = strContractCode;

            CommonUtil c = new CommonUtil();

            strContractCode = c.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);

            List <dtTbt_RentalContractBasicForView>      vw_dtRentalContract = new List <dtTbt_RentalContractBasicForView>();
            List <dtTbt_RentalSecurityBasicForView>      vw_dtRentalSecurity = new List <dtTbt_RentalSecurityBasicForView>();
            List <dtTbt_RentalMaintenanceDetailsForView> vw_dtRentalMaint    = new List <dtTbt_RentalMaintenanceDetailsForView>();


            ViewBag.Currency = CommonValue.CURRENCY_UNIT;

            // default ViewBag
            ViewBag.chkFire_monitoring     = false;
            ViewBag.chkCrime_prevention    = false;
            ViewBag.chkEmergency_report    = false;
            ViewBag.chkFacility_monitoring = false;


            try
            {
                ICommonHandler        comHand       = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_CURRENCT,
                        ValueCode = "%"
                    }
                }).ToList();

                ICommonHandler        handlerComm  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode> MiscTypeCode = new List <doMiscTypeCode>();

                List <string> lsFieldNames = new List <string>();
                lsFieldNames.Add(MiscType.C_RENTAL_CHANGE_TYPE);
                lsFieldNames.Add(MiscType.C_CHANGE_NAME_REASON_TYPE);
                lsFieldNames.Add(MiscType.C_REASON_TYPE);
                lsFieldNames.Add(MiscType.C_STOP_CANCEL_REASON_TYPE);
                lsFieldNames.Add(MiscType.C_MA_TARGET_PROD_TYPE);
                lsFieldNames.Add(MiscType.C_MA_TYPE);
                lsFieldNames.Add(MiscType.C_MA_FEE_TYPE);
                lsFieldNames.Add(MiscType.C_SG_AREA_TYPE);
                lsFieldNames.Add(MiscType.C_SG_TYPE);
                lsFieldNames.Add(MiscType.C_NUM_OF_DATE);
                lsFieldNames.Add(MiscType.C_CHANGE_REASON_TYPE);

                // Get Misc type
                List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);

                // Rental
                IRentralContractHandler handler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;

                List <dtTbt_RentalContractBasicForView>      dtRentalContract = handler.GetTbt_RentalContractBasicForView(strContractCode);
                List <dtTbt_RentalSecurityBasicForView>      dtRentalSecurity = new List <dtTbt_RentalSecurityBasicForView>();
                List <dtTbt_RentalMaintenanceDetailsForView> dtRentalMaint    = new List <dtTbt_RentalMaintenanceDetailsForView>();
                List <dtTbt_RentalBEDetailsForView>          dtRentalBED      = new List <dtTbt_RentalBEDetailsForView>();
                List <dtTbt_RentalSentryGuardForView>        RentalSG         = new List <dtTbt_RentalSentryGuardForView>();

                if (dtRentalContract.Count > 0)
                {
                    // Get related data
                    dtRentalSecurity = handler.GetTbt_RentalSecurityBasicForView(strContractCode, (CommonUtil.IsNullOrEmpty(strOCC) == false ? strOCC : dtRentalContract[0].LastOCC));
                    dtRentalMaint    = handler.GetTbt_RentalMaintenanceDetailsForView(strContractCode, (dtRentalSecurity.Count > 0 ? dtRentalSecurity[0].OCC : strOCC));
                    dtRentalBED      = handler.GetTbt_RentalBEDetailsForView(strContractCode, (dtRentalSecurity.Count > 0 ? dtRentalSecurity[0].OCC : strOCC));
                    RentalSG         = handler.GetTbt_RentalSentryGuardForView(strContractCode, (CommonUtil.IsNullOrEmpty(strOCC) == false ? strOCC : dtRentalContract[0].LastOCC));

                    //Add Currency
                    for (int i = 0; i < RentalSG.Count(); i++)
                    {
                        if (RentalSG[i].SecurityItemFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                        {
                            RentalSG[i].SecurityItemFee = RentalSG[i].SecurityItemFeeUsd;
                        }
                        if (RentalSG[i].OtherItemFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                        {
                            RentalSG[i].OtherItemFee = RentalSG[i].OtherItemFeeUsd;
                        }
                        RentalSG[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                    }


                    /* ----- Set grobal variable for javascript side ---- */

                    ViewBag.strOCC          = (dtRentalSecurity.Count > 0 ? dtRentalSecurity[0].OCC : strOCC);
                    ViewBag.ProductTypeCode = dtRentalContract[0].ProductTypeCode;


                    // Select language
                    vw_dtRentalContract = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalContractBasicForView, dtTbt_RentalContractBasicForView>(dtRentalContract, "Quo_OfficeName", "Con_OfficeName", "Op_OfficeName");
                    vw_dtRentalSecurity = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalSecurityBasicForView, dtTbt_RentalSecurityBasicForView>(dtRentalSecurity,
                                                                                                                                                  "ProductName",
                                                                                                                                                  "DocumentName",
                                                                                                                                                  "DocumentNoName",
                                                                                                                                                  "SalesMan1_EmpFirstName",
                                                                                                                                                  "SalesMan1_EmpFirstName",
                                                                                                                                                  "SalesMan1_EmpLastName",
                                                                                                                                                  "SalesMan2_EmpFirstName",
                                                                                                                                                  "SalesMan2_EmpLastName",
                                                                                                                                                  "SalesSupport_EmpFirstName",
                                                                                                                                                  "SalesSupport_EmpLastName",
                                                                                                                                                  "Alm_EmpFirstName",
                                                                                                                                                  "Alm_EmpLastName",
                                                                                                                                                  "NegStaff1_EmpFirstName",
                                                                                                                                                  "NegStaff1_EmpLastName",
                                                                                                                                                  "NegStaff2_EmpFirstName",
                                                                                                                                                  "NegStaff2_EmpLastName",
                                                                                                                                                  "CompStaff_EmpFirstName",
                                                                                                                                                  "CompStaff_EmpLastName",
                                                                                                                                                  "Planner_EmpFirstName",
                                                                                                                                                  "Planner_EmpLastName",
                                                                                                                                                  "PlanChecker_EmpFirstName",
                                                                                                                                                  "PlanChecker_EmpLastName",
                                                                                                                                                  "PlanApprover_EmpFirstName",
                                                                                                                                                  "PlanApprover_EmpLastName"
                                                                                                                                                  );


                    vw_dtRentalMaint = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalMaintenanceDetailsForView, dtTbt_RentalMaintenanceDetailsForView>(dtRentalMaint, "MaintenanceTargetProductType", "MaintenanceFeeType");


                    /**** Convert code to short format *****/

                    // vw_dtRentalContract
                    foreach (var item in vw_dtRentalContract)
                    {
                        // contractcode
                        item.ContractCode    = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        item.OldContractCode = c.ConvertContractCode(item.OldContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        item.CounterBalanceOriginContractCode = c.ConvertContractCode(item.CounterBalanceOriginContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        // customercode
                        item.ContractTargetCustCode = c.ConvertCustCode(item.ContractTargetCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        item.RealCustomerCustCode   = c.ConvertCustCode(item.RealCustomerCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT);

                        // sitecode
                        item.SiteCode = c.ConvertSiteCode(item.SiteCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    }

                    // vw_dtRentalMaint
                    foreach (var item in vw_dtRentalMaint)
                    {
                        item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    }

                    // vw_dtRentalSecurity
                    foreach (var item in vw_dtRentalSecurity)
                    {
                        // contractcode
                        item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        // quotation target code
                        item.QuotationTargetCode = c.ConvertQuotationTargetCode(item.QuotationTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    }

                    foreach (var item in RentalSG)
                    {
                        string strDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_SG_AREA_TYPE, item.SentryGuardAreaTypeCode);
                        item.SentryGuardAreaType = CommonUtil.TextCodeName(item.SentryGuardAreaTypeCode, strDisplayValue);
                    }



                    if (vw_dtRentalContract.Count > 0)
                    {
                        /* -- global valiable for javascript */
                        ViewBag.ServiceTypeCode    = vw_dtRentalContract[0].ServiceTypeCode;
                        ViewBag.ContractTargetCode = vw_dtRentalContract[0].ContractTargetCustCode;
                        ViewBag.RealCustomerCode   = vw_dtRentalContract[0].RealCustomerCustCode;
                        ViewBag.SiteCode           = vw_dtRentalContract[0].SiteCode;


                        ViewBag.txtContractCode = vw_dtRentalContract[0].ContractCode;

                        ViewBag.txtUserCode      = vw_dtRentalContract[0].UserCode;
                        ViewBag.lnkCustomerCodeC = vw_dtRentalContract[0].ContractTargetCustCode;
                        ViewBag.lnkCustomerCodeR = vw_dtRentalContract[0].RealCustomerCustCode;
                        ViewBag.lnkSiteCode      = vw_dtRentalContract[0].SiteCode;

                        ViewBag.txtContractNameEng = vw_dtRentalContract[0].CustFullNameEN_Cust; // ContractTargetFullNameEN
                        ViewBag.txtContractAddrEng = vw_dtRentalContract[0].AddressFullEN_Cust;
                        ViewBag.txtSiteNameEng     = vw_dtRentalContract[0].SiteNameEN_Site;
                        ViewBag.txtSiteAddrEng     = vw_dtRentalContract[0].AddressFullEN_Site;

                        ViewBag.txtContractNameLocal = vw_dtRentalContract[0].CustFullNameLC_Cust; // ContractTargetFullNameLC
                        ViewBag.txtContractAddrLocal = vw_dtRentalContract[0].AddressFullLC_Cust;
                        ViewBag.txtSiteNameLocal     = vw_dtRentalContract[0].SiteNameLC_Site;
                        ViewBag.txtSiteAddrLocal     = vw_dtRentalContract[0].AddressFullLC_Site;

                        ViewBag.txtContactPoint = CommonUtil.IsNullOrEmpty(vw_dtRentalContract[0].ContactPoint) == true ? "-" : vw_dtRentalContract[0].ContactPoint;

                        DateTime datFirstSecurityStartDate;
                        if (vw_dtRentalContract[0].FirstSecurityStartDate != null)
                        {
                            datFirstSecurityStartDate = vw_dtRentalContract[0].FirstSecurityStartDate.Value.AddMonths(1);
                            ViewBag.txtMaintenanceContractStart_month_Online = datFirstSecurityStartDate.ToString("MMM-yyyy");
                        }
                        else
                        {
                            ViewBag.txtMaintenanceContractStart_month_Online = "";
                        }

                        ViewBag.txtAttachImportanceFlag = vw_dtRentalContract[0].SpecialCareFlag;
                    }
                }

                // RentalMaintenance Detail for view
                if (vw_dtRentalMaint.Count > 0)
                {
                    ViewBag.txtMaintenance_contractCode = vw_dtRentalMaint[0].ContractCode;

                    string strMaintenanceTargetProductTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_MA_TARGET_PROD_TYPE, vw_dtRentalMaint[0].MaintenanceTargetProductTypeCode);
                    ViewBag.txtMaintenanceTargetProduct = CommonUtil.TextCodeName(vw_dtRentalMaint[0].MaintenanceTargetProductTypeCode, strMaintenanceTargetProductTypeDisplayValue);

                    string strMaintenanceTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_MA_TYPE, vw_dtRentalMaint[0].MaintenanceTypeCode);
                    ViewBag.txtMaintenanceType = CommonUtil.TextCodeName(vw_dtRentalMaint[0].MaintenanceTypeCode, strMaintenanceTypeDisplayValue);

                    int    iStartMonth   = (vw_dtRentalMaint[0].MaintenanceContractStartMonth != null ? vw_dtRentalMaint[0].MaintenanceContractStartMonth.Value : 1);
                    string strStartMonth = (new DateTime(2000, iStartMonth, 1)).ToString("MMM");
                    ViewBag.txtMaintenanceContractStart_month = strStartMonth + "-" + vw_dtRentalMaint[0].MaintenanceContractStartYear.ToString();

                    string strMaintenanceFeeTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_MA_FEE_TYPE, vw_dtRentalMaint[0].MaintenanceFeeTypeCode);
                    ViewBag.txtMaintenanceFeeType = CommonUtil.TextCodeName(vw_dtRentalMaint[0].MaintenanceFeeTypeCode, strMaintenanceFeeTypeDisplayValue);

                    if (CommonUtil.IsNullOrEmpty(vw_dtRentalMaint[0].MaintenanceMemo) == false)
                    {
                        ViewBag.txtMemo = vw_dtRentalMaint[0].MaintenanceMemo;
                    }

                    //ViewBag.txtMemo = vw_dtRentalMaint[0].MaintenanceMemo;
                }

                // RentalSecurityBasicForView (RSB)
                if (vw_dtRentalSecurity.Count > 0)
                {
                    // New requirement 27/Feb/2012
                    ViewBag.FacilityMemo = vw_dtRentalSecurity[0].FacilityMemo;

                    ViewBag.txtOccurrence = CommonUtil.IsNullOrEmpty(vw_dtRentalSecurity[0].OCC) == true ? "-" : vw_dtRentalSecurity[0].OCC;

                    // Product information
                    ViewBag.txtSecurity_type_code = vw_dtRentalSecurity[0].SecurityTypeCode;
                    ViewBag.txtProduct            = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ProductCode, vw_dtRentalSecurity[0].ProductName);

                    string strChangeTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_RENTAL_CHANGE_TYPE, vw_dtRentalSecurity[0].ChangeType);
                    ViewBag.txtChange_type = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ChangeType, strChangeTypeDisplayValue);

                    string strDisvplayValue = "";
                    if (vw_dtRentalSecurity[0].ChangeType == "24")
                    {
                        strDisvplayValue  = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_CHANGE_NAME_REASON_TYPE, vw_dtRentalSecurity[0].ChangeNameReasonType);
                        ViewBag.txtReason = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ChangeNameReasonType, strDisvplayValue);
                    }
                    else if (vw_dtRentalSecurity[0].ChangeType == "21")
                    {
                        strDisvplayValue  = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_CHANGE_REASON_TYPE, vw_dtRentalSecurity[0].ChangeReasonType);
                        ViewBag.txtReason = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ChangeReasonType, strDisvplayValue);
                    }
                    else if (vw_dtRentalSecurity[0].ChangeType == "31" ||
                             vw_dtRentalSecurity[0].ChangeType == "32" ||
                             vw_dtRentalSecurity[0].ChangeType == "33" ||
                             vw_dtRentalSecurity[0].ChangeType == "34" ||
                             vw_dtRentalSecurity[0].ChangeType == "36"
                             )
                    {
                        strDisvplayValue  = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_STOP_CANCEL_REASON_TYPE, vw_dtRentalSecurity[0].StopCancelReasonType);
                        ViewBag.txtReason = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].StopCancelReasonType, strDisvplayValue);
                    }
                    else
                    {
                        ViewBag.txtReason = "-";
                    }


                    ViewBag.txtChange_operation_date = CommonUtil.TextDate(vw_dtRentalSecurity[0].ChangeImplementDate);

                    // Alam provide service type
                    ViewBag.chkFire_monitoring     = (vw_dtRentalSecurity[0].FireMonitorFlag != null ? vw_dtRentalSecurity[0].FireMonitorFlag.Value : false);
                    ViewBag.chkCrime_prevention    = (vw_dtRentalSecurity[0].CrimePreventFlag != null ? vw_dtRentalSecurity[0].CrimePreventFlag.Value : false);
                    ViewBag.chkEmergency_report    = (vw_dtRentalSecurity[0].EmergencyReportFlag != null ? vw_dtRentalSecurity[0].EmergencyReportFlag.Value : false);
                    ViewBag.chkFacility_monitoring = (vw_dtRentalSecurity[0].FacilityMonitorFlag != null ? vw_dtRentalSecurity[0].FacilityMonitorFlag.Value : false);

                    //
                    ViewBag.txtMaintenanceCycleMonth = CommonUtil.TextNumeric(vw_dtRentalSecurity[0].MaintenanceCycle, 0);
                }

                // dtRentalBED
                if (dtRentalBED.Count > 0)
                {
                    ViewBag.txtWeekday_daytime            = (dtRentalBED[0].NumOfDayTimeWd != null ? dtRentalBED[0].NumOfDayTimeWd.Value.ToString("N0") : "-");
                    ViewBag.txtWeekday_nighttime          = (dtRentalBED[0].NumOfNightTimeWd != null ? dtRentalBED[0].NumOfNightTimeWd.Value.ToString("N0") : "-");
                    ViewBag.txtSaturday_daytime           = (dtRentalBED[0].NumOfDayTimeSat != null ? dtRentalBED[0].NumOfDayTimeSat.Value.ToString("N0") : "-");
                    ViewBag.txtSaturday_nighttime         = (dtRentalBED[0].NumOfNightTimeSat != null ? dtRentalBED[0].NumOfNightTimeSat.Value.ToString("N0") : "-");
                    ViewBag.txtSunday_daytime             = (dtRentalBED[0].NumOfDayTimeSun != null ? dtRentalBED[0].NumOfDayTimeSun.Value.ToString("N0") : "-");
                    ViewBag.txtSunday_nighttime           = (dtRentalBED[0].NumOfNightTimeSun != null ? dtRentalBED[0].NumOfNightTimeSun.Value.ToString("N0") : "-");
                    ViewBag.txtNumber_of_beat_guard_steps = (dtRentalBED[0].NumOfBeatStep != null ? dtRentalBED[0].NumOfBeatStep.Value.ToString("N0") : "-");
                    ViewBag.txtFrequency_of_gate_usage    = (dtRentalBED[0].FreqOfGateUsage != null ? dtRentalBED[0].FreqOfGateUsage.Value.ToString("N0") : "-");
                    ViewBag.txtNumber_of_clock_key        = (dtRentalBED[0].NumOfClockKey != null ? dtRentalBED[0].NumOfClockKey.Value.ToString("N0") : "-");

                    string strNumOfDate             = (dtRentalBED[0].NumOfDate != null ? dtRentalBED[0].NumOfDate.Value.ToString() : "-");
                    string strNumOfDateDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_NUM_OF_DATE, strNumOfDate);
                    ViewBag.txtNumber_of_date = CommonUtil.TextCodeName(strNumOfDate, strNumOfDateDisplayValue);

                    ViewBag.txtNotify_time = (dtRentalBED[0].NotifyTime != null ?
                                              string.Format("{0}:{1}", dtRentalBED[0].NotifyTime.Value.ToString("hh"), dtRentalBED[0].NotifyTime.Value.ToString("mm"))
                                                        : "-");
                }

                if (RentalSG.Count > 0)
                {
                    ViewBag.txtSecurity_item_fee = RentalSG[0].TextTransferSecurityItemFee;
                    ViewBag.txtOther_item_fee    = RentalSG[0].TextTransferOtherItemFee;
                    //ViewBag.txtSecurity_item_fee = CommonUtil.TextNumeric(RentalSG[0].SecurityItemFee, 2) == string.Empty ? "-" : CommonUtil.TextNumeric(RentalSG[0].SecurityItemFee, 2);
                    //ViewBag.txtOther_item_fee = CommonUtil.TextNumeric(RentalSG[0].OtherItemFee, 2) == string.Empty ? "-" : CommonUtil.TextNumeric(RentalSG[0].OtherItemFee, 2);
                    ViewBag.txtSentry_guard_area_type = RentalSG[0].SentryGuardAreaType == string.Empty ? "-" : RentalSG[0].SentryGuardAreaType;
                }



                return(View());
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }