private void buttonDelete_Click(object sender, EventArgs e) //DELETE Button in Update Info Panel
        {
            MemberTableDataContext mi = new MemberTableDataContext(strCon);

            try
            {
                var x = from a in mi.Members
                        where a.Id == int.Parse(textBox_Up_Id.Text)
                        select a;
                //Lamda Expression

                foreach (Member m in x)
                {
                    mi.Members.DeleteOnSubmit(m);
                }

                mi.SubmitChanges();
                //UpdateGridView();
                MessageBox.Show("Success!");
            }
            catch
            {
                MessageBox.Show("Unsuccessful!");
            }
        }
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            MemberTableDataContext mi = new MemberTableDataContext(strCon);

            try
            {
                Member mt = new Member
                {
                    Id          = int.Parse(textBox_Id.Text),
                    Name        = textName.Text,
                    Age         = textBox_Age.Text,
                    Gender      = comboBox_Gender.Text,
                    Height      = textHeight.Text,
                    Weight      = textWeight.Text,
                    Contact     = textContact.Text,
                    Batch       = comboBatch.Text,
                    Member_Type = comboMember.Text,
                    Fees_Mode   = comboFees.Text
                };
                if (int.Parse(textBox_Age.Text) < 100 && int.Parse(textBox_Age.Text) > 0)
                {
                    mi.Members.InsertOnSubmit(mt);
                    mi.SubmitChanges();
                    MessageBox.Show("Success!");
                }
                else
                {
                    MessageBox.Show("Please input a valid age!");
                }
            }
            catch
            {
                MessageBox.Show("Error!");
            }
        }
        private void buttonUpdate_Click(object sender, EventArgs e) //Update Button in Update Info Panel
        {
            MemberTableDataContext mi = new MemberTableDataContext(strCon);

            if (textBox_Up_Id.Text != "")
            {
                try
                {
                    var x = from a in mi.Members
                            where a.Id == int.Parse(textBox_Up_Id.Text)
                            select a;
                    x.First().Id          = int.Parse(textBox_Up_Id.Text);
                    x.First().Name        = textBox_Up_name.Text;
                    x.First().Gender      = comboBox_Up_Gen.Text;
                    x.First().Age         = textBox_Up_Age.Text;
                    x.First().Height      = textBox_Up_Height.Text;
                    x.First().Weight      = textBox_Up_Weight.Text;
                    x.First().Contact     = textBox_Up_Contact.Text;
                    x.First().Batch       = comboBox_Up_batch.Text;
                    x.First().Member_Type = comboBox_Up_Mem.Text;
                    x.First().Fees_Mode   = comboBox_Up_Fees.Text;

                    mi.SubmitChanges();
                    dataGrid_Update_List.DataSource = x.ToList();
                }
                catch
                {
                    MessageBox.Show("Invalid Entry!");
                }
            }
            else
            {
                MessageBox.Show("Input ID First!");
            }
        }
        private void buttonDelete_Click(object sender, EventArgs e) //DELETE Button in Update Info Panel
        {
            MemberTableDataContext mi = new MemberTableDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject v2.0\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30");

            try
            {
                var x = from a in mi.Members
                        where a.Id == int.Parse(textBox_Up_Id.Text)
                        select a;
                //Lamda Expression

                foreach (Member m in x)
                {
                    mi.Members.DeleteOnSubmit(m);
                }

                mi.SubmitChanges();
                //UpdateGridView();
                MessageBox.Show("Success!");
            }
            catch
            {
                MessageBox.Show("Unsuccessful!");
            }
        }
        private void buttonUpdate_Click(object sender, EventArgs e) //Update Button in Update Info Panel
        {
            MemberTableDataContext mi = new MemberTableDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject v2.0\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30");

            if (textBox_Up_Id.Text != "")
            {
                try
                {
                    var x = from a in mi.Members
                            where a.Id == int.Parse(textBox_Up_Id.Text)
                            select a;
                    x.First().Id          = int.Parse(textBox_Up_Id.Text);
                    x.First().Name        = textBox_Up_name.Text;
                    x.First().Gender      = comboBox_Up_Gen.Text;
                    x.First().Age         = textBox_Up_Age.Text;
                    x.First().Height      = textBox_Up_Height.Text;
                    x.First().Weight      = textBox_Up_Weight.Text;
                    x.First().Contact     = textBox_Up_Contact.Text;
                    x.First().Batch       = comboBox_Up_batch.Text;
                    x.First().Member_Type = comboBox_Up_Mem.Text;
                    x.First().Fees_Mode   = comboBox_Up_Fees.Text;

                    mi.SubmitChanges();
                    dataGrid_Update_List.DataSource = x.ToList();
                }
                catch
                {
                    MessageBox.Show("Invalid Entry!");
                }
            }
            else
            {
                MessageBox.Show("Input ID First!");
            }
        }
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            MemberTableDataContext mi = new MemberTableDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30");

            try
            {
                Member mt = new Member
                {
                    Id          = int.Parse(textBox_Id.Text),
                    Name        = textName.Text,
                    Age         = textBox_Age.Text,
                    Gender      = comboBox_Gender.Text,
                    Height      = textHeight.Text,
                    Weight      = textWeight.Text,
                    Contact     = textContact.Text,
                    Batch       = comboBatch.Text,
                    Member_Type = comboMember.Text,
                    Fees_Mode   = comboFees.Text
                };
                if (int.Parse(textBox_Age.Text) < 100 && int.Parse(textBox_Age.Text) > 0)
                {
                    mi.Members.InsertOnSubmit(mt);
                    mi.SubmitChanges();
                    MessageBox.Show("Success!");
                }
                else
                {
                    MessageBox.Show("Please input a valid age!");
                }
            }
            catch
            {
                MessageBox.Show("Error!");
            }
        }
        //-----------------------------------END OF MEMBER INFO-----------------------------------------



        //--------------------------------------UPDATE MEMBER-------------------------------------------

        private void b3_Click(object sender, EventArgs e)//Update Frame button
        {
            MemberTableDataContext m = new MemberTableDataContext(strCon);

            dataGrid_Update_List.DataSource = m.Members;

            panel_Mem_Info.Visible         = false;
            panel_Purchase_Product.Visible = false;
            panel_Home.Visible             = false;
            panel_AddMem.Visible           = false;
            panel_Update_Member.Visible    = true;
            panel_Admin.Visible            = false;
        }
        //-----------------------------------END OF ADD MEMBER-----------------------------------------



        //--------------------------------------MEMBER INFO---------------------------------------------


        private void b1_Click(object sender, EventArgs e)
        {
            panel_Mem_Info.Visible         = true;
            panel_Home.Visible             = false;
            panel_Purchase_Product.Visible = false;
            panel_AddMem.Visible           = false;
            panel_Update_Member.Visible    = false;
            panel_Admin.Visible            = false;

            MemberTableDataContext m = new MemberTableDataContext(strCon);

            dataGridView1.DataSource = m.Members;
        }
        //-----------------------------------END OF MEMBER INFO-----------------------------------------



        //--------------------------------------UPDATE MEMBER-------------------------------------------

        private void b3_Click(object sender, EventArgs e)//Update Frame button
        {
            MemberTableDataContext m = new MemberTableDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject v2.0\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30");

            dataGrid_Update_List.DataSource = m.Members;

            panel_Mem_Info.Visible         = false;
            panel_Purchase_Product.Visible = false;
            panel_Home.Visible             = false;
            panel_AddMem.Visible           = false;
            panel_Update_Member.Visible    = true;
            panel_Admin.Visible            = false;
        }
        private void buttonLoad_Click(object sender, EventArgs e) //REFRESH Button in Update info Panel
        {
            MemberTableDataContext mi = new MemberTableDataContext(strCon);

            dataGrid_Update_List.DataSource = mi.Members;

            textBox_Up_Id.Text                                        =
                textBox_Up_name.Text                                  =
                    comboBox_Up_Gen.Text                              =
                        textBox_Up_Age.Text                           =
                            textBox_Up_Height.Text                    =
                                textBox_Up_Weight.Text                =
                                    textBox_Up_Contact.Text           =
                                        comboBox_Up_batch.Text        =
                                            comboBox_Up_Mem.Text      =
                                                comboBox_Up_Fees.Text = string.Empty;
        }
        private void buttonLoad_Click(object sender, EventArgs e) //REFRESH Button in Update info Panel
        {
            MemberTableDataContext mi = new MemberTableDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject v2.0\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30");

            dataGrid_Update_List.DataSource = mi.Members;

            textBox_Up_Id.Text                                        =
                textBox_Up_name.Text                                  =
                    comboBox_Up_Gen.Text                              =
                        textBox_Up_Age.Text                           =
                            textBox_Up_Height.Text                    =
                                textBox_Up_Weight.Text                =
                                    textBox_Up_Contact.Text           =
                                        comboBox_Up_batch.Text        =
                                            comboBox_Up_Mem.Text      =
                                                comboBox_Up_Fees.Text = string.Empty;
        }
        private void buttonMemSearch_Click(object sender, EventArgs e)//SEARCH button in Update info Panel
        {
            MemberTableDataContext mi = new MemberTableDataContext(strCon);

            try
            {
                if (int.Parse(textBox_Up_Id.Text) >= 0)
                {
                    var x = from a in mi.Members
                            where a.Id == int.Parse(textBox_Up_Id.Text)
                            select a;

                    {
                        textBox_Up_name.Text    = x.FirstOrDefault().Name;
                        comboBox_Up_Gen.Text    = x.First().Gender;
                        textBox_Up_Age.Text     = x.First().Age;
                        textBox_Up_Height.Text  = x.First().Height;
                        textBox_Up_Weight.Text  = x.First().Weight;
                        textBox_Up_Contact.Text = x.First().Contact;
                        comboBox_Up_batch.Text  = x.First().Batch;
                        comboBox_Up_Mem.Text    = x.First().Member_Type;
                        comboBox_Up_Fees.Text   = x.First().Fees_Mode;

                        dataGrid_Update_List.DataSource = x.ToList();
                    }
                }
                else
                {
                    MessageBox.Show("ID must be positive integer!");
                }
            }

            catch
            {
                MessageBox.Show("Invalid ID!");
            }
        }
        private void buttonMemSearch_Click(object sender, EventArgs e)//SEARCH button in Update info Panel
        {
            MemberTableDataContext mi = new MemberTableDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject v2.0\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30");

            try
            {
                if (int.Parse(textBox_Up_Id.Text) >= 0)
                {
                    var x = from a in mi.Members
                            where a.Id == int.Parse(textBox_Up_Id.Text)
                            select a;

                    {
                        textBox_Up_name.Text    = x.FirstOrDefault().Name;
                        comboBox_Up_Gen.Text    = x.First().Gender;
                        textBox_Up_Age.Text     = x.First().Age;
                        textBox_Up_Height.Text  = x.First().Height;
                        textBox_Up_Weight.Text  = x.First().Weight;
                        textBox_Up_Contact.Text = x.First().Contact;
                        comboBox_Up_batch.Text  = x.First().Batch;
                        comboBox_Up_Mem.Text    = x.First().Member_Type;
                        comboBox_Up_Fees.Text   = x.First().Fees_Mode;

                        dataGrid_Update_List.DataSource = x.ToList();
                    }
                }
                else
                {
                    MessageBox.Show("ID must be positive integer!");
                }
            }

            catch
            {
                MessageBox.Show("Invalid ID!");
            }
        }
        private void buttonRefresh_Click(object sender, EventArgs e)
        {
            MemberTableDataContext mi = new MemberTableDataContext(strCon);

            dataGridView1.DataSource = mi.Members;
        }
        private void buttonRefresh_Click(object sender, EventArgs e)
        {
            MemberTableDataContext mi = new MemberTableDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Study\Sem 8\OOP2 (C#)\Final\Project\FinalTermProject v2.0\FinalTermProject\FinalTermProject\Admindata.mdf;Integrated Security=True;Connect Timeout=30");

            dataGridView1.DataSource = mi.Members;
        }