Example #1
0
        //get Product relative customer,按产品使用情况找客户
        public long[] GetProdRelativeCustomer(long ProdID)
        {
            //取得该产品以及其下属的产品ID
            var prods = GetSubProds(ProdID);

            var qry = from t in CRMCustomerProds
                      .Where(t => prods.Contains(t.ProdID))
                      select t.CustID;

            return(qry.ToArray());
        }
Example #2
0
        //按市场部门找客户
        public long[] GetCategoryRelativeCustomer(int catID)
        {
            //category对应的产品codes
            DataTable dt = DBExtBase.ExeFillTblBySqlText(this.dataCtx, @"select prodID from crmCategoryProd  cp 
                        inner join crmproduct p on left(p.code,len(cp.prodcode)) = cp.prodcode
                        where catid=" + catID.ToString());

            long[] prodIDs = new long[dt.Rows.Count];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                prodIDs[i] = Convert.ToInt32(dt.Rows[i][0]);
            }

            var qry = from t in CRMCustomerProds
                      .Where(t => prodIDs.Contains(t.ProdID))
                      select t.CustID;

            return(qry.ToArray());
        }
Example #3
0
        //把当前记录copy到历史表
        private void CopyToHistory(CRMCustomer obj)
        {
            long NextVersion;

            var qry = CRMCustomerProdHistorys.Where(t => t.CustID == obj.CustID);

            if (qry.Count() > 0)
            {
                NextVersion = qry.Max(t => t.Version) + 1;
            }
            else
            {
                NextVersion = 1;
            }

            CRMCustomerHistory h = new CRMCustomerHistory();

            h.Version          = NextVersion;
            h.BirthDay         = obj.BirthDay;
            h.BuddyList        = obj.BuddyList;
            h.Budget           = obj.Budget;
            h.CommissionFactor = obj.CommissionFactor;
            h.CRMCustomer      = obj;
            h.CustAddress      = obj.CustAddress;
            h.CustBackground   = obj.CustBackground;
            h.CustCity         = obj.CustCity;
            h.CustCode         = obj.CustCode == null?obj.CustID.ToString() : obj.CustCode;

            h.CustCountryID        = obj.CustCountryID;
            h.CustDistinct         = obj.CustDistinct;
            h.CustEmpNumID         = obj.CustEmpNumID;
            h.CustFax              = obj.CustFax;
            h.CustFromID           = obj.CustFromID;
            h.CustFullName         = obj.CustFullName;
            h.CustID               = obj.CustID;
            h.CustIndustryID       = obj.CustIndustryID;
            h.CustInfo             = obj.CustInfo;
            h.CustMaterial         = obj.CustMaterial;
            h.CustName             = obj.CustName;
            h.CustOwnerID          = obj.CustOwnerID;
            h.CustPayMethod        = obj.CustPayMethod;
            h.CustPort             = obj.CustPort;
            h.CustProvince         = obj.CustProvince;
            h.CustPurchaseChannels = obj.CustPurchaseChannels;
            h.CustRelationID       = obj.CustRelationID;
            h.CustRisk             = obj.CustRisk;
            h.CustSaleChannels     = obj.CustSaleChannels;
            h.CustStatusID         = obj.CustStatusID;
            h.CustTel              = obj.CustTel;
            h.CustTypeID           = obj.CustTypeID;
            h.CustWeb              = obj.CustWeb;
            h.FavoriteDest         = obj.FavoriteDest;
            h.FavoriteProd         = obj.FavoriteProd;
            h.Gender               = obj.Gender;
            h.ParentCompany        = obj.ParentCompany;
            h.Passport             = obj.Passport;
            h.PassportExpiryDate   = obj.PassportExpiryDate;
            h.Position             = obj.Position;
            h.PreferPlace          = obj.PreferPlace;
            h.PreferPrice          = obj.PreferPrice;
            h.RequireVisa          = obj.RequireVisa;
            h.Status               = obj.Status;
            h.TravelDay            = obj.TravelDay;
            h.UseOwnMoney          = obj.UseOwnMoney;
            h.SYSID = obj.SYSID;

            this.CRMCustomerHistorys.InsertOnSubmit(h);

            var oldList = CRMCustomerProds.Where(t => t.CustID == obj.CustID).ToList();

            foreach (var item in oldList)
            {
                CRMCustomerProdHistory cph = new CRMCustomerProdHistory();
                cph.Brand   = item.Brand;
                cph.CustID  = item.CustID;
                cph.ProdID  = item.ProdID;
                cph.Remark  = item.Remark;
                cph.Usage   = item.Usage;
                cph.Version = NextVersion;
                this.CRMCustomerProdHistorys.InsertOnSubmit(cph);
            }
            //删除旧的Customer Products
            this.CRMCustomerProds.DeleteAllOnSubmit(oldList);
        }