예제 #1
0
        private List <RouteCardInvoiceHeader> GetRouteCardInvoiceHeader(int skip, int take, string sort, string filter, Dictionary <string, object> valuesObjects, out int fullCount, out List <Vendor> Vendors)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                IQueryable <RouteCardInvoiceHeader> query;
                if (filter != null)
                {
                    var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);

                    fullCount = context.RouteCardInvoiceHeaders.Where(filter, parameterCollection.ToArray()).Count();
                    query     = context.RouteCardInvoiceHeaders.Where(filter, parameterCollection.ToArray()).OrderBy(sort).Skip(skip).Take(take);
                }
                else
                {
                    fullCount = context.RouteCardInvoiceHeaders.Count();
                    query     = context.RouteCardInvoiceHeaders.OrderBy(sort).Skip(skip).Take(take);
                }


                var codes = query.Select(w => w.Vendor).ToList();
                Vendors = context.Vendors.Where(x => codes.Contains(x.vendor_code)).ToList();

                return(query.ToList());
            }
        }
예제 #2
0
        private List <TblSalaryApprovalDetail> GetSalaryApprovalDetail(int skip, int take, int ledgerHeader, string sort, string filter, Dictionary <string, object> valuesObjects, out int fullCount, out List <TblEmployee> EmpList, string company)
        {
            using (var context = new ccnewEntities(SharedOperation.GetSqlConnectionString(company)))
            {
                IQueryable <TblSalaryApprovalDetail> query;
                if (filter != null)
                {
                    filter = filter + " and it.TblSalaryApprovalHeader ==(@Group0)";
                    valuesObjects.Add("Group0", ledgerHeader);

                    var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);
                    fullCount = context.TblSalaryApprovalDetails.Where(filter, parameterCollection.ToArray()).Count();
                    query     = context.TblSalaryApprovalDetails.OrderBy(sort).Where(filter, parameterCollection.ToArray()).Skip(skip).Take(take);
                }
                else
                {
                    fullCount = context.TblSalaryApprovalDetails.Count(v => v.TblSalaryApprovalHeader == ledgerHeader);
                    query     = context.TblSalaryApprovalDetails.OrderBy(sort).Where(v => v.TblSalaryApprovalHeader == ledgerHeader).Skip(skip).Take(take);
                }

                List <int> intList = query.Select(x => x.TblEmployee).ToList();

                EmpList = context.TblEmployees.Where(x => intList.Contains(x.iserial)).ToList();


                return(query.ToList());
            }
        }
예제 #3
0
        private List <TblAdjustmentHeader> GetAdjustment(int skip, int take, string sort, string filter, Dictionary <string, object> valuesObjects,
                                                         int userIserial, bool openningBalance, out int fullCount)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var defaultQuery = context.TblAdjustmentHeaders.Include(nameof(
                                                                            TblAdjustmentHeader.TblWarehouse)).Where(a => a.IsOpeningBalance == openningBalance);
                IQueryable <TblAdjustmentHeader> query;
                if (filter != null)
                {
                    var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);

                    fullCount = defaultQuery.Where(filter, parameterCollection.ToArray()).Where(tr =>
                                                                                                context.TblAuthWarehouses.Any(aw =>
                                                                                                                              aw.AuthUserIserial == userIserial && aw.PermissionType == (short)AuthWarehouseType.Adjustment &&
                                                                                                                              (aw.WarehouseIserial == tr.WarehouseIserial))).Count();
                    query = defaultQuery.Where(filter, parameterCollection.ToArray()).OrderBy(sort).Where(tr =>
                                                                                                          context.TblAuthWarehouses.Any(aw =>
                                                                                                                                        aw.AuthUserIserial == userIserial && aw.PermissionType == (short)AuthWarehouseType.Adjustment &&
                                                                                                                                        (aw.WarehouseIserial == tr.WarehouseIserial)));
                }
                else
                {
                    fullCount = defaultQuery.Where(tr =>
                                                   context.TblAuthWarehouses.Any(aw =>
                                                                                 aw.AuthUserIserial == userIserial && aw.PermissionType == (short)AuthWarehouseType.Adjustment &&
                                                                                 (aw.WarehouseIserial == tr.WarehouseIserial))).Count();
                    query = defaultQuery.OrderBy(sort).Where(tr =>
                                                             context.TblAuthWarehouses.Any(aw =>
                                                                                           aw.AuthUserIserial == userIserial && aw.PermissionType == (short)AuthWarehouseType.Adjustment &&
                                                                                           (aw.WarehouseIserial == tr.WarehouseIserial)));
                }
                return(query.Skip(skip).Take(take).ToList());
            }
        }
예제 #4
0
        private List <ViewPurchaseOrderHeaderRequest> GetTblPurchaseOrderHeaderRequest(int skip, int take, string sort, string filter, Dictionary <string, object> valuesObjects, out int fullCount, out List <Vendor> vendorList)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                context.ViewPurchaseOrderHeaderRequests.MergeOption = MergeOption.NoTracking;
                IQueryable <ViewPurchaseOrderHeaderRequest> query;
                if (filter != null)
                {
                    var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);

                    fullCount = context.ViewPurchaseOrderHeaderRequests.Where(filter, parameterCollection.ToArray()).Count();
                    query     = context.ViewPurchaseOrderHeaderRequests.Where(filter, parameterCollection.ToArray()).OrderBy(sort).Skip(skip).Take(take);
                }
                else
                {
                    fullCount =
                        context.ViewPurchaseOrderHeaderRequests.Count();
                    query = context.ViewPurchaseOrderHeaderRequests.OrderBy(sort).Skip(skip).Take(take);
                }


                var vendorListStrings = query.Select(x => x.Vendor);
                vendorList = context.Vendors.Where(x => vendorListStrings.Any(l => x.vendor_code == l)).ToList();


                return(query.OrderByDescending(w => w.Iserial).ToList());
            }
        }
예제 #5
0
        public List <TblTradeAgreementTransaction> GetTblTradeAgreementTransaction(int skip,
                                                                                   int take, string sort, string filter, Dictionary <string, object> valuesObjects,
                                                                                   out int fullCount)
        {
            string itemCode = null;

            if (filter != null && valuesObjects != null && filter.Contains("it." + nameof(TblLkpSeason.Code)))
            {
                var val = valuesObjects.FirstOrDefault(k => k.Key.StartsWith(nameof(TblLkpSeason.Code)));
                if (val.Value != null)
                {
                    itemCode = val.Value.ToString().Replace("%", "");
                }
                var startIndex = filter.IndexOf(string.Format("it.{0} LIKE(", nameof(TblLkpSeason.Code)));
                var lastIndex  = filter.IndexOf(")", startIndex);
                filter = filter.Remove(startIndex, lastIndex - startIndex + 1).Trim().Replace("  ", " ").Replace("and and", "and").Trim();
                if (filter.StartsWith("and"))
                {
                    filter = filter.Remove(0, 3);
                }
                if (filter.EndsWith("and"))
                {
                    filter = filter.Remove(filter.Length - 3, 3);
                }
                valuesObjects.Remove(val.Key);
                //valuesObjects.Add(val.Key, "%%");
            }
            using (var context = new WorkFlowManagerDBEntities())
            {
                IQueryable <TblTradeAgreementTransaction> query = context.TblTradeAgreementTransactions.Include(
                    nameof(TblTradeAgreementTransaction.TblLkpSeason1));
                if (string.IsNullOrWhiteSpace(itemCode))
                {
                    query.Where(t => t.TblTradeAgreementHeaders.Any(h => h.TblTradeAgreementDetails.Any(d =>
                                                                                                        context.FabricAccSearches.Any(f => f.Iserial == d.ItemCode && f.Code == itemCode))));
                }
                if (!string.IsNullOrWhiteSpace(filter))
                {
                    var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);
                    fullCount = context.TblTradeAgreementTransactions.Where(filter, parameterCollection.ToArray()).Count();
                    query     = query.Where(filter, parameterCollection.ToArray()).OrderBy(sort).Skip(skip).Take(take);
                }
                else
                {
                    fullCount = context.TblTradeAgreementTransactions.Count();
                    query     = query.OrderBy(sort).Skip(skip).Take(take);
                }
                return(query.ToList());
            }
        }
예제 #6
0
 //[OperationContract]
 public List <TblTradeAgreementHeader> GetTblTradeAgreementHeaderList(int skip, int take, string sort, string filter, Dictionary <string, object> valuesObjects, out int fullCount)
 {
     using (var context = new WorkFlowManagerDBEntities())
     {
         IQueryable <TblTradeAgreementHeader> query;
         if (filter != null)
         {
             var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);
             fullCount = context.TblTradeAgreementHeaders.Where(filter, parameterCollection.ToArray()).Count();
             query     = context.TblTradeAgreementHeaders.Where(filter, parameterCollection.ToArray()).OrderBy(sort).Skip(skip).Take(take);
         }
         else
         {
             fullCount = context.TblTradeAgreementHeaders.Count();
             query     = context.TblTradeAgreementHeaders.OrderBy(sort).Skip(skip).Take(take);
         }
         return(query.ToList());
     }
 }
예제 #7
0
 private List <TblDyeingOrderInvoiceDetail> GetDyeingOrderInvoiceDetail(int skip, int take, int groupId, string sort, string filter, Dictionary <string, object> valuesObjects, out int fullCount)
 {
     using (var context = new WorkFlowManagerDBEntities())
     {
         IQueryable <TblDyeingOrderInvoiceDetail> query;
         if (filter != null)
         {
             filter = filter + " and it.TblDyeingOrderInvoiceHeader ==(@Group0)";
             valuesObjects.Add("Group0", groupId);
             var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);
             fullCount = context.TblDyeingOrderInvoiceDetails.Where(filter, parameterCollection.ToArray()).Count();
             query     = context.TblDyeingOrderInvoiceDetails.Include(nameof(TblDyeingOrderInvoiceDetail.TblColor1)).Include((nameof(TblDyeingOrderInvoiceDetail.TblService1))).Where(filter, parameterCollection.ToArray()).OrderBy(sort).Skip(skip).Take(take);
         }
         else
         {
             fullCount = context.TblDyeingOrderInvoiceDetails.Count(v => v.TblDyeingOrderInvoiceHeader == groupId);
             query     = context.TblDyeingOrderInvoiceDetails.Include((nameof(TblDyeingOrderInvoiceDetail.TblColor1))).Include((nameof(TblDyeingOrderInvoiceDetail.TblService1))).OrderBy(sort).Where(v => v.TblDyeingOrderInvoiceHeader == groupId).Skip(skip).Take(take);
         }
         return(query.ToList());
     }
 }
예제 #8
0
파일: MarkUp.cs 프로젝트: Osama91/CCWFM
 private List <TblMarkup> GetTblMarkupProd(int skip, int take, string sort, string filter, Dictionary <string, object> valuesObjects, out int fullCount, string company)
 {
     using (var entity = new ccnewEntities(SharedOperation.GetSqlConnectionString(company)))
     {
         IQueryable <TblMarkup> query;
         if (filter != null)
         {
             var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);
             fullCount = entity.TblMarkups.Where(filter, parameterCollection.ToArray()).Count();
             query     = entity.TblMarkups.Include("TblMarkupGroup1")
                         .Where(filter, parameterCollection.ToArray()).OrderBy(sort).Skip(skip).Take(take);
         }
         else
         {
             fullCount = entity.TblMarkups.Count();
             query     = entity.TblMarkups.Include("TblMarkupGroup1")
                         .OrderBy(sort).Skip(skip).Take(take);
         }
         return(query.ToList());
     }
 }
예제 #9
0
 private List <TblSubFamily> GetTblSubFamily(int skip, int take, int groupId, string sort, string filter, Dictionary <string, object> valuesObjects, out int fullCount)
 {
     using (var context = new WorkFlowManagerDBEntities())
     {
         IQueryable <TblSubFamily> query;
         if (filter != null)
         {
             filter = filter + " and it.TblFamily ==(@Group0)";
             valuesObjects.Add("Group0", groupId);
             var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);
             fullCount = context.TblSubFamilies.Where(filter, parameterCollection.ToArray()).Count();
             query     = context.TblSubFamilies.Where(filter, parameterCollection.ToArray()).OrderBy(sort).Skip(skip).Take(take);
         }
         else
         {
             fullCount = context.TblSubFamilies.Count(v => v.TblFamily == groupId);
             query     = context.TblSubFamilies.OrderBy(sort).Where(v => v.TblFamily == groupId).Skip(skip).Take(take);
         }
         return(query.ToList());
     }
 }
예제 #10
0
 private List <TblPurchaseReceiveHeader> GetTblPurchaseReceiveHeader(int skip, int take, int groupId, string sort, string filter, Dictionary <string, object> valuesObjects, out int fullCount)
 {
     using (var context = new WorkFlowManagerDBEntities())
     {
         IQueryable <TblPurchaseReceiveHeader> query;
         if (filter != null)
         {
             filter = filter + " and it.TblPurchaseOrderHeaderRequest=(@group)";
             valuesObjects.Add("group", groupId);
             var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);
             fullCount = context.TblPurchaseReceiveHeaders.Include(nameof(TblPurchaseReceiveHeader.TblWarehouse1)).Where(filter, parameterCollection.ToArray()).Count();
             query     = context.TblPurchaseReceiveHeaders.Include(nameof(TblPurchaseReceiveHeader.TblWarehouse1)).Where(filter, parameterCollection.ToArray()).OrderBy(sort).Skip(skip).Take(take);
         }
         else
         {
             fullCount = context.TblPurchaseReceiveHeaders.Include(nameof(TblPurchaseReceiveHeader.TblWarehouse1)).Count(x => x.TblPurchaseOrderHeaderRequest == groupId);
             query     = context.TblPurchaseReceiveHeaders.Include(nameof(TblPurchaseReceiveHeader.TblWarehouse1)).OrderBy(sort).Where(v => v.TblPurchaseOrderHeaderRequest == groupId).Skip(skip).Take(take);
         }
         return(query.ToList());
     }
 }
예제 #11
0
        public List <EmployeesView> GetEmpTable(int skip, int take, string sort, string filter,
                                                Dictionary <string, object> valuesObjects, out int fullCount)
        {
            using (var context = new TimeAttEntities())
            {
                IQueryable <EmployeesView> query;
                if (filter != null)
                {
                    var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);

                    fullCount = context.EmployeesViews.Where(filter, parameterCollection.ToArray()).Count();
                    query     = context.EmployeesViews.Where(filter, parameterCollection.ToArray()).OrderBy(sort).Skip(skip).Take(take);
                }
                else
                {
                    fullCount = context.EmployeesViews.Count();
                    query     = context.EmployeesViews.OrderBy(sort).Skip(skip).Take(take);
                }

                return(query.ToList());
            }
        }
예제 #12
0
        private List <TblPurchaseOrderDetailRequest> GetTblPurchaseOrderDetailRequest(int skip, int take, int groupId, string sort, string filter, Dictionary <string, object> valuesObjects, out int fullCount, out Dictionary <int?, double?> purchaseRec)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                IQueryable <TblPurchaseOrderDetailRequest> query;
                if (filter != null)
                {
                    filter = filter + " and it.TblPurchaseOrderHeaderRequest=(@group)";
                    valuesObjects.Add("group", groupId);
                    var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);

                    fullCount = context.TblPurchaseOrderDetailRequests.Where(filter, parameterCollection.ToArray()).Count();
                    query     = context.TblPurchaseOrderDetailRequests.Include("TblPurchaseRequestLinks").Include("TblColor").Where(filter, parameterCollection.ToArray()).OrderBy(sort).Skip(skip).Take(take);
                }
                else
                {
                    fullCount = context.TblPurchaseOrderDetailRequests.Count(x => x.TblPurchaseOrderHeaderRequest == groupId);
                    query     = context.TblPurchaseOrderDetailRequests.Include("TblPurchaseRequestLinks").Include("TblColor").OrderBy(sort).Where(v => v.TblPurchaseOrderHeaderRequest == groupId).Skip(skip).Take(take);
                }
                var listofPurchase = query.Select(x => x.Iserial);
                purchaseRec = context.TblPurchaseReceiveDetails.Where(x => listofPurchase.Any(l => x.TblPurchaseOrderDetailRequest == l)).GroupBy(x => x.TblPurchaseOrderDetailRequest).ToDictionary(t => t.Key, t => t.Sum(w => w.Qty));
                return(query.ToList());
            }
        }
예제 #13
0
        private List <TblBankStatHeader> GetBankStatHeader(int skip, int take, string sort, string filter, Dictionary <string, object> valuesObjects,
                                                           out int fullCount, string company)
        {
            using (var context = new ccnewEntities(SharedOperation.GetSqlConnectionString(company)))
            {
                var defaultQuery = context.TblBankStatHeaders.Include(
                    nameof(TblBankStatHeader.TblBank1)).Include(
                    nameof(TblBankStatHeader.TblCurrency1));
                IQueryable <TblBankStatHeader> query;
                if (filter != null)
                {
                    var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);

                    fullCount = defaultQuery.Where(filter, parameterCollection.ToArray()).Count();
                    query     = defaultQuery.Where(filter, parameterCollection.ToArray()).OrderBy(sort);
                }
                else
                {
                    fullCount = defaultQuery.Count();
                    query     = defaultQuery.OrderBy(sort);
                }
                return(query.Skip(skip).Take(take).ToList());
            }
        }
예제 #14
0
        private List <TblStoreCommission> GetStoreCommission(string sort, string filter,
                                                             Dictionary <string, object> valuesObjects, string company)
        {
            using (var context = new ccnewEntities(service.GetSqlConnectionString(company)))
            {
                IQueryable <TblStoreCommission> query;
                var defaultQuery = context.TblStoreCommissions;
                IEnumerable <TblStoreCommission> notSavedStores = new List <TblStoreCommission>();
                if (string.IsNullOrWhiteSpace(filter))
                {
                    query          = defaultQuery.OrderBy(sort);
                    notSavedStores = context.TblStores
                                     .Where(s => !query.Any(q => q.Tblstore == s.iserial) && s.Type != 2)
                                     .OrderBy(s => s.code)
                                     .Select(s => new
                    {
                        s.iserial,
                    }).ToList().Select(s => new TblStoreCommission
                    {
                        Tblstore = s.iserial,
                        IsActive = false,
                    });
                }
                else
                {
                    filter = filter.Replace("it.code", "it.Tblstore1.code").Replace("it.ENAME", "it.Tblstore1.ENAME");
                    var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);

                    query = defaultQuery.Where(filter, parameterCollection.ToArray()).OrderBy(sort);
                }

                var result = query.ToList();
                result.AddRange(notSavedStores);
                return(result);
            }
        }
예제 #15
0
 private List <TblSalaryApprovalHeader> GetSalaryApprovalHeader(int skip, int take, string sort, string filter,
                                                                Dictionary <string, object> valuesObjects, int userIserial, out int fullCount, string company)
 {
     using (var context = new ccnewEntities(SharedOperation.GetSqlConnectionString(company)))
     {
         IQueryable <TblSalaryApprovalHeader> query;
         if (filter != null)
         {
             //filter = filter + " and it.Code LIKE(@Code0)";
             //valuesObjects.Add("Code0", accCode);
             var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);
             fullCount = context.TblSalaryApprovalHeaders
                         .Where(filter, parameterCollection.ToArray()).Count();
             query = context.TblSalaryApprovalHeaders.Include(nameof(TblSalaryApprovalHeader.TblStore1)).Include(nameof(TblSalaryApprovalHeader.TblSalaryType1))
                     .Where(filter, parameterCollection.ToArray()).OrderBy(sort).Skip(skip).Take(take);
         }
         else
         {
             fullCount = context.TblSalaryApprovalHeaders.Count();
             query     = context.TblSalaryApprovalHeaders.Include(nameof(TblSalaryApprovalHeader.TblStore1)).Include(nameof(TblSalaryApprovalHeader.TblSalaryType1)).OrderBy(sort).Skip(skip).Take(take);
         }
         return(query.ToList());
     }
 }
예제 #16
0
        private List <TblContractHeader> GetContractHeader(int skip, int take, string sort, string filter,
                                                           Dictionary <string, object> valuesObjects, int userIserial, out int fullCount, string company)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                context.CommandTimeout = 0;

                var defaultQuery = context.TblContractHeaders.Include(
                    nameof(TblContractHeader.TblLkpSeason1)).Include(
                    nameof(TblContractHeader.TblLkpBrandSection1)).Include(
                    nameof(TblContractHeader.TblSubContractor1));
                IQueryable <TblContractHeader> query;
                if (valuesObjects == null)
                {
                    valuesObjects = new Dictionary <string, object>();
                }
                var    styleCodeFilter = valuesObjects.Where(o => o.Key.StartsWith("TblContractDetails_TblSalesOrderColor1_TblSalesOrder1_TblStyle1_StyleCode"));
                string styleCode       = string.Empty;
                if (styleCodeFilter.Count() > 0)
                {
                    styleCode = styleCodeFilter.ElementAt(0).Value.ToString().Replace("%", "");
                    styleCodeFilter.ToArray().ForEach(f =>
                    {
                        valuesObjects.Remove(f.Key);
                        filter = filter.Replace(
                            string.Format("it.TblContractDetails.TblSalesOrderColor1.TblSalesOrder1.TblStyle1.StyleCode LIKE(@{0})",
                                          f.Key), "");
                    });
                    filter = filter.Trim();
                    if (filter.ToLower().StartsWith("and"))
                    {
                        filter = filter.Remove(0, 3);
                    }
                    if (filter.ToLower().EndsWith("and"))
                    {
                        filter = filter.Remove(filter.Length - 3 - 1, 3);
                    }
                }
                if (!string.IsNullOrWhiteSpace(filter))
                {
                    filter = SharedOperation.GetBrandPerUser(filter, valuesObjects, userIserial, context)
                             .Replace("it.Brand", "it.BrandCode").Replace("it.BrandCodeCode", "it.BrandCode");
                    var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);
                    //var parameterCollection = valuesObjects.Select(valuesObject => new System.Data.Objects.ObjectParameter(valuesObject.Key, valuesObject.Value)).ToList();
                    fullCount = defaultQuery.Where(filter, parameterCollection.ToArray()).Count();
                    query     = defaultQuery.Where(filter, parameterCollection.ToArray()).OrderBy(sort);
                }
                else
                {
                    fullCount = defaultQuery.Count(x =>
                                                   x.TblLkpBrandSection1.TblUserBrandSections.Any(
                                                       e => e.TblAuthUser == userIserial && e.BrandCode == x.BrandCode));
                    query = defaultQuery.OrderBy(sort).Where(
                        x =>
                        x.TblLkpBrandSection1.TblUserBrandSections.Any(
                            e => e.TblAuthUser == userIserial && e.BrandCode == x.BrandCode));
                }

                List <TblContractHeader> result;
                if (!string.IsNullOrWhiteSpace(styleCode))
                {
                    query = query.Where(r =>
                                        r.TblContractDetails.Any(d => d.TblSalesOrderColor1.TblSalesOrder1.TblStyle1.StyleCode.Contains(styleCode)));
                    fullCount = query.Count();
                    try
                    {
                        //    var sql = ((System.Data.Objects.ObjectQuery)query).ToTraceString();

                        //result = query.AsNoTracking().ToList();
                        result = query.ToList();
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                }
                else
                {
                    result = query.Skip(skip).Take(take).ToList();
                }
                var db = new ccnewEntities(SharedOperation.GetSqlConnectionString(company));
                foreach (var item in result)
                {
                    item.Supplier = db.TBLsuppliers.FirstOrDefault(s => s.Iserial == item.SupplierIserial);
                    item.Currency = db.TblCurrencyTests.FirstOrDefault(c => c.Iserial == item.TblCurrency);
                }
                return(result);
            }
        }
예제 #17
0
        public List <TblTradeAgreementDetail> GetTblTradeAgreementDetailList(int skip, int take, int tradeAgreementTransaction,
                                                                             string sort, string filter, Dictionary <string, object> valuesObjects,
                                                                             out int fullCount, out List <ItemsDto> itemsList, out List <Vendor> vendorsList)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                IQueryable <TblTradeAgreementDetail> query;
                if (filter != null)
                {
                    filter = filter + " and it.TblTradeAgreementHeader.TblTradeAgreementTransaction LIKE(@TblTradeAgreementTransaction0)";
                    valuesObjects.Add("TblTradeAgreementTransaction0", tradeAgreementTransaction);
                    var parameterCollection = SharedOperation.ConvertToParamters(valuesObjects);
                    fullCount = context.TblTradeAgreementDetails.Include(string.Format("{0}.{1}",
                                                                                       nameof(TblTradeAgreementDetail.TblTradeAgreementHeader1), nameof(TblTradeAgreementHeader.TblTradeAgreementTransaction1)))
                                .Where(filter, parameterCollection.ToArray()).Count();
                    query = context.TblTradeAgreementDetails.Include(nameof(TblTradeAgreementDetail.TblTradeAgreementHeader1)).Include(
                        string.Format("{0}.{1}", nameof(TblTradeAgreementDetail.TblTradeAgreementHeader1), nameof(
                                          TblTradeAgreementHeader.TblTradeAgreementTransaction1))).Include(nameof(TblTradeAgreementDetail.TblColor1)).Where(
                        filter, parameterCollection.ToArray()).OrderBy(sort).Skip(skip).Take(take);
                }
                else
                {
                    fullCount = context.TblTradeAgreementDetails.Count(x => x.TblTradeAgreementHeader1.TblTradeAgreementTransaction == tradeAgreementTransaction);
                    query     = context.TblTradeAgreementDetails.Include(nameof(TblTradeAgreementDetail.TblTradeAgreementHeader1)).Include(
                        string.Format("{0}.{1}", nameof(TblTradeAgreementDetail.TblTradeAgreementHeader1), nameof(
                                          TblTradeAgreementHeader.TblTradeAgreementTransaction1))).Include(nameof(TblTradeAgreementDetail.TblColor1)).Where(
                        x => x.TblTradeAgreementHeader1.TblTradeAgreementTransaction == tradeAgreementTransaction).OrderBy(sort).Skip(skip).Take(take);
                }

                var fabricsIserial = query.Where(x => x.ItemType != "Accessories").Select(x => x.ItemCode);

                var accIserial = query.Where(x => x.ItemType == "Accessories").Select(x => x.ItemCode);
                //fabricInventList = temp.Where(x => lineNumbers.All(l => x.LINENUM != l));
                var itemsquery = (from x in context.tbl_FabricAttriputes.Include(nameof(tbl_FabricAttriputes.tbl_lkp_UoM)).Include(
                                      nameof(tbl_FabricAttriputes.tbl_lkp_FabricMaterials))
                                  where (fabricsIserial.Any(l => x.Iserial == l))
                                  select new ItemsDto
                {
                    Iserial = x.Iserial,
                    Code = x.FabricID,
                    Name = x.FabricDescription,
                    ItemGroup = x.tbl_lkp_FabricMaterials.Ename,
                    Unit = x.tbl_lkp_UoM.Ename
                }).ToList();

                itemsquery.AddRange((from x in context.tbl_AccessoryAttributesHeader
                                     where (accIserial.Any(l => x.Iserial == l))
                                     select new ItemsDto
                {
                    Iserial = x.Iserial,
                    Code = x.Code,
                    Name = x.Descreption,
                    ItemGroup = "Accessories",
                    IsSizeIncluded = x.IsSizeIncludedInHeader,
                    Unit = context.tbl_lkp_UoM.FirstOrDefault(s => s.Iserial == x.UoMID).Ename,
                }).ToList());
                itemsList   = itemsquery;
                vendorsList = context.Vendors.Where(v => query.Any(q => q.TblTradeAgreementHeader1.Vendor == v.vendor_code)).ToList();
                return(query.ToList());
            }
        }