예제 #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //get the data from textboxes
            S.ID          = int.Parse(txtID.Text);
            S.Lecture1    = cmbSelectLec.Text;
            S.Lecture2    = txtSelectLec.Text;
            S.SubjectCode = txtSubCode.Text;
            S.SubjectName = cmbSelectSubject.Text;
            S.GroupID     = cmbSelectGroup.Text;
            S.Tag         = cmbSelectTag.Text;
            S.NoOfStudent = txtNoStudent.Text;
            S.Duration    = txtDuration.Text;

            //update data in database

            bool success = S.UpdateSession(S);

            if (success == true)
            {
                MessageBox.Show("Successfully Updated.");

                //load data into gridview
                DataTable dt = S.Select();
                dataGridView1.DataSource = dt;
            }
            else
            {
                MessageBox.Show("Failed to Update Details.Try Again.");
            }
        }