09-10-12, 05:50 PM
كاتب الموضوع : egyption-coder
الكلاس سهل و بسيط و لا يحتاج لشرح و اى سؤال انا جاهز للأجابةكود :
Imports System.IO
Imports System.Data.OleDb
Public Class hassan
Public filestreamDist As String = "C:\surgery\dist.txt"
Public costnmlabel As String
Dim fs As New IO.FileStream(filestreamDist, FileMode.Open)
Dim sr As New IO.StreamReader(fs)
Public datasorc As String = sr.ReadLine
Public con As New OleDb.OleDbConnection
Public intmsg As Integer
Public checins As Integer
Public PASS As Integer
Public SelectedFildes(30) As String
Public empin As String
'-----------------------------------
Public Sub OpenConniction()
sr.Close()
fs.Close()
Try
con.ConnectionString = (("provider=microsoft.jet.oledb.4.0" & ";data source=" & datasorc & ";user id=admin;jet oledb:database password=26327446"))
If con.State = ConnectionState.Closed Then
con.Open()
End If
Catch Exoledb As OleDb.OleDbException
Dim message As String
Dim se As OleDb.OleDbError
For Each se In Exoledb.Errors
Select Case se.Message
Case 17
message = "Wrong Server Name"
Case 4060
message = "Wrong DataBase Name"
Case 18456
message = "Wrong User ID Or PSSWORD"
Case Else
message = se.Message
End Select
MessageBox.Show(message)
Exit Sub
Next
Catch ex As Exception
End Try
End Sub
Public Sub CloaseConniction()
If con.State = ConnectionState.Open Or con.State = ConnectionState.Connecting Then
con.Close()
End If
End Sub
Public Sub ins(ByVal str As String)
If checins = 1 Then
Exit Sub
End If
OpenConniction()
Dim has As String
Try
has = str
'--------------------------------------------------------------
Dim cuaav As OleDb.OleDbCommand
cuaav = New OleDb.OleDbCommand(has, con)
cuaav.ExecuteNonQuery()
con.Close()
'-----------------------------------------------------
Catch ex As Exception
MsgBox(ex.Message)
con.Close()
End Try
checins = 0
MsgBox("تم الأدخال بنجاح")
End Sub
Public Sub inschek(ByVal strc As String, ByVal strmsg As String)
Dim rdr As Integer
OpenConniction()
Try
Dim insss As String
insss = strc
Dim cu As OleDb.OleDbCommand
cu = New OleDb.OleDbCommand(insss, con)
Dim dr As OleDb.OleDbDataReader
dr = cu.ExecuteReader()
While (dr.Read())
rdr = dr.GetValue(0)
Exit While
End While
dr.Close()
'-----------------------------------------------------
Catch ex As Exception
MsgBox(ex.Message)
con.Close()
End Try
'----------------------------------------------------------
If rdr > 0 Then
con.Close()
intmsg = MsgBox(strmsg, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
checins = 1
Else
checins = 0
End If
End Sub
Public Sub SelectCommand(ByVal CommandString As String, ByVal ParameterName() As String, ByVal ParametersValues() As String)
OpenConniction()
Dim cmd As New OleDbCommand(CommandString, con)
Dim ii As Integer
For ii = 0 To ParameterName.Length - 1
cmd.Parameters.AddWithValue(ParameterName(ii), ParametersValues(ii))
Next
Try
Dim dr As OleDb.OleDbDataReader
Dim nn As Integer
dr = cmd.ExecuteReader()
While (dr.Read())
For nn = 0 To dr.FieldCount - 1
SelectedFildes(nn) = dr.GetValue(nn)
Next
End While
dr.Close()
'-----------------------------------------------------
Catch ex As Exception
MsgBox("please insert a sutable valu")
con.Close()
End Try
End Sub
Public Sub ClearTextBox(ByVal root As Control)
For Each ctrl As Control In root.Controls
ClearTextBox(ctrl)
If TypeOf ctrl Is TextBox Then
CType(ctrl, TextBox).Text = String.Empty
End If
Next ctrl
End Sub
Public Sub CloseForm(ByVal root As Control, ByVal fname As String)
For Each ctrl As Control In root.Controls
CloseForm(ctrl, fname)
If TypeOf ctrl Is Form AndAlso ctrl.Name <> fname Then
ctrl.Hide()
End If
Next ctrl
End Sub
' ClearTextBox(Me)
End Class