Example #1
0
        protected void FirstPartRead(ResistanceBox Rb, StreamReader sr)
        {
            Rb.Model        = sr.ReadLine().Trim();
            Rb.Accuracy     = sr.ReadLine().Trim();
            Rb.NumberDecade = Convert.ToInt32(sr.ReadLine().Trim());

            double MinResistance;

            double.TryParse(sr.ReadLine().Trim(), out MinResistance);
            Rb.MinResistance = MinResistance;

            double MaxResistance;

            double.TryParse(sr.ReadLine().Trim(), out MaxResistance);
            Rb.MaxResistance = MaxResistance;

            double NullResistance;

            double.TryParse(sr.ReadLine().Trim(), out NullResistance);
            Rb.NullResistance = NullResistance;

            double VariationNullResistance;

            double.TryParse(sr.ReadLine().Trim(), out VariationNullResistance);
            Rb.VariationNullResistance = VariationNullResistance;
        }
Example #2
0
 private void buttonLoad_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Внимание!\nДанное действие загрузит список магазинов сопротивления расположенный в файле Rbtxt.txt с заменой текущего списка магазинов сопротивления.\nДля загрузки нажмите Ок, для выхода Отмена", "Чтение из файла", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
     {
         R.ClearList();
         try
         {
             using (StreamReader file = new StreamReader(@"Rbtxt.txt", false))
             {
                 while (!file.EndOfStream)
                 {
                     if (file.ReadLine().Trim() == "[1]")
                     {
                         ResistanceBox f = new ResistanceBox();
                         R.AddRb(f.Read(file));
                     }
                     else
                     {
                         ResistanceBox2 f2 = new ResistanceBox2();
                         R.AddRb(f2.Read(file));
                     }
                 }
                 listBox1.Items.Clear();
                 R.ShowModel(listBox1);
             }
             listBox1.SelectedIndex = 0;
         }
         catch
         {
             MessageBox.Show("При загрузке данных из файла произошла ошибка", "Ошибка чтения", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Example #3
0
        public virtual ResistanceBox Read(StreamReader sr)
        {
            ResistanceBox Rb = new ResistanceBox();

            FirstPartRead(Rb, sr);
            SecondPartRead(Rb, sr);
            return(Rb);
        }
Example #4
0
        public ResistanceBox FindResistanceBoxInListBox(ListBox L)
        {
            ResistanceBox Rb = new ResistanceBox();

            foreach (ResistanceBox ResBox in ListOfResistanceBoxes)
            {
                if (ResBox.Model == L.SelectedItem.ToString())
                {
                    Rb = ResBox;
                }
            }
            return(Rb);
        }
Example #5
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            ResistanceBox ResistBox = R.FindResistanceBoxInListBox(listBox1);

            indexOfList = R.GetListOfResistanceBoxes.IndexOf(ResistBox);

            AddResistanceBox edit = new AddResistanceBox();

            edit.EditResistanceBox(ResistBox);
            edit.buttonAdd.Text = "Сохранить";
            edit.Text           = "Редактирование прибора";
            edit.ShowDialog(this);
        }
Example #6
0
        private void ShowDec(DataGridView D, List <double> lstDec, ResistanceBox ResB, ref int line, double km)
        {
            double resist         = 0;
            double _relativeError = 0;
            double _absoluteError = 0;
            double lowerLimit     = 0;
            double upperLimit     = 0;

            string FormatString = GetFormatString();

            foreach (double resistanceValue in lstDec)
            {
                resist += km;
                dataGridView2.Rows.Add();
                dataGridView2[0, line].Value = resist.ToString();
                dataGridView2[1, line].Value = resistanceValue.ToString();
                _relativeError = ResB.RelativeError(resist, ResB.ConstantABC);
                dataGridView2[2, line].Value = _relativeError.ToString(FormatString);
                _absoluteError = _relativeError * resist / 100;
                dataGridView2[3, line].Value = _absoluteError.ToString(FormatString);

                lowerLimit = resist - _absoluteError;
                upperLimit = resist + _absoluteError;

                dataGridView2[4, line].Value = lowerLimit.ToString(FormatString);
                dataGridView2[5, line].Value = upperLimit.ToString(FormatString);

                if (resistanceValue < lowerLimit)
                {
                    dataGridView2[1, line].Style.BackColor = Color.Red;
                    dataGridView2[6, line].Style.BackColor = Color.Red;
                    dataGridView2[6, line].Value           = "меньше на " + (lowerLimit - resistanceValue).ToString(FormatString);
                }
                else if (resistanceValue > upperLimit)
                {
                    dataGridView2[1, line].Style.BackColor = Color.Red;
                    dataGridView2[6, line].Style.BackColor = Color.Red;
                    dataGridView2[6, line].Value           = "больше на " + (resistanceValue - upperLimit).ToString(FormatString);
                }
                else
                {
                    dataGridView2[1, line].Style.BackColor = Color.LimeGreen;
                    dataGridView2[6, line].Style.BackColor = Color.LimeGreen;
                    dataGridView2[6, line].Value           = "Соответствует";
                }
                line++;
            }
        }
Example #7
0
        protected void SecondPartRead(ResistanceBox Rb, StreamReader sr)
        {
            Rb.Temperature = sr.ReadLine().Trim();
            Rb.Humidity    = sr.ReadLine().Trim();
            Rb.Pressure    = sr.ReadLine().Trim();

            Formuls formuls = new Formuls();
            string  formula = sr.ReadLine();

            string[] constants = sr.ReadLine().Trim().Split(';');
            Rb.ConstantABC = new double[constants.Length - 1];

            for (int i = 0; i < constants.Length - 1; i++)
            {
                double d;
                double.TryParse(constants[i], out d);
                Rb.ConstantABC[i] = d;
            }

            switch (formula)
            {
            case "Double Formula1(Double, Double[])":
                Rb.RelativeError = new Func <double, double[], double>(formuls.Formula1);

                break;

            case "Double Formula2(Double, Double[])":
                Rb.RelativeError = new Func <double, double[], double>(formuls.Formula2);
                break;

            case "Double Formula3(Double, Double[])":
                Rb.RelativeError = new Func <double, double[], double>(formuls.Formula3);
                break;

            case "Double Formula4(Double, Double[])":
                Rb.RelativeError = new Func <double, double[], double>(formuls.Formula4);
                break;

            case "Double Formula5(Double, Double[])":
                Rb.RelativeError = new Func <double, double[], double>(formuls.Formula5);
                break;

            default:
                break;
            }
        }
Example #8
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            ResistanceBox Rb;
            Formuls       Formula = new Formuls();

            if (comboBoxTypeDevice.SelectedIndex == 0)
            {
                Rb = new ResistanceBox();
            }
            else
            {
                Rb = new ResistanceBox2();
            }

            if (textBoxDevice.Text == "")
            {
                toolTip1.Show("Введите модель магазина сопротивлений", textBoxDevice, 3000);
                return;
            }
            else
            {
                Rb.Model = textBoxDevice.Text;
            }

            if (textBoxAccuracy.Text == "")
            {
                toolTip1.Show("Введите класс точности прибора", textBoxAccuracy, 3000);
                return;
            }
            else
            {
                Rb.Accuracy = textBoxAccuracy.Text;
            }

            Rb.NumberDecade  = (int)nUDNumberDecade.Value;
            Rb.MinResistance = (double)numericUpDownRmin.Value;
            Rb.MaxResistance = (double)numericUpDownRmax.Value;

            if (comboBoxTypeDevice.SelectedIndex == 0)
            {
                Rb.NullResistance          = (double)numericUDRo1.Value;
                Rb.VariationNullResistance = (double)numericUDVarRo1.Value;
            }
            else
            {
                Rb.NullResistance                               = (double)numericUDRo1.Value;
                Rb.VariationNullResistance                      = (double)numericUDVarRo1.Value;
                (Rb as ResistanceBox2).NullResistance2          = (double)numericUDRo2.Value;
                (Rb as ResistanceBox2).VariationNullResistance2 = (double)numericUDVarRo2.Value;
            }

            double[] constants = new double[3];

            if (radioButtonType1.Checked)
            {
                constants        = new double[3];
                constants        = SelectedFormulsType134(constants);
                Rb.RelativeError = new Func <double, double[], double>(Formula.Formula1);
            }

            if (radioButtonType2.Checked)
            {
                constants        = new double[2];
                constants[0]     = (double)numericUpDownA.Value;
                constants[1]     = (double)numericUpDownB.Value;
                Rb.RelativeError = new Func <double, double[], double>(Formula.Formula2);
            }

            if (radioButtonType3.Checked)
            {
                constants        = new double[3];
                constants        = SelectedFormulsType134(constants);
                Rb.RelativeError = new Func <double, double[], double>(Formula.Formula3);
            }

            if (radioButtonType4.Checked)
            {
                constants        = new double[3];
                constants        = SelectedFormulsType134(constants);
                Rb.RelativeError = new Func <double, double[], double>(Formula.Formula4);
            }

            if (radioButtonType5.Checked)
            {
                constants        = new double[1];
                constants[0]     = (double)numericUpDownA.Value;
                Rb.RelativeError = new Func <double, double[], double>(Formula.Formula5);
            }
            Rb.ConstantABC = constants;
            Rb.Temperature = maskedTextBoxTemperature.Text;
            Rb.Humidity    = maskedTextBoxHumidity.Text;
            Rb.Pressure    = maskedTextBoxPressure.Text;

            Form1 f = Owner as Form1;

            if (f != null)
            {
                if (this.Text == "Редактирование прибора")
                {
                    f.R.Replace(f.indexOfList, Rb);
                    f.listBox1.Items.Clear();
                    f.R.ShowModel(f.listBox1);
                    f.listBox1.SelectedIndex = f.indexOfList;
                }

                else
                {
                    f.listBox1.Items.Clear();
                    f.R.AddRb(Rb);
                    f.R.ShowModel(f.listBox1);
                    f.listBox1.SelectedIndex = 0;
                }
            }

            Close();
        }
Example #9
0
        public void EditResistanceBox(ResistanceBox ResBox)
        {
            if ((ResBox as ResistanceBox2) != null)
            {
                comboBoxTypeDevice.SelectedIndex = 1;
                numericUDRo1.Value    = (decimal)ResBox.NullResistance;
                numericUDRo2.Value    = (decimal)((ResistanceBox2)ResBox).NullResistance2;
                numericUDVarRo1.Value = (decimal)ResBox.VariationNullResistance;
                numericUDVarRo2.Value = (decimal)((ResistanceBox2)ResBox).VariationNullResistance2;
            }
            else
            {
                comboBoxTypeDevice.SelectedIndex = 0;
                numericUDRo1.Value    = (decimal)ResBox.NullResistance;
                numericUDVarRo1.Value = (decimal)ResBox.VariationNullResistance;
            }

            textBoxDevice.Text            = ResBox.Model;
            textBoxAccuracy.Text          = ResBox.Accuracy;
            nUDNumberDecade.Value         = (decimal)ResBox.NumberDecade;
            numericUpDownRmin.Value       = (decimal)ResBox.MinResistance;
            numericUpDownRmax.Value       = (decimal)ResBox.MaxResistance;
            maskedTextBoxTemperature.Text = ResBox.Temperature;
            maskedTextBoxHumidity.Text    = ResBox.Humidity;
            maskedTextBoxPressure.Text    = ResBox.Pressure;

            switch (ResBox.RelativeError.Method.Name.Trim())
            {
            case "Formula1":
            {
                radioButtonType1.Checked = true;
                numericUpDownA.Value     = (decimal)ResBox.ConstantABC[0];
                numericUpDownB.Value     = (decimal)ResBox.ConstantABC[1];
                numericUpDownC.Value     = (decimal)ResBox.ConstantABC[2];
                break;
            }

            case "Formula2":
            {
                radioButtonType2.Checked = true;
                numericUpDownA.Value     = (decimal)ResBox.ConstantABC[0];
                numericUpDownB.Value     = (decimal)ResBox.ConstantABC[1];
                break;
            }

            case "Formula3":
            {
                radioButtonType3.Checked = true;
                numericUpDownA.Value     = (decimal)ResBox.ConstantABC[0];
                numericUpDownB.Value     = (decimal)ResBox.ConstantABC[1];
                numericUpDownC.Value     = (decimal)ResBox.ConstantABC[2];
                break;
            }

            case "Formula4":
            {
                radioButtonType4.Checked = true;
                numericUpDownA.Value     = (decimal)ResBox.ConstantABC[0];
                numericUpDownB.Value     = (decimal)ResBox.ConstantABC[1];
                numericUpDownC.Value     = (decimal)ResBox.ConstantABC[2];
                break;
            }

            case "Formula5":
            {
                radioButtonType5.Checked = true;
                numericUpDownA.Value     = (decimal)ResBox.ConstantABC[0];
            }
            break;

            default: MessageBox.Show("При загрузке данных о формуле произошла ошибка", "Ошибка загрузки данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;
            }
        }
Example #10
0
        public void CreateProtocol(DateTimePicker dtp1, string txt1,
                                   string txt2, string txt3, string txt4, string txt5, string txt6,
                                   List <List <double> > list, ResistanceBox ResB, string Corresponds)
        {
            var wordApplication = new Word.Application();

            wordApplication.Visible = false;

            try
            {
                var wordDocument = wordApplication.Documents.Open(Application.StartupPath + @"\Program Files\Протокол.doc");

                ReplaceTextInDocument("{Протокол №:}", txt1, wordDocument);
                ReplaceTextInDocument("{Тип:}", txt2, wordDocument);
                ReplaceTextInDocument("{Номер:}", txt3, wordDocument);
                if (txt4.IndexOf('^') != -1)
                {
                    string degree;
                    string str = txt4;
                    int    FromIndex;
                    int    Len;
                    FromIndex = str.IndexOf('(') + 1;
                    Len       = str.IndexOf(')') - FromIndex;
                    degree    = str.Substring(FromIndex, Len);
                    str       = str.Remove(str.IndexOf('^'));
                    str       = str.Replace('*', '∙');
                    ReplaceTextInDocument("{Класс точности:}", str + degree, wordDocument);
                    Word.Range rng     = wordDocument.Content;
                    int        startIn = rng.Text.IndexOf(str) + str.Length;
                    rng.SetRange(startIn, startIn + degree.Length);
                    rng.Select();
                    rng.FormattedText.Font.Superscript = 1;
                }
                else
                {
                    ReplaceTextInDocument("{Класс точности:}", txt4, wordDocument);
                }


                ReplaceTextInDocument("{Предоставленный на поверку:}", txt5, wordDocument);
                ReplaceTextInDocument("{Дата поверки:}", dtp1.Value.ToLongDateString(), wordDocument);
                ReplaceTextInDocument("{Поверитель:}", txt6, wordDocument);

                ReplaceTextInDocument("{Протокол №:}", txt1, wordDocument);
                ReplaceTextInDocument("{Тип:}", txt2, wordDocument);
                ReplaceTextInDocument("{Номер:}", txt3, wordDocument);
                ReplaceTextInDocument("{не/соответствует}", Corresponds, wordDocument);


                Word.Table table = wordDocument.Tables[2];

                if ((ResB as ResistanceBox2) != null)
                {
                    InsertNullRes(table, list[0], 2);
                    InsertNullRes(table, list[1], 5);
                    list.RemoveAt(1);
                    list.RemoveAt(0);
                }
                else
                {
                    table.Rows[1].Delete();
                    table.Rows[3].Delete();
                    table.Rows[3].Delete();
                    table.Rows[3].Delete();
                    InsertNullRes(table, list[0], 1);
                    list.RemoveAt(0);
                }
                table.PreferredWidth = 560;
                Word.Table table3 = wordDocument.Tables[3];

                double DecadeValue = ResB.MinResistance;
                for (int i = 0; i < ResB.NumberDecade; i++)
                {
                    table3.Columns.Add();
                    table3.Cell(2, i + 2).Range.Text = "x " + DecadeValue.ToString();
                    DecadeValue *= 10;
                }

                for (int i = table3.Columns.Count; i > 2; i--)
                {
                    Word.Cell firstCell = table3.Cell(1, i);
                    Word.Cell currCell  = table3.Cell(1, i - 1);
                    if (currCell.ColumnIndex != firstCell.ColumnIndex)
                    {
                        firstCell.Merge(currCell);
                    }
                }

                table3.Cell(1, 1).Merge(table3.Cell(2, 1));
                table3.Cell(1, 1).Range.Text = "Номер ступени";
                table3.Cell(1, 2).Range.Text = "Действительное значение сопротивления, Ом";

                int maxCount = list[0].Count;
                foreach (var lis in list)
                {
                    if (lis.Count > maxCount)
                    {
                        maxCount = lis.Count;
                    }
                }

                for (int i = 0; i < maxCount; i++)
                {
                    table3.Rows.Add();
                    table3.Cell(i + 3, 1).Range.Text = (i + 1).ToString();
                }

                int rowIndex     = 0;
                int columnsIndex = 2;
                foreach (var item in list)
                {
                    foreach (var lis in item)
                    {
                        table3.Cell(rowIndex++ + 3, columnsIndex).Range.Text = lis.ToString();
                    }
                    columnsIndex++;
                    rowIndex = 0;
                }
                table3.PreferredWidth   = 560;
                wordApplication.Visible = true;
            }
            catch
            {
                MessageBox.Show("При создании документа возникла ошибка\nПроверьте наличие файла в папке шаблонов",
                                "При создании файла MS Word возникла ошибка.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                wordApplication.Quit();
            }
        }
Example #11
0
        /// <summary>
        /// Список магазинов сопротивления по умолчанию
        /// </summary>
        public void DefaultDevice()
        {
            Formuls Formula = new Formuls();

            ResistanceBox2 P4834 = new ResistanceBox2("P4834", "0,02/2,5*10^(-7)", 8, "20±2°С", "25-80%", "84-106,7кПа");

            P4834.MinResistance            = 0.01;
            P4834.MaxResistance            = 111111.1;
            P4834.NullResistance           = 0.012;
            P4834.NullResistance2          = 0.024;
            P4834.VariationNullResistance  = 0.0012;
            P4834.VariationNullResistance2 = 0.0024;
            P4834.RelativeError            = new Func <double, double[], double>(Formula.Formula1);
            P4834.ConstantABC = new double[] { 0.02, 0.00000025, 1000000 };
            ListOfResistanceBoxes.Add(P4834);

            ResistanceBox2 P4831 = new ResistanceBox2("P4831", "0,02/2,0*10^(-6)", 7, "20±2°С", "25-80%", "84-106,7кПа");

            P4831.MinResistance            = 0.01;
            P4831.MaxResistance            = 111111.10;
            P4831.NullResistance           = 0.021;
            P4831.NullResistance2          = 0.021;
            P4831.VariationNullResistance  = 0.0021;
            P4831.VariationNullResistance2 = 0.0021;
            P4831.RelativeError            = new Func <double, double[], double>(Formula.Formula1);
            P4831.ConstantABC = new double[] { 0.02, 0.000002, P4831.MaxResistance };
            ListOfResistanceBoxes.Add(P4831);

            ResistanceBox P327 = new ResistanceBox("P327", "0,01/1,5*10^(-6)", 6, "20±1°С", "25-80%", "84-106,7кПа");

            P327.MinResistance           = 0.1;
            P327.MaxResistance           = 111111.0;
            P327.NullResistance          = 0.012;
            P327.VariationNullResistance = 0.001;
            P327.RelativeError           = new Func <double, double[], double>(Formula.Formula1);
            P327.ConstantABC             = new double[] { 0.01, 0.0000015, P327.MaxResistance };
            ListOfResistanceBoxes.Add(P327);

            ResistanceBox MCP_60M = new ResistanceBox("MCP-60M", "0,02", 6, "20±2°С", "25-80%", "84-106,7кПа");

            MCP_60M.MinResistance           = 0.01;
            MCP_60M.MaxResistance           = 11111.1;
            MCP_60M.NullResistance          = 0.018;
            MCP_60M.VariationNullResistance = 0.002;
            MCP_60M.RelativeError           = new Func <double, double[], double>(Formula.Formula3);
            MCP_60M.ConstantABC             = new double[] { 0.02, 0.02, MCP_60M.NumberDecade };
            ListOfResistanceBoxes.Add(MCP_60M);

            ResistanceBox MCP_60 = new ResistanceBox("MCP-60", "0,02", 6, "20±2°С", "25-80%", "84-106,7кПа");

            MCP_60.MinResistance           = 0.01;
            MCP_60.MaxResistance           = 11111.1;
            MCP_60.NullResistance          = 0.011;
            MCP_60.VariationNullResistance = 0.0025;
            MCP_60.RelativeError           = new Func <double, double[], double>(Formula.Formula3);
            MCP_60.ConstantABC             = new double[] { 0.02, 0.1, 1 };
            ListOfResistanceBoxes.Add(MCP_60);

            ResistanceBox P33 = new ResistanceBox("P33", "0,2/6*10^(-6)", 6, "20±2°С", "25-80%", "84-106,7кПа");

            P33.MinResistance           = 0.1;
            P33.MaxResistance           = 99999.9;
            P33.NullResistance          = 0.06;
            P33.VariationNullResistance = 0.006;
            P33.RelativeError           = new Func <double, double[], double>(Formula.Formula1);
            P33.ConstantABC             = new double[] { 0.2, 0.000006, P33.MaxResistance };
            ListOfResistanceBoxes.Add(P33);

            ResistanceBox2 P4830_1 = new ResistanceBox2("P4830/1", "0,05/2,5*10^(-5)", 6, "20±2°С", "25-80%", "84-106,7кПа");

            P4830_1.MinResistance            = 0.01;
            P4830_1.MaxResistance            = 12222.21;
            P4830_1.NullResistance           = 0.03;
            P4830_1.NullResistance2          = 0.02;
            P4830_1.VariationNullResistance  = 0.003;
            P4830_1.VariationNullResistance2 = 0.002;
            P4830_1.RelativeError            = new Func <double, double[], double>(Formula.Formula1);
            P4830_1.ConstantABC = new double[] { 0.05, 0.000025, P4830_1.MaxResistance };
            ListOfResistanceBoxes.Add(P4830_1);

            ResistanceBox2 P4830_2 = new ResistanceBox2("P4830/2", "0,05/2,5*10^(-6)", 6, "20±2°С", "25-80%", "84-106,7кПа");

            P4830_2.MinResistance            = 0.1;
            P4830_2.MaxResistance            = 122222.1;
            P4830_2.NullResistance           = 0.03;
            P4830_2.NullResistance2          = 0.015;
            P4830_2.VariationNullResistance  = 0.003;
            P4830_2.VariationNullResistance2 = 0.0015;
            P4830_2.RelativeError            = new Func <double, double[], double>(Formula.Formula1);
            P4830_2.ConstantABC = new double[] { 0.05, 0.0000025, P4830_2.MaxResistance };
            ListOfResistanceBoxes.Add(P4830_2);

            ResistanceBox MCP_63 = new ResistanceBox("MCP-63", "0,05/4*10^(-6)", 7, "20±2°С", "25-80%", "84-106,7кПа");

            MCP_63.MinResistance           = 0.01;
            MCP_63.MaxResistance           = 111111.1;
            MCP_63.NullResistance          = 0.035;
            MCP_63.VariationNullResistance = 0.0035;
            MCP_63.RelativeError           = new Func <double, double[], double>(Formula.Formula4);
            MCP_63.ConstantABC             = new double[] { 0.05, 0.000004, MCP_63.MaxResistance };
            ListOfResistanceBoxes.Add(MCP_63);

            //ResistanceBox P40103 = new ResistanceBox("Р40103", "0,1", 1, "20±2°С", "25-80%", "84-106,7кПа");
            //P40103.MinResistance = 0.01;
            //P40103.MaxResistance = 111111.1;
            //P40103.NullResistance = 0.035;
            //P40103.VariationNullResistance = 0.0035;
            //P40103.RelativeError = new Func<double, double[], double>(Formula.Formula5);
            //P40103.ConstantABC = new double[] { 0.1 };
            //ListOfResistanceBoxes.Add(P40103);
        }
Example #12
0
 public void DeleteRb(ResistanceBox res)
 {
     ListOfResistanceBoxes.Remove(res);
 }
Example #13
0
 /// <summary>
 /// Заменяет магазин сопротивления с указанным индексом
 /// </summary>
 /// <param name="index"></param>
 /// <param name="res"></param>
 public void Replace(int index, ResistanceBox res)
 {
     ListOfResistanceBoxes.RemoveAt(index);
     ListOfResistanceBoxes.Insert(index, res);
 }
Example #14
0
 /// <summary>
 /// Добавляет новый магазин сопротивления в список
 /// </summary>
 /// <param name="res">Добавляемый магазин сопротивления</param>
 public void AddRb(ResistanceBox res)
 {
     ListOfResistanceBoxes.Add(res);
 }
Example #15
0
        private bool FillDataGridView2()
        {
            dataGridView2.Columns.Clear();
            dataGridView2.Columns.Add("Rnom", "Rном.,Ом");
            dataGridView2.Columns.Add("Rd", "Rд.,Ом");
            dataGridView2.Columns.Add("r_otn", "r%");
            dataGridView2.Columns.Add("R_ab", "∆R,Ом");
            dataGridView2.Columns.Add("R_mdR", "R-∆R,Ом");
            dataGridView2.Columns.Add("R_pdR", "R+∆R,Ом");
            dataGridView2.Columns.Add("Сonclusion", "Заключение");

            ResistanceBox R1 = R.FindResistanceBoxInListBox(listBox1);

            List <List <double> > lis = new List <List <double> >();

            double k = 0;

            for (int i = 0; i < dataGridView1.ColumnCount; i++)
            {
                lis.Add(new List <double>());
                for (int j = 0; j < dataGridView1.RowCount; j++)
                {
                    if (dataGridView1[i, j].Value != null && dataGridView1[i, j].Value.ToString() != "")
                    {
                        double.TryParse(dataGridView1[i, j].Value.ToString(), out k);
                        lis[i].Add(k);
                    }
                }
            }

            int indexLine = 0;
            int showColumnsCount;

            if ((R1 as ResistanceBox2) != null)
            {
                if (lis[0].Count == 0)
                {
                    MessageBox.Show("Внимание! Нет данных в столбце: 'Ro на зажимах №1'\nВведите данные и повторите попытку", "Заполнение данных", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                if (lis[0].Count > 4)
                {
                    lis[0].RemoveRange(4, lis[0].Count - 4);
                }
                dataGridView2.Rows.Add();
                dataGridView2[1, indexLine++].Value = "Ro на зажимах №1";
                ShowNullRes(dataGridView2, lis[0], ref indexLine, ((ResistanceBox2)R1).NullResistance, ((ResistanceBox2)R1).VariationNullResistance);
                if (lis[1].Count == 0)
                {
                    MessageBox.Show("Внимание! Нет данных в столбце: 'Ro на зажимах №2'\nВведите данные и повторите попытку", "Заполнение данных", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                if (lis[1].Count > 4)
                {
                    lis[1].RemoveRange(4, lis[1].Count - 4);
                }
                dataGridView2.Rows.Add();
                dataGridView2[1, indexLine++].Value = "Ro на зажимах №2";
                ShowNullRes(dataGridView2, lis[1], ref indexLine, ((ResistanceBox2)R1).NullResistance2, ((ResistanceBox2)R1).VariationNullResistance2);
                showColumnsCount = 2;
            }
            else
            {
                if (lis[0].Count == 0)
                {
                    MessageBox.Show("Внимание! Нет данных в столбце: 'Ro'\nВведите данные и повторите попытку", "Заполнение данных", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                if (lis[0].Count > 4)
                {
                    lis[0].RemoveRange(4, lis[0].Count - 4);
                }
                dataGridView2.Rows.Add();
                dataGridView2[1, indexLine++].Value = "Ro";
                ShowNullRes(dataGridView2, lis[0], ref indexLine, R1.NullResistance, R1.VariationNullResistance);
                showColumnsCount = 1;
            }

            int kz = 1;

            double km = R1.MinResistance;

            for (int i = showColumnsCount; i < lis.Count; i++)
            {
                dataGridView2.Rows.Add();
                dataGridView2[0, indexLine++].Value = "Декада №" + kz++.ToString();
                ShowDec(dataGridView2, lis[i], R1, ref indexLine, km);
                km *= 10;
            }
            ShowtInExportForm = R1;
            listExport        = lis;
            return(true);
        }