///<summary>
        ///Purpose:
        ///     Get billing client data
        ///
        ///Parameters:
        ///     strBillingClientCode: 0000000036
        ///
        ///Expected:
        ///     Expect test case 4
        ///</summary>
        public string Case3()
        {
            IBillingMasterHandler target        = ServiceContainer.GetService <IBillingMasterHandler>() as IBillingMasterHandler;
            string strBillingClientCode         = "0000000036";
            List <dtBillingClientData> expected = new List <dtBillingClientData>();
            List <dtBillingClientData> actual   = null;

            dtBillingClientData billing = new dtBillingClientData();

            billing.BillingClientCode  = "0000000036";
            billing.NameEN             = "FUJI XEROX (THAILAND)";
            billing.NameLC             = "ฟูจิ ซีร็อกซ์ (ประเทศไทย)";
            billing.FullNameEN         = "FUJI XEROX (THAILAND) CO.,LTD.";
            billing.FullNameLC         = "บริษัท ฟูจิ ซีร็อกซ์ (ประเทศไทย) จำกัด";
            billing.BranchNameEN       = "Head office";
            billing.BranchNameLC       = "สำนักงานใหญ่";
            billing.CustTypeCode       = "0";
            billing.CustTypeNameEN     = "Juristic";
            billing.CustTypeNameJP     = "法人";
            billing.CustTypeNameLC     = "JuristicLC";
            billing.CompanyTypeCode    = "03";
            billing.CompanyTypeNameEN  = "Limited company";
            billing.CompanyTypeNameLC  = "บริษัทจำกัด";
            billing.BusinessTypeCode   = "013";
            billing.BusinessTypeNameEN = "Electrical Equipment";
            billing.BusinessTypeNameJP = "電気機器";
            billing.BusinessTypeNameLC = "อุปกรณ์อิเล็กทรอนิกส์";
            billing.PhoneNo            = "0868965423";
            billing.IDNo          = "1234567890000";
            billing.RegionCode    = "TH";
            billing.NationalityEN = "Thai";
            billing.NationalityJP = "タイ人";
            billing.NationalityLC = "คนไทย";
            billing.AddressEN     = "123 SUNTOWERS  BUILDING A,23rd-26th FLOOR,VIBHAVADI-RANGSIT,CHOMPHON,JATUJAK,BANGKOK 10700";
            billing.AddressLC     = "123 อาคารทานตะวัน A ชั้น 23-26 ถ.วิภาวดีรังสิต แขวงจอมพล เขตจตุจักร จ.กรุงเทพมหานคร 10700";
            billing.CreateDate    = new DateTime(2011, 7, 13, 12, 9, 0);
            billing.CreateBy      = "500576";
            billing.UpdateDate    = new DateTime(2011, 7, 13, 12, 9, 0);
            billing.UpdateBy      = "500576";
            expected.Add(billing);
            CommonUtil.MappingObjectLanguage <dtBillingClientData>(expected);

            try {
                actual = target.GetBillingClient(strBillingClientCode);
            } catch (ApplicationErrorException ex) {
                actual = new List <dtBillingClientData>();
            } catch (Exception ex) {
                actual = new List <dtBillingClientData>();
            }

            return(string.Format(RESULT_FORMAT, 3, expected[0].BillingClientCode, actual[0].BillingClientCode, CompareObjectList <dtBillingClientData>(expected, actual, BILLING_CLIENT_FIELD) ? "Pass" : "Fail"));
        }
        ///<summary>
        ///Purpose:
        ///     Get billing client data (Max length all columns)
        ///
        ///Parameters:
        ///     strBillingClientCode: 0000000179
        ///
        ///Expected:
        ///     1. Expect test case 5
        ///     Note: At end character of text column will be 'z' or 'ฮ'
        ///
        ///</summary>
        public string Case4()
        {
            IBillingMasterHandler target        = ServiceContainer.GetService <IBillingMasterHandler>() as IBillingMasterHandler;
            string strBillingClientCode         = "0000000179";
            List <dtBillingClientData> expected = new List <dtBillingClientData>();
            List <dtBillingClientData> actual   = null;

            dtBillingClientData billing = new dtBillingClientData();

            billing.BillingClientCode  = "0000000179";
            billing.NameEN             = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz";
            billing.NameLC             = "กกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกฮ";
            billing.FullNameEN         = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz";
            billing.FullNameLC         = "กกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกฮกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกฮ";
            billing.BranchNameEN       = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz";
            billing.BranchNameLC       = "กกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกฮ";
            billing.CustTypeCode       = "0";
            billing.CustTypeNameEN     = "Juristic";
            billing.CustTypeNameJP     = "法人";
            billing.CustTypeNameLC     = "JuristicLC";
            billing.CompanyTypeCode    = "03";
            billing.CompanyTypeNameEN  = "Limited company";
            billing.CompanyTypeNameLC  = "บริษัทจำกัด";
            billing.BusinessTypeCode   = "005";
            billing.BusinessTypeNameEN = "Automotive Auto Parts";
            billing.BusinessTypeNameJP = "自動車産業・部品";
            billing.BusinessTypeNameLC = "ชิ้นส่วนรถยนต์";
            billing.PhoneNo            = "12345678901234567890";
            billing.IDNo          = "12345678901234567890";
            billing.RegionCode    = "TH";
            billing.NationalityEN = "Thai";
            billing.NationalityJP = "タイ人";
            billing.NationalityLC = "คนไทย";
            billing.AddressEN     = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz";
            billing.AddressLC     = "กกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกกฮ";
            billing.CreateDate    = new DateTime(2011, 7, 13, 12, 9, 0);
            billing.CreateBy      = "500576";
            billing.UpdateDate    = new DateTime(2011, 7, 13, 12, 9, 0);
            billing.UpdateBy      = "500576";
            expected.Add(billing);
            CommonUtil.MappingObjectLanguage <dtBillingClientData>(expected);

            try {
                actual = target.GetBillingClient(strBillingClientCode);
            } catch (ApplicationErrorException ex) {
                actual = new List <dtBillingClientData>();
            } catch (Exception ex) {
                actual = new List <dtBillingClientData>();
            }

            return(string.Format(RESULT_FORMAT, 4, expected[0].BillingClientCode, actual[0].BillingClientCode, CompareObjectList <dtBillingClientData>(expected, actual, BILLING_CLIENT_FIELD) ? "Pass" : "Fail"));
        }
        /// <summary>
        /// Set screen parameter of billing target information
        /// </summary>
        /// <param name="doBillingClientData"></param>
        /// <returns></returns>
        public ActionResult BLS010_SetScreenParameterBillingtargetInfo(dtBillingClientData doBillingClientData)
        {
            ObjectResultData res       = new ObjectResultData();
            ValidatorUtil    validator = new ValidatorUtil();

            try
            {
                BLS010_ScreenParameter sParam = GetScreenObject <BLS010_ScreenParameter>();
                if (sParam.doBillingClientList != null)
                {
                    sParam.doBillingClientList.Clear();
                    sParam.doBillingClientList.Add(doBillingClientData);
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
        /// <summary>
        /// Return mapping language of billing client data
        /// </summary>
        /// <param name="doBillingClientData"></param>
        /// <returns></returns>
        public ActionResult BLS010_ReturnMappingLanguage(dtBillingClientData doBillingClientData)
        {
            ObjectResultData       res     = new ObjectResultData();
            CommonUtil             comUtil = new CommonUtil();
            BLS010_ScreenParameter sParam  = GetScreenObject <BLS010_ScreenParameter>();

            try
            {
                if (doBillingClientData != null)
                {
                    List <dtBillingClientData> listBillingClientData = new List <dtBillingClientData>();
                    listBillingClientData.Add(doBillingClientData);
                    //listBillingClientData = base.GetBillingClient(MiscType.C_CUST_TYPE, billingClientCode);
                    CommonUtil.MappingObjectLanguage <dtBillingClientData>(listBillingClientData);
                    sParam.doBillingClientList = listBillingClientData;
                    res.ResultData             = sParam.doBillingClientList[0];
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }
        /// <summary>
        /// Register billing target
        /// </summary>
        /// <param name="doTbtBillingTarget"></param>
        /// <param name="doBillingClientDdata"></param>
        /// <returns></returns>
        public ActionResult BLS010_RegisterData(tbt_BillingTarget doTbtBillingTarget, dtBillingClientData doBillingClientDdata)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            ValidatorUtil validator = new ValidatorUtil();
            CommonUtil    comUtil   = new CommonUtil();

            try
            {
                BLS010_ScreenParameter     sParam  = GetScreenObject <BLS010_ScreenParameter>();
                BLS010_ScreenInputValidate obj     = new BLS010_ScreenInputValidate();
                IBillingHandler            handler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
                List <string> lstParam             = new List <string>();
                List <string> lstControl           = new List <string>();

                ///////// Check Suspending //////////
                ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                if (chandler.IsSystemSuspending())
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049);
                    return(Json(res));
                }

                /////// Check permission //////////
                if (!CheckUserPermission(ScreenID.C_SCREEN_ID_REGIST_BILL_TARGET, FunctionID.C_FUNC_ID_OPERATE))
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                    return(Json(res));
                }

                //if (sParam.doBillingClientList == null)
                //{
                //    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                //    //res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { "lblBillingClientCode" }, new string[] { "lblBillingClientCode" });
                //    res.AddErrorMessage(MessageUtil.MODULE_BILLING,
                //                     ScreenID.C_SCREEN_ID_REGIST_BILL_TARGET,
                //                     MessageUtil.MODULE_COMMON,
                //                     MessageUtil.MessageList.MSG0007,
                //                     new string[] { "lblBillingClientCode" },
                //                      new string[] { "lblBillingClientCode" });
                //    return Json(res);
                //}
                ////////////////5.2 Check mandatory
                //if (CommonUtil.IsNullOrEmpty(sParam.doBillingClientList[0].BillingClientCode))
                //{
                //    if (CommonUtil.IsNullOrEmpty(sParam.doBillingClientList[0].NameEN))
                //    {
                //        lstParam.Add("lblNameEnglish");
                //        lstControl.Add("FullNameEN");
                //    }
                //    if (CommonUtil.IsNullOrEmpty(sParam.doBillingClientList[0].NameLC))
                //    {
                //        lstParam.Add("lblNameLocal");
                //        lstControl.Add("FullNameEN");
                //    }
                //    if (CommonUtil.IsNullOrEmpty(sParam.doBillingClientList[0].CustTypeCode))
                //    {
                //        lstParam.Add("lblCustTypeCode");
                //        lstControl.Add("CustTypeName");

                //    }
                //}

                // Modify by siripoj 06-06-12
                if (CommonUtil.IsNullOrEmpty(doBillingClientDdata.BillingClientCode))
                {
                    if (CommonUtil.IsNullOrEmpty(doBillingClientDdata.NameEN))
                    {
                        lstParam.Add("lblNameEnglish");
                        lstControl.Add("FullNameEN");
                    }
                    // 2017.02.15 delete matsuda start
                    //if (CommonUtil.IsNullOrEmpty(doBillingClientDdata.NameLC))
                    //{
                    //    lstParam.Add("lblNameLocal");
                    //    lstControl.Add("FullNameLC");
                    //}
                    // 2017.02.15 delete matsuda end
                    if (CommonUtil.IsNullOrEmpty(doBillingClientDdata.CustTypeCode))
                    {
                        lstParam.Add("lblCustTypeCode");
                        lstControl.Add("CustTypeName");
                    }
                }

                if (CommonUtil.IsNullOrEmpty(doTbtBillingTarget.BillingOfficeCode))
                {
                    lstParam.Add("lblBillingOffice");
                    lstControl.Add("BillingOfficeCode");
                }
                if (lstParam.Count > 0 && lstControl.Count > 0)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    // res.AddErrorMessage(MessageUtil.MODULE_BILLING, MessageUtil.MessageList.MSG0007, lstParam.ToArray(), lstControl.ToArray());
                    res.AddErrorMessage(MessageUtil.MODULE_BILLING,
                                        ScreenID.C_SCREEN_ID_REGIST_BILL_TARGET,
                                        MessageUtil.MODULE_COMMON,
                                        MessageUtil.MessageList.MSG0007,
                                        lstParam.ToArray(),
                                        lstControl.ToArray());
                    return(Json(res));
                }

                //Clone Data
                //obj = CommonUtil.CloneObject<dtBillingClientData, BLS010_ScreenInputValidate>(sParam.doBillingClientList[0]);
                //obj.BillingOfficeCode = doTbtBillingTarget.BillingOfficeCode;

                ////////////////5.2 Check mandatory
                //ValidatorUtil.BuildErrorMessage(res, this, new object[] { obj });
                //if (res.IsError)
                //{

                //    return Json(res);
                //}
                ///////////////5.3 Validate Business
                //doTbtBillingTarget = CommonUtil.CloneObject<dtBillingClientData, tbt_BillingTarget>(sParam.doBillingClientList[0]);

                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

                // Modify by Siripoj 06-06-12
                //doTbtBillingTarget.BillingClientCode = sParam.doBillingClientList[0].BillingClientCode;
                doTbtBillingTarget.BillingClientCode = doBillingClientDdata.BillingClientCode;

                if (CommonUtil.IsNullOrEmpty(doTbtBillingTarget.IssueInvMonth))
                {
                    doTbtBillingTarget.IssueInvMonth = 0;
                }
                if (doTbtBillingTarget.IssueInvMonth > 60)
                {
                    //res.AddErrorMessage(MessageUtil.MODULE_BILLING, MessageUtil.MessageList.MSG6001, new string[] { "IssueInvTime" }, new string[] { "IssueInvTime" });
                    res.AddErrorMessage(MessageUtil.MODULE_BILLING,
                                        ScreenID.C_SCREEN_ID_REGIST_BILL_TARGET,
                                        MessageUtil.MODULE_BILLING,
                                        MessageUtil.MessageList.MSG6001,
                                        new string[] { "lblIssueInvoiceTiming" },
                                        new string[] { "IssueInvMonth" });
                    return(Json(res));
                }
                if (!CommonUtil.IsNullOrEmpty(doTbtBillingTarget.BillingClientCode))
                {
                    List <tbt_BillingTarget> lst = new List <tbt_BillingTarget>();
                    lst = handler.GetTbt_BillingTarget(null, comUtil.ConvertBillingClientCode(doTbtBillingTarget.BillingClientCode, CommonUtil.CONVERT_TYPE.TO_LONG), doTbtBillingTarget.BillingOfficeCode);
                    if (lst.Count > 0)
                    {
                        doTbtBillingTarget = lst[0];
                    }
                    else
                    {
                        doTbtBillingTarget = null;
                    }
                    //doTbtBillingTarget = handler.GetTbt_BillingTarget(null, comUtil.ConvertBillingClientCode(doTbtBillingTarget.BillingClientCode, CommonUtil.CONVERT_TYPE.TO_LONG), doTbtBillingTarget.BillingOfficeCode);
                    if (doTbtBillingTarget != null)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_BILLING,
                                            ScreenID.C_SCREEN_ID_REGIST_BILL_TARGET,
                                            MessageUtil.MODULE_BILLING,
                                            MessageUtil.MessageList.MSG6002,
                                            new string[] { comUtil.ConvertBillingTargetCode(doTbtBillingTarget.BillingTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT) },
                                            new string[] { "BillingClientCodeView" });
                        return(Json(res));
                    }
                }
                res.ResultData             = true;
                sParam.doBillingClient     = doBillingClientDdata;
                sParam.doTbt_BillingTarget = doTbtBillingTarget;
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }