コード例 #1
0
 public void DobPrepod(Prepodav prepodav) //добавление преподавателей
 {
     cnn.Open();
     comand             = cnn.CreateCommand();
     comand.CommandText = "INSERT INTO Prepodavateli (Family, Name, Surname, Phone, Stazh) VALUES  (@Family, @Name, @Surname, @Phone, @Stazh)";
     comand.Parameters.AddWithValue("@Family", Convert.ToString(prepodav.dobPredFam.Text));
     comand.Parameters.AddWithValue("@Name", Convert.ToString(prepodav.dobPredName.Text));
     comand.Parameters.AddWithValue("@Surname", Convert.ToString(prepodav.dobPredSurN.Text));
     comand.Parameters.AddWithValue("@Phone", Convert.ToString(prepodav.dobNomerPrep.Text));
     comand.Parameters.AddWithValue("@Stazh", Convert.ToString(prepodav.dobStazhPrep.Text));
     comand.ExecuteNonQuery();
     cnn.Close();
 }
コード例 #2
0
 public void Prepod(Prepodav prepodav)  //загрузка табл преподавателей
 {
     try
     {
         cnn.Open();
         zapros = (" SELECT CONCAT(Family, ' ', Name,' ' , Surname) AS [ФИО], Phone AS [Телефон], Stazh AS [Стаж] FROM Courses.dbo.Prepodavateli");
         SqlDataAdapter    da = new SqlDataAdapter(zapros, cnn);
         SqlCommandBuilder cb = new SqlCommandBuilder(da);
         DataSet           ds = new DataSet();
         da.Fill(ds, "Prepodavateli");
         prepodav.DataPrepodavatel.DataSource = ds.Tables[0];
         cnn.Close();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }