/// <summary> /// Validate user input. /// </summary> /// <returns></returns> public ActionResult MAS030_ValidateData() { ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; try { doBillingClient custDo = null; MAS030_ScreenParameter custData = GetScreenObject <MAS030_ScreenParameter>(); if (custData != null) { if (custData.InputData != null) { custDo = custData.InputData; } } if (custDo != null) { //IMasterHandler mhandler = ServiceContainer.GetService<IMasterHandler>() as IMasterHandler; ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; #region Set Misc Data MiscTypeMappingList miscList = new MiscTypeMappingList(); miscList.AddMiscType(custDo); chandler.MiscTypeMappingList(miscList); #endregion } MAS030_ValidateCombo validate = CommonUtil.CloneObject <doBillingClient, MAS030_ValidateCombo>(custDo); ValidatorUtil.BuildErrorMessage(res, new object[] { validate }); if (custDo != null) { if (custDo.ValidateBillingClient == true) { MAS030_CheckReqField vq = CommonUtil.CloneObject <doBillingClient, MAS030_CheckReqField>(custDo); ValidatorUtil.BuildErrorMessage(res, new object[] { vq }); } } } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }
/// <summary> /// Check is user input all require field. /// </summary> /// <param name="param"></param> /// <returns></returns> public ActionResult MAS030_CheckReqField(MAS030_CheckReqField param) { ObjectResultData res = new ObjectResultData(); res.MessageType = MessageModel.MESSAGE_TYPE.WARNING; try { if (ModelState.IsValid == false) { ValidatorUtil.BuildErrorMessage(res, this); if (res.IsError) { return(Json(res)); } } //Add by Jutarat A. on 25122013 if (param.CustTypeCode == CustomerType.C_CUST_TYPE_JURISTIC || param.CustTypeCode == CustomerType.C_CUST_TYPE_ASSOCIATION || param.CustTypeCode == CustomerType.C_CUST_TYPE_PUBLIC_OFFICE) { ValidatorUtil validator = new ValidatorUtil(); if (CommonUtil.IsNullOrEmpty(param.IDNo)) { validator.AddErrorMessage(MessageUtil.MODULE_MASTER, "MAS030", MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, "mas030_IDNo", "lblIDnoTaxIDno", "mas030_IDNo"); } //if (CommonUtil.IsNullOrEmpty(param.BranchNo)) // validator.AddErrorMessage(MessageUtil.MODULE_MASTER, // "MAS030", // MessageUtil.MODULE_COMMON, // MessageUtil.MessageList.MSG0007, // "mas030_BranchNo", // "lblBranchNo", // "mas030_BranchNo"); //if (CommonUtil.IsNullOrEmpty(param.BranchNameEN)) // validator.AddErrorMessage(MessageUtil.MODULE_MASTER, // "MAS030", // MessageUtil.MODULE_COMMON, // MessageUtil.MessageList.MSG0007, // "mas030_BranchNameEN", // "lblBranchNameEn", // "mas030_BranchNameEN"); //if (CommonUtil.IsNullOrEmpty(param.BranchNameLC)) // validator.AddErrorMessage(MessageUtil.MODULE_MASTER, // "MAS030", // MessageUtil.MODULE_COMMON, // MessageUtil.MessageList.MSG0007, // "mas030_BranchNameLC", // "lblBranchNameLc", // "mas030_BranchNameLC"); ValidatorUtil.BuildErrorMessage(res, validator); if (res.IsError) { return(Json(res)); } } if (param.CustTypeCode == CustomerType.C_CUST_TYPE_JURISTIC || param.CustTypeCode == CustomerType.C_CUST_TYPE_ASSOCIATION || param.CustTypeCode == CustomerType.C_CUST_TYPE_PUBLIC_OFFICE) { if (CommonUtil.IsNullOrEmpty(param.IDNo) == false && param.IDNo.Length != 15) { res.AddErrorMessage(MessageUtil.MODULE_MASTER, "MAS030", MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1060, null, new string[] { "mas030_IDNo" }); res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; return(Json(res)); } if (CommonUtil.IsNullOrEmpty(param.BranchNo) == false && param.BranchNo.Length != 5) { res.AddErrorMessage(MessageUtil.MODULE_MASTER, "MAS030", MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1061, null, new string[] { "mas030_BranchNo" }); res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; return(Json(res)); } if (param.BranchType == "2" && param.BranchNo == "00000") { res.AddErrorMessage(MessageUtil.MODULE_MASTER, "MAS030", MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1062, null, new string[] { "mas030_BranchNo" }); res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; return(Json(res)); } } //End Add bool bResult = true; //if data from control <> data in doBillingClient (from initial) then set billingClientCode = empty MAS030_ScreenParameter MAS030Param = GetScreenObject <MAS030_ScreenParameter>(); doBillingClient inputDO = MAS030Param.InputData; if (CommonUtil.IsNullOrEmpty(inputDO.BillingClientCode)) { bResult = false; } else if ((inputDO.CustTypeCode != param.CustTypeCode) || (inputDO.CompanyTypeCode != param.CompanyTypeCode) || (inputDO.IDNo != param.IDNo) || (inputDO.NameEN != param.NameEN) || (inputDO.NameLC != param.NameLC) || //(inputDO.BranchNameEN != param.BranchNameEN) || //(inputDO.BranchNameLC != param.BranchNameLC) || (inputDO.AddressEN != param.AddressEN) || (inputDO.AddressLC != param.AddressLC) || (inputDO.RegionCode != param.RegionCode) || (inputDO.BusinessTypeCode != param.BusinessTypeCode) || (inputDO.PhoneNo != param.PhoneNo)) { bResult = false; } res.ResultData = bResult; } catch (Exception ex) { res.AddErrorMessage(ex); } return(Json(res)); }