Exemplo n.º 1
0
 public static List <OITM_Articles> GetGenericBranchArticles(OWHS_Branch branch)
 {
     lock (Extensions.Locker)
     {
         var db = ContextFactory.GetDBContext();
         return
             (branch.OITW_BranchArticles.Join(db.OITM_Articles,
                                              ba => ba.ItemCode, a => a.ItemCode,
                                              (ba, a) => new { branchArticle = ba, article = a })
              .Select(obj => obj.article).ToList());
     }
 }
        public static ObservableCollection <WTQ1_TransferRequestDetails> GetFilteredTransferRequestDetails(OWHS_Branch selectedBranchStore, OWTQ_TransferRequest transferRequest = null)
        {
            lock (Extensions.Locker)
            {
                var db = ContextFactory.GetDBContext();

                //de la branch

                var branchDetails = (

                    from t2 in db.OITW_BranchArticles                                   // sucursal a la que se le pide
                    join t1 in db.OITW_BranchArticles on t2.ItemCode equals t1.ItemCode //sucursal que pide
                    join t0 in db.OITM_Articles on t2.ItemCode equals t0.ItemCode
                    join t3 in db.UCategories on t0.U_categoria equals t3.Code
                    join t4 in db.UWarehouseOrders on t3.Code equals t4.IdCategory
                    where !string.IsNullOrEmpty(t0.TemplateL) && t0.TemplateL.ToLower().Contains("y") && t4.Whscode == selectedBranchStore.WhsCode &&
                    t0.validFor.Contains("Y") && t1.Locked.Contains("N") && t2.Locked.Contains("N") && t0.InvntItem.Contains("Y") && //Todos los filtros de los articulos
                    t1.WhsCode == Config.WhsCode &&
                    t2.WhsCode == selectedBranchStore.WhsCode
                    select new
                {
                    WhsCode = Config.WhsCode,
                    InvntryUom = t0.InvntryUom,
                    ItemCode = t2.ItemCode,
                    ItemName = t0.ItemName,
                    OnHand1 = t1.OnHand1 ?? 0,
                    Line = t3 != null ? t3.Name : string.Empty,
                    LineCode = t3 != null ? t3.Code : string.Empty,
                    Quantity = 0
                }).ToList();

                if (transferRequest.IdTransferRequestL > 0)
                {
                    var collection = (from trd in branchDetails
                                      join strd in transferRequest.WTQ1_TransferRequestDetails
                                      on trd.ItemCode equals strd.ItemCode into jtrds
                                      from jtrd in jtrds.DefaultIfEmpty()
                                      select new
                    {
                        ItemCode = trd.ItemCode,
                        Quantity = jtrd != null ? jtrd.Quantity : trd.Quantity,
                        WhsCode = trd.WhsCode,
                        ItemName = trd.ItemName,
                        InvntryUom = trd.InvntryUom,
                        OnHand1 = trd.OnHand1,
                        Line = trd.Line,
                        LineCode = trd.LineCode,
                        CreatedDateL = jtrd != null ? jtrd.CreatedDateL : DateTime.Now,
                        CreatedByL = jtrd != null ? jtrd.CreatedByL : Config.CurrentUser,
                        ModifiedByL = jtrd != null ? jtrd.ModifiedByL : Config.CurrentUser,
                        ModifiedDateL = jtrd != null ? jtrd.ModifiedDateL : DateTime.Now,
                    }).ToList();

                    var savedDetils = collection.Select(v => new WTQ1_TransferRequestDetails()
                    {
                        ItemCode      = v.ItemCode,
                        Quantity      = v.Quantity,
                        WhsCode       = v.WhsCode,
                        ItemName      = v.ItemName,
                        InvntryUom    = v.InvntryUom,
                        OnHand1       = v.OnHand1,
                        Line          = v.Line,
                        LineCode      = v.LineCode,
                        CreatedDateL  = v.CreatedDateL,
                        CreatedByL    = v.CreatedByL,
                        ModifiedByL   = v.ModifiedByL,
                        ModifiedDateL = v.ModifiedDateL
                    }).ToList();
                    return(new ObservableCollection <WTQ1_TransferRequestDetails>(savedDetils));
                }
                var details = branchDetails.Select(v => new WTQ1_TransferRequestDetails()
                {
                    InvntryUom = v.InvntryUom,
                    ItemCode   = v.ItemCode,
                    ItemName   = v.ItemName,
                    OnHand1    = v.OnHand1,
                    Line       = v.Line,
                    LineCode   = v.LineCode,
                    Quantity   = v.Quantity
                }).ToList();
                return(new ObservableCollection <WTQ1_TransferRequestDetails>(details));
            }
        }
Exemplo n.º 3
0
        public static List <OITM_Articles> GetBranchArticles(OWHS_Branch branch)
        {
            var loop = branch.OITW_BranchArticles;

            return(loop.Select(ba => ba.OITM_Articles).ToList());
        }