Browse Source

вывод в лист бокс с запросами через for

chernyshyov.2000 4 years ago
parent
commit
e55ec3ca81
1 changed files with 56 additions and 5 deletions
  1. 56 5
      testkonkurs1/Form3.cs

+ 56 - 5
testkonkurs1/Form3.cs

@@ -39,19 +39,70 @@ namespace testkonkurs1
                 {
                     
                 }
+
+                int[] cod_mesta = new int[20];
+                int[] nomer_comnat = new int[20];
+                String[] lvl_comfort = new String[20];
+                String[] price = new String[20];
+                int i = 0;
                 while (Reader.Read()) {
                     DateTime date_2_start = Convert.ToDateTime(Reader["date_zaezda"]);
                     DateTime date_2_end = date_2_start.AddDays(Convert.ToInt16(Reader["kol_days"]));
                     // bool intersect = !(date_2_end < date_1start || date_2_start > date_1end);
                     bool intersect = date_2_end >= date_1start && date_2_start <= date_1end;
                     if (!intersect) {
-
-           
-                    } 
+                        cod_mesta[i] = Convert.ToInt32( Reader["nomer_mesta"]);
+                        i+=1;
                     }
+                }
+                Reader.Close();
+
+            
                 
-                   
-        }
+                for (int j = 0; j < 20; j++)
+                {
+                    if(cod_mesta[j] != 0)
+                    {
+                        SqlCommand takeMesta = new SqlCommand("SELECT * FROM mesto where cod_mesta = @nomer_mesta", conn);
+                        takeMesta.Parameters.AddWithValue("@nomer_mesta", cod_mesta[j]);
+                        SqlDataReader Mesta = takeMesta.ExecuteReader();
+                        Mesta.Read();
+                        nomer_comnat[j] = Convert.ToInt32( Mesta["nomer_comnat"]);
+                        Mesta.Close();
+                    }
+                }
+
+                for (int j = 0; j < 20; j++)
+                {
+                    if (nomer_comnat[j] != 0)
+                    {
+                        SqlCommand takeMesta = new SqlCommand("SELECT * FROM nomera where nomer_comnat = @nomer_mesta", conn);
+                        takeMesta.Parameters.AddWithValue("@nomer_mesta", nomer_comnat[j]);
+                        SqlDataReader Mesta = takeMesta.ExecuteReader();
+                        Mesta.Read();
+             
+                        lvl_comfort[j] = Mesta["lvl_comfort"].ToString();
+                        Mesta.Close();
+                    }
+                }
+                for (int j = 0; j < 20; j++)
+                {
+                    if (lvl_comfort[j] != null)
+                    {
+                        SqlCommand takeMesta = new SqlCommand("SELECT * FROM comfort where [lvl-comfort] = @nomer_mesta", conn);
+                        takeMesta.Parameters.AddWithValue("@nomer_mesta", lvl_comfort[j]);
+                        SqlDataReader Mesta = takeMesta.ExecuteReader();
+                        Mesta.Read();
+                        price[j] = (Mesta["price_life"].ToString());
+                        Mesta.Close();
+                    }
+                }
+                for (int j = 0; j < 20; j++)
+                {
+                    listBox1.Items.Add(nomer_comnat[j]+ " " + lvl_comfort[j] + " " + price[j]);
+                }
+
+            }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message.ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Error);