//�ѵ�ǰ��¼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); }
//把当前记录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); }