private void window_Loaded(object sender, RoutedEventArgs e) { StandardDeviceDesModel model = DBControler.UnityIns.GetSSDesTotalRecord(_ID); //无法读取数据,故而直接报错 if (model == null) { BottomPart.Log("读取数据出现错误!", LogMessage.LevelEnum.Error); this.window.Close(); return; } else { //设置信息 EquCode_TB.Text = model.EquCode; EquType_TB.Text = model.EquType; Tem_TB.Text = model.Tem.GetDisplayString(); StartWork_Part.SetMessage(model.StartWork); IdlingWork_Part.SetMessage(model.IdlingWork); IdlingBreak_Part.SetMessage(model.IdlingBreak); ReviseBegin_Part.SetMessage(model.ReviseBegin); ReviseWork_Part.SetMessage(model.ReviseWork); ReviseEnd_Part.SetMessage(model.ReviseEnd); DemWork_Part.SetMessage(model.DemWork); AdjWork_Part.SetMessage(model.AdjWork); HighBreak_Part.SetMessage(model.HighBreak); } }
private void DeviceStartTest(DeviceShortMessageLine line) { //有正在测试的器件,则需要等待 if (NowTestDevice != null) { MessageDialog dialog = new MessageDialog("有器件正在测试,请等待......"); dialog.ShowDialog(); } //如果没有,则可以使用这个器件开始测试 else { if (BottomPart.Unity.IsConnect()) { MessageDialog dialog = new MessageDialog(String.Format("喷油泵型号 : {0}\n是否开始测试?", line.GetEquType()), true); //同意开始测试 if (dialog.ShowDialog().Value) { line.SetTesting(true); NowTestDevice = line; StandardDeviceDesModel model = DBControler.UnityIns.GetSSDesTotalRecord(line.GetID()); model.Id = line.GetID(); //注册接受事件代理 ITrans.UnityIns.Add_GetMeeageDel(this.RecieveData); ITrans.UnityIns.SendMeesageAsync(model.ToString(), ITrans.CommandEnum.REQUIRE, (result, data, commmand) => { this.Dispatcher.Invoke(new Action(() => { if (result) { BottomPart.Log("发送喷油泵标准测试数据成功", LogMessage.LevelEnum.Important); } else { BottomPart.Log("发送喷油泵标准测试数据失败", LogMessage.LevelEnum.Important); } })); }); } } //还未连接,则提示 else { MessageDialog dialog = new MessageDialog("测试台未连接,请先连接测试台"); dialog.ShowDialog(); } } }
private void AddNewDeviceButton_Click() { NewDeviceDialog dialog = new NewDeviceDialog(); dialog.Owner = MainWindow.MWindow; //完成输入工作,成功添加了 if (dialog.ShowDialog().Value) { //获取数据 StandardDeviceDesModel result = dialog.GetResult(); //保存数据 AddNewDeviceDispose(result); } }
/// <summary> /// 接受数据代理 /// </summary> /// <param name="result"></param> /// <param name="data"></param> /// <param name="command"></param> private void RecieveData(bool result, String data, ITrans.CommandEnum command) { this.Dispatcher.Invoke(new Action(() => { //接受到了数据 if (command == ITrans.CommandEnum.RESULT) { HistoryModel model = new HistoryModel(data); if (model.Id == NowTestDevice.GetID()) { int index = -1; StandardDeviceDesModel sdd = DBControler.UnityIns.GetSSDesTotalRecord(NowTestDevice.GetID()); //测试状态取消 NowTestDevice.SetTesting(false); NowTestDevice = null; CombinaPara(sdd, model); BottomPart.Log("接受结果数据成功", LogMessage.LevelEnum.Important); index = DBControler.UnityIns.AddHistoryRecord(model); model.Id = index; if (index > 0) { BottomPart.Log("保存测试数据成功", LogMessage.LevelEnum.Important); MainWindow.MWindow.AddAHistoryLine(model); } else { BottomPart.Log("保存测试数据失败", LogMessage.LevelEnum.Error); } } else { BottomPart.Log("接受结果数据与当前测试数据ID不匹配", LogMessage.LevelEnum.Error); } } })); }
/// <summary> /// 组合参数 /// </summary> /// <param name="sdd"></param> /// <param name="model"></param> public static void CombinaPara(StandardDeviceDesModel sdd, HistoryModel model) { model.AdjWork.S_RotateSpeed = sdd.AdjWork.S_RotateSpeed; model.AdjWork.S_InjectionTime = sdd.AdjWork.S_InjectionTime; model.DemWork.S_RotateSpeed = sdd.DemWork.S_RotateSpeed; model.DemWork.S_InjectionTime = sdd.DemWork.S_InjectionTime; model.EquCode = sdd.EquCode; model.EquType = sdd.EquType; model.HighBreak.S_RotateSpeed = sdd.HighBreak.S_RotateSpeed; model.HighBreak.S_InjectionTime = sdd.HighBreak.S_InjectionTime; model.IdlingBreak.S_RotateSpeed = sdd.IdlingBreak.S_RotateSpeed; model.IdlingBreak.S_InjectionTime = sdd.IdlingBreak.S_InjectionTime; model.IdlingWork.S_RotateSpeed = sdd.IdlingWork.S_RotateSpeed; model.IdlingWork.S_InjectionTime = sdd.IdlingWork.S_InjectionTime; model.ReviseBegin.S_RotateSpeed = sdd.ReviseBegin.S_RotateSpeed; model.ReviseBegin.S_InjectionTime = sdd.ReviseBegin.S_InjectionTime; model.ReviseEnd.S_RotateSpeed = sdd.ReviseEnd.S_RotateSpeed; model.ReviseEnd.S_InjectionTime = sdd.ReviseEnd.S_InjectionTime; model.ReviseWork.S_RotateSpeed = sdd.ReviseWork.S_RotateSpeed; model.ReviseWork.S_InjectionTime = sdd.ReviseWork.S_InjectionTime; model.StartWork.S_RotateSpeed = sdd.StartWork.S_RotateSpeed; model.StartWork.S_InjectionTime = sdd.StartWork.S_InjectionTime; //设置时间 model.HTime = DateTime.Now.ToShortTimeString(); model.HDate = DateTime.Now.ToShortDateString(); //测试数据是否符合要求 model.IsPass = sdd.IsMatchRequire(model); }
private void ETXButton_Click() { DialogBox.SaveFileDialog dialog = new DialogBox.SaveFileDialog(); string filePath; dialog.Title = "选择导出文件保存路径"; dialog.Filter = "xml File(*.xml)|*.xml"; dialog.DefaultExt = "xml"; //如果用户没有添加则自动添加扩展 dialog.AddExtension = true; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //文件路径 filePath = dialog.FileName; StandardDeviceDesModel model = DBControler.UnityIns.GetSSDesTotalRecord(_ID); List <StandardDeviceDesModel> list = new List <StandardDeviceDesModel>(); list.Add(model); SDDAndXml.SaveToXml(filePath, list); BottomPart.Log("导出成功", LogMessage.LevelEnum.Important); } }
private void ModifyButton_Click() { //正在测试,无法删除该器件 if (Testing) { MessageDialog dialogForError = new MessageDialog("该器件信息正在被使用无法修改"); return; } StandardDeviceDesModel model = DBControler.UnityIns.GetSSDesTotalRecord(DeviceID); if (model != null) { NewDeviceDialog newDDialog = new NewDeviceDialog(model, true); if (newDDialog.ShowDialog().Value) { MessageDialog sureDialog = new MessageDialog(String.Format("是否确认修改该标准器件测试信息?\n喷油泵型号 : {0}\n喷油泵编号 : {1}", EquType, EquCode), true); //确认修改 if (sureDialog.ShowDialog().Value) { StandardDeviceDesModel result = newDDialog.GetResult(); result.Id = DeviceID; if (DBControler.UnityIns.ModifySSDesRecord(result)) { BottomPart.Log("成功修改", LogMessage.LevelEnum.Important); } else { BottomPart.Log("修改失败", LogMessage.LevelEnum.Error); } } } } }
/// <summary> /// 预先填装数据 /// </summary> /// <param name="model"></param> /// <param name="isModify">是否是修改数据</param> public NewDeviceDialog(StandardDeviceDesModel model, bool isModify = false) { InitializeComponent(); AdvanceData = model; IsModify = isModify; }
private void SubmitButtonClick() { StandardDeviceDesModel sModel = new StandardDeviceDesModel(); for (int counter = 0; counter < MainContent.Children.Count; counter++) { if (counter <= 8) { if (!((NormalPara_NDD)((Grid)MainContent.Children[counter]).Children[0]).IsValueRight()) { MessageDialog dialog = new MessageDialog("数据填写不正确(红色按钮部分)!"); if (dialog.ShowDialog().Value) { return; } } } else { if (!((SpecialPara_NDD)((Grid)MainContent.Children[counter]).Children[0]).IsValueRight()) { MessageDialog dialog = new MessageDialog("数据填写不正确(红色按钮部分)!"); if (dialog.ShowDialog().Value) { return; } } } //填装数据 switch (counter) { case 0: sModel.StartWork = ((NormalPara_NDD)((Grid)MainContent.Children[counter]).Children[0]).GetModelValue(); break; case 1: sModel.IdlingWork = ((NormalPara_NDD)((Grid)MainContent.Children[counter]).Children[0]).GetModelValue(); break; case 2: sModel.IdlingBreak = ((NormalPara_NDD)((Grid)MainContent.Children[counter]).Children[0]).GetModelValue(); break; case 3: sModel.ReviseBegin = ((NormalPara_NDD)((Grid)MainContent.Children[counter]).Children[0]).GetModelValue(); break; case 4: sModel.ReviseWork = ((NormalPara_NDD)((Grid)MainContent.Children[counter]).Children[0]).GetModelValue(); break; case 5: sModel.ReviseEnd = ((NormalPara_NDD)((Grid)MainContent.Children[counter]).Children[0]).GetModelValue(); break; case 6: sModel.DemWork = ((NormalPara_NDD)((Grid)MainContent.Children[counter]).Children[0]).GetModelValue(); break; case 7: sModel.AdjWork = ((NormalPara_NDD)((Grid)MainContent.Children[counter]).Children[0]).GetModelValue(); break; case 8: sModel.HighBreak = ((NormalPara_NDD)((Grid)MainContent.Children[counter]).Children[0]).GetModelValue(); break; case 9: SpecialPara_NDD sPara = (SpecialPara_NDD)((Grid)MainContent.Children[counter]).Children[0]; sModel.Tem = sPara.GetTem(); sModel.EquCode = sPara.GetEquCode(); sModel.EquType = sPara.GetEquType(); break; } } _Result = sModel; //数据填写正确 this.DialogResult = true; }
private void AddNewDeviceDispose(StandardDeviceDesModel result) { int repetitionId = 0; //查重,如果出现了型号和编号重复 if (DBControler.UnityIns.CheckSSDesRepetition(result.EquCode, result.EquType, out repetitionId)) { //询问是否覆盖数据 MessageDialog mDialog = new MessageDialog("数据库中已存在该器件\n器件型号 : " + result.EquType + "\n是否覆盖数据?", true); //无需覆盖,直接返回 if (!mDialog.ShowDialog().Value) { return; } //覆盖数据 else { result.Id = repetitionId; //寻找相同数据 foreach (DeviceShortMessageLine line in DeviceSMesageContainer.Children) { //出现了重复,则是覆盖了之前的内容 if (line.GetID() == result.Id) { //在这里需要检查该器件是否正在被使用,如果是,则无法修改 if (!line.IsTesting()) { //可以修改数据 //修改成功 if (DBControler.UnityIns.ModifySSDesRecord(result)) { BottomPart.Log(String.Format("覆盖数据成功(<编号:{0}><型号:{1}>)", result.EquCode, result.EquType), LogMessage.LevelEnum.Normal); } //修改失败 else { BottomPart.Log(String.Format("覆盖数据失败(<编号:{0}><型号:{1}>)", result.EquCode, result.EquType), LogMessage.LevelEnum.Error); return; } line.ModifyEquType(result.EquType, result.EquCode); return; } //器件正在被使用,故而无法修改数据 else { MessageDialog errorDialog = new MessageDialog("该器件信息正在被使用,无法修改!"); if (errorDialog.ShowDialog().Value) { return; } } } } } } //没有重复的编号和型号 else { int newId = DBControler.UnityIns.AddSSDesRecord(result); //插入失败 if (newId < 0) { BottomPart.Log(String.Format("添加新器件信息失败"), LogMessage.LevelEnum.Error); return; } else { //保存获得的id result.Id = newId; BottomPart.Log(String.Format("添加新器件信息成功(<编号:{0}><型号:{1}>)", result.EquCode, result.EquType), LogMessage.LevelEnum.Normal); //新添加的器件信息 DeviceShortMessageLine newLine = new DeviceShortMessageLine(result.Id, result.EquType, result.EquCode, DeviceStartTest, (DeviceShortMessageLine which) => { //之前的器件取消选择状态 if (NowSelectDevice != null) { NowSelectDevice.Selected_Cancel(); } NowSelectDevice = which; }); DeviceSMesageContainer.Children.Add(newLine); } } }