protected override List <StackOutSheet> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            DataLoadOptions opt = new DataLoadOptions();

            opt.LoadWith <StackOutSheet>(item => item.Items);
            dc.LoadOptions = opt;
            IQueryable <StackOutSheet> ret = dc.GetTable <StackOutSheet>();

            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 StackOutSheetSearchCondition)
            {
                StackOutSheetSearchCondition con = search as StackOutSheetSearchCondition;
                if (!string.IsNullOrEmpty(con.CustomerID))
                {
                    ret = ret.Where(item => item.CustomerID == con.CustomerID);
                }
                if (!string.IsNullOrEmpty(con.WareHouseID))
                {
                    ret = ret.Where(item => item.WareHouseID == con.WareHouseID);
                }
                if (con.SheetTypes != null && con.SheetTypes.Count > 0)
                {
                    ret = ret.Where(item => con.SheetTypes.Contains(item.ClassID));
                }
                if (con.WithTax != null)
                {
                    if (con.WithTax.Value)
                    {
                        ret = ret.Where(item => item.WithTax == true);
                    }
                    else
                    {
                        ret = ret.Where(item => item.WithTax == false);
                    }
                }
            }
            List <StackOutSheet> sheets = ret.ToList();

            return(sheets);
        }
        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()
 {
     if (SearchCondition == null)
     {
         StackOutSheetSearchCondition con = new StackOutSheetSearchCondition();
         con.LastActiveDate = new DateTimeRange(DateTime.Today.AddYears(-1), DateTime.Now);
         _Sheets            = (new StackOutSheetBLL(AppSettings.Current.ConnStr)).GetItems(con).QueryObjects;
     }
     else
     {
         _Sheets = (new StackOutSheetBLL(AppSettings.Current.ConnStr)).GetItems(SearchCondition).QueryObjects;
     }
     _Warehouses = (new WareHouseBLL(AppSettings.Current.ConnStr)).GetItems(null).QueryObjects;
     return(FilterData());
 }
Пример #4
0
        protected override List <object> GetDataSource()
        {
            List <object> items = null;
            StackOutSheetSearchCondition con = new StackOutSheetSearchCondition();

            con.LastActiveDate = new DateTimeRange(ucDateTimeInterval1.StartDateTime, ucDateTimeInterval1.EndDateTime);
            con.States         = new List <SheetState>();
            con.States.Add(SheetState.Shipped);
            List <StackOutSheet> sheets = (new StackOutSheetBLL(AppSettings.Current.ConnStr)).GetItems(con).QueryObjects;

            var salesGroup = sheets.GroupBy(item => item.SalesPerson);

            foreach (var group in salesGroup)
            {
                IEnumerable <IGrouping <string, StackOutSheet> > gs = null;
                if (rdByDay.Checked)
                {
                    gs = group.GroupBy(item => item.LastActiveDate.ToString("yyyy-MM-dd"));
                }
                if (rdByMonth.Checked)
                {
                    gs = group.GroupBy(item => item.LastActiveDate.ToString("yyyy-MM"));
                }
                if (rdByYear.Checked)
                {
                    gs = group.GroupBy(item => item.LastActiveDate.ToString("yyyy"));
                }
                foreach (var g in gs)
                {
                    if (!string.IsNullOrEmpty(group.Key))
                    {
                        if (items == null)
                        {
                            items = new List <object>();
                        }
                        GroupData gd = new GroupData()
                        {
                            Key = g.Key, Group = g
                        };
                        items.Add(gd);
                    }
                }
            }
            return(items);
        }
Пример #5
0
        protected override List <StackOutRecord> GetingItems(System.Data.Linq.DataContext dc, SearchCondition search)
        {
            DataLoadOptions opt = new DataLoadOptions();

            opt.LoadWith <StackOutRecord>(item => item.Customer);
            opt.LoadWith <StackOutRecord>(item => item.WareHouse);
            opt.LoadWith <StackOutRecord>(item => item.Product);
            opt.LoadWith <Product>(item => item.Category);
            dc.LoadOptions = opt;
            IQueryable <StackOutRecord> ret = dc.GetTable <StackOutRecord>();

            if (search is SheetSearchCondition)
            {
                SheetSearchCondition con = search as SheetSearchCondition;
                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.SheetNo));
                }
                if (con.States != null && con.States.Count > 0)
                {
                    ret = ret.Where(item => con.States.Contains(item.State));
                }
            }
            if (search is StackOutSheetSearchCondition)
            {
                StackOutSheetSearchCondition con = search as StackOutSheetSearchCondition;
                if (!string.IsNullOrEmpty(con.CustomerID))
                {
                    ret = ret.Where(item => item.CustomerID == con.CustomerID);
                }
                if (!string.IsNullOrEmpty(con.WareHouseID))
                {
                    ret = ret.Where(item => item.WareHouseID == con.WareHouseID);
                }
                if (con.SheetTypes != null && con.SheetTypes.Count > 0)
                {
                    ret = ret.Where(item => con.SheetTypes.Contains(item.ClassID));
                }
            }
            if (search is StackOutRecordSearchCondition)
            {
                StackOutRecordSearchCondition con = search as StackOutRecordSearchCondition;
                if (!string.IsNullOrEmpty(con.ProductID))
                {
                    ret = ret.Where(item => item.ProductID == con.ProductID);
                }
                if (!string.IsNullOrEmpty(con.CategoryID))
                {
                    ret = ret.Where(item => item.Product.CategoryID == con.CategoryID);
                }
                if (!string.IsNullOrEmpty(con.OrderID))
                {
                    ret = ret.Where(item => item.OrderID == con.OrderID);
                }
                if (con.OrderItem != null)
                {
                    ret = ret.Where(item => item.OrderItem == con.OrderItem);
                }
            }
            List <StackOutRecord> items = ret.ToList();

            return(items);
        }