private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(UsefullStrings.GetString());

            con.Open();
            SqlCommand cmd1;

            if (btnAddStudent.Text == "ADD STUDENT")
            {
                try
                {
                    cmd1 = new SqlCommand("insert into student (fname, lname, rollno, email, gender, dob, hobby, vill, pin, hname, dno, semno, cgpa, rmno)" +
                                          "values('" + txtFname.Text + "', '" + txtLname.Text + "', '" + txtRollno.Text + "', '" + txtEmail.Text + "', '" + txtGender.Text + "', '" + txtDob.Text + "','" + txtHobby.Text + "'," +
                                          " '" + txtVill.Text + "', " + txtPin.Text + ", '" + txtHname.Text + "', " + txtDno.Text + ", " + txtSno.Text + ", " + txtCgpa.Text + ", " + txtRmno.Text + ")", con);

                    cmd1.ExecuteNonQuery();
                    LoadData();
                    MessageBox.Show($"{txtRollno.Text} added successfully");
                    ClearFields();
                }

                catch (Exception er)
                {
                    MessageBox.Show(UsefullStrings.ErrorString() + er.Message);
                }

                finally
                {
                    con.Close();
                }
            }

            else
            {
                try
                {
                    cmd1 = new SqlCommand("update student set fname='" + txtFname.Text + "', lname='" + txtLname.Text + "', email='" + txtEmail.Text + "'," +
                                          "gender='" + txtGender.Text + "', dob='" + txtDob.Text + "', hobby='" + txtHobby.Text + "', vill='" + txtVill.Text + "', pin=" + txtPin.Text + "," +
                                          "hname='" + txtHname.Text + "', dno=" + txtDno.Text + ", semno=" + txtSno.Text + ", cgpa=" + txtCgpa.Text + ", rmno=" + txtRmno.Text + " where rollno='" + txtRollno.Text + "'", con);

                    cmd1.ExecuteNonQuery();
                    btnAddStudent.Text = "ADD STUDENT";
                    LoadData();
                    MessageBox.Show($"Information of {txtRollno.Text} updated successfully");
                    ClearFields();
                }

                catch (Exception er)
                {
                    MessageBox.Show(UsefullStrings.ErrorString() + er.Message);
                }

                finally
                {
                    con.Close();
                }
            }
        }
        private void btnAddClist_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(UsefullStrings.GetString());

            con.Open();
            SqlCommand cmd1;

            if (btnAddClist.Text == "ADD")
            {
                try
                {
                    cmd1 = new SqlCommand("insert into course values('" + txtCname.Text + "', '" + txtCcodeCL.Text + "'," +
                                          " " + txtCredit.Text + ", " + txtDnoCl.Text + ")", con);

                    cmd1.ExecuteNonQuery();
                    CourseListClr();
                    LoadCourseList();
                }

                catch (Exception er)
                {
                    MessageBox.Show(UsefullStrings.ErrorString() + er.Message);
                }

                finally
                {
                    con.Close();
                }
            }

            else
            {
                try
                {
                    cmd1 = new SqlCommand("update course set cname='" + txtCname.Text + "', credit=" + txtCredit.Text + "," +
                                          "dno=" + txtDnoCl.Text + " where ccode='" + txtCcodeCL.Text + "'", con);
                    cmd1.ExecuteNonQuery();
                    //MessageBox.Show("updated");
                    CourseListClr();
                    btnAddClist.Text = "ADD";
                    LoadCourseList();
                }

                catch (Exception er)
                {
                    MessageBox.Show(er.Message);
                }

                finally
                {
                    con.Close();
                }
            }
        }
        private void btnAddDlist_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(UsefullStrings.GetString());

            con.Open();
            SqlCommand cmd1;

            if (btnAddDlist.Text == "ADD")
            {
                try
                {
                    cmd1 = new SqlCommand("insert into department values('" + txtDname.Text + "', " + txtDnoDl.Text + ")", con);

                    cmd1.ExecuteNonQuery();
                    DeptListClr();
                    LoadDeptList();
                }

                catch (Exception er)
                {
                    MessageBox.Show(UsefullStrings.ErrorString() + er.Message);
                }

                finally
                {
                    con.Close();
                }
            }

            else
            {
                try
                {
                    cmd1 = new SqlCommand("update department set dname='" + txtDname.Text + "' where dno=" + txtDnoDl.Text + "", con);
                    cmd1.ExecuteNonQuery();
                    DeptListClr();
                    btnAddDlist.Text = "ADD";
                    LoadDeptList();
                }

                catch (Exception er)
                {
                    MessageBox.Show(er.Message);
                }

                finally
                {
                    con.Close();
                }
            }
        }
        private void btnAddStudent_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(UsefullStrings.GetString());

            con.Open();
            SqlCommand cmd1;

            if (btnAddCourse.Text == "ADD")
            {
                try
                {
                    cmd1 = new SqlCommand("insert into takes values('" + txtRollno.Text + "', '" + txtCcodeAc.Text + "')", con);
                    cmd1.ExecuteNonQuery();
                    txtCcodeAc.Text = "";
                    LoadAddCourse();
                }

                catch (Exception er)
                {
                    MessageBox.Show(UsefullStrings.ErrorString() + er.Message);
                }

                finally
                {
                    con.Close();
                }
            }

            else
            {
                try
                {
                    cmd1 = new SqlCommand("delete from takes where rollno='" + txtRollno.Text + "' and ccode='" + txtCcodeAc.Text + "'", con);
                    cmd1.ExecuteNonQuery();
                    LoadAddCourse();
                    AddCourseClr();
                    btnAddCourse.Text = "ADD";
                }
                catch (Exception er)
                {
                    MessageBox.Show(er.Message);
                }
                finally
                {
                    con.Close();
                }
            }
        }