Private Sub bsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bsave.Click
Dim k As Integer
If TabPage1.Focus Then
gg:
If govercard.SelectedIndex = -1 Then
MsgBox("يجب عليك ادخال الاسم ", MsgBoxStyle.Information, "name is required")
govercard.Focus()
End If
If govercard.SelectedIndex <> -1 Then
dasg.SelectCommand.CommandText = "select max(TrackOwnerNumber) from tSalesGovernorate"
dssg.Clear()
dasg.Fill(dssg)
k = Convert.ToInt64(dssg.Tables(0).Rows(0)(0)) + 1
dasg.InsertCommand.CommandText = "INSERT INTO tSalesGovernorate (TrackOwnerNumber, " & _
"TrackOwnerName,Address,Phone,MotorNumber,ShasyahNumber,TrackBoardNumber,Transportations,TrackType,TrackMark,DeviceNumber,SetupCardNumber,SensitiveType,MayaraNumber,TrackRoadLine)" & _
"values(" & k & "," & _
"'" & oname.Text & "'," & _
"'" & oaddress.Text & "'," & _
"'" & ophone.Text & "'," & _
"'" & mnumber.Text & "'," & _
"'" & shnumber.Text & "'," & _
"'" & tbnumber.Text & "'," & _
"'" & trans.Text & "'," & _
"'" & ttype.Text & "'," & _
"'" & tmark.Text & "'," & _
"'" & devnumber.Text & "'," & _
"'" & scnumber.Text & "'," & _
"'" & sentype.Text & "'," & _
"'" & numberm.Text & "'," & _
"'" & trline.Text & "')"
If dasg.SelectCommand.CommandText = "select IDdevice from tDevices where IDdevice=devnumber.Text" Then
MsgBox("انتبه رقم الجهاز مكرر", , "رسالة تنبيه")
GoTo gg
ElseIf dasg.SelectCommand.CommandText = "select IDdevice from tDevices where devnumber.Text between (min(IDdevice) and max(IDdevice))" Then
MsgBox("انتبه رقم الجهاز خارج الرقام التسلسلية", , "رسالة تنبيه")
GoTo gg
Else
GoTo ww
End If
If dasg.SelectCommand.CommandText = "select IDreceipt from tCardS where IDreceipt=scnumber.Text" Then
MsgBox("انتبه رقم الايصال مكرر", , "رسالة تنبيه")
GoTo gg
ElseIf dasg.SelectCommand.CommandText = "select IDreceipt from tCardS where scnumber.Text between (min(IDreceipt) and max(IDreceipt))" Then
MsgBox("انتبه رقم الايصال خارج الرقام التسلسلية", , "رسالة تنبيه")
GoTo gg
Else
GoTo ww
End If
ww:
sq1.Open()
dasg.InsertCommand.ExecuteNonQuery()
sq1.Close()
MsgBox("تم الحفظ", , "رسالة حفظ")
Else
dasg.SelectCommand.CommandText = "select max(TrackOwnerNumber) from tSalesGovernorate"
k = Convert.ToInt64(dssg.Tables(0).Rows(0)(0)) + 1
dasg.UpdateCommand.CommandText = _
"UPDATE tSalesGovernorate SET TrackOwnerName=" & _
"'" & oname.Text & "'," & _
"Address = '" & oaddress.Text & "'," & _
"Phone = '" & ophone.Text & "'," & _
"MotorNumber = '" & mnumber.Text & "'," & _
"ShasyahNumber = '" & shnumber.Text & "'," & _
"TrackBoardNumber = '" & tbnumber.Text & "'," & _
"Transportations = '" & trans.Text & "'," & _
"TrackType = '" & ttype.Text & "'," & _
"TrackMark = '" & tmark.Text & "'," & _
"DeviceNumber = '" & devnumber.Text & "'," & _
"SetupCardNumber = '" & scnumber.Text & "'," & _
"SensitiveType = '" & sentype.Text & "'," & _
"MayaraNumber = '" & numberm.Text & "'," & _
"TrackRoadLine = '" & trline.Text & "' " & _
"WHERE TrackOwnerNumber= " & k & ";"
If dasg.SelectCommand.CommandText = "select IDdevice from tDevices where IDdevice=devnumber.Text" Then
MsgBox("انتبه رقم الجهاز مكرر", , "رسالة تنبيه")
GoTo gg
ElseIf dasg.SelectCommand.CommandText = "select IDdevice from tDevices where devnumber.Text between (min(IDdevice) and max(IDdevice))" Then
MsgBox("انتبه رقم الجهاز خارج الرقام التسلسلية", , "رسالة تنبيه")
GoTo gg
Else
GoTo ww
End If
If dasg.SelectCommand.CommandText = "select IDreceipt from tCardS where IDreceipt=scnumber.Text" Then
MsgBox("انتبه رقم الايصال مكرر", , "رسالة تنبيه")
GoTo gg
ElseIf dasg.SelectCommand.CommandText = "select IDreceipt from tCardS where scnumber.Text between (min(IDreceipt) and max(IDreceipt))" Then
MsgBox("انتبه رقم الايصال خارج الرقام التسلسلية", , "رسالة تنبيه")
GoTo gg
Else
GoTo nn
End If
nn:
sq1.Open()
dasg.UpdateCommand.ExecuteNonQuery()
sq1.Close()
MsgBox("قد تم التعديل بنجاح", , "رسالة تعديل")
End If
ElseIf TabPage2.Focus Then
If iddev.Text = "" Then
dade.SelectCommand.CommandText = "select max(IDdevice) from tDevices"
dsde.Clear()
dade.Fill(dsde)
k = Convert.ToInt64(dsde.Tables(0).Rows(0)(0)) + 1
dade.InsertCommand.CommandText = "INSERT INTO tDevices (IDdevice, " & _
"DateRec)" & _
"values(" & k & "," & _
"'" & DateTimePicker2.Text & "')"
sq1.Open()
dasg.InsertCommand.ExecuteNonQuery()
sq1.Close()
iddev.Text = k
MsgBox("تم الحفظ", , "رسالة حفظ")
Else
dade.SelectCommand.CommandText = "select max(IDdevice) from tDevices"
k = Convert.ToInt64(dsde.Tables(0).Rows(0)(0)) + 1
dade.UpdateCommand.CommandText = _
"UPDATE tDevices SET DateRec=" & _
"'" & DateTimePicker2.Text & "'," & _
"WHERE IDdevice= " & k & ";"
sq1.Open()
dasg.UpdateCommand.ExecuteNonQuery()
sq1.Close()
MsgBox("قد تم التعديل بنجاح", , "رسالة تعديل")
End If
ElseIf TabPage3.Focus Then
If idreceipt.Text = "" Then
dacs.SelectCommand.CommandText = "select max(IDreceipt) from tCardS"
dscs.Clear()
dacs.Fill(dscs)
k = Convert.ToInt64(dscs.Tables(0).Rows(0)(0)) + 1
dacs.InsertCommand.CommandText = "INSERT INTO tCardS (IDreceipt, " & _
"DAterec)" & _
"values(" & k & "," & _
"'" & DateTimePicker3.Text & "')"
sq1.Open()
dacs.InsertCommand.ExecuteNonQuery()
sq1.Close()
idreceipt.Text = k
MsgBox("تم الحفظ")
Else
dacs.SelectCommand.CommandText = "select max(IDreceipt) from tCardS"
k = Convert.ToInt64(dscs.Tables(0).Rows(0)(0)) + 1
dacs.UpdateCommand.CommandText = _
"UPDATE tCardS SET DAterec=" & _
"'" & DateTimePicker3.Text & "'," & _
"WHERE IDreceipt= " & k & ";"
sq1.Open()
dasg.UpdateCommand.ExecuteNonQuery()
sq1.Close()
MsgBox("قد تم التعديل بنجاح", , "رسالة تعديل")
End If
Else
End If
End Sub
في Oct 22, 2007 23:50، قال وسام البهنسي بهدوء وتؤدة:
لست متأكداً من الخطأ لأن الـ exception لا يقدم أي شرح مفيد (تباً له). لكن يمكننا على الأقل تجريب بعض الأمور:في Oct 22, 2007 23:50، عقد وسام البهنسي حاجبيه بتفكير وقال:
1- هل ينجح التنفيذ للعبارةوفي Oct 22, 2007 23:50، قال وسام البهنسي متحمساً:
2- وإن كنت أشك بهذه النقطة، لكن هل من الممكن تجريب تعبئة DataSet object جديدة بدلاً من تنظيف الـ dssg وإعادة تعبئتها ثانية؟