123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel.TeachingMaterial;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.ViewModel;
- namespace EMIS.DataLogic.Common.TeachingMaterial
- {
- public class StockInDetailDAL
- {
- public TeachersOrderRepository TeachersOrderRepository { get; set; }
- public StockInRepository StockInRepository { get; set; }
- public StockInDetailRepository StockInDetailRepository { get; set; }
- public SchoolyearRepository SchoolyearRepository { get; set; }
- public UserRepository UserRepository { get; set; }
- public TeachingMaterialPoolRepository TeachingMaterialPoolRepository { get; set; }
- public CoursematerialRepository CoursematerialRepository { get; set; }
- public PublishRepository PublishRepository { get; set; }
- public CollegeRepository CollegeRepository { get; set; }
- public DictionaryItemRepository DictionaryItemRepository { get; set; }
- public IQueryable<StockInView> GetStockInDetailGridView(Expression<Func<ET_StockIn, bool>> exporder)
- {
- var viewList = (from a in StockInRepository.Entities.Where(exporder)
- join b in SchoolyearRepository.Entities on a.SchoolyearID equals b.SchoolyearID
- join c in UserRepository.Entities on a.HandlerUserID equals c.UserID
- into cdata
- from ctb in cdata.DefaultIfEmpty()
- join f in UserRepository.Entities on a.CreateUserID equals f.UserID
- into fdata
- from ftb in fdata.DefaultIfEmpty()
- join d in PublishRepository.Entities on a.SupplierID equals d.PublishID
- into ddata
- from dtb in ddata.DefaultIfEmpty()
- from e in a.ET_StockInDetail
- join t in TeachingMaterialPoolRepository.Entities on e.CF_TeachingMaterialPool.TeachingMaterialPoolID
- equals t.TeachingMaterialPoolID
- select new StockInView
- {
- StockInDocumentNo = a.StockInDocumentNo,
- StockInNumber = a.StockInNumber,
- SchoolyearName = b.Code,
- SchoolyearID = a.SchoolyearID,
- SupplierID = a.SupplierID,
- TeachingMaterialCode = t.TeachingMaterialCode,
- TeachingMaterialName = t.TeachingMaterialName,
- PublishName = dtb.UnitName,
- SupplierName = dtb.UnitName,
- HandlerUserName = ctb.Name,
- PublishTime = t.PublishTime,
- StockInUserName = ftb.Name,
- StockInTime = a.StockInTime,
- Author = t.Author,
- Quantity = e.Quantity == null ? 0 : e.Quantity,
- Price = t.Price,
- Discount = e.Discount == null ? 0 : e.Discount,
- DiscountPrice = (e.Discount * t.Price) == null ? 0 : (e.Discount * t.Price),
- TotalPrice = t.Price * e.Quantity,
- TotalDollar = (e.Discount * t.Price) * e.Quantity == null ? 0 : (e.Discount * t.Price) * e.Quantity,
- });
- return viewList;
- }
- #region 2.0 删除明细
- public void Delete(List<Guid> stockInDetailIDs)
- {
- try
- {
- if (stockInDetailIDs.Count > 0)
- {
- foreach (var stockInDetailID in stockInDetailIDs)
- {
- StockInDetailRepository.UnitOfWork.Delete<ET_StockInDetail>(x => x.StockInDetailID == stockInDetailID);
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- #region 3.0 入库统计信息
- public IQueryable<StockInView> GetStockInStatisticsGridView(Expression<Func<ET_StockIn, bool>> exporder)
- {
- var viewList = (from a in StockInRepository.Entities.Where(exporder)
- join b in SchoolyearRepository.Entities on a.SchoolyearID equals b.SchoolyearID
- join c in UserRepository.Entities on a.HandlerUserID equals c.UserID
- join f in UserRepository.Entities on a.CreateUserID equals f.UserID
- join e in StockInDetailRepository.Entities on a.StockInID equals e.StockInID
- join t in TeachingMaterialPoolRepository.Entities on e.TeachingMaterialPoolID equals t.TeachingMaterialPoolID
- join d in PublishRepository.Entities on t.PublishID equals d.PublishID
- join s in PublishRepository.Entities on a.SupplierID equals s.PublishID
- into g
- from x in g.DefaultIfEmpty()//自动生成入库没有供应商信息
- group new { a, b, t, e, d } by
- new
- {
- e.Discount,
- e.DiscountPrice,
- a.StockInType,
- a.SchoolyearID,
- a.SupplierID,
- SupplierName=x.UnitName,
- b.Code,
- d.UnitName,
- t.PublishTime,
- t.TeachingMaterialTypeID,
- t.ISBN,
- t.Author,
- t.TeachingMaterialCode,
- t.TeachingMaterialName,
- t.TeachingMaterialPoolID,
- t.Price,
- t.PublishID
- } into h
- select new StockInView
- {
- SchoolyearName = h.Key.Code,
- SchoolyearID = h.Key.SchoolyearID,
- SupplierID = h.Key.PublishID,
- TeachingMaterialCode = h.Key.TeachingMaterialCode,
- TeachingMaterialName = h.Key.TeachingMaterialName,
- PublishName = h.Key.UnitName,
- SupplierName = h.Key.SupplierName,
- TeachingMaterialTypeID = h.Key.TeachingMaterialTypeID,
- PublishTime = h.Key.PublishTime,
- ISBN = h.Key.ISBN,
- TeachingMaterialPoolID = h.Key.TeachingMaterialPoolID,
- Author = h.Key.Author,
- Quantity = h.Sum(x => x.e.Quantity),
- Price = Math.Round((decimal)h.Key.Price,2),
- Discount = h.Key.Discount == null ? 0 : h.Key.Discount,
- DiscountPrice = h.Key.DiscountPrice == null ? 0 : h.Key.DiscountPrice,
- TotalPrice = (h.Key.Price * h.Sum(x => x.e.Quantity)),
- TotalDollar = h.Key.DiscountPrice * h.Sum(x => x.e.Quantity) == null ? 0 : (h.Key.DiscountPrice * h.Sum(x => x.e.Quantity))
- });
- return viewList;
- }
- #endregion
- }
- }
|