private void UploadGradeBtn_Click(object sender, EventArgs e)
        {
            this.Hide();
            UploadGrade UG = new UploadGrade(uid);

            UG.Show();
        }
        private void ConfirmBtn_Click(object sender, EventArgs e)
        {
            con.Open();

            cmd = new SqlCommand("Insert into Grade(gsid,gcid,grade,marks) values (@s,@c,@g,@m)", con);
            // cmd3 = new SqlCommand("select * from Grade");

            cmd.Parameters.AddWithValue("@s", (Convert.ToInt32(IdBox.Text)));
            cmd.Parameters.AddWithValue("@c", SubjBox.Text.ToString());
            cmd.Parameters.AddWithValue("@g", (Convert.ToInt32(comboBox1.SelectedIndex)));
            cmd.Parameters.AddWithValue("@m", (Convert.ToSingle(MarkBox.Text)));

            cmd.ExecuteNonQuery();
            //MessageBox.Show("Grade uploaded  succesfully");
            int ass = Convert.ToInt32(comboBox1.SelectedIndex);

            con2.Open();

            cmd3 = new SqlCommand("Select Credits, cgpa from student where sid=(@data)", con2);
            cmd3.Parameters.AddWithValue("@data", (Convert.ToInt32(IdBox.Text)));
            int?  c = null;
            float?g = null;

            using (SqlDataReader oReader = cmd3.ExecuteReader())
            {
                while (oReader.Read())
                {
                    if (oReader["Credits"].Equals(DBNull.Value))
                    {
                        c = null;
                    }
                    else
                    {
                        c = Convert.ToInt32(oReader["Credits"]);
                    }
                    if (oReader["cgpa"].Equals(DBNull.Value))
                    {
                        g = null;
                    }
                    else
                    {
                        g = Convert.ToSingle(oReader["cgpa"]);
                    }
                }
            }

            if (c.Equals(null))
            {
                c = 0;
                c = c + 3;
            }
            else
            {
                c = c + 3;
            }

            if (g.Equals(null))
            {
                if (ass == 0)
                {
                    g = 4;
                }
                else if (ass == 1)
                {
                    g = Convert.ToSingle(3.8);
                }
                else if (ass == 2)
                {
                    g = Convert.ToSingle(3.6);
                }
                else
                {
                    g = 0;
                }
            }
            else
            {
                if (ass == 0)
                {
                    g = g - 0;
                }
                else if (ass == 1)
                {
                    g = Convert.ToSingle(g - .2);
                }
                else if (ass == 2)
                {
                    g = Convert.ToSingle(g - .4);
                }
                else
                {
                    g = Convert.ToSingle(g - .8);;
                }
            }

            //cmd1.ExecuteNonQuery();



            con.Close();

            con2.Open();

            cmd4 = new SqlCommand("Update student set Credits= (@sal), cgpa= (@edu) where sid= (@tid)", con2);
            cmd4.Parameters.AddWithValue("@tid", (Convert.ToInt32(IdBox.Text)));
            cmd4.Parameters.AddWithValue("@sal", c);
            cmd4.Parameters.AddWithValue("@edu", g);
            //cmd.Parameters.AddWithValue("@edu", nat);
            //cmd.Parameters.AddWithValue("@dob1", dateTimePicker1.Text);

            cmd4.ExecuteNonQuery();

            MessageBox.Show("Uploaded");
            this.Visible = false;
            UploadGrade form = new UploadGrade(s);

            form.Show();
        }