コード例 #1
0
 public int GetAllCount(int companyId, int customerId, int commodityId, int commodityTypeId, int brandId, int warsehouseId, int status, DateTime? startDate, DateTime? endDate, int userId)
 {
     var commoditySvc = new CommodityService();
     var companySvc = new CompanyService();
     var listCommodity = commoditySvc.GetCommodityByUser(userId);
     var listCompany = companySvc.GetAllCompanyByUser((int)CustomerType.Internal, userId);
     if (listCompany.Count > 0 && listCommodity.Count > 0)
     {
         List<int> listComm = listCommodity.Select(o => o.Id).ToList();
         List<int> listComp = listCompany.Select(o => o.Id).ToList();
         var sorts = new List<SortCol> { new SortCol { ColName = "Id", IsDescending = false } };
         var func1 = GetQueryExp(companyId, customerId, commodityId, commodityTypeId, brandId, warsehouseId, status, startDate, endDate, listComm, listComp);
         return SalesOrderDAL.GetCount(func1);
     }
     return 0;
 }
コード例 #2
0
 public List<SalesOrderViewVM> GetSalesOrderByRange(int from, int to, int companyId, int customerId, int commodityId, int commodityTypeId, int brandId, int warsehouseId, int status, DateTime? startDate, DateTime? endDate, int userId)
 {
     List<SalesOrderViewVM> list = new List<SalesOrderViewVM>();
     var commoditySvc = new CommodityService();
     var companySvc = new CompanyService();
     var listCommodity = commoditySvc.GetCommodityByUser(userId);
     var listCompany = companySvc.GetAllCompanyByUser((int)CustomerType.Internal, userId);
     if (listCompany.Count > 0 && listCommodity.Count > 0)
     {
         List<int> listComm = listCommodity.Select(o => o.Id).ToList();
         List<int> listComp = listCompany.Select(o => o.Id).ToList();
         var sorts = new List<SortCol> { new SortCol { ColName = "Id", IsDescending = false } };
         var func1 = GetQueryExp(companyId, customerId, commodityId, commodityTypeId, brandId, warsehouseId, status, startDate, endDate, listComm, listComp);
         var result = SalesOrderDAL.Query(func1, sorts, from, to, new List<string> { "Company", "Stock.Company", "Stock.Warehouse", "Stock.Commodity", "Stock.CommodityType", "Stock.Brand" });
         foreach (var r in result)
         {
             SalesOrderViewVM order = new SalesOrderViewVM()
             {
                 Id = r.Id,
                 Date = r.Date.ToString("yyyy-MM-dd"),
                 Qty = r.Quantity,
                 Price = r.Price ?? 0,
                 Remark = r.Comment,
                 Status = r.Status,
                 CustomerName = r.Company.Name,
                 InterCompanyName = r.Stock.Company.Name,
                 CommodityName = r.Stock.Commodity.Name,
                 CommodityTypeName = r.Stock.CommodityType.Name,
                 BrandName = r.Stock.Brand.Name,
                 WarsehouseName = r.Stock.Warehouse.Name
             };
             Type orderStatus = typeof(SalesOrderStatus);
             var item = (SalesOrderStatus)Enum.ToObject(orderStatus, r.Status);
             string description = EnumHelper.GetDescription<SalesOrderStatus>(item);
             var des = description.Split(new char[] { ',' });
             order.StatusMsg = des[0];
             if (des.Length > 1)
             {
                 order.OptionMsg = des[1];
             }
             list.Add(order);
         }
     }
     return list;
 }