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