1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43:
| private void fnSaveNewRecord() { try { string strInsert; strInsert = "insert into PersonTable" + "(FirstName, LastName, Title, City,Country)" + " values('" + this.textboxFirstname.Text + "', '" + this.textboxLastname.Text + "', '" + this.textboxTitle.Text + "', '" + this.textboxCity.Text + "', '" + this.textboxCountry.Text + "')"; if (this.textboxFirstname.Text !="" && this.textboxLastname.Text !=""&& this.textboxTitle.Text !="" && this.textboxCity.Text !="" && this.textboxCountry.Text !="") { this.oleDbDataAdapter1.InsertCommand.CommandText = strInsert; this.oleDbDataAdapter1.InsertCommand.ExecuteNonQuery(); fnGetLastPersonID(); fnEnableButtonsNextPreviousLastFirst(true); fnEnableToolbarButtons(true, "Edit"); fnEnableToolbarButtons(true, "Delete"); fnEnableToolbarButtons(false, "Save"); this.fnEnableDisableTextBox(false); }else { MessageBox.Show("You have to fill the TextBoxes...", "WARNING", MessageBoxButtons.OK,MessageBoxIcon.Warning); this.textboxFirstname.Focus(); } } catch (Exception ex) { MessageBox.Show("Error in inserting new record : " + ex.Message, "Insert Error", MessageBoxButtons.OK, MessageBoxIcon.Information); fnRefreshDataSet(); } } |