private void button10_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtateacherid.Text == "")
         {
             MessageBox.Show("Please Enter Teacher ID", " Student");
         }
         else
         {
             TeaDT = TeaAdapter.SelectTeabyID(Convert.ToInt16(txtateacherid.Text));
             if (TeaDT.Rows.Count > 0)
             {
                 gpteacher.Visible  = true;
                 txtateachname.Text = TeaDT.Rows[0]["TeacherName"].ToString();
                 txtasubject.Text   = TeaDT.Rows[0]["Subject"].ToString();
                 txtaqulif.Text     = TeaDT.Rows[0]["Qulification"].ToString();
             }
             else
             {
                 MessageBox.Show("Invalid Teacher ID", "Student");
                 gpteacher.Visible = false;
             }
         }
     }
     catch (Exception a)
     {
         MessageBox.Show(a.Message.ToString(), "Error !! Student");
     }
 }
        private void pictureBox9_Click(object sender, EventArgs e)
        {
            try
            {
                dgstudent.DataSource    = null;
                dgfess.DataSource       = null;
                dgfess.Visible          = false;
                tbstudent.Visible       = true;
                tbstudent.SelectedIndex = 1;
                CourseDT                = CourseAdapter.SelectCourse();
                cmbscoure.DataSource    = CourseDT;
                cmbscoure.DisplayMember = "CourseName";
                cmbscoure.ValueMember   = "Coursefees";
                cmbscoure.Text          = "SELECT";

                TeaDT = TeaAdapter.select();
                cmmtach.DataSource    = TeaDT;
                cmmtach.DisplayMember = "TeacherName";
                cmmtach.ValueMember   = "ID";
                cmmtach.Text          = "SELECT";

                txtsname.Text  = "";
                lblrecord.Text = "";
            }
            catch (Exception a)
            {
                MessageBox.Show(a.Message.ToString(), "Error!!  Student");
            }
        }
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            try
            {
                dgteacher.DataSource    = null;
                tbstudent.Visible       = true;
                tbstudent.SelectedIndex = 6;

                TeaDT = TeaAdapter.select();
                dgteacher.DataSource = TeaDT;
            }
            catch (Exception a)
            {
                MessageBox.Show(a.Message.ToString(), "Error!!  Student");
            }
        }
        private void tbstudent_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (tbstudent.SelectedIndex == 0)
                {
                    tbstudent.Visible = true;
                    //tbstudent.SelectedIndex = 0;
                    studentclear();
                    CourseDT                = CourseAdapter.SelectCourse();
                    cmbcourse.DataSource    = CourseDT;
                    cmbcourse.DisplayMember = "CourseName";
                    cmbcourse.ValueMember   = "Coursefees";
                    cmbcourse.SelectedIndex = 0;
                }
                else if (tbstudent.SelectedIndex == 1)
                {
                    tbstudent.Visible    = true;
                    dgstudent.DataSource = null;
                    dgfess.DataSource    = null;
                    dgfess.Visible       = false;
                    //tbstudent.SelectedIndex = 1;
                    CourseDT                = CourseAdapter.SelectCourse();
                    cmbscoure.DataSource    = CourseDT;
                    cmbscoure.DisplayMember = "CourseName";
                    cmbscoure.ValueMember   = "Coursefees";
                    cmbscoure.Text          = "SELECT";


                    TeaDT = TeaAdapter.select();
                    cmmtach.DataSource    = TeaDT;
                    cmmtach.DisplayMember = "TeacherName";
                    cmmtach.ValueMember   = "ID";
                    cmmtach.Text          = "SELECT";
                    txtsname.Text         = "";
                    lblrecord.Text        = "";
                }
                else if (tbstudent.SelectedIndex == 2)
                {
                    tbstudent.Visible = true;
                    lblfees.Text      = "";
                    //tbstudent.SelectedIndex = 2;
                    lblfeeerror.Text     = "";
                    gpupdatefees.Visible = false;
                    txtfeeid.Text        = "";
                    txtfeeadd.Text       = "";
                    btnedit.Visible      = false;
                }
                else if (tbstudent.SelectedIndex == 3)
                {
                    lblcourse.Text    = "";
                    tbstudent.Visible = true;
                    // tbstudent.SelectedIndex = 3;
                }
                else if (tbstudent.SelectedIndex == 4)
                {
                    tbstudent.Visible = true;
                    // tbstudent.SelectedIndex = 4;
                    CourseDT            = CourseAdapter.SelectCourse();
                    dgcourse.DataSource = CourseDT;
                }
                else if (tbstudent.SelectedIndex == 5)
                {
                }
                else if (tbstudent.SelectedIndex == 6)
                {
                    dgteacher.DataSource = null;
                    TeaDT = TeaAdapter.select();
                    dgteacher.DataSource = TeaDT;
                }
                else if (tbstudent.SelectedIndex == 7)
                {
                    lblerror.Text = "";

                    if (userid == 1 || userid == 2)
                    {
                        tbadmin.Visible  = true;
                        lblerror.Visible = false;
                        lblerror.Text    = "";
                        txtsid.Text      = "";
                        dgstu.Visible    = false;
                        dgstu.DataSource = null;
                        btndel.Visible   = false;
                    }
                    else
                    {
                        tbadmin.Visible  = false;
                        lblerror.Visible = true;
                        lblerror.Text    = "Sorry !!, You are unable to get this faclity !!";
                    }
                }
            }
            catch (Exception a)
            {
                MessageBox.Show(a.Message.ToString(), "Error!!  Student");
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                int blank = 0;
                if (txtname.Text == "")
                {
                    lblnamee.Visible = true;
                    blank            = 1;
                }
                else
                {
                    lblnamee.Visible = false;
                }
                if (txtsurname.Text == "")
                {
                    lblsurnamee.Visible = true;
                    blank = 1;
                }
                else
                {
                    lblsurnamee.Visible = false;
                }
                if (txtemail.Text == "")
                {
                    lblemaile.Visible = true;
                    blank             = 1;
                }
                else
                {
                    lblemaile.Visible = false;
                }

                if (txtemail.Text.Contains("@") && txtemail.Text.Contains("."))
                {
                    lblemaile.Visible = false;
                }
                else
                {
                    lblemaile.Visible = true;
                    blank             = 1;
                }
                if (txtcontact.Text == "")
                {
                    lblmoe.Visible = true;
                    blank          = 1;
                }
                else
                {
                    lblmoe.Visible = false;
                }

                if (blank == 0)
                {
                    lblmoe.Visible      = false;
                    lblemaile.Visible   = false;
                    lblnamee.Visible    = false;
                    lblsurnamee.Visible = false;
//gpcourse.Visible = true;
                    Drpyear.SelectedItem    = 0;
                    gpcourse.Enabled        = true;
                    CourseDT                = CourseAdapter.SelectCourse();
                    cmbcourse.DataSource    = CourseDT;
                    cmbcourse.DisplayMember = "CourseName";
                    cmbcourse.ValueMember   = "Coursefees";
                    cmbcourse.Text          = "SELECT";

                    TeaDT = TeaAdapter.select();
                    cmbteacher.DataSource    = TeaDT;
                    cmbteacher.DisplayMember = "TeacherName";
                    cmbteacher.ValueMember   = "ID";
                    cmbteacher.Text          = "SELECT";

                    txtfees.Text = "";
                }
            }
            catch (Exception a)
            {
                MessageBox.Show(a.Message.ToString(), "Error!!  Student");
            }
        }