Esempio n. 1
0
        //ini bagian coach
        public int doInsertCoach(Coach acc)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("insert into Coach(Coachname, Coachgender, Coachaddress, Coachphonenumber) values(@name, @gender, @address, @phone)", con);

            cmd.Parameters.AddWithValue("@name", acc.Name);
            cmd.Parameters.AddWithValue("@gender", acc.Gender);
            cmd.Parameters.AddWithValue("@address", acc.Address);
            cmd.Parameters.AddWithValue("@phone", acc.Phone);

            int result = cmd.ExecuteNonQuery();

            if (result == 1)
            {
                con.Close();
                return(1);
            }
            else
            {
                con.Close();
                return(0);
            }
        }
Esempio n. 2
0
        public int doUpdateCoach(Coach acc)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("update Coach set Coachname=@name, Coachgender=@gender, Coachaddress=@address, Coachphonenumber=@phone where id=@id", con);

            cmd.Parameters.AddWithValue("@name", acc.Name);
            cmd.Parameters.AddWithValue("@gender", acc.Gender);
            cmd.Parameters.AddWithValue("@address", acc.Address);
            cmd.Parameters.AddWithValue("@phone", acc.Phone);
            cmd.Parameters.AddWithValue("@id", acc.Id);

            int result = cmd.ExecuteNonQuery();

            if (result == 1)
            {
                con.Close();
                return(1);
            }
            else
            {
                con.Close();
                return(0);
            }
        }