/// <summary>
 /// Deprecated Method for adding a new object to the Members EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMembers(Member member)
 {
     base.AddObject("Members", member);
 }
        private void txtId_KeyPress(object sender, KeyPressEventArgs e)
        {
            tslStatus.Text = ""; // reset status if save function work in previous
            tsProgress.Value = 0;

            try
            {
                if (e.KeyChar == (char)13)
                {
                    if (!txtId.Text.Equals(""))
                    {
                        memberId = Convert.ToInt32(txtId.Text);

                        //Use FirstOrDefault instead of First. This will return null in the face of an empty collection.
                        member = context.Members.FirstOrDefault(x => x.MemberID == memberId);
                        if (member != null)
                        {
                            txtName.Text = member.FirstName.ToString() + " " + member.LastName.ToString();

                            list = context.BookLendByMemberSP(memberId).ToList<BookLendByMemberSP_Result>();

                            if (list.Count != 0)
                                dgvBook.DataSource = list;
                            else
                                dgvBook.DataSource = null;
                        }
                        else
                        {
                            txtName.Text = "";
                            dgvBook.DataSource = null;
                        }
                    }
                    else
                    {
                        txtName.Text = "";
                        dgvBook.DataSource = null;
                    }
                }
            }
            catch (Exception a)
            { txtId.Text = ""; }
        }
 /// <summary>
 /// Create a new Member object.
 /// </summary>
 /// <param name="memberID">Initial value of the MemberID property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="address">Initial value of the Address property.</param>
 /// <param name="phoneNo">Initial value of the PhoneNo property.</param>
 public static Member CreateMember(global::System.Int32 memberID, global::System.String firstName, global::System.String lastName, global::System.String email, global::System.String address, global::System.String phoneNo)
 {
     Member member = new Member();
     member.MemberID = memberID;
     member.FirstName = firstName;
     member.LastName = lastName;
     member.Email = email;
     member.Address = address;
     member.PhoneNo = phoneNo;
     return member;
 }