Exemplo n.º 1
0
        public static Tech GetTechDataByID(string id)
        {
            SqlConnection sqlConnection = new SqlConnection(ConnectionAdres);

            Tech       tech       = null;
            SqlCommand nameComand = new SqlCommand($"SELECT * FROM technic WHERE ID = '{id}';", sqlConnection);

            sqlConnection.Open();
            SqlDataReader reader = nameComand.ExecuteReader();

            reader.Read();
            if (reader.HasRows)
            {
                var type           = reader.GetString(1);
                var company        = reader.GetString(2);
                var model          = reader.GetString(3);
                var businessNumber = reader.GetString(4);
                var serialNumber   = reader.GetString(5);

                tech = new Tech {
                    type = type, company = company, model = model, businessNumber = businessNumber, serialNumber = serialNumber
                };
            }
            reader.Close();
            sqlConnection.Close();
            return(tech);
        }
Exemplo n.º 2
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (techID.Text != "")
     {
         Tech tech = Querys.GetTechDataByID(techID.Text);
         if (tech != null)
         {
             typeBox.Text       = tech.type;
             firmBox.Text       = tech.company;
             modelNumber.Text   = tech.model;
             sirialNumber.Text  = tech.serialNumber;
             buisnesNumber.Text = tech.businessNumber;
         }
     }
     else
     {
         errorLabel.Content = "Поле должно быть заполненно";
     }
 }