04-04-17, 09:14 PM
(آخر تعديل لهذه المشاركة : 04-04-17, 09:23 PM {2} بواسطة ramimohammed.)
السلام عليكم
اخي انا قمت بعمل فورم للصلاحيات المستخدمين وهو فورم رقم 2
وشاشة الدخول فورم رقم 3
اريد عند ادخال اسم مستخدم معين تفتح له بعض الصلاحيات في الفورم 1 كما في المرفقات
وهذه الاكواد المستخدمه
كود فورم 2
(( كود الاضافة))
If db.State = ConnectionState.Closed Then db.Open()
Dim s As String = "insert into pass(no_user,na_user,pass_user,marahel,malyaah,setting_sys)values(@no_user,@na_user,@pass_user,@marahel,@malyaah,@setting_sys)"
Dim sw As New OleDbCommand(s, db)
sw.Parameters.AddWithValue("@no_user", TextBox1.Text)
sw.Parameters.AddWithValue("@na_user", TextBox2.Text)
sw.Parameters.AddWithValue("@pass_user", TextBox3.Text)
sw.Parameters.AddWithValue("@marahel", CheckBox1.Checked)
sw.Parameters.AddWithValue("@malyaah", CheckBox2.Checked)
sw.Parameters.AddWithValue("@setting_sys", CheckBox3.Checked)
Try
sw.ExecuteNonQuery()
MsgBox("تم اضافة المستخدم", MsgBoxStyle.MsgBoxRight, "تنبية")
clear1()
Catch
MsgBox("المستخدم موجود مسبقا", MsgBoxStyle.MsgBoxRight, "تنبية")
TextBox1.Clear()
TextBox1.Focus()
If db.State = ConnectionState.Open Then db.Close()
End Try
--------------------------------------------------
كود فورم الدخول
If ComboBox1.SelectedIndex = -1 Then
MsgBox("حدد اسم المستخدم")
Exit Sub
End If
If TextBox1.Text = "" Then
MsgBox("ادخل كلمة المرور")
Exit Sub
End If
On Error Resume Next
If db.State = ConnectionState.Closed Then db.Open()
Dim s As String = "select * from pass where (na_user=@na_user)and(pass_user=@pass_user)"
dco = New OleDbCommand(s, db)
dco.Parameters.AddWithValue("@x2", ComboBox1.Text)
dco.Parameters.AddWithValue("@x3", TextBox1.Text)
Dim reader As OleDbDataReader = dco.ExecuteReader
If reader.Read = True Then
reader.Close()
Form1.ShowDialog()
Dispose()
Else
reader.Close()
MsgBox("الرجاء ادخال البيانات الصحيحة", MsgBoxStyle.Question, "تنبيه")
End If
If db.State = ConnectionState.Open Then db.Close()
-----------------------------------------------------
كود فورم 1 شرط الصلاحية
If CheckBox1.Checked = True Then
Button1.Enabled = True
Button2.Enabled = True
Button4.Enabled = True
Button5.Enabled = True
Button6.Enabled = True
Button7.Enabled = True
Button8.Enabled = True
Button9.Enabled = True
Button10.Enabled = True
Button11.Enabled = True
Button12.Enabled = True
Button13.Enabled = True
Button14.Enabled = True
Button15.Enabled = True
End If
If CheckBox2.Checked = True Then
Button18.Enabled = True
Button26.Enabled = True
Button24.Enabled = True
Button17.Enabled = True
Button16.Enabled = True
Button27.Enabled = True
Button19.Enabled = True
Button20.Enabled = True
End If
If CheckBox3.Checked = True Then
Button22.Enabled = True
End If
----------------------
السؤال هو اين اضع الشرط
او ما هو النقص ؟ ارجو التعديل في الاكواد لمعرفة اين المشكلة
اخي انا قمت بعمل فورم للصلاحيات المستخدمين وهو فورم رقم 2
وشاشة الدخول فورم رقم 3
اريد عند ادخال اسم مستخدم معين تفتح له بعض الصلاحيات في الفورم 1 كما في المرفقات
وهذه الاكواد المستخدمه
كود فورم 2
(( كود الاضافة))
If db.State = ConnectionState.Closed Then db.Open()
Dim s As String = "insert into pass(no_user,na_user,pass_user,marahel,malyaah,setting_sys)values(@no_user,@na_user,@pass_user,@marahel,@malyaah,@setting_sys)"
Dim sw As New OleDbCommand(s, db)
sw.Parameters.AddWithValue("@no_user", TextBox1.Text)
sw.Parameters.AddWithValue("@na_user", TextBox2.Text)
sw.Parameters.AddWithValue("@pass_user", TextBox3.Text)
sw.Parameters.AddWithValue("@marahel", CheckBox1.Checked)
sw.Parameters.AddWithValue("@malyaah", CheckBox2.Checked)
sw.Parameters.AddWithValue("@setting_sys", CheckBox3.Checked)
Try
sw.ExecuteNonQuery()
MsgBox("تم اضافة المستخدم", MsgBoxStyle.MsgBoxRight, "تنبية")
clear1()
Catch
MsgBox("المستخدم موجود مسبقا", MsgBoxStyle.MsgBoxRight, "تنبية")
TextBox1.Clear()
TextBox1.Focus()
If db.State = ConnectionState.Open Then db.Close()
End Try
--------------------------------------------------
كود فورم الدخول
If ComboBox1.SelectedIndex = -1 Then
MsgBox("حدد اسم المستخدم")
Exit Sub
End If
If TextBox1.Text = "" Then
MsgBox("ادخل كلمة المرور")
Exit Sub
End If
On Error Resume Next
If db.State = ConnectionState.Closed Then db.Open()
Dim s As String = "select * from pass where (na_user=@na_user)and(pass_user=@pass_user)"
dco = New OleDbCommand(s, db)
dco.Parameters.AddWithValue("@x2", ComboBox1.Text)
dco.Parameters.AddWithValue("@x3", TextBox1.Text)
Dim reader As OleDbDataReader = dco.ExecuteReader
If reader.Read = True Then
reader.Close()
Form1.ShowDialog()
Dispose()
Else
reader.Close()
MsgBox("الرجاء ادخال البيانات الصحيحة", MsgBoxStyle.Question, "تنبيه")
End If
If db.State = ConnectionState.Open Then db.Close()
-----------------------------------------------------
كود فورم 1 شرط الصلاحية
If CheckBox1.Checked = True Then
Button1.Enabled = True
Button2.Enabled = True
Button4.Enabled = True
Button5.Enabled = True
Button6.Enabled = True
Button7.Enabled = True
Button8.Enabled = True
Button9.Enabled = True
Button10.Enabled = True
Button11.Enabled = True
Button12.Enabled = True
Button13.Enabled = True
Button14.Enabled = True
Button15.Enabled = True
End If
If CheckBox2.Checked = True Then
Button18.Enabled = True
Button26.Enabled = True
Button24.Enabled = True
Button17.Enabled = True
Button16.Enabled = True
Button27.Enabled = True
Button19.Enabled = True
Button20.Enabled = True
End If
If CheckBox3.Checked = True Then
Button22.Enabled = True
End If
----------------------
السؤال هو اين اضع الشرط
او ما هو النقص ؟ ارجو التعديل في الاكواد لمعرفة اين المشكلة
