private void refreshbutton2_Click(object sender, EventArgs e)
 {
     nametextBox1.Clear();
     FnametextBox2.Clear();
     MnametextBox3.Clear();
     feestextBox4.Clear();
     phonenotextBox1.Clear();
     addresstextBox5.Clear();
     nametextBox1.Focus();
 }
        private void adddatabutton1_Click(object sender, EventArgs e)
        {
            if (nametextBox1.Text == "" || FnametextBox2.Text == "")
            {
                MessageBox.Show("Error");
            }
            else
            {
                try
                {
                    string          MyConnection2 = "datasource=localhost; username=root;password=; database=mini_school";
                    string          Query         = "insert into `students`(student_name,class,father_name,mother_name,address,admission_fees,phone_no) values('" + this.nametextBox1.Text + "','" + this.comboBox1.SelectedItem.ToString() + "','" + this.FnametextBox2.Text + "','" + this.MnametextBox3.Text + "','" + this.addresstextBox5.Text + "','" + this.feestextBox4.Text + "','" + this.phonenotextBox1.Text + "');";
                    MySqlConnection MyConn2       = new MySqlConnection(MyConnection2);
                    MySqlCommand    MyCommand2    = new MySqlCommand(Query, MyConn2);
                    MySqlDataReader MyReader2;
                    MyConn2.Open();
                    MyReader2 = MyCommand2.ExecuteReader();
                    // MessageBox.Show("Save Data");
                    while (MyReader2.Read())
                    {
                    }
                    MyConn2.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                if (comboBox1.SelectedIndex.ToString() == "0")
                {
                    try
                    {
                        int    x     = 3000;
                        string y     = feestextBox4.Text;
                        int    found = int.Parse(y);

                        string          MyConnection2 = "datasource=localhost; username=root;password=; database=mini_school";
                        string          Query         = "insert into `class_five`(student_name,Due) values('" + this.nametextBox1.Text + "','" + (x - found) + "');";
                        MySqlConnection MyConn2       = new MySqlConnection(MyConnection2);
                        MySqlCommand    MyCommand2    = new MySqlCommand(Query, MyConn2);
                        MySqlDataReader MyReader2;
                        MyConn2.Open();
                        MyReader2 = MyCommand2.ExecuteReader();
                        //MessageBox.Show("Save Data");
                        while (MyReader2.Read())
                        {
                        }
                        MyConn2.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                if (comboBox1.SelectedIndex.ToString() == "1")
                {
                    try
                    {
                        int    x     = 3000;
                        string y     = feestextBox4.Text;
                        int    found = int.Parse(y);

                        string          MyConnection2 = "datasource=localhost; username=root;password=; database=mini_school";
                        string          Query         = "insert into `class_eight`(student_name,Due) values('" + this.nametextBox1.Text + "','" + (x - found) + "');";
                        MySqlConnection MyConn2       = new MySqlConnection(MyConnection2);
                        MySqlCommand    MyCommand2    = new MySqlCommand(Query, MyConn2);
                        MySqlDataReader MyReader2;
                        MyConn2.Open();
                        MyReader2 = MyCommand2.ExecuteReader();
                        //MessageBox.Show("Save Data");
                        while (MyReader2.Read())
                        {
                        }
                        MyConn2.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                if (comboBox1.SelectedIndex.ToString() == "2")
                {
                    try
                    {
                        int    x     = 4000;
                        string y     = feestextBox4.Text;
                        int    found = int.Parse(y);

                        string          MyConnection2 = "datasource=localhost; username=root;password=; database=mini_school";
                        string          Query         = "insert into `class_ten`(student_name,Due) values('" + this.nametextBox1.Text + "','" + (x - found) + "');";
                        MySqlConnection MyConn2       = new MySqlConnection(MyConnection2);
                        MySqlCommand    MyCommand2    = new MySqlCommand(Query, MyConn2);
                        MySqlDataReader MyReader2;
                        MyConn2.Open();
                        MyReader2 = MyCommand2.ExecuteReader();
                        //  MessageBox.Show("Save Data");
                        while (MyReader2.Read())
                        {
                        }
                        MyConn2.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                if (comboBox1.SelectedIndex.ToString() == "3")
                {
                    try
                    {
                        int    x     = 5000;
                        string y     = feestextBox4.Text;
                        int    found = int.Parse(y);

                        string          MyConnection2 = "datasource=localhost; username=root;password=; database=mini_school";
                        string          Query         = "insert into `hsc_batch`(student_name,Due) values('" + this.nametextBox1.Text + "','" + (x - found) + "');";
                        MySqlConnection MyConn2       = new MySqlConnection(MyConnection2);
                        MySqlCommand    MyCommand2    = new MySqlCommand(Query, MyConn2);
                        MySqlDataReader MyReader2;
                        MyConn2.Open();
                        MyReader2 = MyCommand2.ExecuteReader();
                        // MessageBox.Show("Save Data");
                        while (MyReader2.Read())
                        {
                        }
                        MyConn2.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            nametextBox1.Clear();
            FnametextBox2.Clear();
            MnametextBox3.Clear();
            feestextBox4.Clear();
            phonenotextBox1.Clear();
            addresstextBox5.Clear();
            nametextBox1.Focus();
        }