cach | Comment pourrai-je transformer cette application en application smart device pour pocket PC qui utilise une syntaxe différente sous Visual Studio.net?
Code :
- Public Class Form1
- Inherits System.Windows.Forms.Form
- Public FichierIni As String
- Public DbConnect As String
- Public DateRef As Date
- Public Gcpper_Ident As String
- ' création d'une connection = d'un lien
- ' vers la base de données, la création est faite
- ' dans la méthode NEW
- Dim MyConnection As New OleDb.OleDbConnection
- #Region " Code généré par le Concepteur Windows Form "
- Public Sub New()
- MyBase.New()
- 'Cet appel est requis par le Concepteur Windows Form.
- InitializeComponent()
- 'Ajoutez une initialisation quelconque après l'appel InitializeComponent()
- FichierIni = "c:\pointeuse.ini"
- ' récupération des paramètres
- DbConnect = "Integrated Security=SSPI;Packet Size=4096;Data Source=DEV-INTERNET;Tag with column collation when possible=False;Initial Catalog=POINTEUSE;Use Procedure for Prepare=1;Auto Translate=True;Persist Security Info=False;Provider='SQLOLEDB.1';Workstation ID=DEV-INTERNET;Use Encryption for Data=False"
- DA_1.Fill(DS_1, "GCPPER" )
- ' ouverture de la connection
- MyConnection.ConnectionString = DbConnect
- MyConnection.Open()
- End Sub
- 'La méthode substituée Dispose du formulaire pour nettoyer la liste des composants.
- Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
- 'Requis par le Concepteur Windows Form
- Private components As System.ComponentModel.IContainer
- 'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form
- 'Elle peut être modifiée en utilisant le Concepteur Windows Form.
- 'Ne la modifiez pas en utilisant l'éditeur de code.
- Friend WithEvents TT_NOM As System.Windows.Forms.TextBox
- Friend WithEvents SQL_1 As System.Data.SqlClient.SqlConnection
- Friend WithEvents DA_1 As System.Data.OleDb.OleDbDataAdapter
- Friend WithEvents CD_1 As System.Data.OleDb.OleDbConnection
- Friend WithEvents DS_1 As WindowsApplication1.DataSet2
- Friend WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand
- Friend WithEvents Label1 As System.Windows.Forms.Label
- Friend WithEvents Timer_Pause As System.Windows.Forms.Timer
- Friend WithEvents Timer1 As System.Windows.Forms.Timer
- Friend WithEvents LL_DATE As System.Windows.Forms.Label
- Friend WithEvents Button1 As System.Windows.Forms.Button
- Friend WithEvents TT_INPUT As System.Windows.Forms.TextBox
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Me.components = New System.ComponentModel.Container
- Me.SQL_1 = New System.Data.SqlClient.SqlConnection
- Me.TT_NOM = New System.Windows.Forms.TextBox
- Me.DA_1 = New System.Data.OleDb.OleDbDataAdapter
- Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCommand
- Me.CD_1 = New System.Data.OleDb.OleDbConnection
- Me.DS_1 = New WindowsApplication1.DataSet2
- Me.TT_INPUT = New System.Windows.Forms.TextBox
- Me.Label1 = New System.Windows.Forms.Label
- Me.Timer_Pause = New System.Windows.Forms.Timer(Me.components)
- Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
- Me.LL_DATE = New System.Windows.Forms.Label
- Me.Button1 = New System.Windows.Forms.Button
- CType(Me.DS_1, System.ComponentModel.ISupportInitialize).BeginInit()
- Me.SuspendLayout()
- '
- 'SQL_1
- '
- Me.SQL_1.ConnectionString = "workstation id=""DEV-INTERNET"";packet size=4096;integrated security=SSPI;data sour" & _
- "ce=""DEV-INTERNET"";persist security info=False;initial catalog=POINTEUSE"
- '
- 'TT_NOM
- '
- Me.TT_NOM.Location = New System.Drawing.Point(24, 48)
- Me.TT_NOM.Name = "TT_NOM"
- Me.TT_NOM.Size = New System.Drawing.Size(232, 20)
- Me.TT_NOM.TabIndex = 1
- Me.TT_NOM.Text = ""
- '
- 'DA_1
- '
- Me.DA_1.SelectCommand = Me.OleDbSelectCommand1
- Me.DA_1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "GCPPER", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("IDENT", "IDENT" ), New System.Data.Common.DataColumnMapping("CODE", "CODE" ), New System.Data.Common.DataColumnMapping("DESIG", "DESIG" ), New System.Data.Common.DataColumnMapping("PRENOM", "PRENOM" )})})
- '
- 'OleDbSelectCommand1
- '
- Me.OleDbSelectCommand1.CommandText = "SELECT IDENT, CODE, DESIG, PRENOM FROM GCPPER"
- Me.OleDbSelectCommand1.Connection = Me.CD_1
- '
- 'CD_1
- '
- Me.CD_1.ConnectionString = "Integrated Security=SSPI;Packet Size=4096;Data Source=""DEV-INTERNET"";Tag with col" & _
- "umn collation when possible=False;Initial Catalog=POINTEUSE;Use Procedure for Pr" & _
- "epare=1;Auto Translate=True;Persist Security Info=False;Provider=""SQLOLEDB.1"";Wo" & _
- "rkstation ID=""DEV-INTERNET"";Use Encryption for Data=False"
- '
- 'DS_1
- '
- Me.DS_1.DataSetName = "DataSet2"
- Me.DS_1.Locale = New System.Globalization.CultureInfo("fr-FR" )
- '
- 'TT_INPUT
- '
- Me.TT_INPUT.Location = New System.Drawing.Point(40, 112)
- Me.TT_INPUT.Name = "TT_INPUT"
- Me.TT_INPUT.Size = New System.Drawing.Size(200, 20)
- Me.TT_INPUT.TabIndex = 2
- Me.TT_INPUT.Text = ""
- '
- 'Label1
- '
- Me.Label1.Location = New System.Drawing.Point(40, 72)
- Me.Label1.Name = "Label1"
- Me.Label1.Size = New System.Drawing.Size(192, 40)
- Me.Label1.TabIndex = 3
- Me.Label1.Text = "Label1"
- Me.Label1.Visible = False
- '
- 'Timer_Pause
- '
- '
- 'Timer1
- '
- Me.Timer1.Enabled = True
- Me.Timer1.Interval = 1000
- '
- 'LL_DATE
- '
- Me.LL_DATE.Location = New System.Drawing.Point(32, 16)
- Me.LL_DATE.Name = "LL_DATE"
- Me.LL_DATE.Size = New System.Drawing.Size(216, 23)
- Me.LL_DATE.TabIndex = 4
- '
- 'Button1
- '
- Me.Button1.Location = New System.Drawing.Point(216, 224)
- Me.Button1.Name = "Button1"
- Me.Button1.Size = New System.Drawing.Size(64, 24)
- Me.Button1.TabIndex = 5
- Me.Button1.Text = "Sauver"
- Me.Button1.Visible = False
- '
- 'Form1
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
- Me.ClientSize = New System.Drawing.Size(360, 342)
- Me.Controls.Add(Me.Button1)
- Me.Controls.Add(Me.LL_DATE)
- Me.Controls.Add(Me.TT_INPUT)
- Me.Controls.Add(Me.TT_NOM)
- Me.Controls.Add(Me.Label1)
- Me.Name = "Form1"
- Me.Text = "Form1"
- CType(Me.DS_1, System.ComponentModel.ISupportInitialize).EndInit()
- Me.ResumeLayout(False)
- End Sub
- #End Region
- Protected Overrides Sub Finalize()
- MyBase.Finalize()
- End Sub
- Private Sub TT_NOM_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles TT_NOM.Validated
- DateRef = Now
- ' On construit la requete à partir de la zone saisie
- Dim MySql As String
- MySql = "SELECT IDENT, PRENOM+' '+DESIG FROM GCPPER WHERE CODE='" _
- & TT_NOM.Text & "'"
- ' Création d'une commande qui s'adressera à la connection
- ' que je viens de créer: J'ai créé un tuyau, je crée
- ' maintenant l'ordre (OledbCommand) qui passera dans le tuyau
- Dim MyRs As OleDb.OleDbCommand
- MyRs = New OleDb.OleDbCommand
- ' je dis quel tuyau utiliser
- MyRs.Connection = MyConnection
- ' quel type d'info je veux (table ou ici une requete)
- MyRs.CommandType = CommandType.Text
- ' le texte de la requete
- MyRs.CommandText = MySql
- ' Création d'un réceptacle qui recueillera les données
- ' issues de la requete
- Dim MyData As OleDb.OleDbDataReader
- ' on charge le réceptacle en demandant l'exexution
- ' de l'objet commande
- MyData = MyRs.ExecuteReader()
- ' il reste à travailler sur le résultat
- ' l'instruction .read lit l'enregistrement suivant
- If MyData.HasRows = False Then
- Label1.Text = TT_NOM.Text & " est inconnu"
- Label1.Visible = True
- Timer_Pause.Interval = 2000
- Timer_Pause.Enabled = True
- TT_NOM.Text = ""
- Else
- MyData.Read()
- TT_NOM.Text = MyData.GetString(1)
- Gcpper_Ident = MyData.GetString(0)
- End If
- MyData.Close()
- End Sub
- Private Sub Timer_Pause_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer_Pause.Tick
- Timer_Pause.Enabled = False
- Label1.Visible = False
- End Sub
- Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- LL_DATE.Text = Format(Now, "dd/MM/yyyy HH:mm:ss" )
- End Sub
- Private Sub sub_entree()
- ' On construit la requete à partir de la zone saisie
- Dim MySql As String
- Dim MyRs As OleDb.OleDbCommand
- MyRs = New OleDb.OleDbCommand
- MySql = "INSERT INTO CB_TEMPS (IDENT,DATE_SAISIE,HEURE_SAISIE) VALUES ('" _
- & Gcpper_Ident & "','" & DateRef & "','" & DateRef & "')"
- ' Création d'une commande qui s'adressera à la connection
- ' que je viens de créer: J'ai créé un tuyau, je crée
- ' maintenant l'ordre (OledbCommand) qui passera dans le tuyau
- ' je dis quel tuyau utiliser
- MyRs.Connection = MyConnection
- ' quel type d'info je veux (table ou ici une requete)
- MyRs.CommandType = CommandType.Text
- ' le texte de la requete
- MyRs.CommandText = MySql
- If MyRs.ExecuteNonQuery() <> 1 Then
- MsgBox("erreur, aucune ligne insérée sur l'entrée!" )
- End If
- End Sub
- Private Sub TT_INPUT_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles TT_INPUT.Validated
- ' Private Sub TT_INPUT_Validated((ByVal sender As Object, ByVal e As System.EventArgs) Handles TT_INPUT.Validated
- If TT_INPUT.Text = "ENTREE" Then
- Call sub_entree()
- ElseIf TT_INPUT.Text = "SORTIE" Then
- Call Sub_Sortie()
- ElseIf Microsoft.VisualBasic.Left(TT_INPUT.Text, 2) = "OF" Then
- Call sub_of()
- Else ' imputation
- Call sub_imputation()
- End If
- TT_NOM.Text = ""
- TT_INPUT.Text = ""
- End Sub
- Private Sub Sub_Sortie()
- Dim MySql As String
- Dim MyRs, MyRs2 As OleDb.OleDbCommand
- Dim MyData As OleDb.OleDbDataReader
- Dim MyCb_Temps_Ident As Int32
- MyRs = New OleDb.OleDbCommand
- MyRs2 = New OleDb.OleDbCommand
- Do While True
- ' On vérifie qu'il y a déjà une entrée
- MySql = "SELECT IDENT FROM CB_TEMPS WHERE GCPPER_IDENT='" & Gcpper_Ident & "' AND "
- MySql = MySql & "GCPIMP_IDENT is null AND GCPOFRES_IDENT is null AND DATE_FIN is null"
- ' je dis quel tuyau utiliser
- MyRs.Connection = MyConnection
- MyRs.CommandType = CommandType.Text
- MyRs.CommandText = MySql
- MyData = MyRs.ExecuteReader()
- ' si je n'ai pas d'entrée ouverte, il faut la créer
- If MyData.HasRows = False Then
- MyData.Close()
- Call sub_entree()
- Else
- MyData.Read()
- MyCb_Temps_Ident = MyData.GetInt32(0)
- MyData.Close()
- ' sortie réelle
- MySql = "UPDATE CB_TEMPS SET DATE_FIN='" & DateRef & "' WHERE IDENT=" & MyCb_Temps_Ident
- MyRs2.Connection = MyConnection
- MyRs2.CommandType = CommandType.Text
- MyRs2.CommandText = MySql
- If MyRs2.ExecuteNonQuery() <> 1 Then
- MsgBox("Oxygovl!!! sur la requête de sortie" )
- End If
- Exit Do
- End If
- Loop
- End Sub
|
Les différences entre ce programme et celui compréhensible par un pocket PC ne doivent se trouvées que dans la déclaration des 'variables'?
|