فهرست منبع

PRS DESKTOP - Job Requisitions screen purchasing function

Nick-PRSDigital@bitbucket.org 2 سال پیش
والد
کامیت
9e96f78315

+ 3 - 61
prs.desktop/JobRequisitionPurchasing.xaml

@@ -3,70 +3,12 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:local="clr-namespace:PRSDesktop"
+             xmlns:local="clr-namespace:PRSDesktop" xmlns:dynamic="clr-namespace:InABox.DynamicGrid;assembly=InABox.Wpf"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
     <DockPanel>
-        <Border DockPanel.Dock="Top" BorderBrush="Gray" BorderThickness="1" Background="WhiteSmoke">
-            <Grid Margin="4,4,0,0">
-                <Grid.ColumnDefinitions>
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="*" />
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="*" />
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="*" />
-                </Grid.ColumnDefinitions>
-                <Grid.RowDefinitions>
-                    <RowDefinition Height="Auto" />
-                    <RowDefinition Height="Auto" />
-                    <RowDefinition Height="Auto" />
-                    <RowDefinition Height="Auto" />
-                    <RowDefinition Height="Auto" />
-                    <RowDefinition Height="Auto" />
-                </Grid.RowDefinitions>
-
-                <Label Grid.Row="0" Grid.Column="0" Margin="0,0,4,4" Content="Purchase #"
-                               VerticalContentAlignment="Center" />
-                <TextBox Grid.Row="0" Grid.Column="1" Margin="0,0,4,4" x:Name="Number"
-                                 VerticalContentAlignment="Center" />
-
-                <Label Grid.Row="1" Grid.Column="0" Margin="0,0,4,4" Content="Supplier"
-                               VerticalContentAlignment="Center" />
-                <TextBox Grid.Row="1" Grid.Column="1" Margin="0,0,4,4" x:Name="SupplierCode"
-                                 VerticalContentAlignment="Center" />
-                <TextBox Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="4" Margin="0,0,4,4"
-                                 x:Name="SupplierName" VerticalContentAlignment="Center" />
-
-                <Label Grid.Row="2" Grid.Column="0" Margin="0,0,4,4" Content="Description"
-                               VerticalContentAlignment="Center" />
-                <Border Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="5" BorderBrush="Gray"
-                                BorderThickness="0.75" Background="White" Padding="0" Margin="0,0,4,4">
-                    <TextBlock Height="80" x:Name="Description" TextWrapping="WrapWithOverflow" />
-                </Border>
-
-                <Label Grid.Row="3" Grid.Column="0" Margin="0,0,4,4" Content="Issued"
-                               VerticalContentAlignment="Center" />
-                <TextBox Grid.Row="3" Grid.Column="1" Margin="0,0,4,4" x:Name="Issued"
-                                 VerticalContentAlignment="Center" />
-
-                <Label Grid.Row="3" Grid.Column="2" Margin="0,0,4,4" Content="Issued By"
-                               VerticalContentAlignment="Center" />
-                <TextBox Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="3" Margin="0,0,4,4" x:Name="IssuedBy"
-                                 VerticalContentAlignment="Center" />
-
-                <Label Grid.Row="4" Grid.Column="0" Margin="0,0,4,4" Content="Due Date"
-                               VerticalContentAlignment="Center" />
-                <TextBox Grid.Row="4" Grid.Column="1" Margin="0,0,4,4" x:Name="DueDate"
-                                 VerticalContentAlignment="Center" />
-
-                <Label Grid.Row="4" Grid.Column="4" Margin="0,0,4,4" Content="Closed"
-                               VerticalContentAlignment="Center" />
-                <TextBox Grid.Row="4" Grid.Column="5" Margin="0,0,4,4" x:Name="ClosedDate"
-                                 VerticalContentAlignment="Center" />
-
-            </Grid>
+        <Border BorderBrush="Gray" BorderThickness="0.75" x:Name="DetailBorder">
+            <dynamic:EmbeddedDynamicEditorForm Grid.Row="1" x:Name="Editor"/>
         </Border>
-        <local:SupplierPurchaseOrderItems x:Name="Items" DockPanel.Dock="Top" Margin="0,2,0,2"/>
     </DockPanel>
 </UserControl>

+ 296 - 31
prs.desktop/JobRequisitionPurchasing.xaml.cs

@@ -5,63 +5,328 @@ using InABox.DynamicGrid;
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
 using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
 
 namespace PRSDesktop
 {
     /// <summary>
     /// Interaction logic for JobRequisitionPurchasing.xaml
     /// </summary>
-    public partial class JobRequisitionPurchasing : UserControl
+    public partial class JobRequisitionPurchasing : UserControl, IBasePanel, IDynamicEditorHost
     {
-        private List<JobRequisitionItem> jobRequiItems;
-        public List<JobRequisitionItem> JobRequiItems
+        public delegate void PurchaseOrderSaved();
+        public event PurchaseOrderSaved OnPurchaseOrderSaved;
+
+        public List<JobRequisitionItem> JobRequiItems;
+
+        public event DataModelUpdateEvent? OnUpdateDataModel;
+
+        public PurchaseOrder Order { get; set; } = new PurchaseOrder();
+
+        bool bLoaded = false;
+        public void LoadFromRequiLine()
+        {
+            if (bLoaded)
+                return;
+
+            var poid = JobRequiItems[0].PurchaseOrderItem.PurchaseOrderLink.ID;
+            if (poid != Guid.Empty && poid != Order.ID)
+                LoadPO(poid);              
+            else if (poid == Guid.Empty)
+                ClearEditor();
+        }
+
+        private void LoadPO(Guid poid)
         {
-            get => jobRequiItems;
-            set
+            var po = new Client<PurchaseOrder>().Query(
+                        new Filter<PurchaseOrder>(x => x.ID).IsEqualTo(poid),
+                        new Columns<PurchaseOrder>
+                        (
+                            x => x.ID,
+                            x => x.SupplierLink.ID,
+                            x => x.SupplierLink.Code,
+                            x => x.SupplierLink.Name,
+                            x => x.Notes,
+                            x => x.Category.ID,
+                            x => x.Category.Code,
+                            x => x.Category.Description,
+                            x => x.RaisedBy.ID,
+                            x => x.RaisedBy.Code,
+                            x => x.RaisedBy.Name,
+                            x => x.DueDate,
+                            x => x.IssuedBy.ID,
+                            x => x.IssuedBy.Code,
+                            x => x.IssuedBy.Name,
+                            x => x.IssuedDate,
+                            x => x.ClosedDate,
+                            x => x.PONumber
+                            ))
+                        .Rows.FirstOrDefault().ToObject<PurchaseOrder>();
+            if (po != null)
             {
-                jobRequiItems = value;
-                if (jobRequiItems.First().PurchaseOrderItem.ID != Guid.Empty)
-                    LoadOrder(new Client<PurchaseOrder>().Query(new Filter<PurchaseOrder>(x => x.ID).IsEqualTo(jobRequiItems.First().PurchaseOrderItem.PurchaseOrderLink.ID)).Rows.First());
+                Order = po;
+                CreatePOEditor(new BaseObject[] { po });
             }
         }
 
+        public IEnumerable<DynamicGridColumn> Columns => throw new NotImplementedException();
+
+        public bool IsReady { get; set; }
+
+        public string SectionName { get; set; }
+
         public JobRequisitionPurchasing()
         {
             InitializeComponent();
+            empName = new Client<Employee>().Query(new Filter<Employee>(x => x.UserLink.ID).IsEqualTo(ClientFactory.UserGuid)).Rows.FirstOrDefault().Get<Employee, string>(x => x.Name);
+            CreatePOEditor();
             //JobRequiItems = new List<JobRequisitionItem>();
-            Items.Options.Remove(DynamicGridOption.ImportData);
-            Items.Options.Remove(DynamicGridOption.ExportData);
         }
-        private void LoadOrder(CoreRow row)
+
+        private string CheckDate(DateTime date)
         {
-            Number.Text = row == null ? "" : row.Get<PurchaseOrder, string>(x => x.PONumber);
+            return date.IsEmpty() ? "" : date.ToShortDateString();
+        }
+
+        private bool EditorChanged = false;
+        private string empName = "";
 
-            SupplierCode.Text = row == null ? "" : row.Get<PurchaseOrder, string>(x => x.SupplierLink.Code);
-            SupplierName.Text = row == null ? "" : row.Get<PurchaseOrder, string>(x => x.SupplierLink.Name);
+        private void CreatePOEditor(BaseObject[]? items = null)
+        {
+            DetailBorder.Child = null;
 
-            Description.Text = row == null ? "" : row.Get<PurchaseOrder, string>(x => x.Notes);
+            Editor = new EmbeddedDynamicEditorForm();
+            Editor.SetLayoutType<VerticalDynamicEditorGridLayout>();
+            Editor.SetValue(Grid.RowProperty, 1);
+            Editor.SetValue(Grid.ColumnProperty, 0);
+            Editor.SetValue(Grid.ColumnSpanProperty, 4);
+            
+            EditorChanged = false;
 
-            Issued.Text = row == null ? "" : CheckDate(row.Get<PurchaseOrder, DateTime>(x => x.IssuedDate));
-            IssuedBy.Text = row == null ? "" : row.Get<PurchaseOrder, string>(x => x.IssuedBy.Name);
+            Editor.OnAfterEditorValueChanged += (sender, column) =>
+            {
+                EditorChanged = true;
+                return null;
+            };
+
+            Editor.OnOK += () =>
+            {
+                var cancel = new System.ComponentModel.CancelEventArgs();
+                Editor.SaveItem(cancel);
+                UpdateJobRequiItems();
+                OnPurchaseOrderSaved?.Invoke();
+                bLoaded = false;
+            };
+            Editor.OnCancel += () =>
+            {
+                bLoaded = false;
+                ClearEditor();
+            };
 
-            DueDate.Text = row == null ? "" : CheckDate(row.Get<PurchaseOrder, DateTime>(x => x.DueDate));
-            ClosedDate.Text = row == null ? "" : CheckDate(row.Get<PurchaseOrder, DateTime>(x => x.ClosedDate));
+            DetailBorder.Child = Editor;
+
+            var grid = DynamicGridUtils.CreateDynamicGrid(typeof(DynamicDataGrid<>), typeof(PurchaseOrder));
+            grid.InitialiseEditorForm(Editor, items ?? new object[] { Activator.CreateInstance(typeof(PurchaseOrder))! });
+
+            var loadPO = new Button
+            {
+                Content = "Load PO",
+                Height = 30,
+                Margin = new System.Windows.Thickness(2, 0, 0, 0),
+                Padding = new System.Windows.Thickness(15, 0, 15, 0)
+            };
+            loadPO.Click += LoadPO_Click;
+            Editor.AddButton(loadPO);
         }
 
-        private string CheckDate(DateTime date)
+        private void LoadPO_Click(object sender, System.Windows.RoutedEventArgs e)
         {
-            return date.IsEmpty() ? "" : date.ToShortDateString();
+            var popup = new PopupList(typeof(PurchaseOrder), Guid.Empty, new string[0]);
+            if(popup.ShowDialog() == true)
+            {
+                bLoaded = true;
+                LoadPO(popup.ID);
+            }
+        }
+
+        private void UpdateJobRequiItems()
+        {
+            var page = Editor.Pages.Find(x => x.GetType() == typeof(SupplierPurchaseOrderItemOneToMany)) as SupplierPurchaseOrderItemOneToMany;
+            if (page.Items.Count != 0)
+                MatchRequiItems(page.Items);
+        }
+
+        private void MatchRequiItems(List<PurchaseOrderItem> poItems)
+        {
+            List<JobRequisitionItem> toSave = new List<JobRequisitionItem>();
+            foreach (var JobReqItem in JobRequiItems)
+            {
+                if (JobReqItem.PurchaseOrderItem.ID == Guid.Empty)
+                    foreach (var item in poItems)
+                        if (MatchReqItemToPOItem(JobReqItem, item))
+                            toSave.Add(UpdateJobReqItemWithPODetails(JobReqItem, item));
+            }
+            if (toSave.Count > 0)
+                new Client<JobRequisitionItem>().Save(toSave, "Updated from Job Requi Review Create Purchase Order");
+        }
+
+        private bool MatchReqItemToPOItem(JobRequisitionItem JobReqItem, PurchaseOrderItem item)
+        {
+            if (JobReqItem.Product.ID == item.Product.ID &&
+                                JobReqItem.Dimensions.UnitSize == item.Dimensions.UnitSize &&
+                                JobReqItem.Requisition.Job.ID == item.Job.ID)
+                return true;
+            else
+                return false;
+        }
+
+        private JobRequisitionItem UpdateJobReqItemWithPODetails(JobRequisitionItem JobReqItem, PurchaseOrderItem poItem)
+        {
+            JobReqItem.PurchaseOrderItem.ID = poItem.ID;
+            JobReqItem.PurchaseOrderItem.DueDate = poItem.DueDate;
+            if (JobReqItem.Status != JobRequisitionItemStatus.OnOrder)
+            {
+                JobReqItem.Notes = JobReqItem.Notes + Environment.NewLine + "Line marked as On Order by " + empName + " on " + DateTime.Now.ToString("dd MMM yy");
+                JobReqItem.Ordered = poItem.Created;
+            }
+            return JobReqItem;
+        }
+
+        private void ClearEditor()
+        {
+            Order = new PurchaseOrder();
+            CreatePOEditor();
+
+            //if (Popup is not null)
+            //{
+            //    Popup.Value = Guid.Empty;
+            //}
+        }
+
+        public void DropItems(CoreRow[] rows)
+        {
+            var page = Editor.Pages.Find(x => x.GetType() == typeof(SupplierPurchaseOrderItemOneToMany)) as SupplierPurchaseOrderItemOneToMany;
+            if (page.Items.Count == 0)
+                page.LoadItems(CreatePOItemsFromRequiItems(rows).ToArray());
+            else
+                page.LoadItems(CombineItems(rows, page.Items));
+        }
+
+        private PurchaseOrderItem[] CombineItems(CoreRow[] selected, List<PurchaseOrderItem> existingItems)
+        {
+            List<PurchaseOrderItem> items = new List<PurchaseOrderItem>();
+            items.AddRange(existingItems);
+            items.AddRange(CreatePOItemsFromRequiItems(selected, existingItems));
+            return items.ToArray();
+        }
+
+        private List<PurchaseOrderItem> CreatePOItemsFromRequiItems(CoreRow[] selected, List<PurchaseOrderItem> comparison = null)
+        {
+            List<PurchaseOrderItem> items = new List<PurchaseOrderItem>();
+            foreach (CoreRow row in selected)
+            {
+                JobRequisitionItem JobReqItem = row.ToObject<JobRequisitionItem>();
+                JobRequiItems.Add(JobReqItem);
+                if (JobReqItem.PurchaseOrderItem.ID != Guid.Empty)
+                    continue;
+
+                PurchaseOrderItem POItem = new PurchaseOrderItem();
+                POItem.Product.ID = JobReqItem.Product.ID;
+                POItem.Product.Code = JobReqItem.Product.Code;
+                POItem.Product.Name = JobReqItem.Product.Name;
+                POItem.Description = JobReqItem.Product.Name;
+                POItem.Qty = JobReqItem.Qty;
+                POItem.Dimensions.CopyFrom(JobReqItem.Dimensions);
+                POItem.Style.ID = JobReqItem.Style.ID;
+                POItem.Style.Code = JobReqItem.Style.Code;
+                POItem.Style.Description = JobReqItem.Style.Description;
+                POItem.Job.ID = JobReqItem.Requisition.Job.ID;
+                POItem.Job.JobNumber = JobReqItem.Requisition.Job.JobNumber;
+                POItem.Job.Name = JobReqItem.Requisition.Job.Name;
+                POItem.Dimensions.UnitSize = JobReqItem.Dimensions.UnitSize;
+                if (comparison != null && !Duplicated(POItem, comparison))
+                    items.Add(POItem);
+                else if (comparison == null)
+                    items.Add(POItem);
+            }
+            return items;
+        }
+
+        private bool Duplicated(PurchaseOrderItem newItem, List<PurchaseOrderItem> existing)
+        {
+            if (existing.Find(x =>
+                x.Product.ID == newItem.Product.ID
+                && x.Qty == newItem.Qty
+                && x.Style.ID == newItem.Style.ID
+                && x.Job.ID == newItem.Job.ID
+                && x.Dimensions.UnitSize == newItem.Dimensions.UnitSize
+                )
+                != null)
+                return true;
+
+            return false;
+        }
+
+
+        public void LoadColumns(string column, Dictionary<string, string> columns)
+        {
+
+        }
+
+        public IFilter? DefineFilter(Type type) => LookupFactory.DefineFilter(type);
+
+        public void LoadLookups(ILookupEditorControl sender)
+        {
+            var editor = sender.EditorDefinition as ILookupEditor;
+            var colname = sender.ColumnName;
+
+            var values = editor.Values(colname, Editor.Items);
+            sender.LoadLookups(values);
+        }
+
+        public Document? FindDocument(string filename) => null;
+
+        public Document? GetDocument(Guid id) => null;
+
+        public void SaveDocument(Document document) { }
+
+        object?[] IDynamicEditorHost.GetItems() => Editor.Items;
+
+        public BaseEditor? GetEditor(DynamicGridColumn column) => column.Editor.CloneEditor();
+
+        public void CreateToolbarButtons(IPanelHost host)
+        {
+
+        }
+
+        public Dictionary<string, object[]> Selected()
+        {
+            return new Dictionary<string, object[]>();
+        }
+
+        public void Heartbeat(TimeSpan time)
+        {
+
+        }
+
+        public void Setup()
+        {
+
+        }
+
+        public void Shutdown()
+        {
+
+        }
+
+        public void Refresh()
+        {
+
+        }
+
+        public DataModel DataModel(Selection selection)
+        {
+            return new EmptyDataModel();
         }
     }
 }

+ 3 - 3
prs.desktop/Panels/Products/Job Requisitions/JobRequisitionHoldingsReview.xaml

@@ -45,7 +45,7 @@
     <Grid Margin="0">
         <Grid.RowDefinitions>
             <RowDefinition Height="auto"/>
-            <RowDefinition Height="auto"/>
+            <RowDefinition Height="*"/>
         </Grid.RowDefinitions>
 
         <Border Grid.Row="0" BorderThickness="1.25" BorderBrush="Gray" Background="WhiteSmoke" Margin="0, 0, 0, 4">
@@ -152,7 +152,7 @@
                                     <RotateTransform Angle="270"/>
                                 </TextBlock.LayoutTransform>
                             </TextBlock>
-                            <ListView Grid.Column="1" x:Name="listViewYellow" BorderThickness="0" Margin="0" Background="Cornsilk" VerticalAlignment="Center"
+                            <ListView Grid.Column="1" x:Name="listViewYellow" BorderThickness="0" Margin="0" Background="Cornsilk" VerticalAlignment="Top"
                               HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Padding="0"/>
                         </Grid>
                     </Border>
@@ -169,7 +169,7 @@
                                     <RotateTransform Angle="270"/>
                                 </TextBlock.LayoutTransform>
                             </TextBlock>
-                            <ListView Grid.Column="1" x:Name="listViewRed" Grid.Row="4" BorderThickness="0" Margin="0" Background="LightSalmon" VerticalAlignment="Center"
+                            <ListView Grid.Column="1" x:Name="listViewRed" Grid.Row="4" BorderThickness="0" Margin="0" Background="LightSalmon" VerticalAlignment="Top"
                               HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Padding="0"/>
                         </Grid>
                     </Border>

+ 5 - 55
prs.desktop/Panels/Products/Job Requisitions/JobRequisitionReviewGrid.cs

@@ -31,8 +31,7 @@ namespace PRSDesktop
         public event GridRefresh OnGridRefresh;
         public Guid empID = new Guid();
         string empName = "";
-        bool bIncludeArchived = false;
-        bool bViewCancelled = false;
+
         JobRequisitionReviewUserSettings FilterSettings = new JobRequisitionReviewUserSettings();
 
         Dictionary<Guid, double> JobRequisReservedQty = new Dictionary<Guid, double>();
@@ -42,7 +41,7 @@ namespace PRSDesktop
             if (!string.IsNullOrWhiteSpace(FilterSettings.Filter.Name))
             {
                 SelectedFilter = new(FilterSettings.Filter.Name, Serialization.Deserialize<Filter<JobRequisitionItem>>(FilterSettings.Filter.Filter));
-                UpdateFilterButton(InABox.Wpf.Resources.filter_set);
+                UpdateFilterButton(InABox.Wpf.Resources.filter_set, FilterSettings.Filter.Name);
             }
                 
 
@@ -52,7 +51,6 @@ namespace PRSDesktop
                 DynamicGridOption.RecordCount
                 );
             Options.Remove(DynamicGridOption.AddRows);
-            Options.Remove(DynamicGridOption.EditRows);
             Options.Remove(DynamicGridOption.ImportData);
             Options.Remove(DynamicGridOption.ExportData);
             Options.Remove(DynamicGridOption.Print);
@@ -101,13 +99,6 @@ namespace PRSDesktop
 
             if (Security.CanEdit<JobRequisitionItem>())
                 ActionColumns.Add(new DynamicMenuColumn(BuildMenu));
-            //if (Security.CanEdit<PurchaseOrder>())
-            //    AddButton("Create Purchase Order", null, CreatePurchaseOrder);
-            //if (Security.CanEdit<PurchaseOrder>())
-            //    AddButton("Create Treatment PO", null, CreateTreatmentPO);
-
-            AddButton("Include Archived", null, ViewArchived);
-            AddButton("Include Cancelled", null, ViewCancelled);
 
             OnSelectItem += JobRequisitionReviewGrid_OnSelectItem;
 
@@ -125,10 +116,11 @@ namespace PRSDesktop
             //Migrate();
         }
 
-        private void GridOnFilterSelected(DynamicGridFilter filter, Bitmap image)
+        private bool GridOnFilterSelected(DynamicGridFilter filter)
         {
             new UserConfiguration<JobRequisitionReviewUserSettings>().Save(new JobRequisitionReviewUserSettings { Filter = filter });         
             OnGridRefresh?.Invoke();
+            return true;
         }
 
         private void Migrate()
@@ -263,43 +255,7 @@ namespace PRSDesktop
         private void JobRequisitionReviewGrid_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
         {
             OnJobRequiItemSelected?.Invoke(SelectedRows);
-        }
-
-        private bool ViewCancelled(Button button, CoreRow[] rows)
-        {
-            if (bViewCancelled)
-            {
-                bViewCancelled = false;
-                button.Content = "Include Cancelled";
-            }
-            else
-            {
-                bViewCancelled = true;
-                button.Content = "Exclude Cancelled";
-            }
-
-            OnGridRefresh?.Invoke();
-
-            return true;
-        }
-
-        private bool ViewArchived(Button button, CoreRow[] rows)
-        {
-            if (bIncludeArchived)
-            {
-                bIncludeArchived = false;
-                button.Content = "Include Archived";
-            }
-            else
-            {
-                bIncludeArchived = true;
-                button.Content = "Exclude Archived";
-            }
-
-            OnGridRefresh?.Invoke();
-
-            return true;
-        }
+        }        
 
         private bool CreateTreatmentPO(Button button, CoreRow[] rows)
         {
@@ -654,12 +610,6 @@ namespace PRSDesktop
         {
             criteria.Add(new Filter<JobRequisitionItem>(x => x.Requisition.Approved).IsNotEqualTo(DateTime.MinValue));
 
-            if (!bViewCancelled)
-                criteria.Add(new Filter<JobRequisitionItem>(x => x.Status).IsNotEqualTo(JobRequisitionItemStatus.Cancelled));
-
-            if (!bIncludeArchived)
-                criteria.Add(new Filter<JobRequisitionItem>(x => x.Status).IsNotEqualTo(JobRequisitionItemStatus.Archived));
-
             sort = new SortOrder<JobRequisitionItem>(x => x.Requisition.Number, SortDirection.Descending);
             base.Reload(criteria, columns, ref sort, action);
         }

+ 4 - 4
prs.desktop/Panels/Products/Job Requisitions/JobRequisitionsPanel.xaml

@@ -9,7 +9,7 @@
     <dynamicgrid:DynamicSplitPanel MasterCaption="Job Requisition Items" DetailCaption="Available Stock" AnchorWidth="1200" AllowableViews="Combined" View="Combined">
        
         <dynamicgrid:DynamicSplitPanel.Master>
-            <local:JobRequisitionReviewGrid  x:Name="JobRequiItems" Margin="0,2,0,0"/>
+            <local:JobRequisitionReviewGrid  x:Name="JobRequiItems" Margin="0,2,0,0" MouseMove="Grid_MouseMove"/>
         </dynamicgrid:DynamicSplitPanel.Master>
 
         <dynamicgrid:DynamicSplitPanel.Detail>
@@ -21,8 +21,8 @@
       
                 <Grid Grid.Row="0">
                     <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="*" />
-                        <ColumnDefinition Width="*" />
+                        <ColumnDefinition Width="*"/>
+                        <ColumnDefinition Width="*"/>
                     </Grid.ColumnDefinitions>
                     <Button Grid.Column="0" Content="Reserve Stock" Height="30"  FontWeight="DemiBold" x:Name="reserveBtn"
                             BorderBrush="DarkGray" Margin="0,2,1,0" Padding="13,3,13,3" BorderThickness="1.25"
@@ -37,7 +37,7 @@
                         <ColumnDefinition Width="0" x:Name="purchaseCol"/>
                     </Grid.ColumnDefinitions>
                     <local:JobRequisitionHoldingsReview Grid.Column="0" x:Name="holdings" Margin="0,2,0,0"/>
-                    <local:JobRequisitionPurchasing Grid.Column="1" x:Name="purchasing" Margin="0,2,0,0"/>
+                    <local:JobRequisitionPurchasing Grid.Column="1" x:Name="purchasing" Margin="0,2,0,0" AllowDrop="True" Drop="Purchasing_Drop"/>
                 </Grid>
             </Grid>
         </dynamicgrid:DynamicSplitPanel.Detail>

+ 30 - 1
prs.desktop/Panels/Products/Job Requisitions/JobRequisitionsPanel.xaml.cs

@@ -7,7 +7,10 @@ using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
+using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Input;
 using System.Windows.Media;
 
 namespace PRSDesktop
@@ -31,6 +34,7 @@ namespace PRSDesktop
     {
         Guid JobID = Guid.Empty;
         private JobRequisitionPanelSettings _settings = null;
+
         public JobRequisitionsPanel()
         {
             InitializeComponent();
@@ -71,6 +75,11 @@ namespace PRSDesktop
                 JobRequiItems.Options.Add(DynamicGridOption.MultiSelect);
                 reserveBtn.Background = new SolidColorBrush(Colors.WhiteSmoke);
                 purchaseBtn.Background = new SolidColorBrush(Colors.LightGray);
+                if (JobRequiItems.SelectedRows.Any())
+                {
+                    purchasing.JobRequiItems = CreateList(JobRequiItems.SelectedRows);
+                    purchasing.LoadFromRequiLine();
+                }
             }
         }
 
@@ -154,6 +163,8 @@ namespace PRSDesktop
             holdings.CompanyDefaultStyle = _settings.ProductStyle;
 
             holdings.OnHoldingsReviewRefresh += Holdings_OnHoldingsReviewRefresh;
+
+            purchasing.OnPurchaseOrderSaved += () => { RefreshJobRequiGrids(); };
         }
 
 
@@ -179,7 +190,11 @@ namespace PRSDesktop
         private void OnJobRequiItemSelected(CoreRow[] rows)
         {
             holdings.Item = rows[0].ToObject<JobRequisitionItem>();
-            purchasing.JobRequiItems = CreateList(rows);
+            if (mode == PanelMode.Purchase)
+            {
+                purchasing.JobRequiItems = CreateList(rows);
+                purchasing.LoadFromRequiLine();
+            }
         }
 
         private List<JobRequisitionItem> CreateList(CoreRow[] rows)
@@ -210,5 +225,19 @@ namespace PRSDesktop
         {
             Mode = PanelMode.Purchase;
         }
+
+        private void Grid_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
+        {
+            if (e.LeftButton == MouseButtonState.Pressed
+                && e.OriginalSource.GetType() != typeof(Border)
+                && e.OriginalSource.GetType() != typeof(Thumb)
+                )
+                DragDrop.DoDragDrop(JobRequiItems, JobRequiItems.SelectedRows, DragDropEffects.Link);
+        }
+
+        private void Purchasing_Drop(object sender, DragEventArgs e)
+        {
+            purchasing.DropItems(JobRequiItems.SelectedRows);
+        }
     }
 }