public OutputInvoiceResponse Create(OutputInvoiceViewModel outputInvoice)
        {
            OutputInvoiceResponse response = new OutputInvoiceResponse();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                SqliteCommand insertCommand = db.CreateCommand();
                insertCommand.CommandText = SqlCommandInsertPart;

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, outputInvoice);
                    insertCommand.ExecuteNonQuery();
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    return(response);
                }
                db.Close();

                response.Success = true;
                return(response);
            }
        }
        public OutputInvoiceResponse Update(OutputInvoiceViewModel oi)
        {
            OutputInvoiceResponse response = new OutputInvoiceResponse();

            try
            {
                //List<OutputInvoiceItem> outputInvoiceItems = oi.ConvertToOutputInvoice().InvoiceItems;
                //oi.SumOfBase = outputInvoiceItems.Sum(x => x.Base);
                //oi.SumOfPdvValue = outputInvoiceItems.Sum(x => x.Pdv);
                //oi.SumOfTotalValue = outputInvoiceItems.Sum(x => x.TotalPrice);
                //oi.OutputInvoiceSubItems = null;

                OutputInvoice updatedOutputInvoice = unitOfWork.GetOutputInvoiceRepository().Update(oi.ConvertToOutputInvoice());

                //unitOfWork.GetOutputInvoiceItemRepository().UpdateOutputInvoiceItems(outputInvoiceItems ?? new List<OutputInvoiceItem>(), updatedOutputInvoice);

                unitOfWork.Save();

                response.OutputInvoice = updatedOutputInvoice.ConvertToOutputInvoiceViewModel();
                response.Success       = true;
            }
            catch (Exception ex)
            {
                response.OutputInvoice = new OutputInvoiceViewModel();
                response.Success       = false;
                response.Message       = ex.Message;
            }

            return(response);
        }
        private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, OutputInvoiceViewModel OutputInvoice)
        {
            insertCommand.Parameters.AddWithValue("@ServerId", OutputInvoice.Id);
            insertCommand.Parameters.AddWithValue("@Identifier", OutputInvoice.Identifier);
            insertCommand.Parameters.AddWithValue("@Code", ((object)OutputInvoice.Code) ?? DBNull.Value);

            insertCommand.Parameters.AddWithValue("@BusinessPartnerId", ((object)OutputInvoice.BusinessPartner?.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerIdentifier", ((object)OutputInvoice.BusinessPartner?.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerCode", ((object)OutputInvoice.BusinessPartner?.Code) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerName", ((object)OutputInvoice.BusinessPartner?.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerInternalCode", ((object)OutputInvoice.BusinessPartner?.InternalCode) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerNameGer", ((object)OutputInvoice.BusinessPartner?.NameGer) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Supplier", ((object)OutputInvoice.Supplier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Address", ((object)OutputInvoice.Address) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@InvoiceNumber", ((object)OutputInvoice.InvoiceNumber) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@InvoiceDate", ((object)OutputInvoice.InvoiceDate) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@AmountNet", ((object)OutputInvoice.AmountNet) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@PdvPercent", ((object)OutputInvoice.PdvPercent) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Pdv", ((object)OutputInvoice.Pdv) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@AmountGross", ((object)OutputInvoice.AmountGross) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Currency", ((object)OutputInvoice.Currency) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@DateOfPayment", ((object)OutputInvoice.DateOfPayment) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Status", ((object)OutputInvoice.Status) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@StatusDate", ((object)OutputInvoice.StatusDate) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Description", ((object)OutputInvoice.Description) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Path", ((object)OutputInvoice.Path) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@IsSynced", OutputInvoice.IsSynced);
            insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)OutputInvoice.UpdatedAt) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CreatedById", MainWindow.CurrentUser.Id);
            insertCommand.Parameters.AddWithValue("@CreatedByName", MainWindow.CurrentUser.FirstName + " " + MainWindow.CurrentUser.LastName);
            insertCommand.Parameters.AddWithValue("@CompanyId", MainWindow.CurrentCompany.Id);
            insertCommand.Parameters.AddWithValue("@CompanyName", MainWindow.CurrentCompany.CompanyName);

            return(insertCommand);
        }
示例#4
0
        public JsonResult CancelOutputInvoice([FromBody] OutputInvoiceViewModel inOI)
        {
            OutputInvoiceResponse response = new OutputInvoiceResponse();

            try
            {
                if (inOI != null && inOI.Id > 0)
                {
                    response = this.outputInvoiceService.CancelOutputInvoice(inOI.Id);
                }
                else
                {
                    response.Success = false;
                    string errorMessage = "Prilikom storniranja izlaznog racuna id nije prosledjen.";
                    response.Message = errorMessage;
                    Console.WriteLine(errorMessage);
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
                Console.WriteLine(ex.Message);
            }

            return(Json(response, new Newtonsoft.Json.JsonSerializerSettings()
            {
                Formatting = Newtonsoft.Json.Formatting.Indented
            }));
        }
        private static OutputInvoiceViewModel Read(SqliteDataReader query)
        {
            int counter = 0;
            OutputInvoiceViewModel dbEntry = new OutputInvoiceViewModel();

            dbEntry.Id              = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.Identifier      = SQLiteHelper.GetGuid(query, ref counter);
            dbEntry.Code            = SQLiteHelper.GetString(query, ref counter);
            dbEntry.BusinessPartner = SQLiteHelper.GetBusinessPartner(query, ref counter);
            dbEntry.Supplier        = SQLiteHelper.GetString(query, ref counter);
            dbEntry.Address         = SQLiteHelper.GetString(query, ref counter);
            dbEntry.InvoiceNumber   = SQLiteHelper.GetString(query, ref counter);
            dbEntry.InvoiceDate     = SQLiteHelper.GetDateTime(query, ref counter);
            dbEntry.AmountNet       = SQLiteHelper.GetDecimal(query, ref counter);
            dbEntry.PdvPercent      = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.Pdv             = SQLiteHelper.GetDecimal(query, ref counter);
            dbEntry.AmountGross     = SQLiteHelper.GetDecimal(query, ref counter);
            dbEntry.Currency        = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.DateOfPayment   = SQLiteHelper.GetDateTime(query, ref counter);
            dbEntry.Status          = SQLiteHelper.GetString(query, ref counter);
            dbEntry.StatusDate      = SQLiteHelper.GetDateTime(query, ref counter);
            dbEntry.Description     = SQLiteHelper.GetString(query, ref counter);
            dbEntry.Path            = SQLiteHelper.GetString(query, ref counter);

            dbEntry.IsSynced = SQLiteHelper.GetBoolean(query, ref counter);

            dbEntry.UpdatedAt = SQLiteHelper.GetDateTime(query, ref counter);
            dbEntry.CreatedBy = SQLiteHelper.GetCreatedBy(query, ref counter);
            dbEntry.Company   = SQLiteHelper.GetCompany(query, ref counter);
            return(dbEntry);
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            OutputInvoiceViewModel outputInvoice = new OutputInvoiceViewModel();

            outputInvoice.Identifier  = Guid.NewGuid();
            outputInvoice.InvoiceDate = DateTime.Now;

            OutputInvoiceAddEdit addEditForm = new OutputInvoiceAddEdit(outputInvoice, true, false);

            addEditForm.OutputInvoiceCreatedUpdated += new OutputInvoiceHandler(SyncData);
            FlyoutHelper.OpenFlyout(this, ((string)Application.Current.FindResource("Podaci_o_izlaznim_fakturama")), 95, addEditForm);
        }
        public int GetOutputInvoicesCount(string filterString = "")
        {
            OutputInvoiceViewModel filterObject = JsonConvert.DeserializeObject <OutputInvoiceViewModel>(filterString);

            return(context.OutputInvoices
                   .Where(x => x.Active == true)
                   .Where(x => filterObject == null || String.IsNullOrEmpty(filterObject.SearchBy_Code) || x.Code.ToString().ToLower().Contains(filterObject.SearchBy_Code.ToLower()))
                   .Where(x => filterObject == null || String.IsNullOrEmpty(filterObject.SearchBy_Construction) || x.Construction.ToLower().Contains(filterObject.SearchBy_Construction.ToLower()))
                   .Where(x => filterObject == null || String.IsNullOrEmpty(filterObject.SearchBy_BusinessPartner) || x.BusinessPartner.ToLower().Contains(filterObject.SearchBy_BusinessPartner.ToLower()))
                   .Where(x => filterObject == null || filterObject.SearchBy_DateFrom == null || x.InvoiceDate.Date >= ((DateTime)filterObject.SearchBy_DateFrom).Date)
                   .Where(x => filterObject == null || filterObject.SearchBy_DateTo == null || x.InvoiceDate.Date <= ((DateTime)filterObject.SearchBy_DateTo).Date)
                   .Count());
        }
        public static OutputInvoiceViewModel ConvertToOutputInvoiceViewModel(this OutputInvoice outputInvoice)
        {
            OutputInvoiceViewModel outputInvoiceViewModel = new OutputInvoiceViewModel()
            {
                Id = outputInvoice.Id,

                Code = outputInvoice.Code,

                Construction = outputInvoice.Construction,

                InvoiceDate = outputInvoice.InvoiceDate,

                BusinessPartner = outputInvoice.BusinessPartner,

                InvoiceType = outputInvoice.InvoiceType,

                Quantity = outputInvoice.Quantity,

                TrafficDate = outputInvoice.TrafficDate,

                Price       = outputInvoice.Price,
                Rebate      = outputInvoice.Rebate,
                RebateValue = outputInvoice.RebateValue,
                Base        = outputInvoice.Base,
                PDV         = outputInvoice.PDV,
                Total       = outputInvoice.Total,

                //Status = outputInvoice.Status,
                //IsLocked = outputInvoice.IsLocked,
                //LockedDate = outputInvoice.LockedDate,

                Company = outputInvoice.Company?.ConvertToCompanyViewModelLite(),

                UpdatedAt = outputInvoice.UpdatedAt,
                CreatedAt = outputInvoice.CreatedAt,
                //IsCancelItem = outputInvoice.IsCancelItem,
            };

            //if (outputInvoice.InvoiceItems != null && outputInvoice.InvoiceItems.Count > 0)
            //{
            //    outputInvoiceViewModel.OutputInvoiceSubItems = new ObservableCollection<OutputInvoiceSubItemViewModel>(outputInvoice.InvoiceItems.ConvertToOutputInvoiceSubItemViewModelListLite());
            //}
            //else
            //{
            //    outputInvoiceViewModel.OutputInvoiceSubItems = new ObservableCollection<OutputInvoiceSubItemViewModel>();
            //}

            return(outputInvoiceViewModel);
        }
示例#9
0
        public OutputInvoiceAddEdit(OutputInvoiceViewModel OutputInvoiceViewModel, bool isCreateProcess, bool isPopup = false)
        {
            // Initialize service
            outputInvoiceService = DependencyResolver.Kernel.Get <IOutputInvoiceService>();

            InitializeComponent();

            this.DataContext = this;

            IsHeaderCreated = !isCreateProcess;

            CurrentOutputInvoice = OutputInvoiceViewModel;
            IsCreateProcess      = isCreateProcess;
            IsPopup = isPopup;
        }
        public OutputInvoiceResponse Create(OutputInvoiceViewModel re)
        {
            OutputInvoiceResponse response = new OutputInvoiceResponse();

            try
            {
                response = WpfApiHandler.SendToApi <OutputInvoiceViewModel, OutputInvoiceResponse>(re, "Create");
            }
            catch (Exception ex)
            {
                response.OutputInvoice = new OutputInvoiceViewModel();
                response.Success       = false;
                response.Message       = ex.Message;
            }

            return(response);
        }
        public static OutputInvoice ConvertToOutputInvoice(this OutputInvoiceViewModel outputInvoiceViewModel)
        {
            OutputInvoice outputinvoice = new OutputInvoice()
            {
                Id = outputInvoiceViewModel.Id,

                Code = outputInvoiceViewModel.Code,

                Construction = outputInvoiceViewModel.Construction,

                InvoiceDate = outputInvoiceViewModel.InvoiceDate,

                BusinessPartner = outputInvoiceViewModel.BusinessPartner,

                InvoiceType = outputInvoiceViewModel.InvoiceType,

                Quantity = outputInvoiceViewModel.Quantity,

                TrafficDate = outputInvoiceViewModel.TrafficDate,

                Price       = outputInvoiceViewModel.Price,
                Rebate      = outputInvoiceViewModel.Rebate,
                RebateValue = outputInvoiceViewModel.RebateValue,
                Base        = outputInvoiceViewModel.Base,
                PDV         = outputInvoiceViewModel.PDV,
                Total       = outputInvoiceViewModel.Total,

                //IsLocked = outputInvoiceViewModel.IsLocked,
                //LockedDate = outputInvoiceViewModel.LockedDate,

                CreatedBy = new User()
                {
                    Id = outputInvoiceViewModel.CreatedBy?.Id ?? 0
                },

                //InvoiceItems = outputInvoiceViewModel.OutputInvoiceSubItems?.ConvertToOutputInvoiceSubItemList(),

                //Status = 0,

                CreatedAt = outputInvoiceViewModel.CreatedAt,
                //IsCancelItem = outputInvoiceViewModel.IsCancelItem
            };

            return(outputinvoice);
        }
        public OutputInvoiceListResponse GetOutputInvoicesForPopup(int companyId, string filterString)
        {
            OutputInvoiceListResponse     response       = new OutputInvoiceListResponse();
            List <OutputInvoiceViewModel> OutputInvoices = new List <OutputInvoiceViewModel>();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM OutputInvoices " +
                        "WHERE (@Name IS NULL OR @Name = '' OR Name LIKE @Name OR Code LIKE @Name) " +
                        "AND CompanyId = @CompanyId " +
                        "ORDER BY IsSynced, Id DESC " +
                        "LIMIT @ItemsPerPage;", db);

                    selectCommand.Parameters.AddWithValue("@Name", ((object)filterString) != null ? "%" + filterString + "%" : "");
                    selectCommand.Parameters.AddWithValue("@CompanyId", ((object)filterString) != null ? companyId : 0);
                    selectCommand.Parameters.AddWithValue("@ItemsPerPage", 100);

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    while (query.Read())
                    {
                        OutputInvoiceViewModel dbEntry = Read(query);
                        OutputInvoices.Add(dbEntry);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    response.OutputInvoices = new List <OutputInvoiceViewModel>();
                    return(response);
                }
                db.Close();
            }
            response.Success        = true;
            response.OutputInvoices = OutputInvoices;
            return(response);
        }
        public OutputInvoiceResponse CancelOutputInvoice(int id)
        {
            OutputInvoiceResponse response = new OutputInvoiceResponse();

            try
            {
                OutputInvoiceViewModel oi = new OutputInvoiceViewModel();
                oi.Id    = id;
                response = WpfApiHandler.SendToApi <OutputInvoiceViewModel, OutputInvoiceResponse>(oi, "CancelOutputInvoice");
            }
            catch (Exception ex)
            {
                response.OutputInvoice = new OutputInvoiceViewModel();
                response.Success       = false;
                response.Message       = ex.Message;
            }

            return(response);
        }
        public OutputInvoiceResponse Delete(Guid identifier)
        {
            OutputInvoiceResponse response = new OutputInvoiceResponse();

            try
            {
                OutputInvoiceViewModel re = new OutputInvoiceViewModel();
                re.Identifier = identifier;
                response      = WpfApiHandler.SendToApi <OutputInvoiceViewModel, OutputInvoiceResponse>(re, "Delete");
            }
            catch (Exception ex)
            {
                response.OutputInvoice = new OutputInvoiceViewModel();
                response.Success       = false;
                response.Message       = ex.Message;
            }

            return(response);
        }
示例#15
0
        public static OutputInvoiceViewModel ConvertToOutputInvoiceViewModel(this OutputInvoice outputInvoice)
        {
            OutputInvoiceViewModel outputInvoiceViewModel = new OutputInvoiceViewModel()
            {
                Id         = outputInvoice.Id,
                Identifier = outputInvoice.Identifier,
                Code       = outputInvoice.Code,

                Supplier      = outputInvoice.Supplier,
                Address       = outputInvoice.Address,
                InvoiceNumber = outputInvoice.InvoiceNumber,
                InvoiceDate   = outputInvoice.InvoiceDate,
                Currency      = outputInvoice.Currency,

                AmountNet = outputInvoice.AmountNet,

                PdvPercent = outputInvoice.PdvPercent,

                Pdv = outputInvoice.Pdv,

                AmountGross = outputInvoice.AmountGross,

                DateOfPayment = outputInvoice.DateOfPayment,
                Status        = outputInvoice.Status,
                StatusDate    = outputInvoice.StatusDate,

                Description = outputInvoice.Description,

                Path = outputInvoice.Path,

                IsActive = outputInvoice.Active,

                Company         = outputInvoice.Company?.ConvertToCompanyViewModelLite(),
                CreatedBy       = outputInvoice.CreatedBy?.ConvertToUserViewModelLite(),
                BusinessPartner = outputInvoice.BusinessPartner?.ConvertToBusinessPartnerViewModelLite(),

                UpdatedAt = outputInvoice.UpdatedAt,
                CreatedAt = outputInvoice.CreatedAt,
            };

            return(outputInvoiceViewModel);
        }
示例#16
0
        public static OutputInvoice ConvertToOutputInvoice(this OutputInvoiceViewModel outputInvoiceViewModel)
        {
            OutputInvoice outputinvoice = new OutputInvoice()
            {
                Id         = outputInvoiceViewModel.Id,
                Identifier = outputInvoiceViewModel.Identifier,
                Code       = outputInvoiceViewModel.Code,

                Supplier      = outputInvoiceViewModel.Supplier,
                Address       = outputInvoiceViewModel.Address,
                InvoiceNumber = outputInvoiceViewModel.InvoiceNumber,
                InvoiceDate   = outputInvoiceViewModel.InvoiceDate,
                Currency      = outputInvoiceViewModel.Currency,

                AmountNet = outputInvoiceViewModel.AmountNet,

                PdvPercent = outputInvoiceViewModel.PdvPercent,

                Pdv = outputInvoiceViewModel.Pdv,

                AmountGross = outputInvoiceViewModel.AmountGross,

                DateOfPayment = outputInvoiceViewModel.DateOfPayment,
                Status        = outputInvoiceViewModel.Status,
                StatusDate    = outputInvoiceViewModel.StatusDate,

                Description = outputInvoiceViewModel.Description,

                Path = outputInvoiceViewModel.Path,

                Active = outputInvoiceViewModel.IsActive,

                BusinessPartnerId = outputInvoiceViewModel.BusinessPartner?.Id ?? null,
                CreatedById       = outputInvoiceViewModel.CreatedBy?.Id ?? null,
                CompanyId         = outputInvoiceViewModel.Company?.Id ?? null,

                CreatedAt = outputInvoiceViewModel.CreatedAt,
                UpdatedAt = outputInvoiceViewModel.UpdatedAt
            };

            return(outputinvoice);
        }
        public OutputInvoice_Document_AddEdit(OutputInvoiceViewModel outputInvoice)
        {
            outputInvoiceService = DependencyResolver.Kernel.Get <IOutputInvoiceService>();

            InitializeComponent();

            this.DataContext = this;

            CurrentOutputInvoice                        = outputInvoice;
            CurrentOutputInvoiceDocumentForm            = new OutputInvoiceDocumentViewModel();
            CurrentOutputInvoiceDocumentForm.Identifier = Guid.NewGuid();
            CurrentOutputInvoiceDocumentForm.ItemStatus = ItemStatus.Added;

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

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

            btnAddDocument.Focus();
        }
        public List <OutputInvoice> GetOutputInvoicesByPages(int currentPage = 1, int itemsPerPage = 50, string filterString = "")
        {
            OutputInvoiceViewModel filterObject = JsonConvert.DeserializeObject <OutputInvoiceViewModel>(filterString);

            List <OutputInvoice> outputInvoices = context.OutputInvoices
                                                  .Include(x => x.CreatedBy)
                                                  .Where(x => x.Active == true)
                                                  .Where(x => filterObject == null || String.IsNullOrEmpty(filterObject.SearchBy_Code) || x.Code.ToString().ToLower().Contains(filterObject.SearchBy_Code.ToLower()))
                                                  .Where(x => filterObject == null || String.IsNullOrEmpty(filterObject.SearchBy_Construction) || x.Construction.ToLower().Contains(filterObject.SearchBy_Construction.ToLower()))
                                                  .Where(x => filterObject == null || String.IsNullOrEmpty(filterObject.SearchBy_BusinessPartner) || x.BusinessPartner.ToLower().Contains(filterObject.SearchBy_BusinessPartner.ToLower()))
                                                  .Where(x => filterObject == null || filterObject.SearchBy_DateFrom == null || x.InvoiceDate.Date >= ((DateTime)filterObject.SearchBy_DateFrom).Date)
                                                  .Where(x => filterObject == null || filterObject.SearchBy_DateTo == null || x.InvoiceDate.Date <= ((DateTime)filterObject.SearchBy_DateTo).Date)
                                                  .OrderByDescending(x => x.UpdatedAt)
                                                  .Skip((currentPage - 1) * itemsPerPage)
                                                  .Take(itemsPerPage)
                                                  .AsNoTracking()
                                                  .ToList();

            return(outputInvoices);
        }
示例#19
0
        public JsonResult Update([FromBody] OutputInvoiceViewModel c)
        {
            OutputInvoiceResponse response = new OutputInvoiceResponse();

            try
            {
                response = this.outputInvoiceService.Update(c);
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
                Console.WriteLine(ex.Message);
            }

            return(Json(response, new Newtonsoft.Json.JsonSerializerSettings()
            {
                Formatting = Newtonsoft.Json.Formatting.Indented
            }));
        }
        public static OutputInvoiceViewModel ConvertToOutputInvoiceViewModelLite(this OutputInvoice outputInvoice)
        {
            OutputInvoiceViewModel outputInvoiceViewModel = new OutputInvoiceViewModel()
            {
                Id = outputInvoice.Id,

                Code = outputInvoice.Code,

                Construction = outputInvoice.Construction,

                InvoiceDate = outputInvoice.InvoiceDate,

                BusinessPartner = outputInvoice.BusinessPartner,

                InvoiceType = outputInvoice.InvoiceType,

                Quantity = outputInvoice.Quantity,

                TrafficDate = outputInvoice.TrafficDate,

                Price       = outputInvoice.Price,
                Rebate      = outputInvoice.Rebate,
                RebateValue = outputInvoice.RebateValue,
                Base        = outputInvoice.Base,
                PDV         = outputInvoice.PDV,
                Total       = outputInvoice.Total,

                //Status = outputInvoice.Status,
                //IsLocked = outputInvoice.IsLocked,
                //LockedDate = outputInvoice.LockedDate,

                Company = outputInvoice.Company?.ConvertToCompanyViewModelLite(),

                UpdatedAt = outputInvoice.UpdatedAt,
                CreatedAt = outputInvoice.CreatedAt,
                //IsCancelItem = outputInvoice.IsCancelItem,
            };

            return(outputInvoiceViewModel);
        }
示例#21
0
        /// <summary>
        /// OutputInvoiceAddEdit constructor
        /// </summary>
        /// <param name="OutputInvoiceViewModel"></param>
        public OutputInvoiceAddEdit(OutputInvoiceViewModel OutputInvoiceViewModel)
        {
            // Initialize service
            this.outputInvoiceService = DependencyResolver.Kernel.Get <IOutputInvoiceService>();

            // Draw all components
            InitializeComponent();

            this.DataContext = this;

            // Initialize notifications
            notifier = new Notifier(cfg =>
            {
                cfg.PositionProvider = new WindowPositionProvider(
                    parentWindow: System.Windows.Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(),
                    corner: Corner.TopRight,
                    offsetX: 10,
                    offsetY: 10);

                cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(
                    notificationLifetime: TimeSpan.FromSeconds(3),
                    maximumNotificationCount: MaximumNotificationCount.FromCount(3));

                cfg.Dispatcher = Application.Current.Dispatcher;
            });

            CurrentOutputInvoice = OutputInvoiceViewModel;

            if (CurrentOutputInvoice.Code <= 0)
            {
                CurrentOutputInvoice.Code = outputInvoiceService.GetNewCodeValue().OutputInvoiceCode;
            }

            // Add handler for keyboard shortcuts
            AddHandler(Keyboard.KeyDownEvent, (KeyEventHandler)HandleKeyDownEvent);

            //txtName.Focus();
        }
        public OutputInvoiceResponse Create(OutputInvoiceViewModel outputInvoice)
        {
            OutputInvoiceResponse response = new OutputInvoiceResponse();

            try
            {
                //Backup items
                List <OutputInvoiceNoteViewModel> outputInvoiceNotes = outputInvoice
                                                                       .OutputInvoiceNotes?.ToList() ?? new List <OutputInvoiceNoteViewModel>();
                outputInvoice.OutputInvoiceNotes = null;

                List <OutputInvoiceDocumentViewModel> outputInvoiceDocuments = outputInvoice
                                                                               .OutputInvoiceDocuments?.ToList() ?? new List <OutputInvoiceDocumentViewModel>();
                outputInvoice.OutputInvoiceDocuments = null;

                OutputInvoice createdOutputInvoice = unitOfWork.GetOutputInvoiceRepository()
                                                     .Create(outputInvoice.ConvertToOutputInvoice());

                // Update items
                if (outputInvoiceNotes != null && outputInvoiceNotes.Count > 0)
                {
                    foreach (OutputInvoiceNoteViewModel item in outputInvoiceNotes
                             .Where(x => x.ItemStatus == ItemStatus.Added || x.ItemStatus == ItemStatus.Edited)?.ToList() ?? new List <OutputInvoiceNoteViewModel>())
                    {
                        item.OutputInvoice = new OutputInvoiceViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        item.ItemStatus = ItemStatus.Submited;
                        var createdItem = unitOfWork.GetOutputInvoiceNoteRepository().Create(item.ConvertToOutputInvoiceNote());
                    }

                    foreach (OutputInvoiceNoteViewModel item in outputInvoiceNotes
                             .Where(x => x.ItemStatus == ItemStatus.Deleted)?.ToList() ?? new List <OutputInvoiceNoteViewModel>())
                    {
                        item.OutputInvoice = new OutputInvoiceViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        unitOfWork.GetOutputInvoiceNoteRepository().Create(item.ConvertToOutputInvoiceNote());

                        unitOfWork.GetOutputInvoiceNoteRepository().Delete(item.Identifier);
                    }
                }

                // Update items
                if (outputInvoiceDocuments != null && outputInvoiceDocuments.Count > 0)
                {
                    foreach (OutputInvoiceDocumentViewModel item in outputInvoiceDocuments
                             .Where(x => x.ItemStatus == ItemStatus.Added || x.ItemStatus == ItemStatus.Edited)?.ToList() ?? new List <OutputInvoiceDocumentViewModel>())
                    {
                        item.OutputInvoice = new OutputInvoiceViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        item.ItemStatus = ItemStatus.Submited;
                        var createdItem = unitOfWork.GetOutputInvoiceDocumentRepository().Create(item.ConvertToOutputInvoiceDocument());
                    }

                    foreach (OutputInvoiceDocumentViewModel item in outputInvoiceDocuments
                             .Where(x => x.ItemStatus == ItemStatus.Deleted)?.ToList() ?? new List <OutputInvoiceDocumentViewModel>())
                    {
                        item.OutputInvoice = new OutputInvoiceViewModel()
                        {
                            Id = createdOutputInvoice.Id
                        };
                        unitOfWork.GetOutputInvoiceDocumentRepository().Create(item.ConvertToOutputInvoiceDocument());

                        unitOfWork.GetOutputInvoiceDocumentRepository().Delete(item.Identifier);
                    }
                }

                unitOfWork.Save();

                response.OutputInvoice = createdOutputInvoice.ConvertToOutputInvoiceViewModel();
                response.Success       = true;
            }
            catch (Exception ex)
            {
                response.OutputInvoice = new OutputInvoiceViewModel();
                response.Success       = false;
                response.Message       = ex.Message;
            }

            return(response);
        }
示例#23
0
        public static void Show(OutputInvoiceViewModel outputInvoice)
        {
            //Create excel workbook and sheet
            Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
            excel.Visible = true;

            //excel.DisplayFullScreen = true;
            excel.WindowState = XlWindowState.xlMaximized;

            Workbook  workbook = excel.Workbooks.Add(System.Reflection.Missing.Value);
            Worksheet sheet1   = (Worksheet)workbook.Sheets[1];

            //excel.StandardFont = "Calibri"; //"Arial Narrow" "Times New Roman" "Arial" "Bahnschrift SemiBold Condensed"
            //excel.StandardFontSize = 8;

            sheet1.PageSetup.PaperSize      = XlPaperSize.xlPaperA4;
            sheet1.PageSetup.Orientation    = XlPageOrientation.xlPortrait;
            sheet1.PageSetup.FitToPagesTall = false;
            sheet1.PageSetup.FitToPagesWide = 1;
            sheet1.PageSetup.Zoom           = false;


            // Set header rows
            sheet1.PageSetup.PrintTitleRows = "$1:$2";

            sheet1.PageSetup.HeaderMargin = 30;
            sheet1.PageSetup.LeftHeader   = "&16&B Ulazne fakture";
            sheet1.PageSetup.RightHeader  = "&8Stranica &P/&N";

            sheet1.PageSetup.CenterHeaderPicture.Filename = AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\image005.jpg";
            sheet1.PageSetup.CenterHeaderPicture.Width    = 150;
            sheet1.PageSetup.CenterHeaderPicture.Height   = 50;
            sheet1.PageSetup.CenterHeader = "&G";

            sheet1.PageSetup.CenterFooterPicture.Filename = AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\erp8.png";
            sheet1.PageSetup.CenterFooterPicture.Width    = 100;
            sheet1.PageSetup.CenterFooterPicture.Height   = 40;
            sheet1.PageSetup.CenterFooter = "&G";
            //sheet1.PageSetup.LeftFooter = " www.sirmiumerp.com ";
            //sheet1.PageSetup.CenterFooter = " www.sirmiumerp.com ";


            int leftSideMin  = 1;
            int rightSideMax = 14;

            int rowCounter = 1;

            rowCounter++;
            rowCounter++;
            rowCounter++;

            // rowCounter = 26; //top chart area

            #region Table

            rowCounter++;
            rowCounter++;

            int columnCounter = 2;

            sheet1.Cells[rowCounter, columnCounter].Interior.Color      = XlRgbColor.rgbLightGray;
            sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter] = "POSLOVNI PARTNER/GESCHÄFTSPARTNER: ";

            sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter + 1] = outputInvoice.BusinessPartner?.Name;

            rowCounter++;

            sheet1.Cells[rowCounter, columnCounter].Interior.Color      = XlRgbColor.rgbLightGray;
            sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter] = "DOBAVLJAČ/LIEFERANT: ";

            sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter + 1] = outputInvoice.Supplier;

            rowCounter++;

            sheet1.Cells[rowCounter, columnCounter].Interior.Color      = XlRgbColor.rgbLightGray;
            sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter] = "ADRESA/ADRESSE: ";

            sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter + 1] = outputInvoice.Address;

            rowCounter++;

            sheet1.Cells[rowCounter, columnCounter].Interior.Color      = XlRgbColor.rgbLightGray;
            sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter] = "BROJ FAKTURE/FAKTURNUMMER: ";

            sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter + 1] = outputInvoice.InvoiceNumber;

            rowCounter++;

            sheet1.Cells[rowCounter, columnCounter].Interior.Color      = XlRgbColor.rgbLightGray;
            sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter] = "DATUM FAKTURE/FAKTURDATUM: ";

            sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter + 1] = outputInvoice.InvoiceDate.ToString("dd.MM.yyyy");

            rowCounter++;

            sheet1.Cells[rowCounter, columnCounter].Interior.Color      = XlRgbColor.rgbLightGray;
            sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter] = "IZNOS NETO/BETRAG NETTO: ";

            sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter + 1] = outputInvoice.AmountNet;

            rowCounter++;

            sheet1.Cells[rowCounter, columnCounter].Interior.Color      = XlRgbColor.rgbLightGray;
            sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter] = "PDV%: ";

            sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter + 1] = outputInvoice.PdvPercent;

            rowCounter++;

            sheet1.Cells[rowCounter, columnCounter].Interior.Color      = XlRgbColor.rgbLightGray;
            sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter] = "PDV: ";

            sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter + 1] = outputInvoice.Pdv;

            rowCounter++;

            sheet1.Cells[rowCounter, columnCounter].Interior.Color      = XlRgbColor.rgbLightGray;
            sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter] = "IZNOS BRUTO/BETRAG BRUTTO: ";

            sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter + 1] = outputInvoice.AmountGross;

            rowCounter++;

            sheet1.Cells[rowCounter, columnCounter].Interior.Color      = XlRgbColor.rgbLightGray;
            sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter] = "VALUTA: ";

            sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter + 1] = outputInvoice.Currency;

            rowCounter++;

            sheet1.Cells[rowCounter, columnCounter].Interior.Color      = XlRgbColor.rgbLightGray;
            sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter] = "DATUM PLAĆANJA/ZAHLUNGSDATUM: ";

            sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter + 1] = outputInvoice.DateOfPayment.ToString("dd.MM.yyyy");

            rowCounter++;

            sheet1.Cells[rowCounter, columnCounter].Interior.Color      = XlRgbColor.rgbLightGray;
            sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter] = "STATUS: ";

            sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter + 1] = new ChooseStatusConverter().Convert(outputInvoice.Status, null, null, CultureInfo.InvariantCulture);

            rowCounter++;

            sheet1.Cells[rowCounter, columnCounter].Interior.Color      = XlRgbColor.rgbLightGray;
            sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter] = "DATUM STATUSA/STATUSDATUM: ";

            sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment   = XlVAlign.xlVAlignCenter;
            sheet1.Cells[rowCounter, columnCounter + 1].Font.Size           = 10;
            sheet1.Cells[rowCounter, columnCounter + 1] = outputInvoice.StatusDate.ToString("dd.MM.yyyy");

            rowCounter++;

            #endregion

            rowCounter++;
            rowCounter++;
            rowCounter++;
            rowCounter++;

            sheet1.Range[sheet1.Cells[rowCounter, 3], sheet1.Cells[rowCounter, 4]].Merge();
            sheet1.Range[sheet1.Cells[rowCounter, 3], sheet1.Cells[rowCounter, 4]].Font.Size = 10;
            sheet1.Range[sheet1.Cells[rowCounter, 3], sheet1.Cells[rowCounter, 4]]           = "Odgovorno lice/Verantwortliche Person";

            rowCounter++;
            rowCounter++;

            sheet1.Range[sheet1.Cells[rowCounter, 3], sheet1.Cells[rowCounter, 5]].Merge();
            sheet1.Range[sheet1.Cells[rowCounter, 3], sheet1.Cells[rowCounter, 5]] = "_____________________________";

            sheet1.Columns.AutoFit();
        }
        public OutputInvoiceListResponse GetOutputInvoicesByPage(int companyId, OutputInvoiceViewModel OutputInvoiceSearchObject, int currentPage = 1, int itemsPerPage = 50)
        {
            OutputInvoiceListResponse     response       = new OutputInvoiceListResponse();
            List <OutputInvoiceViewModel> OutputInvoices = new List <OutputInvoiceViewModel>();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM OutputInvoices " +
                        "WHERE (@Supplier IS NULL OR @Supplier = '' OR Supplier LIKE @Supplier) " +
                        "AND (@BusinessPartnerName IS NULL OR @BusinessPartnerName = '' OR BusinessPartnerName LIKE @BusinessPartnerName) " +
                        "AND (@InvoiceNumber IS NULL OR @InvoiceNumber = '' OR InvoiceNumber LIKE @InvoiceNumber) " +
                        "AND (@DateTo IS NULL OR @DateTo = '' OR DATE(InvoiceDate) <= DATE(@DateTo)) " +
                        "AND (@DateFrom IS NULL OR @DateFrom = '' OR DATE(InvoiceDate) >= DATE(@DateFrom)) " +
                        "AND (@DateOfPaymentTo IS NULL OR @DateOfPaymentTo = '' OR DATE(DateOfPayment) <=  DATE(@DateOfPaymentTo)) " +
                        "AND (@DateOfPaymentFrom IS NULL OR @DateOfPaymentFrom = '' OR DATE(DateOfPayment) >= DATE(@DateOfPaymentFrom)) " +
                        "AND CompanyId = @CompanyId " +
                        "ORDER BY IsSynced, Id DESC " +
                        "LIMIT @ItemsPerPage OFFSET @Offset;", db);

                    selectCommand.Parameters.AddWithValue("@Supplier", ((object)OutputInvoiceSearchObject.SearchBy_Supplier) != null ? "%" + OutputInvoiceSearchObject.SearchBy_Supplier + "%" : "");
                    selectCommand.Parameters.AddWithValue("@BusinessPartnerName", ((object)OutputInvoiceSearchObject.SearchBy_BusinessPartner) != null ? "%" + OutputInvoiceSearchObject.SearchBy_BusinessPartner + "%" : "");
                    selectCommand.Parameters.AddWithValue("@InvoiceNumber", ((object)OutputInvoiceSearchObject.SearchBy_InvoiceNumber) != null ? "%" + OutputInvoiceSearchObject.SearchBy_InvoiceNumber + "%" : "");
                    selectCommand.Parameters.AddWithValue("@DateFrom", ((object)OutputInvoiceSearchObject.SearchBy_InvoiceDateFrom) ?? DBNull.Value);
                    selectCommand.Parameters.AddWithValue("@DateTo", ((object)OutputInvoiceSearchObject.SearchBy_InvoiceDateTo) ?? DBNull.Value);
                    selectCommand.Parameters.AddWithValue("@DateOfPaymentFrom", ((object)OutputInvoiceSearchObject.SearchBy_DateOfPaymentFrom) ?? DBNull.Value);
                    selectCommand.Parameters.AddWithValue("@DateOfPaymentTo", ((object)OutputInvoiceSearchObject.SearchBy_DateOfPaymentTo) ?? DBNull.Value);
                    selectCommand.Parameters.AddWithValue("@CompanyId", companyId);
                    selectCommand.Parameters.AddWithValue("@ItemsPerPage", itemsPerPage);
                    selectCommand.Parameters.AddWithValue("@Offset", (currentPage - 1) * itemsPerPage);

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    while (query.Read())
                    {
                        OutputInvoiceViewModel dbEntry = Read(query);
                        OutputInvoices.Add(dbEntry);
                    }


                    selectCommand = new SqliteCommand(
                        "SELECT Count(*) " +
                        "FROM OutputInvoices " +
                        "WHERE (@Supplier IS NULL OR @Supplier = '' OR Supplier LIKE @Supplier) " +
                        "AND (@BusinessPartnerName IS NULL OR @BusinessPartnerName = '' OR BusinessPartnerName LIKE @BusinessPartnerName) " +
                        "AND (@InvoiceNumber IS NULL OR @InvoiceNumber = '' OR InvoiceNumber LIKE @InvoiceNumber) " +
                        "AND (@DateFrom IS NULL OR @DateFrom = '' OR DATE(InvoiceDate) >= DATE(@DateFrom)) " +
                        "AND (@DateTo IS NULL OR @DateTo = '' OR DATE(InvoiceDate) <= DATE(@DateTo)) " +
                        "AND (@DateOfPaymentFrom IS NULL OR @DateOfPaymentFrom = '' OR DATE(DateOfPayment) >= DATE(@DateOfPaymentFrom)) " +
                        "AND (@DateOfPaymentTo IS NULL OR @DateOfPaymentTo = '' OR DATE(DateOfPayment) <= DATE(@DateOfPaymentTo)) " +
                        "AND CompanyId = @CompanyId;", db);

                    selectCommand.Parameters.AddWithValue("@Supplier", ((object)OutputInvoiceSearchObject.SearchBy_Supplier) != null ? "%" + OutputInvoiceSearchObject.SearchBy_Supplier + "%" : "");
                    selectCommand.Parameters.AddWithValue("@BusinessPartnerName", ((object)OutputInvoiceSearchObject.SearchBy_BusinessPartner) != null ? "%" + OutputInvoiceSearchObject.SearchBy_BusinessPartner + "%" : "");
                    selectCommand.Parameters.AddWithValue("@InvoiceNumber", ((object)OutputInvoiceSearchObject.SearchBy_InvoiceNumber) != null ? "%" + OutputInvoiceSearchObject.SearchBy_InvoiceNumber + "%" : "");
                    selectCommand.Parameters.AddWithValue("@DateFrom", ((object)OutputInvoiceSearchObject.SearchBy_InvoiceDateFrom) ?? "");
                    selectCommand.Parameters.AddWithValue("@DateTo", ((object)OutputInvoiceSearchObject.SearchBy_InvoiceDateTo) ?? "");
                    selectCommand.Parameters.AddWithValue("@DateOfPaymentFrom", ((object)OutputInvoiceSearchObject.SearchBy_DateOfPaymentFrom) ?? "");
                    selectCommand.Parameters.AddWithValue("@DateOfPaymentTo", ((object)OutputInvoiceSearchObject.SearchBy_DateOfPaymentTo) ?? "");
                    selectCommand.Parameters.AddWithValue("@CompanyId", companyId);

                    query = selectCommand.ExecuteReader();

                    if (query.Read())
                    {
                        response.TotalItems = query.GetInt32(0);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    response.OutputInvoices = new List <OutputInvoiceViewModel>();
                    return(response);
                }
                db.Close();
            }
            response.Success        = true;
            response.OutputInvoices = OutputInvoices;
            return(response);
        }
示例#25
0
        public OutputInvoice_ReportWindow(OutputInvoiceViewModel outputInvoiceView)
        {
            InitializeComponent();
            rdlcOutputInvoiceReport.LocalReport.DataSources.Clear();

            List <OutputInvoicesReportViewModel> outputInvoice      = new List <OutputInvoicesReportViewModel>();
            List <OutputInvoiceViewModel>        OutputInvoiceItems = new OutputInvoiceSQLiteRepository().GetOutputInvoicesByPage(MainWindow.CurrentCompanyId, OutputInvoiceSearchObject, 1, 50).OutputInvoices;
            int counter = 1;

            foreach (var OutputInvoiceItem in OutputInvoiceItems)
            {
                outputInvoice.Add(new OutputInvoicesReportViewModel()
                {
                    OrderNumbersForOutputInvoices = counter++,
                    BusinessPartnerName           = OutputInvoiceItem?.BusinessPartner?.Name ?? "",
                    Supplier       = OutputInvoiceItem?.Supplier ?? "",
                    Address        = OutputInvoiceItem?.Address ?? "",
                    InvoiceNumber  = OutputInvoiceItem?.InvoiceNumber ?? "",
                    InvoiceDate    = OutputInvoiceItem?.InvoiceDate.ToString("dd.MM.yyyy") ?? "",
                    AmountNet      = OutputInvoiceItem?.AmountNet.ToString("#.00") ?? "",
                    PDVPercent     = OutputInvoiceItem?.PdvPercent.ToString("#.00") ?? "",
                    PDV            = OutputInvoiceItem?.Pdv.ToString() ?? "",
                    AmountGros     = OutputInvoiceItem?.AmountGross.ToString("#.00") ?? "",
                    Currency       = OutputInvoiceItem?.Currency.ToString("#.00") ?? "",
                    DateOfPaymetse = OutputInvoiceItem?.DateOfPayment.ToString("dd.MM.yyyy") ?? "",
                    Statuse        = OutputInvoiceItem?.Status.ToString() ?? "",
                    StatusDate     = OutputInvoiceItem?.StatusDate.ToString("dd.MM.yyyy") ?? ""
                });
            }
            var rpdsModel = new ReportDataSource()
            {
                Name  = "DataSet1",
                Value = outputInvoice
            };

            rdlcOutputInvoiceReport.LocalReport.DataSources.Add(rpdsModel);

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


            //var businessPartnerList = new List<InvoiceBusinessPartnerViewModel>();
            //businessPartnerList.Add(new InvoiceBusinessPartnerViewModel() { Name = "Pera peric " });
            //var businessPartnerModel = new ReportDataSource() { Name = "DataSet2", Value = businessPartnerList };
            //rdlcOutputNoteReport.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\OutputInvoices\OutputInvoicesReport.rdlc");

            //////rdlcOutputInvoiceReport.LocalReport.ReportPath = ContentStart;
            ///

            string exeFolder    = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            string ContentStart = System.IO.Path.Combine(exeFolder, @"RdlcReports\OutputInvoices\OutputInvoicesReport.rdlc");

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