|
@@ -24,6 +24,9 @@ public class SupplierPurchaseOrderItemOneToMany : DynamicOneToManyGrid<PurchaseO
|
|
|
|
|
|
public SupplierPurchaseOrderItemOneToMany() : base()
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
HiddenColumns.Add(x => x.ID);
|
|
|
|
|
|
HiddenColumns.Add(x => x.Description);
|
|
@@ -78,11 +81,16 @@ public class SupplierPurchaseOrderItemOneToMany : DynamicOneToManyGrid<PurchaseO
|
|
|
HiddenColumns.Add(x => x.OpenForms);
|
|
|
ActionColumns.Add(new DynamicMenuColumn(BuildFormsMenu) { Position = DynamicActionColumnPosition.End });
|
|
|
ActionColumns.Add(new DynamicImageColumn(FormsImage) { Position = DynamicActionColumnPosition.Start, ToolTip = FormsToolTip });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
protected override void Init()
|
|
|
{
|
|
|
base.Init();
|
|
|
+
|
|
|
+ AddButton("Catalog", PRSDesktop.Resources.product.AsBitmapImage(), SearchProducts);
|
|
|
|
|
|
if (Security.IsAllowed<CanViewConsignmentModule>())
|
|
|
{
|
|
@@ -494,6 +502,155 @@ public class SupplierPurchaseOrderItemOneToMany : DynamicOneToManyGrid<PurchaseO
|
|
|
|
|
|
base.SelectItems(rows);
|
|
|
}
|
|
|
+
|
|
|
+ private bool SearchProducts(Button button, CoreRow[] rows)
|
|
|
+ {
|
|
|
+ var dlg = new MultiSelectDialog<ProductInstance>(
|
|
|
+ new Filter<ProductInstance>().All(),
|
|
|
+ Columns.None<ProductInstance>()
|
|
|
+ .Add(x => x.ID)
|
|
|
+ .Add(x => x.Product.ID)
|
|
|
+ .Add(x => x.Product.Code)
|
|
|
+ .Add(x => x.Product.Name)
|
|
|
+ .Add(x => x.Product.TaxCode.ID)
|
|
|
+ .Add(x => x.Product.TaxCode.Code)
|
|
|
+ .Add(x => x.Product.TaxCode.Description)
|
|
|
+ .Add(x => x.Product.TaxCode.Rate)
|
|
|
+ .Add(x => x.Product.PurchaseGL.ID)
|
|
|
+ .Add(x => x.Product.PurchaseGL.Code)
|
|
|
+ .Add(x => x.Product.PurchaseGL.Description)
|
|
|
+ .Add(x => x.Product.CostCentre.ID)
|
|
|
+ .Add(x => x.Product.CostCentre.Code)
|
|
|
+ .Add(x => x.Product.CostCentre.Description)
|
|
|
+ .Add(x => x.Style.ID)
|
|
|
+ .Add(x => x.Style.Code)
|
|
|
+ .Add(x => x.Style.Description)
|
|
|
+ .AddDimensionsColumns(x => x.Dimensions)
|
|
|
+ .Add(x => x.NettCost),
|
|
|
+ false
|
|
|
+ );
|
|
|
+ if (dlg.ShowDialog() == true)
|
|
|
+ {
|
|
|
+ CreateItems(() =>
|
|
|
+ {
|
|
|
+ var result = new List<PurchaseOrderItem>();
|
|
|
+ var pi = dlg.Data().Rows.FirstOrDefault()?.ToObject<ProductInstance>();
|
|
|
+ if (pi == null)
|
|
|
+ return result;
|
|
|
+
|
|
|
+ var sp = new Client<SupplierProduct>().Query(
|
|
|
+ new Filter<SupplierProduct>(x => x.Product.ID).IsEqualTo(pi.Product.ID)
|
|
|
+ .And(x=>x.Style.ID).IsEqualTo(pi.Style.ID)
|
|
|
+ .And(x=>x.Dimensions).DimensionEquals(pi.Dimensions),
|
|
|
+ Columns.None<SupplierProduct>().Add(x => x.ID)
|
|
|
+ .Add(x => x.Product.ID)
|
|
|
+ .Add(x => x.Product.Code)
|
|
|
+ .Add(x => x.Product.Name)
|
|
|
+ .Add(x => x.Product.TaxCode.ID)
|
|
|
+ .Add(x => x.Product.TaxCode.Code)
|
|
|
+ .Add(x => x.Product.TaxCode.Description)
|
|
|
+ .Add(x => x.Product.TaxCode.Rate)
|
|
|
+ .Add(x => x.Product.PurchaseGL.ID)
|
|
|
+ .Add(x => x.Product.PurchaseGL.Code)
|
|
|
+ .Add(x => x.Product.PurchaseGL.Description)
|
|
|
+ .Add(x => x.Product.CostCentre.ID)
|
|
|
+ .Add(x => x.Product.CostCentre.Code)
|
|
|
+ .Add(x => x.Product.CostCentre.Description)
|
|
|
+ .Add(x => x.Style.ID)
|
|
|
+ .Add(x => x.Style.Code)
|
|
|
+ .Add(x => x.Style.Description)
|
|
|
+ .Add(x=>x.Job.ID)
|
|
|
+ .Add(x=>x.Job.JobNumber)
|
|
|
+ .Add(x=>x.Job.Name)
|
|
|
+ .AddDimensionsColumns(x => x.Dimensions)
|
|
|
+ .Add(x => x.CostPrice)
|
|
|
+ .Add(x => x.ForeignCurrencyPrice)
|
|
|
+ ).Rows.FirstOrDefault()?.ToObject<SupplierProduct>();
|
|
|
+
|
|
|
+ if (sp != null)
|
|
|
+ {
|
|
|
+ var poi = CreateItem();
|
|
|
+ poi.Product.ID = sp.Product.ID;
|
|
|
+ poi.Product.Synchronise(sp.Product);
|
|
|
+ poi.Style.ID = sp.Style.ID;
|
|
|
+ poi.Style.Synchronise(sp.Style);
|
|
|
+ poi.Dimensions.CopyFrom(sp.Dimensions);
|
|
|
+ poi.Job.ID = sp.Job.ID;
|
|
|
+ poi.Job.Synchronise(sp.Job);
|
|
|
+ poi.ForeignCurrencyCost = sp.ForeignCurrencyPrice;
|
|
|
+ poi.Cost = sp.CostPrice;
|
|
|
+ result.Add(poi);
|
|
|
+ }
|
|
|
+ else if (pi != null)
|
|
|
+ {
|
|
|
+ var poi = CreateItem();
|
|
|
+ poi.Product.ID = pi.Product.ID;
|
|
|
+ poi.Product.Synchronise(pi.Product);
|
|
|
+ poi.Style.ID = pi.Style.ID;
|
|
|
+ poi.Style.Synchronise(pi.Style);
|
|
|
+ poi.Dimensions.CopyFrom(pi.Dimensions);
|
|
|
+ poi.Cost = pi.NettCost;
|
|
|
+ result.Add(poi);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void DoAdd(bool OpenEditorOnDirectEdit = false)
|
|
|
+ {
|
|
|
+ var dlg = new MultiSelectDialog<SupplierProduct>(
|
|
|
+ new Filter<SupplierProduct>(x => x.SupplierLink.ID).IsEqualTo(Item.SupplierLink.ID),
|
|
|
+ Columns.None<SupplierProduct>().Add(x => x.ID)
|
|
|
+ .Add(x => x.Product.ID)
|
|
|
+ .Add(x => x.Product.Code)
|
|
|
+ .Add(x => x.Product.Name)
|
|
|
+ .Add(x => x.Product.TaxCode.ID)
|
|
|
+ .Add(x => x.Product.TaxCode.Code)
|
|
|
+ .Add(x => x.Product.TaxCode.Description)
|
|
|
+ .Add(x => x.Product.TaxCode.Rate)
|
|
|
+ .Add(x => x.Product.PurchaseGL.ID)
|
|
|
+ .Add(x => x.Product.PurchaseGL.Code)
|
|
|
+ .Add(x => x.Product.PurchaseGL.Description)
|
|
|
+ .Add(x => x.Product.CostCentre.ID)
|
|
|
+ .Add(x => x.Product.CostCentre.Code)
|
|
|
+ .Add(x => x.Product.CostCentre.Description)
|
|
|
+ .Add(x => x.Style.ID)
|
|
|
+ .Add(x => x.Style.Code)
|
|
|
+ .Add(x => x.Style.Description)
|
|
|
+ .Add(x=>x.Job.ID)
|
|
|
+ .Add(x=>x.Job.JobNumber)
|
|
|
+ .Add(x=>x.Job.Name)
|
|
|
+ .AddDimensionsColumns(x => x.Dimensions)
|
|
|
+ .Add(x => x.CostPrice)
|
|
|
+ .Add(x => x.ForeignCurrencyPrice),
|
|
|
+ false
|
|
|
+ );
|
|
|
+ if (dlg.ShowDialog() == true)
|
|
|
+ {
|
|
|
+ CreateItems(() =>
|
|
|
+ {
|
|
|
+ var result = new List<PurchaseOrderItem>();
|
|
|
+ var sp = dlg.Data().Rows.FirstOrDefault()?.ToObject<SupplierProduct>();
|
|
|
+ if (sp != null)
|
|
|
+ {
|
|
|
+ var poi = CreateItem();
|
|
|
+ poi.Product.ID = sp.Product.ID;
|
|
|
+ poi.Product.Synchronise(sp.Product);
|
|
|
+ poi.Style.ID = sp.Style.ID;
|
|
|
+ poi.Style.Synchronise(sp.Style);
|
|
|
+ poi.Dimensions.CopyFrom(sp.Dimensions);
|
|
|
+ poi.Job.ID = sp.Job.ID;
|
|
|
+ poi.Job.Synchronise(sp.Job);
|
|
|
+ poi.ForeignCurrencyCost = sp.ForeignCurrencyPrice;
|
|
|
+ poi.Cost = sp.CostPrice;
|
|
|
+ result.Add(poi);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
protected override void CustomiseEditor(PurchaseOrderItem[] items, DynamicGridColumn column, BaseEditor editor)
|
|
|
{
|