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 InsertStage(StagesClass St)
 {
     Conn.Open();
     string query = String.Format("Insert into [dbo].[Stages](NumberOfSets,NumberOfExercices,TypeOfExercices,Training_Id,TypeOfStage) values({0},{1},{2},{3},'{4}')",St.GetNumberOfSets(),St.GetNumberOfExercices(),St.GetTypeOfExercice(),St.GetTrainingId(),St.GetTypeOfStage());
     command = new SqlCommand(query, Conn);
     command.ExecuteNonQuery();
     Conn.Close();
 }
 public static void UpdateStage(StagesClass St)
 {
     Conn.Open();
     string query = String.Format("Update [dbo].[Stages] set NumberOfSets={0}, NumberOfExercices={1},TypeOfExercices={2} where Training_Id={3} and TypeOfStage='{4}'", St.GetNumberOfSets(), St.GetNumberOfExercices(), St.GetTypeOfExercice(), St.GetTrainingId(), St.GetTypeOfStage());
     command = new SqlCommand(query, Conn);
     command.ExecuteNonQuery();
     Conn.Close();
 }
 public static StagesClass GetStageByTrainingIdAndType(int TrainigId, string StageType)
 {
     StagesClass St = new StagesClass();
     Conn.Open();
     string query = String.Format("Select * from [dbo].[Stages] where Training_id={0} and TypeOfStage='{1}'", TrainigId, StageType);
     command = new SqlCommand(query, Conn);
     SqlDataReader reader = command.ExecuteReader();
     while (reader.Read())
     {
         St = new StagesClass(Convert.ToInt32(reader["Id"]), Convert.ToInt32(reader["NumberOfSets"]), Convert.ToInt32(reader["NumberOfExercices"]), Convert.ToInt32(reader["TypeOfExercices"]), Convert.ToInt32(reader["Training_id"]), reader["TypeOfStage"].ToString());
     }
     Conn.Close();
     return St;
 }