コード例 #1
0
        private void AppendDocuments()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Title  = "Select a picture",
                Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png"
            };

            ;
            if (openFileDialog.ShowDialog() == true)
            {
                try
                {
                    OrderItemReport oir = new OrderItemReport()
                    {
                        //Comment = "Kommentar kksksksksk",
                        //Id = 59,
                        OrderItemId = SelectedDetailed.OrderItemId,
                        ReportDate  = new DateTime(),
                        Appendix    = new List <OrderItemReportAppendix>()
                        {
                            new OrderItemReportAppendix()
                            {
                                //Id = 10,
                                //OrderItemReportId = 50,
                                Picture = ImageConverter.ImageToByteArray(new BitmapImage(new Uri(openFileDialog.FileName, UriKind.Absolute)))
                            }
                        }
                    };
                    SelectedDetailed.OrderItemReports.Add(oir);
                    Dp.AddOrderItemReport(oir);
                    //if(Dp.AddOrderItemReport(oir))
                    //    MessageBox.Show("Update erfolgreich!", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                    //else
                    //    MessageBox.Show("Update fehlgeschlagen", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);


                    if (Dp.UpdateOrderItemData(SelectedDetailed))
                    {
                        MessageBox.Show("Update erfolgreich!", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show("Update fehlgeschlagen", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Laden des Bildes fehlgeschlagen!\n" + e.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
コード例 #2
0
        private void CreateReport()
        {
            int CurrentMaxOrderItemReportId = 0;
            foreach (var item in SelectedDetailed.OrderItemReports)
            {
                if (item.OrderItemId > CurrentMaxOrderItemReportId)
                    CurrentMaxOrderItemReportId = item.OrderItemId;
            }
            CreateReportDialog reportDialog = new CreateReportDialog(CurrentMaxOrderItemReportId + 1, OrderItemId);
            if (reportDialog.ShowDialog() == true)
            {
                OrderItemReport_ CreatedReport = reportDialog.Answer;
                OrderItemReports.Add(CreatedReport);
                Dp.AddOrderItemReport(CreatedReport);

                RaisePropertyChanged(nameof(SelectedDetailed.OrderItemReports));
            }
        }