コード例 #1
0
 private void Submit_Click(object sender, EventArgs e)
 {
     if (Validate_Form())
     {
         DateTime     today           = DateTime.Today;
         SQL_Operator sql_operator    = new SQL_Operator();
         int          graduation_year = today.Year + 4;
         string       sqlQuery        = null;
         if (YesButton.Checked)
         {
             sqlQuery = "INSERT INTO STUDENT_INFO (usn, name, dob, graduation_year, hostel_id) VALUES ('" + USNBox.Text.ToUpper() + "', '" + NameBox.Text.ToUpper() + "', DATE '" + DOBBox.Text + "', " + graduation_year + ", HOSTEL_ID_SEQUENCE.NEXTVAL)";
         }
         else
         {
             sqlQuery = "INSERT INTO STUDENT_INFO (usn, name, dob, graduation_year) VALUES ('" + USNBox.Text.ToUpper() + "', '" + NameBox.Text.ToUpper() + "', DATE '" + DOBBox.Text + "', " + graduation_year + ")";
         }
         if (sql_operator.Insert(sqlQuery))
         {
             MessageBox.Show("Inserted Entry", "Successful");
             Clear_All_Entries();
         }
         else
         {
             MessageBox.Show("USN Must Be Unique", "Failed");
         }
     }
 }