/// <summary> /// Getting project information /// </summary> /// <param name="strProjectCode"></param> /// <returns></returns> public dsProjectInfo GetProjectInfo(string strProjectCode) { ICustomerMasterHandler custhandler = ServiceContainer.GetService <ICustomerMasterHandler>() as ICustomerMasterHandler; IProjectHandler projecthandler = ServiceContainer.GetService <IProjectHandler>() as IProjectHandler; dsProjectInfo res = new dsProjectInfo(); var projRes = projecthandler.GetTbt_Project(strProjectCode); if (projRes.Count == 1) { var projCust = projecthandler.GetTbt_ProjectPurchaserCustomerForView(strProjectCode); res.dtProjectPurcheser = new dtProjectPurcheser(); if (projCust.Count == 1) { if (string.IsNullOrEmpty(projCust[0].CustCode)) { res.dtProjectPurcheser.CustCode = ""; res.dtProjectPurcheser.CustFullNameEN = projCust[0].CustFullNameEN; res.dtProjectPurcheser.CustFullNameLC = projCust[0].CustFullNameLC; } else { var custRes = custhandler.GetCustomer(projCust[0].CustCode); if (custRes.Count == 1) { res.dtProjectPurcheser.CustCode = projCust[0].CustCode; res.dtProjectPurcheser.CustFullNameEN = custRes[0].CustFullNameEN; res.dtProjectPurcheser.CustFullNameLC = custRes[0].CustFullNameLC; } } } res.tbt_Project = projRes; } return(res); }
/// <summary> /// If user input ContractCode or UserCode retrieve contract data from tbt_RentalContractBasic or tbt_SaleBasic.<br /> /// Else if user input ProjectCode retrieve project data from tbt_Project.<br /> /// Else if user input InvoiceNo get billing details of last invoice OCC. /// </summary> /// <param name="ContractCode"></param> /// <param name="UserCode"></param> /// <param name="InvoiceNo"></param> /// <param name="ProjectCode"></param> /// <returns></returns> public ActionResult CMS020_Retrive(string ContractCode, string UserCode, string InvoiceNo, string ProjectCode) { CommonUtil cm = new CommonUtil(); dtSearchBarData data = new dtSearchBarData(); ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING_DIALOG; List <string> list = new List <string>(); if (CommonUtil.IsNullOrEmpty(ContractCode) == false) { list.Add(ContractCode); } if (CommonUtil.IsNullOrEmpty(UserCode) == false) { list.Add(UserCode); } if (CommonUtil.IsNullOrEmpty(InvoiceNo) == false) { list.Add(InvoiceNo); } if (CommonUtil.IsNullOrEmpty(ProjectCode) == false) { list.Add(ProjectCode); } if (list.Count > 1) { // Input more than one criteria --> Retrun message res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0117); return(Json(res)); } else if (list.Count == 0) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0006); return(Json(res)); } try { // Case goto CMS190 if (CommonUtil.IsNullOrEmpty(ContractCode) == false || CommonUtil.IsNullOrEmpty(UserCode) == false) { dsContractData contractData = new dsContractData(); contractData = CMS020_RetrieveContract(ContractCode, UserCode); if (contractData.dtRCB == null && contractData.dtSB == null) { // Return message MSG0102 // This contract code does not exist. res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0133); return(Json(res)); } bool isRCBNull = true; if (contractData.dtRCB != null) { if (CommonUtil.IsNullOrEmpty(UserCode) == false && contractData.dtRCB.Count > 1) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0157); return(Json(res)); } else if (contractData.dtRCB.Count > 0) { data.ContractCode = cm.ConvertContractCode(contractData.dtRCB[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); data.ServiceType = contractData.dtRCB[0].ServiceTypeCode; data.Mode = "CMS190"; isRCBNull = false; } } if (isRCBNull == true) { if (contractData.dtSB != null) { if (contractData.dtSB.Count > 0) { data.ContractCode = cm.ConvertContractCode(contractData.dtSB[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT); data.ServiceType = contractData.dtSB[0].ServiceTypeCode; data.Mode = "CMS190"; } } } //if (data.ContractCode != null) // CommonUtil.dsTransData.dtCommonSearch.ContractCode = data.ContractCode; } else if (CommonUtil.IsNullOrEmpty(ProjectCode) == false) { IProjectHandler pHandler = ServiceContainer.GetService <IProjectHandler>() as IProjectHandler; List <tbt_Project> lst = pHandler.GetTbt_Project(ProjectCode); if (lst.Count == 0) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0091, new string[] { ProjectCode }); return(Json(res)); } data.ProjectCode = ProjectCode; data.Mode = "CTS260"; //CommonUtil.dsTransData.dtCommonSearch.ProjectCode = ProjectCode; } else if (CommonUtil.IsNullOrEmpty(InvoiceNo) == false) { IViewBillingHandler bHandler = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler; List <dtViewBillingDetailListOfLastInvoiceOCC> lst = bHandler.GetViewBillingDetailListOfLastInvoiceOCC(InvoiceNo, null, null, null, null); if (lst.Count == 0) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0150, new string[] { InvoiceNo }); return(Json(res)); } data.InvoiceNo = InvoiceNo; data.Mode = "CMS450"; //CommonUtil.dsTransData.dtCommonSearch.InvoiceNo = InvoiceNo; } } catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); } return(Json(data)); }