private void ShowBorder(object sender, MouseButtonEventArgs e, string type) { List <Border> borderList = UIUtils.GetChildObjects <Border>(WrapPanelChannel, "border"); List <TextBox> tbSampleNameList = UIUtils.GetChildObjects <TextBox>(WrapPanelChannel, "textBoxSampleName"); List <TextBox> tbTaskList = UIUtils.GetChildObjects <TextBox>(WrapPanelChannel, "TaskName"); List <TextBox> tbCompanyList = UIUtils.GetChildObjects <TextBox>(WrapPanelChannel, "Company"); List <TextBox> tbSampleidList = UIUtils.GetChildObjects <TextBox>(WrapPanelChannel, "Sampleid"); for (int i = 0; i < borderList.Count; ++i) { if (type.Equals("border")) { if (borderList[i] == sender) { if (!_item.Hole[i].Use) { Global.SelIndex = _SelIndex = i; borderList[i].BorderBrush = _borderBrushSelected; _item.Hole[i].Use = true; _checkNum += 1; } else { borderList[i].BorderBrush = _borderBrushNormal; _item.Hole[i].Use = false; _checkNum -= 1; } break; } } else if (type.Equals("sample")) { if (tbSampleNameList[i] == sender) { if (!_item.Hole[i].Use) { Global.SelIndex = _SelIndex = i; borderList[i].BorderBrush = _borderBrushSelected; _item.Hole[i].Use = true; } if (!Global.sampleName.Equals(string.Empty)) { tbSampleNameList[i].Text = Global.sampleName; Global.sampleName = string.Empty; } //e=null时为扫描枪设备或其他方式录入需要将被检单位自动关联 if (e == null) { if (!Global.CompanyName.Equals(string.Empty)) { tbCompanyList[i].Text = Global.CompanyName; Global.CompanyName = string.Empty; } } break; } } else if (type.Equals("task")) { if (tbTaskList[i] == sender) { if (!_item.Hole[i].Use) { Global.SelIndex = _SelIndex = i; borderList[i].BorderBrush = _borderBrushSelected; _item.Hole[i].Use = true; } if (!Global.TaskName.Equals(string.Empty)) { tbTaskList[i].Text = Global.TaskName; tbTaskList[i].DataContext = Global.TaskCode; Global.TaskName = Global.TaskCode = string.Empty; } if (Global.Other.Length > 0) { tbSampleNameList[i].Text = Global.GetTaskSampleName(); Global.Other = string.Empty; } break; } } else if (type.Equals("company")) { if (tbCompanyList[i] == sender) { if (!_item.Hole[i].Use) { Global.SelIndex = _SelIndex = i; borderList[i].BorderBrush = _borderBrushSelected; _item.Hole[i].Use = true; } if (!Global.CompanyName.Equals(string.Empty)) { tbCompanyList[i].Text = Global.CompanyName; Global.CompanyName = string.Empty; } break; } } else if (type.Equals("getsampleCode")) { if (tbSampleidList[i] == sender) { if (!_item.Hole[i].Use) { Global.SelIndex = _SelIndex = i; borderList[i].BorderBrush = _borderBrushSelected; _item.Hole[i].Use = true; } if (Wisdom.GETSAMPLECODE.Length > 0) { tbSampleidList[i].Text = Wisdom.GETSAMPLECODE; tbCompanyList[i].Text = Global.CompanyName; if (Global.IsSelectSampleName) { DataTable dataTable = _clsTaskOpr.GetSampleByNameOrCode(Global.sampleName, _item.Name, true, true, 1); if (dataTable != null && dataTable.Rows.Count > 0) { tbSampleNameList[i].Text = Global.sampleName; } else { if (MessageBox.Show("当前样品名称在本地数据库中未匹配,是否新建该样品?", "操作提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { AddOrUpdateSample addWindow = new AddOrUpdateSample(); try { addWindow.textBoxName.Text = addWindow._projectName = _item.Name; addWindow._sampleName = Global.sampleName; addWindow.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } tbSampleNameList[i].Text = Global.sampleName; } Global.CompanyName = Global.sampleName = Wisdom.GETSAMPLECODE = string.Empty; } } break; } } } if (_checkNum == Global.deviceHole.HmCount) { this.CheckBoxSelAll.IsChecked = true; } else if (_checkNum < Global.deviceHole.HmCount) { this.CheckBoxSelAll.IsChecked = false; } }
private void ShowBorder(object sender, MouseButtonEventArgs e, string type) { try { List <Border> borderList = UIUtils.GetChildObjects <Border>(WrapPanelItem, "border"); List <TextBox> tbSampleNameList = UIUtils.GetChildObjects <TextBox>(WrapPanelItem, "sampleName"); List <TextBox> tbTaskList = UIUtils.GetChildObjects <TextBox>(WrapPanelItem, "TaskName"); List <TextBox> tbCompanyList = UIUtils.GetChildObjects <TextBox>(WrapPanelItem, "Company"); List <TextBox> tbSampleidList = UIUtils.GetChildObjects <TextBox>(WrapPanelItem, "Sampleid"); if (null == borderList) { return; } for (int i = 0; i < borderList.Count; ++i) { if (type.Equals("border")) { if (sender == borderList[i]) { _SelIndex = i; borderList[i].BorderBrush = _borderBrushSelected; } else { borderList[i].BorderBrush = _borderBrushNormal; } } else if (type.Equals("sample")) { if (sender == tbSampleNameList[i]) { _SelIndex = i; borderList[i].BorderBrush = _borderBrushSelected; if (!Global.sampleName.Equals(string.Empty)) { tbSampleNameList[i].Text = Global.sampleName; Global.sampleName = string.Empty; } //e=null时为扫描枪设备或其他方式录入需要将被检单位自动关联 if (e == null) { if (!Global.CompanyName.Equals(string.Empty)) { tbCompanyList[i].Text = Global.CompanyName; Global.CompanyName = string.Empty; } } } else { borderList[i].BorderBrush = _borderBrushNormal; } } else if (type.Equals("task")) { if (sender == tbTaskList[i]) { _SelIndex = i; borderList[i].BorderBrush = _borderBrushSelected; if (!Global.TaskName.Equals(string.Empty)) { tbTaskList[i].Text = Global.TaskName; tbTaskList[i].DataContext = Global.TaskCode; Global.TaskName = Global.TaskCode = string.Empty; } if (Global.Other.Length > 0) { tbSampleNameList[i].Text = Global.GetTaskSampleName(); Global.Other = string.Empty; } } else { borderList[i].BorderBrush = _borderBrushNormal; } } else if (type.Equals("company")) { if (sender == tbCompanyList[i]) { _SelIndex = i; borderList[i].BorderBrush = _borderBrushSelected; if (!Global.CompanyName.Equals(string.Empty)) { tbCompanyList[i].Text = Global.CompanyName; Global.CompanyName = string.Empty; } } else { borderList[i].BorderBrush = _borderBrushNormal; } } else if (type.Equals("getsampleCode")) { if (sender == tbSampleidList[i]) { _SelIndex = i; borderList[i].BorderBrush = _borderBrushSelected; if (Wisdom.GETSAMPLECODE.Length > 0) { tbSampleidList[i].Text = Wisdom.GETSAMPLECODE; tbCompanyList[i].Text = Global.CompanyName; if (Global.IsSelectSampleName) { DataTable dataTable = _clsTaskOpr.GetSampleByNameOrCode(Global.sampleName, Global.hmItems[_SelIndex].Name, true, true, 1); if (dataTable != null && dataTable.Rows.Count > 0) { tbSampleNameList[i].Text = Global.sampleName; } else { if (MessageBox.Show("当前样品名称在本地数据库中未匹配,是否新建该样品?", "操作提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { AddOrUpdateSample addWindow = new AddOrUpdateSample(); try { addWindow.textBoxName.Text = addWindow._projectName = Global.hmItems[_SelIndex].Name; addWindow._sampleName = Global.sampleName; addWindow.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } tbSampleNameList[i].Text = Global.sampleName; } } Global.CompanyName = Global.sampleName = Wisdom.GETSAMPLECODE; } } else { borderList[i].BorderBrush = _borderBrushNormal; } } } if (e == null) { return; } //双击进行检测 var element = (FrameworkElement)sender; if (e.ClickCount == 1) { var timer = new System.Timers.Timer(500) { AutoReset = false }; timer.Elapsed += new ElapsedEventHandler((o, ex) => element.Dispatcher.Invoke(new Action(() => { var timer2 = (System.Timers.Timer)element.Tag; timer2.Stop(); timer2.Dispose(); //UIElement_Click(element, e); }))); timer.Start(); element.Tag = timer; } if (e.ClickCount == 2) { var timer = element.Tag as System.Timers.Timer; if (timer != null) { timer.Stop(); timer.Dispose(); ShowHmSelChannelWindow(); } } } catch (Exception ex) { MessageBox.Show("异常(ShowBorder):\n" + ex.Message); } }