Ejemplo n.º 1
0
        /// <summary>
        /// Search and get view billing target data
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ActionResult CMS470_SearchResponse(doBillingTargetDataSearchCondition cond)
        {
            ObjectResultData res = new ObjectResultData();
            CommonUtil       c   = new CommonUtil();
            List <View_dtBillingTargetData> nlst = new List <View_dtBillingTargetData>();
            List <dtBillingTargetData>      list = new List <dtBillingTargetData>();

            try
            {
                /// Validate Require ////////////////
                if (CommonUtil.IsNullOrEmpty(cond.CMS470_chkJuristic) && CommonUtil.IsNullOrEmpty(cond.CMS470_chkIndividual) &&
                    CommonUtil.IsNullOrEmpty(cond.CMS470_chkAssociation) && CommonUtil.IsNullOrEmpty(cond.CMS470_chkPublicOffice) &&
                    CommonUtil.IsNullOrEmpty(cond.CMS470_chkOther))
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON,
                                        ScreenID.C_SCREEN_ID_SEARCH_BILLING_INFORMATION,
                                        MessageUtil.MODULE_COMMON,
                                        MessageUtil.MessageList.MSG0055, null, null);
                    return(Json(res));
                }



                // Concate string CustomerTypeCode with commar separate. like ,xx,yy,zz,
                List <string> lstCustomerTypeCode = new List <string>();
                lstCustomerTypeCode.Add(cond.CMS470_chkJuristic);
                lstCustomerTypeCode.Add(cond.CMS470_chkIndividual);
                lstCustomerTypeCode.Add(cond.CMS470_chkAssociation);
                lstCustomerTypeCode.Add(cond.CMS470_chkPublicOffice);
                lstCustomerTypeCode.Add(cond.CMS470_chkOther);
                cond.CMS470_CustomerTypeCode  = CommonUtil.CreateCSVString(lstCustomerTypeCode);
                cond.CMS470_BillingClientCode = c.ConvertBillingClientCode(cond.CMS470_BillingClientCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                if (cond.CMS470_CustomerTypeCode == string.Empty)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0055);
                    //return Json(res);
                }
                else
                {
                    IViewBillingHandler handler = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;
                    list = handler.GetViewBillingTargetDataForSearch(cond);

                    foreach (dtBillingTargetData l in list)
                    {
                        nlst.Add(CommonUtil.CloneObject <dtBillingTargetData, View_dtBillingTargetData>(l));
                    }
                }
            }
            catch (Exception ex)
            {
                //nlst = new List<View_dtBillingClientData>();
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }

            res.ResultData = CommonUtil.ConvertToXml <View_dtBillingTargetData>(nlst, "Common\\CMS470_ResultBillingTarget", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
            return(Json(res));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get billing detail list
        /// </summary>
        /// <returns></returns>
        public ActionResult CMS450_ViewBillingDetailList()
        {
            ObjectResultData res = new ObjectResultData();
            List <dtViewBillingDetailList> list = new List <dtViewBillingDetailList>();

            try
            {
                CMS450_ScreenParameter param             = GetScreenObject <CMS450_ScreenParameter>();
                CommonUtil             cm                = new CommonUtil();
                string strContractCode                   = cm.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                IViewBillingHandler   handlerViewBilling = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;
                ICommonHandler        comHand            = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode> tmpCurrencies      = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_CURRENCT,
                        ValueCode = "%"
                    }
                }).ToList();

                if (!CommonUtil.IsNullOrEmpty(param.BillingTargetCode))
                {
                    list = handlerViewBilling.GetViewBillingDetailListByTargetCode(cm.ConvertBillingTargetCode(param.BillingTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG));
                }
                else if (!CommonUtil.IsNullOrEmpty(param.BillingOCC) && !CommonUtil.IsNullOrEmpty(param.ContractCode))
                {
                    list = handlerViewBilling.GetViewBillingDetailList(strContractCode, param.BillingOCC);
                }
                else if (!CommonUtil.IsNullOrEmpty(param.InvoiceNo))
                {
                    List <dtViewBillingDetailListOfLastInvoiceOCC> listBillingDetail = handlerViewBilling.GetViewBillingDetailListOfLastInvoiceOCC(param.InvoiceNo, null, null, null, null);
                    for (int i = 0; i < listBillingDetail.Count(); i++)
                    {
                        listBillingDetail[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                    }
                    if (listBillingDetail.Count > 0)
                    {
                        List <dtViewBillingDetailList> lst = CommonUtil.ClonsObjectList <dtViewBillingDetailListOfLastInvoiceOCC, dtViewBillingDetailList>(listBillingDetail);
                        res.ResultData = CommonUtil.ConvertToXml <dtViewBillingDetailList>(lst, "Common\\CMS450_ViewBillingDetailInformation", CommonUtil.GRID_EMPTY_TYPE.VIEW);
                        return(Json(res));
                    }
                }
                for (int i = 0; i < list.Count(); i++)
                {
                    list[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }
            // test
            //list.RemoveRange(0, 670);
            res.ResultData = CommonUtil.ConvertToXml <dtViewBillingDetailList>(list, "Common\\CMS450_ViewBillingDetailInformation", CommonUtil.GRID_EMPTY_TYPE.VIEW);
            return(Json(res));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get View Billin gBasic
        /// </summary>
        /// <param name="strBillingTargetCode"></param>
        /// <returns></returns>
        public ActionResult CMS400_GetViewBillingBasicForGrid(string strBillingTargetCode)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                CommonUtil          cm = new CommonUtil();
                IViewBillingHandler handlerViewBilling = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;
                if (!CommonUtil.IsNullOrEmpty(strBillingTargetCode))
                {
                    strBillingTargetCode = cm.ConvertBillingTargetCode(strBillingTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                }

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

                List <dtViewBillingBasicList> lst = handlerViewBilling.GetViewBillingBasicList(
                    null,
                    strBillingTargetCode,
                    null,
                    null,
                    null,
                    null
                    );

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

                res.ResultData = CommonUtil.ConvertToXml <dtViewBillingBasicList>(lst, "Common\\CMS400_BillingBasic", CommonUtil.GRID_EMPTY_TYPE.VIEW);
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
            return(Json(res));
        }
        /// <summary>
        /// Getting billing occ list for load to grid
        /// </summary>
        /// <returns></returns>
        public ActionResult CMS420_LoadGridBillingOCC()
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                CMS420_ScreenParameter param = GetScreenObject <CMS420_ScreenParameter>();
                CommonUtil             cm    = new CommonUtil();

                string strContractCode_short = param.ContractCode;
                string strContractCode       = cm.ConvertContractCode(strContractCode_short, CommonUtil.CONVERT_TYPE.TO_LONG);

                IViewBillingHandler   viewBillingHandler = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;
                ICommonHandler        comHand            = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode> tmpCurrencies      = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_CURRENCT,
                        ValueCode = "%"
                    }
                }).ToList();
                List <dtViewBillingOccList> viewBillingOccListData = viewBillingHandler.GetViewBillingOccList(strContractCode);
                for (int i = 0; i < viewBillingOccListData.Count(); i++)
                {
                    viewBillingOccListData[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                }

                CommonUtil.MappingObjectLanguage <dtViewBillingOccList>(viewBillingOccListData);

                string xml = CommonUtil.ConvertToXml <dtViewBillingOccList>(viewBillingOccListData, "Common\\CMS420_BillingOCC", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                res.ResultData = xml;
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
        /// <summary>
        /// Check suspend, authority and resume of CMS430
        /// </summary>
        /// <param name="param">Screen parameter</param>
        /// <returns></returns>
        public ActionResult CMS430_Authority(CMS430_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();
            CommonUtil       cm  = new CommonUtil();

            try
            {
                string strContractCode = null;

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

                // If param.ContractCode is null then set to  CommonUtil.dsTransData.dtCommonSearch.ContractCode;
                if (CommonUtil.IsNullOrEmpty(param.ContractCode) == true &&
                    param.CommonSearch != null && string.IsNullOrEmpty(param.CommonSearch.ContractCode) == false)
                {
                    //param.ContractCode = CommonUtil.dsTransData.dtCommonSearch.ContractCode;
                    param.ContractCode = param.CommonSearch.ContractCode;
                }

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

                // is parameter OK ?
                if (CommonUtil.IsNullOrEmpty(param.ContractCode))
                {
                    //res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0040);
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0147);
                    return(Json(res));
                }
                else
                {
                    if (!CommonUtil.IsNullOrEmpty(param.BillingOCC))
                    {
                        List <dtViewDepositDetailInformation> lst = new List <dtViewDepositDetailInformation>();
                        strContractCode = cm.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                        IViewBillingHandler viewHandler = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;

                        lst = viewHandler.GetViewDepositDetailInformation(strContractCode, param.BillingOCC);
                        if (lst.Count <= 0)
                        {
                            res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                            return(Json(res));
                        }
                        else
                        {
                            for (int i = 0; i < lst.Count(); i++)
                            {
                                lst[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                            }
                        }
                    }
                }

                // Check Data Exist

                strContractCode = cm.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                IRentralContractHandler handler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;

                List <dtTbt_RentalContractBasicForView> lstBaisc = handler.GetTbt_RentalContractBasicForView(strContractCode);
                if (lstBaisc.Count <= 0)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                    return(Json(res));
                }
                else
                {
                    for (int i = 0; i < lstBaisc.Count(); i++)
                    {
                        lstBaisc[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                    }
                    param.dtRentalContract = lstBaisc[0];
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(InitialScreenEnvironment <CMS430_ScreenParameter>("CMS430", param, res));
        }
        /// <summary>
        /// Get view deposit detail
        /// </summary>
        /// <param name="ContractCode"></param>
        /// <param name="BillingOCC"></param>
        /// <returns></returns>
        public ActionResult CMS430_GetViewDepositDetailControl(string ContractCode, string BillingOCC)
        {
            ObjectResultData res = new ObjectResultData();
            List <dtViewDepositDetailInformation> lst = new List <dtViewDepositDetailInformation>();

            try
            {
                CMS430_ScreenParameter param        = GetScreenObject <CMS430_ScreenParameter>();
                CommonUtil             cm           = new CommonUtil();
                string strContractCode              = cm.ConvertContractCode(ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                IViewBillingHandler   viewHandler   = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;
                ICommonHandler        comHand       = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_CURRENCT,
                        ValueCode = "%"
                    }
                }).ToList();
                lst = viewHandler.GetViewDepositDetailInformation(strContractCode, BillingOCC);
                for (int i = 0; i < lst.Count(); i++)
                {
                    lst[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                }
                if (lst.Count > 0)
                {
                    if (lst.Count == 1 && CommonUtil.IsNullOrEmpty(lst[0].DepositFeeNo))
                    {
                        param.dtDepositDetail = null;
                    }
                    else
                    {
                        decimal BalanceOfDeposit = 0;
                        foreach (dtViewDepositDetailInformation data in lst)
                        {
                            if (data.DepositStatus == DepositStatus.C_DEPOSIT_STATUS_PAYMENT)
                            {
                                BalanceOfDeposit += (data.ProcessAmount ?? 0);
                            }
                            else if (data.DepositStatus == DepositStatus.C_DEPOSIT_STATUS_RETURN ||
                                     data.DepositStatus == DepositStatus.C_DEPOSIT_STATUS_SLIDE ||
                                     data.DepositStatus == DepositStatus.C_DEPOSIT_STATUS_REVENUE ||
                                     data.DepositStatus == DepositStatus.C_DEPOSIT_STATUS_CANCEL_PAYMENT ||
                                     data.DepositStatus == DepositStatus.C_DEPOSIT_STATUS_CANCEL_SLIDE)
                            {
                                BalanceOfDeposit += (data.ProcessAmount ?? 0);
                            }

                            data.BalanceOfDeposit = BalanceOfDeposit;

                            if (CommonUtil.IsNullOrEmpty(data.ReceivedFee))
                            {
                                //Receive Fee & Currency is NULL , Default it.
                                data.ReceivedFeeCurrencyType = SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_LOCAL;
                                data.ReceivedFee             = 0;
                            }
                            if (CommonUtil.IsNullOrEmpty(data.ProcessAmount))
                            {
                                data.ProcessAmountCurrencyType = SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_LOCAL;
                                data.ProcessAmount             = 0;
                            }
                        }
                        param.dtDepositDetail = lst;
                    }
                    res.ResultData = lst[0];
                }
                else
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                    return(Json(res));
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
            return(Json(res));
        }
        /// <summary>
        /// Initialize screen of CMS430
        /// </summary>
        /// <returns></returns>
        public ActionResult CMS430()
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                CMS430_ScreenParameter param = GetScreenObject <CMS430_ScreenParameter>();
                CommonUtil             cm    = new CommonUtil();
                string strContractCode       = cm.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                IViewBillingHandler   viewHandler   = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;
                ICommonHandler        comHand       = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_CURRENCT,
                        ValueCode = "%"
                    }
                }).ToList();
                //List<dtViewBillingOccList> lst = viewHandler.GetViewBillingOccList(strContractCode);
                List <dtViewBillingOccList> lst = viewHandler.GetViewBillingOCCListForDepositFree(strContractCode);
                for (int i = 0; i < lst.Count(); i++)
                {
                    lst[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                }

                if (lst.Count > 0)
                {
                    foreach (dtViewBillingOccList data in lst)
                    {
                        if (CommonUtil.IsNullOrEmpty(data.MonthlyBillingAmount))
                        {
                            data.MonthlyBillingAmount = 0.00M;
                        }
                        if (CommonUtil.IsNullOrEmpty(data.BalanceDeposit))
                        {
                            data.BalanceDeposit = 0.00M;
                        }
                        if (CommonUtil.IsNullOrEmpty(data.BillingOCC))
                        {
                            data.BillingOCC = "-";
                        }
                        if (CommonUtil.IsNullOrEmpty(data.PaymentName))
                        {
                            data.PaymentName = "-";
                        }
                        if (CommonUtil.IsNullOrEmpty(data.IssueInvoiceName))
                        {
                            data.IssueInvoiceName = "-";
                        }
                        if (CommonUtil.IsNullOrEmpty(data.OfficeName))
                        {
                            data.OfficeName = "-";
                        }
                    }

                    param.dtOCCList = lst;
                }

                // Prepare for show section
                ViewBag.txtContractCode        = param.dtRentalContract.ContractCodeShort;
                ViewBag.txtNormalDepositFee    = param.dtRentalContract.TextTransferNormalDepositFee_CMS430;
                ViewBag.txtNormalDepositFeeUsd = param.dtRentalContract.TextTransferNormalDepositFeeUsd_CMS430; //Merge at 14032017 By Pachara S.
                //ViewBag.txtNormalDepositFee = param.dtRentalContract.NormalDepositFeeNumeric;
                ViewBag.txtBillingDepositFee    = param.dtRentalContract.TextTransferOrderDepositFee_CMS430;
                ViewBag.txtBillingDepositFeeUsd = param.dtRentalContract.TextTransferOrderDepositFeeUsd_CMS430; //Merge at 14032017 By Pachara S.
                //ViewBag.txtBillingDepositFee = param.dtRentalContract.OrderDepositFeeNumeric;
                ViewBag.txtExemptedDepositFee    = param.dtRentalContract.TextTransferExemptedDepositFee_CMS430;
                ViewBag.txtExemptedDepositFeeUsd = param.dtRentalContract.TextTransferExemptedDepositFeeUsd_CMS430; //Merge at 14032017 By Pachara S.
                //ViewBag.txtExemptedDepositFee = param.dtRentalContract.ExemptedDepositFeeNumeric;
                ViewBag.txtContractTargetNameEN = param.dtRentalContract.CustFullNameEN_Cust;
                ViewBag.txtBranchNameEN         = param.dtRentalContract.BranchNameEN;
                ViewBag.txtSiteNameEN           = param.dtRentalContract.SiteNameEN_Site;
                ViewBag.txtContractTargetNameLC = param.dtRentalContract.CustFullNameLC_Cust;
                ViewBag.txtBranchNameLC         = param.dtRentalContract.BranchNameLC;
                ViewBag.txtSiteNameLC           = param.dtRentalContract.SiteNameLC_Site;

                //To for test
                //ViewBag.BillingOCC = "01";
                ViewBag.BillingOCC   = param.BillingOCC;
                ViewBag.ContractCode = param.ContractCode;
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }
            return(View());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Check suspend, authority and resume of CMS400
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult CMS400_Authority(CMS400_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                // for test
                //param.CallerScreenID = "CMS410";
                //param.BillingTargetCode = "0000009-001";
                //param.isEnableBtnShowInvoiceList = true;

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

                IBillingHandler       handlerBilling     = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
                IViewBillingHandler   handlerViewBilling = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;
                CommonUtil            cm            = new CommonUtil();
                ICommonHandler        comHand       = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_CURRENCT,
                        ValueCode = "%"
                    }
                }).ToList();

                string strBillingTargetCode = cm.ConvertBillingTargetCode(param.BillingTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                if (param.CallerScreenID == ScreenID.C_SCREEN_ID_VIEW_BILLING_TARGET_INFORMATION)
                {
                    //check require field
                    if (CommonUtil.IsNullOrEmpty(param.BillingTargetCode))
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0040);
                        return(Json(res));
                    }

                    //data exist
                    List <dtTbt_BillingTargetForView> lst = handlerBilling.GetTbt_BillingTargetForView(strBillingTargetCode, MiscType.C_CUST_TYPE);
                    if (lst.Count <= 0)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                        return(Json(res));
                    }
                    else
                    {
                        param.dtBillingTargetForView = lst[0];
                    }
                    if (param.isEnableBtnShowInvoiceList == false)
                    {
                        List <dtViewBillingBasicList> lstBasic = handlerViewBilling.GetViewBillingBasicList(null, strBillingTargetCode, null, null, null, null);
                        for (int i = 0; i < lstBasic.Count(); i++)
                        {
                            lstBasic[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                        }
                        //if (lstBasic.Count <= 0)
                        //{
                        //    //res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                        //    //return Json(res);
                        //}
                        //else
                        //{
                        param.doBasicList = lstBasic;
                        //}
                    }
                    else
                    {
                        List <dtViewBillingInvoiceListOfLastInvoiceOcc> lstInvoice = handlerViewBilling.GetViewBillingInvoiceListOfLastInvoiceOcc(null, strBillingTargetCode, null, null, null, null);
                        //if (lstInvoice.Count <= 0)
                        //{
                        //    //res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                        //    //return Json(res);
                        //}
                        //else
                        //{
                        param.dtViewBillingInvoiceListOfLastInvoiceOccList = lstInvoice;
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(InitialScreenEnvironment <CMS400_ScreenParameter>("CMS400", param, res));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Search Data
        /// </summary>
        /// <param name="strBillingClientCode"></param>
        /// <param name="strBillingTargetNo"></param>
        /// <param name="strBillingClientName"></param>
        /// <param name="strBillingClientAddress"></param>
        /// <param name="strBillingClientCode2"></param>
        /// <param name="Flag"></param>
        /// <param name="strInvoiceNo"></param>
        /// <returns></returns>
        public ActionResult CMS400_SearchDataToGrid(string strBillingClientCode, string strBillingTargetNo,
                                                    string strBillingClientName, string strBillingClientAddress, string strBillingClientCode2, int Flag, string strInvoiceNo, string strTaxIDNo)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                // Check validate control


                CMS400_ScreenParameter param           = GetScreenObject <CMS400_ScreenParameter>();
                CommonUtil             cm              = new CommonUtil();
                string strBillingTargetCode            = null;
                IViewBillingHandler handlerViewBilling = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;

                if (!CommonUtil.IsNullOrEmpty(strBillingClientCode2) || !CommonUtil.IsNullOrEmpty(strBillingTargetNo))
                {
                    strBillingTargetCode = cm.ConvertBillingClientCode(strBillingClientCode2, CommonUtil.CONVERT_TYPE.TO_LONG) + "-" + strBillingTargetNo;
                }
                else
                {
                    strBillingTargetCode = null;
                }
                if (CommonUtil.IsNullOrEmpty(strBillingClientCode))
                {
                    strBillingClientCode = null;
                }
                else
                {
                    strBillingClientCode = cm.ConvertBillingClientCode(strBillingClientCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                }
                if (CommonUtil.IsNullOrEmpty(strBillingClientName))
                {
                    strBillingClientName = null;
                }
                if (CommonUtil.IsNullOrEmpty(strBillingClientAddress))
                {
                    strBillingClientAddress = null;
                }
                if (CommonUtil.IsNullOrEmpty(strInvoiceNo))
                {
                    strInvoiceNo = null;
                }
                if (CommonUtil.IsNullOrEmpty(strTaxIDNo))
                {
                    strTaxIDNo = null;
                }
                if (Flag == 0)
                {
                    List <doBillingTargetList> lst = handlerViewBilling.GetViewBillingTargetList(
                        strBillingClientCode,
                        strBillingTargetCode,
                        strBillingClientName,
                        strBillingClientAddress,
                        strInvoiceNo,
                        strTaxIDNo
                        );
                    res.ResultData = CommonUtil.ConvertToXml <doBillingTargetList>(lst, "Common\\CMS400_BillingTarget", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                }
                else if (Flag == 1)
                {
                    List <dtViewBillingBasicList> lst = handlerViewBilling.GetViewBillingBasicList(
                        strBillingClientCode,
                        strBillingTargetCode,
                        strBillingClientName,
                        strBillingClientAddress,
                        strInvoiceNo,
                        strTaxIDNo
                        );
                    res.ResultData = CommonUtil.ConvertToXml <dtViewBillingBasicList>(lst, "Common\\CMS400_BillingBasic", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                }
                else if (Flag == 2)
                {
                    if (CommonUtil.IsNullOrEmpty(strInvoiceNo))
                    {
                        strInvoiceNo = null;
                    }
                    List <dtViewBillingInvoiceListOfLastInvoiceOcc> lst = handlerViewBilling.GetViewBillingInvoiceListOfLastInvoiceOcc(
                        strBillingClientCode,
                        strBillingTargetCode,
                        strBillingClientName,
                        strBillingClientAddress,
                        strInvoiceNo,
                        strTaxIDNo
                        );
                    //lst[0].NoOfBillingDetail = 2500;
                    res.ResultData = CommonUtil.ConvertToXml <dtViewBillingInvoiceListOfLastInvoiceOcc>(lst, "Common\\CMS400_UncancelInvoice", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }
        /// <summary>
        /// Getting billing basic information
        /// </summary>
        /// <param name="BillingOCC"></param>
        /// <returns></returns>
        public ActionResult CMS420_LoadBillingBasicInformation(string BillingOCC)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                CMS420_ScreenParameter param = GetScreenObject <CMS420_ScreenParameter>();
                CommonUtil             cm    = new CommonUtil();

                string strContractCode = cm.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                param.BillingOCC = BillingOCC;

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

                List <dtViewBillingBasic> viewBillingBasicData = viewBillingHandler.GetViewBillingBasic(strContractCode, BillingOCC, null, null, null, null);
                List <doTbt_MonthlyBillingHistoryList> monthlyBillingHistoryListData = billingHandler.GetBillingHistoryList(strContractCode, BillingOCC, CurrencyUtil.C_CURRENCY_LOCAL, CurrencyUtil.C_CURRENCY_US);

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

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

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

                List <object> result        = new List <object>();
                bool          carefulFlag   = false;
                string        paymentMethod = "0";

                if (viewBillingBasicData.Count > 0)
                {
                    //Language mapping
                    CommonUtil.MappingObjectLanguage <dtViewBillingBasic>(viewBillingBasicData);

                    //Misc mapping
                    MiscTypeMappingList miscMapping = new MiscTypeMappingList();
                    miscMapping.AddMiscType(viewBillingBasicData.ToArray <dtViewBillingBasic>());
                    handlerCommon.MiscTypeMappingList(miscMapping);

                    carefulFlag   = viewBillingBasicData[0].CarefulFlag.HasValue ? viewBillingBasicData[0].CarefulFlag.Value : false;
                    paymentMethod = viewBillingBasicData[0].PaymentMethod;

                    dtViewBillingBasic_ForView billingBasic = new dtViewBillingBasic_ForView()
                    {
                        BillingCode = string.Format("{0}-{1}", cm.ConvertContractCode(viewBillingBasicData[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT),
                                                    viewBillingBasicData[0].BillingOCC),
                        BillingOffice             = CommonUtil.TextCodeName(viewBillingBasicData[0].BillingOfficeCode, viewBillingBasicData[0].OfficeName),
                        DebtTracingOffice         = CommonUtil.TextCodeName(viewBillingBasicData[0].DebtTracingOfficeCode, viewBillingBasicData[0].DebtTracingOfficeName),
                        BillingTargetCode         = cm.ConvertBillingTargetCode(viewBillingBasicData[0].BillingTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT),
                        PreviousBillingTargetCode = cm.ConvertBillingTargetCode(viewBillingBasicData[0].PreviousBillingTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT),
                        CustomerType              = viewBillingBasicData[0].CustTypeCodeName,
                        BillingClientNameEN       = viewBillingBasicData[0].FullNameEN,
                        BillingClientBranchNameEN = viewBillingBasicData[0].BranchNameEN,
                        BillingClientAddressEN    = viewBillingBasicData[0].AddressEN,
                        BillingClientNameLC       = viewBillingBasicData[0].FullNameLC,
                        BillingClientBranchNameLC = viewBillingBasicData[0].BranchNameLC,
                        BillingClientAddressLC    = viewBillingBasicData[0].AddressLC,
                        MonthlyBillingAmount      = viewBillingBasicData[0].TextTransferMonthlyBillingAmount,
                        PaymentMethod             = viewBillingBasicData[0].PaymentMethodName,
                        BillingCycle              = CommonUtil.TextNumeric(viewBillingBasicData[0].BillingCycle, 0),
                        CreditTerm                        = CommonUtil.TextNumeric(viewBillingBasicData[0].CreditTerm),
                        CalculationDailyFee               = viewBillingBasicData[0].CalDailyFeeStatusName,
                        LastBillingDate                   = CommonUtil.TextDate(viewBillingBasicData[0].LastBillingDate),
                        ManagementCodeForSortDetails      = viewBillingBasicData[0].SortingType,
                        AdjustEndingDateOfBillingPeriod   = CommonUtil.TextDate(viewBillingBasicData[0].AdjustEndDate),
                        BillingFlag                       = viewBillingBasicData[0].StopBillingFlagCodeName,
                        VATUnchargedBillingTarget         = viewBillingBasicData[0].VATUnchargedFlag.HasValue ? viewBillingBasicData[0].VATUnchargedFlag.Value : false,
                        BalanceOfDepositFee               = viewBillingBasicData[0].TextTransferBalanceDeposit,
                        MonthlyFeeBeforeStop              = viewBillingBasicData[0].TextTransferMonthlyFeeBeforeStop,
                        ResultBasedMaintenanceBillingFlag = viewBillingBasicData[0].ResultBasedMaintenanceFlag.HasValue ? viewBillingBasicData[0].ResultBasedMaintenanceFlag.Value : false,
                        LastPaymentConditionChangingDate  = CommonUtil.TextDate(viewBillingBasicData[0].ChangeDate),
                        RegisteringDateOfLastChanging     = CommonUtil.TextDate(viewBillingBasicData[0].ChangeDate),
                        ApproveNo         = viewBillingBasicData[0].ApproveNo,
                        DocumentReceiving = viewBillingBasicData[0].DocAuditResultName,

                        AdjustmentType      = viewBillingBasicData[0].AdjustType,
                        AdjustBillingAmount = viewBillingBasicData[0].TextTransferAdjustBillingPeriodAmount,

                        AdjustBillingPeriodStartDate = CommonUtil.TextDate(viewBillingBasicData[0].AdjustBillingPeriodStartDate),
                        AdjustBillingPeriodEndDate   = CommonUtil.TextDate(viewBillingBasicData[0].AdjustBillingPeriodEndDate)

                        , IDNo = viewBillingBasicData[0].IDNo //Add by Jutarat A. on 12122013
                    };

                    result.Add(billingBasic);
                }
                else
                {
                    result.Add(new dtViewBillingBasic_ForView());
                }

                if (monthlyBillingHistoryListData.Count > 0)
                {
                    doTbt_MonthlyBillingHistoryList_ForView billingHistory = new doTbt_MonthlyBillingHistoryList_ForView()
                    {
                        LastMonthlyBillingAmount = monthlyBillingHistoryListData[0].TextTransferMonthlyBillingAmount,
                        LastDate = CommonUtil.TextDate(monthlyBillingHistoryListData[0].BillingStartDate),
                        BillingAmountBeforeChanging1 = monthlyBillingHistoryListData.Count < 2 ? null : monthlyBillingHistoryListData[1].TextTransferMonthlyBillingAmount,
                        DateBeforeChanging1          = monthlyBillingHistoryListData.Count < 2 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[1].BillingStartDate),
                        BillingAmountBeforeChanging2 = monthlyBillingHistoryListData.Count < 3 ? null : monthlyBillingHistoryListData[2].TextTransferMonthlyBillingAmount,
                        DateBeforeChanging2          = monthlyBillingHistoryListData.Count < 3 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[2].BillingStartDate),
                        BillingAmountBeforeChanging3 = monthlyBillingHistoryListData.Count < 4 ? null : monthlyBillingHistoryListData[3].TextTransferMonthlyBillingAmount,
                        DateBeforeChanging3          = monthlyBillingHistoryListData.Count < 4 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[3].BillingStartDate),
                        BillingAmountBeforeChanging4 = monthlyBillingHistoryListData.Count < 5 ? null : monthlyBillingHistoryListData[4].TextTransferMonthlyBillingAmount,
                        DateBeforeChanging4          = monthlyBillingHistoryListData.Count < 5 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[4].BillingStartDate),
                        BillingAmountBeforeChanging5 = monthlyBillingHistoryListData.Count < 6 ? null : monthlyBillingHistoryListData[5].TextTransferMonthlyBillingAmount,
                        DateBeforeChanging5          = monthlyBillingHistoryListData.Count < 6 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[5].BillingStartDate)
                    };

                    result.Add(billingHistory);
                }
                else
                {
                    result.Add(new doTbt_MonthlyBillingHistoryList_ForView());
                }

                result.Add(carefulFlag);
                result.Add(paymentMethod);

                res.ResultData = result.ToArray();

                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
        /// <summary>
        /// Check suspend, authority and resume of CMS420
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult CMS420_Authority(CMS420_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                // If param.ContractCode is null then set to  CommonUtil.dsTransData.dtCommonSearch.ContractCode;
                if (String.IsNullOrEmpty(param.ContractCode))
                {
                    //param.strContractCode = CommonUtil.dsTransData.dtCommonSearch.ContractCode;
                    if (param.CommonSearch != null)
                    {
                        if (CommonUtil.IsNullOrEmpty(param.CommonSearch.ContractCode) == false)
                        {
                            param.ContractCode = param.CommonSearch.ContractCode;
                        }
                    }
                }


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

                if (param.CallerScreenID == ScreenID.C_SCREEN_ID_SEARCH_BILLING_INFORMATION)
                {
                    // is parameter OK ?
                    if (CommonUtil.IsNullOrEmpty(param.ContractCode))
                    {
                        //res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0040);
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0155);
                        return(Json(res));
                    }

                    if (CommonUtil.IsNullOrEmpty(param.ContractCode) && CommonUtil.IsNullOrEmpty(param.BillingOCC))
                    {
                        //res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0040);
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0155);
                        return(Json(res));
                    }

                    // Check data exist
                    CommonUtil            cm = new CommonUtil();
                    string                strContractCode    = cm.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                    IViewBillingHandler   viewBillingHandler = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;
                    ICommonHandler        comHand            = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                    List <doMiscTypeCode> tmpCurrencies      = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                    {
                        new doMiscTypeCode()
                        {
                            FieldName = MiscType.C_CURRENCT,
                            ValueCode = "%"
                        }
                    }).ToList();
                    List <dtViewBillingBasic> viewBillingBasicData = viewBillingHandler.GetViewBillingBasic(strContractCode, param.BillingOCC, null, null, null, null);
                    for (int i = 0; i < viewBillingBasicData.Count(); i++)
                    {
                        viewBillingBasicData[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                    }
                    if (viewBillingBasicData.Count == 0)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001); // data not found
                        return(Json(res));
                    }
                }
                else
                {
                    // is parameter OK ?
                    if (CommonUtil.IsNullOrEmpty(param.ContractCode))
                    {
                        //res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0040);
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0147);
                        return(Json(res));
                    }

                    // Check data exist
                    CommonUtil                  cm = new CommonUtil();
                    string                      strContractCode        = cm.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                    IViewBillingHandler         viewBillingHandler     = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;
                    List <dtViewBillingOccList> viewBillingOccListData = viewBillingHandler.GetViewBillingOccList(strContractCode);
                    if (viewBillingOccListData.Count == 0)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001); // data not found
                        return(Json(res));
                    }
                }

                param.CommonSearch = new ScreenParameter.CommonSearchDo()
                {
                    ContractCode = param.ContractCode
                };

                return(InitialScreenEnvironment <CMS420_ScreenParameter>("CMS420", param, res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
        public ActionResult CMS420()
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                CMS420_ScreenParameter param = GetScreenObject <CMS420_ScreenParameter>();
                CommonUtil             cm    = new CommonUtil();

                ViewBag._ContractCode = param.ContractCode;
                ViewBag._BillingOCC   = param.BillingOCC;

                string strContractCode = cm.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                ViewBag._CallerScreen = param.CallerScreenID;

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

                List <dtViewBillingOccList>            viewBillingOccListData        = viewBillingHandler.GetViewBillingOccList(strContractCode);
                List <dtViewBillingBasic>              viewBillingBasicData          = viewBillingHandler.GetViewBillingBasic(strContractCode, param.BillingOCC, null, null, null, null);
                List <doTbt_MonthlyBillingHistoryList> monthlyBillingHistoryListData = billingHandler.GetBillingHistoryList(strContractCode, param.BillingOCC, CurrencyUtil.C_CURRENCY_LOCAL, CurrencyUtil.C_CURRENCY_US);

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

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

                ViewBag.IsSpecialCareful                     = "0";
                ViewBag.txtVATUnchargedBillingTarget         = false;
                ViewBag.txtResultBasedMaintenanceBillingFlag = false;

                if (viewBillingOccListData.Count > 0)
                {
                    //Language mapping
                    CommonUtil.MappingObjectLanguage <dtViewBillingOccList>(viewBillingOccListData);

                    ViewBag.txtContractCode = cm.ConvertContractCode(viewBillingOccListData[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                }

                if (param.BillingOCC != null)
                {
                    if (viewBillingBasicData.Count > 0)
                    {
                        //Language mapping
                        CommonUtil.MappingObjectLanguage <dtViewBillingBasic>(viewBillingBasicData);

                        //Misc mapping
                        MiscTypeMappingList miscMapping = new MiscTypeMappingList();
                        miscMapping.AddMiscType(viewBillingBasicData.ToArray <dtViewBillingBasic>());
                        handlerCommon.MiscTypeMappingList(miscMapping);

                        if (viewBillingBasicData[0].CarefulFlag.HasValue)
                        {
                            ViewBag.IsSpecialCareful = viewBillingBasicData[0].CarefulFlag.Value == true ? "1" : "0";
                        }

                        ViewBag.IsPaymentMethod = viewBillingBasicData[0].PaymentMethod;

                        ViewBag.txtBillingCode               = string.Format("{0}-{1}", cm.ConvertContractCode(viewBillingBasicData[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT), viewBillingBasicData[0].BillingOCC);
                        ViewBag.txtBillingOffice             = CommonUtil.TextCodeName(viewBillingBasicData[0].BillingOfficeCode, viewBillingBasicData[0].OfficeName);
                        ViewBag.txtDebtTracingOffice         = CommonUtil.TextCodeName(viewBillingBasicData[0].DebtTracingOfficeCode, viewBillingBasicData[0].DebtTracingOfficeName);
                        ViewBag.txtBillingTargetCode         = cm.ConvertBillingTargetCode(viewBillingBasicData[0].BillingTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        ViewBag.txtPreviousBillingTargetCode = cm.ConvertBillingTargetCode(viewBillingBasicData[0].PreviousBillingTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        ViewBag.txtCustomerType              = viewBillingBasicData[0].CustTypeCodeName;
                        ViewBag.txtBillingClientNameEN       = viewBillingBasicData[0].FullNameEN;
                        ViewBag.txtBillingClientBranchNameEN = viewBillingBasicData[0].BranchNameEN;
                        ViewBag.txtBillingClientAddressEN    = viewBillingBasicData[0].AddressEN;
                        ViewBag.txtBillingClientNameLC       = viewBillingBasicData[0].FullNameLC;
                        ViewBag.txtBillingClientBranchNameLC = viewBillingBasicData[0].BranchNameLC;
                        ViewBag.txtBillingClientAddressLC    = viewBillingBasicData[0].AddressLC;
                        ViewBag.txtMonthlyBillingAmount      = viewBillingBasicData[0].TextTransferMonthlyBillingAmount;
                        //ViewBag.txtMonthlyBillingAmount = CommonUtil.TextNumeric(viewBillingBasicData[0].MonthlyBillingAmount);
                        ViewBag.txtPaymentMethod                   = viewBillingBasicData[0].PaymentMethodName;
                        ViewBag.txtBillingCycle                    = CommonUtil.TextNumeric(viewBillingBasicData[0].BillingCycle, 0);
                        ViewBag.txtCreditTerm                      = CommonUtil.TextNumeric(viewBillingBasicData[0].CreditTerm);
                        ViewBag.txtCalculationDailyFee             = viewBillingBasicData[0].CalDailyFeeStatusName;
                        ViewBag.txtLastBillingDate                 = CommonUtil.TextDate(viewBillingBasicData[0].LastBillingDate);
                        ViewBag.txtManagementCodeForSortDetails    = viewBillingBasicData[0].SortingType;
                        ViewBag.txtAdjustEndingDateOfBillingPeriod = CommonUtil.TextDate(viewBillingBasicData[0].AdjustEndDate);
                        ViewBag.txtBillingFlag                     = viewBillingBasicData[0].StopBillingFlagCodeName;
                        ViewBag.txtVATUnchargedBillingTarget       = viewBillingBasicData[0].VATUnchargedFlag.HasValue ? viewBillingBasicData[0].VATUnchargedFlag.Value : false;
                        ViewBag.txtBalanceOfDepositFee             = viewBillingBasicData[0].TextTransferBalanceDeposit;
                        //ViewBag.txtBalanceOfDepositFee = CommonUtil.TextNumeric(viewBillingBasicData[0].BalanceDeposit);
                        ViewBag.txtMonthlyFeeBeforeStop = viewBillingBasicData[0].TextTransferMonthlyFeeBeforeStop;
                        //ViewBag.txtMonthlyFeeBeforeStop = CommonUtil.TextNumeric(viewBillingBasicData[0].MonthlyFeeBeforeStop);
                        ViewBag.txtResultBasedMaintenanceBillingFlag = viewBillingBasicData[0].ResultBasedMaintenanceFlag.HasValue ? viewBillingBasicData[0].ResultBasedMaintenanceFlag.Value : false;
                        ViewBag.txtLastPaymentConditionChangingDate  = CommonUtil.TextDate(viewBillingBasicData[0].ChangeDate);
                        ViewBag.txtRegisteringDateOfLastChanging     = CommonUtil.TextDate(viewBillingBasicData[0].ChangeDate);
                        ViewBag.txtApproveNo         = viewBillingBasicData[0].ApproveNo;
                        ViewBag.txtDocumentReceiving = viewBillingBasicData[0].DocAuditResultName;

                        ViewBag.txtAdjustmentType      = viewBillingBasicData[0].AdjustType;
                        ViewBag.txtAdjustBillingAmount = viewBillingBasicData[0].TextTransferAdjustBillingPeriodAmount;
                        //ViewBag.txtAdjustBillingAmount = CommonUtil.TextNumeric(viewBillingBasicData[0].AdjustBillingPeriodAmount);

                        ViewBag.txtAdjustBillingPeriodStartDate = CommonUtil.TextDate(viewBillingBasicData[0].AdjustBillingPeriodStartDate);
                        ViewBag.txtAdjustBillingPeriodEndDate   = CommonUtil.TextDate(viewBillingBasicData[0].AdjustBillingPeriodEndDate);

                        ViewBag.txtIDNo = viewBillingBasicData[0].IDNo; //Add by Jutarat A. on 12122013
                    }

                    if (monthlyBillingHistoryListData != null)
                    {
                        if (monthlyBillingHistoryListData.Count > 0)
                        {
                            ViewBag.txtLastMonthlyBillingAmount = monthlyBillingHistoryListData[0].TextTransferMonthlyBillingAmount;
                            ViewBag.txtLastDate = CommonUtil.TextDate(monthlyBillingHistoryListData[0].BillingStartDate);
                            ViewBag.txtBillingAmountBeforeChanging1 = monthlyBillingHistoryListData.Count < 2 ? null : monthlyBillingHistoryListData[1].TextTransferMonthlyBillingAmount;
                            ViewBag.txtDateBeforeChanging1          = monthlyBillingHistoryListData.Count < 2 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[1].BillingStartDate);
                            ViewBag.txtBillingAmountBeforeChanging2 = monthlyBillingHistoryListData.Count < 3 ? null : monthlyBillingHistoryListData[2].TextTransferMonthlyBillingAmount;
                            ViewBag.txtDateBeforeChanging2          = monthlyBillingHistoryListData.Count < 3 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[2].BillingStartDate);
                            ViewBag.txtBillingAmountBeforeChanging3 = monthlyBillingHistoryListData.Count < 4 ? null : monthlyBillingHistoryListData[3].TextTransferMonthlyBillingAmount;
                            ViewBag.txtDateBeforeChanging3          = monthlyBillingHistoryListData.Count < 4 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[3].BillingStartDate);
                            ViewBag.txtBillingAmountBeforeChanging4 = monthlyBillingHistoryListData.Count < 5 ? null : monthlyBillingHistoryListData[4].TextTransferMonthlyBillingAmount;
                            ViewBag.txtDateBeforeChanging4          = monthlyBillingHistoryListData.Count < 5 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[4].BillingStartDate);
                            ViewBag.txtBillingAmountBeforeChanging5 = monthlyBillingHistoryListData.Count < 6 ? null : monthlyBillingHistoryListData[5].TextTransferMonthlyBillingAmount;
                            ViewBag.txtDateBeforeChanging5          = monthlyBillingHistoryListData.Count < 6 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[5].BillingStartDate);
                        }
                    }
                }

                //Finding service type code
                if (string.IsNullOrEmpty(strContractCode) == false)
                {
                    //Rental
                    IRentralContractHandler        handlerR         = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
                    List <tbt_RentalContractBasic> dtRentalContract = handlerR.GetTbt_RentalContractBasic(strContractCode, null);
                    if (dtRentalContract.Count > 0)
                    {
                        param.ServiceTypeCode   = ServiceType.C_SERVICE_TYPE_RENTAL;
                        ViewBag.ServiceTypeCode = ServiceType.C_SERVICE_TYPE_RENTAL;
                        ViewBag.ProductTypeCode = dtRentalContract[0].ProductTypeCode;
                    }
                    else
                    {
                        // Sale
                        ISaleContractHandler handlerS       = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
                        List <tbt_SaleBasic> dtSaleContract = handlerS.GetTbt_SaleBasic(strContractCode, null, true);
                        if (dtSaleContract.Count > 0)
                        {
                            param.ServiceTypeCode   = ServiceType.C_SERVICE_TYPE_SALE;
                            ViewBag.ServiceTypeCode = ServiceType.C_SERVICE_TYPE_SALE;
                            ViewBag.ProductTypeCode = dtSaleContract[0].ProductTypeCode;
                        }
                    }
                }

                return(View());
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Check suspend, authority and resume of CMS450
        /// </summary>
        /// <param name="param">Screen parameter</param>
        /// <returns></returns>
        public ActionResult CMS450_Authority(CMS450_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                // Check permission
                if (CheckUserPermission(ScreenID.C_SCREEN_ID_VIEW_BILLING_DETAIL, FunctionID.C_FUNC_ID_OPERATE) == false)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                    return(Json(res));
                }

                // is parameter OK ?
                if (CommonUtil.IsNullOrEmpty(param.BillingTargetCode) &&
                    CommonUtil.IsNullOrEmpty(param.ContractCode) &&
                    CommonUtil.IsNullOrEmpty(param.BillingOCC) &&
                    CommonUtil.IsNullOrEmpty(param.InvoiceNo))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0156);
                    return(Json(res));
                }

                // data is exist ?

                CommonUtil          cm                 = new CommonUtil();
                IBillingHandler     handlerBilling     = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
                IViewBillingHandler handlerViewBilling = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;

                List <dtTbt_BillingTargetForView> listBillingTarget = new List <dtTbt_BillingTargetForView>();
                if (!CommonUtil.IsNullOrEmpty(param.BillingTargetCode))
                {
                    listBillingTarget = handlerBilling.GetTbt_BillingTargetForView(cm.ConvertBillingTargetCode(param.BillingTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG), MiscType.C_CUST_TYPE);

                    if (listBillingTarget.Count <= 0)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                        return(Json(res));
                    }
                }
                else if (!CommonUtil.IsNullOrEmpty(param.BillingOCC) && !CommonUtil.IsNullOrEmpty(param.ContractCode))
                {
                    //GetBillingDetailOfBillingCode
                    string strContractCode = cm.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                    List <dtTbt_BillingBasicForView> listBillingBasicForView = handlerBilling.GetTbt_BillingBasicForView(strContractCode, param.BillingOCC);
                    if (listBillingBasicForView.Count <= 0)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                        return(Json(res));
                    }
                }
                else if (!CommonUtil.IsNullOrEmpty(param.InvoiceNo))
                {
                    List <dtViewBillingDetailListOfLastInvoiceOCC> listBillingDetailListOfLastInvoiceOCC = handlerViewBilling.GetViewBillingDetailListOfLastInvoiceOCC(param.InvoiceNo, null, null, null, null);
                    if (listBillingDetailListOfLastInvoiceOCC.Count <= 0)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                        return(Json(res));
                    }
                }
                else
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0156);
                    return(Json(res));
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(InitialScreenEnvironment <CMS450_ScreenParameter>("CMS450", param, res));
        }
Ejemplo n.º 14
0
        public ActionResult CMS450()
        {
            ObjectResultData       res   = new ObjectResultData();
            CMS450_ScreenParameter param = GetScreenObject <CMS450_ScreenParameter>();
            CommonUtil             cm    = new CommonUtil();

            // Prepare for show section
            ViewBag._ContractCode      = param.ContractCode;
            ViewBag._BillingOCC        = param.BillingOCC;
            ViewBag._BillingTargetCode = param.BillingTargetCode;
            ViewBag._InvoiceNo         = param.InvoiceNo;

            try
            {
                IBillingHandler     handlerBilling     = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
                IViewBillingHandler handlerViewBilling = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;

                if (!CommonUtil.IsNullOrEmpty(param.BillingTargetCode))
                {
                    List <dtTbt_BillingTargetForView> listBillingTarget = handlerBilling.GetTbt_BillingTargetForView(cm.ConvertBillingTargetCode(param.BillingTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG), MiscType.C_CUST_TYPE);
                    if (listBillingTarget.Count > 0)
                    {
                        ViewBag.txtBillingTargetCode           = listBillingTarget[0].BillingTargetCode_Short;
                        ViewBag.txtBillingClientNameEnglish    = listBillingTarget[0].FullNameEN;
                        ViewBag.txtBillingClientAddressEnglish = listBillingTarget[0].AddressEN;
                        ViewBag.txtBillingClientNameLocal      = listBillingTarget[0].FullNameLC;
                        ViewBag.txtBillingClientAddressLocal   = listBillingTarget[0].AddressLC;
                    }
                }
                else if (!CommonUtil.IsNullOrEmpty(param.BillingOCC) && !CommonUtil.IsNullOrEmpty(param.ContractCode))
                {
                    //GetBillingDetailOfBillingCode
                    string strContractCode = cm.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                    List <dtTbt_BillingBasicForView> listBillingBasicForView = handlerBilling.GetTbt_BillingBasicForView(strContractCode, param.BillingOCC);
                    if (listBillingBasicForView.Count > 0)
                    {
                        ViewBag.txtBillingCode                 = cm.ConvertBillingCode(listBillingBasicForView[0].BillingCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        ViewBag.txtBillingOffice               = listBillingBasicForView[0].OfficeName;
                        ViewBag.txtBillingTargetCode           = cm.ConvertBillingTargetCode(listBillingBasicForView[0].BillingTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        ViewBag.txtBillingClientNameEnglish    = listBillingBasicForView[0].FullNameEN;
                        ViewBag.txtBillingClientAddressEnglish = listBillingBasicForView[0].AddressEN;
                        ViewBag.txtBillingClientNameLocal      = listBillingBasicForView[0].FullNameLC;
                        ViewBag.txtBillingClientAddressLocal   = listBillingBasicForView[0].AddressLC;
                    }
                }
                else if (!CommonUtil.IsNullOrEmpty(param.InvoiceNo))
                {
                    List <dtViewBillingDetailListOfLastInvoiceOCC> listBillingDetailListOfLastInvoiceOCC = handlerViewBilling.GetViewBillingDetailListOfLastInvoiceOCC(param.InvoiceNo, null, null, null, null);
                    if (listBillingDetailListOfLastInvoiceOCC.Count > 0)
                    {
                        ViewBag.txtInvoiceNo                   = listBillingDetailListOfLastInvoiceOCC[0].InvoiceNo;
                        ViewBag.txtBillingTargetCode           = cm.ConvertBillingTargetCode(listBillingDetailListOfLastInvoiceOCC[0].BillingTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        ViewBag.txtBillingClientNameEnglish    = listBillingDetailListOfLastInvoiceOCC[0].FullNameEN;
                        ViewBag.txtBillingClientAddressEnglish = listBillingDetailListOfLastInvoiceOCC[0].AddressEN;
                        ViewBag.txtBillingClientNameLocal      = listBillingDetailListOfLastInvoiceOCC[0].FullNameLC;
                        ViewBag.txtBillingClientAddressLocal   = listBillingDetailListOfLastInvoiceOCC[0].AddressLC;
                    }
                }
                else
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0040);
                    return(Json(res));
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }
            return(View());
        }
Ejemplo n.º 15
0
        /// <summary>
        /// If user input ContractCode or UserCode retrieve contract data from tbt_RentalContractBasic or tbt_SaleBasic.<br />
        /// Else if user input ProjectCode retrieve project data from tbt_Project.<br />
        /// Else if user input InvoiceNo get billing details of last invoice OCC.
        /// </summary>
        /// <param name="ContractCode"></param>
        /// <param name="UserCode"></param>
        /// <param name="InvoiceNo"></param>
        /// <param name="ProjectCode"></param>
        /// <returns></returns>
        public ActionResult CMS020_Retrive(string ContractCode, string UserCode, string InvoiceNo, string ProjectCode)
        {
            CommonUtil       cm   = new CommonUtil();
            dtSearchBarData  data = new dtSearchBarData();
            ObjectResultData res  = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING_DIALOG;

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

            if (CommonUtil.IsNullOrEmpty(ContractCode) == false)
            {
                list.Add(ContractCode);
            }
            if (CommonUtil.IsNullOrEmpty(UserCode) == false)
            {
                list.Add(UserCode);
            }
            if (CommonUtil.IsNullOrEmpty(InvoiceNo) == false)
            {
                list.Add(InvoiceNo);
            }
            if (CommonUtil.IsNullOrEmpty(ProjectCode) == false)
            {
                list.Add(ProjectCode);
            }

            if (list.Count > 1)
            {
                // Input more than one criteria --> Retrun message
                res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0117);
                return(Json(res));
            }
            else if (list.Count == 0)
            {
                res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0006);
                return(Json(res));
            }

            try
            {
                // Case goto CMS190
                if (CommonUtil.IsNullOrEmpty(ContractCode) == false || CommonUtil.IsNullOrEmpty(UserCode) == false)
                {
                    dsContractData contractData = new dsContractData();
                    contractData = CMS020_RetrieveContract(ContractCode, UserCode);

                    if (contractData.dtRCB == null && contractData.dtSB == null)
                    {
                        // Return message MSG0102 // This contract code does not exist.
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0133);
                        return(Json(res));
                    }

                    bool isRCBNull = true;
                    if (contractData.dtRCB != null)
                    {
                        if (CommonUtil.IsNullOrEmpty(UserCode) == false && contractData.dtRCB.Count > 1)
                        {
                            res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0157);
                            return(Json(res));
                        }
                        else if (contractData.dtRCB.Count > 0)
                        {
                            data.ContractCode = cm.ConvertContractCode(contractData.dtRCB[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                            data.ServiceType  = contractData.dtRCB[0].ServiceTypeCode;
                            data.Mode         = "CMS190";

                            isRCBNull = false;
                        }
                    }
                    if (isRCBNull == true)
                    {
                        if (contractData.dtSB != null)
                        {
                            if (contractData.dtSB.Count > 0)
                            {
                                data.ContractCode = cm.ConvertContractCode(contractData.dtSB[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                                data.ServiceType  = contractData.dtSB[0].ServiceTypeCode;
                                data.Mode         = "CMS190";
                            }
                        }
                    }

                    //if (data.ContractCode != null)
                    //    CommonUtil.dsTransData.dtCommonSearch.ContractCode = data.ContractCode;
                }
                else if (CommonUtil.IsNullOrEmpty(ProjectCode) == false)
                {
                    IProjectHandler    pHandler = ServiceContainer.GetService <IProjectHandler>() as IProjectHandler;
                    List <tbt_Project> lst      = pHandler.GetTbt_Project(ProjectCode);
                    if (lst.Count == 0)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0091, new string[] { ProjectCode });
                        return(Json(res));
                    }

                    data.ProjectCode = ProjectCode;
                    data.Mode        = "CTS260";

                    //CommonUtil.dsTransData.dtCommonSearch.ProjectCode = ProjectCode;
                }
                else if (CommonUtil.IsNullOrEmpty(InvoiceNo) == false)
                {
                    IViewBillingHandler bHandler = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;
                    List <dtViewBillingDetailListOfLastInvoiceOCC> lst = bHandler.GetViewBillingDetailListOfLastInvoiceOCC(InvoiceNo, null, null, null, null);
                    if (lst.Count == 0)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0150, new string[] { InvoiceNo });
                        return(Json(res));
                    }

                    data.InvoiceNo = InvoiceNo;
                    data.Mode      = "CMS450";

                    //CommonUtil.dsTransData.dtCommonSearch.InvoiceNo = InvoiceNo;
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }


            return(Json(data));
        }