コード例 #1
0
 public static void UpdateTraining(TrainingClass Tr)
 {
     Conn.Open();
     string Query = String.Format("Update [dbo].[Trainings] set Day='{0}', Hour='{1}' ,Trainer_id={2}, Name='{3}' where Id={4}", Tr.GetDay(), Tr.GetHour(), Tr.GetTrainerId(), Tr.GetTrainingName(), Tr.GetTrainingId());
     command = new SqlCommand(Query, Conn);
     command.ExecuteNonQuery();
     Conn.Close();
 }
コード例 #2
0
 public static void InsertNewTraining(TrainingClass Tr)
 {
     Conn.Open();
     string Query = String.Format("Insert into [dbo].[Trainings](Day,Hour,Trainer_id,Name) values ('{0}','{1}',{2},'{3}')", Tr.GetDay(), Tr.GetHour(), Tr.GetTrainerId(),Tr.GetTrainingName());
     command = new SqlCommand(Query, Conn);
     command.ExecuteNonQuery();
     Conn.Close();
 }
コード例 #3
0
 public static bool IsFree(TrainingClass Tr)
 {
     Conn.Open();
     string query = String.Format("Select count(*) from [dbo].[Trainings] where Day='{0}' and Hour={1} ", Tr.GetDay(),Tr.GetHour());
     command = new SqlCommand(query, Conn);
     int x = Convert.ToInt32(command.ExecuteScalar());
     Conn.Close();
     if (x >= 1)
         return false;
     return true;
 }
コード例 #4
0
 public static int GetTrainingIdFromDB(TrainingClass Tr)
 {
     Conn.Open();
     string query = String.Format("Select Id from [dbo].[Trainings] where Day='{0}' and Hour='{1}'", Tr.GetDay(), Tr.GetHour());
     command = new SqlCommand(query, Conn);
     int x = Convert.ToInt32(command.ExecuteScalar());
        Conn.Close();
        return x;
 }