20-05-13, 06:05 PM (آخر تعديل لهذه المشاركة : 21-05-13, 11:02 AM {2} بواسطة kshadi71.)
اخواني هذا هو الكود
كود :
Imports System.Data.OleDb
Public Class Login
Public ds As New DataSet
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
ds.Clear()
Dim data As New OleDbDataAdapter("select Approve,SMR,KH,SA,NA,MOD1,AH,NO,AZ,MA,SJ,MOA,HA,OL from users where User='" & Trim(TextBox1.Text) & "' and Pass = '" & Trim(TextBox2.Text) & "'", con)
con.Open()
data.Fill(ds, "users")
con.Close()
If ds.Tables("users").Rows.Count = 0 Then
MsgBox("Please check username or Password")
Else
check_premission()
Me.Dispose()
Main.Show()
End If
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Me.Close()
End Sub
Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If users_count() = True Then
MsgBox("we will add you admin", MsgBoxStyle.Information)
Me.Dispose()
Formnewuser.Show()
Exit Sub
End If
End Sub
Function users_count()
Dim cmd As New OleDbCommand("select count(*) from users", con)
If con.State = ConnectionState.Open Then
con.Close()
End If
Dim count As Integer = 0
con.Open()
count = cmd.ExecuteScalar()
con.Close()
If count = 0 Then
Return True
Else
Return False
End If
End Function
Sub check_premission()
SMR = ds.Tables("users").Rows(0)(0)
KH = ds.Tables("users").Rows(0)(1)
SA = ds.Tables("users").Rows(0)(2)
NA = ds.Tables("users").Rows(0)(3)
MOD1 = ds.Tables("users").Rows(0)(4)
AH = ds.Tables("users").Rows(0)(5)
NO = ds.Tables("users").Rows(0)(6)
AZ = ds.Tables("users").Rows(0)(7)
MA = ds.Tables("users").Rows(0)(8)
SJ = ds.Tables("users").Rows(0)(9)
MOA = ds.Tables("users").Rows(0)(10)
HA = ds.Tables("users").Rows(0)(11)
OL = ds.Tables("users").Rows(0)(12)
Approve = ds.Tables("users").Rows(0)(13)
End Sub
End Class
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim sql As String = " Select * " & _ " From [users] " & _ " Where [User] = @User " & _ " And [Pass] = @Pass " Dim comm As New OleDbCommand(sql, con) comm.Parameters.AddWithValue("@User", Me.TextBox1.Text) comm.Parameters.AddWithValue("@Pass", Me.TextBox2.Text)
Dim data As New OleDbDataAdapter(comm) ds.Clear() data.Fill(ds)
If ds.Tables(0).Rows.Count = 0 Then MsgBox("Please check username or Password") Else check_premission() Me.Dispose() Main.Show() End If