protected void SubmitClick(object sender, EventArgs e)
        {
            UserClass Usr = (UserClass)Session["User"];
            int Time = Convert.ToInt32(HourOT.Value);
            string Day = DayOfTheWeek.SelectedValue.ToString();
            string Name = "TrainingName";
            Name = NameOfTraining.Value.ToString();
            int WarmingNumberOfSets = Convert.ToInt32(WrNOS.Value);
            int WarmingNumverOfExercices = Convert.ToInt32(WrNOE.Value);
            int WarmingExerciceId = Convert.ToInt32(WrTypeOfExercices.SelectedValue);
            int SkillNumberOfSets = Convert.ToInt32(SkNOS.Value);
            int SkillNumberOfExercices = Convert.ToInt32(SkNOE.Value);
            int SkillExerciceId = Convert.ToInt32(SkTypeOfExercices.SelectedValue);
            int WodNumberOfSets = Convert.ToInt32(WodNOS.Value);
            int WodNumberOfExercices = Convert.ToInt32(WodNOE.Value);
            int WodExerciceId = Convert.ToInt32(WodTypeOfExercicies.SelectedValue);

            TrainingClass NewTraining = new TrainingClass(Usr.GetId(), Name, Day, Time);
            if (ConnectionClass.IsFree(NewTraining))
            {
                ConnectionClass.InsertNewTraining(NewTraining);
                int id = ConnectionClass.GetTrainingIdFromDB(NewTraining);
                NewTraining.SetId(id);
                StagesClass Warming = new StagesClass(WarmingNumberOfSets, WarmingNumverOfExercices, WarmingExerciceId, NewTraining.GetTrainingId(), "Warming");
                StagesClass Skill = new StagesClass(SkillNumberOfSets, SkillNumberOfExercices, SkillExerciceId, NewTraining.GetTrainingId(), "Skill");
                StagesClass Wod = new StagesClass(WodNumberOfSets, WodNumberOfExercices, WodExerciceId, NewTraining.GetTrainingId(), "Wod");
                ConnectionClass.InsertStage(Warming);
                ConnectionClass.InsertStage(Skill);
                ConnectionClass.InsertStage(Wod);
                Response.Redirect("Program.aspx");

            }
            else
            { VforTime.Visible = true; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["TId"] == null || !int.TryParse(Request.QueryString["TId"], out TrainingId) || !ConnectionClass.TrainingExists(TrainingId))
            {
                Response.Redirect("Program.aspx");
            }
            UserC = (UserClass)Session["User"];
            Tr = ConnectionClass.GetTrainingById(TrainingId);
            Warming = ConnectionClass.GetStageByTrainingIdAndType(Tr.GetTrainingId(), "Warming");
            Skill = ConnectionClass.GetStageByTrainingIdAndType(Tr.GetTrainingId(), "Skill");
            Wod = ConnectionClass.GetStageByTrainingIdAndType(Tr.GetTrainingId(), "Wod");
            if (Tr.GetTrainerId() != UserC.GetId())
            {
                Response.Redirect("Program.aspx");

            }
            if (!IsPostBack)
                FillPanel();
        }
 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();
 }