Beispiel #1
0
        public AgroStepUlv[] SelectRowFrom_Step_Ulv(int razrez, string myConnectionString)
        {
            AgroStepUlv[] step_uvl = new AgroStepUlv[7];
            for (int i = 0; i < 7; i++)
            {
                step_uvl[i].ball = new float[4];
                step_uvl[i].val_do = new float[4];
                step_uvl[i].val_ot = new float[4];
            }
            string query_sel = "SELECT * FROM t_Step_uvlachnen WHERE razrez=" + razrez.ToString();
            SqlConnection myConnection = new SqlConnection(myConnectionString);
            SqlCommand myCommand = new SqlCommand(query_sel);
            myCommand.Connection = myConnection;
            myConnection.Open();
            SqlDataReader reader = myCommand.ExecuteReader();
            int ii=0;

            while (reader.Read())
            {
                int jj = 0;
                step_uvl[ii].znachenie = Convert.ToInt32(reader["znachenie_uvl"]);
                for (int i = 3; i < 15; i = i + 3)
                {
                    step_uvl[ii].val_ot[jj] = ConvertStringToFloat(reader[i].ToString(),1);
                    step_uvl[ii].val_do[jj] = ConvertStringToFloat(reader[i+1].ToString(), 1);
                    step_uvl[ii].ball[jj] = ConvertStringToFloat(reader[i+2].ToString(), 1);
                    jj++;
                }
                ii++;
            }
            myCommand.Connection.Close();
            return step_uvl;
        }
Beispiel #2
0
        public void AddRowTo_Step_Ulv(AgroStepUlv[] Step_uvl, int razrez, string myConnectionString)
        {
            string query_del_from_uvl = "DELETE FROM t_Step_uvlachnen WHERE razrez=" + razrez.ToString();
            ExecQuery(myConnectionString, query_del_from_uvl);

            for (int i = 0; i < 7; i++)
            {
                string query_add = "INSERT INTO t_Step_uvlachnen(razrez, znachenie_uvl, sloj10_val_ot, sloj10_val_do, sloj10_ball, " +
                    "sloj20_val_ot, sloj20_val_do, sloj20_ball, " +
                    "sloj50_val_ot, sloj50_val_do, sloj50_ball, " +
                    "sloj100_val_ot, sloj100_val_do, sloj100_ball) VALUES(";
                query_add += razrez.ToString() + ",";
                query_add += Step_uvl[i].znachenie;
                for (int j = 0; j < 4; j++)
                {
                    query_add += "," + ConvertFloatToString(Step_uvl[i].val_ot[j]) + "," + ConvertFloatToString(Step_uvl[i].val_do[j]) + "," + ConvertFloatToString(Step_uvl[i].ball[j]);
                }
                query_add += ")";
                ExecQuery(myConnectionString, query_add);
            }
        }