26-05-13, 09:54 PM
نعم كلام سليم ... ما شاء الله تبارك الله ..
وأليكم مثــــــال متواضع وعلى السريع حتى تصل الفكرة للشباب :
عندنا كلاس يحتوي على :
ومن خلال EnterFace تتم العملية كالتالى :
مع أنه الموضوع مش مكانه ,,, ولكن لعله خير وشكرا لكل الشباب والشكر موصول للأخوه في الادارة لمرونة التعامل وسعه الصدر .
وأليكم مثــــــال متواضع وعلى السريع حتى تصل الفكرة للشباب :
عندنا كلاس يحتوي على :
PHP كود :
Imports System.Data.SqlClient
Public Class UserData
Dim UCmd As SqlCommand
Dim DTable As New DataTable
#Region " properties "
Public Property UserID As Integer
Private _UserName As String
Public Property UserName() As String
Get
Return _UserName
End Get
Set(ByVal value As String)
If value.Length = 0 Then
MsgBox("أدخـــــل الأســــــم بالكامل")
Exit Property
End If
_UserName = value
End Set
End Property
Private _UserPass As String
Public Property UserPass() As String
Get
Return _UserPass
End Get
Set(ByVal value As String)
If value.Length = 0 Then
MsgBox("أدخــــل كلمة مرور ")
Exit Property
End If
_UserPass = value
End Set
End Property
Private _Phone As String
Public Property Phone() As String
Get
Return _Phone
End Get
Set(ByVal value As String)
_Phone = value
End Set
End Property
Private _Jaw As String
Public Property Jaw() As String
Get
Return _Jaw
End Get
Set(ByVal value As String)
_Jaw = value
End Set
End Property
Private _Address As String
Public Property Address() As String
Get
Return _Address
End Get
Set(ByVal value As String)
If value.Length = 0 Then
MsgBox("أدخل العنــــوان")
Exit Property
End If
_Address = value
End Set
End Property
#End Region
#Region " Constractor "
Public Sub New(ByVal UName As String, _
ByVal UPass As String, ByVal Phn As String, _
ByVal Jw As String, ByVal Adrs As String)
Me.UserName = UName
Me.UserPass = UPass
Me.Phone = Phn
Me.Jaw = Jw
Me.Address = Adrs
End Sub
#End Region
#Region " Functions "
'-- Add
Public Function AddUser() As Boolean
Dim UCmd = New SqlCommand("AddNewUser", MyDatabaseCon.Cn) With {.CommandType = CommandType.StoredProcedure}
UCmd.Parameters.Clear()
With UCmd.Parameters
.AddWithValue("@UserName", Me.UserName)
.AddWithValue("@UserPass", Me.UserPass)
.AddWithValue("@Phone", Me.Phone)
.AddWithValue("@Jaw", Me.Jaw)
.AddWithValue("@Address", Me.Address)
End With
Try
MyDatabaseCon.Open() : UCmd.ExecuteNonQuery() : MyDatabaseCon.Close()
Return True
UCmd.Parameters.Clear()
Catch ex As SqlException
MyDatabaseCon.Close()
Throw New Exception
End Try
End Function
#End Region
Public Function GetAllUsrs() As DataTable
Dim UCmd = New SqlCommand("GetAllUsers", MyDatabaseCon.Cn) With {.CommandType = CommandType.StoredProcedure}
Try
MyDatabaseCon.Open()
DTable.Load(UCmd.ExecuteReader)
MyDatabaseCon.Close()
Return DTable
Catch ex As SqlException
MyDatabaseCon.Close()
Throw New Exception
End Try
End Function
End Class
ومن خلال EnterFace تتم العملية كالتالى :
PHP كود :
Try
Dim XUser As New UserData(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text)
XUser.AddUser()
MsgBox("Okey Saved")
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub
مع أنه الموضوع مش مكانه ,,, ولكن لعله خير وشكرا لكل الشباب والشكر موصول للأخوه في الادارة لمرونة التعامل وسعه الصدر .

