Example #1
0
 public void ButtonNext_Click(object sender, RoutedEventArgs e)
 {
     // 将数据保存到文件
     try
     {
         if (Check())
         {
             if (null == _item)
             {
                 // 这属于新添加
                 _item = new DYJTJItemPara();
                 Global.jtjItems.Add(_item);
             }
             if (sender == null && e == null)
             {
                 _item.Name     = _JTJItemNameType[0].ToString();                     //项目名称
                 _item.Unit     = _JTJItemNameType[3].ToString();                     //项目检测单位
                 _item.HintStr  = _JTJItemNameType[4].ToString();                     //简要操作:新添加实验--注释
                 _item.Password = _JTJItemNameType[5].ToString();                     //密码
                 Int32.TryParse(_JTJItemNameType[6].ToString(), out _item.SampleNum); //样品编号
                 //Int32.TryParse(JTJItemNameType[9].ToString(), out item.Wave);//波长
                 //检测方法选择
                 _item.Method      = Convert.ToInt32(_JTJItemNameType[12].ToString());
                 _item.Hole[0].Use = Convert.ToBoolean(_JTJItemNameType[8].ToString());
                 _item.Hole[1].Use = Convert.ToBoolean(_JTJItemNameType[9].ToString());
                 _item.Hole[2].Use = true;
                 _item.Hole[3].Use = true;
                 _item.InvalidC    = Convert.ToInt32(_JTJItemNameType[7].ToString());
             }
             else
             {
                 _item.Name     = TextBoxItemName.Text;
                 _item.Password = TextBoxPassword.Text;
                 _item.HintStr  = TextBoxHintStr.Text;
                 Int32.TryParse(TextBoxSampleNum.Text, out _item.SampleNum);
                 _item.Unit     = TextBoxUnit.Text;
                 _item.InvalidC = Convert.ToInt32(TextBoxInvalidC.Text);
                 List <CheckBox> listCheckBoxes = UIUtils.GetChildObjects <CheckBox>(StackPanelHole, typeof(CheckBox));
                 for (int i = 0; i < Global.deviceHole.SxtCount; ++i)
                 {
                     _item.Hole[i].Use = (bool)listCheckBoxes[i].IsChecked;
                 }
                 _item.Method = ComboBoxMethod.SelectedIndex;
             }
             if (0 == _item.Method)
             {
                 Double.TryParse(TextBoxDXXXPlusT.Text, out _item.dxxx.PlusT);
                 Double.TryParse(TextBoxDXXXMinusT.Text, out _item.dxxx.MinusT);
             }
             else if (1 == _item.Method)
             {
                 Double.TryParse(tb_DXBSAbs.Text, out _item.dxbs.Abs_X);
                 _item.dxbs.SetIdx = comboBox_DXBSSelected.SelectedIndex;
             }
             else if (2 == _item.Method)
             {
                 Double.TryParse(TextBoxDLTA0.Text, out _item.dlt.A0);
                 Double.TryParse(TextBoxDLTA1.Text, out _item.dlt.A1);
                 Double.TryParse(TextBoxDLTA2.Text, out _item.dlt.A2);
                 Double.TryParse(TextBoxDLTA3.Text, out _item.dlt.A3);
                 Double.TryParse(TextBoxDLTB0.Text, out _item.dlt.B0);
                 Double.TryParse(TextBoxDLTB1.Text, out _item.dlt.B1);
                 Double.TryParse(TextBoxDLTPPB.Text, out _item.dlt.Limit);
             }
             else if (3 == _item.Method)
             {
                 Double.TryParse(TextBoxDLTCA0.Text, out _item.dltc.A0);
                 Double.TryParse(TextBoxDLTCA1.Text, out _item.dltc.A1);
                 Double.TryParse(TextBoxDLTCA2.Text, out _item.dltc.A2);
                 Double.TryParse(TextBoxDLTCA3.Text, out _item.dltc.A3);
                 Double.TryParse(TextBoxDLTCB0.Text, out _item.dltc.B0);
                 Double.TryParse(TextBoxDLTCB1.Text, out _item.dltc.B1);
                 Double.TryParse(TextBoxDLTCPPB.Text, out _item.dltc.Limit);
             }
             else if (4 == _item.Method)
             {
                 Double.TryParse(tb_DXBSAbs_CT.Text, out _item.dxbs.Abs_X);
             }
             Global.SerializeToFile(Global.jtjItems, Global.jtjItemsFile);
             if (sender != null && e != null)
             {
                 _isClose  = true;
                 _isUpdate = false;
                 try { this.Close(); }
                 catch (Exception) { }
             }
         }
         else
         {
             _isClose = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("保存失败!\n错误信息:" + ex.Message);
     }
 }
        private JTJResult CalJTJFResult(byte CValue, byte TValue, DYJTJItemPara mItem)
        {
            JTJResult jtjResult = new JTJResult();

            if (CValue <= mItem.InvalidC)
            {
                //C线不显色为无效
                jtjResult.result = JTJResult.JTJF_STAT_INVALID;
            }
            else
            {
                switch (mItem.Method)
                {
                //定性消线
                case DYJTJItemPara.METHOD_DXXX:
                {
                    double a = TValue;
                    double f = mItem.dlt.A0 + mItem.dlt.A1 * a + mItem.dlt.A2 * a * a + mItem.dlt.A3 * a * a * a;
                    jtjResult.density = f = mItem.dlt.B0 * f + mItem.dlt.B1;

                    if (TValue <= mItem.dxxx.PlusT)
                    {
                        jtjResult.result = JTJResult.JTJF_STAT_PLUS;
                    }
                    else if (TValue > mItem.dxxx.MinusT)
                    {
                        jtjResult.result = JTJResult.JTJF_STAT_MINUS;
                    }
                }
                break;

                case DYJTJItemPara.METHOD_DXBS:
                {
                    double a = TValue;
                    double f = mItem.dlt.A0 + mItem.dlt.A1 * a + mItem.dlt.A2 * a * a + mItem.dlt.A3 * a * a * a;
                    jtjResult.density = f = mItem.dlt.B0 * f + mItem.dlt.B1;
                    if (TValue < CValue)        // 阳性
                    {
                        jtjResult.result = JTJResult.JTJF_STAT_PLUS;
                    }
                    else
                    {
                        jtjResult.result = JTJResult.JTJF_STAT_MINUS;
                    }
                }
                break;

                case DYJTJItemPara.METHOD_DLT:
                {
                    double a = TValue;
                    double f = mItem.dlt.A0 + mItem.dlt.A1 * a + mItem.dlt.A2 * a * a + mItem.dlt.A3 * a * a * a;
                    jtjResult.density = f = mItem.dlt.B0 * f + mItem.dlt.B1;
                    if (f > mItem.dlt.Limit)
                    {
                        jtjResult.result = JTJResult.JTJF_STAT_PLUS;
                    }
                    else
                    {
                        jtjResult.result = JTJResult.JTJF_STAT_MINUS;
                    }
                }
                break;

                case DYJTJItemPara.METHOD_DLTC:
                {
                    double a = CValue == 0 ? 1 : TValue * 1.0 / CValue;
                    double f = mItem.dltc.A0 + mItem.dltc.A1 * a + mItem.dltc.A2 * a * a + mItem.dltc.A3 * a * a * a;
                    jtjResult.density = f = mItem.dltc.B0 * f + mItem.dltc.B1;
                    if (f > mItem.dltc.Limit)
                    {
                        jtjResult.result = JTJResult.JTJF_STAT_PLUS;
                    }
                    else
                    {
                        jtjResult.result = JTJResult.JTJF_STAT_MINUS;
                    }
                }

                break;
                }
            }
            return(jtjResult);
        }