/// <summary> /// Generate subcontractor combobox /// </summary> /// <param name="helper"></param> /// <param name="id"></param> /// <param name="firstElement"></param> /// <param name="attribute"></param> /// <returns></returns> public static MvcHtmlString SubContractorComboBoxWithFirstElement(this HtmlHelper helper, string id, string firstElement, object attribute = null) { ICommonContractHandler hand = ServiceContainer.GetService <ICommonContractHandler>() as ICommonContractHandler; List <tbm_SubContractor> lst = hand.GetTbm_SubContractorData(null); //MvcHtmlString mvc = CommonUtil.CommonComboBox<tbm_SubContractor>(id, lst, "SubContractorCodeName", "SubContractorCode", attribute); return(CommonUtil.CommonComboBoxWithCustomFirstElement <tbm_SubContractor>(id, lst, "SubContractorCodeName", "SubContractorCode", firstElement, attribute)); }
//Add by Nutnicha C. 01/09/2011 /// <summary> /// Generate subcontractor combobox /// </summary> /// <param name="helper"></param> /// <param name="id"></param> /// <param name="attribute"></param> /// <returns></returns> public static MvcHtmlString SubContractorComboBox(this HtmlHelper helper, string id, object attribute = null) { ICommonContractHandler hand = ServiceContainer.GetService <ICommonContractHandler>() as ICommonContractHandler; List <tbm_SubContractor> lst = hand.GetTbm_SubContractorData(null); MvcHtmlString mvc = CommonUtil.CommonComboBox <tbm_SubContractor>(id, lst, "SubContractorCodeName", "SubContractorCode", attribute); return(mvc); }
/// <summary> /// To edit draft sale contract data /// </summary> /// <param name="draft"></param> /// <returns></returns> public bool EditDraftSaleContractData(doDraftSaleContractData draft) { try { UpdateTbt_DraftSaleContract(draft.doTbt_DraftSaleContract); UpdateTbt_DraftSaleBillingTarget(draft.doTbt_DraftSaleContract.QuotationTargetCode, draft.doTbt_DraftSaleBillingTarget); UpdateTbt_DraftSaleInstrument(draft.doTbt_DraftSaleContract.QuotationTargetCode, draft.doTbt_DraftSaleInstrument); UpdateTbt_DraftSaleEmail(draft.doTbt_DraftSaleContract.QuotationTargetCode, draft.doTbt_DraftSaleEmail); ICommonContractHandler chandler = ServiceContainer.GetService <ICommonContractHandler>() as ICommonContractHandler; chandler.UpdateTbt_RelationType(draft.doTbt_DraftSaleContract.QuotationTargetCode, draft.doTbt_RelationType); return(true); } catch (Exception) { throw; } }
/// <summary> /// To create draft sale contract data /// </summary> /// <param name="draft"></param> /// <returns></returns> public bool CreateDraftSaleContractData(doDraftSaleContractData draft) { try { InsertTbt_DraftSaleContract(draft.doTbt_DraftSaleContract); InsertTbt_DraftSaleBillingTarget(draft.doTbt_DraftSaleBillingTarget); InsertTbt_DraftSaleInstrument(draft.doTbt_DraftSaleInstrument); InsertTbt_DraftSaleEmail(draft.doTbt_DraftSaleEmail); ICommonContractHandler chandler = ServiceContainer.GetService <ICommonContractHandler>() as ICommonContractHandler; chandler.InsertTbt_RelationType(draft.doTbt_RelationType); return(true); } catch (Exception) { throw; } }
/// <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> /// To send notify email for change contract fee /// </summary> /// <param name="UserId"></param> /// <param name="BatchDate"></param> /// <returns></returns> public SECOM_AJIS.Common.Util.doBatchProcessResult SendNotifyEmailForChangeFee(string UserId, DateTime BatchDate) { SECOM_AJIS.Common.Util.doBatchProcessResult doResult = new SECOM_AJIS.Common.Util.doBatchProcessResult(); try { ILogHandler handLog = ServiceContainer.GetService <ILogHandler>() as ILogHandler; //1. Get list of unsent email List <tbt_ContractEmail> dtTbt_ContractEmail = this.GetUnsentNotifyEmail(); //2. For each unsent email in dtTbt_ContractEmail int failedItem = 0; int completdeItem = 0; foreach (tbt_ContractEmail email in dtTbt_ContractEmail) { //2.1 Prepare destination email //2.1.1 Get employee data of destination email IEmployeeMasterHandler handMaster = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler; List <tbm_Employee> dtEmployee = handMaster.GetTbm_Employee(email.ToEmpNo); //2.1.2 If dtEmployee is empty if (dtEmployee.Count <= 0) { handLog.WriteWindowLog(EventType.C_EVENT_TYPE_ERROR, (MessageUtil.GetMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3077, email.ToEmpNo)).Message, EventID.C_EVENT_ID_NOTIFY_EMAIL_ERROR); failedItem += 1; continue; } //2.1.3 Get default email if endDate is not empty String strEmailTo = (dtEmployee[0].EndDate != null) ? this.getEmailsOfDefaultDepartment() : dtEmployee[0].EmailAddress; //2.2 Prepare email object for sending doEmailProcess emailProc = new doEmailProcess(); emailProc.MailTo = strEmailTo; emailProc.MailFrom = email.EmailFrom; emailProc.Subject = email.EmailSubject; emailProc.Message = email.EmailContent; //2.3 Send email //2.3.1 Retry for 3 times while strStatus is still fails int retry = 0; do { try { ICommonHandler commonHand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; commonHand.SendMail(emailProc); break; } catch (Exception) { retry += 1; } } while (retry < 3); ICommonContractHandler comContractHand = ServiceContainer.GetService <ICommonContractHandler>() as ICommonContractHandler; if (retry == 3) { failedItem += 1; email.FailSendingCounter = (email.FailSendingCounter == null) ? 1 : email.FailSendingCounter + 1; email.UpdateBy = UserId; //Update to database comContractHand.UpdateTbt_ContractEmail(email); //Check the number of fail for reporting error if (email.FailSendingCounter >= 6 && email.FailSendingCounter % 3 == 0) { handLog.WriteWindowLog(EventType.C_EVENT_TYPE_ERROR, (MessageUtil.GetMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3078, strEmailTo)).Message, EventID.C_EVENT_ID_NOTIFY_EMAIL_ERROR); } } else { completdeItem += 1; //Delete sent email comContractHand.DeleteTbt_ContractEmail(email.ContractEmailID, UserId); } } //3. Prepare process result for returning doResult.Result = FlagType.C_FLAG_ON; doResult.Total = dtTbt_ContractEmail.Count; doResult.Complete = completdeItem; doResult.Failed = failedItem; } catch (Exception) { throw; } return(doResult); }
/// <summary> /// Register input data to database (BLS030) /// </summary> /// <param name="validData"></param> /// <returns></returns> public ActionResult BLS030_RegisterData(BLS030_ValidateData validData) { ObjectResultData res = new ObjectResultData(); ICommonHandler handlerCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; ICommonContractHandler commonContractHandler = ServiceContainer.GetService <ICommonContractHandler>() as ICommonContractHandler; IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler; CommonUtil comUtil = new CommonUtil(); try { if (handlerCommon.IsSystemSuspending()) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); return(Json(res)); } if (!CheckUserPermission(ScreenID.C_SCREEN_ID_REGIST_BILL_BASIC, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } BLS030_ScreenParameter sParam = GetScreenObject <BLS030_ScreenParameter>(); // === Business validate === List <doServiceProductTypeCode> lstContractServiceProductType = commonContractHandler.GetServiceProductTypeCode(sParam.ContractProjectCodeLong); List <doServiceProductTypeCode> lstProjectServiceProductType = commonContractHandler.GetServiceProductTypeCode(sParam.ContractProjectCodeLong); bool isContractCode = false; bool isProjectCode = false; if (lstContractServiceProductType.Count > 0 && lstProjectServiceProductType.Count > 0) { isContractCode = (string.IsNullOrEmpty(lstContractServiceProductType[0].ServiceTypeCode) == false); if (isContractCode == false) { isProjectCode = (string.IsNullOrEmpty(lstProjectServiceProductType[0].ServiceTypeCode) == false); } } //------ (1) if (isContractCode == false && isProjectCode == false) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0011, new string[] { "lblContractProjectCode" }, new string[] { "ContractCodeProjectCode" }); return(Json(res)); } //------ (2) var lst = billingHandler.GetTbt_BillingTargetForView(sParam.BillingClientCode + "-" + sParam.BillingTargetRunningNo, MiscType.C_CUST_TYPE); if (lst.Count == 0) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_BILLING, MessageUtil.MessageList.MSG6040, null, null); return(Json(res)); } //------ (1) + (2) var lstdoBillingBasic = billingHandler.GetBillingBasic(sParam.ContractProjectCodeLong, null, sParam.BillingClientCode + "-" + sParam.BillingTargetRunningNo, null, null, CurrencyUtil.C_CURRENCY_LOCAL, CurrencyUtil.C_CURRENCY_US); if (lstdoBillingBasic.Count > 0) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_BILLING, MessageUtil.MessageList.MSG6003, new string[] { comUtil.ConvertBillingCode(lstdoBillingBasic[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT) + "-" + lstdoBillingBasic[0].BillingOCC }, null); return(Json(res)); } using (TransactionScope scope = new TransactionScope()) { //=== Billing Basic === DataEntity.Billing.tbt_BillingBasic doBillingBasic2 = new DataEntity.Billing.tbt_BillingBasic() { ContractCode = sParam.ContractProjectCodeLong, BillingTargetCode = sParam.BillingClientCode + "-" + sParam.BillingTargetRunningNo, DebtTracingOfficeCode = sParam.doBillingTarget.BillingOfficeCode, PaymentMethod = sParam.PaymentMethod, SortingType = sParam.SortingType, StopBillingFlag = true, VATUnchargedFlag = false, BillingCycle = BillingCycle.C_BILLING_CYCLE_DEFAULT_ONETIME, CreditTerm = CreditTerm.C_CREDIT_TERM_DEFAULT, CalDailyFeeStatus = CalculationDailyFeeType.C_CALC_DAILY_FEE_TYPE_CALENDAR, ResultBasedMaintenanceFlag = false, // Narupon PreviousBillingTargetCode = sParam.BillingClientCode + "-" + sParam.BillingTargetRunningNo }; // CREATE !! string strBillingOCC = billingHandler.CreateBillingBasic(doBillingBasic2); if (sParam.PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_AUTO_TRANSFER) { //=== Auto Transfer === string strAccountNo = string.Empty; strAccountNo = string.IsNullOrEmpty(sParam.doAutoTransferBankAccount.AccountNo) ? string.Empty : sParam.doAutoTransferBankAccount.AccountNo.Replace("-", ""); tbt_AutoTransferBankAccount doTbt_AutoTransferBankAccount = new tbt_AutoTransferBankAccount() { ContractCode = sParam.ContractProjectCodeLong, BillingOCC = strBillingOCC, BankCode = sParam.doAutoTransferBankAccount.BankCode, BankBranchCode = sParam.doAutoTransferBankAccount.BankBranchCode, AccountNo = strAccountNo, // Edit Narupon W. 29/05/2012 AccountName = sParam.doAutoTransferBankAccount.AccountName, AccountType = sParam.doAutoTransferBankAccount.AccountType, AutoTransferDate = sParam.doAutoTransferBankAccount.AutoTransferDate }; List <tbt_AutoTransferBankAccount> doTbt_AutoTransferBankAccountList = new List <tbt_AutoTransferBankAccount>(); doTbt_AutoTransferBankAccountList.Add(doTbt_AutoTransferBankAccount); billingHandler.InsertTbt_AutoTransferBankAccountData(doTbt_AutoTransferBankAccountList); } else if (sParam.PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_CREDIT_CARD_TRANSFER) { //=== Credit Card === string strCreditCardNo = string.IsNullOrEmpty(sParam.doCreditCard.CreditCardNo) ? string.Empty : sParam.doCreditCard.CreditCardNo.Replace("-", ""); tbt_CreditCard doTbt_CreditCard = new tbt_CreditCard() { ContractCode = sParam.ContractProjectCodeLong, BillingOCC = strBillingOCC, CreditCardCompanyCode = sParam.doCreditCard.CreditCardCompanyCode, CreditCardType = sParam.doCreditCard.CreditCardType, CreditCardNo = strCreditCardNo, // Edit by Narupon W. 28/05/2012 CardName = sParam.doCreditCard.CardName, ExpMonth = sParam.doCreditCard.ExpMonth, ExpYear = sParam.doCreditCard.ExpYear }; List <tbt_CreditCard> doTbt_CreditCardList = new List <tbt_CreditCard>(); doTbt_CreditCardList.Add(doTbt_CreditCard); billingHandler.InsertTbt_CreditCard(doTbt_CreditCardList); } // === Billing Type Detail === if (sParam.doBillingTypeList != null) { foreach (tbt_BillingTypeDetail doBillingType in sParam.doBillingTypeList) { doBillingType.ContractCode = sParam.ContractProjectCodeLong; doBillingType.BillingOCC = strBillingOCC; doBillingType.IssueInvoiceFlag = true; doBillingType.ProductCode = null; doBillingType.ProductTypeCode = sParam.ProductTypeCode; if (doBillingType.BillingTypeCode == BillingType.C_BILLING_TYPE_SALE_PRODUCT_PRICE || doBillingType.BillingTypeCode == BillingType.C_BILLING_TYPE_SALE_PRICE || doBillingType.BillingTypeCode == BillingType.C_BILLING_TYPE_SALE_PRICE_DOWN || doBillingType.BillingTypeCode == BillingType.C_BILLING_TYPE_SALE_PRICE_PARTIAL) { // tt doBillingType.InvoiceDescriptionEN = doBillingType.InvoiceDescriptionEN; doBillingType.InvoiceDescriptionLC = doBillingType.InvoiceDescriptionLC; } else { // tt doBillingType.InvoiceDescriptionEN = null; doBillingType.InvoiceDescriptionLC = null; } billingHandler.CreateBillingTypeDetail(doBillingType); } } scope.Complete(); res.ResultData = true; } } catch (Exception ex) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(ex); } return(Json(res)); }
/// <summary> /// Validate input data before save to database (BLS030) /// </summary> /// <param name="validData"></param> /// <param name="ScreenData"></param> /// <param name="doTbt_AutoTransferBankAccount"></param> /// <param name="doTbt_CreditCard"></param> /// <returns></returns> public ActionResult BLS030_ValidateBeforeRegister(BLS030_ValidateData validData, BLS030_ScreenParameter ScreenData, tbt_AutoTransferBankAccount doTbt_AutoTransferBankAccount, tbt_CreditCard doTbt_CreditCard) { ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; ValidatorUtil validator = new ValidatorUtil(); CommonUtil comUtil = new CommonUtil(); res.ResultData = true; try { ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; if (chandler.IsSystemSuspending()) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); res.ResultData = false; return(Json(res)); } if (!CheckUserPermission(ScreenID.C_SCREEN_ID_REGIST_BILL_BASIC, FunctionID.C_FUNC_ID_OPERATE)) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); res.ResultData = false; return(Json(res)); } BLS030_ScreenParameter sParam = GetScreenObject <BLS030_ScreenParameter>(); sParam.AccountName = ScreenData.AccountName; sParam.CardName = ScreenData.CardName; sParam.PaymentMethod = ScreenData.PaymentMethod; sParam.SortingType = ScreenData.SortingType; //===================== Assign autotransfer data ======================= sParam.doAutoTransferBankAccount = new BLS030_doAutoTransferBankAccount(); sParam.doAutoTransferBankAccount.BankCode = doTbt_AutoTransferBankAccount.BankCode; sParam.doAutoTransferBankAccount.BankBranchCode = doTbt_AutoTransferBankAccount.BankBranchCode; sParam.doAutoTransferBankAccount.AccountNo = doTbt_AutoTransferBankAccount.AccountNo; sParam.doAutoTransferBankAccount.AccountName = doTbt_AutoTransferBankAccount.AccountName; sParam.doAutoTransferBankAccount.AccountType = doTbt_AutoTransferBankAccount.AccountType; sParam.doAutoTransferBankAccount.AutoTransferDate = doTbt_AutoTransferBankAccount.AutoTransferDate; //====================================================================== //===================== Assign Credit Card data ======================== sParam.doCreditCard = new BLS030_doCreditCard(); sParam.doCreditCard.CreditCardCompanyCode = doTbt_CreditCard.CreditCardCompanyCode; sParam.doCreditCard.CreditCardType = doTbt_CreditCard.CreditCardType; sParam.doCreditCard.CreditCardNo = doTbt_CreditCard.CreditCardNo; sParam.doCreditCard.CardName = doTbt_CreditCard.CardName; sParam.doCreditCard.ExpMonth = doTbt_CreditCard.ExpMonth; sParam.doCreditCard.ExpYear = doTbt_CreditCard.ExpYear; //====================================================================== ICommonContractHandler commonContractHandler = ServiceContainer.GetService <ICommonContractHandler>() as ICommonContractHandler; IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler; if (ModelState.IsValid == false) { ValidatorUtil.BuildErrorMessage(res, this); if (res.IsError) { res.ResultData = false; return(Json(res)); } } //================ Validate Business ====================== // Billing Type List if (sParam.doBillingTypeList == null || sParam.doBillingTypeList.Count == 0) { res.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_BILLING, MessageUtil.MessageList.MSG6005, null, null); res.ResultData = false; } if (sParam.PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_AUTO_TRANSFER && CommonUtil.IsNullOrEmpty(sParam.doAutoTransferBankAccount.AccountNo)) { res.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_BILLING, MessageUtil.MessageList.MSG6006, null, new string[] { "PaymentMethod" }); res.ResultData = false; } if (sParam.PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_CREDIT_CARD_TRANSFER && CommonUtil.IsNullOrEmpty(sParam.doCreditCard.CreditCardNo)) { res.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_BILLING, MessageUtil.MessageList.MSG6007, null, new string[] { "PaymentMethod" }); res.ResultData = false; } List <doServiceProductTypeCode> lstContractServiceProductType = commonContractHandler.GetServiceProductTypeCode(sParam.ContractProjectCodeLong); List <doServiceProductTypeCode> lstProjectServiceProductType = commonContractHandler.GetServiceProductTypeCode(sParam.ContractProjectCodeLong); bool isContractCode = false; bool isProjectCode = false; if (lstContractServiceProductType.Count > 0 && lstProjectServiceProductType.Count > 0) { isContractCode = (string.IsNullOrEmpty(lstContractServiceProductType[0].ServiceTypeCode) == false); if (isContractCode == false) { isProjectCode = (string.IsNullOrEmpty(lstProjectServiceProductType[0].ServiceTypeCode) == false); } } // ----- (1) if (isContractCode == false && isProjectCode == false) { res.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0011, new string[] { "lblContractProjectCode" }, new string[] { "ContractCodeProjectCode" }); res.ResultData = false; } // ----- (2) var billingTargetForView = billingHandler.GetTbt_BillingTargetForView(sParam.BillingClientCode + "-" + sParam.BillingTargetRunningNo, MiscType.C_CUST_TYPE); if (billingTargetForView.Count == 0) { res.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_BILLING, MessageUtil.MessageList.MSG6040, null, new string[] { "BillingTargetCode", "BillingTargetRunningNo" }); res.ResultData = false; } // ----- (1) + (2) var lstdoBillingBasic = billingHandler.GetBillingBasic(sParam.ContractProjectCodeLong, null, sParam.BillingClientCode + "-" + sParam.BillingTargetRunningNo, null, null, CurrencyUtil.C_CURRENCY_LOCAL, CurrencyUtil.C_CURRENCY_US); if (lstdoBillingBasic.Count > 0) { res.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_BILLING, MessageUtil.MessageList.MSG6003, new string[] { comUtil.ConvertBillingCode(lstdoBillingBasic[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT) + "-" + lstdoBillingBasic[0].BillingOCC }, new string[] { "ContractCodeProjectCode", "BillingTargetCode", "BillingTargetRunningNo" }); res.ResultData = false; } } catch (Exception ex) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.ResultData = false; res.AddErrorMessage(ex); } return(Json(res)); }
/// <summary> /// Retrieve billing basic data /// </summary> /// <param name="ContractProjectCodeShort"></param> /// <param name="BillingClientCode"></param> /// <param name="BillingTargetRunningNo"></param> /// <returns></returns> public ActionResult BLS030_RetrieveData(string ContractProjectCodeShort, string BillingClientCode, string BillingTargetRunningNo) { ObjectResultData res = new ObjectResultData(); CommonUtil comUtil = new CommonUtil(); ICommonContractHandler commonContractHandler = ServiceContainer.GetService <ICommonContractHandler>() as ICommonContractHandler; IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler; string lang = CommonUtil.GetCurrentLanguage(); ValidatorUtil validator = new ValidatorUtil(); try { ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; if (chandler.IsSystemSuspending()) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049); return(Json(res)); } res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; BLS030_ScreenParameter sParam = GetScreenObject <BLS030_ScreenParameter>(); sParam.doBillingTypeList = new List <tbt_BillingTypeDetail>(); if (String.IsNullOrEmpty(ContractProjectCodeShort)) { validator.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, "ContractCodeProjectCode", "lblContractProjectCode", "ContractCodeProjectCode"); } if (String.IsNullOrEmpty(BillingClientCode)) { validator.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, "BillingTargetCode", "lblBillingTargetCode", "BillingTargetCode"); } if (String.IsNullOrEmpty(BillingTargetRunningNo)) { validator.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, "BillingTargetRunningNo", "lblBillingTargetCode", "BillingTargetRunningNo"); } ValidatorUtil.BuildErrorMessage(res, validator, null); if (res.IsError) { return(Json(res)); } string strProjectCodeLong = comUtil.ConvertProjectCode(ContractProjectCodeShort, CommonUtil.CONVERT_TYPE.TO_LONG); string strContractCodeLong = comUtil.ConvertContractCode(ContractProjectCodeShort, CommonUtil.CONVERT_TYPE.TO_LONG); List <doServiceProductTypeCode> lstContractServiceProductType = commonContractHandler.GetServiceProductTypeCode(strContractCodeLong); List <doServiceProductTypeCode> lstProjectServiceProductType = commonContractHandler.GetServiceProductTypeCode(strProjectCodeLong); bool isContractCode = false; bool isProjectCode = false; if (lstContractServiceProductType.Count > 0 && lstProjectServiceProductType.Count > 0) { isContractCode = (string.IsNullOrEmpty(lstContractServiceProductType[0].ServiceTypeCode) == false); if (isContractCode == false) { isProjectCode = (string.IsNullOrEmpty(lstProjectServiceProductType[0].ServiceTypeCode) == false); } } // --- (1) if (isContractCode == false && isProjectCode == false) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0011, new string[] { "lblContractProjectCode" }, new string[] { "ContractCodeProjectCode" }); return(Json(res)); } else { if (isContractCode) { sParam.ContractProjectCodeLong = strContractCodeLong; sParam.ServiceTypeCode = lstContractServiceProductType[0].ServiceTypeCode; sParam.ProductTypeCode = lstContractServiceProductType[0].ProductTypeCode; } else { sParam.ContractProjectCodeLong = strProjectCodeLong; sParam.ServiceTypeCode = lstProjectServiceProductType[0].ServiceTypeCode; sParam.ProductTypeCode = lstProjectServiceProductType[0].ProductTypeCode; } } //--- (2) string strBillingClientCodeLong = comUtil.ConvertBillingClientCode(BillingClientCode, CommonUtil.CONVERT_TYPE.TO_LONG); var lst = billingHandler.GetTbt_BillingTargetForView(strBillingClientCodeLong + "-" + BillingTargetRunningNo, MiscType.C_CUST_TYPE); if (lst.Count == 0) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_BILLING, MessageUtil.MessageList.MSG6040, null, new string[] { "BillingTargetCode", "BillingTargetRunningNo" }); return(Json(res)); } else { var existsBillingOffice = CommonUtil.dsTransData.dtOfficeData.Where(x => x.OfficeCode == lst[0].BillingOfficeCode); if (existsBillingOffice.Count() <= 0) { res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0063, null, new string[] { "BillingTargetCode", "BillingTargetRunningNo" }); return(Json(res)); } sParam.doBillingTarget = lst[0]; sParam.BillingClientCode = strBillingClientCodeLong; sParam.BillingTargetRunningNo = BillingTargetRunningNo; } doTbt_BillingBasic doBillingBasic = new doTbt_BillingBasic(); List <doTbt_BillingBasic> lstdoBillingBasic = billingHandler.GetBillingBasic(sParam.ContractProjectCodeLong, null, strBillingClientCodeLong + "-" + BillingTargetRunningNo, null, null, CurrencyUtil.C_CURRENCY_LOCAL, CurrencyUtil.C_CURRENCY_US); if (lstdoBillingBasic.Count > 0) { doBillingBasic = lstdoBillingBasic[0]; } else { doBillingBasic = null; } if (doBillingBasic != null) { string tmpContractProjectCodeLong = ContractProjectCodeShort + "-" + doBillingBasic.BillingOCC; // doBillingBasic.ContractCode + "-" + doBillingBasic.BillingOCC res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; res.AddErrorMessage(MessageUtil.MODULE_BILLING, "BLS030", MessageUtil.MODULE_BILLING, MessageUtil.MessageList.MSG6003, new string[] { tmpContractProjectCodeLong }, new string[] { "ContractCodeProjectCode", "BillingTargetCode", "BillingTargetRunningNo" }); return(Json(res)); } res.ResultData = sParam; } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }
/// <summary> /// Get billing temporary list by condition /// </summary> /// <param name="cond"></param> /// <returns></returns> public ActionResult CMS200_GetBillingTempList(doContractInfoCondition cond) { CommonUtil c = new CommonUtil(); List <View_dtTbt_BillingTempListForView> nlst = new List <View_dtTbt_BillingTempListForView>(); ObjectResultData res = new ObjectResultData(); try { cond.ContractCode = c.ConvertContractCode(cond.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG); ICommonContractHandler handler = ServiceContainer.GetService <ICommonContractHandler>() as ICommonContractHandler; ICommonHandler comHand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>() { new doMiscTypeCode() { FieldName = MiscType.C_CURRENCT, ValueCode = "%" } }).ToList(); List <dtTbt_BillingTempListForView> list = handler.GetTbt_BillingTempListForView(cond.ContractCode, null); //Add Currency for (int i = 0; i < list.Count(); i++) { if (list[i].BillingAmtCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US) { list[i].BillingAmt = list[i].BillingAmtUsd; } list[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies); } // clone object to View foreach (dtTbt_BillingTempListForView l in list) { nlst.Add(CommonUtil.CloneObject <dtTbt_BillingTempListForView, View_dtTbt_BillingTempListForView>(l)); } // select language nlst = CommonUtil.ConvertObjectbyLanguage <View_dtTbt_BillingTempListForView, View_dtTbt_BillingTempListForView>(nlst, "BillingOffice"); // get misc display value ICommonHandler handlerComm = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <string> lsFieldNames = new List <string>(); lsFieldNames.Add(MiscType.C_BILLING_TIMING); lsFieldNames.Add(MiscType.C_CONTRACT_BILLING_TYPE); lsFieldNames.Add(MiscType.C_PAYMENT_METHOD); List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames); string strDisplayValue = string.Empty; foreach (var item in nlst) { strDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_BILLING_TIMING, item.BillingTiming) ; item.BillingTiming_EX = strDisplayValue; // CommonUtil.TextCodeName(item.BillingTiming, strDisplayValue); strDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_CONTRACT_BILLING_TYPE, item.BillingType); item.BillingType_EX = strDisplayValue; // CommonUtil.TextCodeName(item.BillingType, strDisplayValue); strDisplayValue = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_PAYMENT_METHOD, item.PayMethod); item.Paymethod_EX = strDisplayValue; // CommonUtil.TextCodeName(item.PayMethod, strDisplayValue); } // Sorting , order by BillingOCC nlst = (from p in nlst orderby p.BillingOCC ascending select p).ToList <View_dtTbt_BillingTempListForView>(); } catch (Exception ex) { nlst = new List <View_dtTbt_BillingTempListForView>(); res.AddErrorMessage(ex); } res.ResultData = CommonUtil.ConvertToXml <View_dtTbt_BillingTempListForView>(nlst, "Common\\CMS200"); return(Json(res)); }