Ejemplo n.º 1
0
        private void comboBox1_TextChanged(object sender, EventArgs e)
        {
            Connect_to_sql conn = new Connect_to_sql();
            string connect_string = conn.Con_str();
            int sel_povt = (int)((ComboBox)(sender)).SelectedItem;
            string query_ifex = "SELECT kod_data FROM t_data_povt WHERE kod_Glavn=" + ras_param.Glav_ID + " AND povtornost=" + sel_povt;
            int ifexist = conn.ExecQueryWithResult(connect_string, query_ifex);
            if (ifexist != -1)
            {
                TextBox[] stolbec1 = GetTextBoxVesVlazhPochvi();
                TextBox[] stolbec2 = GetTextBoxVesSuhojPochvi();
                TextBox[] stolbec3 = GetTextBoxVesStakan();
                TextBox[] stolbec4 = GetTextBoxPole4();
                TextBox[] stolbec5 = GetTextBoxPole5();
                TextBox[] stolbec6 = GetTextBoxPole6();
                TextBox[] stolbec7 = GetTextBoxPole7();

                Connect_to_sql.AgroDataPovt[] agro_data = new Connect_to_sql.AgroDataPovt[11];
                int kod_st;
                agro_data = conn.SelectFromDataPovt(ras_param.Glav_ID, sel_povt, out kod_st, connect_string);
                for (int i = 0; i < 11; i++)
                {
                    stolbec1[i].Text = conn.ConvertFloatToString(agro_data[i].ves_vlazhnoj);
                    stolbec2[i].Text = conn.ConvertFloatToString(agro_data[i].ves_suhoj);
                    stolbec3[i].Text = conn.ConvertFloatToString(agro_data[i].ves_stakan);
                    stolbec4[i].Text = conn.ConvertFloatToString(agro_data[i].vlazhn_suhaya);
                    stolbec5[i].Text = conn.ConvertFloatToString(agro_data[i].suhaya_stakan);
                    stolbec6[i].Text = conn.ConvertFloatToString(agro_data[i].procent_isparivsh_vlagi);
                    stolbec7[i].Text = conn.ConvertFloatToString(agro_data[i].vlazhnaya_stakan);
                }
                listBox2.SelectedIndex = -1;
                textBox134.Text = "";
                if (kod_st != -1)
                {
                    string[] num_stak = conn.SelectNomerFormStaka(kod_st, connect_string);
                    string name_stak_grup = conn.SelectNameFormStakanGrup(kod_st, connect_string);
                    Label[] num_st = GetLabelNumStakan();
                    for (int i = 0; i < 11; i++)
                    {
                        num_st[i].Text = num_stak[i];
                    }

                    int ii = 0;
                    System.Collections.IEnumerator numerator = listBox2.Items.GetEnumerator();
                    while(numerator.MoveNext())
                    {
                        if (numerator.Current.ToString() == name_stak_grup)
                        {
                            listBox2.SelectedIndex = ii;
                            textBox134.Text = name_stak_grup;
                            break;
                        }
                        else
                        {
                            ii++;
                        }
                    }
                    //int ind = listBox2.Items.GetEnumerator

                }
            }
        }
Ejemplo n.º 2
0
        public void SetDataToTextBoxSredn()
        {
            Connect_to_sql conn = new Connect_to_sql();
            string connect_string = conn.Con_str();
            int kod_razrez;
            if (ras_param.kod_sred != -1)
            {
                Connect_to_sql.AgroDataSredn[] AgroSredn = conn.SelectDataFromDataSredn(ras_param.kod_sred, ras_param.sloj0_5, out kod_razrez, connect_string);
                if (AgroSredn != null)
                {
                    TextBox[] str3 = GetTextBoxStroka3();
                    TextBox[] str4 = GetTextBoxStroka4();
                    TextBox[] str5 = GetTextBoxStroka5();
                    if (ras_param.sloj0_5)
                    {
                        for (int i = 0; i < 11; i++)
                        {
                            str3[i].Text = conn.ConvertFloatToString(AgroSredn[i].stroka3);
                            str4[i].Text = conn.ConvertFloatToString(AgroSredn[i].stroka4);
                            str5[i].Text = conn.ConvertFloatToString(AgroSredn[i].stroka5);
                        }
                    }
                    else
                    {
                        for (int i = 1; i < 11; i++)
                        {
                            str3[i].Text = conn.ConvertFloatToString(AgroSredn[i].stroka3);
                            str4[i].Text = conn.ConvertFloatToString(AgroSredn[i].stroka4);
                            str5[i].Text = conn.ConvertFloatToString(AgroSredn[i].stroka5);
                        }
                    }

                    SqlConnection myConnection = new SqlConnection(connect_string);
                    string myInsertQuery = "SELECT * FROM t_razrez WHERE kod_razrez=" + kod_razrez;
                    SqlCommand myCommand = new SqlCommand(myInsertQuery);
                    myCommand.Connection = myConnection;
                    myConnection.Open();
                    SqlDataReader reader = myCommand.ExecuteReader();
                    TextBox[] TextBoxNum = GetTextBoxOb_massa_pochvi();
                    TextBox[] TextBoxVes = GetTextBoxVl_ustoj_zav();
                    int ii = 0;
                    while (reader.Read())
                    {
                        int ind = listBox1.Items.IndexOf(reader[1].ToString());
                        listBox1.SelectedIndex = ind;
                        textBox133.Text = reader[1].ToString();
                        for (int i = 2; i < 13; i++)
                        {
                            TextBoxNum[ii].Text = reader[i].ToString();
                            ii++;
                        }
                        ii = 0;
                        for (int i = 13; i < 24; i++)
                        {
                            TextBoxVes[ii].Text = reader[i].ToString();
                            ii++;
                        }
                    }
                    myCommand.Connection.Close();
                    TextBox[] stroka5 = GetTextBoxStroka5();
                    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);
                    }

                }
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            int ind_selRow = dataGridView1.CurrentRow.Index;
            Connect_to_sql.AgroNewRaschet edit_ras = new Connect_to_sql.AgroNewRaschet();
            int id_glav = Convert.ToInt32(dataGridView1[0, ind_selRow].Value);
            Connect_to_sql conn = new Connect_to_sql();
            string connect_string = conn.Con_str();
            SqlConnection myConnection = new SqlConnection(connect_string);
            string myInsertQuery = "SELECT     t_Glavnaya.Date, t_Glavnaya.Kod_Polya, t_Naz_poley.Ima_polya, t_Glavnaya.Kod_Sred, t_Glavnaya.Progress, t_Glavnaya.sloj0_5, "
                      + "t_Glavnaya.marshrut "
                      + "FROM         t_Glavnaya INNER JOIN "
                      + "t_Naz_poley ON t_Glavnaya.Kod_Polya = t_Naz_poley.kod_polya "
                      + "WHERE     (t_Glavnaya.Kod =" + id_glav + ")";
            SqlCommand myCommand = new SqlCommand(myInsertQuery);
            myCommand.Connection = myConnection;
            myConnection.Open();
            SqlDataReader reader = myCommand.ExecuteReader();
            while (reader.Read())
            {
                edit_ras.date = Convert.ToDateTime(reader[0]);
                edit_ras.kod_polya = Convert.ToInt32(reader[1]);
                edit_ras.name_polya = Convert.ToString(reader[2]);
                if ((reader[3]).ToString() != "")
                {
                    edit_ras.kod_sred = Convert.ToInt32(reader[3]);
                }
                else
                    edit_ras.kod_sred = -1;
                edit_ras.progress = Convert.ToInt32(reader[4]);
                edit_ras.sloj0_5 = Convert.ToBoolean(reader[5]);
                edit_ras.marshrut = Convert.ToBoolean(reader[6]);
                edit_ras.Glav_ID = id_glav;

            }
            myCommand.Connection.Close();
            Excel.Workbooks excelappworkbooks;
            Excel.Workbook excelappworkbook;
            Excel.Application appl = new Excel.Application();
            appl.Visible = false;
            appl.SheetsInNewWorkbook = edit_ras.progress+1;
            appl.Workbooks.Add(Type.Missing);
            Excel.Sheets excelsheets;
            Excel.Worksheet excelworksheet;
            Excel.Range excelcells;
            excelappworkbooks = appl.Workbooks;
            excelappworkbook = excelappworkbooks[1];
            excelsheets = excelappworkbook.Worksheets;
            string[] polya = {"Слой почвы см", "Масса влажной почвы\n и стаканчика", "Масса сухой почвы\n и стаканчика", "Масса стаканчиков",
                             "Масса испарившейся\n воды", "Масса сухой почвы\n без стаканчика", "Влажность почвы %", "Масса влажной почвы\n без стаканчика"};
            for (int j = 1; j <= edit_ras.progress; j++)
            {
                int sl = 0;

                Connect_to_sql.AgroDataPovt[] agro_data = new Connect_to_sql.AgroDataPovt[11];
                excelworksheet = (Excel.Worksheet)excelsheets.get_Item(j);

                excelcells = excelworksheet.get_Range("A1", "H4");
                excelcells.Merge(Type.Missing);
                excelcells.Font.Bold = true;
                excelcells.Font.Size = 15;
                excelcells.Borders.Weight = 3;
                excelcells.Borders.Value = 1;
                excelcells.HorizontalAlignment = Excel.Constants.xlCenter;
                excelcells.VerticalAlignment = Excel.Constants.xlCenter;
                excelcells.Value2 = "Отчет по " + j.ToString() + "й повторности\n Дата:" + edit_ras.date.ToLongDateString();
                if(edit_ras.sloj0_5)
                    excelcells = excelworksheet.get_Range("A7", "H17");
                else
                    excelcells = excelworksheet.get_Range("A7", "H16");
                excelcells.HorizontalAlignment = Excel.Constants.xlCenter;
                excelcells.VerticalAlignment = Excel.Constants.xlCenter;
                excelcells.Borders.Weight = 2;
                excelcells.Borders.Value = 1;

                for (int i = 1; i < 9; i++)
                {
                    excelcells = (Excel.Range)excelworksheet.Cells[6, i];
                    excelcells.Borders.Weight = 2;
                    excelcells.Orientation = 90;
                    excelcells.HorizontalAlignment = Excel.Constants.xlCenter;
                    excelcells.VerticalAlignment = Excel.Constants.xlCenter;
                    excelcells.Font.Size = 9;
                    excelcells.NumberFormat = "@";
                    excelcells.Borders.Value = 1;
                    excelcells.Value2 = polya[i - 1];
                }
                bool tr = false;
                int col;
                if (edit_ras.sloj0_5)
                    col = 0;
                else
                    col = 1;

                string query_ifex = "SELECT kod_data FROM t_data_povt WHERE kod_Glavn=" + edit_ras.Glav_ID + " AND povtornost=" + j;
                int ifexist = conn.ExecQueryWithResult(connect_string, query_ifex);
                if (ifexist != -1)
                {
                    int kod_st; //неиспользуемае переменная, нужна для работы функции
                    agro_data = conn.SelectFromDataPovt(edit_ras.Glav_ID, j,out kod_st, connect_string);
                    for (int i = col; i < 11; i++)
                    {

                        if (i == 0)
                        {
                            excelcells = (Excel.Range)excelworksheet.Cells[i + 7 - col, 1];
                            excelcells.NumberFormat = "@";
                            excelcells.Value2 = sl.ToString() + " - " + (sl + 5).ToString();
                            sl += 5;
                            tr = true;
                        }
                        else
                        {
                            excelcells = (Excel.Range)excelworksheet.Cells[i + 7 - col, 1];
                            excelcells.NumberFormat = "@";

                            if (tr)
                            {
                                excelcells.Value2 = sl.ToString() + " - " + (sl + 5).ToString();
                                sl += 5;
                                tr = false;
                            }
                            else
                            {
                                excelcells.Value2 = sl.ToString() + " - " + (sl + 10).ToString();
                                sl += 10;
                            }
                        }

                        excelcells = (Excel.Range)excelworksheet.Cells[i + 7 - col, 2];
                        excelcells.Value2 = conn.ConvertFloatToString(agro_data[i].ves_vlazhnoj);
                        excelcells = (Excel.Range)excelworksheet.Cells[i + 7 - col, 3];
                        excelcells.Value2 = conn.ConvertFloatToString(agro_data[i].ves_suhoj);
                        excelcells = (Excel.Range)excelworksheet.Cells[i + 7 - col, 4];
                        excelcells.Value2 = conn.ConvertFloatToString(agro_data[i].ves_stakan);
                        excelcells = (Excel.Range)excelworksheet.Cells[i + 7 - col, 5];
                        excelcells.Value2 = conn.ConvertFloatToString(agro_data[i].vlazhn_suhaya);
                        excelcells = (Excel.Range)excelworksheet.Cells[i + 7 - col, 6];
                        excelcells.Value2 = conn.ConvertFloatToString(agro_data[i].suhaya_stakan);
                        excelcells = (Excel.Range)excelworksheet.Cells[i + 7 - col, 7];
                        excelcells.Value2 = conn.ConvertFloatToString(agro_data[i].procent_isparivsh_vlagi);
                        excelcells = (Excel.Range)excelworksheet.Cells[i + 7 - col, 8];
                        excelcells.Value2 = conn.ConvertFloatToString(agro_data[i].vlazhnaya_stakan);
                    }
                }
            }
            if (edit_ras.kod_sred != -1)
            {
                int kod_sred;
                Connect_to_sql.AgroDataSredn[] agro_sred = conn.SelectDataFromDataSredn(edit_ras.kod_sred,edit_ras.sloj0_5,out kod_sred,connect_string);
                excelworksheet = (Excel.Worksheet)excelsheets.get_Item(edit_ras.progress+1);

                string name_r = "";

                myConnection = new SqlConnection(connect_string);
                myInsertQuery = "SELECT * FROM t_razrez WHERE kod_razrez=" + kod_sred;
               myCommand = new SqlCommand(myInsertQuery);
                myCommand.Connection = myConnection;
                myConnection.Open();
                reader = myCommand.ExecuteReader();
                //Connect_to_sql.AgroRazrez[] raz = new Connect_to_sql.AgroRazrez[11];
                int ii = 0;
                string[,] raz = new string[2,11];
                while (reader.Read())
                {
                    name_r = reader[1].ToString();
                    for (int i = 2; i < 13; i++)
                    {
                        raz[0,ii] = reader[i].ToString();
                        ii++;
                    }
                    ii = 0;
                    for (int i = 13; i < 24; i++)
                    {
                        raz[1, ii] = reader[i].ToString();
                        ii++;
                    }
                }
                myCommand.Connection.Close();

                            string[] polya_2 = {"Слой","Объемная масса почвы", "Влажность устойчивого\nзавядание", "Расчитанная влажность\n%","Запасы влаги\nв мм.", "Запасы влаги\nнарастающим итогом"};
                int sl = 0;
                if(edit_ras.sloj0_5)
                    excelcells = excelworksheet.get_Range("A1", "L3");
                else
                    excelcells = excelworksheet.get_Range("A1", "K3");
                excelcells.Merge(Type.Missing);
                excelcells.Font.Bold = true;
                excelcells.Font.Size = 15;
                excelcells.Borders.Weight = 3;
                excelcells.Borders.Value = 1;
                excelcells.HorizontalAlignment = Excel.Constants.xlCenter;
                excelcells.VerticalAlignment = Excel.Constants.xlCenter;
                excelcells.Value2 = "Отчет по по запасам влаги, на " + edit_ras.date.ToLongDateString();
                if(edit_ras.sloj0_5)
                    excelcells = excelworksheet.get_Range("A4", "L9");
                else
                    excelcells = excelworksheet.get_Range("A4", "K9");
                excelcells.HorizontalAlignment = Excel.Constants.xlCenter;
                excelcells.VerticalAlignment = Excel.Constants.xlCenter;
                excelcells.Borders.Weight = 2;
                excelcells.Borders.Value = 1;

                for (int i = 4; i < 10; i++)
                {
                    excelcells = (Excel.Range)excelworksheet.Cells[i, 1];
                    excelcells.Borders.Weight = 2;
                    //excelcells.Orientation = 90;
                    excelcells.HorizontalAlignment = Excel.Constants.xlLeft;
                    excelcells.VerticalAlignment = Excel.Constants.xlCenter;
                    excelcells.Font.Size = 9;
                    excelcells.NumberFormat = "@";
                    excelcells.Borders.Value = 1;
                    excelcells.Value2 = polya_2[i - 4];
                    excelcells.ColumnWidth = 20;
                }
                bool tr = false;
                int col;
                if (edit_ras.sloj0_5)
                    col = 0;
                else
                    col = 1;

                    for (int i = col; i < 11; i++)
                    {

                        if (i == 0)
                        {
                            excelcells = (Excel.Range)excelworksheet.Cells[4,i + 2 - col];
                            excelcells.NumberFormat = "@";
                            excelcells.Value2 = sl.ToString() + " - " + (sl + 5).ToString();
                            sl += 5;
                            tr = true;
                        }
                        else
                        {
                            excelcells = (Excel.Range)excelworksheet.Cells[4,i + 2 - col];
                            excelcells.NumberFormat = "@";

                            if (tr)
                            {
                                excelcells.Value2 = sl.ToString() + " - " + (sl + 5).ToString();
                                sl += 5;
                                tr = false;
                            }
                            else
                            {
                                excelcells.Value2 = sl.ToString() + " - " + (sl + 10).ToString();
                                sl += 10;
                            }
                        }
                        excelcells = (Excel.Range)excelworksheet.Cells[5, i + 2 - col];
                        excelcells.Value2 = raz[0, i];
                        excelcells = (Excel.Range)excelworksheet.Cells[6, i + 2 - col];
                        excelcells.Value2 = raz[1, i];

                        excelcells = (Excel.Range)excelworksheet.Cells[7, i + 2 - col];
                        excelcells.Value2 = conn.ConvertFloatToString(agro_sred[i].stroka3);
                        excelcells = (Excel.Range)excelworksheet.Cells[8, i + 2 - col];
                        excelcells.Value2 = conn.ConvertFloatToString(agro_sred[i].stroka4);
                        excelcells = (Excel.Range)excelworksheet.Cells[9, i + 2 - col];
                        excelcells.Value2 = conn.ConvertFloatToString(agro_sred[i].stroka5);
                    }
                    float[] val = new float[10];
                    for (int k = 0; k < 10; k++)
                    {
                        val[k] = agro_sred[k+1].stroka5;
                    }
                    Form1 f_owner = (Form1)this.Owner;
                    string[] step_t = new string[7];
                    step_t[0] = "Почвенная засуха сильная";
                    step_t[1] = "Почвенная засуха слабая";
                    step_t[2] = "Недостаточное увлажнение сильное";
                    step_t[3] = "Недостаточное увлажнение слабое";
                    step_t[4] = "Оптимальное увлажнение";
                    step_t[5] = "Избыточное увлажнение";
                    step_t[6] = "Заболачивание";

                    Connect_to_sql.ResultStepUvl[] res_step = conn.GetResultStepUvl(val, name_r, connect_string);
                    for (int k = 12; k < 17; k++)
                    {
                        for (int p = 1; p < 9; p++)
                        {
                            excelcells = (Excel.Range)excelworksheet.Cells[k, p];
                            excelcells.Merge(Type.Missing);
                            excelcells.Font.Bold = true;
                            excelcells.Font.Size = 10;
                            excelcells.Borders.Weight = 2;
                            excelcells.Borders.Value = 1;
                            excelcells.HorizontalAlignment = Excel.Constants.xlLeft;
                            excelcells.VerticalAlignment = Excel.Constants.xlCenter;
                        }
                    }
                    excelcells = excelworksheet.get_Range("A11", "h12");
                    excelcells.Merge(Type.Missing);
                    excelcells.Font.Bold = true;
                    excelcells.Font.Size = 15;
                    excelcells.Borders.Weight = 3;
                    excelcells.Borders.Value = 1;
                    excelcells.HorizontalAlignment = Excel.Constants.xlCenter;
                    excelcells.VerticalAlignment = Excel.Constants.xlCenter;
                    excelcells.Value2 = "Степень увлажнения почвы по слоям";

                    excelcells = excelworksheet.get_Range("a13", "b13");
                    excelcells.Merge(Type.Missing);
                    excelcells.Value2 = "Слой 0-10";
                    excelcells = excelworksheet.get_Range("c13", "h13");
                    excelcells.Merge(Type.Missing);
                    excelcells.Value2 = step_t[res_step[0].znachenie];

                    excelcells = excelworksheet.get_Range("a14", "b14");
                    excelcells.Merge(Type.Missing);
                    excelcells.Value2 = "Слой 0-20";
                    excelcells = excelworksheet.get_Range("c14", "h14");
                    excelcells.Merge(Type.Missing);
                    excelcells.Value2 = step_t[res_step[1].znachenie];

                    excelcells = excelworksheet.get_Range("a15", "b15");
                    excelcells.Merge(Type.Missing);
                    excelcells.Value2 = "Слой 0-50";
                    excelcells = excelworksheet.get_Range("c15", "h15");
                    excelcells.Merge(Type.Missing);
                    excelcells.Value2 = step_t[res_step[4].znachenie];

                    excelcells = excelworksheet.get_Range("a16", "b16");
                    excelcells.Merge(Type.Missing);
                    excelcells.Value2 = "Слой 0-100";
                    excelcells = excelworksheet.get_Range("c16", "h16");
                    excelcells.Merge(Type.Missing);
                    excelcells.Value2 = step_t[res_step[9].znachenie];

            }

            appl.Visible = true;
        }