|
@@ -1,6 +1,7 @@
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
+using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Media.Imaging;
|
|
using Comal.Classes;
|
|
using Comal.Classes;
|
|
@@ -10,226 +11,265 @@ using InABox.DynamicGrid;
|
|
using InABox.Wpf;
|
|
using InABox.Wpf;
|
|
using InABox.WPF;
|
|
using InABox.WPF;
|
|
|
|
|
|
-namespace PRSDesktop
|
|
|
|
|
|
+namespace PRSDesktop;
|
|
|
|
+
|
|
|
|
+public class SupplierBillLineGrid : DynamicOneToManyGrid<Bill, BillLine>
|
|
{
|
|
{
|
|
- public class SupplierBillLineGrid : DynamicOneToManyGrid<Bill, BillLine>
|
|
|
|
|
|
+ private static readonly BitmapImage pencil = InABox.Wpf.Resources.pencil.AsBitmapImage();
|
|
|
|
+
|
|
|
|
+ public SupplierBillLineGrid()
|
|
{
|
|
{
|
|
- private static readonly BitmapImage pencil = InABox.Wpf.Resources.pencil.AsBitmapImage();
|
|
|
|
|
|
|
|
- public SupplierBillLineGrid()
|
|
|
|
|
|
+ AddButton("Import", PRSDesktop.Resources.purchase.AsBitmapImage(), ImportPOLines);
|
|
|
|
+
|
|
|
|
+ HiddenColumns.Add(x => x.TaxCode.ID);
|
|
|
|
+ HiddenColumns.Add(x => x.TaxCode.Code);
|
|
|
|
+ HiddenColumns.Add(x => x.TaxCode.Description);
|
|
|
|
+ HiddenColumns.Add(x => x.TaxCode.Rate);
|
|
|
|
+ HiddenColumns.Add(x => x.TaxRate);
|
|
|
|
+ HiddenColumns.Add(x => x.ExTax);
|
|
|
|
+ HiddenColumns.Add(x => x.Tax);
|
|
|
|
+ HiddenColumns.Add(x => x.IncTax);
|
|
|
|
+ HiddenColumns.Add(x => x.Description);
|
|
|
|
+
|
|
|
|
+ HiddenColumns.Add(x=>x.OrderItem.PurchaseOrderLink.PONumber);
|
|
|
|
+ HiddenColumns.Add(x=>x.OrderItem.Product.Code);
|
|
|
|
+ HiddenColumns.Add(x=>x.OrderItem.Description);
|
|
|
|
+ HiddenColumns.Add(x=>x.OrderItem.Qty);
|
|
|
|
+ HiddenColumns.Add(x=>x.OrderItem.ExTax);
|
|
|
|
+ HiddenColumns.Add(x=>x.OrderItem.TaxCode.ID);
|
|
|
|
+ HiddenColumns.Add(x=>x.OrderItem.Tax);
|
|
|
|
+ HiddenColumns.Add(x=>x.OrderItem.IncTax);
|
|
|
|
+
|
|
|
|
+ ActionColumns.Add(new DynamicImageColumn(pencil, BillLineEdit_Click));
|
|
|
|
+ }
|
|
|
|
+ protected override void DoReconfigure(FluentList<DynamicGridOption> options)
|
|
|
|
+ {
|
|
|
|
+ base.DoReconfigure(options);
|
|
|
|
+ options
|
|
|
|
+ .BeginUpdate()
|
|
|
|
+ .Clear()
|
|
|
|
+ .Add(DynamicGridOption.AddRows)
|
|
|
|
+ .Add(DynamicGridOption.DeleteRows)
|
|
|
|
+ .Add(DynamicGridOption.SelectColumns)
|
|
|
|
+ .Add(DynamicGridOption.DirectEdit)
|
|
|
|
+ .Add(DynamicGridOption.DragTarget)
|
|
|
|
+ .EndUpdate();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public override void Load(object item, Func<Type, CoreTable?>? PageDataHandler)
|
|
|
|
+ {
|
|
|
|
+ Refresh(true, false);
|
|
|
|
+ base.Load(item, type =>
|
|
{
|
|
{
|
|
|
|
+ var data = PageDataHandler?.Invoke(type);
|
|
|
|
+ if(data is null && type == typeof(BillLine))
|
|
|
|
+ {
|
|
|
|
+ data = new Client<BillLine>().Query(
|
|
|
|
+ new Filter<BillLine>(x => x.BillLink.ID).IsEqualTo(Item.ID),
|
|
|
|
+ DynamicGridUtils.LoadEditorColumns(DataColumns()),
|
|
|
|
+ LookupFactory.DefineSort<BillLine>());
|
|
|
|
+ }
|
|
|
|
+ return data;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
- AddButton("Import", PRSDesktop.Resources.purchase.AsBitmapImage(), ImportPOLines);
|
|
|
|
-
|
|
|
|
- HiddenColumns.Add(x => x.TaxCode.ID);
|
|
|
|
- HiddenColumns.Add(x => x.TaxCode.Code);
|
|
|
|
- HiddenColumns.Add(x => x.TaxCode.Description);
|
|
|
|
- HiddenColumns.Add(x => x.TaxCode.Rate);
|
|
|
|
- HiddenColumns.Add(x => x.TaxRate);
|
|
|
|
- HiddenColumns.Add(x => x.ExTax);
|
|
|
|
- HiddenColumns.Add(x => x.Tax);
|
|
|
|
- HiddenColumns.Add(x => x.IncTax);
|
|
|
|
- HiddenColumns.Add(x => x.Description);
|
|
|
|
-
|
|
|
|
- HiddenColumns.Add(x=>x.OrderItem.PurchaseOrderLink.PONumber);
|
|
|
|
- HiddenColumns.Add(x=>x.OrderItem.Product.Code);
|
|
|
|
- HiddenColumns.Add(x=>x.OrderItem.Description);
|
|
|
|
- HiddenColumns.Add(x=>x.OrderItem.Qty);
|
|
|
|
- HiddenColumns.Add(x=>x.OrderItem.ExTax);
|
|
|
|
- HiddenColumns.Add(x=>x.OrderItem.TaxCode.ID);
|
|
|
|
- HiddenColumns.Add(x=>x.OrderItem.Tax);
|
|
|
|
- HiddenColumns.Add(x=>x.OrderItem.IncTax);
|
|
|
|
-
|
|
|
|
- ActionColumns.Add(new DynamicImageColumn(pencil, BillLineEdit_Click));
|
|
|
|
|
|
+ private bool BillLineEdit_Click(CoreRow? row)
|
|
|
|
+ {
|
|
|
|
+ if(row is null)
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
- protected override void DoReconfigure(FluentList<DynamicGridOption> options)
|
|
|
|
|
|
+ var item = LoadItem(row);
|
|
|
|
+ if (EditItems(new BillLine[] { item }))
|
|
{
|
|
{
|
|
- base.DoReconfigure(options);
|
|
|
|
- options
|
|
|
|
- .BeginUpdate()
|
|
|
|
- .Clear()
|
|
|
|
- .Add(DynamicGridOption.AddRows)
|
|
|
|
- .Add(DynamicGridOption.DeleteRows)
|
|
|
|
- .Add(DynamicGridOption.SelectColumns)
|
|
|
|
- .Add(DynamicGridOption.DirectEdit)
|
|
|
|
- .EndUpdate();
|
|
|
|
|
|
+ SaveItem(item);
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
|
|
- public override void Load(object item, Func<Type, CoreTable?>? PageDataHandler)
|
|
|
|
|
|
+ public override void ConfigureColumns(DynamicGridColumns columns)
|
|
|
|
+ {
|
|
|
|
+ base.ConfigureColumns(columns);
|
|
|
|
+
|
|
|
|
+ // var orderItemColumn = columns.Find(x => x.ColumnName == $"{nameof(BillLine.OrderItem)}.{nameof(BillLine.OrderItem.ID)}");
|
|
|
|
+ // if (orderItemColumn != null)
|
|
|
|
+ // {
|
|
|
|
+ // orderItemColumn.Editor.Editable = Editable.DisabledOnDirectEdit;
|
|
|
|
+ // }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private bool ImportPOLines(Button arg1, CoreRow[] arg2)
|
|
|
|
+ {
|
|
|
|
+ MultiSelectDialog<PurchaseOrderItem> dlg = new MultiSelectDialog<PurchaseOrderItem>(
|
|
|
|
+ new Filter<PurchaseOrderItem>(x => x.PurchaseOrderLink.SupplierLink.ID).IsEqualTo(Item.SupplierLink.ID)
|
|
|
|
+ .And(x => x.BillLine.ID).IsEqualTo(Guid.Empty),
|
|
|
|
+ new Columns<PurchaseOrderItem>
|
|
|
|
+ (
|
|
|
|
+ x => x.ID,
|
|
|
|
+ x => x.Description,
|
|
|
|
+ x => x.Product.Code,
|
|
|
|
+ x => x.ReceivedDate,
|
|
|
|
+ x => x.Consignment.Number,
|
|
|
|
+ x => x.PurchaseOrderLink.PONumber,
|
|
|
|
+ x => x.PurchaseOrderLink.ID,
|
|
|
|
+ x => x.Consignment.ID,
|
|
|
|
+ x => x.Qty,
|
|
|
|
+ x => x.ExTax,
|
|
|
|
+ x => x.TaxRate,
|
|
|
|
+ x => x.IncTax
|
|
|
|
+ ));
|
|
|
|
+ if (dlg.ShowDialog() == true)
|
|
{
|
|
{
|
|
- Refresh(true, false);
|
|
|
|
- base.Load(item, type =>
|
|
|
|
|
|
+ var imports = dlg.Items();
|
|
|
|
+ var poids = imports.Select(x => x.PurchaseOrderLink.ID).Distinct().ToArray();
|
|
|
|
+ var consids = imports.Select(x => x.Consignment.ID).Distinct().ToArray();
|
|
|
|
+ MultiQuery query = new MultiQuery();
|
|
|
|
+
|
|
|
|
+ query.Add<PurchaseOrderItem>(
|
|
|
|
+ new Filter<PurchaseOrderItem>(x => x.ID).InList(dlg.IDs()),
|
|
|
|
+ new Columns<PurchaseOrderItem>(x => x.ID)
|
|
|
|
+ .Add(x => x.Description)
|
|
|
|
+ .Add(x => x.TaxCode.ID)
|
|
|
|
+ .Add(x => x.TaxCode.Code)
|
|
|
|
+ .Add(x => x.TaxCode.Description)
|
|
|
|
+ .Add(x => x.TaxCode.Rate)
|
|
|
|
+ .Add(x => x.Qty)
|
|
|
|
+ .Add(x => x.TaxRate)
|
|
|
|
+ .Add(x => x.ExTax)
|
|
|
|
+ .Add(x => x.Tax)
|
|
|
|
+ .Add(x => x.IncTax)
|
|
|
|
+ .Add(x => x.Created)
|
|
|
|
+ .Add(x => x.PurchaseOrderLink.ID)
|
|
|
|
+ .Add(x => x.PurchaseOrderLink.PONumber)
|
|
|
|
+ .Add(x => x.Consignment.ID)
|
|
|
|
+ .Add(x => x.Product.ID)
|
|
|
|
+ .Add(x => x.Product.Code)
|
|
|
|
+ .Add(x => x.Product.Name)
|
|
|
|
+ .Add(x => x.PurchaseGL.ID)
|
|
|
|
+ .Add(x => x.CostCentre.ID)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ query.Add<PurchaseOrderDocument>(
|
|
|
|
+ new Filter<PurchaseOrderDocument>(x=>x.EntityLink.ID).InList(poids));
|
|
|
|
+
|
|
|
|
+ query.Add<ConsignmentDocument>(
|
|
|
|
+ new Filter<ConsignmentDocument>(x => x.EntityLink.ID).InList(consids));
|
|
|
|
+
|
|
|
|
+ query.Query();
|
|
|
|
+
|
|
|
|
+ var items = query.Get<PurchaseOrderItem>();
|
|
|
|
+ foreach (var row in items.Rows)
|
|
{
|
|
{
|
|
- var data = PageDataHandler?.Invoke(type);
|
|
|
|
- if(data is null && type == typeof(BillLine))
|
|
|
|
|
|
+ var line = CreateItem();
|
|
|
|
+
|
|
|
|
+ line.OrderItem.ID = row.Get<PurchaseOrderItem, Guid>(x => x.ID);
|
|
|
|
+ line.OrderItem.PurchaseOrderLink.ID = row.Get<PurchaseOrderItem, Guid>(x => x.PurchaseOrderLink.ID);
|
|
|
|
+ line.OrderItem.PurchaseOrderLink.PONumber = row.Get<PurchaseOrderItem, String>(x => x.PurchaseOrderLink.PONumber);
|
|
|
|
+
|
|
|
|
+ line.OrderItem.Product.ID = row.Get<PurchaseOrderItem, Guid>(x => x.Product.ID);
|
|
|
|
+ line.OrderItem.Product.Code = row.Get<PurchaseOrderItem, string>(x => x.Product.Code);
|
|
|
|
+ line.OrderItem.Product.Name = row.Get<PurchaseOrderItem, string>(x => x.Product.Name);
|
|
|
|
+
|
|
|
|
+ line.OrderItem.Description = row.Get<PurchaseOrderItem, string>(x => x.Description);
|
|
|
|
+ line.OrderItem.Qty = row.Get<PurchaseOrderItem, double>(x => x.Qty);
|
|
|
|
+ line.OrderItem.ExTax = row.Get<PurchaseOrderItem, double>(x => x.ExTax);
|
|
|
|
+ line.OrderItem.TaxCode.ID = row.Get<PurchaseOrderItem, Guid>(x => x.TaxCode.ID);
|
|
|
|
+ line.OrderItem.TaxCode.Code = row.Get<PurchaseOrderItem, string>(x => x.TaxCode.Code);
|
|
|
|
+ line.OrderItem.TaxCode.Description = row.Get<PurchaseOrderItem, string>(x => x.TaxCode.Description);
|
|
|
|
+ line.OrderItem.TaxCode.Rate = row.Get<PurchaseOrderItem, double>(x => x.TaxCode.Rate);
|
|
|
|
+ line.OrderItem.PurchaseGL.ID = row.Get<PurchaseOrderItem, Guid>(x => x.PurchaseGL.ID);
|
|
|
|
+ line.OrderItem.CostCentre.ID = row.Get<PurchaseOrderItem, Guid>(x => x.CostCentre.ID);
|
|
|
|
+
|
|
|
|
+ line.ExTax = row.Get<PurchaseOrderItem, double>(x => x.ExTax);
|
|
|
|
+ line.TaxCode.ID = row.Get<PurchaseOrderItem, Guid>(x => x.TaxCode.ID);
|
|
|
|
+ line.TaxCode.Code = row.Get<PurchaseOrderItem, string>(x => x.TaxCode.Code);
|
|
|
|
+ line.TaxCode.Description = row.Get<PurchaseOrderItem, string>(x => x.TaxCode.Description);
|
|
|
|
+ line.TaxCode.Rate = row.Get<PurchaseOrderItem, double>(x => x.TaxCode.Rate);
|
|
|
|
+ line.TaxRate = row.Get<PurchaseOrderItem, double>(x => x.TaxRate);
|
|
|
|
+ line.Tax = row.Get<PurchaseOrderItem, double>(x => x.Tax);
|
|
|
|
+ line.IncTax = row.Get<PurchaseOrderItem, double>(x => x.IncTax);
|
|
|
|
+ line.PurchaseGL.ID = row.Get<PurchaseOrderItem, Guid>(x => x.PurchaseGL.ID);
|
|
|
|
+ line.CostCentre.ID = row.Get<PurchaseOrderItem, Guid>(x => x.CostCentre.ID);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Items.Add(line);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var docpage = EditorGrid.Pages.FirstOrDefault(x=>x is BillDocumentGrid) as BillDocumentGrid;
|
|
|
|
+ if (!docpage.Ready)
|
|
|
|
+ docpage.Load(Item,null);
|
|
|
|
+
|
|
|
|
+ if (docpage != null)
|
|
|
|
+ {
|
|
|
|
+ var podocs = query.Get<PurchaseOrderDocument>();
|
|
|
|
+ foreach (var row in podocs.Rows)
|
|
{
|
|
{
|
|
- data = new Client<BillLine>().Query(
|
|
|
|
- new Filter<BillLine>(x => x.BillLink.ID).IsEqualTo(Item.ID),
|
|
|
|
- DynamicGridUtils.LoadEditorColumns(DataColumns()),
|
|
|
|
- LookupFactory.DefineSort<BillLine>());
|
|
|
|
|
|
+ var podoc = new BillDocument();
|
|
|
|
+ podoc.EntityLink.ID = Item.ID;
|
|
|
|
+ podoc.DocumentLink.ID = row.Get<PurchaseOrderDocument, Guid>(x => x.DocumentLink.ID);
|
|
|
|
+ podoc.DocumentLink.FileName = row.Get<PurchaseOrderDocument, String>(x => x.DocumentLink.FileName);
|
|
|
|
+ podoc.Thumbnail = row.Get<PurchaseOrderDocument, byte[]>(x => x.Thumbnail);
|
|
|
|
+ docpage.SaveItem(podoc);
|
|
}
|
|
}
|
|
- return data;
|
|
|
|
- });
|
|
|
|
|
|
+
|
|
|
|
+ var consdocs = query.Get<ConsignmentDocument>();
|
|
|
|
+ foreach (var row in consdocs.Rows)
|
|
|
|
+ {
|
|
|
|
+ var consdoc = new BillDocument();
|
|
|
|
+ consdoc.EntityLink.ID = Item.ID;
|
|
|
|
+ consdoc.DocumentLink.ID = row.Get<ConsignmentDocument, Guid>(x => x.DocumentLink.ID);
|
|
|
|
+ consdoc.DocumentLink.FileName = row.Get<ConsignmentDocument, String>(x => x.DocumentLink.FileName);
|
|
|
|
+ consdoc.Thumbnail = row.Get<ConsignmentDocument, byte[]>(x => x.Thumbnail);
|
|
|
|
+ docpage.SaveItem(consdoc);
|
|
|
|
+ }
|
|
|
|
+ docpage.Refresh(false,true);
|
|
|
|
+ }
|
|
|
|
+ DoChanged();
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected override void HandleDragOver(object sender, DragEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ base.HandleDragOver(sender, e);
|
|
|
|
|
|
- private bool BillLineEdit_Click(CoreRow? row)
|
|
|
|
|
|
+ if (e.Data.GetDataPresent(typeof(Product)))
|
|
{
|
|
{
|
|
- if(row is null)
|
|
|
|
- {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- var item = LoadItem(row);
|
|
|
|
- if (EditItems(new BillLine[] { item }))
|
|
|
|
|
|
+ if (e.Data.GetData(typeof(Product)) is Product product)
|
|
{
|
|
{
|
|
- SaveItem(item);
|
|
|
|
- return true;
|
|
|
|
|
|
+ if (!Security.CanEdit<Bill>() || !Security.CanEdit<BillLine>())
|
|
|
|
+ {
|
|
|
|
+ e.Effects = DragDropEffects.None;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- return false;
|
|
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- public override void ConfigureColumns(DynamicGridColumns columns)
|
|
|
|
- {
|
|
|
|
- base.ConfigureColumns(columns);
|
|
|
|
-
|
|
|
|
- // var orderItemColumn = columns.Find(x => x.ColumnName == $"{nameof(BillLine.OrderItem)}.{nameof(BillLine.OrderItem.ID)}");
|
|
|
|
- // if (orderItemColumn != null)
|
|
|
|
- // {
|
|
|
|
- // orderItemColumn.Editor.Editable = Editable.DisabledOnDirectEdit;
|
|
|
|
- // }
|
|
|
|
- }
|
|
|
|
|
|
+ protected override void HandleDragDrop(object sender, DragEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ base.HandleDragDrop(sender, e);
|
|
|
|
|
|
- private bool ImportPOLines(Button arg1, CoreRow[] arg2)
|
|
|
|
|
|
+ if (e.Data.GetDataPresent(typeof(Product)))
|
|
{
|
|
{
|
|
- MultiSelectDialog<PurchaseOrderItem> dlg = new MultiSelectDialog<PurchaseOrderItem>(
|
|
|
|
- new Filter<PurchaseOrderItem>(x => x.PurchaseOrderLink.SupplierLink.ID).IsEqualTo(Item.SupplierLink.ID)
|
|
|
|
- .And(x => x.BillLine.ID).IsEqualTo(Guid.Empty),
|
|
|
|
- new Columns<PurchaseOrderItem>
|
|
|
|
- (
|
|
|
|
- x => x.ID,
|
|
|
|
- x => x.Description,
|
|
|
|
- x => x.Product.Code,
|
|
|
|
- x => x.ReceivedDate,
|
|
|
|
- x => x.Consignment.Number,
|
|
|
|
- x => x.PurchaseOrderLink.PONumber,
|
|
|
|
- x => x.PurchaseOrderLink.ID,
|
|
|
|
- x => x.Consignment.ID,
|
|
|
|
- x => x.Qty,
|
|
|
|
- x => x.ExTax,
|
|
|
|
- x => x.TaxRate,
|
|
|
|
- x => x.IncTax
|
|
|
|
- ));
|
|
|
|
- if (dlg.ShowDialog() == true)
|
|
|
|
|
|
+ if (e.Data.GetData(typeof(Product)) is Product product)
|
|
{
|
|
{
|
|
- var imports = dlg.Items();
|
|
|
|
- var poids = imports.Select(x => x.PurchaseOrderLink.ID).Distinct().ToArray();
|
|
|
|
- var consids = imports.Select(x => x.Consignment.ID).Distinct().ToArray();
|
|
|
|
- MultiQuery query = new MultiQuery();
|
|
|
|
-
|
|
|
|
- query.Add<PurchaseOrderItem>(
|
|
|
|
- new Filter<PurchaseOrderItem>(x => x.ID).InList(dlg.IDs()),
|
|
|
|
- new Columns<PurchaseOrderItem>(x => x.ID)
|
|
|
|
- .Add(x => x.Description)
|
|
|
|
- .Add(x => x.TaxCode.ID)
|
|
|
|
- .Add(x => x.TaxCode.Code)
|
|
|
|
- .Add(x => x.TaxCode.Description)
|
|
|
|
- .Add(x => x.TaxCode.Rate)
|
|
|
|
- .Add(x => x.Qty)
|
|
|
|
- .Add(x => x.TaxRate)
|
|
|
|
- .Add(x => x.ExTax)
|
|
|
|
- .Add(x => x.Tax)
|
|
|
|
- .Add(x => x.IncTax)
|
|
|
|
- .Add(x => x.Created)
|
|
|
|
- .Add(x => x.PurchaseOrderLink.ID)
|
|
|
|
- .Add(x => x.PurchaseOrderLink.PONumber)
|
|
|
|
- .Add(x => x.Consignment.ID)
|
|
|
|
- .Add(x => x.Product.ID)
|
|
|
|
- .Add(x => x.Product.Code)
|
|
|
|
- .Add(x => x.Product.Name)
|
|
|
|
- .Add(x => x.PurchaseGL.ID)
|
|
|
|
- .Add(x => x.CostCentre.ID)
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- query.Add<PurchaseOrderDocument>(
|
|
|
|
- new Filter<PurchaseOrderDocument>(x=>x.EntityLink.ID).InList(poids));
|
|
|
|
-
|
|
|
|
- query.Add<ConsignmentDocument>(
|
|
|
|
- new Filter<ConsignmentDocument>(x => x.EntityLink.ID).InList(consids));
|
|
|
|
-
|
|
|
|
- query.Query();
|
|
|
|
-
|
|
|
|
- var items = query.Get<PurchaseOrderItem>();
|
|
|
|
- foreach (var row in items.Rows)
|
|
|
|
|
|
+ if (Security.CanEdit<Bill>() && Security.CanEdit<BillLine>())
|
|
{
|
|
{
|
|
- var line = CreateItem();
|
|
|
|
-
|
|
|
|
- line.OrderItem.ID = row.Get<PurchaseOrderItem, Guid>(x => x.ID);
|
|
|
|
- line.OrderItem.PurchaseOrderLink.ID = row.Get<PurchaseOrderItem, Guid>(x => x.PurchaseOrderLink.ID);
|
|
|
|
- line.OrderItem.PurchaseOrderLink.PONumber = row.Get<PurchaseOrderItem, String>(x => x.PurchaseOrderLink.PONumber);
|
|
|
|
-
|
|
|
|
- line.OrderItem.Product.ID = row.Get<PurchaseOrderItem, Guid>(x => x.Product.ID);
|
|
|
|
- line.OrderItem.Product.Code = row.Get<PurchaseOrderItem, string>(x => x.Product.Code);
|
|
|
|
- line.OrderItem.Product.Name = row.Get<PurchaseOrderItem, string>(x => x.Product.Name);
|
|
|
|
-
|
|
|
|
- line.OrderItem.Description = row.Get<PurchaseOrderItem, string>(x => x.Description);
|
|
|
|
- line.OrderItem.Qty = row.Get<PurchaseOrderItem, double>(x => x.Qty);
|
|
|
|
- line.OrderItem.ExTax = row.Get<PurchaseOrderItem, double>(x => x.ExTax);
|
|
|
|
- line.OrderItem.TaxCode.ID = row.Get<PurchaseOrderItem, Guid>(x => x.TaxCode.ID);
|
|
|
|
- line.OrderItem.TaxCode.Code = row.Get<PurchaseOrderItem, string>(x => x.TaxCode.Code);
|
|
|
|
- line.OrderItem.TaxCode.Description = row.Get<PurchaseOrderItem, string>(x => x.TaxCode.Description);
|
|
|
|
- line.OrderItem.TaxCode.Rate = row.Get<PurchaseOrderItem, double>(x => x.TaxCode.Rate);
|
|
|
|
- line.OrderItem.PurchaseGL.ID = row.Get<PurchaseOrderItem, Guid>(x => x.PurchaseGL.ID);
|
|
|
|
- line.OrderItem.CostCentre.ID = row.Get<PurchaseOrderItem, Guid>(x => x.CostCentre.ID);
|
|
|
|
-
|
|
|
|
- line.ExTax = row.Get<PurchaseOrderItem, double>(x => x.ExTax);
|
|
|
|
- line.TaxCode.ID = row.Get<PurchaseOrderItem, Guid>(x => x.TaxCode.ID);
|
|
|
|
- line.TaxCode.Code = row.Get<PurchaseOrderItem, string>(x => x.TaxCode.Code);
|
|
|
|
- line.TaxCode.Description = row.Get<PurchaseOrderItem, string>(x => x.TaxCode.Description);
|
|
|
|
- line.TaxCode.Rate = row.Get<PurchaseOrderItem, double>(x => x.TaxCode.Rate);
|
|
|
|
- line.TaxRate = row.Get<PurchaseOrderItem, double>(x => x.TaxRate);
|
|
|
|
- line.Tax = row.Get<PurchaseOrderItem, double>(x => x.Tax);
|
|
|
|
- line.IncTax = row.Get<PurchaseOrderItem, double>(x => x.IncTax);
|
|
|
|
- line.PurchaseGL.ID = row.Get<PurchaseOrderItem, Guid>(x => x.PurchaseGL.ID);
|
|
|
|
- line.CostCentre.ID = row.Get<PurchaseOrderItem, Guid>(x => x.CostCentre.ID);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- Items.Add(line);
|
|
|
|
- }
|
|
|
|
|
|
+ var item = CreateItem();
|
|
|
|
+ item.Product.ID = product.ID;
|
|
|
|
+ item.Product.Synchronise(product);
|
|
|
|
+ item.Description = product.Name;
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- var docpage = EditorGrid.Pages.FirstOrDefault(x=>x is BillDocumentGrid) as BillDocumentGrid;
|
|
|
|
- if (!docpage.Ready)
|
|
|
|
- docpage.Load(Item,null);
|
|
|
|
-
|
|
|
|
- if (docpage != null)
|
|
|
|
- {
|
|
|
|
- var podocs = query.Get<PurchaseOrderDocument>();
|
|
|
|
- foreach (var row in podocs.Rows)
|
|
|
|
- {
|
|
|
|
- var podoc = new BillDocument();
|
|
|
|
- podoc.EntityLink.ID = Item.ID;
|
|
|
|
- podoc.DocumentLink.ID = row.Get<PurchaseOrderDocument, Guid>(x => x.DocumentLink.ID);
|
|
|
|
- podoc.DocumentLink.FileName = row.Get<PurchaseOrderDocument, String>(x => x.DocumentLink.FileName);
|
|
|
|
- podoc.Thumbnail = row.Get<PurchaseOrderDocument, byte[]>(x => x.Thumbnail);
|
|
|
|
- docpage.SaveItem(podoc);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var consdocs = query.Get<ConsignmentDocument>();
|
|
|
|
- foreach (var row in consdocs.Rows)
|
|
|
|
- {
|
|
|
|
- var consdoc = new BillDocument();
|
|
|
|
- consdoc.EntityLink.ID = Item.ID;
|
|
|
|
- consdoc.DocumentLink.ID = row.Get<ConsignmentDocument, Guid>(x => x.DocumentLink.ID);
|
|
|
|
- consdoc.DocumentLink.FileName = row.Get<ConsignmentDocument, String>(x => x.DocumentLink.FileName);
|
|
|
|
- consdoc.Thumbnail = row.Get<ConsignmentDocument, byte[]>(x => x.Thumbnail);
|
|
|
|
- docpage.SaveItem(consdoc);
|
|
|
|
- }
|
|
|
|
- docpage.Refresh(false,true);
|
|
|
|
|
|
+ SaveItem(item);
|
|
|
|
+ DoChanged();
|
|
|
|
+ Refresh(false, true);
|
|
}
|
|
}
|
|
- DoChanged();
|
|
|
|
- return true;
|
|
|
|
}
|
|
}
|
|
- return false;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|