/// <summary> /// Validate business of screen /// </summary> /// <param name="res"></param> /// <param name="tbt_SaleBasicData"></param> public void ValidateDataBusiness_CTS090(ObjectResultData res, tbt_SaleBasic tbt_SaleBasicData = null) { CTS090_RegisterCancelTargetData registerCancelData; IInstallationHandler installHandler = ServiceContainer.GetService <IInstallationHandler>() as IInstallationHandler; try { if (tbt_SaleBasicData != null) { registerCancelData = new CTS090_RegisterCancelTargetData(); registerCancelData.RegisterCancelData = tbt_SaleBasicData; } else { CTS090_ScreenParameter sParam = GetScreenObject <CTS090_ScreenParameter>(); registerCancelData = sParam.CTS090_Session; } if (registerCancelData != null) { //Check change type if ((registerCancelData.RegisterCancelData != null && registerCancelData.RegisterCancelData.ChangeType != null) && ((registerCancelData.RegisterCancelData.ChangeType != SaleChangeType.C_SALE_CHANGE_TYPE_NEW_SALE) && (registerCancelData.RegisterCancelData.ChangeType != SaleChangeType.C_SALE_CHANGE_TYPE_ADD_SALE))) { res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3168, null, null); return; } //Check complete installation status if ((registerCancelData.RegisterCancelData != null && registerCancelData.RegisterCancelData.InstallationCompleteFlag != null) && (registerCancelData.RegisterCancelData.InstallationCompleteFlag == FlagType.C_FLAG_ON)) { res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3058, null, null); return; } //Check cancel status if ((registerCancelData.RegisterCancelData != null && registerCancelData.RegisterCancelData.SaleProcessManageStatus != null) && (registerCancelData.RegisterCancelData.SaleProcessManageStatus == SaleProcessManageStatus.C_SALE_PROCESS_STATUS_CANCEL)) { res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3105, null, null); return; } //Add by Jutarat A. on 06062013 //Check installation status //Get installation basic List <tbt_InstallationBasic> doTbt_InstallationBasicValidate = installHandler.GetTbt_InstallationBasicData(registerCancelData.RegisterCancelData.ContractCode); if (doTbt_InstallationBasicValidate != null && doTbt_InstallationBasicValidate.Count > 0 && doTbt_InstallationBasicValidate[0].InstallationStatus != InstallationStatus.C_INSTALL_STATUS_INSTALL_NOT_REGISTERED) { res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3309, null, null); return; } //End Add } } catch (Exception ex) { res.AddErrorMessage(ex); } }
/// <summary> /// Check system suspending, user’s permission and user’s authority of screen /// </summary> /// <param name="sParam"></param> /// <returns></returns> public ActionResult CTS090_Authority(CTS090_ScreenParameter sParam) { ObjectResultData res = new ObjectResultData(); CommonUtil comUtil = new CommonUtil(); ISaleContractHandler saleHandler; List <tbt_SaleBasic> tbtSaleBasicList; tbt_SaleBasic tbt_SaleBasicData = null; string strContractCodeLong = string.Empty; string strOccCode = string.Empty; CTS090_doSaleBasicDataAuthority doSaleBasicDataAuthority; try { //CheckSystemStatus if (CheckIsSuspending(res) == true) { return(Json(res)); } /*--- HasAuthority ---*/ //Check screen permission if (CheckUserPermission(ScreenID.C_SCREEN_ID_CANCEL_SALE_CONTRACT, FunctionID.C_FUNC_ID_OPERATE) == false) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } //if (String.IsNullOrEmpty(sParam.ContractCode)) // sParam.ContractCode = CommonUtil.dsTransData.dtCommonSearch.ContractCode; if (String.IsNullOrEmpty(sParam.ContractCode) && sParam.CommonSearch != null) { if (CommonUtil.IsNullOrEmpty(sParam.CommonSearch.ContractCode) == false) { sParam.ContractCode = sParam.CommonSearch.ContractCode; } } //Check required field if (String.IsNullOrEmpty(sParam.ContractCode)) { //res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { "ContractCode" }); //res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, // ScreenID.C_SCREEN_ID_CANCEL_SALE_CONTRACT, // MessageUtil.MODULE_COMMON, // MessageUtil.MessageList.MSG0007, // new string[] { "lblContractCode" }, // null); res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0147); return(Json(res)); } strContractCodeLong = comUtil.ConvertContractCode(sParam.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); //RetrieveSaleContractData saleHandler = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; strOccCode = saleHandler.GetLastOCC(strContractCodeLong); tbtSaleBasicList = saleHandler.GetTbt_SaleBasic(strContractCodeLong, strOccCode, FlagType.C_FLAG_ON); //Check existing of sale contract data if (tbtSaleBasicList == null || tbtSaleBasicList.Count < 1) { //res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0093, new string[] { sParam.ContractCode }); res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0124); return(Json(res)); } //CheckDataAuthority tbt_SaleBasicData = tbtSaleBasicList[0]; doSaleBasicDataAuthority = CommonUtil.CloneObject <tbt_SaleBasic, CTS090_doSaleBasicDataAuthority>(tbt_SaleBasicData); if (CommonUtil.IsNullOrEmpty(doSaleBasicDataAuthority.OperationOfficeCode) == false) { ValidatorUtil.BuildErrorMessage(res, new object[] { doSaleBasicDataAuthority }, null, false); if (res.IsError) { return(Json(res)); } } /*-------------------------*/ //ValidateDataBusiness ValidateDataBusiness_CTS090(res, tbt_SaleBasicData); if (res.IsError) { return(Json(res)); } //sParam = new CTS090_ScreenParameter(); sParam.CTS090_Session = new CTS090_RegisterCancelTargetData(); sParam.CTS090_Session.InitialData = new CTS090_InitialRegisterCancelTargetData(); sParam.CTS090_Session.InitialData.ContractCode = strContractCodeLong; sParam.CTS090_Session.InitialData.OCCCode = strOccCode; sParam.CTS090_Session.RegisterCancelData = tbt_SaleBasicData; } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } //**** Change Session ****// //return InitialScreenEnvironment("CTS090", new object[] { strContractCodeLong, strOccCode, tbt_SaleBasicData}); return(InitialScreenEnvironment <CTS090_RegisterCancelTargetData>("CTS090", sParam, res)); }