public override CommandResult Delete(CompanyInfo info) { StackOutSheetSearchCondition con = new StackOutSheetSearchCondition(); con.CustomerID = info.ID; List <StackOutSheet> items = (new StackOutSheetBLL(RepoUri)).GetItems(con).QueryObjects; if (items != null && items.Count > 0) { return(new CommandResult(ResultCode.Fail, string.Format("不能删除客户 {0} 的资料,系统中已经存在此客户的送货单", info.Name))); } IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(RepoUri); CustomerPaymentSearchCondition con1 = new CustomerPaymentSearchCondition() { CustomerID = info.ID }; List <CustomerPayment> cps = ProviderFactory.Create <IProvider <CustomerPayment, string> >(RepoUri).GetItems(con1).QueryObjects; if (cps != null && cps.Count > 0) { foreach (CustomerPayment cp in cps) { ProviderFactory.Create <IProvider <CustomerPayment, string> >(RepoUri).Delete(cp, unitWork); } } CustomerOtherReceivableSearchCondition con2 = new CustomerOtherReceivableSearchCondition() { CustomerID = info.ID }; List <CustomerOtherReceivable> cds = ProviderFactory.Create <IProvider <CustomerOtherReceivable, string> >(RepoUri).GetItems(con2).QueryObjects; if (cds != null && cds.Count > 0) { foreach (CustomerOtherReceivable cd in cds) { ProviderFactory.Create <IProvider <CustomerOtherReceivable, string> >(RepoUri).Delete(cd, unitWork); } } CustomerReceivableSearchCondition con3 = new CustomerReceivableSearchCondition() { CustomerID = info.ID }; List <CustomerReceivable> crs = ProviderFactory.Create <IProvider <CustomerReceivable, Guid> >(RepoUri).GetItems(con3).QueryObjects; if (crs != null && crs.Count > 0) { foreach (CustomerReceivable cr in crs) { ProviderFactory.Create <IProvider <CustomerReceivable, Guid> >(RepoUri).Delete(cr, unitWork); } } ProviderFactory.Create <IProvider <CompanyInfo, string> >(RepoUri).Delete(info, unitWork); return(unitWork.Commit()); }
protected override List <object> GetDataSource() { CustomerReceivableSearchCondition con1 = new CustomerReceivableSearchCondition(); con1.ReceivableTypes = new List <CustomerReceivableType>(); con1.ReceivableTypes.Add(CustomerReceivableType.CustomerOtherReceivable); _Receivables = new CustomerReceivableBLL(AppSettings.Current.ConnStr).GetItems(con1).QueryObjects; if (SearchCondition == null) { CustomerOtherReceivableSearchCondition con = new CustomerOtherReceivableSearchCondition(); con.LastActiveDate = new DateTimeRange(DateTime.Today.AddYears(-1), DateTime.Now); _Sheets = (new CustomerOtherReceivableBLL(AppSettings.Current.ConnStr)).GetItems(con).QueryObjects; } else { _Sheets = (new CustomerOtherReceivableBLL(AppSettings.Current.ConnStr)).GetItems(SearchCondition).QueryObjects; } return(FilterData()); }
protected override List <CustomerOtherReceivable> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search) { IQueryable <CustomerOtherReceivable> ret = dc.GetTable <CustomerOtherReceivable>(); if (search is SheetSearchCondition) { SheetSearchCondition con = search as SheetSearchCondition; if (con.SheetDate != null) { ret = ret.Where(item => item.SheetDate >= con.SheetDate.Begin && item.SheetDate <= con.SheetDate.End); } if (con.LastActiveDate != null) { ret = ret.Where(item => item.LastActiveDate >= con.LastActiveDate.Begin && item.LastActiveDate <= con.LastActiveDate.End); } if (con.SheetNo != null && con.SheetNo.Count > 0) { ret = ret.Where(item => con.SheetNo.Contains(item.ID)); } if (con.States != null && con.States.Count > 0) { ret = ret.Where(item => con.States.Contains(item.State)); } } if (search is CustomerOtherReceivableSearchCondition) { CustomerOtherReceivableSearchCondition con = search as CustomerOtherReceivableSearchCondition; if (!string.IsNullOrEmpty(con.CustomerID)) { ret = ret.Where(item => item.CustomerID == con.CustomerID); } } List <CustomerOtherReceivable> items = ret.ToList(); return(items); }