| | |
| | | using System.IO; |
| | | using HMI.Base; |
| | | using HMI.Core.Entity; |
| | | using HMI.Core.Util; |
| | | using HMI.ParameterManage.Model; |
| | | using HMI.UI.Util; |
| | | using System.Linq; |
| | | using System.Windows; |
| | | using System.Windows.Controls; |
| | | using System.Windows.Markup; |
| | | using HMI.Base; |
| | | using HMI.Core.Util; |
| | | using HMI.ParameterManage.Entity; |
| | | using HMI.ParameterManage.Model; |
| | | using HMI.UI.Util; |
| | | |
| | | namespace HMI.ParameterManage |
| | | { |
| | |
| | | case "addBtn": |
| | | OpenProductDialog(null); |
| | | break; |
| | | case "refreshBtn": |
| | | Model.LoadProducts(); |
| | | break; |
| | | case "editProductBtn": |
| | | OpenProductDialog((ProductData)btn.DataContext); |
| | | break; |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private void OpenProductDialog(ProductData data) |
| | | { |
| | | var win = new ProductModal(Model) |
| | | { |
| | | Title = data == null ? "新增产品" : "编辑产品", |
| | | Title = data == null ? this.lang("Pm.Product.Add") : this.lang("Pm.Product.Edit"), |
| | | Owner = Window.GetWindow(this), |
| | | }; |
| | | if (win.Open(data ?? new ProductData()) == true) |
| | | if (win.Open(data ?? new ProductData(), data != null) == true) |
| | | { |
| | | Model.LoadProducts(); |
| | | } |
| | |
| | | { |
| | | if (Model.SelectedProduct == null) |
| | | { |
| | | ToastHelper.Warning(Window.GetWindow(this), "请先选择一项产品"); |
| | | ToastHelper.Warning(Window.GetWindow(this), this.lang("Pm.PleaseSelectProduct")); |
| | | return; |
| | | } |
| | | var win = new ParameterModal(Model) |
| | | { |
| | | Title = data == null ? "新增参数" : "编辑参数", |
| | | Title = data == null ? this.lang("Pm.Parameter.Add") : this.lang("Pm.Parameter.Edit"), |
| | | Owner = Window.GetWindow(this), |
| | | }; |
| | | if (win.Open(data ?? new ParameterData { ProductName = Model.SelectedProduct.Name }) == true) |
| | | if (win.Open(Model.SelectedProduct.Name, data ?? new ParameterData { ProductName = Model.SelectedProduct.Name }, Model.groups) == true) |
| | | { |
| | | Model.LoadParameters(); |
| | | } |
| | |
| | | |
| | | private void TryDeleteProduct(ProductData data) |
| | | { |
| | | if (MsgBoxHelper.WarnMessage(Window.GetWindow(this), $"确定要删除产品[{data.Name}]吗?该操作无法撤销") |
| | | if (MsgBoxHelper.WarnMessage(Window.GetWindow(this), this.lang("HMI.MakeSureDeleteSingle", data.Name)) |
| | | == MessageBoxResult.OK) |
| | | { |
| | | Model.DeleteProduct(data); |
| | |
| | | var temp = Model.Products.Where(p => p.IsSelected).Count(); |
| | | if (temp <= 0) |
| | | { |
| | | this.Warning("请选择要删除的产品"); |
| | | this.Warning(this.lang("HMI.NoDeleteData")); |
| | | return; |
| | | } |
| | | if (MsgBoxHelper.WarnMessage(Window.GetWindow(this), $"确定要删除选中的[{temp}]条产品吗?该操作无法撤销") |
| | | if (MsgBoxHelper.WarnMessage(Window.GetWindow(this), this.lang("HMI.MakeSureDeletes", temp)) |
| | | == MessageBoxResult.OK) |
| | | { |
| | | Model.DeleteProducts(); |
| | |
| | | |
| | | private void TryDeleteParameter(ParameterData data) |
| | | { |
| | | if (MsgBoxHelper.WarnMessage(Window.GetWindow(this), $"确定要删除参数[{data.Name}]吗?该操作无法撤销") == MessageBoxResult.OK) |
| | | if (MsgBoxHelper.WarnMessage(Window.GetWindow(this), this.lang("HMI.MakeSureDeleteSingle", data.Name)) == MessageBoxResult.OK) |
| | | { |
| | | Model.DeleteParameter(data); |
| | | Model.LoadParameters(); |
| | |
| | | var temp = Model.Parameters.Where(p => p.IsSelected).Count(); |
| | | if (temp <= 0) |
| | | { |
| | | this.Warning("请选择要删除的参数"); |
| | | this.Warning(this.lang("HMI.NoDeleteData")); |
| | | return; |
| | | } |
| | | if (MsgBoxHelper.WarnMessage(Window.GetWindow(this), $"确定要删除选中的[{temp}]条参数吗?该操作无法撤销") |
| | | if (MsgBoxHelper.WarnMessage(Window.GetWindow(this), this.lang("HMI.MakeSureDeletes", temp)) |
| | | == MessageBoxResult.OK) |
| | | { |
| | | Model.DeleteParameters(); |