public override void ExecuteNewCommand()
 {
     TransferRequest     = null;
     TransferRequest     = new OWTQ_TransferRequest();
     SelectedSerie       = null;
     SelectedBranchStore = null;
     FormTitle           = "Nuevo Pedido";
     ShowDialog(new NewTransferRequestView(), this);
 }
示例#2
0
        //public static void UploadPendingChanges()
        //{
        //    if (!WebApiClient.IsAvailableConnection) return;

        //    //TransferRequestHelper.GetPendingToSyncOrders()
        //    //.ForEach(transfer=> SyncUpload(transfer));

        //    //PurchaseHelper.GetPendingToSyncPurchases()
        //    //.ForEach(purchase=> purchase.Upload(SyncUpload,true));

        //    //var sales = SalesHelper.GetPendingToSyncSales();
        //    //sales.ForEach(sale=> SyncUpload(sale));

        //    //var notes = SupplierCreditNoteHelper.GetPendingtoSyncNotes();
        //    //notes.ForEach(note => SyncUpload(note));

        //    //var receipts = GoodsReceiptHelper.GetPendingToSync();
        //    //receipts.ForEach(receipt=> SyncUpload(receipt));

        //    //var goodIssues = GoodIssuesHelper.GetPendingToSync();
        //    //goodIssues.ForEach(issue=> SyncUpload(issue));

        //    //var downPayments = DownPaymentHelper.GetPendingToSync();
        //    //downPayments.ForEach(dp=> SyncUpload(dp));

        //    //var inventoryCount = InventoryCountHelper.GetOpenInventoryCountForToday();

        //    //inventoryCount.ForEach(InventoryCountHelper.Process);
        //}

        private static OWTQ_TransferRequest SyncUpload(OWTQ_TransferRequest transferRequest)

        {
            var transfer = WebApiClient.AddTransfer(transferRequest).Result;

            transferRequest.UpdateModelPropertiesFrom(transfer.Model);
            transferRequest.StateL = LocalStatus.Procesado;
            transfer.UpdateEntityVersion();
            return(transferRequest);
        }
 public static void Add(OWTQ_TransferRequest transferRequest)
 {
     lock (Extensions.Locker)
     {
         var db = ContextFactory.GetDBContext();
         using (var scope = new TransactionScope())
         {
             db.OWTQ_TransferRequest.Add(transferRequest);
             db.SaveChanges();
             scope.Complete();
         }
     }
 }
示例#4
0
 public static OWTQ_TransferRequest Synchronize(OWTQ_TransferRequest model)
 {
     CheckForUpdates();// Actualizar cambios antes de subir y verificar si el objeto no fue ya procesado
     model = TransferRequestHelper.Get(model.IdTransferRequestL);
     if (model.StateL != LocalStatus.Procesado)
     {
         return(model.Upload(SyncUpload));
     }
     else
     {
         return(model);
     }
 }
        // CODIGO CHAMPERO REMOVIDO :)
        //public static void Update(OWTQ_TransferRequest transferRequest, List<WTQ1_TransferRequestDetails> details) {
        //    lock (Extensions.Locker)
        //    {

        //        var db = ContextFactory.GetDBContext();
        //        using (var scope = new TransactionScope())
        //        {
        //            if (transferRequest.WTQ1_TransferRequestDetails.Any())
        //            {

        //                db.Database.ExecuteSqlCommand(
        //                    string.Format("DELETE FROM WTQ1_TransferRequestDetails WHERE IdTransferRequestL = {0}",
        //                        transferRequest.IdTransferRequestL));
        //               // db.SaveChanges();

        //                foreach(var detail in details){ transferRequest.WTQ1_TransferRequestDetails.Add(detail);}

        //            }
        //            db.SaveChanges();
        //            scope.Complete();
        //        }
        //    }
        //}
        public static void AddOrUpdate(OWTQ_TransferRequest transfer)
        {
            lock (Extensions.Locker)
            {
                var db = ContextFactory.GetDBContext();

                if (transfer.IdTransferRequestL == 0)
                {
                    db.OWTQ_TransferRequest.Add(transfer);
                }
                else
                {
                    transfer.ChangeEntityState(EntityState.Modified);
                }
            }
        }
        public static void Delete(OWTQ_TransferRequest transferRequest)
        {
            lock (Extensions.Locker)
            {
                var db = ContextFactory.GetDBContext();
                using (var scope = new TransactionScope())
                {
                    //transferRequest.WTQ1_TransferRequestDetails.ToList().ForEach(t => db.WTQ1_TransferRequestDetails.Remove(t));
                    if (transferRequest.IdTransferRequestL != 0)
                    {
                        db.OWTQ_TransferRequest.Remove(transferRequest);

                        db.SaveChanges();
                        scope.Complete();
                    }
                }
            }
        }
        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));
            }
        }
示例#8
0
 public static Task <Synchro <OWTQ_TransferRequest> > AddTransfer(OWTQ_TransferRequest order)
 {
     return(PostAsync <OWTQ_TransferRequest, Synchro <OWTQ_TransferRequest> >("api/orders", order));
 }