Przeglądaj źródła

Fixed Quote Module Broken Stuff
Turned off Projects Grid MultiSelect as default

frogsoftware 3 miesięcy temu
rodzic
commit
d33bd5c466

+ 0 - 9
prs.classes/Entities/Quote/QuoteDiagram/QuoteDiagram.cs

@@ -5,15 +5,6 @@ using InABox.Core;
 
 namespace Comal.Classes
 {
-    public class QuoteDiagramLink : EntityLink<QuoteDiagram>
-    {
-        [NullEditor]
-        public override Guid ID { get; set; }
-
-        [TextBoxEditor(Editable = Editable.Hidden)]
-        public string Description { get; set; }
-    }
-
     [UserTracking(typeof(Quote))]
     public class QuoteDiagram : Entity, IRemotable, IPersistent, IOneToMany<Quote>, IStringAutoIncrement<QuoteDiagram>, ILicense<QuotesManagementLicense>
     {

+ 15 - 0
prs.classes/Entities/Quote/QuoteDiagram/QuoteDiagramArea.cs

@@ -0,0 +1,15 @@
+using InABox.Core;
+
+namespace Comal.Classes
+{
+    public class QuoteDiagramArea : QuoteDiagramEntity
+    {
+        [ColorEditor]
+        [EditorSequence(10)]
+        public string FillColor { get; set; } = "#AAAAAA";
+
+        [ColorEditor]
+        [EditorSequence(11)]
+        public string LineColor { get; set; } = "#000000";
+    }
+}

+ 15 - 0
prs.classes/Entities/Quote/QuoteDiagram/QuoteDiagramConnector.cs

@@ -0,0 +1,15 @@
+using InABox.Core;
+
+namespace Comal.Classes
+{
+    public class QuoteDiagramConnector : QuoteDiagramEntity, ILicense<QuotesManagementLicense>
+    {
+        [EditorSequence(10)]
+        [EnumLookupEditor(typeof(QuoteDiagramConnectorType))]
+        public QuoteDiagramConnectorType Type { get; set; }
+
+        [ColorEditor]
+        [EditorSequence(12)]
+        public string Color { get; set; } = "#AAAAAA";
+    }
+}

+ 10 - 0
prs.classes/Entities/Quote/QuoteDiagram/QuoteDiagramConnectorType.cs

@@ -0,0 +1,10 @@
+namespace Comal.Classes
+{
+    public enum QuoteDiagramConnectorType
+    {
+        StraightLine,
+        OrthogonalLine,
+        CubicBezier,
+        QuadraticBezier
+    }
+}

+ 14 - 0
prs.classes/Entities/Quote/QuoteDiagram/QuoteDiagramLink.cs

@@ -0,0 +1,14 @@
+using System;
+using InABox.Core;
+
+namespace Comal.Classes
+{
+    public class QuoteDiagramLink : EntityLink<QuoteDiagram>
+    {
+        [NullEditor]
+        public override Guid ID { get; set; }
+
+        [TextBoxEditor(Editable = Editable.Hidden)]
+        public string Description { get; set; }
+    }
+}

+ 3 - 30
prs.classes/Entities/Quote/QuoteDiagram/QuoteDiagramSymbol.cs

@@ -45,41 +45,14 @@ namespace Comal.Classes
 
     public class QuoteDiagramSymbol : QuoteDiagramEntity
     {
-        [VectorDocumentEditor]
         [EditorSequence(10)]
         public VectorDocumentLink Symbol { get; set; }
 
+        [EditorSequence(11)]
         [JsonEditor(typeof(QuoteDiagramSymbolPort))]
         public string Ports { get; set; }
-    }
-
-    public enum QuoteDiagramConnectorType
-    {
-        StraightLine,
-        OrthogonalLine,
-        CubicBezier,
-        QuadraticBezier
-    }
-
-    public class QuoteDiagramConnector : QuoteDiagramEntity, ILicense<QuotesManagementLicense>
-    {
-        [EditorSequence(10)]
-        [EnumLookupEditor(typeof(QuoteDiagramConnectorType))]
-        public QuoteDiagramConnectorType Type { get; set; }
-
-        [ColorEditor]
+        
         [EditorSequence(12)]
-        public string Color { get; set; } = "#AAAAAA";
-    }
-
-    public class QuoteDiagramArea : QuoteDiagramEntity
-    {
-        [ColorEditor]
-        [EditorSequence(10)]
-        public string FillColor { get; set; } = "#AAAAAA";
-
-        [ColorEditor]
-        [EditorSequence(11)]
-        public string LineColor { get; set; } = "#000000";
+        public KitLink Kit { get; set; }
     }
 }

+ 1 - 0
prs.desktop/Panels/Jobs/ProjectsGrid.cs

@@ -89,6 +89,7 @@ public class ProjectsGrid : DynamicDataGrid<Job>
         options.RecordCount = true;
         options.SelectColumns = true;
         options.FilterRows = true;
+        options.MultiSelect = false;
     }
 
     // private void BuildMenu(DynamicMenuColumn column, CoreRow? row)

+ 4 - 2
prs.desktop/Panels/Quotes/Details/QuoteDetails.xaml.cs

@@ -139,11 +139,13 @@ namespace PRSDesktop
 
         private void Customer_OnEditorValueChanged(IDynamicEditorControl sender, Dictionary<string, object> values)
         {
-            Account.Value = (Guid)values["Account.ID"];
+            Account.Value = values.TryGetValue("Account.ID", out object accountid)
+                ? (Guid)accountid
+                : Guid.Empty;
             if (IsReady && Master != null)
             {
                 Master.Customer.ID = (Guid)values["Customer.ID"];
-                Master.Account.ID = (Guid)values["Account.ID"];
+                Master.Account.ID = Account.Value;
                 new Client<Quote>().Save(Master, "Updated Customer ID", (j, err) => { });
             }
         }

+ 2 - 0
prs.desktop/Panels/Quotes/Diagrams/QuoteDiagramControl.xaml

@@ -246,6 +246,8 @@
                          VerticalContentAlignment="Center" Margin="2,0,0,0" IsReadOnly="True" />
                 <Button x:Name="TakeOff" DockPanel.Dock="Right" Content="Take Off" Padding="10,0,10,0"
                         Click="TakeOff_Click" />
+                <Button x:Name="PickingList" DockPanel.Dock="Right" Content="Picking List" Padding="10,0,10,0" Margin="5,0,5,0"
+                        Click="PickingList_Click" />
                 <Slider x:Name="Zoom" DockPanel.Dock="Right" Minimum="25" Value="100" Maximum="400" Interval="1"
                         ValueChanged="Zoom_ValueChanged" Width="100" VerticalAlignment="Center" />
                 <Label Content="Zoom:" DockPanel.Dock="Right" VerticalContentAlignment="Center" />

+ 68 - 0
prs.desktop/Panels/Quotes/Diagrams/QuoteDiagramControl.xaml.cs

@@ -12,6 +12,7 @@ using Comal.Classes;
 using InABox.Clients;
 using InABox.Core;
 using InABox.DynamicGrid;
+using InABox.Wpf;
 using InABox.WPF;
 using Syncfusion.UI.Xaml.Diagram;
 using Syncfusion.UI.Xaml.Diagram.Stencil;
@@ -337,6 +338,73 @@ namespace PRSDesktop
                 return;
         }
 
+        private void PickingList_Click(object sender, RoutedEventArgs e)
+        {
+            var confirm = MessageWindow.ShowYesNo("Create a new Costing Sheet?", "Confirm");
+            if (!confirm)
+                return;
+
+            using (new WaitCursor())
+            {
+                var costsheet = new QuoteCostSheet();
+                costsheet.Quote.ID = Diagram.Quote.ID;
+                costsheet.Description = Diagram.Description;
+                new Client<QuoteCostSheet>().Save(costsheet, "Created from Diagram");
+
+                var scale = GetDiagramScale();
+                var updates = new List<QuoteCostSheetItem>();
+
+                
+                
+                var nodes = diagram.Nodes as NodeCollection;
+
+                var keys = nodes.Select(x => x.Key).Distinct().ToList();
+                var masters = QuoteDiagramSymbolCache.Symbols.Where(x => keys.Contains(x.ID));
+                var kitids = masters.Select(x => x.KitID).Distinct().ToArray();
+                
+                var query = new MultiQuery();
+                query.Add(new Filter<Kit>(x => x.ID).InList(kitids));
+                query.Add(new Filter<KitProduct>(x => x.Kit.ID).InList(kitids));
+                query.Query();
+
+                var kits = query.Get<Kit>().ToObjects<Kit>();
+                var kititems = query.Get<KitProduct>().ToObjects<KitProduct>();
+
+                int i = 1;
+                foreach (var symbol in nodes.Where(x => x is QuoteDiagramSymbolModel))
+                {
+                    var header = new QuoteCostSheetItem();
+                    header.Type = QuoteCostSheetItemLineType.Header;
+                    header.Description = symbol.Name;
+                    header.CostSheet.ID = costsheet.ID;
+                    header.Sequence = i++;
+                    updates.Add(header);
+                    
+                    var master = QuoteDiagramSymbolCache.Symbols.FirstOrDefault(x => String.Equals(x.ID,symbol.Key));
+                    var kit = kits.FirstOrDefault(x => x.ID == master?.KitID);
+                    if (kit != null)
+                    {
+                        foreach (var kititem in kititems.Where(x => x.Kit.ID == kit.ID))
+                        {
+                            var item = new QuoteCostSheetItem();
+                            item.Type = QuoteCostSheetItemLineType.Costing;
+                            item.Product.ID = kititem.Product.ID;
+                            item.Product.Synchronise(kititem.Product);
+                            item.Description = item.Product.Name;
+                            item.CostSheet.ID = costsheet.ID;
+                            item.Sequence = i++;
+                            updates.Add(item);
+                        }
+                    }
+
+                }
+
+                if (updates.Any())
+                    new Client<QuoteCostSheetItem>().Save(updates, "");
+            }
+        }
+
+
         private void TakeOff_Click(object sender, RoutedEventArgs e)
         {
             using (new WaitCursor())

+ 7 - 1
prs.desktop/Panels/Quotes/Diagrams/QuoteDiagramSymbolCache.cs

@@ -20,8 +20,10 @@ namespace PRSDesktop
 {
     public class QuoteDiagramSymbolModel : NodeViewModel
     {
+        public Guid KitID { get; set; }
     }
 
+
     public class QuoteDiagramAreaModel : NodeViewModel
     {
     }
@@ -105,6 +107,7 @@ namespace PRSDesktop
         private static QuoteDiagramSymbolModel CreateSymbol(CoreRow row)
         {
             var result = CreateModel<QuoteDiagramSymbolModel, QuoteDiagramSymbol>(row);
+            result.KitID = row.Get<QuoteDiagramSymbol, Guid>(x => x.Kit.ID);
             result.UnitHeight = row.Get<QuoteDiagramSymbol, int>(x => x.Length) / 100F;
             result.UnitWidth = row.Get<QuoteDiagramSymbol, int>(x => x.Width) / 100F;
 
@@ -114,7 +117,10 @@ namespace PRSDesktop
                 if (symbolid != Guid.Empty)
                 {
                     var Image = new Image();
-                    var docrow = _documents.Rows.FirstOrDefault(r => r.Get<Document, Guid>(c => c.ID).Equals(symbolid));
+                    Image.Stretch = Stretch.Fill;
+                    Image.VerticalAlignment = VerticalAlignment.Stretch;
+                    Image.HorizontalAlignment = HorizontalAlignment.Stretch;
+                    var docrow = _documents?.Rows.FirstOrDefault(r => r.Get<Document, Guid>(c => c.ID).Equals(symbolid));
                     if (docrow != null)
                     {
                         var data = docrow.Get<Document, byte[]>(x => x.Data);

+ 77 - 66
prs.desktop/Panels/Quotes/Diagrams/QuoteDiagrams.xaml.cs

@@ -4,12 +4,17 @@ using System.ComponentModel;
 using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using Comal.Classes;
 using InABox.Clients;
 using InABox.Configuration;
 using InABox.Core;
+using InABox.DynamicGrid;
 using InABox.Wpf;
+using InABox.WPF;
+using Syncfusion.Pdf.Parsing;
+using Syncfusion.UI.Xaml.Diagram;
 using Syncfusion.Windows.Tools.Controls;
 
 namespace PRSDesktop
@@ -100,15 +105,20 @@ namespace PRSDesktop
 
         private BitmapImage ExtractImage(Guid id, int page)
         {
-            MessageBox.Show("PDF Functions broken in .NET6");
-            // var doc = _documents.FirstOrDefault(x => x.ID.Equals(id));
-            // if (doc != null)
-            // {
-            //     PdfLoadedDocument pdf = new PdfLoadedDocument(doc.Data);
-            //     var dpi = VisualTreeHelper.GetDpi(this);
-            //     var bitmap = pdf.ExportAsImage(page).AsBitmapImage();
-            //     return bitmap;
-            // }
+            //MessageBox.Show("PDF Functions broken in .NET6");
+            var doc = _documents.FirstOrDefault(x => x.ID.Equals(id));
+            if (doc != null)
+            {
+                var images = ImageUtils.PDFToBitmapArray(doc.Data);
+                return images[page].AsBitmapImage();
+                //var bmp = ImageUtils.PDFToBitmap(doc.Data, page);
+                //var img = ImageUtils.BitmapImageFromBytes(bmp);
+                //return img;
+                // PdfLoadedDocument pdf = new PdfLoadedDocument(doc.Data);
+                // var dpi = VisualTreeHelper.GetDpi(this);
+                // var bitmap = pdf.ExportAsImage(page).AsBitmapImage();
+                // return bitmap;
+            }
             return null;
         }
 
@@ -146,67 +156,68 @@ namespace PRSDesktop
 
         private void TabChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
+            QuoteDiagramSymbolCache.Refresh();
         }
 
         private void AddDiagram_Click(object sender, RoutedEventArgs e)
         {
-            MessageBox.Show("PDF Functions broken in .NET6");
-
-            // Filter<QuoteDocument> extensions = new Filter<QuoteDocument>(x => x.DocumentLink.FileName).EndsWith(".pdf").Or(x => x.DocumentLink.FileName).EndsWith(".PDF");
-            // //.Or(x => x.DocumentLink.FileName).EndsWith(".bmp").Or(x => x.DocumentLink.FileName).EndsWith(".BMP")
-            // //.Or(x => x.DocumentLink.FileName).EndsWith(".png").Or(x => x.DocumentLink.FileName).EndsWith(".PNG")
-            // //.Or(x => x.DocumentLink.FileName).EndsWith(".jpg").Or(x => x.DocumentLink.FileName).EndsWith(".JPG")
-            // //.Or(x => x.DocumentLink.FileName).EndsWith(".jpeg").Or(x => x.DocumentLink.FileName).EndsWith(".JPEG");
-            //
-            // MultiSelectDialog<QuoteDocument> dlg = new MultiSelectDialog<QuoteDocument>(new Filter<QuoteDocument>(x => x.EntityLink.ID).IsEqualTo(QuoteID) /*.And(extensions) */, null, false);
-            // if (dlg.ShowDialog() == true)
-            // {
-            //     QuoteDocument qdoc = dlg.Items().FirstOrDefault();
-            //     var doc = _documents.FirstOrDefault(x => x.ID.Equals(qdoc.DocumentLink.ID));
-            //     if (doc == null)
-            //     {
-            //         doc = new Client<Document>().Load(new Filter<Document>(x => x.ID).IsEqualTo(qdoc.DocumentLink.ID)).FirstOrDefault();
-            //         _documents.Add(doc);
-            //     }
-            //
-            //     PdfLoadedDocument pdf = new PdfLoadedDocument(doc.Data);
-            //     int firstpage = 1;
-            //     int lastpage = pdf.Pages.Count;
-            //     if (pdf.Pages.Count > 1)
-            //     {
-            //         MessageBoxResult mr = MessageBox.Show("This PDF contains multiple pages.  Do you want to import all pages?", "Multi-Page PDF Found", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
-            //         if (mr == MessageBoxResult.Cancel)
-            //             return;
-            //         if (mr == MessageBoxResult.No)
-            //         {
-            //             if (NumberEdit.Execute("Select PDF Page", firstpage, lastpage, ref firstpage))
-            //                 lastpage = firstpage;
-            //             else
-            //                 return;
-            //         }
-            //     }
-            //
-            //     for (int iPage = firstpage; iPage <= lastpage; iPage++)
-            //     {
-            //         QuoteDiagram diagram = new QuoteDiagram();
-            //         if ((firstpage == lastpage) && (firstpage == 1))
-            //             diagram.Description = System.IO.Path.GetFileNameWithoutExtension(doc.FileName);
-            //         else
-            //             diagram.Description = String.Format("{0} {1}", System.IO.Path.GetFileNameWithoutExtension(doc.FileName), iPage);
-            //         diagram.Document.ID = qdoc.ID;
-            //         diagram.Document.Synchronise(qdoc);
-            //         diagram.Document.DocumentLink.ID = qdoc.DocumentLink.ID;
-            //         diagram.Document.DocumentLink.Synchronise(qdoc.DocumentLink);
-            //         diagram.DocumentPage = iPage - 1;
-            //         diagram.Quote.ID = QuoteID;
-            //         new Client<QuoteDiagram>().Save(diagram, "");
-            //         _diagrams.Add(diagram);
-            //         var bmp = ExtractImage(diagram.Document.DocumentLink.ID, iPage-1);
-            //         CreateDrawing(diagram, bmp);
-            //
-            //
-            //     }
-            // }
+            //MessageBox.Show("PDF Functions broken in .NET6");
+
+            Filter<QuoteDocument> extensions = new Filter<QuoteDocument>(x => x.DocumentLink.FileName).EndsWith(".pdf").Or(x => x.DocumentLink.FileName).EndsWith(".PDF");
+            //.Or(x => x.DocumentLink.FileName).EndsWith(".bmp").Or(x => x.DocumentLink.FileName).EndsWith(".BMP")
+            //.Or(x => x.DocumentLink.FileName).EndsWith(".png").Or(x => x.DocumentLink.FileName).EndsWith(".PNG")
+            //.Or(x => x.DocumentLink.FileName).EndsWith(".jpg").Or(x => x.DocumentLink.FileName).EndsWith(".JPG")
+            //.Or(x => x.DocumentLink.FileName).EndsWith(".jpeg").Or(x => x.DocumentLink.FileName).EndsWith(".JPEG");
+            
+            MultiSelectDialog<QuoteDocument> dlg = new MultiSelectDialog<QuoteDocument>(new Filter<QuoteDocument>(x => x.EntityLink.ID).IsEqualTo(Master.ID) /*.And(extensions) */, null, false);
+            if (dlg.ShowDialog() == true)
+            {
+                QuoteDocument qdoc = dlg.Items().FirstOrDefault();
+                var doc = _documents.FirstOrDefault(x => x.ID.Equals(qdoc.DocumentLink.ID));
+                if (doc == null)
+                {
+                    doc = new Client<Document>().Load(new Filter<Document>(x => x.ID).IsEqualTo(qdoc.DocumentLink.ID)).FirstOrDefault();
+                    _documents.Add(doc);
+                }
+
+                var array = ImageUtils.PDFToBitmapArray(doc.Data);
+                
+                int firstpage = 1;
+                int lastpage = array.Length;
+                if (array.Length > 1)
+                {
+                    MessageBoxResult mr = MessageBox.Show("This PDF contains multiple pages.  Do you want to import all pages?", "Multi-Page PDF Found", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
+                    if (mr == MessageBoxResult.Cancel)
+                        return;
+                    if (mr == MessageBoxResult.No)
+                    {
+                        if (NumberEdit.Execute("Select PDF Page", firstpage, lastpage, ref firstpage))
+                            lastpage = firstpage;
+                        else
+                            return;
+                    }
+                }
+            
+                for (int iPage = firstpage; iPage <= lastpage; iPage++)
+                {
+                    QuoteDiagram diagram = new QuoteDiagram();
+                    if ((firstpage == lastpage) && (firstpage == 1))
+                        diagram.Description = System.IO.Path.GetFileNameWithoutExtension(doc.FileName);
+                    else
+                        diagram.Description = String.Format("{0} {1}", System.IO.Path.GetFileNameWithoutExtension(doc.FileName), iPage);
+                    diagram.Document.ID = qdoc.ID;
+                    diagram.Document.Synchronise(qdoc);
+                    diagram.Document.DocumentLink.ID = qdoc.DocumentLink.ID;
+                    diagram.Document.DocumentLink.Synchronise(qdoc.DocumentLink);
+                    diagram.DocumentPage = iPage - 1;
+                    diagram.Quote.ID = Master.ID;
+                    new Client<QuoteDiagram>().Save(diagram, "");
+                    _diagrams.Add(diagram);
+                    CreateDrawing(diagram, array[iPage-1].AsBitmapImage());
+            
+            
+                }
+            }
         }
 
         private void DeleteDiagram_Click(object sender, RoutedEventArgs e)

+ 1 - 1
prs.desktop/prsdesktop.iss

@@ -8,7 +8,7 @@
 #define public Dependency_Path_NetCoreCheck "dependencies\"
 
 #define MyAppName "PRS Desktop"
-#define MyAppVersion "8.52a"
+#define MyAppVersion "8.53"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSDesktop.exe"

+ 1 - 1
prs.licensing/PRSLicensing.iss

@@ -8,7 +8,7 @@
 #define public Dependency_Path_NetCoreCheck "dependencies\"
 
 #define MyAppName "PRS Licensing"
-#define MyAppVersion "8.52a"
+#define MyAppVersion "8.53"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSLicensing.exe"

+ 1 - 1
prs.server/PRSServer.iss

@@ -8,7 +8,7 @@
 #define public Dependency_Path_NetCoreCheck "dependencies\"
 
 #define MyAppName "PRS Server"
-#define MyAppVersion "8.52a"
+#define MyAppVersion "8.53"
 #define MyAppPublisher "PRS Digital"
 #define MyAppURL "https://www.prs-software.com.au"
 #define MyAppExeName "PRSServer.exe"