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(); }
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(); }
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; }
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; }