コード例 #1
0
        /// <summary>
        /// Confirm billing target data
        /// </summary>
        /// <param name="doTbmBillingClient"></param>
        /// <param name="doTbtBillingTarget"></param>
        /// <returns></returns>
        public ActionResult BLS010_ConfirmBillingTargetData(SECOM_AJIS.DataEntity.Master.tbm_BillingClient doTbmBillingClient, tbt_BillingTarget doTbtBillingTarget)
        //public ActionResult BLS010_ConfirmBillingTargetData(BLS010_ScreenParameter param)
        {
            ObjectResultData res     = new ObjectResultData();
            CommonUtil       comUtil = new CommonUtil();
            IBillingHandler  handler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;

            SECOM_AJIS.DataEntity.Master.IBillingMasterHandler handlerMaster = ServiceContainer.GetService <SECOM_AJIS.DataEntity.Master.IBillingMasterHandler>() as SECOM_AJIS.DataEntity.Master.IBillingMasterHandler;
            string strBillingClientCode = null;
            string strBillingTargetCode = null;

            BLS010_ScreenParameter sParam = GetScreenObject <BLS010_ScreenParameter>();

            // tbm_BillingClient doTbmBillingClient = param.doTbmBillingClientParam;
            // tbt_BillingTarget doTbtBillingTarget = param.doTbt_BillingTarget;
            try
            {
                ///////// Check Suspending //////////
                ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                if (chandler.IsSystemSuspending())
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049);
                    return(Json(res));
                }


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

                //clone tbtBillingClientData to tbm_billingcliebtData
                doTbmBillingClient = CommonUtil.CloneObject <SECOM_AJIS.DataEntity.Master.dtBillingClientData, SECOM_AJIS.DataEntity.Master.tbm_BillingClient>(sParam.doBillingClient);
                doTbmBillingClient.BillingClientCode = comUtil.ConvertBillingClientCode(doTbmBillingClient.BillingClientCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                doTbtBillingTarget.BillingClientCode = comUtil.ConvertBillingClientCode(doTbtBillingTarget.BillingClientCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                //validatebusiness
                tbt_BillingTarget tmpTbtBillingTarget = new tbt_BillingTarget();
                if (!CommonUtil.IsNullOrEmpty(doTbmBillingClient.BillingClientCode))
                {
                    List <tbt_BillingTarget> lst = new List <tbt_BillingTarget>();
                    lst = handler.GetTbt_BillingTarget(null, doTbmBillingClient.BillingClientCode, doTbtBillingTarget.BillingOfficeCode);
                    if (lst.Count > 0)
                    {
                        tmpTbtBillingTarget = lst[0];
                    }
                    else
                    {
                        tmpTbtBillingTarget = null;
                    }


                    if (tmpTbtBillingTarget != null)
                    {
                        res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;

                        res.AddErrorMessage(MessageUtil.MODULE_BILLING,
                                            ScreenID.C_SCREEN_ID_REGIST_BILL_TARGET,
                                            MessageUtil.MODULE_BILLING,
                                            MessageUtil.MessageList.MSG6002,
                                            new string[] { comUtil.ConvertBillingTargetCode(tmpTbtBillingTarget.BillingTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT) },
                                            null);
                        return(Json(res));
                    }
                }


                var tmpdoTbmBillingClient = CommonUtil.CloneObject <tbm_BillingClient, tbm_BillingClient>(doTbmBillingClient);
                var tmpdoTbtBillingTarget = CommonUtil.CloneObject <tbt_BillingTarget, tbt_BillingTarget>(doTbtBillingTarget);

                //register new billing target
                using (TransactionScope scope = new TransactionScope())
                {
                    //7.3.4
                    if (CommonUtil.IsNullOrEmpty(tmpdoTbtBillingTarget.BillingClientCode))
                    {
                        strBillingClientCode = handlerMaster.ManageBillingClient(tmpdoTbmBillingClient);
                        tmpdoTbtBillingTarget.BillingClientCode = strBillingClientCode;
                    }

                    //7.3.5 create billing target
                    strBillingTargetCode = handler.CreateBillingTarget(tmpdoTbtBillingTarget);
                    tmpdoTbtBillingTarget.BillingTargetCode = comUtil.ConvertBillingClientCode(strBillingTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    tmpdoTbmBillingClient.BillingClientCode = comUtil.ConvertBillingClientCode(tmpdoTbmBillingClient.BillingClientCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    scope.Complete();

                    doTbmBillingClient = CommonUtil.CloneObject <tbm_BillingClient, tbm_BillingClient>(tmpdoTbmBillingClient);
                    doTbtBillingTarget = CommonUtil.CloneObject <tbt_BillingTarget, tbt_BillingTarget>(tmpdoTbtBillingTarget);
                }
                doTbtBillingTarget.BillingClientCode = comUtil.ConvertBillingClientCode(doTbtBillingTarget.BillingClientCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                sParam.doTbt_BillingTarget           = doTbtBillingTarget;
                res.ResultData  = doTbtBillingTarget;
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION_OK;
                res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0046, null, null);
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }