/// <summary>
        /// Confirm data user input.<br />
        /// - Generate customer full address.<br />
        /// - Check is site change.
        /// </summary>
        /// <param name="doSite"></param>
        /// <returns></returns>
        public ActionResult MAS040_ConfirmData(MAS040_CheckRequiredField doSite)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            try
            {
                if (ModelState.IsValid == false)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                    return(Json(res));
                }

                #region Create Customer Address Full

                doCustomer     cust     = CommonUtil.CloneObject <doSite, doCustomer>(doSite);
                IMasterHandler mhandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler;
                mhandler.CreateAddressFull(cust);

                doSite.AddressFullEN = cust.AddressFullEN;
                doSite.AddressFullLC = cust.AddressFullLC;

                #endregion
                #region Check is changed

                if (doSite != null)
                {
                    if (MAS040_IsSiteChanged(doSite) == true)
                    {
                        doSite.SiteCode = null;
                    }
                    else
                    {
                        CommonUtil cmm = new CommonUtil();
                        doSite.SiteCode = cmm.ConvertSiteCode(doSite.SiteCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                    }
                }
                #endregion

                res.ResultData = doSite;
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Exemple #2
0
        /// <summary>
        /// Validate customer data
        /// </summary>
        /// <param name="cust"></param>
        /// <param name="isFullValidate"></param>
        public void ValidateCustomerData(doCustomer cust, bool isFullValidate = false)
        {
            IMasterHandler mhandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler;
            ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

            doCompanyType cType = null;

            cust.ValidateCustomerData = true;
            try
            {
                #region Set Misc Data

                MiscTypeMappingList miscList = new MiscTypeMappingList();
                miscList.AddMiscType(cust);
                chandler.MiscTypeMappingList(miscList);

                #endregion
                #region Company Type

                List <doCompanyType> clst = mhandler.GetCompanyType(cust.CompanyTypeCode);
                if (clst.Count > 0)
                {
                    cType = clst[0];
                    cust.CompanyTypeName = clst[0].CompanyTypeName;
                }

                #endregion
                #region Nationality Data

                if (CommonUtil.IsNullOrEmpty(cust.RegionCode) == false)
                {
                    List <tbm_Region> nlst = mhandler.GetTbm_Region();
                    if (nlst.Count > 0)
                    {
                        foreach (tbm_Region r in nlst)
                        {
                            if (cust.RegionCode == r.RegionCode)
                            {
                                cust.Nationality = r.Nationality;
                                break;
                            }
                        }
                    }
                }

                #endregion
                #region BusinessType Data

                if (CommonUtil.IsNullOrEmpty(cust.BusinessTypeCode) == false)
                {
                    List <tbm_BusinessType> blst = mhandler.GetTbm_BusinessType();
                    if (blst.Count > 0)
                    {
                        foreach (tbm_BusinessType b in blst)
                        {
                            if (cust.BusinessTypeCode == b.BusinessTypeCode)
                            {
                                cust.BusinessTypeName = b.BusinessTypeName;
                                break;
                            }
                        }
                    }
                }

                #endregion
                #region Province Data

                if (CommonUtil.IsNullOrEmpty(cust.ProvinceCode) == false)
                {
                    List <tbm_Province> plst = mhandler.GetTbm_Province();
                    if (plst.Count > 0)
                    {
                        foreach (tbm_Province pv in plst)
                        {
                            if (cust.ProvinceCode == pv.ProvinceCode)
                            {
                                cust.ProvinceNameEN = pv.ProvinceNameEN;
                                cust.ProvinceNameLC = pv.ProvinceNameLC;
                                break;
                            }
                        }
                    }
                }

                #endregion
                #region District

                if (CommonUtil.IsNullOrEmpty(cust.DistrictCode) == false)
                {
                    List <tbm_District> dlst = mhandler.GetTbm_District(cust.ProvinceCode);
                    if (dlst.Count > 0)
                    {
                        foreach (tbm_District d in dlst)
                        {
                            if (cust.ProvinceCode == d.ProvinceCode &&
                                cust.DistrictCode == d.DistrictCode)
                            {
                                cust.DistrictNameEN = d.DistrictNameEN;
                                cust.DistrictNameLC = d.DistrictNameLC;
                                break;
                            }
                        }
                    }
                }

                #endregion

                if (CommonUtil.IsNullOrEmpty(cust.CustTypeName) || cust.CustTypeCode != CustomerType.C_CUST_TYPE_JURISTIC)
                {
                    cust.CompanyTypeName = null;
                }
                if (CommonUtil.IsNullOrEmpty(cust.CompanyTypeName) || cust.CompanyTypeCode != CompanyType.C_COMPANY_TYPE_PUBLIC_CO_LTD)
                {
                    cust.FinancialMaketTypeName = null;
                }

                if (CommonUtil.IsNullOrEmpty(cust.CustCode))
                {
                    if (isFullValidate)
                    {
                        ApplicationErrorException.CheckMandatoryField <doCustomer, ValidateCustomer_Full>(cust);
                    }
                    else if (CommonUtil.IsNullOrEmpty(cust.CustCode) == true)
                    {
                        ApplicationErrorException.CheckMandatoryField <doCustomer, ValidateCustomer_CodeNull>(cust);
                    }
                    else
                    {
                        ApplicationErrorException.CheckMandatoryField <doCustomer, ValidateCustomer>(cust);
                    }
                }
            }
            catch
            {
                cust.ValidateCustomerData = false;
            }
            try
            {
                if (cType == null)
                {
                    cType = new doCompanyType();
                }

                cust.CustFullNameEN =
                    CommonUtil.TextList(new string[] { cType.CustNamePrefixEN,
                                                       cust.CustNameEN,
                                                       cType.CustNameSuffixEN }, " ");
                cust.CustFullNameLC =
                    CommonUtil.TextList(new string[] { cType.CustNamePrefixLC,
                                                       cust.CustNameLC,
                                                       cType.CustNameSuffixLC }, " ");

                mhandler.CreateAddressFull(cust);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #3
0
        /// <summary>
        /// Validate customer data.<br />
        /// - Check require field.<br />
        /// - Check duplicate ID.<br />
        /// - Check duplicate local name.<br />
        /// - Generate full address.
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public ActionResult MAS050_ConfirmData(MAS050_CheckRequiredField customer)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            try
            {
                if (ModelState.IsValid == false)
                {
                    if (customer.IsFullValidate)
                    {
                        ValidatorUtil.BuildErrorMessage(res, this);
                        return(Json(res));
                    }
                    else
                    {
                        object validate = null;
                        if (CommonUtil.IsNullOrEmpty(customer.CustCode) == true)
                        {
                            validate = CommonUtil.CloneObject <doCustomer, MAS050_CheckRequiredFieldCustNull>(customer);
                        }
                        else
                        {
                            validate = CommonUtil.CloneObject <doCustomer, MAS050_CheckRequiredFieldNotFull>(customer);
                        }

                        ValidatorUtil.BuildErrorMessage(res, new object[] { validate });
                        if (res.IsError)
                        {
                            return(Json(res));
                        }
                    }
                }

                //Add by Jutarat A. on 02012014
                if (customer != null)
                {
                    if (customer.CustTypeCode == CustomerType.C_CUST_TYPE_JURISTIC ||
                        customer.CustTypeCode == CustomerType.C_CUST_TYPE_ASSOCIATION ||
                        customer.CustTypeCode == CustomerType.C_CUST_TYPE_PUBLIC_OFFICE)
                    {
                        if (customer.DummyIDFlag != null && customer.DummyIDFlag.Value == false)
                        {
                            if (CommonUtil.IsNullOrEmpty(customer.IDNo) == false && customer.IDNo.Length != 15)
                            {
                                res.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                                    "MAS050",
                                                    MessageUtil.MODULE_MASTER,
                                                    MessageUtil.MessageList.MSG1060,
                                                    null,
                                                    new string[] { "IDNo" });
                                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                                return(Json(res));
                            }
                        }
                    }
                }
                //End Add

                #region Update code

                CommonUtil cmm = new CommonUtil();
                if (customer != null)
                {
                    customer.CustCode = cmm.ConvertCustCode(customer.CustCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                }

                #endregion

                string callerID = null;
                MAS050_ScreenParameter param = GetScreenObject <MAS050_ScreenParameter>();
                if (param != null)
                {
                    callerID = param.CallerScreenID;
                }

                if (callerID != ScreenID.C_SCREEN_ID_QTN_TARGET)
                {
                    bool isChanged = MAS050_IsCustomerChanged(customer);
                    if (isChanged == true)
                    {
                        customer.CustCode       = null;
                        customer.CustStatus     = null;
                        customer.CustStatusName = null;

                        ICustomerMasterHandler custhandler = ServiceContainer.GetService <ICustomerMasterHandler>() as ICustomerMasterHandler;

                        #region Check duplicate customer

                        if (customer != null)
                        {
                            if (custhandler.CheckDuplicateCustomer_IDNo(customer) == true)
                            {
                                res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1003);
                                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                                return(Json(res));
                            }
                            if (custhandler.CheckDuplicateCustomer_CustNameLC(customer) == true)
                            {
                                res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1004);
                                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING_DIALOG_LIST;
                            }
                        }

                        #endregion
                    }
                }

                #region Create Customer Address Full

                IMasterHandler mhandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler;
                mhandler.CreateAddressFull(customer);

                #endregion
                res.ResultData = customer;
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Exemple #4
0
        public void ValidateSiteData(doSite doSite)
        {
            if (doSite == null)
            {
                return;
            }

            doSite.ValidateSiteData = true;
            try
            {
                IMasterHandler mhandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler;
                ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

                #region Building Usage

                if (CommonUtil.IsNullOrEmpty(doSite.BuildingUsageCode) == false)
                {
                    List <tbm_BuildingUsage> blst = mhandler.GetTbm_BiuldingUsage();
                    if (blst.Count > 0)
                    {
                        foreach (tbm_BuildingUsage b in blst)
                        {
                            if (doSite.BuildingUsageCode == b.BuildingUsageCode)
                            {
                                doSite.BuildingUsageName   = b.BuildingUsageName;
                                doSite.BuildingUsageNameEN = b.BuildingUsageNameEN;
                                doSite.BuildingUsageNameLC = b.BuildingUsageNameLC;
                                doSite.BuildingUsageNameJP = b.BuildingUsageNameJP;
                                break;
                            }
                        }
                    }
                }

                #endregion
                #region Province Data

                if (CommonUtil.IsNullOrEmpty(doSite.ProvinceCode) == false)
                {
                    List <tbm_Province> plst = mhandler.GetTbm_Province();
                    if (plst.Count > 0)
                    {
                        foreach (tbm_Province pv in plst)
                        {
                            if (doSite.ProvinceCode == pv.ProvinceCode)
                            {
                                doSite.ProvinceNameEN = pv.ProvinceNameEN;
                                doSite.ProvinceNameLC = pv.ProvinceNameLC;
                                break;
                            }
                        }
                    }
                }

                #endregion
                #region District

                if (CommonUtil.IsNullOrEmpty(doSite.DistrictCode) == false)
                {
                    List <tbm_District> dlst = mhandler.GetTbm_District(doSite.ProvinceCode);
                    if (dlst.Count > 0)
                    {
                        foreach (tbm_District d in dlst)
                        {
                            if (doSite.ProvinceCode == d.ProvinceCode &&
                                doSite.DistrictCode == d.DistrictCode)
                            {
                                doSite.DistrictNameEN = d.DistrictNameEN;
                                doSite.DistrictNameLC = d.DistrictNameLC;
                                break;
                            }
                        }
                    }
                }

                #endregion

                ApplicationErrorException.CheckMandatoryField <doSite, ValidateSite>(doSite);
            }
            catch
            {
                doSite.ValidateSiteData = false;
            }
            try
            {
                doCustomer cust = CommonUtil.CloneObject <doSite, doCustomer>(doSite);

                IMasterHandler mhandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler;
                mhandler.CreateAddressFull(cust);

                doSite.AddressFullEN = cust.AddressFullEN;
                doSite.AddressFullLC = cust.AddressFullLC;
            }
            catch (Exception)
            {
                throw;
            }
        }