|
@@ -15,6 +15,7 @@ using System.Windows.Media.Media3D;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using DocumentFormat.OpenXml.Drawing;
|
|
using DocumentFormat.OpenXml.Drawing;
|
|
|
|
+using DocumentFormat.OpenXml.Drawing.Charts;
|
|
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
|
|
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
|
|
using DocumentFormat.OpenXml.Spreadsheet;
|
|
using DocumentFormat.OpenXml.Spreadsheet;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
@@ -26,6 +27,7 @@ using UniformMaterialManagementSystem.Models;
|
|
using UniformMaterialManagementSystem.Services;
|
|
using UniformMaterialManagementSystem.Services;
|
|
using UniformMaterialManagementSystem.Utils;
|
|
using UniformMaterialManagementSystem.Utils;
|
|
using UniformMaterialManagementSystem.Views;
|
|
using UniformMaterialManagementSystem.Views;
|
|
|
|
+using DataTable = System.Data.DataTable;
|
|
using Material = UniformMaterialManagementSystem.Entities.Material;
|
|
using Material = UniformMaterialManagementSystem.Entities.Material;
|
|
|
|
|
|
namespace UniformMaterialManagementSystem.ViewModels
|
|
namespace UniformMaterialManagementSystem.ViewModels
|
|
@@ -162,7 +164,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
page.dpShippedDate.IsEnabled = page.fieldShippedMan.IsEnabled = page.fieldShippedTel.IsEnabled = false;
|
|
page.dpShippedDate.IsEnabled = page.fieldShippedMan.IsEnabled = page.fieldShippedTel.IsEnabled = false;
|
|
|
|
|
|
// 隐藏明细发货和使用按钮
|
|
// 隐藏明细发货和使用按钮
|
|
- page.btnAddDtl.Visibility = page.btnDeleteDtls.Visibility = page.sep2.Visibility = page.btnImportDtl.Visibility = page.btnExportDtl.Visibility = page.btnUseDtl.Visibility = Visibility.Collapsed;
|
|
|
|
|
|
+ page.btnAddDtl.Visibility = page.btnDeleteDtls.Visibility = page.sepDtl.Visibility = page.btnImportDtl.Visibility = page.btnExportDtl.Visibility = page.btnUseDtl.Visibility = Visibility.Collapsed;
|
|
|
|
|
|
foreach (DataGridColumn col in page.fdgDeliveryDetail.Columns)
|
|
foreach (DataGridColumn col in page.fdgDeliveryDetail.Columns)
|
|
{
|
|
{
|
|
@@ -214,7 +216,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
page.dpReceivedDate.IsEnabled = page.fieldReceivedMan.IsEnabled = page.fieldReceivedTel.IsEnabled = page.cbReceivedStatus.IsEnabled = false;
|
|
page.dpReceivedDate.IsEnabled = page.fieldReceivedMan.IsEnabled = page.fieldReceivedTel.IsEnabled = page.cbReceivedStatus.IsEnabled = false;
|
|
|
|
|
|
// 隐藏明细发货和接收按钮
|
|
// 隐藏明细发货和接收按钮
|
|
- page.btnAddDtl.Visibility = page.btnDeleteDtls.Visibility = page.sep2.Visibility = page.btnImportDtl.Visibility = page.btnExportDtl.Visibility = page.btnReceiveDtl.Visibility = Visibility.Collapsed;
|
|
|
|
|
|
+ page.btnAddDtl.Visibility = page.btnDeleteDtls.Visibility = page.sepDtl.Visibility = page.btnImportDtl.Visibility = page.btnExportDtl.Visibility = page.btnReceiveDtl.Visibility = Visibility.Collapsed;
|
|
|
|
|
|
// 隐藏明细表发货字段
|
|
// 隐藏明细表发货字段
|
|
foreach (DataGridColumn col in page.fdgDeliveryDetail.Columns)
|
|
foreach (DataGridColumn col in page.fdgDeliveryDetail.Columns)
|
|
@@ -523,8 +525,73 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
cbReceivedStatus.SelectedItem = "已复核";
|
|
cbReceivedStatus.SelectedItem = "已复核";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [RelayCommand]
|
|
|
|
+ public void ExportThree()
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [RelayCommand]
|
|
|
|
+ public void ExportFour()
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
+ [RelayCommand]
|
|
|
|
+ public void ExportDB()
|
|
|
|
+ {
|
|
|
|
+ // 需要存在 bin\DataBase 目录,且目录下存在一份 .db 文件,需要存在表
|
|
|
|
+
|
|
|
|
+ // 导出主表到 bin\DataBase 目录下的 .db:根据主键判断,存在数据则更新,不存在则插入
|
|
|
|
+ var deliveries = DeliveryReceipts;
|
|
|
|
+ DataBaseUtil.ExportTable(deliveries, "DeliveryReceipts"); // 数据库表名输错会抛出异常,但在本方法里获取不到抛出异常
|
|
|
|
+
|
|
|
|
+ // 必须先导出主表,否则明细插入数据库时报错:Foreign Key constraint failed
|
|
|
|
+ List<DeliveryReceiptDetail> details = new List<DeliveryReceiptDetail>();
|
|
|
|
+ foreach (var delivery in DeliveryReceipts)
|
|
|
|
+ {
|
|
|
|
+ details.AddRange(delivery.DeliveryReceiptDetails);
|
|
|
|
+ }
|
|
|
|
+ DataBaseUtil.ExportTable(details, "DeliveryReceiptDetails");
|
|
|
|
+
|
|
|
|
+ // 将选择的数据导出为加密数据包
|
|
|
|
+ string exportPath = DataBaseUtil.ExportData();
|
|
|
|
+ if (!string.IsNullOrEmpty(exportPath))
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show("导出成功。");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [RelayCommand]
|
|
|
|
+ public async Task ImportDB()
|
|
|
|
+ {
|
|
|
|
+ // 从加密数据包中获取出 .db 放到 path 目录下(bin\DataBase 目录)
|
|
|
|
+ string path = DataBaseUtil.ImportData();
|
|
|
|
+ if (string.IsNullOrEmpty(path)) { return; }
|
|
|
|
+
|
|
|
|
+ // 新增发货单
|
|
|
|
+ var deliveries = DataBaseUtil.QueryAll<DeliveryReceipt>(path, x => x.Include(x => x.DeliveryReceiptDetails))
|
|
|
|
+ .Result;
|
|
|
|
+ await DataBaseUtil.ImportTable("DeliveryReceipts", deliveries);
|
|
|
|
+
|
|
|
|
+ // 新增发货单明细 - 方法一:
|
|
|
|
+ List<DeliveryReceiptDetail> details = new List<DeliveryReceiptDetail>();
|
|
|
|
+ foreach (var d in deliveries)
|
|
|
|
+ {
|
|
|
|
+ details.AddRange(d.DeliveryReceiptDetails);
|
|
|
|
+ }
|
|
|
|
+ await DataBaseUtil.ImportTable("DeliveryReceiptDetails", details);
|
|
|
|
+
|
|
|
|
+ // 新增发货单明细 - 方法二:
|
|
|
|
+ //var drDetails = DataBaseUtil.QueryAll<DeliveryReceiptDetail>(path)
|
|
|
|
+ // .Result;
|
|
|
|
+ //await DataBaseUtil.ImportTable("DeliveryReceiptDetails", drDetails);
|
|
|
|
+
|
|
|
|
+ MessageBox.Show("导入成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
#region 子表事件
|
|
#region 子表事件
|
|
|
|
|
|
public void FdgDeliveryDetail_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
|
|
public void FdgDeliveryDetail_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
|
|
@@ -1380,7 +1447,8 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
}
|
|
}
|
|
|
|
|
|
// 检查发运数量不能超出可发运数量
|
|
// 检查发运数量不能超出可发运数量
|
|
- decimal hasShippedQty = _service.Query(x => x.ProductName.Equals(CurrDeliveryReceipt!.ProductName) && x.ContractNo.Equals(CurrDeliveryReceipt.ContractNo) && !x.Guid.Equals(CurrDeliveryReceipt.Guid)).Select(x => x.ShippedQty)
|
|
|
|
|
|
+ decimal hasShippedQty = _service.Query(x => x.ProductName.Equals(CurrDeliveryReceipt!.ProductName) && x.ContractNo.Equals(CurrDeliveryReceipt.ContractNo) && !x.Guid.Equals(CurrDeliveryReceipt.Guid))
|
|
|
|
+ .Select(x => x.ShippedQty)
|
|
.ToList() // 必须转换为 List<decimal> 才不抛异常
|
|
.ToList() // 必须转换为 List<decimal> 才不抛异常
|
|
.Sum();
|
|
.Sum();
|
|
decimal currQty = CurrDeliveryReceipt.ShippedQty;
|
|
decimal currQty = CurrDeliveryReceipt.ShippedQty;
|