public ActionResult CTS055(string contractCode) { ObjectResultData res = new ObjectResultData(); try { CTS055_ScreenParameter session = GetScreenObject <CTS055_ScreenParameter>(); ViewBag.ContractCode = session.ScreenParameter.ContractCode; ViewBag.ImportantFlag = false; //HasAuthority_CTS055(contractCode); HasAuthority_CTS055(session.ScreenParameter.ContractCode); if (ViewBag.Permission == true && ViewBag.IsSystemSuspending == false && ViewBag.HasAuthorityContract == true && ViewBag.HasAuthorityOperation == true) { InitialScreen_CTS055(session.ScreenParameter.ContractCode.Trim()); } return(View("CTS055")); } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }
/// <summary> /// Set import data to screen /// </summary> /// <param name="import"></param> /// <param name="key"></param> private void CTS055_SetImportData(CTS055_ScreenParameter import, string key = null) { try { UpdateScreenObject(import, key); } catch (Exception ex) { throw ex; } }
/// <summary> /// Initial session of screen /// </summary> /// <returns></returns> public CTS055_ScreenParameter InitialScreenSession_CTS055() { try { CTS055_ScreenParameter importData = new CTS055_ScreenParameter() { DOValidateBusiness = new CTS055_DOValidateBusiness(), ScreenParameter = new CTS055_Parameter() }; CTS055_SetImportData(importData); return(importData); } catch (Exception ex) { throw ex; } }
/// <summary> /// Check system suspending, user’s permission and user’s authority of screen /// </summary> /// <param name="param"></param> /// <returns></returns> public ActionResult CTS055_Authority(CTS055_ScreenParameter param) { ObjectResultData res = new ObjectResultData(); try { CommonUtil util = new CommonUtil(); ISaleContractHandler salehandler = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; ICommonHandler commonHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; IRentralContractHandler renderHandler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; IInstallationHandler installhandler = ServiceContainer.GetService <IInstallationHandler>() as IInstallationHandler; //1.1 Check suspending if (commonHandler.IsSystemSuspending()) { res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0049, null, null); return(Json(res)); } //1.2 Check user's permission if (!CheckUserPermission(ScreenID.C_SCREEN_ID_CP12_CANCEL_UNIMPLEMENTED_CONTRACT, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0053, null, null); return(Json(res)); } //if (String.IsNullOrEmpty(param.ContractCode) && !String.IsNullOrEmpty(CommonUtil.dsTransData.dtCommonSearch.ContractCode)) //{ // param.ContractCode = CommonUtil.dsTransData.dtCommonSearch.ContractCode; //} if (String.IsNullOrEmpty(param.ContractCode) && param.CommonSearch != null) { if (CommonUtil.IsNullOrEmpty(param.CommonSearch.ContractCode) == false) { param.ContractCode = param.CommonSearch.ContractCode; } } // Check parameter if ((param == null) || (String.IsNullOrEmpty(param.ContractCode))) { // Not valid //res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0011, new string[] { "Contract Code" }, null); res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0147, null, null); return(Json(res)); } //Comment by Jutarat A. on 08082012 //var saleExists = salehandler.IsContractExist(util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG)); //if (saleExists.Count > 0 && saleExists[0].GetValueOrDefault()) //{ // res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3278, null, null); // return Json(res); //} // Check is contact exists var contractObj = renderHandler.GetTbt_RentalContractBasic(util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG), null); if ((contractObj == null) || (contractObj.Count == 0)) { // Not found //res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0011, new string[] { String.Format("Contract Code: {0}", param.ContractCode) }, null); res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0124, null, null); return(Json(res)); } //1.3 Check user's authority to view data /* * if (CommonUtil.dsTransData.dtOfficeData.FindAll(delegate(OfficeDataDo s) { return s.OfficeCode == contractObj[0].ContractOfficeCode; }).Count == 0) * { * res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0063, null, null); * return Json(res); * } * * if (CommonUtil.dsTransData.dtOfficeData.FindAll(delegate(OfficeDataDo s) { return s.OfficeCode == contractObj[0].OperationOfficeCode; }).Count == 0) * { * res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0063, null, null); * return Json(res); * } * */ var existsContarctOffice = CommonUtil.dsTransData.dtOfficeData.Where(x => x.OfficeCode == contractObj[0].ContractOfficeCode); var existsOperateOffice = CommonUtil.dsTransData.dtOfficeData.Where(x => x.OfficeCode == contractObj[0].OperationOfficeCode); if ((contractObj[0].ContractStatus == ContractStatus.C_CONTRACT_STATUS_BEF_START && (existsContarctOffice.Count() <= 0) && (existsOperateOffice.Count() <= 0)) || (contractObj[0].ContractStatus == ContractStatus.C_CONTRACT_STATUS_AFTER_START && (existsOperateOffice.Count() <= 0)) ) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0063, null, null); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; return(Json(res)); } var lastOCC = renderHandler.GetLastUnimplementedOCC(util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG)); if (String.IsNullOrEmpty(lastOCC) || contractObj[0].ProductTypeCode == ProductType.C_PROD_TYPE_MA || contractObj[0].ProductTypeCode == ProductType.C_PROD_TYPE_SG || contractObj[0].ProductTypeCode == ProductType.C_PROD_TYPE_BE ) { res.AddErrorMessage("Contract", MessageUtil.MessageList.MSG3056, null, null); return(Json(res)); } if ((contractObj[0].LastChangeType == RentalChangeType.C_RENTAL_CHANGE_TYPE_CANCEL) || (contractObj[0].LastChangeType == RentalChangeType.C_RENTAL_CHANGE_TYPE_CANCEL_BEFORE_START) || (contractObj[0].LastChangeType == RentalChangeType.C_RENTAL_CHANGE_TYPE_END_CONTRACT) || (contractObj[0].LastChangeType == RentalChangeType.C_RENTAL_CHANGE_TYPE_TERMINATED)) { res.AddErrorMessage("Contract", MessageUtil.MessageList.MSG3001, null, null); return(Json(res)); } var secureObj = renderHandler.GetTbt_RentalSecurityBasic(util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG), lastOCC); // Unimplement Addition string installStatus = installhandler.GetInstallationStatus(util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG)); if (((contractObj[0].ProductTypeCode == ProductType.C_PROD_TYPE_AL) || (contractObj[0].ProductTypeCode == ProductType.C_PROD_TYPE_RENTAL_SALE)) && ((installStatus != InstallationStatus.C_INSTALL_STATUS_NO_INSTALLATION) || (secureObj[0].InstallationCompleteFlag == FlagType.C_FLAG_ON))) { res.AddErrorMessage("Contract", MessageUtil.MessageList.MSG3054, null, null); return(Json(res)); } string occCode = renderHandler.GetLastUnimplementedOCC(contractObj[0].ContractCode); if (String.IsNullOrEmpty(occCode)) { res.AddErrorMessage("Contract", MessageUtil.MessageList.MSG3055, null, null); return(Json(res)); } var dtRentalSecurityBasic = renderHandler.GetTbt_RentalSecurityBasicForView(contractObj[0].ContractCode, occCode.Trim())[0]; if (StartType.C_START_TYPE_ALTER_START == contractObj[0].StartType && OCCType.C_FIRST_UNIMPLEMENTED_SECURITY_OCC == dtRentalSecurityBasic.OCC) { res.AddErrorMessage("Contract", MessageUtil.MessageList.MSG3288, null, null); return(Json(res)); } if (contractObj[0].ContractStatus == SECOM_AJIS.Common.Util.ConstantValue.ContractStatus.C_CONTRACT_STATUS_BEF_START && dtRentalSecurityBasic.OCC == SECOM_AJIS.Common.Util.ConstantValue.OCCType.C_FIRST_UNIMPLEMENTED_SECURITY_OCC) { res.AddErrorMessage("Contract", MessageUtil.MessageList.MSG3055, null, null); return(Json(res)); } //================ CHeck permission to view contract data =================== List <tbt_RentalContractBasic> listRentalContractBasic; listRentalContractBasic = renderHandler.GetTbt_RentalContractBasic(util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG), null); //1.3 Check user's authority to view data if (CommonUtil.dsTransData.dtOfficeData.FindAll(delegate(OfficeDataDo s) { return(s.OfficeCode == contractObj[0].ContractOfficeCode); }).Count == 0) { res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0063, null, null); return(Json(res)); } //=========================================================================== CTS055_ScreenParameter session = InitialScreenSession_CTS055(); session.ScreenParameter.ContractCode = util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); //return InitialScreenEnvironment("CTS054", session); return(InitialScreenEnvironment <CTS055_ScreenParameter>("CTS055", session, res)); } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }