Exemplo n.º 1
0
        /// <summary>
        /// To check maintenance target contract list
        /// </summary>
        /// <param name="contracts"></param>
        /// <param name="quotationTargetCode"></param>
        /// <returns></returns>
        public List <doContractHeader> CheckMaintenanceTargetContractList(List <string> contracts, string quotationTargetCode)
        {
            bool isEmpty = true;

            if (contracts != null)
            {
                if (contracts.Count > 0)
                {
                    isEmpty = false;
                }
            }
            if (isEmpty)
            {
                return(new List <doContractHeader>());
            }

            try
            {
                //1.	Initial data
                //1.1.	Create data set
                dsMaintenanceTargetList dsTargetList = new dsMaintenanceTargetList();
                dsTargetList.doContractHeaderList = new List <doContractHeader>();


                /* --- Merge --- */
                //2.	Check site of maintenance target contract
                //bool bSameSite = this.IsSameSite(contracts);
                //if(bSameSite == false)
                //    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3093);
                /* ------------- */

                //3. Loop to check maintenance target contract of dtContractCode
                int iAlarmCnt = 0;
                int iSaleCnt  = 0;

                /* --- Merge --- */
                string bSiteCode = null;
                /* ------------- */

                foreach (string contractCode in contracts)
                {
                    //3.1.	Call ContractHandler.CheckMaintenanceTargetContract
                    doContractHeader doHeader = this.CheckMaintenanceTargetContract(contractCode, quotationTargetCode);

                    //3.2 Add doContractHeader to dsMaintenanceTargetList
                    dsTargetList.doContractHeaderList.Add(doHeader);

                    /* --- Merge --- */
                    if (bSiteCode == null)
                    {
                        bSiteCode = doHeader.SiteCode;
                    }
                    if (doHeader.SiteCode != bSiteCode)
                    {
                        throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3093);
                    }
                    /* ------------- */

                    //if not error
                    if (doHeader.ProductTypeCode == ProductType.C_PROD_TYPE_AL ||
                        doHeader.ProductTypeCode == ProductType.C_PROD_TYPE_ONLINE ||
                        doHeader.ProductTypeCode == ProductType.C_PROD_TYPE_RENTAL_SALE)
                    {
                        iAlarmCnt++;
                    }

                    if (doHeader.ProductTypeCode == ProductType.C_PROD_TYPE_SALE)
                    {
                        iSaleCnt++;
                    }
                }

                if (iAlarmCnt > 1)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3224);
                }

                if (iAlarmCnt == 1 && iSaleCnt > 0)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0132);
                }

                return(dsTargetList.doContractHeaderList);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// To check maintenance target contract
        /// </summary>
        /// <param name="strContractCode"></param>
        /// <param name="strQuotationTargetCode"></param>
        /// <returns></returns>
        public doContractHeader CheckMaintenanceTargetContract(string strContractCode, string strQuotationTargetCode)
        {
            doContractHeader headerDo = new doContractHeader();

            try
            {
                //1. Get rental contract & 2. Get sale contract
                IContractHandler hand = ServiceContainer.GetService <IContractHandler>() as IContractHandler;
                List <dtGetMaintenanceTargetContract> contractList = hand.GetMaintenanceTargetContract(strContractCode, FlagType.C_FLAG_ON);

                //6. Check contract data
                if (contractList != null && contractList.Count > 0)
                {
                    CommonUtil cmm                = new CommonUtil();
                    string     contractCode       = cmm.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    string     strProductTypeCode = contractList[0].ProductTypeCode;
                    string     strContractStatus  = (contractList[0].ContractStatus != null) ? contractList[0].ContractStatus.Trim() : contractList[0].ContractStatus;

                    if (strProductTypeCode != ProductType.C_PROD_TYPE_SALE &&
                        strProductTypeCode != ProductType.C_PROD_TYPE_AL &&
                        strProductTypeCode != ProductType.C_PROD_TYPE_ONLINE &&
                        strProductTypeCode != ProductType.C_PROD_TYPE_RENTAL_SALE)
                    {
                        throw ApplicationErrorException.ThrowErrorException(
                                  MessageUtil.MODULE_CONTRACT,
                                  MessageUtil.MessageList.MSG3118,
                                  new string[] { contractCode });
                    }

                    if (CommonUtil.dsTransData.dtTransHeader.ScreenID != ScreenID.C_SCREEN_ID_QTN_DETAIL)
                    {
                        if (strContractStatus == ContractStatus.C_CONTRACT_STATUS_BEF_START)
                        {
                            throw ApplicationErrorException.ThrowErrorException(
                                      MessageUtil.MODULE_CONTRACT,
                                      MessageUtil.MessageList.MSG3119,
                                      new string[] { contractCode });
                        }
                    }

                    if (strContractStatus == ContractStatus.C_CONTRACT_STATUS_STOPPING)
                    {
                        throw ApplicationErrorException.ThrowErrorException(
                                  MessageUtil.MODULE_CONTRACT,
                                  MessageUtil.MessageList.MSG3044,
                                  new string[] { contractCode });
                    }

                    if (strContractStatus == ContractStatus.C_CONTRACT_STATUS_CANCEL ||
                        strContractStatus == ContractStatus.C_CONTRACT_STATUS_END)
                    {
                        throw ApplicationErrorException.ThrowErrorException(
                                  MessageUtil.MODULE_CONTRACT,
                                  MessageUtil.MessageList.MSG3105,
                                  new string[] { contractCode });
                    }

                    if (strContractStatus == ContractStatus.C_CONTRACT_STATUS_FIXED_CANCEL)
                    {
                        throw ApplicationErrorException.ThrowErrorException(
                                  MessageUtil.MODULE_CONTRACT,
                                  MessageUtil.MessageList.MSG3116,
                                  new string[] { contractCode });
                    }

                    List <tbt_RelationType> relationTypeList
                        = base.CheckRelationType(strContractCode
                                                 , ContractStatus.C_CONTRACT_STATUS_END
                                                 , ContractStatus.C_CONTRACT_STATUS_CANCEL
                                                 , ContractStatus.C_CONTRACT_STATUS_FIXED_CANCEL
                                                 , strQuotationTargetCode
                                                 , null);
                    //                                  , (strProductTypeCode == ProductType.C_PROD_TYPE_SALE? RelationType.C_RELATION_TYPE_SALE : RelationType.C_RELATION_TYPE_MA));

                    if (relationTypeList != null && relationTypeList.Count > 0)
                    {
                        CommonUtil c = new CommonUtil();

                        /* --- Merge --- */

                        /*  throw ApplicationErrorException.ThrowErrorException(
                         *  MessageUtil.MODULE_CONTRACT,
                         *  MessageUtil.MessageList.MSG3120,
                         *  c.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT),
                         *  c.ConvertContractCode(relationTypeList[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT)
                         *  ); */
                        throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT,
                                                                            MessageUtil.MessageList.MSG3120,
                                                                            contractCode,
                                                                            c.ConvertContractCode(relationTypeList[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT));
                        /* ------------- */
                    }

                    //7. Map dtContractData to doContractHeader
                    contractList             = CommonUtil.ConvertObjectbyLanguage <dtGetMaintenanceTargetContract, dtGetMaintenanceTargetContract>(contractList, "ProductName");
                    headerDo.ContractCode    = contractList[0].ContractCode;
                    headerDo.CreateDate      = contractList[0].CreateDate;
                    headerDo.ProductCode     = contractList[0].ProductCode;
                    headerDo.ProductName     = contractList[0].ProductName;
                    headerDo.ProductNameEN   = contractList[0].ProductNameEN;
                    headerDo.ProductNameJP   = contractList[0].ProductNameJP;
                    headerDo.ProductNameLC   = contractList[0].ProductNameLC;
                    headerDo.ProductTypeCode = contractList[0].ProductTypeCode;

                    /* --- Merge --- */
                    headerDo.SiteCode = contractList[0].SiteCode;
                    /* ------------- */
                }
                else
                {
                    CommonUtil c = new CommonUtil();
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0105, c.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT));
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(headerDo);
        }