///<summary> ///Purpose: /// Get site data /// ///Parameters: /// siteCode: S0000000014-0001 /// ///Expected: /// Refer to : "SECOM-AJIS-STC.MAP022-GetSite" sheet 'Expectation' ///</summary> public string Case3() { ISiteMasterHandler target = ServiceContainer.GetService <ISiteMasterHandler>() as ISiteMasterHandler; string siteCode = "S0000000014-0001"; string custCode = null; List <doSite> expected = new List <doSite>(); List <doSite> actual = null; //00007 001 10700 NULL 440065 NULL 440065 doSite site = new doSite(); site.SiteCode = "S0000000014-0001"; site.CustCode = "C0000000014"; site.SiteNo = "0001"; site.SiteNameEN = "B-QUIK CO.,LTD. (CARREFOUR RAMA 2 ROAD BRANCH)"; site.SiteNameLC = "บริษัท บี-ควิค จำกัด (สาขาคาร์ฟูร์ พระราม2)"; site.SECOMContactPerson = null; site.PersonInCharge = null; site.PhoneNo = null; site.BuildingUsageCode = "023"; site.AddressEN = "189/1 MOO 6"; site.AlleyEN = null; site.RoadEN = "RAMA 2"; site.SubDistrictEN = "SAMAE-DAM"; site.AddressFullEN = "189/1 MOO 6, RAMA 2, SAMAE-DAM, BANGKHUNTIEN, BANGKOK 10700"; site.AddressLC = "189/1 หมู่ 6"; site.AlleyLC = null; site.RoadLC = "พระราม 2"; site.SubDistrictLC = "แสมดำ"; site.AddressFullLC = "189/1 หมู่ 6 ถ.พระราม 2 แขวงแสมดำ เขตบางขุนเทียน จ.กรุงเทพมหานคร 10700"; site.DistrictCode = "00007"; site.ProvinceCode = "001"; site.ZipCode = "10700"; site.CreateDate = null; site.CreateBy = "440065"; site.UpdateDate = null; site.UpdateBy = "440065"; expected.Add(site); try { actual = target.GetSite(siteCode, custCode); } catch (ApplicationErrorException ex) { actual = null; } catch (Exception ex) { actual = null; } return(string.Format(RESULT_FORMAT, 3, expected[0].SiteCode, actual[0].SiteCode, CompareObjectList <doSite>(expected, actual, SITE_FIELD) ? "Pass" : "Fail")); }
///<summary> ///Purpose: /// Get site data when site code dose not exist /// ///Parameters: /// siteCode: S0000000014 /// ///Expected: /// MSG2006: "Customer code not found, S0000000014." ///</summary> public string Case2() { ISiteMasterHandler target = ServiceContainer.GetService <ISiteMasterHandler>() as ISiteMasterHandler; string siteCode = "S0000000014"; string custCode = null; string expected = "MSG2006"; string actual = null; try { target.GetSite(siteCode, custCode); } 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> /// Get entire draft sale contract /// </summary> /// <param name="cond"></param> /// <param name="mode"></param> /// <param name="procType"></param> /// <returns></returns> public doDraftSaleContractData GetEntireDraftSaleContract(doDraftSaleContractCondition cond, doDraftSaleContractData.SALE_CONTRACT_MODE mode, doDraftSaleContractData.PROCESS_TYPE procType) { try { doDraftSaleContractData saleData = null; if (mode == doDraftSaleContractData.SALE_CONTRACT_MODE.QUOTATION) { CommonUtil cmm = new CommonUtil(); doGetQuotationDataCondition qcond = new doGetQuotationDataCondition(); qcond.QuotationTargetCode = cond.QuotationTargetCodeLong; qcond.Alphabet = cond.Alphabet; qcond.ServiceTypeCode = ServiceType.C_SERVICE_TYPE_SALE; if (procType == doDraftSaleContractData.PROCESS_TYPE.NEW) { qcond.TargetCodeTypeCode = TargetCodeType.C_TARGET_CODE_TYPE_QTN_CODE; } else { qcond.TargetCodeTypeCode = TargetCodeType.C_TARGET_CODE_TYPE_CONTRACT_CODE; } qcond.ContractFlag = true; IQuotationHandler qhandler = ServiceContainer.GetService <IQuotationHandler>() as IQuotationHandler; dsQuotationData qData = qhandler.GetQuotationData(qcond); if (qData != null) { #region Check Authority bool hasAuthority = false; List <OfficeDataDo> officeLst = CommonUtil.dsTransData.dtOfficeData; if (qData.dtTbt_QuotationTarget != null && officeLst.Count > 0) { foreach (OfficeDataDo office in officeLst) { if (office.OfficeCode == qData.dtTbt_QuotationTarget.QuotationOfficeCode || office.OfficeCode == qData.dtTbt_QuotationTarget.OperationOfficeCode) { hasAuthority = true; break; } } } if (hasAuthority == false) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0063); } #endregion saleData = new doDraftSaleContractData(); if (qData.dtTbt_QuotationTarget.UpdateDate != null) { saleData.LastUpdateDateQuotationData = qData.dtTbt_QuotationTarget.UpdateDate.Value; } #region Set Draft Sale Contract saleData.doTbt_DraftSaleContract = CommonUtil.CloneObject <tbt_QuotationBasic, tbt_DraftSaleContract>(qData.dtTbt_QuotationBasic); if (saleData.doTbt_DraftSaleContract != null) { saleData.doTbt_DraftSaleContract.QuotationTargetCode = cond.QuotationTargetCodeLong; saleData.doTbt_DraftSaleContract.Alphabet = cond.Alphabet; saleData.doTbt_DraftSaleContract.ProductTypeCode = qData.dtTbt_QuotationTarget.ProductTypeCode; saleData.doTbt_DraftSaleContract.BranchNameEN = qData.dtTbt_QuotationTarget.BranchNameEN; saleData.doTbt_DraftSaleContract.BranchNameLC = qData.dtTbt_QuotationTarget.BranchNameLC; saleData.doTbt_DraftSaleContract.BranchAddressEN = qData.dtTbt_QuotationTarget.BranchAddressEN; saleData.doTbt_DraftSaleContract.BranchAddressLC = qData.dtTbt_QuotationTarget.BranchAddressLC; saleData.doTbt_DraftSaleContract.PurchaserMemo = qData.dtTbt_QuotationTarget.ContractTargetMemo; saleData.doTbt_DraftSaleContract.RealCustomerMemo = qData.dtTbt_QuotationTarget.RealCustomerMemo; foreach (tbt_QuotationCustomer cust in qData.dtTbt_QuotationCustomer) { if (cust.CustPartTypeCode == CustPartType.C_CUST_PART_TYPE_CONTRACT_TARGET) { saleData.doTbt_DraftSaleContract.PurchaserCustCode = cust.CustCode; } else if (cust.CustPartTypeCode == CustPartType.C_CUST_PART_TYPE_REAL_CUST) { saleData.doTbt_DraftSaleContract.RealCustomerCustCode = cust.CustCode; } } if (qData.dtTbt_QuotationSite != null) { saleData.doTbt_DraftSaleContract.SiteCode = qData.dtTbt_QuotationSite.SiteCode; } saleData.doTbt_DraftSaleContract.ConnectTargetCode = qData.dtTbt_QuotationBasic.SaleOnlineContractCode; if (CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.ConnectTargetCode) == false) { saleData.doTbt_DraftSaleContract.ConnectionFlag = FlagType.C_FLAG_ON; } else { saleData.doTbt_DraftSaleContract.ConnectionFlag = FlagType.C_FLAG_OFF; } saleData.doTbt_DraftSaleContract.NormalProductPriceCurrencyType = qData.dtTbt_QuotationBasic.ProductPriceCurrencyType; saleData.doTbt_DraftSaleContract.NormalProductPrice = qData.dtTbt_QuotationBasic.ProductPrice; saleData.doTbt_DraftSaleContract.NormalProductPriceUsd = qData.dtTbt_QuotationBasic.ProductPriceUsd; saleData.doTbt_DraftSaleContract.NormalInstallFeeCurrencyType = qData.dtTbt_QuotationBasic.InstallationFeeCurrencyType; saleData.doTbt_DraftSaleContract.NormalInstallFee = qData.dtTbt_QuotationBasic.InstallationFee; saleData.doTbt_DraftSaleContract.NormalInstallFeeUsd = qData.dtTbt_QuotationBasic.InstallationFeeUsd; if (CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.NormalProductPrice) == false || CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.NormalInstallFee) == false) { saleData.doTbt_DraftSaleContract.NormalSalePrice = 0; //if (CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.NormalProductPrice) == false) // saleData.doTbt_DraftSaleContract.NormalSalePrice += saleData.doTbt_DraftSaleContract.NormalProductPrice; //if (CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.NormalInstallFee) == false) // saleData.doTbt_DraftSaleContract.NormalSalePrice += saleData.doTbt_DraftSaleContract.NormalInstallFee; } saleData.doTbt_DraftSaleContract.NormalSpecialItemPrice = 0; saleData.doTbt_DraftSaleContract.NormalOtherProdPrice = 0; saleData.doTbt_DraftSaleContract.NormalOtherInstallFee = 0; //saleData.doTbt_DraftSaleContract.OrderProductPrice = qData.dtTbt_QuotationBasic.ProductPrice; //saleData.doTbt_DraftSaleContract.OrderInstallFee = qData.dtTbt_QuotationBasic.InstallationFee; //saleData.doTbt_DraftSaleContract.OrderSalePrice = saleData.doTbt_DraftSaleContract.NormalSalePrice; saleData.doTbt_DraftSaleContract.OrderProductPriceCurrencyType = qData.dtTbt_QuotationBasic.ProductPriceCurrencyType; saleData.doTbt_DraftSaleContract.OrderProductPrice = null; saleData.doTbt_DraftSaleContract.OrderProductPriceUsd = null; saleData.doTbt_DraftSaleContract.OrderInstallFeeCurrencyType = qData.dtTbt_QuotationBasic.InstallationFeeCurrencyType; saleData.doTbt_DraftSaleContract.OrderInstallFee = null; saleData.doTbt_DraftSaleContract.OrderInstallFeeUsd = null; saleData.doTbt_DraftSaleContract.OrderSalePrice = null; saleData.doTbt_DraftSaleContract.TotalSaleBilingAmt_Agreed = 0; saleData.doTbt_DraftSaleContract.QuotationStaffEmpNo = qData.dtTbt_QuotationTarget.QuotationStaffEmpNo; saleData.doTbt_DraftSaleContract.QuotationOfficeCode = qData.dtTbt_QuotationTarget.QuotationOfficeCode; saleData.doTbt_DraftSaleContract.OperationOfficeCode = qData.dtTbt_QuotationTarget.OperationOfficeCode; saleData.doTbt_DraftSaleContract.AcquisitionTypeCode = qData.dtTbt_QuotationTarget.AcquisitionTypeCode; saleData.doTbt_DraftSaleContract.IntroducerCode = qData.dtTbt_QuotationTarget.IntroducerCode; saleData.doTbt_DraftSaleContract.MotivationTypeCode = qData.dtTbt_QuotationTarget.MotivationTypeCode; saleData.doTbt_DraftSaleContract.ApproveNo1 = null; saleData.doTbt_DraftSaleContract.ApproveNo2 = null; saleData.doTbt_DraftSaleContract.ApproveNo3 = null; saleData.doTbt_DraftSaleContract.ApproveNo4 = null; saleData.doTbt_DraftSaleContract.ApproveNo5 = null; saleData.doTbt_DraftSaleContract.CreateBy = null; saleData.doTbt_DraftSaleContract.CreateDate = null; saleData.doTbt_DraftSaleContract.UpdateBy = null; saleData.doTbt_DraftSaleContract.UpdateDate = null; List <tbt_DraftSaleContract> contractLst = this.GetTbt_DraftSaleContract(cond.QuotationTargetCodeLong); if (contractLst.Count > 0) { saleData.doTbt_DraftSaleContract.CreateBy = contractLst[0].CreateBy; saleData.doTbt_DraftSaleContract.CreateDate = contractLst[0].CreateDate; saleData.doTbt_DraftSaleContract.UpdateBy = contractLst[0].UpdateBy; saleData.doTbt_DraftSaleContract.UpdateDate = contractLst[0].UpdateDate; } if (saleData.doTbt_DraftSaleContract.ProductTypeCode == ProductType.C_PROD_TYPE_ONLINE) { ISaleContractHandler shandler = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler; if (qData.dtTbt_QuotationBasic.SaleOnlineContractCode != null) { doSaleContractData doSaleContract = shandler.GetSaleContractData(qData.dtTbt_QuotationBasic.SaleOnlineContractCode, null); if (doSaleContract != null) { saleData.doTbt_DraftSaleContract.SecurityAreaFrom = doSaleContract.dtTbt_SaleBasic.SecurityAreaFrom; saleData.doTbt_DraftSaleContract.SecurityAreaTo = doSaleContract.dtTbt_SaleBasic.SecurityAreaTo; } } } } #endregion #region Set Draft Sale Customer MiscTypeMappingList cmLst = new MiscTypeMappingList(); ICustomerMasterHandler chandler = ServiceContainer.GetService <ICustomerMasterHandler>() as ICustomerMasterHandler; foreach (tbt_QuotationCustomer cust in qData.dtTbt_QuotationCustomer) { doCustomerWithGroup icust = null; if (cust.CustCode != null) { List <doCustomerWithGroup> lst = chandler.GetCustomerWithGroup(cust.CustCode); if (lst.Count > 0) { icust = lst[0]; } } else { icust = CommonUtil.CloneObject <tbt_QuotationCustomer, doCustomerWithGroup>(cust); if (icust != null) { icust.CustomerGroupData = new List <dtCustomeGroupData>(); } IMasterHandler mhandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler; if (icust.BusinessTypeCode != null) { List <tbm_BusinessType> btLst = mhandler.GetTbm_BusinessType(); foreach (tbm_BusinessType bt in btLst) { if (bt.BusinessTypeCode == icust.BusinessTypeCode) { icust.BusinessTypeName = bt.BusinessTypeName; break; } } } if (icust.RegionCode != null) { List <tbm_Region> rLst = mhandler.GetTbm_Region(); foreach (tbm_Region r in rLst) { if (r.RegionCode == icust.RegionCode) { icust.Nationality = r.Nationality; break; } } } if (icust.CustTypeCode != null) { cmLst.AddMiscType(icust); } } if (icust != null) { if (cust.CustPartTypeCode == CustPartType.C_CUST_PART_TYPE_CONTRACT_TARGET) { saleData.doPurchaserCustomer = icust; } else if (cust.CustPartTypeCode == CustPartType.C_CUST_PART_TYPE_REAL_CUST) { saleData.doRealCustomer = icust; } } } ICommonHandler cmmhandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; cmmhandler.MiscTypeMappingList(cmLst); #endregion #region Set Draft Sale Site if (qData.dtTbt_QuotationSite != null) { if (qData.dtTbt_QuotationSite.SiteCode != null) { ISiteMasterHandler shandler = ServiceContainer.GetService <ISiteMasterHandler>() as ISiteMasterHandler; List <doSite> lst = shandler.GetSite(qData.dtTbt_QuotationSite.SiteCode, null); if (lst.Count > 0) { saleData.doSite = lst[0]; } } else { saleData.doSite = CommonUtil.CloneObject <tbt_QuotationSite, doSite>(qData.dtTbt_QuotationSite); IMasterHandler mhandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler; List <tbm_BuildingUsage> blst = mhandler.GetTbm_BiuldingUsage(); foreach (tbm_BuildingUsage b in blst) { if (b.BuildingUsageCode == saleData.doSite.BuildingUsageCode) { saleData.doSite.BuildingUsageName = b.BuildingUsageName; break; } } } } #endregion #region Set Draft Sale Instrument saleData.doTbt_DraftSaleInstrument = new List <tbt_DraftSaleInstrument>(); if (qData.dtTbt_QuotationInstrumentDetails != null) { foreach (tbt_QuotationInstrumentDetails inst in qData.dtTbt_QuotationInstrumentDetails) { tbt_DraftSaleInstrument dInst = new tbt_DraftSaleInstrument(); dInst.QuotationTargetCode = cond.QuotationTargetCodeLong; dInst.InstrumentCode = inst.InstrumentCode; dInst.InstrumentQty = inst.InstrumentQty; dInst.InstrumentTypeCode = InstrumentType.C_INST_TYPE_GENERAL; if (CommonUtil.IsNullOrEmpty(dInst.InstrumentQty) == false) { if (CommonUtil.IsNullOrEmpty(inst.AddQty) == false) { dInst.InstrumentQty += inst.AddQty; } if (CommonUtil.IsNullOrEmpty(inst.RemoveQty) == false) { dInst.InstrumentQty -= inst.RemoveQty; } } saleData.doTbt_DraftSaleInstrument.Add(dInst); } } if (qData.dtTbt_QuotationFacilityDetails != null) { foreach (tbt_QuotationFacilityDetails facility in qData.dtTbt_QuotationFacilityDetails) { tbt_DraftSaleInstrument dInst = new tbt_DraftSaleInstrument(); dInst.QuotationTargetCode = cond.QuotationTargetCode; dInst.InstrumentCode = facility.FacilityCode; dInst.InstrumentQty = facility.FacilityQty; dInst.InstrumentTypeCode = InstrumentType.C_INST_TYPE_MONITOR; saleData.doTbt_DraftSaleInstrument.Add(dInst); } } if (saleData.doTbt_DraftSaleInstrument.Count > 0) { InstrumentMappingList instMappingLst = new InstrumentMappingList(); instMappingLst.AddInstrument(saleData.doTbt_DraftSaleInstrument.ToArray()); IInstrumentMasterHandler ihandler = ServiceContainer.GetService <IInstrumentMasterHandler>() as IInstrumentMasterHandler; ihandler.InstrumentListMapping(instMappingLst); } #endregion #region Set Draft Relation Type saleData.doTbt_RelationType = new List <tbt_RelationType>(); /* -- Sale Online --- */ if (CommonUtil.IsNullOrEmpty(qData.dtTbt_QuotationBasic.SaleOnlineContractCode) == false) { saleData.doTbt_RelationType.Add(new tbt_RelationType() { RelatedContractCode = qData.dtTbt_QuotationBasic.SaleOnlineContractCode, RelatedOCC = qData.dtTbt_QuotationBasic.LastOccNo, OCC = null, RelationType = RelationType.C_RELATION_TYPE_SALE }); } #endregion } } else if (mode == doDraftSaleContractData.SALE_CONTRACT_MODE.DRAFT || mode == doDraftSaleContractData.SALE_CONTRACT_MODE.APPROVE) { saleData = new doDraftSaleContractData(); #region Set Draft Sale Contract List <tbt_DraftSaleContract> contractLst = this.GetTbt_DraftSaleContract(cond.QuotationTargetCodeLong); if (contractLst.Count > 0) { saleData.doTbt_DraftSaleContract = contractLst[0]; } else { return(null); } #endregion #region Check Authority bool hasAuthority = false; List <OfficeDataDo> officeLst = CommonUtil.dsTransData.dtOfficeData; if (saleData.doTbt_DraftSaleContract != null && officeLst.Count > 0) { foreach (OfficeDataDo office in officeLst) { if (office.OfficeCode == saleData.doTbt_DraftSaleContract.QuotationOfficeCode || office.OfficeCode == saleData.doTbt_DraftSaleContract.OperationOfficeCode) { hasAuthority = true; break; } } } if (hasAuthority == false) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0063); } #endregion #region Check Contract status if (mode == doDraftSaleContractData.SALE_CONTRACT_MODE.DRAFT && saleData.doTbt_DraftSaleContract.DraftSaleContractStatus != ApprovalStatus.C_APPROVE_STATUS_RETURNED) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3100); } else if (mode == doDraftSaleContractData.SALE_CONTRACT_MODE.APPROVE) { if (saleData.doTbt_DraftSaleContract.DraftSaleContractStatus == ApprovalStatus.C_APPROVE_STATUS_APPROVED) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3246); } else if (saleData.doTbt_DraftSaleContract.DraftSaleContractStatus == ApprovalStatus.C_APPROVE_STATUS_REJECTED) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3244); } else if (saleData.doTbt_DraftSaleContract.DraftSaleContractStatus == ApprovalStatus.C_APPROVE_STATUS_RETURNED) { throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3245); } } #endregion #region Set Draft Sale E-mail saleData.doTbt_DraftSaleEmail = this.GetTbt_DraftSaleEmail(cond.QuotationTargetCodeLong); if (saleData.doTbt_DraftSaleEmail != null) { IEmployeeMasterHandler empHandler = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler; List <tbm_Employee> emps = new List <tbm_Employee>(); foreach (tbt_DraftSaleEmail email in saleData.doTbt_DraftSaleEmail) { emps.Add(new tbm_Employee() { EmpNo = email.ToEmpNo }); } List <tbm_Employee> empList = empHandler.GetEmployeeList(emps); if (empList.Count > 0) { foreach (tbt_DraftSaleEmail email in saleData.doTbt_DraftSaleEmail) { foreach (tbm_Employee emp in empList) { if (emp.EmpNo == email.ToEmpNo) { email.EmailAddress = emp.EmailAddress; break; } } } } } #endregion #region Set Draft Sale Instrument saleData.doTbt_DraftSaleInstrument = this.GetTbt_DraftSaleInstrument(cond.QuotationTargetCodeLong); if (saleData.doTbt_DraftSaleInstrument.Count > 0) { InstrumentMappingList instMappingLst = new InstrumentMappingList(); instMappingLst.AddInstrument(saleData.doTbt_DraftSaleInstrument.ToArray()); IInstrumentMasterHandler ihandler = ServiceContainer.GetService <IInstrumentMasterHandler>() as IInstrumentMasterHandler; ihandler.InstrumentListMapping(instMappingLst); } #endregion #region Set Draft Sale Billing Target saleData.doTbt_DraftSaleBillingTarget = this.GetTbt_DraftSaleBillingTarget(cond.QuotationTargetCodeLong); #endregion #region Set Contract Customer ICustomerMasterHandler custhandler = ServiceContainer.GetService <ICustomerMasterHandler>() as ICustomerMasterHandler; if (CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.PurchaserCustCode) == false) { List <doCustomerWithGroup> custLst = custhandler.GetCustomerWithGroup(saleData.doTbt_DraftSaleContract.PurchaserCustCode); if (custLst.Count > 0) { saleData.doPurchaserCustomer = custLst[0]; } } if (CommonUtil.IsNullOrEmpty(saleData.doTbt_DraftSaleContract.RealCustomerCustCode) == false) { List <doCustomerWithGroup> custLst = custhandler.GetCustomerWithGroup(saleData.doTbt_DraftSaleContract.RealCustomerCustCode); if (custLst.Count > 0) { saleData.doRealCustomer = custLst[0]; } } #endregion #region Set Site ISiteMasterHandler shandler = ServiceContainer.GetService <ISiteMasterHandler>() as ISiteMasterHandler; List <doSite> siteLst = shandler.GetSite(saleData.doTbt_DraftSaleContract.SiteCode, saleData.doTbt_DraftSaleContract.RealCustomerCustCode); if (siteLst.Count > 0) { saleData.doSite = siteLst[0]; } #endregion doGetQuotationDataCondition qcond = new doGetQuotationDataCondition(); qcond.QuotationTargetCode = cond.QuotationTargetCodeLong; qcond.Alphabet = saleData.doTbt_DraftSaleContract.Alphabet;//cond.Alphabet; qcond.ServiceTypeCode = ServiceType.C_SERVICE_TYPE_SALE; if (saleData.doTbt_DraftSaleContract.SaleProcessType == SaleProcessType.C_SALE_PROCESS_TYPE_ADD_SALE) { qcond.TargetCodeTypeCode = TargetCodeType.C_TARGET_CODE_TYPE_CONTRACT_CODE; } else { qcond.TargetCodeTypeCode = TargetCodeType.C_TARGET_CODE_TYPE_QTN_CODE; } qcond.ContractFlag = true; IQuotationHandler qhandler = ServiceContainer.GetService <IQuotationHandler>() as IQuotationHandler; dsQuotationData qData = qhandler.GetQuotationData(qcond); if (qData != null) { if (qData.dtTbt_QuotationTarget.UpdateDate != null) { saleData.LastUpdateDateQuotationData = qData.dtTbt_QuotationTarget.UpdateDate.Value; } } } if (saleData != null) { if (saleData.doTbt_DraftSaleContract != null) { #region Set Product Name IProductMasterHandler mhandler = ServiceContainer.GetService <IProductMasterHandler>() as IProductMasterHandler; List <View_tbm_Product> pLst = mhandler.GetTbm_ProductByLanguage( saleData.doTbt_DraftSaleContract.ProductCode, saleData.doTbt_DraftSaleContract.ProductTypeCode); if (pLst.Count > 0) { saleData.doTbt_DraftSaleContract.ProductName = pLst[0].ProductName; } #endregion #region Set Misc Name MiscTypeMappingList miscLst = new MiscTypeMappingList(); miscLst.AddMiscType(saleData.doTbt_DraftSaleContract); miscLst.AddMiscType(saleData.doTbt_DraftSaleInstrument.ToArray()); ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; chandler.MiscTypeMappingList(miscLst); #endregion #region Set Employee Name EmployeeMappingList empLst = new EmployeeMappingList(); empLst.AddEmployee(saleData.doTbt_DraftSaleContract); IEmployeeMasterHandler emphandler = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler; emphandler.EmployeeListMapping(empLst); #endregion } } return(saleData); } catch (Exception) { throw; } }
public ActionResult CMS220() { CMS220_ScreenParameter cond = new CMS220_ScreenParameter(); try { cond = GetScreenObject <CMS220_ScreenParameter>(); } catch { } // Conver to long format CommonUtil c = new CommonUtil(); cond.ContractCode = c.ConvertContractCode(cond.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); cond.ContractTargetCode = c.ConvertCustCode(cond.ContractTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG); cond.PurchaserCustCode = c.ConvertCustCode(cond.PurchaserCustCode, CommonUtil.CONVERT_TYPE.TO_LONG); cond.RealCustomerCode = c.ConvertCustCode(cond.RealCustomerCode, CommonUtil.CONVERT_TYPE.TO_LONG); cond.SiteCode = c.ConvertSiteCode(cond.SiteCode, CommonUtil.CONVERT_TYPE.TO_LONG); // Keep data to ViewBag ViewBag.isShowContractTarget = false; ViewBag.isShowPurchaser = false; ViewBag.isShowRealCustomer = false; ViewBag.isShowSite = false; string CustomerCode = string.Empty; string OCC = string.Empty; string ContractCode = string.Empty; // Assign value of CSCustCode , RCCustCode if (!CommonUtil.IsNullOrEmpty(cond.ContractTargetCode)) { cond.CSCustCode = cond.ContractTargetCode; } else if (!CommonUtil.IsNullOrEmpty(cond.PurchaserCustCode)) { cond.CSCustCode = cond.PurchaserCustCode; } else if (!CommonUtil.IsNullOrEmpty(cond.RealCustomerCode)) { cond.RCCustCode = cond.RealCustomerCode; } // View mode if (cond.Mode == "Contract") { ViewBag.isShowContractTarget = true; ContractCode = cond.ContractCode; OCC = cond.OCC; CustomerCode = cond.ContractTargetCode; } else if (cond.Mode == "Purchaser") { ViewBag.isShowPurchaser = true; ContractCode = cond.ContractCode; OCC = cond.OCC; CustomerCode = cond.PurchaserCustCode; } else if (cond.Mode == "Customer") { ViewBag.isShowRealCustomer = true; ContractCode = "NotSpecify"; OCC = "NotSpecify"; CustomerCode = cond.RealCustomerCode; } else if (cond.Mode == "Site") { ViewBag.isShowSite = true; } try { ICommonHandler handlerComm = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <string> lsFieldNames = new List <string>(); lsFieldNames.Add(MiscType.C_CONTRACT_SIGNER_TYPE); lsFieldNames.Add(MiscType.C_CUST_STATUS); lsFieldNames.Add(MiscType.C_CUST_TYPE); lsFieldNames.Add(MiscType.C_FINANCIAL_MARKET_TYPE); List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames); //IViewContractHandler handler = ServiceContainer.GetService<IViewContractHandler>() as IViewContractHandler; //List<dtChangedCustHistList2> list = handler.GetChangedCustHistList2(cond); // ******* ICustomerMasterHandler handlerCM = ServiceContainer.GetService <ICustomerMasterHandler>() as ICustomerMasterHandler; IViewContractHandler handlerVC = ServiceContainer.GetService <IViewContractHandler>() as IViewContractHandler; ISiteMasterHandler handlerSM = ServiceContainer.GetService <ISiteMasterHandler>() as ISiteMasterHandler; List <doCustomer> listCustomer = new List <doCustomer>(); List <doSite> listSite = new List <doSite>(); List <dtContractSignerType> listSigner = new List <dtContractSignerType>(); listCustomer = handlerCM.GetCustomer(CustomerCode); listSigner = handlerVC.GetContractSignerType(MiscType.C_CONTRACT_SIGNER_TYPE, ContractCode, OCC); listSite = handlerSM.GetSite(cond.SiteCode, null); // select language listCustomer = CommonUtil.ConvertObjectbyLanguage <doCustomer, doCustomer>(listCustomer, "BusinessTypeName", "Nationality", "CustStatusName", "CustTypeName", "FinancialMaketTypeName" ); // select language listSite = CommonUtil.ConvertObjectbyLanguage <doSite, doSite>(listSite, "BuildingUsageName"); // select language listSigner = CommonUtil.ConvertObjectbyLanguage <dtContractSignerType, dtContractSignerType>(listSigner, "ContractSignerTypeName"); // Convert code to short format foreach (doCustomer item in listCustomer) { item.CustCode = c.ConvertCustCode(item.CustCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } foreach (var item in listSite) { item.SiteCode = c.ConvertSiteCode(item.SiteCode, CommonUtil.CONVERT_TYPE.TO_SHORT); } if (listCustomer.Count > 0) { if (!CommonUtil.IsNullOrEmpty(cond.ContractTargetCode)) { ViewBag.txtCTCustomerCode = listCustomer[0].CustCode; if (listSigner.Count > 0) { ViewBag.txtCTContractSignerType = CommonUtil.TextCodeName(listSigner[0].ContractSignerTypeCode, listSigner[0].ContractSignerTypeName); } ViewBag.txtCTCustomerStatus = CommonUtil.TextCodeName(listCustomer[0].CustStatus, listCustomer[0].CustStatusName); ViewBag.txtCTCustomerType = CommonUtil.TextCodeName(listCustomer[0].CustTypeCode, listCustomer[0].CustTypeName); ViewBag.txtCTName_English = listCustomer[0].CustFullNameEN; ViewBag.txtCTAddress_English = listCustomer[0].AddressFullEN; ViewBag.txtCTName_Local = listCustomer[0].CustFullNameLC; ViewBag.txtCTAddress_Local = listCustomer[0].AddressFullLC; ViewBag.txtCTRepresentativePersonName = listCustomer[0].RepPersonName; ViewBag.txtCTContactPersonName = listCustomer[0].ContactPersonName; ViewBag.txtCTNationality = listCustomer[0].Nationality; ViewBag.txtCTTelephoneNo = listCustomer[0].PhoneNo; ViewBag.txtCTFinancialMarketType = CommonUtil.TextCodeName(listCustomer[0].FinancialMarketTypeCode, listCustomer[0].FinancialMaketTypeName); ViewBag.txtCTBusinessType = listCustomer[0].BusinessTypeName; ViewBag.txtCTIDTax = listCustomer[0].IDNo; ViewBag.txtCTSECOMContactPerson = listCustomer[0].SECOMContactPerson; ViewBag.txtCTURL = listCustomer[0].URL; // ** Old version //ViewBag.txtCTBranchName_English = listCustomer[0].BranchNameEN; //ViewBag.txtCTBranchAddress_English = listCustomer[0].BranchAddressEN; //ViewBag.txtCTBranchName_Local = listCustomer[0].BranchNameLC; //ViewBag.txtCTBranchAddress_Local = listCustomer[0].BranchAddressLC; } if (!CommonUtil.IsNullOrEmpty(cond.PurchaserCustCode)) { ViewBag.txtPUCustomerCode = listCustomer[0].CustCode; if (listSigner.Count > 0) { ViewBag.txtPUContractSignerType = CommonUtil.TextCodeName(listSigner[0].ContractSignerTypeCode, listSigner[0].ContractSignerTypeName); } ViewBag.txtPUCustomerStatus = CommonUtil.TextCodeName(listCustomer[0].CustStatus, listCustomer[0].CustStatusName); ViewBag.txtPUCustomerType = CommonUtil.TextCodeName(listCustomer[0].CustTypeCode, listCustomer[0].CustTypeName); ViewBag.txtPUName_English = listCustomer[0].CustFullNameEN; ViewBag.txtPUAddress_English = listCustomer[0].AddressFullEN; ViewBag.txtPUName_Local = listCustomer[0].CustFullNameLC; ViewBag.txtPUAddress_Local = listCustomer[0].AddressFullLC; ViewBag.txtPURepresentativePersonName = listCustomer[0].RepPersonName; ViewBag.txtPUContactPersonName = listCustomer[0].ContactPersonName; ViewBag.txtPUNationality = listCustomer[0].Nationality; ViewBag.txtPUTelephoneNo = listCustomer[0].PhoneNo; ViewBag.txtPUFinancialMarketType = CommonUtil.TextCodeName(listCustomer[0].FinancialMarketTypeCode, listCustomer[0].FinancialMaketTypeName); ViewBag.txtPUBusinessType = listCustomer[0].BusinessTypeName; ViewBag.txtPUIDTax = listCustomer[0].IDNo; ViewBag.txtPUSECOMContactPerson = listCustomer[0].SECOMContactPerson; ViewBag.txtPUURL = listCustomer[0].URL; // ** Old version //ViewBag.txtPUBranchName_English = listCustomer[0].BranchNameEN; //ViewBag.txtPUBranchAddress_English = listCustomer[0].BranchAddressEN; //ViewBag.txtPUBranchName_Local = listCustomer[0].BranchNameLC; //ViewBag.txtPUBranchAddress_Local = listCustomer[0].BranchAddressLC; } if (!CommonUtil.IsNullOrEmpty(cond.RealCustomerCode)) { ViewBag.txtRCCustomerCode = listCustomer[0].CustCode; ViewBag.txtRCCustomerStatus = CommonUtil.TextCodeName(listCustomer[0].CustStatus, listCustomer[0].CustStatusName); ViewBag.txtRCCustomerType = CommonUtil.TextCodeName(listCustomer[0].CustTypeCode, listCustomer[0].CustTypeName); ViewBag.txtRCName_English = listCustomer[0].CustFullNameEN; ViewBag.txtRCAddress_English = listCustomer[0].AddressFullEN; ViewBag.txtRCName_Local = listCustomer[0].CustFullNameLC; ViewBag.txtRCAddress_Local = listCustomer[0].AddressFullLC; ViewBag.txtRCRepresentativePersonName = listCustomer[0].RepPersonName; ViewBag.txtRCContactPersonName = listCustomer[0].ContactPersonName; ViewBag.txtRCNationality = listCustomer[0].Nationality; ViewBag.txtRCTelephoneNo = listCustomer[0].PhoneNo; ViewBag.txtRCFinancialMarketType = CommonUtil.TextCodeName(listCustomer[0].FinancialMarketTypeCode, listCustomer[0].FinancialMaketTypeName); ViewBag.txtRCBusinessType = listCustomer[0].BusinessTypeName; ViewBag.txtRCIDTax = listCustomer[0].IDNo; ViewBag.txtRCSECOMContactPerson = listCustomer[0].SECOMContactPerson; ViewBag.txtRCURL = listCustomer[0].URL; //** old version //ViewBag.txtRCBranchName_English = listCustomer[0].BranchNameEN; //ViewBag.txtRCBranchAddress_English = listCustomer[0].BranchAddressEN; //ViewBag.txtRCBranchName_Local = listCustomer[0].BranchNameLC; //ViewBag.txtRCBranchAddress_Local = listCustomer[0].BranchAddressLC; } } if (listSite.Count > 0) { if (!CommonUtil.IsNullOrEmpty(cond.SiteCode)) { ViewBag.txtSiteCode = listSite[0].SiteCode; ViewBag.txtSiteName_English = listSite[0].SiteNameEN; ViewBag.txtSiteAddress_English = listSite[0].AddressFullEN; ViewBag.txtSiteName_Local = listSite[0].SiteNameLC; ViewBag.txtSiteAddress_Local = listSite[0].AddressFullLC; ViewBag.txtSiteTelephoneNo = listSite[0].PhoneNo; ViewBag.txtSiteUsage = listSite[0].BuildingUsageName; ViewBag.txtAttachImportanceFlag = listSite[0].SpecialCareFlag; } } } catch (Exception ex) { ObjectResultData res = new ObjectResultData(); res.AddErrorMessage(ex); return(Json(res)); } return(View()); }