Exemplo n.º 1
0
        public void DisplayData()
        {
            InputInvoiceDataLoading = true;

            InputInvoiceListResponse response = new InputInvoiceSQLiteRepository()
                                                .GetInputInvoicesByPage(MainWindow.CurrentCompanyId, InputInvoiceSearchObject, currentPage, itemsPerPage);

            if (response.Success)
            {
                InputInvoicesFromDB = new ObservableCollection <InputInvoiceViewModel>(response.InputInvoices ?? new List <InputInvoiceViewModel>());
                totalItems          = response.TotalItems;
            }
            else
            {
                InputInvoicesFromDB     = new ObservableCollection <InputInvoiceViewModel>();
                totalItems              = 0;
                MainWindow.ErrorMessage = response.Message;
            }

            int itemFrom = totalItems != 0 ? (currentPage - 1) * itemsPerPage + 1 : 0;
            int itemTo   = currentPage * itemsPerPage < totalItems ? currentPage * itemsPerPage : totalItems;

            PaginationDisplay = itemFrom + " - " + itemTo + " od " + totalItems;

            InputInvoiceDataLoading = false;
        }
        private void BtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (currentInputInvoice?.BusinessPartner == null)
            {
                MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Poslovni_partner"));
                return;
            }

            #endregion

            Thread td = new Thread(() => {
                SubmitButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke"));
                SubmitButtonEnabled = false;

                currentInputInvoice.IsSynced = false;
                currentInputInvoice.Company  = new CompanyViewModel()
                {
                    Id = MainWindow.CurrentCompanyId
                };
                currentInputInvoice.CreatedBy = new UserViewModel()
                {
                    Id = MainWindow.CurrentUserId
                };

                InputInvoiceResponse response = new InputInvoiceSQLiteRepository().Create(currentInputInvoice);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_lokalnog_čuvanjaUzvičnik"));
                    SubmitButtonContent     = ((string)Application.Current.FindResource("Proknjiži"));
                    SubmitButtonEnabled     = true;
                }

                response = InputInvoiceService.Create(currentInputInvoice);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Podaci_su_sačuvani_u_lokaluUzvičnikTačka_Greška_kod_čuvanja_na_serveruUzvičnik"));
                    SubmitButtonContent     = ((string)Application.Current.FindResource("Proknjiži"));
                    SubmitButtonEnabled     = true;
                }

                if (response.Success)
                {
                    MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_sačuvaniUzvičnik"));
                    SubmitButtonContent       = ((string)Application.Current.FindResource("Proknjiži"));
                    SubmitButtonEnabled       = true;

                    new InputInvoiceSQLiteRepository().Sync(InputInvoiceService);

                    InputInvoiceCreatedUpdated();

                    Application.Current.Dispatcher.BeginInvoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(() =>
                    {
                        FlyoutHelper.CloseFlyout(this);
                    })
                        );
                }
            });
            td.IsBackground = true;
            td.Start();
        }
        public InputInvoice_ReportWindow(InputInvoiceViewModel inputInvoiceView)
        {
            InitializeComponent();

            rdlcInputInvoiceReport.LocalReport.DataSources.Clear();

            List <InputInvoicesReportsViewModel> inputInvoice      = new List <InputInvoicesReportsViewModel>();
            List <InputInvoiceViewModel>         InputInvoiceItems = new InputInvoiceSQLiteRepository().GetInputInvoicesByPage(MainWindow.CurrentCompanyId, InputInvoiceSearchObject, 1, 50).InputInvoices;
            int counter = 1;

            foreach (var InputInvoiceItem in InputInvoiceItems)
            {
                inputInvoice.Add(new InputInvoicesReportsViewModel()
                {
                    OrderNumbersForInputInvoices = counter++,
                    BusinessPartnerName          = InputInvoiceItem?.BusinessPartner?.Name ?? "",
                    Supplier       = InputInvoiceItem?.Supplier ?? "",
                    Address        = InputInvoiceItem?.Address ?? "",
                    InvoiceNumber  = InputInvoiceItem?.InvoiceNumber ?? "",
                    InvoiceDate    = InputInvoiceItem?.InvoiceDate.ToString("dd.MM.yyyy") ?? "",
                    AmountNet      = InputInvoiceItem?.AmountNet.ToString("#.00") ?? "",
                    PDVPercent     = InputInvoiceItem?.PDVPercent.ToString("#.00") ?? "",
                    PDV            = InputInvoiceItem?.PDV.ToString() ?? "",
                    AmountGros     = InputInvoiceItem?.AmountGross.ToString("#.00") ?? "",
                    Currency       = InputInvoiceItem?.Currency.ToString("#.00") ?? "",
                    DateOfPaymetse = InputInvoiceItem?.DateOfPaymet.ToString("dd.MM.yyyy") ?? "",
                    Statuse        = InputInvoiceItem?.Status.ToString() ?? "",
                    StatusDate     = InputInvoiceItem?.StatusDate.ToString("dd.MM.yyyy") ?? ""
                });
            }
            var rpdsModel = new ReportDataSource()
            {
                Name  = "DataSet1",
                Value = inputInvoice
            };

            rdlcInputInvoiceReport.LocalReport.DataSources.Add(rpdsModel);

            //List<ReportParameter> reportParams = new List<ReportParameter>();
            //string parameterText = "Dana " + (CurrentInputInvoice?.InvoiceDate.ToString("dd.MM.yyyy") ?? "") + " na stočni depo klanice Bioesen primljeno je:";
            //reportParams.Add(new ReportParameter("txtInputInvoiceDate", parameterText));


            //var businessPartnerList = new List<InvoiceBusinessPartnerViewModel>();
            //businessPartnerList.Add(new InvoiceBusinessPartnerViewModel() { Name = "Pera peric " });
            //var businessPartnerModel = new ReportDataSource() { Name = "DataSet2", Value = businessPartnerList };
            //rdlcInputNoteReport.LocalReport.DataSources.Add(businessPartnerModel);

            //////string exeFolder = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory())));
            //////string ContentStart = System.IO.Path.Combine(exeFolder, @"SirmiumERPGFC\RdlcReports\InputInvoices\InputInvoicesReport.rdlc");

            //////rdlcInputInvoiceReport.LocalReport.ReportPath = ContentStart;
            string exeFolder    = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            string ContentStart = System.IO.Path.Combine(exeFolder, @"RdlcReports\InputInvoices\InputInvoicesReport.rdlc");

            rdlcInputInvoiceReport.LocalReport.ReportPath = ContentStart;
            // rdlcInputInvoiceReport.LocalReport.SetParameters(reportParams);
            rdlcInputInvoiceReport.SetDisplayMode(DisplayMode.PrintLayout);
            rdlcInputInvoiceReport.Refresh();
            rdlcInputInvoiceReport.ZoomMode    = ZoomMode.Percent;
            rdlcInputInvoiceReport.ZoomPercent = 100;
            rdlcInputInvoiceReport.RefreshReport();
        }