Ejemplo n.º 1
0
 private static void CreateFieldLabelsandText(string sql, bool useData = false)
 {
     using (SqlConnection con = new SqlConnection(connectionString))
     {
         con.Open();
         try
         {
             using (SqlCommand command = new SqlCommand(sql, con))
             {
                 using (SqlDataReader reader = command.ExecuteReader())
                 {
                     for (int i = 0; i < reader.FieldCount; i++)
                     {
                         string field = reader.GetName(i);
                         Label  l     = ControlGenerator.CreateLabel(0, 0, field);
                         tableData.Controls.Add(l);
                         if (useData)
                         {
                             TextBox t = ControlGenerator.CreateTextBox(0, 0, Settings.formWidth - 50, 50);
                             t.Name = "textBox" + field;
                             tableData.Controls.Add(t);
                             tableData.SetFlowBreak(t, true);
                         }
                         else
                         {
                             tableData.SetFlowBreak(l, true);
                         }
                     }
                 }
             }
         }
         catch (SqlException e)
         {
             HandleError(e);
         }
         try
         {
             string f = getPKFromTable.Replace("table", currentTableData);
             using (SqlCommand command = new SqlCommand(f, con))
             {
                 using (SqlDataReader reader = command.ExecuteReader())
                 {
                     reader.Read();
                     PKColumnName = reader.GetString(0);
                 }
             }
         }
         catch (SqlException e)
         {
             HandleError(e);
         }
     }
 }
Ejemplo n.º 2
0
        public override void GenForm()
        {
            ControlGenerator.CreateLabel(10, 10, "Search");
            Button b = ControlGenerator.CreateButton(10, 40, 100, 50, "Back");

            ControlGenerator.BindNavButton(b, new FormMain());
            ControlGenerator.CreateLabel(120, 10, "Select table");
            ComboBox c = ControlGenerator.CreateComboBox(120, 40, 100);

            ControlGenerator.SetComboBoxToTableList(c);
            ControlGenerator.CreateLabel(120, 80, "Select Field");
            ComboBox c2 = ControlGenerator.CreateComboBox(120, 110, 100);

            ControlGenerator.SetComboBoxToFillTableFieldsOfComboBox(c, c2);
            ControlGenerator.CreateLabel(120, 160, "Type search parameters");
            TextBox t = ControlGenerator.CreateTextBox(120, 190, 120, 100);

            b = ControlGenerator.CreateButton(260, 40, 100, 100, "Search");
            ControlGenerator.BindSearch(b, 10, 250, c, c2, t);
            b = ControlGenerator.CreateButton(370, 70, 50, 30, "<");
            ControlGenerator.BindChangeRecord(b, false);
            b = ControlGenerator.CreateButton(420, 70, 50, 30, ">");
            ControlGenerator.BindChangeRecord(b, true);
        }