コード例 #1
0
 public static void AddNewExercice(TypeOfExercicies Ex)
 {
     Conn.Open();
         string query = String.Format("Insert into [dbo].[TypeOfExercices](Name) Values('{0}')", Ex.GetExName());
         command = new SqlCommand(query, Conn);
         command.ExecuteNonQuery();
         Conn.Close();
 }
コード例 #2
0
        protected void AddExerciseButtonClick(object sender, EventArgs e)
        {
            if (NewExerciceName.Value.ToString() != "")
            {
                TypeOfExercicies Ex = new TypeOfExercicies(NewExerciceName.Value.ToString());
                if (!ConnectionClass.ExerciceExists(Ex))
                {
                    ConnectionClass.AddNewExercice(Ex);

                }
                Response.Redirect(Request.RawUrl);

            }
        }
コード例 #3
0
        public static bool ExerciceExists(TypeOfExercicies ex)
        {
            bool Ok = true;

                Conn.Open();
                string query = String.Format("Select count(*) from [dbo].[TypeOfExercices] where Name='{0}'", ex.GetExName());
                command = new SqlCommand(query, Conn);
                if (Convert.ToInt32(command.ExecuteScalar()) >= 1)
                    Ok = true;
                else
                    Ok = false;

                Conn.Close();

            return Ok;
        }
コード例 #4
0
 public static TypeOfExercicies GetExerciceById(int id)
 {
     TypeOfExercicies Ty = new TypeOfExercicies();
     Conn.Open();
     string query = String.Format("Select * from [Dbo].[TypeOfExercices] where Id={0}", id);
     command = new SqlCommand(query, Conn);
     SqlDataReader reader = command.ExecuteReader();
     while(reader.Read())
     {
         Ty = new TypeOfExercicies(Convert.ToInt32(reader["Id"]), reader["Name"].ToString());
     }
     Conn.Close();
     return Ty;
 }
コード例 #5
0
        public static List<TypeOfExercicies> GetTypeOfExercices()
        {
            List<TypeOfExercicies> List = new List<TypeOfExercicies>();
            Conn.Open();
            string query = "Select * from [dbo].[TypeOfExercices]";
            command = new SqlCommand(query, Conn);
            SqlDataReader reader = command.ExecuteReader();
            while(reader.Read())
            {
                TypeOfExercicies Ex = new TypeOfExercicies(Convert.ToInt32(reader["Id"]), reader["Name"].ToString());
                List.Add(Ex);
            }

            Conn.Close();
            return List;
        }