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
| Private Sub ButtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtnSave.Click
sql = "select * from gm862"
cmd = New MySqlCommand(sql)
dataadapt = New MySqlDataAdapter(cmd)
datset = New DataSet
cmd.Connection() = cn
dataadapt.Fill(datset, "gm862")
datatab = datset.Tables("gm862")
If txtimei.Text = "" Or cmbxartifact.Text = "" Or cbxsurename.Text = "" Or cbxforename.Text = "" Or cmbxintiallatitude.Text = "" Or cmbxinitiallongitude.Text = "" Or txtcurrentlongitude.Text = "" Or txtcurrentlongitude.Text = "" Or datelab.Text = "" Or timelabuct.Text = "" Then
MsgBox("Please fill in all fields !", MsgBoxStyle.Information, "Information")
Else
datrow = datset.Tables("gm862").NewRow
datrow("refgm862") = txtimei.Text
datrow("artefact") = cmbxartifact.Text
datrow("usersurename") = cbxsurename.Text
datrow("userforename") = cbxforename.Text
datrow("initiallatitude") = CDbl(cmbxintiallatitude.Text)
datrow("initiallongitude") = CDbl(cmbxinitiallongitude.Text)
datrow("currentlattitude") = CDbl(txtcurrentlattitude.Text)
datrow("currentlongitude") = CDbl(txtcurrentlongitude.Text)
datrow("trackingdate") = CDate(datelab.Text)
datrow("trackingtime") = CDate(timelabuct.Text)
datset.Tables("gm862").Rows.Add(datrow)
cmdb = New MySqlCommandBuilder(dataadapt)
dataadapt.Update(datset, "gm862")
datset.Clear()
dataadapt.Fill(datset, "gm862")
datatab = datset.Tables("gm862")
cbxforename.Text = ""
cbxsurename.Text = ""
cmbxartifact.Text = ""
txtimei.Text = ""
cmbxintiallatitude.Text = ""
cmbxinitiallongitude.Text = ""
txtcurrentlongitude.Text = ""
txtcurrentlongitude.Text = ""
datelab.Text = ""
timelabuct.Text = ""
ButnNew.Enabled = True
ButtnSave.Enabled = True
cmbxGM862Findby.Enabled = True
End If |
Partager