Beispiel #1
0
        /// <summary>
        /// FinancialInvoiceList constructor
        /// </summary>
        public Shipment_List(string shipmentCode = "", bool addEditEnabled = true)
        {
            // Get required service
            ShipmentService = DependencyResolver.Kernel.Get <IShipmentService>();

            ShipmentDocumentService = DependencyResolver.Kernel.Get <IShipmentDocumentService>();

            // Draw all components
            InitializeComponent();

            this.DataContext = this;
            ShipmentSearchObject.SearchBy_ShipmentNumber = shipmentCode;
            AddEditEnabled = addEditEnabled;
        }
        public Shipment_Document_AddEdit(ShipmentViewModel Shipment)
        {
            ShipmentService         = DependencyResolver.Kernel.Get <IShipmentService>();
            ShipmentDocumentService = DependencyResolver.Kernel.Get <IShipmentDocumentService>();

            InitializeComponent();

            this.DataContext = this;

            CurrentShipment                        = Shipment;
            CurrentShipmentDocumentForm            = new ShipmentDocumentViewModel();
            CurrentShipmentDocumentForm.Identifier = Guid.NewGuid();
            CurrentShipmentDocumentForm.ItemStatus = ItemStatus.Added;

            Thread displayThread = new Thread(() => DisplayShipmentDocumentData());

            displayThread.IsBackground = true;
            displayThread.Start();

            btnAddDocument.Focus();
        }
 public ShipmentDocumentController(IServiceProvider provider)
 {
     ShipmentDocumentService = provider.GetRequiredService <IShipmentDocumentService>();
 }
Beispiel #4
0
        public void Sync(IShipmentDocumentService ShipmentDocumentService, Action <int, int> callback = null)
        {
            try
            {
                SyncShipmentDocumentRequest request = new SyncShipmentDocumentRequest();
                request.CompanyId     = MainWindow.CurrentCompanyId;
                request.LastUpdatedAt = GetLastUpdatedAt(MainWindow.CurrentCompanyId);

                int toSync      = 0;
                int syncedItems = 0;

                ShipmentDocumentListResponse response = ShipmentDocumentService.Sync(request);
                if (response.Success)
                {
                    toSync = response?.ShipmentDocuments?.Count ?? 0;
                    List <ShipmentDocumentViewModel> items = response.ShipmentDocuments;

                    using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
                    {
                        db.Open();
                        using (var transaction = db.BeginTransaction())
                        {
                            SqliteCommand deleteCommand = db.CreateCommand();
                            deleteCommand.CommandText = "DELETE FROM ShipmentDocuments WHERE Identifier = @Identifier";

                            SqliteCommand insertCommand = db.CreateCommand();
                            insertCommand.CommandText = SqlCommandInsertPart;

                            foreach (var item in items)
                            {
                                deleteCommand.Parameters.AddWithValue("@Identifier", item.Identifier);
                                deleteCommand.ExecuteNonQuery();
                                deleteCommand.Parameters.Clear();

                                if (item.IsActive)
                                {
                                    item.IsSynced = true;

                                    insertCommand = AddCreateParameters(insertCommand, item);
                                    insertCommand.ExecuteNonQuery();
                                    insertCommand.Parameters.Clear();

                                    syncedItems++;
                                    callback?.Invoke(syncedItems, toSync);
                                }
                            }

                            transaction.Commit();
                        }
                        db.Close();
                    }
                }
                else
                {
                    throw new Exception(response.Message);
                }
            }
            catch (Exception ex)
            {
                MainWindow.ErrorMessage = ex.Message;
            }
        }