/// <summary> /// Get sub-contractor data list by contractcode , OCC /// </summary> /// <param name="strContractCode"></param> /// <param name="strOCC"></param> /// <returns></returns> public ActionResult CMS130_GetSubContractList(string strContractCode, string strOCC) { CommonUtil c = new CommonUtil(); List <dtTbt_RentalInstSubContractorListForView> list = new List <dtTbt_RentalInstSubContractorListForView>(); ObjectResultData res = new ObjectResultData(); try { strContractCode = c.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); IRentralContractHandler handler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; list = handler.GetTbt_RentalInstSubContractorListForView(strContractCode, strOCC); //return Json(CommonUtil.ConvertToXml<dtTbt_RentalInstSubContractorListForView>(list, "Common\\CMS130")); } catch (Exception ex) { list = new List <dtTbt_RentalInstSubContractorListForView>(); res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(ex); } res.ResultData = CommonUtil.ConvertToXml <dtTbt_RentalInstSubContractorListForView>(list, "Common\\CMS130"); return(Json(res)); }
//public ActionResult CMS020_SearchBar_Authority() //{ // return InitialScreenEnvironment("CMS020_SearchBar"); //} ////[Initialize("CMS020_SearchBar")] //public ActionResult CMS020_SearchBar() //{ // return View(); //} /// <summary> /// Retrieve contract data from tbt_RentalContractBasic or tbt_SaleBasic. /// </summary> /// <param name="strContractCode"></param> /// <param name="strUserCode"></param> /// <returns></returns> private dsContractData CMS020_RetrieveContract(string strContractCode, string strUserCode) { try { CommonUtil cm = new CommonUtil(); strContractCode = cm.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); dsContractData dsContractData = new dsContractData(); IRentralContractHandler RentHand = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; List <tbt_RentalContractBasic> dtRCB = RentHand.GetTbt_RentalContractBasic(strContractCode, strUserCode); if (dtRCB.Count == 0) { ISaleContractHandler SaleHand = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; List <tbt_SaleBasic> dtSB = SaleHand.GetTbt_SaleBasic(strContractCode, null, FlagType.C_FLAG_ON); if (dtSB.Count > 0) { dsContractData.dtSB = dtSB; dsContractData.dtRCB = null; } } else { dsContractData.dtSB = null; dsContractData.dtRCB = dtRCB; } return(dsContractData); } catch (Exception) { throw; } }
/// <summary> /// Check permission for access screen CMS200 /// </summary> /// <param name="param"></param> /// <returns></returns> public ActionResult CMS200_Authority(CMS200_ScreenParameter param) // IN parameter: string strContractCode, string strServiceTypeCode { ObjectResultData res = new ObjectResultData(); // Check permission if (!CheckUserPermission(ScreenID.C_SCREEN_ID_VIEW_CONTRACT_BILLING, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } // Check parameter is OK ? if (CommonUtil.IsNullOrEmpty(param.strContractCode) == false && CommonUtil.IsNullOrEmpty(param.strServiceTypeCode) == false) { param.ContractCode = param.strContractCode; param.ServiceTypeCode = param.strServiceTypeCode; } else { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0040); return(Json(res)); } // Check exist data try { CommonUtil c = new CommonUtil(); string ContractCode = c.ConvertContractCode(param.strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); IRentralContractHandler handlerRC = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; ISaleContractHandler handlerSC = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; List <dtTbt_RentalContractBasicForView> listRC = new List <dtTbt_RentalContractBasicForView>(); List <dtTbt_SaleBasicForView> listSC = new List <dtTbt_SaleBasicForView>(); if (param.strServiceTypeCode == ServiceType.C_SERVICE_TYPE_RENTAL) { listRC = handlerRC.GetTbt_RentalContractBasicForView(ContractCode); } else if (param.strServiceTypeCode == ServiceType.C_SERVICE_TYPE_SALE) { listSC = handlerSC.GetTbt_SaleBasicForView(ContractCode, null, true); } if (listRC.Count == 0 && listSC.Count == 0) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001); return(Json(res)); } } catch { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001); return(Json(res)); } return(InitialScreenEnvironment <CMS200_ScreenParameter>("CMS200", param, res)); }
/// <summary> /// Get facility detail /// </summary> /// <param name="strContractCode"></param> /// <param name="strOCC"></param> /// <returns></returns> public ActionResult CMS140_GetFacilityDetail(string strContractCode, string strOCC) { CommonUtil c = new CommonUtil(); List <dtTbt_RentalInstrumentDetailsListForView> list = new List <dtTbt_RentalInstrumentDetailsListForView>(); ObjectResultData res = new ObjectResultData(); try { strContractCode = c.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); IRentralContractHandler handler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; list = handler.GetTbt_RentalInstrumentDetailsListForView(strContractCode, strOCC, null, InstrumentType.C_INST_TYPE_MONITOR); // Select language list = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalInstrumentDetailsListForView, dtTbt_RentalInstrumentDetailsListForView>(list, "InstrumentNameForCustomer"); } catch (Exception ex) { res.AddErrorMessage(ex); } res.ResultData = CommonUtil.ConvertToXml <dtTbt_RentalInstrumentDetailsListForView>(list, "Common\\CMS140_FacilityDeatail"); return(Json(res)); }
/// <summary> /// Get maintenance contract target data list /// </summary> /// <param name="strContractCode"></param> /// <param name="strOCC"></param> /// <returns></returns> public ActionResult CMS140_GetMaintenanceContractTargetList(string strContractCode, string strOCC) { CommonUtil c = new CommonUtil(); List <View_dtRelatedContract> nlst = new List <View_dtRelatedContract>(); ObjectResultData res = new ObjectResultData(); try { strContractCode = c.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); IRentralContractHandler handler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; ICommonHandler comHand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>() { new doMiscTypeCode() { FieldName = MiscType.C_CURRENCT, ValueCode = "%" } }).ToList(); List <dtRelatedContract> list = handler.GetRelatedContractList(RelationType.C_RELATION_TYPE_MA, strContractCode, strOCC); //Add Currency to List for (int i = 0; i < list.Count(); i++) { list[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies); } // Clone object to View object foreach (dtRelatedContract l in list) { nlst.Add(CommonUtil.CloneObject <dtRelatedContract, View_dtRelatedContract>(l)); } // Select language nlst = CommonUtil.ConvertObjectbyLanguage <View_dtRelatedContract, View_dtRelatedContract>(nlst, "ProductName"); // convert to short format foreach (var item in nlst) { // contractcode item.RelatedContractCode = c.ConvertContractCode(item.RelatedContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } } catch (Exception ex) { nlst = new List <View_dtRelatedContract>(); res.AddErrorMessage(ex); } res.ResultData = CommonUtil.ConvertToXml <View_dtRelatedContract>(nlst, "Common\\CMS140_MaintenanceContract"); return(Json(res)); }
public ActionResult CMS180() { ObjectResultData res = new ObjectResultData(); try { CMS180_ScreenParameter param = GetScreenObject <CMS180_ScreenParameter>(); //for test //param.ContractCode = "N2700112"; //param.InstallationSlipNo = "70000120120101"; //Prepare for show section if (!CommonUtil.IsNullOrEmpty(param)) { ViewBag.ContractCode = param.ContractCode; ViewBag.InstallationSlipNo = param.InstallationSlipNo; } if (string.IsNullOrEmpty(param.ContractCode) == false) { //Finding service type code CommonUtil c = new CommonUtil(); string longContractCode = c.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); //Rental IRentralContractHandler handlerR = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; List <tbt_RentalContractBasic> dtRentalContract = handlerR.GetTbt_RentalContractBasic(longContractCode, null); if (dtRentalContract.Count > 0) { param.ServiceTypeCode = ServiceType.C_SERVICE_TYPE_RENTAL; } else { // Sale ISaleContractHandler handlerS = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; List <tbt_SaleBasic> dtSaleContract = handlerS.GetTbt_SaleBasic(longContractCode, null, true); if (dtSaleContract.Count > 0) { param.ServiceTypeCode = ServiceType.C_SERVICE_TYPE_SALE; } } } ViewBag.ServiceTypeCode = param.ServiceTypeCode; } catch (Exception ex) { res.AddErrorMessage(ex); } //ViewBag.AttachKey = GetCurrentKey(); return(View()); }
/// <summary> /// Get Rental Basic information from tbt_RentalBasic /// </summary> /// <param name="strLongContratCode"></param> /// <returns></returns> public dsRentalBasicForHistDigestView GetRentalBasicForHistoryDigestView(string strLongContratCode) { try { dsRentalBasicForHistDigestView dsRentBasicForHDView = new dsRentalBasicForHistDigestView(); IRentralContractHandler handRen = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; List <dtTbt_RentalContractBasicForView> lstTbt_RentalContractBasicForView = handRen.GetTbt_RentalContractBasicForView(strLongContratCode); if (lstTbt_RentalContractBasicForView.Count <= 0) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001); } dsRentBasicForHDView.dtTbt_RentalContractBasicForView = lstTbt_RentalContractBasicForView; //2.3 ICommonHandler handCom = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; //List<doMiscTypeCode> MiscTypeCode = new List<doMiscTypeCode>(); //for (int i = 0; i < 3; i++) // MiscTypeCode.Add(new doMiscTypeCode()); //MiscTypeCode[0].FieldName = MiscType.C_RENTAL_CHANGE_TYPE; //MiscTypeCode[0].ValueCode = "%"; //MiscTypeCode[1].FieldName = MiscType.C_INCIDENT_TYPE; //MiscTypeCode[1].ValueCode = "%"; //MiscTypeCode[2].FieldName = MiscType.C_AR_TYPE; //MiscTypeCode[2].ValueCode = "%"; //List<doMiscTypeCode> MiscTypeResult = handCom.GetMiscTypeCodeList(MiscTypeCode); //dsRentBasicForHDView.dtMiscellaneousType = MiscTypeResult; IViewContractHandler handView = ServiceContainer.GetService <IViewContractHandler>() as IViewContractHandler; ICommonHandler comHand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>() { new doMiscTypeCode() { FieldName = MiscType.C_CURRENCT, ValueCode = "%" } }).ToList(); List <dtRentalHistoryDigest> dtRentalHistoryDigest = handView.GetRentalHistoryDigestList(dsRentBasicForHDView.dtTbt_RentalContractBasicForView[0].ContractCode, null, null); for (int i = 0; i < dtRentalHistoryDigest.Count; i++) { dtRentalHistoryDigest[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies); } dsRentBasicForHDView.dtRentalHistoryDigest = dtRentalHistoryDigest; return(dsRentBasicForHDView); } catch (Exception) { throw; } }
/// <summary> /// Check permission for access screen CMS140 /// </summary> /// <param name="param"></param> /// <returns></returns> public ActionResult CMS140_Authority(CMS140_ScreenParameter param) // IN parameter: string strContractCode, string strOCC { ObjectResultData res = new ObjectResultData(); // Check permission if (!CheckUserPermission(ScreenID.C_SCREEN_ID_VIEW_SECURITY_DETAIL, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } // Check parameter is OK ? if (CommonUtil.IsNullOrEmpty(param.strContractCode) == false) { param.ContractCode = param.strContractCode; param.OCC = param.strOCC; } else { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0040); return(Json(res)); } // Check data exist try { CommonUtil c = new CommonUtil(); string ContractCode = c.ConvertContractCode(param.strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); // Rental IRentralContractHandler handler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; List <dtTbt_RentalContractBasicForView> dtRentalContract = handler.GetTbt_RentalContractBasicForView(ContractCode); if (dtRentalContract.Count == 0) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001); return(Json(res)); } } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } return(InitialScreenEnvironment <CMS140_ScreenParameter>("CMS140", param, res)); }
/// <summary> /// Update contract basic data /// </summary> /// <param name="dt"></param> /// <returns></returns> private bool CTS190_UpdateContractBasicData(List <tbt_ContractDocument> dt) { try { if (dt == null || dt.Count == 0) { return(false); } IRentralContractHandler handlerRC = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; // Get RCB List <tbt_RentalContractBasic> dtRCB = handlerRC.GetTbt_RentalContractBasic(dt[0].ContractCode, null); if (dtRCB.Count == 0) { return(false); } if (dt[0].DocumentCode == DocumentCode.C_DOCUMENT_CODE_PO) { dtRCB[0].PODocAuditResult = dt[0].DocAuditResult; dtRCB[0].PODocReceiveDate = dt[0].CollectDocDate; } else if ((dt[0].DocumentCode == DocumentCode.C_DOCUMENT_CODE_CONTRACT_EN || dt[0].DocumentCode == DocumentCode.C_DOCUMENT_CODE_CONTRACT_TH) && dt[0].OCC == ParticularOCC.C_PARTICULAR_OCC_CONTRACT_REP_BEF_START) { dtRCB[0].ContractDocAuditResult = dt[0].DocAuditResult; dtRCB[0].ContractDocReceiveDate = dt[0].CollectDocDate; } else if (dt[0].DocumentCode == DocumentCode.C_DOCUMENT_CODE_START_OPER_CONFIRM_LETTER) { dtRCB[0].StartMemoAuditResult = dt[0].DocAuditResult; dtRCB[0].StartMemoReceiveDate = dt[0].CollectDocDate; } dtRCB[0].AuditCollectionProcessDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; handlerRC.UpdateTbt_RentalContractBasicCore(dtRCB[0]); return(true); } catch (Exception) { throw; } }
/// <summary> /// Check permission for access screen CMS131 /// </summary> /// <param name="param"></param> /// <returns></returns> public ActionResult CMS131_Authority(CMS131_ScreenParameter param) // IN parameter: string strContractCode, string strOCC { ObjectResultData res = new ObjectResultData(); // Check parameter is OK ? if (CommonUtil.IsNullOrEmpty(param.strContractCode) == false && CommonUtil.IsNullOrEmpty(param.strOCC) == false) { param.ContractCode = param.strContractCode; param.OCC = param.strOCC; } else { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0040); return(Json(res)); } // Check exist data try { CommonUtil c = new CommonUtil(); string ContractCode = c.ConvertContractCode(param.strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); IRentralContractHandler handler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; List <dtTbt_RentalContractBasicForView> dtRentalContract = handler.GetTbt_RentalContractBasicForView(ContractCode); if (dtRentalContract.Count == 0) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001); return(Json(res)); } } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } return(InitialScreenEnvironment <CMS131_ScreenParameter>("CMS131", param, res)); }
/// <summary> /// Check data authority /// </summary> /// <param name="dtContractDocReceive"></param> /// <returns></returns> private bool CTS190_CheckDataAuthority(dtContractDocHeader dtContractDocReceive) { bool hasAuthority = false; // Old //List<OfficeDataDo> list = (from p in CommonUtil.dsTransData.dtOfficeData // where p.OfficeCode == dtContractDocReceive.ContractOfficeCode || // p.OfficeCode == dtContractDocReceive.OperationOfficeCode // select p).ToList<OfficeDataDo>(); //hasAuthority = (list.Count > 0); IRentralContractHandler handlerRC = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; ISaleContractHandler handlerSale = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; // get RCB List <tbt_RentalContractBasic> dtRCB = handlerRC.GetTbt_RentalContractBasic(dtContractDocReceive.ContractCode, null); // get Sale basic List <tbt_SaleBasic> dtSB = handlerSale.GetTbt_SaleBasic(dtContractDocReceive.ContractCode, null, true); List <OfficeDataDo> list = new List <OfficeDataDo>(); if (dtRCB.Count > 0) { list = (from p in CommonUtil.dsTransData.dtOfficeData where p.OfficeCode == dtRCB[0].ContractOfficeCode || p.OfficeCode == dtRCB[0].OperationOfficeCode select p).ToList <OfficeDataDo>(); } else if (dtSB.Count > 0) { list = (from p in CommonUtil.dsTransData.dtOfficeData where p.OfficeCode == dtSB[0].ContractOfficeCode || p.OfficeCode == dtSB[0].OperationOfficeCode select p).ToList <OfficeDataDo>(); } hasAuthority = (list.Count > 0); return(hasAuthority); }
/// <summary> /// Get Rental digest by type and contract code. /// </summary> /// <param name="sType"></param> /// <param name="strLongContractCode"></param> /// <returns></returns> public ActionResult getRentalDigestCMS150(string sType, string strLongContractCode) { if (strLongContractCode.Trim() == "") { strLongContractCode = null; } if (sType.Trim() == "") { sType = null; } ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; List <View_dtRentalHistoryDigest> RentalHist = null; try { IRentralContractHandler handRen = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; List <dtTbt_RentalContractBasicForView> lstTbt_RentalContractBasicForView = handRen.GetTbt_RentalContractBasicForView(strLongContractCode); if (lstTbt_RentalContractBasicForView.Count <= 0) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001); // return Json(res); } else { IViewContractHandler handView = ServiceContainer.GetService <IViewContractHandler>() as IViewContractHandler; List <dtRentalHistoryDigest> dtRentalHistoryDigest = handView.GetRentalHistoryDigestList(lstTbt_RentalContractBasicForView[0].ContractCode, null, null); RentalHist = CommonUtil.ConvertObjectbyLanguage <dtRentalHistoryDigest, View_dtRentalHistoryDigest>(dtRentalHistoryDigest, "ChangeTypeName", "IncidentARTypeName", "DocAuditResultName", "DocumentName"); } res.ResultData = CommonUtil.ConvertToXml <View_dtRentalHistoryDigest>(RentalHist, "Common\\CMS150", CommonUtil.GRID_EMPTY_TYPE.SEARCH); return(Json(res)); } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } }
/// <summary> /// Update rental secuirty basic /// </summary> /// <param name="dt"></param> /// <returns></returns> private bool CTS190_UpdateRentalSecurityBasic(List <tbt_ContractDocument> dt) { try { if (dt == null || dt.Count == 0) { return(false); } IRentralContractHandler handlerRC = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; // Get RSB List <tbt_RentalSecurityBasic> dtRSB = handlerRC.GetTbt_RentalSecurityBasic(dt[0].ContractCode, dt[0].OCC); if (dtRSB.Count == 0) { return(false); } if (dt[0].DocAuditResult == DocAuditResult.C_DOC_AUDIT_RESULT_OTHER) { dtRSB[0].DocAuditResult = null; dtRSB[0].DocumentCode = null; } else { dtRSB[0].DocAuditResult = dt[0].DocAuditResult; dtRSB[0].DocumentCode = dt[0].DocumentCode; } handlerRC.UpdateTbt_RentalSecurityBasic(dtRSB[0]); return(true); } catch (Exception) { throw; } }
/// <summary> /// Update data in case new/add sale and will insert new occurrence in case other installation type. /// </summary> /// <param name="doComplete"></param> public void CompleteInstallation(doCompleteInstallationData doComplete) { try { //Validation ServiceTypeCode and CompleteInstallationProcessFlag ApplicationErrorException.CheckMandatoryField <doCompleteInstallationData, doCompleteContractCompleteInstallation>(doComplete); //2. Check service type code and complete process flag if (doComplete.ServiceTypeCode == ServiceType.C_SERVICE_TYPE_RENTAL) { if (doComplete.CompleteInstallationProcessFlag == FlagType.C_FLAG_ON) { IRentralContractHandler hand = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; hand.CompleteInstallation(doComplete); } else if (doComplete.CompleteInstallationProcessFlag == FlagType.C_FLAG_OFF) { //do nothing } } else if (doComplete.ServiceTypeCode == ServiceType.C_SERVICE_TYPE_SALE) { ISaleContractHandler hand = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; if (doComplete.CompleteInstallationProcessFlag == FlagType.C_FLAG_ON) { hand.CompleteInstallation(doComplete); } else if (doComplete.CompleteInstallationProcessFlag == FlagType.C_FLAG_OFF) { hand.CancelInstallation(doComplete); } } } catch (Exception) { throw; } }
///<summary> ///Purpose : Generate rental contract counter ///Parameters: strContractCode = N0000000038 ///Expected : Return counter that is 2. ///</summary> public string Case3() { IRentralContractHandler target = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; string strContractCode = "N0000000038"; string expected = "2"; string actual; try { int result = target.GenerateContractCounter(strContractCode); actual = result.ToString(); } catch (ApplicationErrorException ex) { actual = ex.ErrorResult.Message.Code; } catch (Exception ex) { actual = ex.StackTrace; } return(string.Format(RESULT_FORMAT, 3, expected, actual, CompareResult_String(expected, actual))); }
///<summary> ///Purpose : Generate rental contract OCC ///Parameters: strContractCode = N0000000017 /// bImplementFlag = FALSE ///Expected : Return OCC that is 0002. ///</summary> public string Case2() { IRentralContractHandler target = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; string strContractCode = "N0000000017"; bool bImplementFlag = false; string expected = "0002"; string actual; try { actual = target.GenerateContractOCC(strContractCode, bImplementFlag); } catch (ApplicationErrorException ex) { actual = ex.ErrorResult.Message.Code; } catch (Exception ex) { actual = ex.StackTrace; } return(string.Format(RESULT_FORMAT, 2, expected, actual, CompareResult_String(expected, actual))); }
/// <summary> /// Import quotation data /// </summary> /// <param name="ScreenID"></param> /// <param name="DataList"></param> /// <returns></returns> public ActionResult QUS050_ImportData(string ScreenID, List <string> DataList) { ObjectResultData res = new ObjectResultData(); try { dsImportData importData = new dsImportData() { dtTbt_QuotationCustomer = new List <tbt_QuotationCustomer>(), dtTbt_QuotationSite = new List <tbt_QuotationSite>(), dtTbt_QuotationTarget = new List <tbt_QuotationTarget>(), dtTbt_QuotationBasic = new List <tbt_QuotationBasic>(), dtTbt_QuotationOperationType = new List <tbt_QuotationOperationType>(), dtTbt_QuotationInstrumentDetails = new List <tbt_QuotationInstrumentDetails>(), dtTbt_QuotationFacilityDetails = new List <tbt_QuotationFacilityDetails>(), dtTbt_QuotationBeatGuardDetails = new List <tbt_QuotationBeatGuardDetails>(), dtTbt_QuotationSentryGuardDetails = new List <tbt_QuotationSentryGuardDetails>(), dtTbt_QuotationMaintenanceLinkage = new List <tbt_QuotationMaintenanceLinkage>() }; #region Mapping Data List <object> impLst = new List <object>() { importData.dtTbt_QuotationCustomer, importData.dtTbt_QuotationSite, importData.dtTbt_QuotationTarget, importData.dtTbt_QuotationBasic, importData.dtTbt_QuotationOperationType, importData.dtTbt_QuotationInstrumentDetails, importData.dtTbt_QuotationFacilityDetails, importData.dtTbt_QuotationBeatGuardDetails, importData.dtTbt_QuotationSentryGuardDetails, importData.dtTbt_QuotationMaintenanceLinkage }; string filePath = CommonUtil.WebPath + SECOM_AJIS.Common.Util.ConstantValue.CommonValue.IMPORT_TEMPLATE_FILE; XmlDocument doc = new XmlDocument(); doc.Load(filePath); XmlNodeList nodes = doc.SelectNodes("tables/table"); bool isError = false; List <string> setFailList = new List <string>(); int lineIdx = 0; int nodeIdx = 0; for (; nodeIdx < nodes.Count; nodeIdx++) { if (lineIdx < DataList.Count) { /* --- Check Table name --- */ string[] tbName = DataList[lineIdx].Split(",".ToCharArray()); if (nodes[nodeIdx].Attributes["name"].Value != tbName[0] || lineIdx + 1 >= DataList.Count) { isError = true; break; } lineIdx += 1; /* --- Check Column --- */ bool isSameCol = false; string[] cols = DataList[lineIdx].Split(",".ToCharArray()); if (cols != null) { if (nodes[nodeIdx].ChildNodes.Count <= cols.Length) { int colIdx = 0; for (; colIdx < nodes[nodeIdx].ChildNodes.Count; colIdx++) { string colName = cols[colIdx] == null ? "" : cols[colIdx]; string cColName = nodes[nodeIdx].ChildNodes[colIdx].Attributes["name"].Value; if (cColName == null) { cColName = ""; } colName = colName.Trim().ToUpper(); cColName = cColName.Trim().ToUpper(); if (colName != cColName) { break; } } bool isColOver = false; if (colIdx < cols.Length) { for (int nColIdx = colIdx; nColIdx < cols.Length; nColIdx++) { if (CommonUtil.IsNullOrEmpty(cols[nColIdx]) == false) { isColOver = true; break; } } } if (isColOver == false && colIdx == nodes[nodeIdx].ChildNodes.Count) { isSameCol = true; } } } if (isSameCol == false) { isError = true; break; } /* --- Get next Table --- */ string nextTable = null; if (nodeIdx + 1 < nodes.Count) { nextTable = nodes[nodeIdx + 1].Attributes["name"].Value; } /* --- Loop fill data to each table --- */ lineIdx += 1; while (lineIdx < DataList.Count) { tbName = DataList[lineIdx].Split(",".ToCharArray()); if (nextTable == tbName[0]) { break; } bool isEmpty = true; foreach (string d in tbName) { if (CommonUtil.IsNullOrEmpty(d) == false) { isEmpty = false; break; } } if (isEmpty) { isError = true; break; } string data = DataList[lineIdx]; string[] lst = new string[nodes[nodeIdx].ChildNodes.Count]; for (int dIdx = 0; dIdx < nodes[nodeIdx].ChildNodes.Count; dIdx++) { if (data.Length <= 0 && dIdx < nodes[nodeIdx].ChildNodes.Count - 1) { isError = true; break; } int tIdx = 0; int cmIdx = data.IndexOf(","); int ccIdx = data.IndexOf("\""); string val = string.Empty; if (cmIdx < 0) { val = data; } else if (cmIdx < ccIdx || ccIdx < 0) { val = data.Substring(tIdx, cmIdx); tIdx += cmIdx + 1; } else { int cceIdx = data.IndexOf("\"", ccIdx + 1); if (cceIdx <= 0) { val = data; } else { val = data.Substring(tIdx + 1, cceIdx - 1); tIdx += cceIdx + 2; } } lst[dIdx] = val; data = data.Substring(tIdx); } lineIdx += 1; if (isError) { break; } else { if (nodeIdx < impLst.Count) { object obj = impLst[nodeIdx]; /* --- Create Object --- */ object objDo = Activator.CreateInstance(obj.GetType().GetGenericArguments()[0]); MethodInfo mf = obj.GetType().GetMethod("Add"); if (mf != null) { mf.Invoke(obj, new object[] { objDo }); } for (int colIdx = 0; colIdx < nodes[nodeIdx].ChildNodes.Count; colIdx++) { bool canSetValue = CommonUtil.SetObjectValue(objDo, nodes[nodeIdx].ChildNodes[colIdx].Attributes["name"].Value, lst[colIdx] != string.Empty ? lst[colIdx] : null); if (canSetValue == false) { string v = nodes[nodeIdx].ChildNodes[colIdx].Attributes["name"].Value; if (setFailList.IndexOf(v) < 0) { setFailList.Add(v); } } } } } } } if (isError) { break; } } if (nodeIdx < nodes.Count) { res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2020); return(Json(res)); } if (setFailList.Count > 0) { string txt = CommonUtil.TextList(setFailList.ToArray()); res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2084, new string[] { txt }); return(Json(res)); } #endregion #region Check Mandatory ValidatorUtil validator = new ValidatorUtil(); List <object> objLst = new List <object>(); if (ScreenID == SECOM_AJIS.Common.Util.ConstantValue.ScreenID.C_SCREEN_ID_QTN_TARGET) { if (importData.dtTbt_QuotationCustomer.Count == 0) { validator.AddErrorMessage( MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, "CustomerList", "CustPartTypeCode, CustCode (or CustNameEN, CustNameLC, CustTypeCode, RegionCode)"); } else { int cidx = 1; foreach (tbt_QuotationCustomer cust in importData.dtTbt_QuotationCustomer) { if (CommonUtil.IsNullOrEmpty(cust.CustPartTypeCode)) { validator.AddErrorMessage( MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, "CustPartTypeCode" + cidx, "CustPartTypeCode" + cidx); } if (CommonUtil.IsNullOrEmpty(cust.CustCode)) { List <string> eLst = new List <string>(); if (CommonUtil.IsNullOrEmpty(cust.CustNameEN)) { eLst.Add("CustNameEN" + cidx); } if (CommonUtil.IsNullOrEmpty(cust.CustNameLC)) { eLst.Add("CustNameLC" + cidx); } if (CommonUtil.IsNullOrEmpty(cust.CustTypeCode)) { eLst.Add("CustTypeCode" + cidx); } if (CommonUtil.IsNullOrEmpty(cust.RegionCode)) { eLst.Add("RegionCode" + cidx); } if (eLst.Count == 4) { validator.AddErrorMessage( MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, "Customer" + cidx, string.Format("CustCode{0} (or CustNameEN{0}, CustNameLC{0}, CustTypeCode{0}, RegionCode{0})", cidx)); } else { foreach (string s in eLst) { validator.AddErrorMessage( MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, s, s); } } } cidx++; } } tbt_QuotationSite site = new tbt_QuotationSite(); if (importData.dtTbt_QuotationSite.Count > 0) { site = importData.dtTbt_QuotationSite[0]; } if (CommonUtil.IsNullOrEmpty(site.SiteNo)) { List <string> eLst = new List <string>(); if (CommonUtil.IsNullOrEmpty(site.SiteNameEN)) { eLst.Add("SiteNameEN"); } if (CommonUtil.IsNullOrEmpty(site.SiteNameLC)) { eLst.Add("SiteNameLC"); } if (CommonUtil.IsNullOrEmpty(site.AddressEN)) { eLst.Add("AddressEN"); } if (CommonUtil.IsNullOrEmpty(site.AddressLC)) { eLst.Add("AddressLC"); } //if (CommonUtil.IsNullOrEmpty(site.RoadEN)) // eLst.Add("RoadEN"); //if (CommonUtil.IsNullOrEmpty(site.RoadLC)) // eLst.Add("RoadLC"); if (CommonUtil.IsNullOrEmpty(site.SubDistrictEN)) { eLst.Add("SubDistrictEN"); } if (CommonUtil.IsNullOrEmpty(site.SubDistrictLC)) { eLst.Add("SubDistrictLC"); } if (CommonUtil.IsNullOrEmpty(site.BuildingUsageCode)) { eLst.Add("BuildingUsageCode"); } if (CommonUtil.IsNullOrEmpty(site.ProvinceCode)) { eLst.Add("ProvinceCode"); } if (CommonUtil.IsNullOrEmpty(site.ProvinceCode)) { eLst.Add("DistrictCode"); } if (eLst.Count == 11) { validator.AddErrorMessage( MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, "Site", "SiteNo (or SiteNameEN, SiteNameLC, AddressEN, AddressLC, SubDistrictEN, SubDistrictLC, BuildingUsageCode, ProvinceCode, DistrictCode)"); } else { foreach (string s in eLst) { validator.AddErrorMessage( MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, s, s); } } } if (importData.dtTbt_QuotationTarget.Count == 0) { importData.dtTbt_QuotationTarget.Add(new tbt_QuotationTarget()); } foreach (tbt_QuotationTarget target in importData.dtTbt_QuotationTarget) { objLst.Add(CommonUtil.CloneObject <tbt_QuotationTarget, QUS050_tbt_QuotationTarget>(target)); } } else { if (importData.dtTbt_QuotationTarget.Count == 0) { importData.dtTbt_QuotationTarget.Add(new tbt_QuotationTarget()); } foreach (tbt_QuotationTarget target in importData.dtTbt_QuotationTarget) { objLst.Add(CommonUtil.CloneObject <tbt_QuotationTarget, QUS050_tbt_QuotationTarget_D>(target)); } if (importData.dtTbt_QuotationBasic.Count == 0) { importData.dtTbt_QuotationBasic.Add(new tbt_QuotationBasic()); } foreach (tbt_QuotationBasic basic in importData.dtTbt_QuotationBasic) { /* --- Update QuotationTargetCode --- */ /* ---------------------------------- */ basic.QuotationTargetCode = importData.dtTbt_QuotationTarget[0].QuotationTargetCode; /* ---------------------------------- */ objLst.Add(CommonUtil.CloneObject <tbt_QuotationBasic, QUS050_tbt_QuotationBasic>(basic)); } } ValidatorUtil.BuildErrorMessage(res, validator, objLst.ToArray()); if (res.IsError) { return(Json(res)); } #endregion #region Business Check if (ScreenID == SECOM_AJIS.Common.Util.ConstantValue.ScreenID.C_SCREEN_ID_QTN_TARGET) { bool isFoundTarget = false; bool isFoundReal = false; if (importData.dtTbt_QuotationCustomer.Count > 0 && importData.dtTbt_QuotationCustomer.Count <= 2) { foreach (tbt_QuotationCustomer cust in importData.dtTbt_QuotationCustomer) { if (cust.CustPartTypeCode != SECOM_AJIS.Common.Util.ConstantValue.CustPartType.C_CUST_PART_TYPE_CONTRACT_TARGET && cust.CustPartTypeCode != SECOM_AJIS.Common.Util.ConstantValue.CustPartType.C_CUST_PART_TYPE_REAL_CUST) { res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2025); return(Json(res)); } if (cust.CustPartTypeCode == SECOM_AJIS.Common.Util.ConstantValue.CustPartType.C_CUST_PART_TYPE_CONTRACT_TARGET) { if (isFoundTarget == true) { res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2093); return(Json(res)); } else { isFoundTarget = true; } } else if (cust.CustPartTypeCode == SECOM_AJIS.Common.Util.ConstantValue.CustPartType.C_CUST_PART_TYPE_REAL_CUST) { if (isFoundReal == true) { res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2093); return(Json(res)); } else { isFoundReal = true; } } QUS050_tbt_QuotationCustomer_BC custBC = CommonUtil.CloneObject <tbt_QuotationCustomer, QUS050_tbt_QuotationCustomer_BC>(cust); ObjectResultData r = ValidatorUtil.BuildErrorMessage(custBC); if (r != null) { if (r.IsError) { res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2021); return(Json(res)); } } } if (isFoundTarget == false) { res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2024); return(Json(res)); } } else { res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2026); return(Json(res)); } if (importData.dtTbt_QuotationSite != null) { if (importData.dtTbt_QuotationSite.Count > 0) { QUS050_tbt_QuotationSite_BC siteBC = CommonUtil.CloneObject <tbt_QuotationSite, QUS050_tbt_QuotationSite_BC>(importData.dtTbt_QuotationSite[0]); ValidatorUtil.BuildErrorMessage(res, new object[] { siteBC }); if (res.IsError) { return(Json(res)); } } } } #endregion #region Data Authority Check string QuotationOfficeCode = null; if (ScreenID == SECOM_AJIS.Common.Util.ConstantValue.ScreenID.C_SCREEN_ID_QTN_TARGET) { if (importData.dtTbt_QuotationTarget != null) { if (importData.dtTbt_QuotationTarget.Count > 0) { QuotationOfficeCode = importData.dtTbt_QuotationTarget[0].QuotationOfficeCode; } } } else { IQuotationHandler handler = ServiceContainer.GetService <IQuotationHandler>() as IQuotationHandler; if (importData.dtTbt_QuotationBasic.Count > 0) { CommonUtil cmm = new CommonUtil(); string qt = cmm.ConvertQuotationTargetCode(importData.dtTbt_QuotationBasic[0].QuotationTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG); doGetQuotationDataCondition cond = new doGetQuotationDataCondition() { QuotationTargetCode = qt }; List <tbt_QuotationTarget> lst = handler.GetTbt_QuotationTarget(cond); if (lst.Count <= 0) { ISaleContractHandler shandler = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; List <tbt_SaleBasic> sLst = shandler.GetTbt_SaleBasic(qt, null, true); if (sLst.Count <= 0) { IRentralContractHandler rhandler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; List <tbt_RentalContractBasic> rLst = rhandler.GetTbt_RentalContractBasic(qt, null); if (rLst.Count <= 0) { res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2003, new string[] { importData.dtTbt_QuotationBasic[0].QuotationTargetCode }); return(Json(res)); } else { if (rLst[0].ContractStatus == ContractStatus.C_CONTRACT_STATUS_BEF_START) { QuotationOfficeCode = rLst[0].ContractOfficeCode; } else { QuotationOfficeCode = rLst[0].OperationOfficeCode; } } } else { if (sLst[0].ContractStatus == ContractStatus.C_CONTRACT_STATUS_BEF_START) { QuotationOfficeCode = sLst[0].ContractOfficeCode; } else { QuotationOfficeCode = sLst[0].OperationOfficeCode; } } } else { QuotationOfficeCode = lst[0].OperationOfficeCode; } } } if (QuotationOfficeCode != null && CommonUtil.dsTransData.dtOfficeData != null) { bool isFound = false; foreach (OfficeDataDo office in CommonUtil.dsTransData.dtOfficeData) { if (office.OfficeCode == QuotationOfficeCode) { isFound = true; break; } } if (isFound == false) { res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2023); return(Json(res)); } } #endregion QUS050_ScreenParameter param = GetScreenObject <QUS050_ScreenParameter>(); if (param != null) { param.ImportData = importData; } res.ResultData = new object[] { importData, GetCurrentKey() }; } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }
/// <summary> /// Check permission for access screen CMS190 /// </summary> /// <param name="param"></param> /// <returns></returns> public ActionResult CMS190_Authority(CMS190_ScreenParameter param) // IN parameter: string strContractCode, string strServiceTypeCode { ObjectResultData res = new ObjectResultData(); // Check permission if (!CheckUserPermission(ScreenID.C_SCREEN_ID_VIEW_CONTRACT_DIGEST, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } if (String.IsNullOrEmpty(param.strContractCode)) { //param.strContractCode = CommonUtil.dsTransData.dtCommonSearch.ContractCode; if (param.CommonSearch != null) { if (CommonUtil.IsNullOrEmpty(param.CommonSearch.ContractCode) == false) { param.strContractCode = param.CommonSearch.ContractCode; } } } // Check parameter if (CommonUtil.IsNullOrEmpty(param.strContractCode) == true) { //res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0040); res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0147); return(Json(res)); } // Check exist data try { CommonUtil c = new CommonUtil(); string ContractCode = c.ConvertContractCode(param.strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); // Rental IRentralContractHandler handlerR = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; // Sale ISaleContractHandler handlerS = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; //List<dtTbt_RentalContractBasicForView> dtRentalContract = new List<dtTbt_RentalContractBasicForView>(); //List<dtTbt_SaleBasicForView> dtSaleContract = new List<dtTbt_SaleBasicForView>(); List <tbt_RentalContractBasic> dtRentalContract = new List <tbt_RentalContractBasic>(); List <tbt_SaleBasic> dtSaleContract = new List <tbt_SaleBasic>(); // get data for check exist if (param.strServiceTypeCode == ServiceType.C_SERVICE_TYPE_RENTAL) { dtRentalContract = handlerR.GetTbt_RentalContractBasic(ContractCode, null); } else if (param.strServiceTypeCode == ServiceType.C_SERVICE_TYPE_SALE) { dtSaleContract = handlerS.GetTbt_SaleBasic(ContractCode, null, true); } else { dtRentalContract = handlerR.GetTbt_RentalContractBasic(ContractCode, null); if (dtRentalContract.Count == 0) { dtSaleContract = handlerS.GetTbt_SaleBasic(ContractCode, null, true); param.strServiceTypeCode = ServiceType.C_SERVICE_TYPE_SALE; } else { param.strServiceTypeCode = ServiceType.C_SERVICE_TYPE_RENTAL; } } CommonUtil comUtil = new CommonUtil(); if (dtRentalContract.Count > 0) { param.strContractCode = comUtil.ConvertContractCode(dtRentalContract[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } else if (dtSaleContract.Count > 0) { param.strContractCode = comUtil.ConvertContractCode(dtSaleContract[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } // parameter param.ContractCode = param.strContractCode; param.ServiceTypeCode = param.strServiceTypeCode; if (dtRentalContract.Count == 0 && dtSaleContract.Count == 0) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001); return(Json(res)); } //CommonUtil.dsTransData.dtCommonSearch.ContractCode = param.strContractCode; //CommonUtil.dsTransData.dtCommonSearch.ProjectCode = null; param.CommonSearch = new ScreenParameter.CommonSearchDo() { ContractCode = param.strContractCode }; } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } return(InitialScreenEnvironment <CMS190_ScreenParameter>("CMS190", param, res)); }
/// <summary> /// Add received contract document /// </summary> /// <param name="cond"></param> /// <returns></returns> public ActionResult CTS190_AddReceivedContractDoc(CTS190_ScreenParameter cond) { ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; CommonUtil cm = new CommonUtil(); IMasterHandler handlerMaster = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler; List <dtDocumentTemplateByDocumentCode> listDocTemplate = new List <dtDocumentTemplateByDocumentCode>(); string contracCode; string quotationTargetCode; try { ICommonContractHandler handler = ServiceContainer.GetService <ICommonContractHandler>() as ICommonContractHandler; List <dtContractDocHeader> list = new List <dtContractDocHeader>(); contracCode = cm.ConvertContractCode(cond.ContractCode_QuotationTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG); quotationTargetCode = cm.ConvertQuotationTargetCode(cond.ContractCode_QuotationTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG); // Check required field. if (ModelState.IsValid == false) { ValidatorUtil.BuildErrorMessage(res, this); if (res.IsError) { return(Json(res)); } } // Business check 1 if (cond.OCC_Alphabet == null) { cond.OCC_Alphabet = string.Empty; } if (!(cond.OCC_Alphabet.ToUpper() == ParticularOCC.C_PARTICULAR_OCC_PO.ToUpper())) //|| cond.OCC_Alphabet.ToUpper() == ParticularOCC.C_PARTICULAR_OCC_START_CONFIRM_LETTER.ToUpper())) //Comment by Jutarat A. on 22042013 { //Then Check "Contract document OCC" field // ---> Then show message at warning section (MSG3234: Please specify contract document occurrence) if (CommonUtil.IsNullOrEmpty(cond.ContractDocOCC) == true) { res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3234, null, new string[] { "ContractDocOCC" }); return(Json(res)); } } // Business check 2 if (CommonUtil.IsNullOrEmpty(cond.ContractDocOCC) == true) // Not fill ContractDocOCC { if (!(cond.OCC_Alphabet.ToUpper() == ParticularOCC.C_PARTICULAR_OCC_PO.ToUpper())) //|| cond.OCC_Alphabet.ToUpper() == ParticularOCC.C_PARTICULAR_OCC_START_CONFIRM_LETTER.ToUpper())) //Comment by Jutarat A. on 22042013 { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001); return(Json(res)); } //#region Check billing basic data //if (cond.OCC_Alphabet.ToUpper().CompareTo(ParticularOCC.C_PARTICULAR_OCC_MIN_BILLING_MEMO.ToUpper()) >= 0 // && cond.OCC_Alphabet.ToUpper().CompareTo(ParticularOCC.C_PARTICULAR_OCC_MAX_BILLING_MEMO.ToUpper()) <= 0) //{ // string occ = cond.OCC_Alphabet.Trim(); // if (occ.Length > 2) // occ = occ.Substring(occ.Length - 2); // IBillingHandler bhandler = ServiceContainer.GetService<IBillingHandler>() as IBillingHandler; // doTbt_BillingBasic bs = bhandler.GetBillingBasicData(contracCode.Trim(), occ, null, null, null); // if (bs == null) // { // res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3242); // return Json(res); // } //} //#endregion list = handler.GetContractDocHeader(contracCode.Trim(), quotationTargetCode.Trim(), cond.OCC_Alphabet.Trim(), cond.ContractDocOCC); if (list.Count == 0) // not found ! (ContractDoc Header) { //Comment by Jutarat A. on 22042013 //if (cond.OCC_Alphabet.ToUpper() == ParticularOCC.C_PARTICULAR_OCC_START_CONFIRM_LETTER.ToUpper()) //{ // res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001); // return Json(res); //} //End Comment IRentralContractHandler handlerRental = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; List <tbt_RentalContractBasic> rentalList = handlerRental.GetTbt_RentalContractBasic(contracCode, null); if (rentalList.Count == 0) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001); return(Json(res)); } else { // Create dt !! dtContractDocHeader dt = new dtContractDocHeader(); dt.ContractCode = contracCode.ToUpper(); dt.OCC = cond.OCC_Alphabet.Trim().ToUpper(); if (cond.OCC_Alphabet.Trim().ToUpper() == ParticularOCC.C_PARTICULAR_OCC_PO.ToUpper()) { dt.DocumentCode = DocumentCode.C_DOCUMENT_CODE_PO; } //else //{ // dt.DocumentCode = DocumentCode.C_DOCUMENT_CODE_CHANGE_PAYMENT_MEMO; //} listDocTemplate = handlerMaster.GetDocumentTemplateByDocumentCode(dt.DocumentCode); if (listDocTemplate.Count > 0) { dt.DocumentNameEN = listDocTemplate[0].DocumentNameEN; dt.DocumentNameJP = listDocTemplate[0].DocumentNameJP; dt.DocumentNameLC = listDocTemplate[0].DocumentNameLC; } dt.ContractOfficeCode = rentalList[0].ContractOfficeCode; dt.OperationOfficeCode = rentalList[0].OperationOfficeCode; dt.DocStatus = ContractDocStatus.C_CONTRACT_DOC_STATUS_COLLECTED; dt.DocAuditResult = cond.DocAuditResult; dt.CollectDocDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; // extra field dt.ContractCode_QuotationTargetCode = contracCode.ToUpper(); dt.OCC_Alphabet = cond.OCC_Alphabet.Trim().ToUpper(); dt.IsCreateFlag = true; //*** dt.IsContractFlag = true; //*** list.Clear(); list.Add(dt); } } else // Found !! (ContractDoc Header) { // Update dt !! list[0].IsCreateFlag = false; // is updated list[0].DocStatus = ContractDocStatus.C_CONTRACT_DOC_STATUS_COLLECTED; list[0].DocAuditResult = cond.DocAuditResult; list[0].CollectDocDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; } } else // ContractDocOCC is filled { list = handler.GetContractDocHeader(contracCode.Trim(), quotationTargetCode.Trim(), cond.OCC_Alphabet.Trim(), cond.ContractDocOCC.Trim()); if (list.Count > 0) { // get Document templete for get "ReportFlag" listDocTemplate = handlerMaster.GetDocumentTemplateByDocumentCode(list[0].DocumentCode); if (listDocTemplate.Count == 0) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0111, new string[] { "Document Template is not found." }, null); return(Json(res)); } // Business check if (CommonUtil.IsNullOrEmpty(list[0].ContractCode) == true) { res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3160); return(Json(res)); } // Business check if (listDocTemplate[0].ReportFlag == true) { if (list[0].DocStatus == ContractDocStatus.C_CONTRACT_DOC_STATUS_NOT_ISSUED || list[0].IssuedDate.HasValue == false) { res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3179); return(Json(res)); } } else { if (list[0].DocStatus == ContractDocStatus.C_CONTRACT_DOC_STATUS_NOT_ISSUED) { res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3179); return(Json(res)); } } // Update dt !! list[0].IsCreateFlag = false; // is updated list[0].DocStatus = ContractDocStatus.C_CONTRACT_DOC_STATUS_COLLECTED; list[0].DocAuditResult = cond.DocAuditResult; list[0].CollectDocDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; } } if (list.Count > 0) { // CheckDataAuthority if (CTS190_CheckDataAuthority(list[0]) == false) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0063); return(Json(res)); } } else { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001); return(Json(res)); } CommonUtil.MappingObjectLanguage <dtContractDocHeader>(list); MiscTypeMappingList miscList = new MiscTypeMappingList(); miscList.AddMiscType(list.ToArray()); ICommonHandler comHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; comHandler.MiscTypeMappingList(miscList); if (list.Count > 0) { if (list[0].IsContractFlag.Value) { list[0].ContractCode_QuotationTargetCode = cm.ConvertContractCode(list[0].ContractCode_QuotationTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } else { list[0].ContractCode_QuotationTargetCode = cm.ConvertQuotationTargetCode(list[0].ContractCode_QuotationTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } string myContractCode = cm.ConvertContractCode(list[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); string myOCC = list[0].OCC; string myQuotationTargetCode = cm.ConvertQuotationTargetCode(list[0].QuotationTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT); string myAlphabet = list[0].Alphabet; string myDocOCC = list[0].ContractDocOCC; if (cond.OCC_Alphabet.ToUpper() == ParticularOCC.C_PARTICULAR_OCC_PO.ToUpper()) { //|| cond.OCC_Alphabet.ToUpper() == ParticularOCC.C_PARTICULAR_OCC_START_CONFIRM_LETTER.ToUpper()) //Comment by Jutarat A. on 22042013 myDocOCC = ""; } // Update my_checked_id_by_ct , my_checked_id_by_quo , my_checked_id list[0].my_checked_id_by_ct = string.Format("{0}-{1}-{2}", myContractCode, myOCC, myDocOCC).ToUpper(); list[0].my_checked_id_by_quo = string.Format("{0}-{1}-{2}", myQuotationTargetCode, myAlphabet, myDocOCC).ToUpper(); list[0].my_checked_id = string.Format("{0}-{1}", list[0].my_checked_id_by_ct, list[0].my_checked_id_by_quo).ToUpper(); res.ResultData = list[0]; } return(Json(res)); } catch (Exception ex) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; 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)); }
public ActionResult CMS200() { string strContractCode = ""; string strServiceTypeCode = ""; try { CMS200_ScreenParameter param = GetScreenObject <CMS200_ScreenParameter>(); strContractCode = param.ContractCode; strServiceTypeCode = param.ServiceTypeCode; } catch { } // Keep service type code ViewBag.ServiceTypeCode = strServiceTypeCode; // Keep contract code (short) ViewBag._ContractCode = strContractCode; ViewBag._OCC = string.Empty; ViewBag._ContractTargetCode = string.Empty; ViewBag._RealCustomerCode = string.Empty; ViewBag._PurchaserCustCode = string.Empty; ViewBag._SiteCode = string.Empty; CommonUtil c = new CommonUtil(); strContractCode = c.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); try { IRentralContractHandler handlerRC = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; ISaleContractHandler handlerSC = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; if (strServiceTypeCode == ServiceType.C_SERVICE_TYPE_RENTAL) { List <dtTbt_RentalContractBasicForView> listRC = handlerRC.GetTbt_RentalContractBasicForView(strContractCode); if (listRC.Count > 0) { // convert code to short format listRC[0].ContractCode = c.ConvertContractCode(listRC[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); listRC[0].ContractTargetCustCode = c.ConvertCustCode(listRC[0].ContractTargetCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT); listRC[0].RealCustomerCustCode = c.ConvertCustCode(listRC[0].RealCustomerCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT); listRC[0].SiteCode = c.ConvertSiteCode(listRC[0].SiteCode, CommonUtil.CONVERT_TYPE.TO_SHORT); // gorbal javascript variable ViewBag._OCC = listRC[0].LastOCC; ViewBag._ContractTargetCode = listRC[0].ContractTargetCustCode; ViewBag._RealCustomerCode = listRC[0].RealCustomerCustCode; ViewBag._SiteCode = listRC[0].SiteCode; ViewBag.txtContractCode = listRC[0].ContractCode; ViewBag.txtUserCode = listRC[0].UserCode; ViewBag.lnkCustomerCodeC = listRC[0].ContractTargetCustCode; ViewBag.lnkCustomerCodeR = listRC[0].RealCustomerCustCode; ViewBag.lnkSiteCode = listRC[0].SiteCode; ViewBag.txtContractNameEng = listRC[0].CustFullNameEN_Cust; ViewBag.txtContractAddrEng = listRC[0].AddressFullEN_Cust; ViewBag.txtSiteNameEng = listRC[0].SiteNameEN_Site; ViewBag.txtSiteAddrEng = listRC[0].AddressFullEN_Site; ViewBag.txtContractNameLocal = listRC[0].CustFullNameLC_Cust; ViewBag.txtContractAddrLocal = listRC[0].AddressFullLC_Cust; ViewBag.txtSiteNameLocal = listRC[0].SiteNameLC_Site; ViewBag.txtSiteAddrLocal = listRC[0].AddressFullLC_Site; //ViewBag.txtContactPoint = listRC[0].ContactPoint ; ViewBag.txtContactPoint = CommonUtil.IsNullOrEmpty(listRC[0].ContactPoint) == true ? "-" : listRC[0].ContactPoint; ViewBag.txtRentalAttachImportanceFlag = listRC[0].SpecialCareFlag; ViewBag.ProductTypeCode = listRC[0].ProductTypeCode; } } else if (strServiceTypeCode == ServiceType.C_SERVICE_TYPE_SALE) { List <dtTbt_SaleBasicForView> listSC = handlerSC.GetTbt_SaleBasicForView(strContractCode, null, true); if (listSC.Count > 0) // SCB : Sale Contract Basic { // convert code to short format listSC[0].ContractCode = c.ConvertContractCode(listSC[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); listSC[0].CustCode_PurCust = c.ConvertCustCode(listSC[0].CustCode_PurCust, CommonUtil.CONVERT_TYPE.TO_SHORT); listSC[0].CustCode_RealCust = c.ConvertCustCode(listSC[0].CustCode_RealCust, CommonUtil.CONVERT_TYPE.TO_SHORT); listSC[0].SiteCode = c.ConvertSiteCode(listSC[0].SiteCode, CommonUtil.CONVERT_TYPE.TO_SHORT); // gorbal javascript variable ViewBag._OCC = listSC[0].OCC; ViewBag._PurchaserCustCode = listSC[0].CustCode_PurCust; ViewBag._RealCustomerCode = listSC[0].CustCode_RealCust; ViewBag._SiteCode = listSC[0].SiteCode; ViewBag.txtSCBContractCode = listSC[0].ContractCode; ViewBag.lnkSCBPurchaserC = listSC[0].CustCode_PurCust; ViewBag.lnkSCBCustomerCodeR = listSC[0].CustCode_RealCust; ViewBag.lnkSCBSiteCode = listSC[0].SiteCode; ViewBag.txtSCBPurchaserNameEng = listSC[0].PurCust_CustFullNameEN; ViewBag.txtSCBPurchaserAddrEng = listSC[0].AddressFullEN_PurCust; ViewBag.txtSCBSiteNameEng = listSC[0].site_SiteNameEN; ViewBag.txtSCBSiteAddrEng = listSC[0].AddressFullEN_site; ViewBag.txtSCBPurchaserNameLocal = listSC[0].PurCust_CustFullNameLC; ViewBag.txtSCBPurchaserAddrLocal = listSC[0].AddressFullLC_PurCust; ViewBag.txtSCBSiteNameLocal = listSC[0].site_SiteNameLC; ViewBag.txtSCBSiteAddrLocal = listSC[0].AddressFullLC_site; //ViewBag.txtSCBContactPoint = listSC[0].ContactPoint ; ViewBag.txtSCBContactPoint = CommonUtil.IsNullOrEmpty(listSC[0].ContactPoint) == true ? "-" : listSC[0].ContactPoint; ViewBag.txtSaleAttachImportanceFlag = listSC[0].SpecialCareFlag; ViewBag.ProductTypeCode = listSC[0].ProductTypeCode; } } return(View()); } catch (Exception ex) { ObjectResultData res = new ObjectResultData(); res.AddErrorMessage(ex); return(Json(res)); } }
public ActionResult CTP060_UpdateEmailContentOfNotifyEmail() { ObjectResultData res = new ObjectResultData(); IContractHandler conHandler = ServiceContainer.GetService <IContractHandler>() as IContractHandler; IRentralContractHandler rentalConHandler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; IMasterHandler masterHandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler; IEmployeeMasterHandler empMasterHandler = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler; IBillingMasterHandler billingmasterhandler = ServiceContainer.GetService <IBillingMasterHandler>() as IBillingMasterHandler; IOfficeMasterHandler officehandler = ServiceContainer.GetService <IOfficeMasterHandler>() as IOfficeMasterHandler; IBillingHandler billinghandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler; List <tbm_Customer> dtCustomer; List <doGetTbm_Site> dtSite; List <tbm_Employee> dtEmployee; decimal?contractFeeBeforeChange; decimal?ChangeContractFee; try { CommonUtil comUtil = new CommonUtil(); doNotifyChangeFeeContract doNotifyEmail = new doNotifyChangeFeeContract(); List <tbt_ContractEmail> updateContractEmailList = new List <tbt_ContractEmail>(); using (TransactionScope scope = new TransactionScope()) { List <tbt_ContractEmail> contractEmailList = conHandler.GetUnsentNotifyEmail(); foreach (tbt_ContractEmail data in contractEmailList) { List <tbt_BillingBasic> doBillingBasic = billinghandler.GetTbt_BillingBasic(data.ContractCode, "01"); List <tbt_BillingTarget> doBillingTarget = billinghandler.GetTbt_BillingTarget(doBillingBasic[0].BillingTargetCode, null, null); dsRentalContractData dsRentalContract = rentalConHandler.GetEntireContract(data.ContractCode, data.OCC); if (dsRentalContract.dtTbt_RentalSecurityBasic[0].ReturnToOriginalFeeDate != null) { var operationOfficeDat = officehandler.GetTbm_Office(dsRentalContract.dtTbt_RentalContractBasic[0].OperationOfficeCode); var billingOfficeDat = officehandler.GetTbm_Office(doBillingTarget[0].BillingOfficeCode); EmailTemplateUtil mailUtil = new EmailTemplateUtil(EmailTemplateName.C_EMAIL_TEMPLATE_NAME_CHANGE_FEE); dtCustomer = masterHandler.GetTbm_Customer(dsRentalContract.dtTbt_RentalContractBasic[0].ContractTargetCustCode); dtSite = masterHandler.GetTbm_Site(dsRentalContract.dtTbt_RentalContractBasic[0].SiteCode); dtEmployee = empMasterHandler.GetTbm_Employee(data.CreateBy); contractFeeBeforeChange = rentalConHandler.GetContractFeeBeforeChange(dsRentalContract.dtTbt_RentalContractBasic[0].ContractCode, dsRentalContract.dtTbt_RentalSecurityBasic[0].OCC, dsRentalContract); doNotifyEmail.ContractCode = comUtil.ConvertContractCode(dsRentalContract.dtTbt_RentalContractBasic[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); doNotifyEmail.ContractTargetNameEN = dtCustomer[0].CustFullNameEN; doNotifyEmail.ContractTargetNameLC = dtCustomer[0].CustFullNameLC; doNotifyEmail.SiteNameEN = dtSite[0].SiteNameEN; doNotifyEmail.SiteNameLC = dtSite[0].SiteNameLC; doNotifyEmail.ChangeDateOfContractFee = CommonUtil.TextDate(dsRentalContract.dtTbt_RentalSecurityBasic[0].ChangeImplementDate); doNotifyEmail.ContractFeeBeforeChange = CommonUtil.TextNumeric(contractFeeBeforeChange); if (dsRentalContract.dtTbt_RentalContractBasic[0].ContractStatus == ContractStatus.C_CONTRACT_STATUS_STOPPING) { ChangeContractFee = dsRentalContract.dtTbt_RentalSecurityBasic[0].ContractFeeOnStop; } else { ChangeContractFee = dsRentalContract.dtTbt_RentalSecurityBasic[0].OrderContractFee; } doNotifyEmail.ContractFeeAfterChange = CommonUtil.TextNumeric(ChangeContractFee); doNotifyEmail.ReturnToOriginalFeeDate = CommonUtil.TextDate(dsRentalContract.dtTbt_RentalSecurityBasic[0].ReturnToOriginalFeeDate); doNotifyEmail.OperationOfficeEN = operationOfficeDat[0].OfficeNameEN; doNotifyEmail.OperationOfficeLC = operationOfficeDat[0].OfficeNameLC; doNotifyEmail.RegisterChangeEmpNameEN = dtEmployee[0].EmpFirstNameEN + ' ' + dtEmployee[0].EmpLastNameEN; doNotifyEmail.RegisterChangeEmpNameLC = dtEmployee[0].EmpFirstNameLC + ' ' + dtEmployee[0].EmpLastNameLC; doNotifyEmail.BillingOfficeEN = billingOfficeDat[0].OfficeNameEN; doNotifyEmail.BillingOfficeLC = billingOfficeDat[0].OfficeNameLC; var mailTemplate = mailUtil.LoadTemplate(doNotifyEmail); data.EmailContent = mailTemplate.TemplateContent; tbt_ContractEmail conEmailTemp = CommonUtil.CloneObject <tbt_ContractEmail, tbt_ContractEmail>(data); updateContractEmailList.Add(conEmailTemp); } } if (updateContractEmailList != null && updateContractEmailList.Count > 0) { conHandler.UpdateTbt_ContractEmail(updateContractEmailList); } scope.Complete(); } } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }
public ActionResult CMS210() { CMS210_ScreenParameter cond = new CMS210_ScreenParameter(); try { cond = GetScreenObject <CMS210_ScreenParameter>(); } catch { } // Keep ServiceTypeCode ViewBag.ServiceTypeCode = cond.ServiceTypeCode; CommonUtil c = new CommonUtil(); cond.ContractCode = c.ConvertContractCode(cond.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); cond.MATargetContractCode = c.ConvertContractCode(cond.MATargetContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); cond.ContractTargetCode = c.ConvertCustCode(cond.ContractTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG); try { IRentralContractHandler handlerR = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; ISaleContractHandler handlerS = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; List <dtTbt_RentalContractBasicForView> dtRentalContract = new List <dtTbt_RentalContractBasicForView>(); List <dtTbt_SaleBasicForView> dtSaleContract = new List <dtTbt_SaleBasicForView>(); ICommonHandler comHand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>() { new doMiscTypeCode() { FieldName = MiscType.C_CURRENCT, ValueCode = "%" } }).ToList(); if (cond.ServiceTypeCode == ServiceType.C_SERVICE_TYPE_RENTAL) { dtRentalContract = handlerR.GetTbt_RentalContractBasicForView(cond.MATargetContractCode); //Add Currency to List for (int i = 0; i < dtRentalContract.Count(); i++) { dtRentalContract[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies); } foreach (var item in dtRentalContract) { item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } if (dtRentalContract.Count > 0) { ViewBag.txtContractCode = dtRentalContract[0].ContractCode; ViewBag.txtContract_target_name_English = dtRentalContract[0].CustFullNameEN_Cust; ViewBag.txtContract_target_address_English = dtRentalContract[0].AddressFullEN_Cust; ViewBag.txtSite_name_English = dtRentalContract[0].SiteNameEN_Site; ViewBag.Site_address_English = dtRentalContract[0].AddressFullEN_Site; ViewBag.txtContract_target_name_Local = dtRentalContract[0].CustFullNameLC_Cust; ViewBag.txtContract_target_address_Local = dtRentalContract[0].AddressFullLC_Cust; ViewBag.txtSite_name_Local = dtRentalContract[0].SiteNameLC_Site; ViewBag.txtSite_address_Local = dtRentalContract[0].AddressFullLC_Site; ViewBag.txtRentalAttachImportanceFlag = dtRentalContract[0].SpecialCareFlag; } } else if (cond.ServiceTypeCode == ServiceType.C_SERVICE_TYPE_SALE) { dtSaleContract = handlerS.GetTbt_SaleBasicForView(cond.MATargetContractCode, null, null); //Add Currency to List for (int i = 0; i < dtSaleContract.Count(); i++) { dtSaleContract[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies); } foreach (var item in dtSaleContract) { item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } if (dtSaleContract.Count > 0) { ViewBag.txtContractCode = dtSaleContract[0].ContractCode; ViewBag.txtContract_target_name_English = dtSaleContract[0].PurCust_CustFullNameEN; ViewBag.txtContract_target_address_English = dtSaleContract[0].AddressFullEN_PurCust; ViewBag.txtSite_name_English = dtSaleContract[0].site_SiteNameEN; ViewBag.Site_address_English = dtSaleContract[0].AddressFullEN_site; ViewBag.txtContract_target_name_Local = dtSaleContract[0].PurCust_CustFullNameLC; ViewBag.txtContract_target_address_Local = dtSaleContract[0].AddressFullLC_PurCust; ViewBag.txtSite_name_Local = dtSaleContract[0].site_SiteNameLC; ViewBag.txtSite_address_Local = dtSaleContract[0].AddressFullLC_site; ViewBag.txtSaleAttachImportanceFlag = dtSaleContract[0].SpecialCareFlag; } } return(View()); } catch (Exception ex) { ObjectResultData res = new ObjectResultData(); 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)); } }
public ActionResult CMS131() { string strContractCode = ""; string strOCC = ""; try { CMS131_ScreenParameter param = GetScreenObject <CMS131_ScreenParameter>(); strContractCode = param.ContractCode; strOCC = param.OCC; } catch { } ViewBag.ContractCode = strContractCode; ViewBag.Occurrence = strOCC; CommonUtil c = new CommonUtil(); strContractCode = c.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); List <dtTbt_RentalContractBasicForView> vw_dtRentalContract = new List <dtTbt_RentalContractBasicForView>(); List <dtTbt_RentalSecurityBasicForView> vw_dtRentalSecurity = new List <dtTbt_RentalSecurityBasicForView>(); try { IRentralContractHandler handler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; List <dtTbt_RentalContractBasicForView> dtRentalContract = handler.GetTbt_RentalContractBasicForView(strContractCode); List <dtTbt_RentalSecurityBasicForView> dtRentalSecurity = handler.GetTbt_RentalSecurityBasicForView(strContractCode, CommonUtil.IsNullOrEmpty(strOCC) == true ? null : strOCC); // Select language vw_dtRentalContract = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalContractBasicForView, dtTbt_RentalContractBasicForView>(dtRentalContract, "Quo_OfficeName", "Con_OfficeName", "Op_OfficeName"); vw_dtRentalSecurity = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalSecurityBasicForView, dtTbt_RentalSecurityBasicForView>(dtRentalSecurity, "NegStaff1_EmpFirstName", "NegStaff1_EmpLastName", "NegStaff2_EmpFirstName", "NegStaff2_EmpLastName"); if (vw_dtRentalContract.Count > 0) { string txtContractOffice = CommonUtil.TextCodeName(vw_dtRentalContract[0].ContractOfficeCode, vw_dtRentalContract[0].Con_OfficeName); ViewBag.txtContractOffice = CommonUtil.IsNullOrEmpty(txtContractOffice) == true ? "-" : txtContractOffice; string txtOperationOffice = CommonUtil.TextCodeName(vw_dtRentalContract[0].OperationOfficeCode, vw_dtRentalContract[0].Op_OfficeName); ViewBag.txtOperationOffice = CommonUtil.IsNullOrEmpty(txtOperationOffice) == true ? "-" : txtOperationOffice; } if (vw_dtRentalSecurity.Count > 0) { string txtNegotiationStaff1 = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].NegotiationStaffEmpNo1, string.Format("{0} {1}", vw_dtRentalSecurity[0].NegStaff1_EmpFirstName, vw_dtRentalSecurity[0].NegStaff1_EmpLastName)); ViewBag.txtNegotiationStaff1 = CommonUtil.IsNullOrEmpty(txtNegotiationStaff1) == true ? "-" : txtNegotiationStaff1; string txtNegotiationStaff2 = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].NegotiationStaffEmpNo2, string.Format("{0} {1}", vw_dtRentalSecurity[0].NegStaff2_EmpFirstName, vw_dtRentalSecurity[0].NegStaff2_EmpLastName)); ViewBag.txtNegotiationStaff2 = CommonUtil.IsNullOrEmpty(txtNegotiationStaff2) == true ? "-" : txtNegotiationStaff2; } return(View()); } catch (Exception ex) { ObjectResultData res = new ObjectResultData(); res.AddErrorMessage(ex); return(Json(res)); } }
/// <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)); }
/// <summary> /// Check system suspending, user’s permission and user’s authority of screen /// </summary> /// <param name="param"></param> /// <returns></returns> public ActionResult CTS054_Authority(CTS054_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; //return InitialScreenEnvironment("CTS054", session); // Natthavat S., 2012/01/30 // Check Authority Here //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_CHANGE_EXPECTED_OPR_DATE, 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.Where(x => x.OfficeCode == contractObj[0].ContractOfficeCode).Count() == 0) * { * //if (CommonUtil.dsTransData.dtOfficeData.FindAll(delegate(OfficeDataDo s) { return s.OfficeCode == listRentalContractBasic[0].ContractOfficeCode; }).Count == 0) * res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0063, null, null); * return Json(res); * } * * if (CommonUtil.dsTransData.dtOfficeData.Where(x => x.OfficeCode == contractObj[0].OperationOfficeCode).Count() == 0) * { * //if (CommonUtil.dsTransData.dtOfficeData.FindAll(delegate(OfficeDataDo s) { return s.OfficeCode == listRentalContractBasic[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)); } string lastOCC = ""; lastOCC = renderHandler.GetLastUnimplementedOCC(util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG)); if (String.IsNullOrEmpty(lastOCC)) { res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3053, null, null); //res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; return(Json(res)); } CTS054_ScreenParameter session = InitialScreenSession_CTS054(); session.ScreenParameter.ContractCode = util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); //session.ScreenParameter.ContractCode = param.ContractCode; session.ContractCode = session.ScreenParameter.ContractCode; session.CommonSearch = param.CommonSearch; return(InitialScreenEnvironment <CTS054_ScreenParameter>("CTS054", session, res)); } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }
public ActionResult CMS190() { string strContractCode = ""; string strServiceTypeCode = ""; try { CMS190_ScreenParameter param = GetScreenObject <CMS190_ScreenParameter>(); strContractCode = param.ContractCode; strServiceTypeCode = param.ServiceTypeCode; } catch { } /* ----- Set grobal variable for javascript side ---- */ ViewBag._ServiceTypeCode = strServiceTypeCode; ViewBag._ContractCode = strContractCode; CommonUtil c = new CommonUtil(); List <dtTbt_RentalContractBasicForView> vw_dtRentalContract = new List <dtTbt_RentalContractBasicForView>(); List <dtTbt_SaleBasicForView> vw_dtSaleContract = new List <dtTbt_SaleBasicForView>(); List <dtTbt_RentalSecurityBasicForView> vw_dtRentalSecurity = new List <dtTbt_RentalSecurityBasicForView>(); //List<dtContractTargetInfoByRelated> vw_dtMaintenanceContractInfo = new List<dtContractTargetInfoByRelated>(); ViewBag.Currency = CommonValue.CURRENCY_UNIT; string dateFormat = "dd-MMM-yyyy"; string numberFormat = "N0"; string floatNumberFormat = "N2"; // default ViewBag ViewBag.chkFire_monitoring = false; ViewBag.chkCrime_prevention = false; ViewBag.chkEmergency_report = false; ViewBag.chkFacility_monitoring = false; ViewBag.bOutOfRegulationDocFlag = false; try { strContractCode = c.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); ICommonHandler handlerComm = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; /****** get misc display value ******/ List <string> lsFieldNames = new List <string>(); lsFieldNames.Add(MiscType.C_RENTAL_CHANGE_TYPE); lsFieldNames.Add(MiscType.C_SALE_CHANGE_TYPE); lsFieldNames.Add(MiscType.C_SALE_TYPE); lsFieldNames.Add(MiscType.C_SALE_PROC_MANAGE_STATUS); List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames); /************************************/ // Rental IRentralContractHandler handlerR = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; // Sale ISaleContractHandler handlerS = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; // Online IViewContractHandler handlerVC = ServiceContainer.GetService <IViewContractHandler>() as IViewContractHandler; IInstallationHandler iHandler = ServiceContainer.GetService <IInstallationHandler>() as IInstallationHandler; ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; string strInstallationStatusCode = "-"; string strInstallationStatusName = "-"; List <dtTbt_RentalContractBasicForView> dtRentalContract = new List <dtTbt_RentalContractBasicForView>(); List <dtTbt_SaleBasicForView> dtSaleContract = new List <dtTbt_SaleBasicForView>(); List <dtTbt_RentalSecurityBasicForView> dtRentalSecurity = new List <dtTbt_RentalSecurityBasicForView>(); List <dtContractTargetInfoByRelated> dtOnlineContractInfo = new List <dtContractTargetInfoByRelated>(); List <dtContractTargetInfoByRelated> dtMaintenanceContractInfo = new List <dtContractTargetInfoByRelated>(); ICommonHandler comHand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>() { new doMiscTypeCode() { FieldName = MiscType.C_CURRENCT, ValueCode = "%" } }).ToList(); if (strServiceTypeCode == ServiceType.C_SERVICE_TYPE_RENTAL) { dtRentalContract = handlerR.GetTbt_RentalContractBasicForView(strContractCode); //Check Currency *For view if (dtRentalContract[0].NormalDepositFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalContract[0].NormalDepositFee = dtRentalContract[0].NormalDepositFeeUsd; } if (dtRentalContract[0].OrderDepositFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalContract[0].OrderDepositFee = dtRentalContract[0].OrderDepositFeeUsd; } if (dtRentalContract[0].LastOrderContractFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalContract[0].LastOrderContractFee = dtRentalContract[0].LastOrderContractFeeUsd; } if (dtRentalContract[0].ExemptedDepositFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalContract[0].ExemptedDepositFee = dtRentalContract[0].ExemptedDepositFeeUsd; } //Add currency to List for (int i = 0; i < dtRentalContract.Count(); i++) { dtRentalContract[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies); } } else if (strServiceTypeCode == ServiceType.C_SERVICE_TYPE_SALE) { dtSaleContract = handlerS.GetTbt_SaleBasicForView(strContractCode, null, true); if (dtSaleContract[0].NormalInstallFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtSaleContract[0].NormalInstallFee = dtSaleContract[0].NormalInstallFeeUsd; } if (dtSaleContract[0].OrderInstallFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtSaleContract[0].OrderInstallFee = dtSaleContract[0].OrderInstallFeeUsd; } if (dtSaleContract[0].InstallFeePaidBySECOMCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtSaleContract[0].InstallFeePaidBySECOM = dtSaleContract[0].InstallFeePaidBySECOMUsd; } if (dtSaleContract[0].InstallFeeRevenueBySECOMCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtSaleContract[0].InstallFeeRevenueBySECOM = dtSaleContract[0].InstallFeeRevenueBySECOMUsd; } if (dtSaleContract[0].OrderProductPriceCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtSaleContract[0].OrderProductPrice = dtSaleContract[0].OrderProductPriceUsd; } if (dtSaleContract[0].NormalProductPriceCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtSaleContract[0].NormalProductPrice = dtSaleContract[0].NormalProductPriceUsd; } if (dtSaleContract[0].BidGuaranteeAmount1CurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtSaleContract[0].BidGuaranteeAmount1 = dtSaleContract[0].BidGuaranteeAmount1Usd; } if (dtSaleContract[0].BidGuaranteeAmount2CurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtSaleContract[0].BidGuaranteeAmount2 = dtSaleContract[0].BidGuaranteeAmount2Usd; } if (dtSaleContract[0].NewBldMgmtCostCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtSaleContract[0].NewBldMgmtCost = dtSaleContract[0].NewBldMgmtCostUsd; } //Add Currency to List for (int i = 0; i < dtSaleContract.Count(); i++) { dtSaleContract[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies); } } if (dtRentalContract.Count > 0) { // Get related data dtRentalSecurity = handlerR.GetTbt_RentalSecurityBasicForView(strContractCode, dtRentalContract[0].LastOCC); for (int i = 0; i < dtRentalSecurity.Count(); i++) { dtRentalSecurity[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies); } //Must get InstallationInterfaceHandler.GetInstallationStatus (Next phase) strInstallationStatusCode = iHandler.GetInstallationStatus(strContractCode); //======== GET INSTALLATION STATUS NAME ============================= List <doMiscTypeCode> lst = new List <doMiscTypeCode>(); List <doMiscTypeCode> miscs = new List <doMiscTypeCode>() { new doMiscTypeCode() { FieldName = MiscType.C_INSTALL_STATUS, ValueCode = strInstallationStatusCode } }; lst = chandler.GetMiscTypeCodeList(miscs); if (lst != null && lst.Count > 0) { strInstallationStatusName = lst[0].ValueDisplay; } //================================================================ // Select language vw_dtRentalContract = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalContractBasicForView, dtTbt_RentalContractBasicForView>(dtRentalContract, "Quo_OfficeName", "Con_OfficeName", "Op_OfficeName"); vw_dtRentalSecurity = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalSecurityBasicForView, dtTbt_RentalSecurityBasicForView>(dtRentalSecurity, "ProductName", "DocumentName", "DocumentNoName", "SalesMan1_EmpFirstName", "SalesMan1_EmpFirstName", "SalesMan1_EmpLastName", "SalesMan2_EmpFirstName", "SalesMan2_EmpLastName", "SalesSupport_EmpFirstName", "SalesSupport_EmpLastName", "Alm_EmpFirstName", "Alm_EmpLastName", "NegStaff1_EmpFirstName", "NegStaff1_EmpLastName", "NegStaff2_EmpFirstName", "NegStaff2_EmpLastName", "CompStaff_EmpFirstName", "CompStaff_EmpLastName", "Planner_EmpFirstName", "Planner_EmpLastName", "PlanChecker_EmpFirstName", "PlanChecker_EmpLastName", "PlanApprover_EmpFirstName", "PlanApprover_EmpLastName" ); /**** Convert code to short format *****/ foreach (var item in vw_dtRentalContract) { // contract code item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); item.OldContractCode = c.ConvertContractCode(item.OldContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); // customer code item.ContractTargetCustCode = c.ConvertCustCode(item.ContractTargetCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT); item.RealCustomerCustCode = c.ConvertCustCode(item.RealCustomerCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT); //site code item.SiteCode = c.ConvertSiteCode(item.SiteCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } // dtOnlineContractInfo foreach (var item in dtOnlineContractInfo) { item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } } // Sale if (dtSaleContract.Count > 0) { // Get related data //dtOnlineContractInfo = handlerVC.GetContractTargetInfoByRelated(strContractCode, RelationType.C_RELATION_TYPE_SALE, dtSaleContract[0].OCC, ProductType.C_PROD_TYPE_SALE, ProductType.C_PROD_TYPE_AL, ProductType.C_PROD_TYPE_ONLINE, dtSaleContract[0].ProductTypeCode, // RelationType.C_RELATION_TYPE_MA, RelationType.C_RELATION_TYPE_SALE); //dtMaintenanceContractInfo = handlerVC.GetContractTargetInfoByRelated(strContractCode, RelationType.C_RELATION_TYPE_MA, dtSaleContract[0].OCC, ProductType.C_PROD_TYPE_SALE, ProductType.C_PROD_TYPE_AL, ProductType.C_PROD_TYPE_ONLINE, dtSaleContract[0].ProductTypeCode, // RelationType.C_RELATION_TYPE_MA, RelationType.C_RELATION_TYPE_SALE); dtOnlineContractInfo = handlerVC.GetContractTargetInfoByRelated(strContractCode, RelationType.C_RELATION_TYPE_SALE, dtSaleContract[0].OCC, dtSaleContract[0].ProductTypeCode); dtMaintenanceContractInfo = handlerVC.GetContractTargetInfoByRelated(strContractCode, RelationType.C_RELATION_TYPE_MA, dtSaleContract[0].OCC, dtSaleContract[0].ProductTypeCode); //Must get InstallationInterfaceHandler.GetInstallationStatus (Next phase) strInstallationStatusCode = iHandler.GetInstallationStatus(strContractCode); //======== GET INSTALLATION STATUS NAME ============================= List <doMiscTypeCode> lst = new List <doMiscTypeCode>(); List <doMiscTypeCode> miscs = new List <doMiscTypeCode>() { new doMiscTypeCode() { FieldName = MiscType.C_INSTALL_STATUS, ValueCode = strInstallationStatusCode } }; lst = chandler.GetMiscTypeCodeList(miscs); if (lst != null && lst.Count > 0) { strInstallationStatusName = lst[0].ValueDisplay; } //================================================================ // select language vw_dtSaleContract = CommonUtil.ConvertObjectbyLanguage <dtTbt_SaleBasicForView, dtTbt_SaleBasicForView>(dtSaleContract, "PurCust_CustName", "PurCust_CustFullName", "RealCust_CustName", "RealCust_CustFullName", "site_SiteName", "QuoEmp_EmpFirstName", "QuoEmp_EmpLastName", "DocTemp_DocumentName", "DocTemp_DocumentNoName", "PlanEmp_EmpFirstName", "PlanEmp_EmpLastName", "planAppEmp_EmpFirstName", "planAppEmp_EmpLastName", "PlanChkrEmp_EmpFirstName", "PlanChkrEmp_EmpLastName", "ProductName", "SalesMan1_EmpFirstName", "SalesMan1_EmpLastName", "Quo_OfficeName", "Con_OfficeName", "Sale_OfficeName", "Op_OfficeName"); /**** Convert code to short format *****/ // vw_dtSaleContract foreach (var item in vw_dtSaleContract) { // contract code item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); // customer code item.CustCode_PurCust = c.ConvertCustCode(item.CustCode_PurCust, CommonUtil.CONVERT_TYPE.TO_SHORT); item.CustCode_RealCust = c.ConvertCustCode(item.CustCode_RealCust, CommonUtil.CONVERT_TYPE.TO_SHORT); item.RealCustomerCustCode = c.ConvertCustCode(item.RealCustomerCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT); // site code item.SiteCode = c.ConvertSiteCode(item.SiteCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } // dtMaintenanceContractInfo foreach (var item in dtMaintenanceContractInfo) { item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } // Online contract foreach (var item in dtOnlineContractInfo) { item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } } // Rental if (vw_dtRentalContract.Count > 0) { /* --- global variable for javascript side --*/ ViewBag._ContractCode = vw_dtRentalContract[0].ContractCode; ViewBag._OCC = vw_dtRentalContract[0].LastOCC; ViewBag._ContractTargetCode = vw_dtRentalContract[0].ContractTargetCustCode; ViewBag._RealCustomerCode = vw_dtRentalContract[0].RealCustomerCustCode; ViewBag._SiteCode = vw_dtRentalContract[0].SiteCode; ViewBag._ServiceTypeCode = vw_dtRentalContract[0].ServiceTypeCode; ViewBag._OldContractCode = vw_dtRentalContract[0].OldContractCode; ViewBag.ProductTypeCode = vw_dtRentalContract[0].ProductTypeCode; ViewBag.SiteCodeList = vw_dtRentalContract[0].SiteCode; ViewBag.ContractCode = vw_dtRentalContract[0].ContractCode; ViewBag.txtContractCode = vw_dtRentalContract[0].ContractCode; ViewBag.txtOccurrence = vw_dtRentalContract[0].LastOCC; ViewBag.txtUserCode = vw_dtRentalContract[0].UserCode; ViewBag.lnkCustomerCodeC = vw_dtRentalContract[0].ContractTargetCustCode; ViewBag.lnkCustomerCodeR = vw_dtRentalContract[0].RealCustomerCustCode; ViewBag.lnkSiteCode = vw_dtRentalContract[0].SiteCode; ViewBag.txtContractNameEng = vw_dtRentalContract[0].CustFullNameEN_Cust; // ContractTargetFullNameEN ViewBag.txtContractAddrEng = vw_dtRentalContract[0].AddressFullEN_Cust; ViewBag.txtSiteNameEng = vw_dtRentalContract[0].SiteNameEN_Site; ViewBag.txtSiteAddrEng = vw_dtRentalContract[0].AddressFullEN_Site; ViewBag.txtContractNameLocal = vw_dtRentalContract[0].CustFullNameLC_Cust; // ContractTargetFullNameLC ViewBag.txtContractAddrLocal = vw_dtRentalContract[0].AddressFullLC_Cust; ViewBag.txtSiteNameLocal = vw_dtRentalContract[0].SiteNameLC_Site; ViewBag.txtSiteAddrLocal = vw_dtRentalContract[0].AddressFullLC_Site; //Add by Jutarat A. on 26032014 ViewBag.txtCustomerContact = vw_dtRentalContract[0].ContactPersonName_Cust; ViewBag.txtTelephoneNoCust = vw_dtRentalContract[0].PhoneNo_Cust; ViewBag.txtFaxNo = vw_dtRentalContract[0].FaxNo_Cust; ViewBag.txtPersonInCharge = vw_dtRentalContract[0].PersonInCharge_Site; ViewBag.txtTelephoneNoSite = vw_dtRentalContract[0].PhoneNo_Site; //End Add //ViewBag.txtContactPoint = vw_dtRentalContract[0].ContactPoint; ViewBag.txtContactPoint = CommonUtil.IsNullOrEmpty(vw_dtRentalContract[0].ContactPoint) == true ? "-" : vw_dtRentalContract[0].ContactPoint; // section: contract detail info //ViewBag.txtReceived_deposit_fee = vw_dtRentalContract[0].BilledDepositFee != null ? vw_dtRentalContract[0].BilledDepositFee.Value.ToString(floatNumberFormat) : "-"; // SA request to chagnge :31/Jan/2012 ref. UCCM1-8 //ViewBag.txtReceived_deposit_fee = vw_dtRentalContract[0].PaidDepositFee.HasValue ? vw_dtRentalContract[0].PaidDepositFee.Value.ToString(floatNumberFormat) : "-"; // SA request to chagnge#2 :15/Mar/2012 ref. UCCM1-75 ViewBag.txtReceived_deposit_fee = vw_dtRentalContract[0].TextTransferOrderDepositFee; //ViewBag.txtReceived_deposit_fee = vw_dtRentalContract[0].OrderDepositFee.HasValue ? vw_dtRentalContract[0].OrderDepositFee.Value.ToString(floatNumberFormat) : "-"; ViewBag.txtOperation_office = CommonUtil.TextCodeName(vw_dtRentalContract[0].OperationOfficeCode, vw_dtRentalContract[0].Op_OfficeName); ViewBag.txtFirst_operation_date = vw_dtRentalContract[0].FirstSecurityStartDate != null ? vw_dtRentalContract[0].FirstSecurityStartDate.Value.ToString(dateFormat) : "-"; ViewBag.txtContract_fee = vw_dtRentalContract[0].TextTransferLastOrderContractFee; //ViewBag.txtContract_fee = vw_dtRentalContract[0].LastOrderContractFee != null ? vw_dtRentalContract[0].LastOrderContractFee.Value.ToString(floatNumberFormat) : "-"; ViewBag.txtContract_office = CommonUtil.TextCodeName(vw_dtRentalContract[0].OfficeCode_Con, vw_dtRentalContract[0].Con_OfficeName); ViewBag.txtLast_operation_date = vw_dtRentalContract[0].LastChangeImplementDate != null ? vw_dtRentalContract[0].LastChangeImplementDate.Value.ToString(dateFormat) : "-"; //ViewBag.txtProcessing_installation = "-"; Get value from InstallInterfaceHandler.GetInstallationSatatus (ContractCode) if (strInstallationStatusCode != InstallationStatus.C_INSTALL_STATUS_NO_INSTALLATION) { ViewBag.txtProcessing_installation = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_COMMON, "CMS190", "lblYes"); } else { ViewBag.txtProcessing_installation = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_COMMON, "CMS190", "lblNo"); } //ViewBag.txtProcessing_installation = strInstallationStatusCode+" : "+strInstallationStatusName; string strLastChangeTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_RENTAL_CHANGE_TYPE, vw_dtRentalContract[0].LastChangeType); ViewBag.txtLast_change_type = CommonUtil.TextCodeName(vw_dtRentalContract[0].LastChangeType, strLastChangeTypeDisplayValue); //ViewBag.txtProcessing_installation_status = "-"; Get value from InstallInterfaceHandler.GetInstallationSatatus (ContractCode) ViewBag.txtProcessing_installation_status = strInstallationStatusCode + " : " + strInstallationStatusName; ViewBag.lnkOld_contract_codeC = vw_dtRentalContract[0].OldContractCode; //** // Change bOutOfRegulationDocFlag --> to RentalContract[0].IrregurationDocUsageFlag (old: vw_dtRentalSecurity[0].DocAuditResult ) ViewBag.bOutOfRegulationDocFlag = vw_dtRentalContract[0].IrregurationDocUsageFlag.HasValue == true ? vw_dtRentalContract[0].IrregurationDocUsageFlag.Value : false; ViewBag.txtRentalAttachImportanceFlag = vw_dtRentalContract[0].SpecialCareFlag; } if (vw_dtRentalSecurity.Count > 0) { // section: contract detail info ViewBag.txtProduct = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ProductCode, vw_dtRentalSecurity[0].ProductName); ViewBag.txtSecurity_type_code = vw_dtRentalSecurity[0].SecurityTypeCode; // ContractStartDate - ContractEndDate string strContractStartDate = vw_dtRentalSecurity[0].ContractStartDate != null ? vw_dtRentalSecurity[0].ContractStartDate.Value.ToString(dateFormat) : string.Empty; //string strContractEndDate = vw_dtRentalSecurity[0].ContractEndDate != null ? vw_dtRentalSecurity[0].ContractEndDate.Value.ToString(dateFormat) : string.Empty; string strContractEndDate = vw_dtRentalSecurity[0].CalContractEndDate != null ? vw_dtRentalSecurity[0].CalContractEndDate.Value.ToString(dateFormat) : string.Empty; ViewBag.strContractStartDate = strContractStartDate; ViewBag.strContractEndDate = strContractEndDate; if (CommonUtil.IsNullOrEmpty(strContractStartDate) == false && CommonUtil.IsNullOrEmpty(strContractEndDate) == false) { ViewBag.txtContract_duration = string.Format("{0} <span style='color:black;'> ~ </span> {1}", strContractStartDate, strContractEndDate); } else if (CommonUtil.IsNullOrEmpty(strContractStartDate) == false) { ViewBag.txtContract_duration = string.Format("{0} <span style='color:black;'> ~ </span> {1}", strContractStartDate, "-"); } else if (CommonUtil.IsNullOrEmpty(strContractEndDate) == false) { ViewBag.txtContract_duration = string.Format("{0} <span style='color:black;'> ~ </span> {1}", "-", strContractEndDate); } else { ViewBag.txtContract_duration = string.Empty; } ViewBag.txtSalesman1 = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].SalesmanEmpNo1, string.Format("{0} {1}", vw_dtRentalSecurity[0].SalesMan1_EmpFirstName, vw_dtRentalSecurity[0].SalesMan1_EmpLastName));; ViewBag.txtContract_duration_month = vw_dtRentalSecurity[0].ContractDurationMonth != null ? vw_dtRentalSecurity[0].ContractDurationMonth.Value.ToString(numberFormat) : "-"; ViewBag.txtAuto_renew_months = vw_dtRentalSecurity[0].AutoRenewMonth != null ? vw_dtRentalSecurity[0].AutoRenewMonth.Value.ToString(numberFormat) : "-"; // Change bOutOfRegulationDocFlag --> to RentalContract[0].IrregurationDocUsageFlag //ViewBag.bOutOfRegulationDocFlag = vw_dtRentalSecurity[0].DocAuditResult == "1" ? true : false ; ViewBag.chkFire_monitoring = vw_dtRentalSecurity[0].FireMonitorFlag.HasValue == true ? vw_dtRentalSecurity[0].FireMonitorFlag.Value : false; ViewBag.chkCrime_prevention = vw_dtRentalSecurity[0].CrimePreventFlag.HasValue == true ? vw_dtRentalSecurity[0].CrimePreventFlag.Value : false;; ViewBag.chkEmergency_report = vw_dtRentalSecurity[0].EmergencyReportFlag.HasValue == true ? vw_dtRentalSecurity[0].EmergencyReportFlag.Value : false;; ViewBag.chkFacility_monitoring = vw_dtRentalSecurity[0].FacilityMonitorFlag.HasValue == true ? vw_dtRentalSecurity[0].FacilityMonitorFlag.Value : false;; } // Sale if (vw_dtSaleContract.Count > 0) { /* --- global variable for javascript side --*/ ViewBag._ContractCode = vw_dtSaleContract[0].ContractCode; ViewBag._OCC = vw_dtSaleContract[0].OCC; ViewBag._PurchaserCustCode = vw_dtSaleContract[0].CustCode_PurCust; ViewBag._RealCustomerCode = vw_dtSaleContract[0].RealCustomerCustCode; ViewBag._SiteCode = vw_dtSaleContract[0].SiteCode; ViewBag._ServiceTypeCode = vw_dtSaleContract[0].ServiceTypeCode; ViewBag.SiteCodeList = vw_dtSaleContract[0].SiteCode; ViewBag.ContractCode = vw_dtSaleContract[0].ContractCode; ViewBag.ProductTypeCode = vw_dtSaleContract[0].ProductTypeCode; ViewBag.txtContractCode = vw_dtSaleContract[0].ContractCode; ViewBag.txtOccurrence = vw_dtSaleContract[0].OCC; ViewBag.lnkCustomerCodeC_Purchaser = vw_dtSaleContract[0].CustCode_PurCust; ViewBag.lnkCustomerCodeR = vw_dtSaleContract[0].RealCustomerCustCode; ViewBag.lnkSiteCode = vw_dtSaleContract[0].SiteCode; ViewBag.txtContractNameEng = vw_dtSaleContract[0].PurCust_CustFullNameEN; ViewBag.txtContractAddrEng = vw_dtSaleContract[0].AddressFullEN_PurCust; ViewBag.txtSiteNameEng = vw_dtSaleContract[0].site_SiteNameEN; ViewBag.txtSiteAddrEng = vw_dtSaleContract[0].AddressFullEN_site; ViewBag.txtContractNameLocal = vw_dtSaleContract[0].PurCust_CustFullNameLC; ViewBag.txtContractAddrLocal = vw_dtSaleContract[0].AddressFullLC_PurCust; ViewBag.txtSiteNameLocal = vw_dtSaleContract[0].site_SiteNameLC; ViewBag.txtSiteAddrLocal = vw_dtSaleContract[0].AddressFullLC_site; //Add by Jutarat A. on 26032014 ViewBag.txtCustomerContact = vw_dtSaleContract[0].ContactPersonName_PurCust; ViewBag.txtTelephoneNoCust = vw_dtSaleContract[0].PhoneNo_PurCust; ViewBag.txtFaxNo = vw_dtSaleContract[0].FaxNo_PurCust; ViewBag.txtPersonInCharge = vw_dtSaleContract[0].PersonInCharge_site; ViewBag.txtTelephoneNoSite = vw_dtSaleContract[0].PhoneNo_site; //End Add //ViewBag.txtContactPoint = vw_dtSaleContract[0].ContactPoint; ViewBag.txtContactPoint = CommonUtil.IsNullOrEmpty(vw_dtSaleContract[0].ContactPoint) == true ? "-" : vw_dtSaleContract[0].ContactPoint; // section : sale contract detail info ViewBag.txtProduct = CommonUtil.TextCodeName(vw_dtSaleContract[0].ProductCode, vw_dtSaleContract[0].ProductName); string strSaleTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_SALE_TYPE, vw_dtSaleContract[0].SalesType); ViewBag.txtSale_type = CommonUtil.TextCodeName(vw_dtSaleContract[0].SalesType, strSaleTypeDisplayValue); ViewBag.txtProduct_Price = vw_dtSaleContract[0].TextTransferOrderProductPrice; ViewBag.txtInstallation_Fee = vw_dtSaleContract[0].TextTransferOrderInstallFee; //ViewBag.txtBilling_amount = vw_dtSaleContract[0].TextTransferOrderSalePrice; //ViewBag.txtBilling_amount = vw_dtSaleContract[0].OrderSalePrice != null ? vw_dtSaleContract[0].OrderSalePrice.Value.ToString(floatNumberFormat) : "-"; string SaleProdessManagementStatusDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_SALE_PROC_MANAGE_STATUS, vw_dtSaleContract[0].SaleProcessManageStatus); ViewBag.txtProcess_management_status = CommonUtil.TextCodeName(vw_dtSaleContract[0].SaleProcessManageStatus, SaleProdessManagementStatusDisplayValue); ViewBag.txtLast_operation_date = vw_dtSaleContract[0].ChangeImplementDate != null ? vw_dtSaleContract[0].ChangeImplementDate.Value.ToString(dateFormat) : "-"; //ViewBag.txtProcessing_installation = "-";Get value from InstallInterfaceHandler.GetInstallationSatatus (ContractCode) if (strInstallationStatusCode != InstallationStatus.C_INSTALL_STATUS_NO_INSTALLATION) { ViewBag.txtProcessing_installation = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_COMMON, "CMS190", "lblYes"); } else { ViewBag.txtProcessing_installation = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_COMMON, "CMS190", "lblNo"); } //ViewBag.txtProcessing_installation = strInstallationStatusCode + " : " + strInstallationStatusName; string strChangeTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_SALE_CHANGE_TYPE, vw_dtSaleContract[0].ChangeType); ViewBag.txtLast_change_type = CommonUtil.TextCodeName(vw_dtSaleContract[0].ChangeType, strChangeTypeDisplayValue); //ViewBag.txtProcessing_installation_status = "-"; Get value from InstallInterfaceHandler.GetInstallationSatatus (ContractCode) ViewBag.txtProcessing_installation_status = strInstallationStatusCode + " : " + strInstallationStatusName; ViewBag.txtApprove_date = vw_dtSaleContract[0].FirstContractDate != null ? vw_dtSaleContract[0].FirstContractDate.Value.ToString(dateFormat) : "-"; ViewBag.txtSalesman1 = CommonUtil.TextCodeName(vw_dtSaleContract[0].SalesmanEmpNo1, string.Format("{0} {1}", vw_dtSaleContract[0].SalesMan1_EmpFirstName, vw_dtSaleContract[0].SalesMan1_EmpLastName)); ViewBag.txtInstrument_stock_out_date = vw_dtSaleContract[0].InstrumentStockOutDate != null ? vw_dtSaleContract[0].InstrumentStockOutDate.Value.ToString(dateFormat) : "-"; ViewBag.txtContract_office = CommonUtil.TextCodeName(vw_dtSaleContract[0].ContractOfficeCode, vw_dtSaleContract[0].Con_OfficeName); ViewBag.txtComplete_installation_date = vw_dtSaleContract[0].InstallCompleteDate != null ? vw_dtSaleContract[0].InstallCompleteDate.Value.ToString(dateFormat) : "-"; ViewBag.txtSales_office = CommonUtil.TextCodeName(vw_dtSaleContract[0].SalesOfficeCode, vw_dtSaleContract[0].Sale_OfficeName); ViewBag.txtCustomer_acceptance_date = vw_dtSaleContract[0].CustAcceptanceDate != null ? vw_dtSaleContract[0].CustAcceptanceDate.Value.ToString(dateFormat) : "-"; ViewBag.txtOperation_office = CommonUtil.TextCodeName(vw_dtSaleContract[0].OperationOfficeCode, vw_dtSaleContract[0].Op_OfficeName); ViewBag.txtSaleAttachImportanceFlag = vw_dtSaleContract[0].SpecialCareFlag; } if (dtOnlineContractInfo.Count > 0) { ViewBag.lnkOnline_contract_code = dtOnlineContractInfo[0].ContractCode; ViewBag._OnlineContractCode = dtOnlineContractInfo[0].ContractCode; } if (dtMaintenanceContractInfo.Count > 0) { ViewBag.lnkMaintenance_contract_code = dtMaintenanceContractInfo[0].ContractCode; ViewBag._MaintenanceContractCode = dtMaintenanceContractInfo[0].ContractCode; } return(View()); } catch (Exception ex) { ObjectResultData res = new ObjectResultData(); res.AddErrorMessage(ex); return(Json(res)); } }
//BLP014 - calculate difference of monthly fee /// <summary> /// Process BLP014 - Calculate difference monthly fee /// </summary> /// <param name="contractCode"></param> /// <param name="billingOCC"></param> /// <param name="changeDate"></param> /// <param name="monthlyBillingAmount"></param> /// <returns></returns> public AdjustOnNextPeriod CalculateDifferenceMonthlyFee(string contractCode, string billingOCC, DateTime changeDate, decimal monthlyBillingAmount, string callerObject) { var billingBasic = this.GetBillingBasic(contractCode, billingOCC, null, null, null, CurrencyUtil.C_CURRENCY_LOCAL, CurrencyUtil.C_CURRENCY_US); AdjustOnNextPeriod billingAdjustOnNextPeriod = null; if (billingBasic.Count == 0) { return(null); } var iChangeDate = Convert.ToInt32(changeDate.ToString("yyyyMMdd")); var iLastBillingDate_plus2day = Convert.ToInt32(billingBasic[0].LastBillingDate.Value.AddDays(2).ToString("yyyyMMdd")); var iLastBillingDate = Convert.ToInt32(billingBasic[0].LastBillingDate.Value.ToString("yyyyMMdd")); // Case #1 : Change monthly fee if (monthlyBillingAmount > 0 || callerObject == ProcessID.C_PROCESS_ID_MANAGE_BILLING_BASIC_RESUME || callerObject == ProcessID.C_PROCESS_ID_MANAGE_BILLING_BASIC_STOP) { // Set start / end date DateTime dtBillingStartDate = changeDate; //DateTime dtBillingEndDate = billingBasic[0].LastBillingDate.HasValue? billingBasic[0].LastBillingDate.Value.AddDays(1) : new DateTime(1,1,1); DateTime dtBillingEndDate = billingBasic[0].LastBillingDate.HasValue ? billingBasic[0].LastBillingDate.Value : new DateTime(1, 1, 1); if (iChangeDate <= iLastBillingDate) { //decimal decNewBillingAmount = this.CalCulateBillingAmountPerHistory(dtBillingStartDate, dtBillingEndDate, monthlyBillingAmount, billingBasic[0].CalDailyFeeStatus); //decimal decOldBillingAmount = this.CalculateBillingAmount(contractCode, billingOCC, billingBasic[0].CalDailyFeeStatus, dtBillingStartDate, dtBillingEndDate); //decimal decDiffBillingAmount = 0; //if (billingBasic[0].AdjustBillingPeriodAmount != null) //{ // decDiffBillingAmount = (decNewBillingAmount - decOldBillingAmount) + Convert.ToDecimal(billingBasic[0].AdjustBillingPeriodAmount); //} //else //{ // decDiffBillingAmount = (decNewBillingAmount - decOldBillingAmount); //} decimal decDiffMonthlyBillingAmount = monthlyBillingAmount - Convert.ToDecimal(billingBasic[0].MonthlyBillingAmount); decimal decDiffBillingAmount = this.CalCulateBillingAmountPerHistory(dtBillingStartDate, dtBillingEndDate, decDiffMonthlyBillingAmount, billingBasic[0].CalDailyFeeStatus) + Convert.ToDecimal(billingBasic[0].AdjustBillingPeriodAmount); decDiffBillingAmount = RoundUp(decDiffBillingAmount, 2); //Add by Jutarat A. on 27012014 if (monthlyBillingAmount > Convert.ToDecimal(billingBasic[0].MonthlyBillingAmount)) // In case increase monthly fee, generate billing detail of "Difference of contract fee" { if (decDiffBillingAmount > 0) { DateTime?autoTransferDate = null; if (billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_AUTO_TRANSFER || billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_CREDIT_CARD_TRANSFER) { autoTransferDate = this.GetNextAutoTransferDate(contractCode, billingOCC, billingBasic[0].PaymentMethod); if (autoTransferDate.HasValue == false) { billingBasic[0].PaymentMethod = PaymentMethod.C_PAYMENT_METHOD_BANK_TRANSFER; } } // Billing type var billingTypeDetail = this.GetBillingTypeDetailContinues(contractCode, billingOCC, BillingTypeGroup.C_BILLING_TYPE_GROUP_CONTINUES); // CREATE Billing detail if (billingTypeDetail.Count > 0) { string strBillingTypeCode = this.GetBillingTypeDifferenceFee(billingTypeDetail[0].BillingTypeCode); // Prepare BillingDetail (data object) tbt_BillingDetail billingDetail = new tbt_BillingDetail() { ContractCode = contractCode, BillingOCC = billingOCC, IssueInvDate = DateTime.Now, IssueInvFlag = true, BillingTypeCode = strBillingTypeCode, BillingAmount = decDiffBillingAmount, BillingStartDate = dtBillingStartDate, BillingEndDate = dtBillingEndDate, PaymentMethod = billingBasic[0].PaymentMethod, PaymentStatus = ((billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_AUTO_TRANSFER || billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_CREDIT_CARD_TRANSFER) ? PaymentStatus.C_PAYMENT_STATUS_DETAIL_AUTO_CREDIT : PaymentStatus.C_PAYMENT_STATUS_DETAIL_BANK_COLLECT), AutoTransferDate = autoTransferDate, StartOperationDate = billingBasic[0].StartOperationDate }; IRentralContractHandler rentalContralHandler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; List <dtTbt_RentalContractBasicForView> dtRentalContract = rentalContralHandler.GetTbt_RentalContractBasicForView(contractCode); if (dtRentalContract.Count > 0) { billingDetail.ContractOCC = dtRentalContract[0].LastOCC; } else { ISaleContractHandler saleHandler = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; List <tbt_SaleBasic> dtSaleBasic = saleHandler.GetTbt_SaleBasic(contractCode, null, true); if (dtSaleBasic != null && dtSaleBasic.Count > 0) { billingDetail.ContractOCC = dtSaleBasic[0].OCC; } } billingDetail.ForceIssueFlag = false; // CREATE this.ManageBillingDetail(billingDetail); billingAdjustOnNextPeriod = new AdjustOnNextPeriod(); // set AdjustOnNextPeriod to empty } } else if (decDiffBillingAmount < 0) { billingAdjustOnNextPeriod = new AdjustOnNextPeriod() { AdjustType = AdjustType.C_ADJUST_TYPE_REDUCT, AdjustBillingPeriodAmount = decDiffBillingAmount, AdjustBillingPeriodStartDate = dtBillingStartDate, AdjustBillingPeriodEndDate = dtBillingEndDate }; } else // decDiffBillingAmount == billingBasic[0].AdjustBillingPeriodAmount { billingAdjustOnNextPeriod = new AdjustOnNextPeriod(); // set AdjustOnNextPeriod to empty } } else if (monthlyBillingAmount < Convert.ToDecimal(billingBasic[0].MonthlyBillingAmount)) // In case decrease monthly fee, calculate "Adjust-on-next-period amount" { if (decDiffBillingAmount > 0) { billingAdjustOnNextPeriod = new AdjustOnNextPeriod() { AdjustType = AdjustType.C_ADJUST_TYPE_ADD, AdjustBillingPeriodAmount = decDiffBillingAmount, AdjustBillingPeriodStartDate = dtBillingStartDate, AdjustBillingPeriodEndDate = dtBillingEndDate }; } else if (decDiffBillingAmount < 0) { billingAdjustOnNextPeriod = new AdjustOnNextPeriod() { AdjustType = AdjustType.C_ADJUST_TYPE_REDUCT, AdjustBillingPeriodAmount = decDiffBillingAmount, AdjustBillingPeriodStartDate = dtBillingStartDate, AdjustBillingPeriodEndDate = dtBillingEndDate }; } else { billingAdjustOnNextPeriod = new AdjustOnNextPeriod(); } } } } else // Case #2 : Monthly billing amount = 0, and it's not during stop , cancel contract --- 4. { if (iChangeDate >= iLastBillingDate_plus2day) { // Set start / end date DateTime dtBillingStartDate = billingBasic[0].LastBillingDate.HasValue ? billingBasic[0].LastBillingDate.Value.AddDays(1) : new DateTime(1, 1, 1); DateTime dtBillingEndDate = changeDate.AddDays(-1); // tt decimal decBillingAmount = this.CalculateBillingAmount(contractCode, billingOCC, billingBasic[0].CalDailyFeeStatus, dtBillingStartDate, dtBillingEndDate); DateTime?autoTransferDate = null; if (billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_AUTO_TRANSFER || billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_CREDIT_CARD_TRANSFER) { autoTransferDate = this.GetNextAutoTransferDate(contractCode, billingOCC, billingBasic[0].PaymentMethod); if (autoTransferDate.HasValue == false) { billingBasic[0].PaymentMethod = PaymentMethod.C_PAYMENT_METHOD_BANK_TRANSFER; } } // Billing type var billingTypeDetail = this.GetBillingTypeDetailContinues(contractCode, billingOCC, BillingTypeGroup.C_BILLING_TYPE_GROUP_CONTINUES); // CREATE Billing detail tbt_BillingDetail billingDetail = new tbt_BillingDetail(); tbt_BillingDetail billingDetail_manage = new tbt_BillingDetail(); if (billingTypeDetail.Count > 0) { string strBillingTypeCode = this.GetBillingTypeDifferenceFee(billingTypeDetail[0].BillingTypeCode); // Prepare BillingDetail (data object) billingDetail = new tbt_BillingDetail() { ContractCode = contractCode, BillingOCC = billingOCC, IssueInvDate = DateTime.Now, IssueInvFlag = true, BillingTypeCode = strBillingTypeCode, BillingAmount = decBillingAmount, BillingStartDate = dtBillingStartDate, BillingEndDate = dtBillingEndDate, PaymentMethod = billingBasic[0].PaymentMethod, PaymentStatus = ((billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_AUTO_TRANSFER || billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_CREDIT_CARD_TRANSFER) ? PaymentStatus.C_PAYMENT_STATUS_DETAIL_AUTO_CREDIT : PaymentStatus.C_PAYMENT_STATUS_DETAIL_BANK_COLLECT), AutoTransferDate = autoTransferDate, StartOperationDate = billingBasic[0].StartOperationDate }; IRentralContractHandler rentalContralHandler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; List <dtTbt_RentalContractBasicForView> dtRentalContract = rentalContralHandler.GetTbt_RentalContractBasicForView(contractCode); if (dtRentalContract.Count > 0) { billingDetail.ContractOCC = dtRentalContract[0].LastOCC; } else { ISaleContractHandler saleHandler = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; List <tbt_SaleBasic> dtSaleBasic = saleHandler.GetTbt_SaleBasic(contractCode, null, true); if (dtSaleBasic != null && dtSaleBasic.Count > 0) { billingDetail.ContractOCC = dtSaleBasic[0].OCC; } } billingDetail.ForceIssueFlag = false; // CREATE ! billingDetail_manage = this.ManageBillingDetail(billingDetail); } // CREATE Invoice tbt_Invoice newInvoice = new tbt_Invoice() { AutoTransferDate = autoTransferDate, BillingTargetCode = billingBasic[0].BillingTargetCode, BillingTypeCode = billingDetail.BillingTypeCode, InvoicePaymentStatus = ((billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_AUTO_TRANSFER || billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_CREDIT_CARD_TRANSFER) ? PaymentStatus.C_PAYMENT_STATUS_INV_AUTO_CREDIT : PaymentStatus.C_PAYMENT_STATUS_INV_BANK_COLLECT), IssueInvFlag = true, PaymentMethod = billingBasic[0].PaymentMethod, IssueInvDate = changeDate, }; // CREATE ! List <tbt_BillingDetail> billingDetailList = new List <tbt_BillingDetail>(); billingDetailList.Add(billingDetail_manage); this.ManageInvoiceByCommand(newInvoice, billingDetailList, false); } else if (iChangeDate <= iLastBillingDate) { var invoice_betweenChangeDate = this.GetInvoiceOfChangeDate(contractCode, billingOCC, changeDate); string[] statusList = { PaymentStatus.C_PAYMENT_STATUS_INV_BANK_COLLECT, PaymentStatus.C_PAYMENT_STATUS_INV_AUTO_CREDIT, PaymentStatus.C_PAYMENT_STATUS_FAIL_AUTO_INV_BANK, PaymentStatus.C_PAYMENT_STATUS_FAIL_NOTE_INV_BANK, PaymentStatus.C_PAYMENT_STATUS_FAIL_CHEQUE_INV_BANK, PaymentStatus.C_PAYMENT_STATUS_COUNTER_BAL }; if (invoice_betweenChangeDate.Count > 0 && statusList.Contains(invoice_betweenChangeDate[0].InvoicePaymentStatus)) { // Cancel Invoice !! var header = GetTbt_Invoice(invoice_betweenChangeDate[0].InvoiceNo, null); // null mean Lastest InvoiceOCC List <tbt_BillingDetail> detail = new List <tbt_BillingDetail>(); if (header.Count > 0) { detail = this.GetTbt_BillingDetailOfInvoice(header[0].InvoiceNo, header[0].InvoiceOCC); this.UpdateInvoicePaymentStatus(header[0], detail, PaymentStatus.C_PAYMENT_STATUS_CANCEL); } } } } if (callerObject != ProcessID.C_PROCESS_ID_MANAGE_BILLING_BASIC_CANCEL) { // Create billing history tbt_MonthlyBillingHistory billingHistory = new tbt_MonthlyBillingHistory() { ContractCode = contractCode, BillingOCC = billingOCC, MonthlyBillingAmount = monthlyBillingAmount, BillingStartDate = changeDate }; this.CreateMonthlyBillingHistory(billingHistory); } return(billingAdjustOnNextPeriod); }
public ActionResult CMS130() { string strContractCode = ""; string strOCC = ""; try { CMS130_ScreenParameter param = GetScreenObject <CMS130_ScreenParameter>(); strContractCode = param.ContractCode; strOCC = param.OCC; } catch { } /* ----- Set grobal variable for javascript side ---- */ ViewBag.strContractCode = strContractCode; CommonUtil c = new CommonUtil(); strContractCode = c.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); List <dtTbt_RentalContractBasicForView> vw_dtRentalContract = new List <dtTbt_RentalContractBasicForView>(); List <dtTbt_RentalSecurityBasicForView> vw_dtRentalSecurity = new List <dtTbt_RentalSecurityBasicForView>(); ViewBag.Currency = CommonValue.CURRENCY_UNIT; string dateFormat = "dd-MMM-yyyy"; string numberFormat = "N0"; string floatNumberFormat = "N2"; // default ViewBag ViewBag.chkFire_monitoring = false; ViewBag.chkCrime_prevention = false; ViewBag.chkEmergency_report = false; ViewBag.chkFacility_monitoring = false; ViewBag.chkOut_of_regulation_document_usage_flag = false; try { ICommonHandler handlerComm = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <string> lsFieldNames = new List <string>(); lsFieldNames.Add(MiscType.C_RENTAL_CHANGE_TYPE); lsFieldNames.Add(MiscType.C_CHANGE_NAME_REASON_TYPE); lsFieldNames.Add(MiscType.C_REASON_TYPE); lsFieldNames.Add(MiscType.C_STOP_CANCEL_REASON_TYPE); lsFieldNames.Add(MiscType.C_MA_TARGET_PROD_TYPE); lsFieldNames.Add(MiscType.C_MA_TYPE); lsFieldNames.Add(MiscType.C_MA_FEE_TYPE); lsFieldNames.Add(MiscType.C_NUM_OF_DATE); lsFieldNames.Add(MiscType.C_OPERATION_TYPE); lsFieldNames.Add(MiscType.C_INSURANCE_TYPE); lsFieldNames.Add(MiscType.C_DOC_AUDIT_RESULT); lsFieldNames.Add(MiscType.C_RENTAL_INSTALL_TYPE); lsFieldNames.Add(MiscType.C_CHANGE_REASON_TYPE); // Get Misc type List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames); // Rental IRentralContractHandler handler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler; List <dtTbt_RentalContractBasicForView> dtRentalContract = handler.GetTbt_RentalContractBasicForView(strContractCode); List <dtTbt_RentalSecurityBasicForView> dtRentalSecurity = new List <dtTbt_RentalSecurityBasicForView>(); List <dtTbt_RentalOperationTypeListForView> dtRentalOperation = new List <dtTbt_RentalOperationTypeListForView>(); ICommonHandler comHand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>() { new doMiscTypeCode() { FieldName = MiscType.C_CURRENCT, ValueCode = "%" } }).ToList(); if (dtRentalContract.Count > 0) { // Get related data dtRentalSecurity = handler.GetTbt_RentalSecurityBasicForView(strContractCode, (CommonUtil.IsNullOrEmpty(strOCC) == false ? strOCC : dtRentalContract[0].LastOCC)); dtRentalOperation = handler.GetTbt_RentalOperationTypeListForView(strContractCode, (dtRentalSecurity.Count > 0 ? dtRentalSecurity[0].OCC : strOCC)); for (int i = 0; i < dtRentalSecurity.Count(); i++) { dtRentalSecurity[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies); } //Check Currency if (dtRentalSecurity[0].NormalContractFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].NormalContractFee = dtRentalSecurity[0].NormalContractFeeUsd; } if (dtRentalSecurity[0].OrderContractFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].OrderContractFee = dtRentalSecurity[0].OrderContractFeeUsd; } if (dtRentalSecurity[0].NormalInstallFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].NormalInstallFee = dtRentalSecurity[0].NormalInstallFeeUsd; } if (dtRentalSecurity[0].OrderInstallFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].OrderInstallFee = dtRentalSecurity[0].OrderInstallFeeUsd; } if (dtRentalSecurity[0].NewBldMgmtCostCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].NewBldMgmtCost = dtRentalSecurity[0].NewBldMgmtCostUsd; } if (dtRentalSecurity[0].ContractFeeOnStopCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].ContractFeeOnStop = dtRentalSecurity[0].ContractFeeOnStopUsd; } if (dtRentalSecurity[0].InsuranceCoverageAmountCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].InsuranceCoverageAmount = dtRentalSecurity[0].InsuranceCoverageAmountUsd; } if (dtRentalSecurity[0].MonthlyInsuranceFeeCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].MonthlyInsuranceFee = dtRentalSecurity[0].MonthlyInsuranceFeeUsd; } if (dtRentalSecurity[0].MaintenanceFee1CurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].MaintenanceFee1 = dtRentalSecurity[0].MaintenanceFee1Usd; } if (dtRentalSecurity[0].AdditionalFee1CurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].AdditionalFee1 = dtRentalSecurity[0].AdditionalFee1Usd; } if (dtRentalSecurity[0].AdditionalFee2CurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].AdditionalFee2 = dtRentalSecurity[0].AdditionalFee2Usd; } if (dtRentalSecurity[0].AdditionalFee3CurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].AdditionalFee3 = dtRentalSecurity[0].AdditionalFee3Usd; } if (dtRentalSecurity[0].OrderInstallFee_ApproveContractCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].OrderInstallFee_ApproveContract = dtRentalSecurity[0].OrderInstallFee_ApproveContractUsd; } if (dtRentalSecurity[0].OrderInstallFee_CompleteInstallCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].OrderInstallFee_CompleteInstall = dtRentalSecurity[0].OrderInstallFee_CompleteInstallUsd; } if (dtRentalSecurity[0].OrderInstallFee_StartServiceCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].OrderInstallFee_StartService = dtRentalSecurity[0].OrderInstallFee_StartServiceUsd; } if (dtRentalSecurity[0].InstallFeePaidBySECOMCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].InstallFeePaidBySECOM = dtRentalSecurity[0].InstallFeePaidBySECOMUsd; } if (dtRentalSecurity[0].InstallFeeRevenueBySECOMCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { dtRentalSecurity[0].InstallFeeRevenueBySECOM = dtRentalSecurity[0].InstallFeeRevenueBySECOMUsd; } /* ----- Set grobal variable for javascript side ---- */ ViewBag.strOCC = (dtRentalSecurity.Count > 0 ? dtRentalSecurity[0].OCC : strOCC); // Select language vw_dtRentalContract = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalContractBasicForView, dtTbt_RentalContractBasicForView>(dtRentalContract, "Quo_OfficeName", "Con_OfficeName", "Op_OfficeName"); vw_dtRentalSecurity = CommonUtil.ConvertObjectbyLanguage <dtTbt_RentalSecurityBasicForView, dtTbt_RentalSecurityBasicForView>(dtRentalSecurity, "ProductName", "DocumentName", "DocumentNoName", "SalesMan1_EmpFirstName", "SalesMan1_EmpFirstName", "SalesMan1_EmpLastName", "SalesMan2_EmpFirstName", "SalesMan2_EmpLastName", "SalesSupport_EmpFirstName", "SalesSupport_EmpLastName", "Alm_EmpFirstName", "Alm_EmpLastName", "NegStaff1_EmpFirstName", "NegStaff1_EmpLastName", "NegStaff2_EmpFirstName", "NegStaff2_EmpLastName", "CompStaff_EmpFirstName", "CompStaff_EmpLastName", "Planner_EmpFirstName", "Planner_EmpLastName", "PlanChecker_EmpFirstName", "PlanChecker_EmpLastName", "PlanApprover_EmpFirstName", "PlanApprover_EmpLastName" ); /**** Convert code to short format *****/ // vw_dtRentalContract foreach (var item in vw_dtRentalContract) { // contractcode item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); item.OldContractCode = c.ConvertContractCode(item.OldContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); item.CounterBalanceOriginContractCode = c.ConvertContractCode(item.CounterBalanceOriginContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); // customercode item.ContractTargetCustCode = c.ConvertCustCode(item.ContractTargetCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT); item.RealCustomerCustCode = c.ConvertCustCode(item.RealCustomerCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT); // sitecode item.SiteCode = c.ConvertSiteCode(item.SiteCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } // vw_dtRentalSecurity foreach (var item in vw_dtRentalSecurity) { // contractcode item.ContractCode = c.ConvertContractCode(item.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); // quotation target code item.QuotationTargetCode = c.ConvertQuotationTargetCode(item.QuotationTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } if (vw_dtRentalContract.Count > 0) { /* ----- Set grobal variable for javascript side ---- */ ViewBag.ProductTypeCode = vw_dtRentalContract[0].ProductTypeCode; ViewBag.ContractTargetCode = vw_dtRentalContract[0].ContractTargetCustCode; ViewBag.RealCustomerCode = vw_dtRentalContract[0].RealCustomerCustCode; ViewBag.SiteCode = vw_dtRentalContract[0].SiteCode; ViewBag.ServiceTypeCode = vw_dtRentalContract[0].ServiceTypeCode; ViewBag.SiteCodeList = dtRentalContract[0].SiteCode; // for parameter of generate link function ; ViewBag.ContractCode = vw_dtRentalContract[0].ContractCode; // for parameter of generate link function ; ViewBag.txtContractCode = vw_dtRentalContract[0].ContractCode; ViewBag.txtUserCode = vw_dtRentalContract[0].UserCode; ViewBag.lnkCustomerCodeC = vw_dtRentalContract[0].ContractTargetCustCode; ViewBag.lnkCustomerCodeR = vw_dtRentalContract[0].RealCustomerCustCode; ViewBag.lnkSiteCode = vw_dtRentalContract[0].SiteCode; ViewBag.txtContractNameEng = vw_dtRentalContract[0].CustFullNameEN_Cust; // ContractTargetFullNameEN ViewBag.txtContractAddrEng = vw_dtRentalContract[0].AddressFullEN_Cust; ViewBag.txtSiteNameEng = vw_dtRentalContract[0].SiteNameEN_Site; ViewBag.txtSiteAddrEng = vw_dtRentalContract[0].AddressFullEN_Site; ViewBag.txtContractNameLocal = vw_dtRentalContract[0].CustFullNameLC_Cust; // ContractTargetFullNameLC ViewBag.txtContractAddrLocal = vw_dtRentalContract[0].AddressFullLC_Cust; ViewBag.txtSiteNameLocal = vw_dtRentalContract[0].SiteNameLC_Site; ViewBag.txtSiteAddrLocal = vw_dtRentalContract[0].AddressFullLC_Site; ViewBag.txtContactPoint = CommonUtil.IsNullOrEmpty(vw_dtRentalContract[0].ContactPoint) == true ? "-" : vw_dtRentalContract[0].ContactPoint; //ViewBag.txtContactPoint = vw_dtRentalContract[0].ContactPoint; // ViewBag.chkOut_of_regulation_document_usage_flag = vw_dtRentalContract[0].IrregurationDocUsageFlag != null ? vw_dtRentalContract[0].IrregurationDocUsageFlag.Value : false; ViewBag.txtAttachImportanceFlag = vw_dtRentalContract[0].SpecialCareFlag; } } // RentalSecurityBasicForView (RSB) if (vw_dtRentalSecurity.Count > 0) { /* ----- Set grobal variable for javascript side ---- */ ViewBag.QuotationTargetCode = vw_dtRentalSecurity[0].QuotationTargetCode; ViewBag.QuotationAlphabet = vw_dtRentalSecurity[0].QuotationAlphabet; ViewBag.InstallationSlipNo = vw_dtRentalSecurity[0].InstallationSlipNo; // OCC ViewBag.txtOccurrence = vw_dtRentalSecurity[0].OCC; // Product information ViewBag.txtContractFee = vw_dtRentalSecurity[0].TextTransferOrderContractFee; //ViewBag.txtContractFee = vw_dtRentalSecurity[0].OrderContractFee != null ? vw_dtRentalSecurity[0].OrderContractFee.Value.ToString(floatNumberFormat) : "-"; ViewBag.txtChange_operation_date = (vw_dtRentalSecurity[0].ChangeImplementDate != null ? vw_dtRentalSecurity[0].ChangeImplementDate.Value.ToString(dateFormat) : "-"); ViewBag.txtStopFee = vw_dtRentalSecurity[0].TextTransferContractFeeOnStop; //ViewBag.txtStopFee = vw_dtRentalSecurity[0].ContractFeeOnStop != null ? vw_dtRentalSecurity[0].ContractFeeOnStop.Value.ToString(floatNumberFormat) : "-"; ViewBag.txtSecurity_type_code = vw_dtRentalSecurity[0].SecurityTypeCode; ViewBag.txtProduct = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ProductCode, vw_dtRentalSecurity[0].ProductName); string strChangeTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_RENTAL_CHANGE_TYPE, vw_dtRentalSecurity[0].ChangeType); ViewBag.txtChange_type = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ChangeType, strChangeTypeDisplayValue); string strDisvplayValue = ""; if (vw_dtRentalSecurity[0].ChangeType == "24" || vw_dtRentalSecurity[0].ChangeType == "35") { strDisvplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_CHANGE_NAME_REASON_TYPE, vw_dtRentalSecurity[0].ChangeNameReasonType); ViewBag.txtReason = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ChangeNameReasonType, strDisvplayValue); } else if (vw_dtRentalSecurity[0].ChangeType == "21") { strDisvplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_CHANGE_REASON_TYPE, vw_dtRentalSecurity[0].ChangeReasonType); ViewBag.txtReason = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].ChangeReasonType, strDisvplayValue); } else if (vw_dtRentalSecurity[0].ChangeType == "31" || vw_dtRentalSecurity[0].ChangeType == "32" || vw_dtRentalSecurity[0].ChangeType == "33" || vw_dtRentalSecurity[0].ChangeType == "34" || vw_dtRentalSecurity[0].ChangeType == "36" || vw_dtRentalSecurity[0].ChangeType == "38" || vw_dtRentalSecurity[0].ChangeType == "39" ) { strDisvplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_STOP_CANCEL_REASON_TYPE, vw_dtRentalSecurity[0].StopCancelReasonType); ViewBag.txtReason = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].StopCancelReasonType, strDisvplayValue); } else { ViewBag.txtReason = "-"; } ViewBag.txtNegotiation_staff_1 = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].NegotiationStaffEmpNo1, string.Format("{0} {1}", vw_dtRentalSecurity[0].NegStaff1_EmpFirstName, vw_dtRentalSecurity[0].NegStaff1_EmpLastName)); ViewBag.txtNegotiation_staff_2 = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].NegotiationStaffEmpNo2, string.Format("{0} {1}", vw_dtRentalSecurity[0].NegStaff2_EmpFirstName, vw_dtRentalSecurity[0].NegStaff2_EmpLastName)); ViewBag.txtApprove_no1 = vw_dtRentalSecurity[0].ApproveNo1; ViewBag.txtApprove_no2 = vw_dtRentalSecurity[0].ApproveNo2; ViewBag.txtChange_operation_register_date = (vw_dtRentalSecurity[0].CompleteChangeOperationDate != null ? vw_dtRentalSecurity[0].CompleteChangeOperationDate.Value.ToString(dateFormat) : "-"); ViewBag.txtChange_operation_registrant = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].CompleteChangeOperationEmpNo, string.Format("{0} {1}", vw_dtRentalSecurity[0].CompStaff_EmpFirstName, vw_dtRentalSecurity[0].CompStaff_EmpLastName)); ViewBag.txtSecurity_memo = vw_dtRentalSecurity[0].SecurityMemo; // Alam provide service type ViewBag.chkFire_monitoring = (vw_dtRentalSecurity[0].FireMonitorFlag != null ? vw_dtRentalSecurity[0].FireMonitorFlag.Value : false); ViewBag.chkCrime_prevention = (vw_dtRentalSecurity[0].CrimePreventFlag != null ? vw_dtRentalSecurity[0].CrimePreventFlag.Value : false); ViewBag.chkEmergency_report = (vw_dtRentalSecurity[0].EmergencyReportFlag != null ? vw_dtRentalSecurity[0].EmergencyReportFlag.Value : false); ViewBag.chkFacility_monitoring = (vw_dtRentalSecurity[0].FacilityMonitorFlag != null ? vw_dtRentalSecurity[0].FacilityMonitorFlag.Value : false); // section: insurance information string strInsuranceTypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_INSURANCE_TYPE, vw_dtRentalSecurity[0].InsuranceTypeCode); ViewBag.txtInsuranceType = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].InsuranceTypeCode, strInsuranceTypeDisplayValue); ViewBag.txtInsurance_coverage_amount = vw_dtRentalSecurity[0].TextTransferInsuranceCoverageAmount; //ViewBag.txtInsurance_coverage_amount = (vw_dtRentalSecurity[0].InsuranceCoverageAmount != null ? vw_dtRentalSecurity[0].InsuranceCoverageAmount.Value.ToString(floatNumberFormat) : "-"); ViewBag.txtMonthly_insurance_fee = vw_dtRentalSecurity[0].TextTransferMonthlyInsuranceFee; //ViewBag.txtMonthly_insurance_fee = (vw_dtRentalSecurity[0].MonthlyInsuranceFee != null ? vw_dtRentalSecurity[0].MonthlyInsuranceFee.Value.ToString(floatNumberFormat) : "-"); // section: contract document information string strDocAuditResultDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_DOC_AUDIT_RESULT, vw_dtRentalSecurity[0].DocAuditResult); ViewBag.txtDocument_audit_result = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].DocAuditResult, strDocAuditResultDisplayValue); ViewBag.txtContract_document_type = vw_dtRentalSecurity[0].DocumentName; // section: future date information ViewBag.txtExpected_resume_service_date = vw_dtRentalSecurity[0].ExpectedResumeDate != null ? vw_dtRentalSecurity[0].ExpectedResumeDate.Value.ToString(dateFormat) : "-"; ViewBag.txtReturn_date_to_original_fee = vw_dtRentalSecurity[0].ReturnToOriginalFeeDate != null ? vw_dtRentalSecurity[0].ReturnToOriginalFeeDate.Value.ToString(dateFormat) : "-"; // section: quotaion information ViewBag.lnkQuotationCode = (CommonUtil.IsNullOrEmpty(vw_dtRentalSecurity[0].QuotationTargetCode) == true || CommonUtil.IsNullOrEmpty(vw_dtRentalSecurity[0].QuotationAlphabet) == true) ? string.Empty : (string.Format("{0}-{1}", vw_dtRentalSecurity[0].QuotationTargetCode, vw_dtRentalSecurity[0].QuotationAlphabet)); ViewBag.txtPlan_code = vw_dtRentalSecurity[0].PlanCode; ViewBag.txtQuatationNo = vw_dtRentalContract[0].QuotationNo; ViewBag.txtPlan_approving_date = vw_dtRentalSecurity[0].PlanApproveDate != null ? vw_dtRentalSecurity[0].PlanApproveDate.Value.ToString(dateFormat) : "-"; ViewBag.txtPlan_approver = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].PlanApproverEmpNo, string.Format("{0} {1}", vw_dtRentalSecurity[0].PlanApprover_EmpFirstName , vw_dtRentalSecurity[0].PlanApprover_EmpLastName)); ViewBag.txtNormal_contract_fee = vw_dtRentalSecurity[0].TextTransferNormalContractFee; //ViewBag.txtNormal_contract_fee = vw_dtRentalSecurity[0].NormalContractFee != null ? vw_dtRentalSecurity[0].NormalContractFee.Value.ToString(floatNumberFormat) : "-"; ViewBag.txtOutsourcing_fee = vw_dtRentalSecurity[0].TextTransferMaintenanceFee1; //ViewBag.txtOutsourcing_fee = vw_dtRentalSecurity[0].MaintenanceFee1 != null ? vw_dtRentalSecurity[0].MaintenanceFee1.Value.ToString(floatNumberFormat) : "-"; ViewBag.txtAdditional_contract_fee1 = vw_dtRentalSecurity[0].TextTransferAdditionalFee1; ViewBag.txtAdditional_contract_fee2 = vw_dtRentalSecurity[0].TextTransferAdditionalFee2; ViewBag.txtAdditional_contract_fee3 = vw_dtRentalSecurity[0].TextTransferAdditionalFee3; //ViewBag.txtAdditional_contract_fee1 = vw_dtRentalSecurity[0].AdditionalFee1 != null ? vw_dtRentalSecurity[0].AdditionalFee1.Value.ToString(floatNumberFormat) : "-"; //ViewBag.txtAdditional_contract_fee2 = vw_dtRentalSecurity[0].AdditionalFee2 != null ? vw_dtRentalSecurity[0].AdditionalFee2.Value.ToString(floatNumberFormat) : "-"; //ViewBag.txtAdditional_contract_fee3 = vw_dtRentalSecurity[0].AdditionalFee3 != null ? vw_dtRentalSecurity[0].AdditionalFee3.Value.ToString(floatNumberFormat) : "-"; // section: installation information string strIntallationtypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_RENTAL_INSTALL_TYPE, vw_dtRentalSecurity[0].InstallationTypeCode); ViewBag.txtInstallation_type = CommonUtil.TextCodeName(vw_dtRentalSecurity[0].InstallationTypeCode, strIntallationtypeDisplayValue); ViewBag.txtComplete_installation_date = vw_dtRentalSecurity[0].InstallationCompleteDate != null ? vw_dtRentalSecurity[0].InstallationCompleteDate.Value.ToString(dateFormat) : "-"; ViewBag.txtNormal_installation_fee = vw_dtRentalSecurity[0].TextTransferNormalInstallFee; //ViewBag.txtNormal_installation_fee = vw_dtRentalSecurity[0].NormalInstallFee != null ? vw_dtRentalSecurity[0].NormalInstallFee.Value.ToString(floatNumberFormat) : "-"; ViewBag.txtOrder_installation_fee = vw_dtRentalSecurity[0].TextTransferOrderInstallFee; //ViewBag.txtOrder_installation_fee = vw_dtRentalSecurity[0].OrderInstallFee != null ? vw_dtRentalSecurity[0].OrderInstallFee.Value.ToString(floatNumberFormat) : "-"; ViewBag.txtOrder_installation_fee_Approve_contract = vw_dtRentalSecurity[0].TextTransferOrderInstallFee_ApproveContract; //ViewBag.txtOrder_installation_fee_Approve_contract = vw_dtRentalSecurity[0].OrderInstallFee_ApproveContract != null ? vw_dtRentalSecurity[0].OrderInstallFee_ApproveContract.Value.ToString(floatNumberFormat) : "-"; ViewBag.txtOrder_installation_fee_Complete_installation = vw_dtRentalSecurity[0].TextTransferOrderInstallFee_CompleteInstall; //ViewBag.txtOrder_installation_fee_Complete_installation = vw_dtRentalSecurity[0].OrderInstallFee_CompleteInstall != null ? vw_dtRentalSecurity[0].OrderInstallFee_CompleteInstall.Value.ToString(floatNumberFormat) : "-"; ViewBag.txtOrder_installation_fee_Start_service = vw_dtRentalSecurity[0].TextTransferOrderInstallFee_StartService; //ViewBag.txtOrder_installation_fee_Start_service = vw_dtRentalSecurity[0].OrderInstallFee_StartService != null ? vw_dtRentalSecurity[0].OrderInstallFee_StartService.Value.ToString(floatNumberFormat) : "-"; ViewBag.txtSECOM_payment = vw_dtRentalSecurity[0].TextTransferInstallFeePaidBySECOM; //ViewBag.txtSECOM_payment = vw_dtRentalSecurity[0].InstallFeePaidBySECOM != null ? vw_dtRentalSecurity[0].InstallFeePaidBySECOM.Value.ToString(floatNumberFormat) : "-"; ViewBag.txtSECOM_revenue = vw_dtRentalSecurity[0].TextTransferInstallFeeRevenueBySECOM; //ViewBag.txtSECOM_revenue = vw_dtRentalSecurity[0].InstallFeeRevenueBySECOM != null ? vw_dtRentalSecurity[0].InstallFeeRevenueBySECOM.Value.ToString(floatNumberFormat) : "-"; ViewBag.lnkInstallation_slip_no = vw_dtRentalSecurity[0].InstallationSlipNo; } //dtRentalOperation if (dtRentalOperation.Count > 0) { //string strOperationtypeDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_OPERATION_TYPE, dtRentalOperation[0].OperationTypeCode ); //ViewBag.txtOperation_type = CommonUtil.TextCodeName(dtRentalOperation[0].OperationTypeCode, strOperationtypeDisplayValue); List <string> lstOperationType = new List <string>(); foreach (var item in dtRentalOperation) { lstOperationType.Add(item.OperationTypeCode); } ViewBag.chkOperationTypeList = lstOperationType.ToArray(); } return(View()); } catch (Exception ex) { ObjectResultData res = new ObjectResultData(); res.AddErrorMessage(ex); return(Json(res)); } }