Example #1
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            Connect_to_sql conn = new Connect_to_sql();
            string connect_string = conn.Con_str();
            float[] SrednVl = conn.GetSrednPovtorn(ras_param.Glav_ID, ras_param.sloj0_5, ras_param.marshrut, connect_string);
            TextBox[] stroka1 = GetTextBoxOb_massa_pochvi();
            TextBox[] stroka2 = GetTextBoxVl_ustoj_zav();
            TextBox[] stroka3 = GetTextBoxStroka3();
            TextBox[] stroka4 = GetTextBoxStroka4();
            TextBox[] stroka5 = GetTextBoxStroka5();
            Connect_to_sql.AgroDataSredn[] DataSred = new Connect_to_sql.AgroDataSredn[11];

            for (int i = 0; i < 11; i++)
            {
                stroka3[i].Text = conn.ConvertFloatToString(SrednVl[i]);
            }
            if (!ras_param.sloj0_5)
            {
                for (int i = 1; i < 11; i++)
                {
                    float str3 = conn.ConvertStringToFloat(stroka3[i].Text,1);
                    float str2 = conn.ConvertStringToFloat(stroka2[i].Text,2);
                    float str1 = conn.ConvertStringToFloat(stroka1[i].Text,2);
                    float srt_rez = (str3 - str2) * str1;
                    stroka4[i].Text = conn.ConvertFloatToString(conn.RoundTo(srt_rez, 1));
                }
                stroka5[1].Text = stroka4[1].Text;
                for (int i = 2; i < 11; i++)
                {
                    stroka5[i].Text = conn.ConvertFloatToString(conn.RoundTo((conn.ConvertStringToFloat(stroka5[i - 1].Text, 1) + conn.ConvertStringToFloat(stroka4[i].Text, 1)), 1));
                }
                for (int i = 1; i < 11; i++)
                {
                    DataSred[i].stroka3 = conn.ConvertStringToFloat(stroka3[i].Text,1);
                    DataSred[i].stroka4 = conn.ConvertStringToFloat(stroka4[i].Text,1);
                    DataSred[i].stroka5 = conn.ConvertStringToFloat(stroka5[i].Text,1);
                }
                conn.AddRowToSredn(DataSred, ras_param.sloj0_5, ras_param.Glav_ID, textBox133.Text, connect_string);

            }
            else
            {
                for (int i = 0; i < 11; i++)
                {
                    float str3 = conn.ConvertStringToFloat(stroka3[i].Text,1);
                    float str2 = conn.ConvertStringToFloat(stroka2[i].Text,2);
                    float str1 = conn.ConvertStringToFloat(stroka1[i].Text,2);
                    float srt_rez = (str3 - str2) * str1;
                    stroka4[i].Text = conn.ConvertFloatToString(conn.RoundTo(srt_rez, 1));
                }
                stroka4[0].Text = conn.ConvertFloatToString(conn.RoundTo((conn.ConvertStringToFloat(stroka4[0].Text, 1) / 2), 1));
                stroka4[1].Text = conn.ConvertFloatToString(conn.RoundTo((conn.ConvertStringToFloat(stroka4[1].Text, 1) / 2), 1));
                stroka5[0].Text = stroka4[0].Text;
                for (int i = 1; i < 11; i++)
                {
                    stroka5[i].Text = conn.ConvertFloatToString(conn.RoundTo((conn.ConvertStringToFloat(stroka5[i - 1].Text, 1) + conn.ConvertStringToFloat(stroka4[i].Text, 1)), 1));
                }
                for (int i = 0; i < 11; i++)
                {
                    DataSred[i].stroka3 = conn.ConvertStringToFloat(stroka3[i].Text, 1);
                    DataSred[i].stroka4 = conn.ConvertStringToFloat(stroka4[i].Text, 1);
                    DataSred[i].stroka5 = conn.ConvertStringToFloat(stroka5[i].Text, 1);
                }
                conn.AddRowToSredn(DataSred, ras_param.sloj0_5, ras_param.Glav_ID, textBox133.Text, connect_string);
            }
            float[] val = new float[10];
            for (int i = 0; i < 10; i++)
            {
                val[i] = conn.ConvertStringToFloat(stroka5[i + 1].Text, 1);
            }
            Connect_to_sql.ResultStepUvl[] res_step = conn.GetResultStepUvl(val, textBox133.Text, connect_string);
               /* for (int i = 0; i < 10; i++)
            {
                if(res_step[i].color!=0)
                stroka5[i + 1].BackColor = Color.FromArgb(res_step[i].color);
            }*/
            if (res_step[0].color != 0)
            {
                textBox137.BackColor = Color.FromArgb(res_step[0].color);
            }
            if (res_step[1].color != 0)
            {
                textBox138.BackColor = Color.FromArgb(res_step[1].color);
            }
            if (res_step[4].color != 0)
            {
                textBox139.BackColor = Color.FromArgb(res_step[4].color);
            }
            if (res_step[9].color != 0)
            {
                textBox140.BackColor = Color.FromArgb(res_step[9].color);
            }
        }