/// <summary>
        /// 查询样品
        /// </summary>
        private void SearchSample()
        {
            this.DataGridRecord.DataContext = null;
            DataTable dataTable = _clsTaskOpr.GetSampleByNameOrCode(textBoxSampleName.Text.Trim(), textBoxName.Text.Trim(), false, _IsFirst, 1);

            if (dataTable != null)
            {
                List <clsttStandardDecide> ItemNames = (List <clsttStandardDecide>)IListDataSet.DataTableToIList <clsttStandardDecide>(dataTable, 1);
                if (ItemNames != null && ItemNames.Count > 0)
                {
                    this.DataGridRecord.DataContext = ItemNames;
                    _IsFirst = false;
                    if (_ItemNames.Count <= 0)
                    {
                        _ItemNames = ItemNames;
                    }
                }
            }
        }
        /// <summary>
        /// 查询样品
        /// </summary>
        private void SearchSampleByName()
        {
            DataTable dataTable = _clsTaskOpr.GetSampleByNameOrCode(textBoxName.Text.Trim(), _projectName, false, _IsFirst, 1);

            if (dataTable != null && dataTable.Rows.Count > 0)
            {
                _Items = (List <clsttStandardDecide>)IListDataSet.DataTableToIList <clsttStandardDecide>(dataTable, 1);
                this.DataGridRecord.ItemsSource = dataTable.DefaultView;
                _IsFirst = false;
            }
            else
            {
                this.DataGridRecord.ItemsSource = null;
            }
        }
예제 #3
0
        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 Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_decide != null && _decide.ID > 0)
                {
                    textBoxFtypeNmae.Text     = _decide.FtypeNmae;
                    textBoxSampleNum.Text     = _decide.SampleNum;
                    textBoxName.Text          = _decide.Name;
                    textBoxItemDes.Text       = _decide.ItemDes;
                    textBoxStandardValue.Text = _decide.StandardValue;
                    textBoxDemarcate.Text     = _decide.Demarcate;
                    textBoxUnit.Text          = _decide.Unit;
                }
                else
                {
                    this.Title = "新增国家检测标准";
                }

                if (_sampleName.Length > 0)
                {
                    this.textBoxFtypeNmae.Text       = _sampleName;
                    this.textBoxFtypeNmae.IsReadOnly = false;
                }

                if (_projectName.Length > 0 && _ItemNames != null && _ItemNames.Count == 0)
                {
                    DataTable dataTable = _clsTaskOpr.GetSampleByNameOrCode(string.Empty, _projectName, true, true, 1);
                    if (dataTable != null && dataTable.Rows.Count > 0)
                    {
                        _ItemNames = (List <clsttStandardDecide>)IListDataSet.DataTableToIList <clsttStandardDecide>(dataTable, 1);
                    }
                }

                if (_ItemNames != null && _ItemNames.Count > 0)
                {
                    SetCheckBox();
                }
                else
                {
                    DataTable dataTable = _clsTaskOpr.GetSampleByNameOrCode(string.Empty, string.Empty, false, false, 1);
                    if (dataTable != null && dataTable.Rows.Count > 0)
                    {
                        _ItemNames = (List <clsttStandardDecide>)IListDataSet.DataTableToIList <clsttStandardDecide>(dataTable, 1);
                        SetCheckBox();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常:" + ex.Message);
            }
            finally
            {
                values.Add(textBoxFtypeNmae.Text.Trim());
                values.Add(textBoxSampleNum.Text.Trim());
                values.Add(textBoxName.Text.Trim());
                values.Add(textBoxItemDes.Text.Trim());
                values.Add(textBoxStandardValue.Text);
                values.Add(textBoxDemarcate.Text);
                values.Add(textBoxUnit.Text);
                _isUpdate = false;
            }
        }
예제 #5
0
        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);
            }
        }