コード例 #1
0
        /// <summary>
        /// Search customer data by search criteria.
        /// </summary>
        /// <param name="searchCondition"></param>
        /// <returns></returns>
        public ActionResult CMS070_CustomerSearch(doSearchInfoCondition searchCondition)
        {
            ObjectResultData res            = new ObjectResultData();
            string           customerStatus = ",";
            string           customerType   = ",";

            try
            {
                //customerStatus += searchCondition.CustomerStatusNew == null ? "" : CustomerStatus.C_CUST_STATUS_NEW + ",";
                //customerStatus += searchCondition.CustomerStatusExist == null ? "" : CustomerStatus.C_CUST_STATUS_EXIST + ",";
                //if (customerStatus.Equals(","))
                customerStatus = null;

                customerType += searchCondition.CustTypeJuristic == null ? "" : CustomerType.C_CUST_TYPE_JURISTIC + ",";
                customerType += searchCondition.CustTypeIndividual == null ? "" : CustomerType.C_CUST_TYPE_INDIVIDUAL + ",";
                customerType += searchCondition.CustTypeAssociation == null ? "" : CustomerType.C_CUST_TYPE_ASSOCIATION + ",";
                customerType += searchCondition.CustTypePublicOffice == null ? "" : CustomerType.C_CUST_TYPE_PUBLIC_OFFICE + ",";
                customerType += searchCondition.CustTypeOther == null ? "" : CustomerType.C_CUST_TYPE_OTHERS + ",";
                if (customerType.Equals(","))
                {
                    customerType = null;
                }

                string RoleTypeContractTarget = null;
                string RoleTypePurchaser      = null;
                string RoleTypeRealCustomer   = null;

                if (CustRoleType.C_CUST_ROLE_TYPE_CONTRACT_TARGET.Equals(searchCondition.CustomerRole))
                {
                    RoleTypeContractTarget = searchCondition.CustomerRole;
                }
                else if (CustRoleType.C_CUST_ROLE_TYPE_PURCHASER.Equals(searchCondition.CustomerRole))
                {
                    RoleTypePurchaser = searchCondition.CustomerRole;
                }
                else if (CustRoleType.C_CUST_ROLE_TYPE_REAL_CUST.Equals(searchCondition.CustomerRole))
                {
                    RoleTypeRealCustomer = searchCondition.CustomerRole;
                }

                CommonUtil c = new CommonUtil();
                searchCondition.CustomerCode = c.ConvertCustCode(searchCondition.CustomerCode, CommonUtil.CONVERT_TYPE.TO_LONG);
                searchCondition.GroupCode    = c.ConvertGroupCode(searchCondition.GroupCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                IViewContractHandler  hand = ServiceContainer.GetService <IViewContractHandler>() as IViewContractHandler;
                List <dtCustomerList> list = hand.GetCustomerListForSearchInfo(
                    searchCondition.CustomerCode,
                    RoleTypeContractTarget,
                    RoleTypePurchaser,
                    RoleTypeRealCustomer,
                    searchCondition.GroupCode,
                    searchCondition.CustomerName,
                    //searchCondition.Branchename,
                    searchCondition.GroupName,
                    customerStatus,
                    customerType,
                    searchCondition.CompanyType,
                    searchCondition.CustomerIDNo,
                    searchCondition.CustomerNatioality,
                    searchCondition.CustomerBusinessType,
                    searchCondition.CustomerAddress,
                    searchCondition.CustomerSoi,
                    searchCondition.CustomerRoad,
                    searchCondition.CustomerTumbol,
                    searchCondition.CustomerJangwat,
                    searchCondition.CustomerAmper,
                    searchCondition.CustomerZipCode,
                    searchCondition.CustomerTelephone,
                    searchCondition.CustomerFax,
                    CustRoleType.C_CUST_ROLE_TYPE_CONTRACT_TARGET,
                    CustRoleType.C_CUST_ROLE_TYPE_REAL_CUST,
                    CustRoleType.C_CUST_ROLE_TYPE_PURCHASER,
                    FlagType.C_FLAG_ON,
                    ServiceType.C_SERVICE_TYPE_RENTAL,
                    ServiceType.C_SERVICE_TYPE_SALE,
                    ContractStatus.C_CONTRACT_STATUS_BEF_START,
                    CustomerType.C_CUST_TYPE_JURISTIC);
                List <CMS070_CustomerView> listView = new List <CMS070_CustomerView>();
                foreach (var i in list)
                {
                    i.CustCode = c.ConvertCustCode(i.CustCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                    CMS070_CustomerView view = CommonUtil.CloneObject <dtCustomerList, CMS070_CustomerView>(i);
                    listView.Add(view);
                }

                string xml = CommonUtil.ConvertToXml <CMS070_CustomerView>(listView, "Common\\CMS070_customer", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                res.ResultData = xml;
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }