|
@@ -78,7 +78,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
|
[ObservableProperty]
|
|
|
private ContractModel? _selectedUnExportContract;
|
|
|
|
|
|
- private string _contactStatus = "Add";//Add:新增 Modify:修改
|
|
|
+ private BillStatus _contactStatus = BillStatus.Add;
|
|
|
|
|
|
#endregion
|
|
|
|
|
@@ -199,7 +199,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
|
|
|
|
ClearInput();
|
|
|
|
|
|
- _contactStatus = "Add";
|
|
|
+ _contactStatus = BillStatus.Add;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -215,7 +215,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
|
//绑定数据源
|
|
|
BindSelectedContractAndDetail();
|
|
|
|
|
|
- _contactStatus = "Modify";
|
|
|
+ _contactStatus = BillStatus.Modify;
|
|
|
}
|
|
|
|
|
|
private void BindSelectedContractAndDetail()
|
|
@@ -231,8 +231,9 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
|
Attachment = SelectedUnExportContract.Attachment;
|
|
|
ApplyAttachment = SelectedUnExportContract.ApplyAttachment;
|
|
|
|
|
|
+ var existDetails = _contractDetailService.QueryNoTracking(x => x.ContractGuid == SelectedUnExportContract.Guid).Include(x=>x.Material).ToList();
|
|
|
ContractDetails.Clear();
|
|
|
- foreach (var detail in SelectedUnExportContract.ContractDetails)
|
|
|
+ foreach (var detail in existDetails)
|
|
|
{
|
|
|
ContractDetails.Add(detail);
|
|
|
}
|
|
@@ -274,7 +275,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if ("Add".Equals(_contactStatus)) //新增
|
|
|
+ if (_contactStatus == BillStatus.Add) //新增
|
|
|
{
|
|
|
var success = SaveContractAndDetail();
|
|
|
if (success == null || !(bool)success) return;
|
|
@@ -286,7 +287,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
|
/* 清空界面数据 */
|
|
|
ClearInput();
|
|
|
}
|
|
|
- else if ("Modify".Equals(_contactStatus)) //修改
|
|
|
+ else if (_contactStatus == BillStatus.Modify) //修改
|
|
|
{
|
|
|
if (SelectedUnExportContract == null)
|
|
|
{
|
|
@@ -702,20 +703,20 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if ("Modify".Equals(_contactStatus))
|
|
|
- {
|
|
|
- //var detail = _contractDetailService?.Get(x => x.Guid == _selectedContractDetail.Guid);
|
|
|
- //if (detail != null)
|
|
|
- //{
|
|
|
- // _contractDetailService?.Delete(_selectedContractDetail);
|
|
|
- //}
|
|
|
-
|
|
|
- var detail = SelectedUnExportContract?.ContractDetails.FirstOrDefault(x => x.Guid == _selectedContractDetail.Guid);
|
|
|
- if (detail != null)
|
|
|
- {
|
|
|
- SelectedUnExportContract?.ContractDetails.Remove(detail);
|
|
|
- }
|
|
|
- }
|
|
|
+ //if ("Modify".Equals(_contactStatus))
|
|
|
+ //{
|
|
|
+ // //var detail = _contractDetailService?.Get(x => x.Guid == _selectedContractDetail.Guid);
|
|
|
+ // //if (detail != null)
|
|
|
+ // //{
|
|
|
+ // // _contractDetailService?.Delete(_selectedContractDetail);
|
|
|
+ // //}
|
|
|
+
|
|
|
+ // var detail = SelectedUnExportContract?.ContractDetails.FirstOrDefault(x => x.Guid == _selectedContractDetail.Guid);
|
|
|
+ // if (detail != null)
|
|
|
+ // {
|
|
|
+ // SelectedUnExportContract?.ContractDetails.Remove(detail);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
|
|
|
ContractDetails.Remove(_selectedContractDetail);
|
|
|
}
|
|
@@ -788,7 +789,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
|
}
|
|
|
|
|
|
/* 校验材料合同号不重复 */
|
|
|
- if ("Add".Equals(_contactStatus))
|
|
|
+ if (_contactStatus == BillStatus.Add)
|
|
|
{
|
|
|
var contract = _contractService.Get(x => x.ContractNo == ContractNo);
|
|
|
if (contract != null)
|
|
@@ -796,7 +797,7 @@ namespace UniformMaterialManagementSystem.ViewModels
|
|
|
errorMessage.Append($"材料合同号【{ContractNo}】已存在,不允许重复录入!\n");
|
|
|
}
|
|
|
}
|
|
|
- else if ("Modify".Equals(_contactStatus))
|
|
|
+ else if (_contactStatus == BillStatus.Modify)
|
|
|
{
|
|
|
var count = _contractService.GetAll(x => x.ContractNo == ContractNo).ToList().Count;
|
|
|
if (count > 1)
|