private void butSystemCalculate_Click(object sender, EventArgs e)
        {
            var gearParameters = new BasicGeraCalculte[_iGrade];

            for (int i = 0, j = 1; i < _iGrade; i++, j++)
            {
                gearParameters[i] = new BasicGeraCalculte
                                        {
                                            A1 = (double)dataGridView1[j, 0].Value,
                                            Mn = (double)dataGridView1[j, 1].Value,
                                            Z1 = int.Parse(s: dataGridView1[j, 2].Value.ToString()),
                                            Z2 = int.Parse(s: dataGridView1[j, 3].Value.ToString()),
                                            Lxj = (double)dataGridView1[j, 4].Value,
                                            X1 = (double)dataGridView1[j, 5].Value,
                                            An = (double)dataGridView1[j, 6].Value,
                                            H = (double)dataGridView1[j, 7].Value,
                                            C = (double)dataGridView1[j, 8].Value,
                                            B = int.Parse(s: dataGridView1[j, 9].Value.ToString())
                                        };
                gearParameters[i].Nbjs();

                dataGridView1[j, 10].Value = gearParameters[i].X2.ToString("f5");
                dataGridView1[j, 11].Value = gearParameters[i].Dyn.ToString("f5");
                dataGridView1[j, 12].Value = gearParameters[i].Ha1.ToString("f5");
                dataGridView1[j, 13].Value = gearParameters[i].Ha2.ToString("f5");
                dataGridView1[j, 14].Value = gearParameters[i].D1.ToString("f5");
                dataGridView1[j, 15].Value = gearParameters[i].Da1.ToString("f5");
                dataGridView1[j, 16].Value = gearParameters[i].Df1.ToString("f5");
                dataGridView1[j, 17].Value = gearParameters[i].D2.ToString("f5");
                dataGridView1[j, 18].Value = gearParameters[i].Da2.ToString("f5");
                dataGridView1[j, 19].Value = gearParameters[i].Df2.ToString("f5");
                dataGridView1[j, 20].Value = gearParameters[i].K1.ToString("f5");
                dataGridView1[j, 21].Value = gearParameters[i].W1.ToString("f5");
                dataGridView1[j, 22].Value = gearParameters[i].K2.ToString("f5");
                dataGridView1[j, 23].Value = gearParameters[i].W2.ToString("f5");
                dataGridView1[j, 24].Value = gearParameters[i].Ea.ToString("f5");
                dataGridView1[j, 25].Value = gearParameters[i].Eb.ToString("f5");
                dataGridView1[j, 26].Value = gearParameters[i].E.ToString("f5");
            }

            #region 速比误差计算

            double dRatio = 1.0;
            for (int i = 0; i < gearParameters.Length; i++)
            {
                dRatio = dRatio * gearParameters[i].Z2 / gearParameters[i].Z1;
            }

            double dSpeedError = (Math.Abs(double.Parse(SystemConstants.XmlProject.Element("总体要求").Element("总速比").Value) - dRatio)) / double.Parse(SystemConstants.XmlProject.Element("总体要求").Element("总速比").Value);
            labSpeedC.Text = labSpeedC.Text + ":" + dRatio.ToString("f4");
            labSpeedError.Text = labSpeedError.Text + ":" + dSpeedError.ToString("f4");

            SystemConstants.XmlProject.Element("齿轮参数计算").Element("计算速比").Value = dRatio.ToString("f8");
            SystemConstants.XmlProject.Element("齿轮参数计算").Element("速比误差").Value = dSpeedError.ToString("f8");

            #endregion

            #region 轴的动力参数计算

            double[,] dDynamicParameters = new double[3, _iGrade + 1];
            dDynamicParameters[0, 0] = Convert.ToDouble(SystemConstants.XmlProject.Element("总体要求").Element("转速").Value);
            dDynamicParameters[1, 0] = Convert.ToDouble(SystemConstants.XmlProject.Element("总体要求").Element("总功率").Value);
            dDynamicParameters[2, 0] = 9550000 * dDynamicParameters[1, 0] / dDynamicParameters[0, 0];
            for (int i = 1, j = 0; i < _iGrade + 1; i++, j++)
            {
                dDynamicParameters[0, i] = dDynamicParameters[0, i - 1] / ((double)dataGridView1[i, 3].Value / (double)dataGridView1[i, 2].Value);
                dDynamicParameters[1, i] = dDynamicParameters[1, i - 1] * 0.99 * 0.97;
                dDynamicParameters[2, i] = 9550000 * dDynamicParameters[1, i] / dDynamicParameters[0, i];
            }

            for (int i = 0; i < 3; i++)
            {
                for (int j = 1; j <= _iGrade + 1; j++)
                {
                    dataGridView2[j, i].Value = dDynamicParameters[i, j - 1].ToString("f4");
                }
            }

            for (int j = 1; j <= _iGrade + 1; j++)
            {
                SystemConstants.XmlProject.Element("第" + j + "级轴串").Element("动力参数").Element("转速").Value =
                   dDynamicParameters[0, j - 1].ToString("f8");
                SystemConstants.XmlProject.Element("第" + j + "级轴串").Element("动力参数").Element("功率").Value =
                   dDynamicParameters[1, j - 1].ToString("f8");
                SystemConstants.XmlProject.Element("第" + j + "级轴串").Element("动力参数").Element("扭矩").Value =
                   dDynamicParameters[2, j - 1].ToString("f8");
            }

            #endregion

            SystemConstants.XmlProject.Save(SystemConstants.StrProjectPath + @"\减速器.xml");
        }
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                var gearcmp1 = new BasicGeraCalculte();
                var t = dataGridView1[1, 2].Value;

                gearcmp1.A1 = (double)dataGridView1[1, 0].Value;
                gearcmp1.Mn = (double)dataGridView1[1, 1].Value;
                gearcmp1.Z1 = int.Parse(s: dataGridView1[1, 2].Value.ToString());
                gearcmp1.Z2 = int.Parse(s: dataGridView1[1, 3].Value.ToString());
                gearcmp1.Lxj = (double)dataGridView1[1, 4].Value;
                gearcmp1.X1 = (double)dataGridView1[1, 5].Value;
                gearcmp1.An = (double)dataGridView1[1, 6].Value;
                gearcmp1.H = (double)dataGridView1[1, 7].Value;
                gearcmp1.C = (double)dataGridView1[1, 8].Value;
                gearcmp1.B = int.Parse(s: dataGridView1[1, 9].Value.ToString());
                gearcmp1.Nbjs();

                dataGridView1[1, 10].Value = gearcmp1.X2.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 11].Value = gearcmp1.Ha1.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 12].Value = gearcmp1.Ha2.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 13].Value = gearcmp1.D1.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 14].Value = gearcmp1.Da1.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 15].Value = gearcmp1.Df1.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 16].Value = gearcmp1.D2.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 17].Value = gearcmp1.Da2.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 18].Value = gearcmp1.Df2.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 19].Value = gearcmp1.K1.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 20].Value = gearcmp1.W1.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 21].Value = gearcmp1.K2.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 22].Value = gearcmp1.W2.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 23].Value = gearcmp1.Ea.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 24].Value = gearcmp1.Eb.ToString(CultureInfo.InvariantCulture);
                dataGridView1[1, 25].Value = gearcmp1.E.ToString(CultureInfo.InvariantCulture);
            }
            catch (Exception)
            {
                MessageBox.Show("aa");
                throw;
            }
        }