예제 #1
0
        /// <summary>
        /// FinancialInvoiceList constructor
        /// </summary>
        public InputInvoiceList()
        {
            // Get required service
            this.inputInvoiceService         = DependencyResolver.Kernel.Get <IInputInvoiceService>();
            this.inputInvoiceNoteService     = DependencyResolver.Kernel.Get <IInputInvoiceNoteService>();
            this.inputInvoiceDocumentService = DependencyResolver.Kernel.Get <IInputInvoiceDocumentService>();

            // Draw all components
            InitializeComponent();

            this.DataContext = this;
        }
예제 #2
0
        public InputInvoice_Note_AddEdit(InputInvoiceViewModel inputInvoice)
        {
            inputInvoiceService     = DependencyResolver.Kernel.Get <IInputInvoiceService>();
            inputInvoiceNoteService = DependencyResolver.Kernel.Get <IInputInvoiceNoteService>();

            InitializeComponent();

            this.DataContext = this;

            CurrentInputInvoice                    = inputInvoice;
            CurrentInputInvoiceNoteForm            = new InputInvoiceNoteViewModel();
            CurrentInputInvoiceNoteForm.Identifier = Guid.NewGuid();
            CurrentInputInvoiceNoteForm.ItemStatus = ItemStatus.Added;

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

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

            btnAddNote.Focus();
        }
 public InputInvoiceNoteController(IServiceProvider provider)
 {
     InputInvoiceNoteService = provider.GetRequiredService <IInputInvoiceNoteService>();
 }
예제 #4
0
        public void Sync(IInputInvoiceNoteService InputInvoiceNoteservice, Action <int, int> callback = null)
        {
            try
            {
                SyncInputInvoiceNoteRequest request = new SyncInputInvoiceNoteRequest();
                request.CompanyId     = MainWindow.CurrentCompanyId;
                request.LastUpdatedAt = GetLastUpdatedAt(MainWindow.CurrentCompanyId);

                int toSync      = 0;
                int syncedItems = 0;

                InputInvoiceNoteListResponse response = InputInvoiceNoteservice.Sync(request);
                if (response.Success)
                {
                    toSync = response?.InputInvoiceNotes?.Count ?? 0;
                    List <InputInvoiceNoteViewModel> items = response.InputInvoiceNotes;

                    using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
                    {
                        db.Open();
                        using (var transaction = db.BeginTransaction())
                        {
                            SqliteCommand deleteCommand = db.CreateCommand();
                            deleteCommand.CommandText = "DELETE FROM InputInvoiceNotes 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;
            }
        }