private void DisplayStudent_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                List <StudentEntityCl> showlist = StudentBALCl.GetAllStudentsBL();
                dataGrid.ItemsSource = showlist;
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void DeleteStudent_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int id = Convert.ToInt32(textBox.Text);

                StudentBALCl.DeleteStudentBL(id);

                MessageBox.Show("Deleted Successfully");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void AddStudent_Click(object sender, RoutedEventArgs e)
        {
            if (!insertready)
            {
                fieldReset();
                int id = StudentBALCl.getNextIdBAL();
                textBox.Text       = id.ToString();
                textBox.IsReadOnly = true;
                insertready        = true;
            }
            else
            {
                try
                {
                    StudentEntityCl entobj = new StudentEntityCl();


                    entobj.STUDENTID       = Convert.ToInt32(textBox.Text);
                    entobj.STUDENTNAME     = textBox1.Text;
                    entobj.CITY            = textBox2.Text;
                    entobj.COURSE          = textBox3.Text;
                    entobj.DATEOFADMISSION = Convert.ToDateTime(DOA.Text);

                    if (StudentBALCl.AddStudentBL(entobj))
                    {
                        MessageBox.Show("Student Successfully Added");
                        insertready        = false;
                        textBox.IsReadOnly = false;
                    }

                    else
                    {
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
        private void Find_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int             flag   = 0;
                int             id     = Convert.ToInt32(textBox.Text);
                StudentEntityCl entobj = StudentBALCl.SearchStudentBL(id);

                List <StudentEntityCl> showlist = StudentBALCl.GetAllStudentsBL();

                for (int index = 0; index < showlist.Count; index++)
                {
                    if (showlist[index].STUDENTID == id)
                    {
                        flag = 1;
                        break;
                    }
                    else
                    {
                        flag = 0;
                    }
                }

                if (flag == 0)
                {
                    MessageBox.Show("No such student found");
                    Environment.Exit(0);
                }

                // MessageBox.Show(entobj.DATEOFADMISSION.ToString());
                textBox1.Text = entobj.STUDENTNAME;
                textBox2.Text = entobj.CITY;
                textBox3.Text = entobj.COURSE;
                DOA.Text      = entobj.DATEOFADMISSION.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void UpdateStudent_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                StudentEntityCl entobj = new StudentEntityCl();

                entobj.STUDENTID       = Convert.ToInt32(textBox.Text);
                entobj.STUDENTNAME     = textBox1.Text;
                entobj.CITY            = textBox2.Text;
                entobj.COURSE          = textBox3.Text;
                entobj.DATEOFADMISSION = Convert.ToDateTime(DOA.Text);



                StudentBALCl.UpdateStudentBL(entobj);
                MessageBox.Show("Student Updated Successfully");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }