Beispiel #1
0
        //Method for submit the add & update session form
        private void btnAddSession_Click(object sender, EventArgs e)
        {
            //get value from input field
            s.ID          = sessionId.Text;
            s.Faculty     = drpFaculty.Text.Trim();
            s.lecturer1   = drpLec1.Text;
            s.lecturer2   = drpLec2.Text.Trim();
            s.SubjectCode = subArr[1];
            s.SubjectName = subArr[0];
            s.Tag         = drpTag.Text.Trim();
            s.Year        = drpYear.Text.Trim();;
            s.GID         = drpGroupId.Text.Trim();
            s.SubGID      = drpSubGId.Text.Trim();
            s.noOfStu     = numOfStu.Text.Trim();
            s.Duration    = Duration.Text;
            s.Generate    = gSession.Text;

            //Submit the add Session form
            if (btnAddSession.Text == "Submit")
            {
                //inserting data in to database using insertLecturer method

                bool success = s.insertSession(s);

                if (success == true)
                {
                    MessageBox.Show("Session was added Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Somthing went Worng!\n\nCannot insert the value!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                btnAddSession.Visible = false;           //Create one time click button
            }

            //Submit the update session form
            if (btnAddSession.Text == "Update")
            {
                //inserting data in to database using insertsession method
                bool success = s.updatesession(s);

                if (success == true)
                {
                    MessageBox.Show("Update successful" + s.SubjectCode, "Informtion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Update Failed", "Informtion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                btnAddSession.Visible = false;       //Make one time click submit button
            }
        }