protected void Button1_Click(object sender, EventArgs e)
        {
            Member aMember = new Member();
            aMember.Number = memberNoTextBox.Text;

               int  memberId = memberManager.GatMemberId(aMember);

            borrowedBookDropDownList.DataSource = memberManager.GetBookId(memberId);
            borrowedBookDropDownList.DataTextField = "Title";
            borrowedBookDropDownList.DataBind();
        }
        protected void saveButton_Click(object sender, EventArgs e)
        {
            Member aMember = new Member();
            aMember.Number = numberTextBox.Text;
            aMember.Name = nameTextBox.Text;
            if(memberManager.IfNymberExists(aMember)){
                msgMemberLabel.Text = "Sorry, Member already exists.";
                return;
            }

            msgMemberLabel.Text = memberManager.SaveMember(aMember);
        }
 public string SaveMember(Member aMember)
 {
     int value = memberGateway.SaveMember(aMember);
     if (value > 0)
     {
         return "This Member has been saved.";
     }
     else
     {
         return "Sorry! Member saved failed.";
     }
 }
        protected void returnButton_Click(object sender, EventArgs e)
        {
            Member aMember = new Member();
            aMember.Number = memberNoTextBox.Text;
               int memberid= memberManager.GatMemberId(aMember);

               if (memberManager.ReturnBook(memberid))
               {
               return;
               }
               else
               {
               return;
               }
        }
        public int GetMemberId(Member aMember)
        {
            int id = 0;
            string query = "SELECT * FROM Member_tbl WHERE Number='" + aMember.Number + "'";
            SqlConnection connection = new SqlConnection(connectionString);

            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            while(reader.Read()){
                id = int.Parse(reader["Id"].ToString());
            }
            return id;
        }
        protected void borrowButton_Click(object sender, EventArgs e)
        {
            Member aMember = new Member();

            aMember.Number = memberNoTextBox.Text;
            int memberid = memberManager.GatMemberId(aMember);
            int bookId = int.Parse(bookDropDownList.SelectedValue);

            if(!memberManager.IfNymberExists(aMember)){
                msgBorrowLabel.Text = "Sorry, member number does not exists.";
                return;
            }

            memberManager.SaveBorrowBook(memberid, bookId);
            msgBorrowLabel.Text = "This Book is borrowed by member whose number is:"+aMember.Number;
        }
        public bool IfNumberExist(Member aMember)
        {
            string query = "SELECT * FROM Member_tbl WHERE Number='" + aMember.Number + "'";
            SqlConnection connection = new SqlConnection(connectionString);

            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            if (reader.Read())
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public int SaveMember(Member aMember)
        {
            string query = "INSERT INTO Member_tbl Values('" +aMember.Number + "','" + aMember.Name + "')";
            SqlConnection connection = new SqlConnection(connectionString);

            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            int rowAffect = command.ExecuteNonQuery();
            connection.Close();

            return rowAffect;
        }
 public bool IfNymberExists(Member aMember)
 {
     return memberGateway.IfNumberExist(aMember);
 }
 public int GatMemberId(Member aMember)
 {
     return memberGateway.GetMemberId(aMember);
 }