private void OK_Click(object sender, RoutedEventArgs e)
        {
            Properties.Settings.Default.otchetType      = typeComboBox.Text;
            Properties.Settings.Default.otchetStanok    = stanokComboBox.Text;
            Properties.Settings.Default.otchetCharakter = charachter.Text;
            Properties.Settings.Default.otchetSkorostK  = speedK.Text;
            Properties.Settings.Default.otchetSkorostZ  = speedZ.Text;
            Properties.Settings.Default.otchetGlubina   = glubinaT.Text;
            Properties.Settings.Default.otchetProdol    = prodolPodachaS.Text;
            Properties.Settings.Default.otchetDiam      = diam.Text;
            Properties.Settings.Default.otchetDlina     = dlina.Text;
            Properties.Settings.Default.otchetPripusk   = pripusk.Text;
            Properties.Settings.Default.otchetCharK     = charkText.Text;
            Properties.Settings.Default.otchetIndex     = indexZText.Text;
            Properties.Settings.Default.otchetStruktura = struktText.Text;

            if (typeComboBox.SelectedIndex == 1)
            {
                SQLiteConnection conn = new SQLiteConnection(@"Data Source=" + Environment.CurrentDirectory + @"\data.db; Version=3;");
                conn.Open();
                DataTable         d   = new DataTable();
                SQLiteCommand     cmd = new SQLiteCommand("select * from naruzhniyStanok where name = '" + stanokComboBox.Text + "'", conn);
                SQLiteDataAdapter ad  = new SQLiteDataAdapter(cmd);
                ad.Fill(d);
                conn.Dispose();

                float  Bk     = float.Parse(d.Rows[0][6].ToString().Replace(".", ","));                                                         // ширина круга
                double S      = float.Parse(prodolPodachaS.Text.Replace(".", ",")) * Bk;                                                        //продольная подача
                float  Dk     = float.Parse(d.Rows[0][5].ToString().Replace(".", ","));                                                         //диаметр круга
                float  nz     = Math.Abs((1000 * float.Parse(speedZ.Text.Replace(".", ","))) / (float.Parse("3,14") * float.Parse(diam.Text))); //частота вращения заготовки
                float  nk     = (1000 * float.Parse(speedK.Text.Replace(".", ",")) * 60) / (float.Parse("3,14") * Dk);                          //частота вращения заготовки
                float  nzRdy  = 0;                                                                                                              //частота вращения заготовки с учетом станка
                float  nkRdy  = 0;                                                                                                              //частота вращения круга с учетом станка
                float  Vkd    = 0;                                                                                                              //Vкд
                double Vst    = 0;                                                                                                              //скорость движения стола
                float  VstRdy = 0;                                                                                                              //скорость движения стола с учетом станка

                if (d.Rows[0][7].ToString().Contains(';'))
                {
                    String[] substrings = d.Rows[0][7].ToString().Split(';');

                    float raznica = Math.Abs(float.Parse(substrings[0]) - nz);
                    int   k       = 0;

                    for (int i = 1; i < substrings.Length; i++)
                    {
                        if (raznica > Math.Abs(float.Parse(substrings[i]) - nz))
                        {
                            raznica = Math.Abs(float.Parse(substrings[i]) - nz);
                            k       = i;
                        }
                    }

                    nzRdy = float.Parse(substrings[k]);
                }
                else if (d.Rows[0][7].ToString().Contains('-'))
                {
                    String[] substrings = d.Rows[0][7].ToString().Split('-');
                    if (nz >= float.Parse(substrings[0]) && nz <= float.Parse(substrings[1]))
                    {
                        nz = Math.Abs(nz);
                    }
                    else if (nz < float.Parse(substrings[0]))
                    {
                        nz = float.Parse(substrings[0]);
                    }
                    else if (nz > float.Parse(substrings[1]))
                    {
                        nz = float.Parse(substrings[1]);
                    }

                    nzRdy = nz;
                }

                if (d.Rows[0][8].ToString().Contains(';'))
                {
                    String[] substrings = d.Rows[0][8].ToString().Split(';');

                    float raznica = Math.Abs(float.Parse(substrings[0]) - nk);
                    int   k       = 0;

                    for (int i = 1; i < substrings.Length; i++)
                    {
                        if (raznica > Math.Abs(float.Parse(substrings[i]) - nk))
                        {
                            raznica = Math.Abs(float.Parse(substrings[i]) - nk);
                            k       = i;
                        }
                    }

                    nkRdy = float.Parse(substrings[k]);
                }
                else if (d.Rows[0][8].ToString().Contains('-'))
                {
                    String[] substrings = d.Rows[0][8].ToString().Split('-');
                    if (nk >= float.Parse(substrings[0]) && nk <= float.Parse(substrings[1]))
                    {
                        nk = Math.Abs(nk);
                    }
                    else if (nk < float.Parse(substrings[0]))
                    {
                        nk = float.Parse(substrings[0]);
                    }
                    else if (nk > float.Parse(substrings[1]))
                    {
                        nk = float.Parse(substrings[1]);
                    }

                    nkRdy = nk;
                }

                Vkd = (float.Parse("3,14") * float.Parse(d.Rows[0][5].ToString().Replace(".", ",")) * nzRdy) / (1000 * 60);
                if (S - Math.Truncate(S) >= 0.5)
                {
                    S = Math.Truncate(S) + 1;
                }
                else
                {
                    S = Math.Truncate(S);
                }

                Vst = S * Math.Truncate(nzRdy);

                if (d.Rows[0][9].ToString().Contains(';'))
                {
                    String[] substrings = d.Rows[0][9].ToString().Split(';');

                    float raznica = Math.Abs(float.Parse(substrings[0]) - float.Parse(Vst.ToString()));
                    int   k       = 0;

                    for (int i = 1; i < substrings.Length; i++)
                    {
                        if (raznica > Math.Abs(float.Parse(substrings[i]) - Vst))
                        {
                            raznica = Math.Abs(float.Parse(substrings[i]) - float.Parse(Vst.ToString()));
                            k       = i;
                        }
                    }

                    VstRdy = float.Parse(substrings[k]);
                }
                else if (d.Rows[0][9].ToString().Contains('-'))
                {
                    String[] substrings = d.Rows[0][9].ToString().Split('-');
                    if (Vst >= float.Parse(substrings[0].Replace(".", ",")) && Vst <= float.Parse(substrings[1].Replace(".", ",")))
                    {
                        Vst = Math.Abs(Vst);
                    }
                    else if (nz < float.Parse(substrings[0].Replace(".", ",")))
                    {
                        Vst = float.Parse(substrings[0].Replace(".", ","));
                    }
                    else if (Vst > float.Parse(substrings[1].Replace(".", ",")))
                    {
                        Vst = float.Parse(substrings[1].Replace(".", ","));
                    }

                    VstRdy = float.Parse(Vst.ToString());
                }
                float   f            = Properties.Settings.Default.r;
                decimal decimalValue = System.Convert.ToDecimal(f);
                double  doubleValue  = System.Convert.ToDouble(decimalValue);

                float   f2            = Properties.Settings.Default.x;
                decimal decimalValue2 = System.Convert.ToDecimal(f2);
                double  doubleValue2  = System.Convert.ToDouble(decimalValue2);

                float   f3            = Properties.Settings.Default.y;
                decimal decimalValue3 = System.Convert.ToDecimal(f3);
                double  doubleValue3  = System.Convert.ToDouble(decimalValue3);

                float   f4            = Properties.Settings.Default.q;
                decimal decimalValue4 = System.Convert.ToDecimal(f4);
                double  doubleValue4  = System.Convert.ToDouble(decimalValue4);

                float Nrez = Properties.Settings.Default.Cn * float.Parse((Math.Pow(double.Parse(speedZ.Text.Replace(".", ",")), doubleValue)).ToString()) * float.Parse((Math.Pow(double.Parse(glubinaT.Text.Replace(".", ",")), doubleValue2)).ToString()) * float.Parse(Math.Pow(S, doubleValue3).ToString()) * float.Parse((Math.Pow(double.Parse(diam.Text.Replace(".", ",")), doubleValue4).ToString()));

                float Nshp = float.Parse(d.Rows[0][3].ToString()) * float.Parse(d.Rows[0][4].ToString());

                float Lpx1 = float.Parse(dlina.Text) + 0.2f * Bk;
                float Lpx2 = float.Parse(dlina.Text) + 0.4f * Bk;
                float kk   = 0;
                if (charachter.SelectedIndex == 0 || charachter.SelectedIndex == 3)
                {
                    kk = 1.1f;
                }
                else
                {
                    kk = 1.4f;
                }
                float Tm1 = 0;
                float Tm2 = 0;

                if (charachter.SelectedIndex == 0 || charachter.SelectedIndex == 1)
                {
                    Tm1 = (Lpx1 * float.Parse(pripusk.Text.Replace(".", ",")) * kk) / (nzRdy * (float)S * float.Parse(glubinaT.Text.Replace(".", ",")));
                    Tm2 = (Lpx2 * float.Parse(pripusk.Text.Replace(".", ",")) * kk) / (nzRdy * (float)S * float.Parse(glubinaT.Text.Replace(".", ",")));
                }

                if (charachter.SelectedIndex == 3 || charachter.SelectedIndex == 4)
                {
                    Tm1 = ((Lpx1 * float.Parse(pripusk.Text.Replace(".", ","))) / ((float)S * nzRdy * float.Parse(glubinaT.Text.Replace(".", ",")))) * kk;
                    Tm2 = ((Lpx2 * float.Parse(pripusk.Text.Replace(".", ","))) / ((float)S * nzRdy * float.Parse(glubinaT.Text.Replace(".", ",")))) * kk;
                }

                Properties.Settings.Default.Nrez         = Math.Round(Nrez, 1);
                Properties.Settings.Default.Nshp         = Math.Round(Nshp, 1);
                Properties.Settings.Default.ProdolPodach = Math.Truncate(S).ToString();
                Properties.Settings.Default.ChastotaZ    = Math.Truncate(nzRdy).ToString();
                Properties.Settings.Default.ChastotaK    = Math.Truncate(nkRdy).ToString();
                Properties.Settings.Default.SkorostStola = Math.Truncate(VstRdy).ToString();
                Properties.Settings.Default.Tm1          = Math.Round(Tm1, 1);
                Properties.Settings.Default.Tm2          = Math.Round(Tm2, 1);
                Properties.Settings.Default.charkText    = charkText.Text;
                Properties.Settings.Default.indexZText   = indexZText.Text;
                Properties.Settings.Default.struktText   = struktText.Text;

                RezhimiNaruzh rn = new RezhimiNaruzh();
                rn.ShowDialog();
            }
            else
            {
                SQLiteConnection conn = new SQLiteConnection(@"Data Source=" + Environment.CurrentDirectory + @"\data.db; Version=3;");
                conn.Open();
                DataTable         d   = new DataTable();
                SQLiteCommand     cmd = new SQLiteCommand("select * from vnutrenniyStanok where name = '" + stanokComboBox.Text + "'", conn);
                SQLiteDataAdapter ad  = new SQLiteDataAdapter(cmd);
                ad.Fill(d);
                conn.Dispose();

                float Dk = 0.9f * float.Parse(diam.Text.Replace(".", ",")); //диаметр круга
                float Bk = float.Parse(diam.Text.Replace(".", ",")) - 15;   //ширина круга

                SQLiteConnection conn1 = new SQLiteConnection(@"Data Source=" + Environment.CurrentDirectory + @"\data.db; Version=3;");
                conn1.Open();
                DataTable         d1   = new DataTable();
                SQLiteCommand     cmd1 = new SQLiteCommand("select do from diams where Dk = '" + Dk.ToString() + "'", conn1);
                SQLiteDataAdapter ad1  = new SQLiteDataAdapter(cmd1);
                ad1.Fill(d1);
                conn1.Dispose();

                //int Do = Int32.Parse(d1.Rows[0][0].ToString()); //диаметр отверстия
                double S = float.Parse(prodolPodachaS.Text.Replace(".", ",")) * Bk; //продольная подача
                float  Sp;

                String[] substrings = d.Rows[0][11].ToString().Replace(".", ",").Split(';');

                float raznica = Math.Abs(float.Parse(substrings[0]) - float.Parse(glubinaT.Text.Replace(".", ",")));
                int   k       = 0;

                for (int i = 1; i < substrings.Length; i++)
                {
                    if (raznica > Math.Abs(float.Parse(substrings[i]) - float.Parse(glubinaT.Text.Replace(".", ","))))
                    {
                        raznica = Math.Abs(float.Parse(substrings[i]) - float.Parse(glubinaT.Text.Replace(".", ",")));
                        k       = i;
                    }
                }

                Sp = float.Parse(substrings[k]);

                float nk    = (1000 * float.Parse(speedK.Text.Replace(".", ",")) * 60) / (float.Parse("3,14") * Dk); //частота вращения заготовки
                float NkRdy = 0;

                if (d.Rows[0][9].ToString().Contains(';'))
                {
                    String[] substrings1 = d.Rows[0][9].ToString().Split(';');

                    float raznica1 = Math.Abs(float.Parse(substrings1[0]) - float.Parse(nk.ToString()));
                    int   k1       = 0;

                    for (int i = 1; i < substrings1.Length; i++)
                    {
                        if (raznica > Math.Abs(float.Parse(substrings1[i]) - nk))
                        {
                            raznica = Math.Abs(float.Parse(substrings1[i]) - float.Parse(nk.ToString()));
                            k1      = i;
                        }
                    }

                    NkRdy = float.Parse(substrings1[k1]);
                }
                else if (d.Rows[0][9].ToString().Contains('-'))
                {
                    String[] substrings1 = d.Rows[0][9].ToString().Split('-');
                    if (nk >= float.Parse(substrings1[0].Replace(".", ",")) && nk <= float.Parse(substrings1[1].Replace(".", ",")))
                    {
                        nk = Math.Abs(nk);
                    }
                    else if (nk < float.Parse(substrings1[0].Replace(".", ",")))
                    {
                        nk = float.Parse(substrings1[0].Replace(".", ","));
                    }
                    else if (nk > float.Parse(substrings1[1].Replace(".", ",")))
                    {
                        nk = float.Parse(substrings1[1].Replace(".", ","));
                    }

                    NkRdy = float.Parse(nk.ToString());
                }

                float nz    = (1000 * float.Parse(speedZ.Text.Replace(".", ","))) / ((float)Math.PI * float.Parse(diam.Text.Replace(".", ",")));
                float NzRdy = 0;
                if (d.Rows[0][8].ToString().Contains(';'))
                {
                    String[] substrings1 = d.Rows[0][8].ToString().Split(';');

                    float raznica1 = Math.Abs(float.Parse(substrings1[0]) - float.Parse(nz.ToString()));
                    int   k1       = 0;

                    for (int i = 1; i < substrings1.Length; i++)
                    {
                        if (raznica > Math.Abs(float.Parse(substrings1[i]) - nz))
                        {
                            raznica = Math.Abs(float.Parse(substrings1[i]) - float.Parse(nz.ToString()));
                            k1      = i;
                        }
                    }

                    NzRdy = float.Parse(substrings1[k1]);
                }
                else if (d.Rows[0][8].ToString().Contains('-'))
                {
                    String[] substrings1 = d.Rows[0][8].ToString().Split('-');
                    if (nz >= float.Parse(substrings1[0].Replace(".", ",")) && nz <= float.Parse(substrings1[1].Replace(".", ",")))
                    {
                        nz = Math.Abs(nz);
                    }
                    else if (nz < float.Parse(substrings1[0].Replace(".", ",")))
                    {
                        nz = float.Parse(substrings1[0].Replace(".", ","));
                    }
                    else if (nz > float.Parse(substrings1[1].Replace(".", ",")))
                    {
                        nz = float.Parse(substrings1[1].Replace(".", ","));
                    }

                    NzRdy = float.Parse(nz.ToString());
                }

                float Vkd = ((float)Math.PI * Dk * NkRdy) / (1000 * 60);
                float Vst = ((float)S * NzRdy) / 1000;

                float   f            = Properties.Settings.Default.r;
                decimal decimalValue = System.Convert.ToDecimal(f);
                double  doubleValue  = System.Convert.ToDouble(decimalValue);

                float   f2            = Properties.Settings.Default.x;
                decimal decimalValue2 = System.Convert.ToDecimal(f2);
                double  doubleValue2  = System.Convert.ToDouble(decimalValue2);

                float   f3            = Properties.Settings.Default.y;
                decimal decimalValue3 = System.Convert.ToDecimal(f3);
                double  doubleValue3  = System.Convert.ToDouble(decimalValue3);

                float   f4            = Properties.Settings.Default.q;
                decimal decimalValue4 = System.Convert.ToDecimal(f4);
                double  doubleValue4  = System.Convert.ToDouble(decimalValue4);

                float Nrez = Properties.Settings.Default.Cn * float.Parse((Math.Pow(double.Parse(speedZ.Text.Replace(".", ",")), doubleValue)).ToString()) * float.Parse((Math.Pow(double.Parse(glubinaT.Text.Replace(".", ",")), doubleValue2)).ToString()) * float.Parse(Math.Pow(S, doubleValue3).ToString()) * float.Parse((Math.Pow(double.Parse(diam.Text.Replace(".", ",")), doubleValue4).ToString()));

                float Nshp = float.Parse(d.Rows[0][4].ToString()) * float.Parse(d.Rows[0][5].ToString());

                float Lpx1 = float.Parse(dlina.Text) + 0.2f * Bk;
                float Lpx2 = float.Parse(dlina.Text) + 0.4f * Bk;
                float kk   = 0;
                if (charachter.SelectedIndex == 0 || charachter.SelectedIndex == 3)
                {
                    kk = 1.1f;
                }
                else
                {
                    kk = 1.4f;
                }
                float Tm1 = 0;
                float Tm2 = 0;

                Tm1 = (2 * Lpx1 * float.Parse(pripusk.Text.Replace(".", ",")) * kk) / (NzRdy * (float)S * float.Parse(glubinaT.Text.Replace(".", ",")));
                Tm2 = (2 * Lpx2 * float.Parse(pripusk.Text.Replace(".", ",")) * kk) / (NzRdy * (float)S * float.Parse(glubinaT.Text.Replace(".", ",")));


                Properties.Settings.Default.Nrez         = Math.Round(Nrez, 1);
                Properties.Settings.Default.Nshp         = Math.Round(Nshp, 1);
                Properties.Settings.Default.ProdolPodach = Math.Truncate(S).ToString();
                Properties.Settings.Default.ChastotaZ    = Math.Truncate(NzRdy).ToString();
                Properties.Settings.Default.ChastotaK    = Math.Truncate(NkRdy).ToString();
                Properties.Settings.Default.SkorostStola = Math.Round(Vst, 1).ToString();
                Properties.Settings.Default.Tm1          = Math.Round(Tm1, 1);
                Properties.Settings.Default.Tm2          = Math.Round(Tm2, 1);
                Properties.Settings.Default.charkText    = charkText.Text;
                Properties.Settings.Default.indexZText   = indexZText.Text;
                Properties.Settings.Default.struktText   = struktText.Text;

                RezhimiNaruzh rn = new RezhimiNaruzh();
                rn.ShowDialog();
            }
        }
Exemple #2
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            RezhimiNaruzh rn = new RezhimiNaruzh();

            rn.Show();
        }