Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1690 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  VB.NET (transformer une application windows form)

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

VB.NET (transformer une application windows form)

n°713006
cach
Posté le 30-04-2004 à 17:03:25  profilanswer
 

Comment pourrai-je transformer cette application en application smart device pour pocket PC qui utilise une syntaxe différente sous Visual Studio.net?

Code :
  1. Public Class Form1
  2.     Inherits System.Windows.Forms.Form
  3.     Public FichierIni As String
  4.     Public DbConnect As String
  5.     Public DateRef As Date
  6.     Public Gcpper_Ident As String
  7.     ' création d'une connection = d'un lien
  8.     ' vers la base de données, la création est faite
  9.     ' dans la méthode NEW
  10.     Dim MyConnection As New OleDb.OleDbConnection
  11. #Region " Code généré par le Concepteur Windows Form "
  12.     Public Sub New()
  13.         MyBase.New()
  14.         'Cet appel est requis par le Concepteur Windows Form.
  15.         InitializeComponent()
  16.         'Ajoutez une initialisation quelconque après l'appel InitializeComponent()
  17.         FichierIni = "c:\pointeuse.ini"
  18.         ' récupération des paramètres
  19.         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"
  20.         DA_1.Fill(DS_1, "GCPPER" )
  21.         ' ouverture de la connection
  22.         MyConnection.ConnectionString = DbConnect
  23.         MyConnection.Open()
  24.     End Sub
  25.     'La méthode substituée Dispose du formulaire pour nettoyer la liste des composants.
  26.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  27.         If disposing Then
  28.             If Not (components Is Nothing) Then
  29.                 components.Dispose()
  30.             End If
  31.         End If
  32.         MyBase.Dispose(disposing)
  33.     End Sub
  34.     'Requis par le Concepteur Windows Form
  35.     Private components As System.ComponentModel.IContainer
  36.     'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form
  37.     'Elle peut être modifiée en utilisant le Concepteur Windows Form. 
  38.     'Ne la modifiez pas en utilisant l'éditeur de code.
  39.     Friend WithEvents TT_NOM As System.Windows.Forms.TextBox
  40.     Friend WithEvents SQL_1 As System.Data.SqlClient.SqlConnection
  41.     Friend WithEvents DA_1 As System.Data.OleDb.OleDbDataAdapter
  42.     Friend WithEvents CD_1 As System.Data.OleDb.OleDbConnection
  43.     Friend WithEvents DS_1 As WindowsApplication1.DataSet2
  44.     Friend WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand
  45.     Friend WithEvents Label1 As System.Windows.Forms.Label
  46.     Friend WithEvents Timer_Pause As System.Windows.Forms.Timer
  47.     Friend WithEvents Timer1 As System.Windows.Forms.Timer
  48.     Friend WithEvents LL_DATE As System.Windows.Forms.Label
  49.     Friend WithEvents Button1 As System.Windows.Forms.Button
  50.     Friend WithEvents TT_INPUT As System.Windows.Forms.TextBox
  51.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  52.         Me.components = New System.ComponentModel.Container
  53.         Me.SQL_1 = New System.Data.SqlClient.SqlConnection
  54.         Me.TT_NOM = New System.Windows.Forms.TextBox
  55.         Me.DA_1 = New System.Data.OleDb.OleDbDataAdapter
  56.         Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCommand
  57.         Me.CD_1 = New System.Data.OleDb.OleDbConnection
  58.         Me.DS_1 = New WindowsApplication1.DataSet2
  59.         Me.TT_INPUT = New System.Windows.Forms.TextBox
  60.         Me.Label1 = New System.Windows.Forms.Label
  61.         Me.Timer_Pause = New System.Windows.Forms.Timer(Me.components)
  62.         Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
  63.         Me.LL_DATE = New System.Windows.Forms.Label
  64.         Me.Button1 = New System.Windows.Forms.Button
  65.         CType(Me.DS_1, System.ComponentModel.ISupportInitialize).BeginInit()
  66.         Me.SuspendLayout()
  67.         '
  68.         'SQL_1
  69.         '
  70.         Me.SQL_1.ConnectionString = "workstation id=""DEV-INTERNET"";packet size=4096;integrated security=SSPI;data sour" & _
  71.         "ce=""DEV-INTERNET"";persist security info=False;initial catalog=POINTEUSE"
  72.         '
  73.         'TT_NOM
  74.         '
  75.         Me.TT_NOM.Location = New System.Drawing.Point(24, 48)
  76.         Me.TT_NOM.Name = "TT_NOM"
  77.         Me.TT_NOM.Size = New System.Drawing.Size(232, 20)
  78.         Me.TT_NOM.TabIndex = 1
  79.         Me.TT_NOM.Text = ""
  80.         '
  81.         'DA_1
  82.         '
  83.         Me.DA_1.SelectCommand = Me.OleDbSelectCommand1
  84.         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" )})})
  85.         '
  86.         'OleDbSelectCommand1
  87.         '
  88.         Me.OleDbSelectCommand1.CommandText = "SELECT IDENT, CODE, DESIG, PRENOM FROM GCPPER"
  89.         Me.OleDbSelectCommand1.Connection = Me.CD_1
  90.         '
  91.         'CD_1
  92.         '
  93.         Me.CD_1.ConnectionString = "Integrated Security=SSPI;Packet Size=4096;Data Source=""DEV-INTERNET"";Tag with col" & _
  94.         "umn collation when possible=False;Initial Catalog=POINTEUSE;Use Procedure for Pr" & _
  95.         "epare=1;Auto Translate=True;Persist Security Info=False;Provider=""SQLOLEDB.1"";Wo" & _
  96.         "rkstation ID=""DEV-INTERNET"";Use Encryption for Data=False"
  97.         '
  98.         'DS_1
  99.         '
  100.         Me.DS_1.DataSetName = "DataSet2"
  101.         Me.DS_1.Locale = New System.Globalization.CultureInfo("fr-FR" )
  102.         '
  103.         'TT_INPUT
  104.         '
  105.         Me.TT_INPUT.Location = New System.Drawing.Point(40, 112)
  106.         Me.TT_INPUT.Name = "TT_INPUT"
  107.         Me.TT_INPUT.Size = New System.Drawing.Size(200, 20)
  108.         Me.TT_INPUT.TabIndex = 2
  109.         Me.TT_INPUT.Text = ""
  110.         '
  111.         'Label1
  112.         '
  113.         Me.Label1.Location = New System.Drawing.Point(40, 72)
  114.         Me.Label1.Name = "Label1"
  115.         Me.Label1.Size = New System.Drawing.Size(192, 40)
  116.         Me.Label1.TabIndex = 3
  117.         Me.Label1.Text = "Label1"
  118.         Me.Label1.Visible = False
  119.         '
  120.         'Timer_Pause
  121.         '
  122.         '
  123.         'Timer1
  124.         '
  125.         Me.Timer1.Enabled = True
  126.         Me.Timer1.Interval = 1000
  127.         '
  128.         'LL_DATE
  129.         '
  130.         Me.LL_DATE.Location = New System.Drawing.Point(32, 16)
  131.         Me.LL_DATE.Name = "LL_DATE"
  132.         Me.LL_DATE.Size = New System.Drawing.Size(216, 23)
  133.         Me.LL_DATE.TabIndex = 4
  134.         '
  135.         'Button1
  136.         '
  137.         Me.Button1.Location = New System.Drawing.Point(216, 224)
  138.         Me.Button1.Name = "Button1"
  139.         Me.Button1.Size = New System.Drawing.Size(64, 24)
  140.         Me.Button1.TabIndex = 5
  141.         Me.Button1.Text = "Sauver"
  142.         Me.Button1.Visible = False
  143.         '
  144.         'Form1
  145.         '
  146.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  147.         Me.ClientSize = New System.Drawing.Size(360, 342)
  148.         Me.Controls.Add(Me.Button1)
  149.         Me.Controls.Add(Me.LL_DATE)
  150.         Me.Controls.Add(Me.TT_INPUT)
  151.         Me.Controls.Add(Me.TT_NOM)
  152.         Me.Controls.Add(Me.Label1)
  153.         Me.Name = "Form1"
  154.         Me.Text = "Form1"
  155.         CType(Me.DS_1, System.ComponentModel.ISupportInitialize).EndInit()
  156.         Me.ResumeLayout(False)
  157.     End Sub
  158. #End Region
  159.     Protected Overrides Sub Finalize()
  160.         MyBase.Finalize()
  161.     End Sub
  162.     Private Sub TT_NOM_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles TT_NOM.Validated
  163.         DateRef = Now
  164.         ' On construit la requete à partir de la zone saisie
  165.         Dim MySql As String
  166.         MySql = "SELECT IDENT, PRENOM+' '+DESIG FROM GCPPER WHERE CODE='" _
  167.                 & TT_NOM.Text & "'"
  168.         ' Création d'une commande qui s'adressera à la connection
  169.         ' que je viens de créer: J'ai créé un tuyau, je crée
  170.         ' maintenant l'ordre (OledbCommand) qui passera dans le tuyau
  171.         Dim MyRs As OleDb.OleDbCommand
  172.         MyRs = New OleDb.OleDbCommand
  173.         ' je dis quel tuyau utiliser
  174.         MyRs.Connection = MyConnection
  175.         ' quel type d'info je veux (table ou ici une requete)
  176.         MyRs.CommandType = CommandType.Text
  177.         ' le texte de la requete
  178.         MyRs.CommandText = MySql
  179.         ' Création d'un réceptacle qui recueillera les données
  180.         ' issues de la requete
  181.         Dim MyData As OleDb.OleDbDataReader
  182.         ' on charge le réceptacle en demandant l'exexution
  183.         ' de l'objet commande
  184.         MyData = MyRs.ExecuteReader()
  185.         ' il reste à travailler sur le résultat
  186.         ' l'instruction .read lit l'enregistrement suivant
  187.         If MyData.HasRows = False Then
  188.             Label1.Text = TT_NOM.Text & " est inconnu"
  189.             Label1.Visible = True
  190.             Timer_Pause.Interval = 2000
  191.             Timer_Pause.Enabled = True
  192.             TT_NOM.Text = ""
  193.         Else
  194.             MyData.Read()
  195.             TT_NOM.Text = MyData.GetString(1)
  196.             Gcpper_Ident = MyData.GetString(0)
  197.         End If
  198.         MyData.Close()
  199.     End Sub
  200.     Private Sub Timer_Pause_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer_Pause.Tick
  201.         Timer_Pause.Enabled = False
  202.         Label1.Visible = False
  203.     End Sub
  204.     Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  205.         LL_DATE.Text = Format(Now, "dd/MM/yyyy HH:mm:ss" )
  206.     End Sub
  207.     Private Sub sub_entree()
  208.         ' On construit la requete à partir de la zone saisie
  209.         Dim MySql As String
  210.         Dim MyRs As OleDb.OleDbCommand
  211.         MyRs = New OleDb.OleDbCommand
  212.         MySql = "INSERT INTO CB_TEMPS (IDENT,DATE_SAISIE,HEURE_SAISIE) VALUES ('" _
  213.                 & Gcpper_Ident & "','" & DateRef & "','" & DateRef & "')"
  214.         ' Création d'une commande qui s'adressera à la connection
  215.         ' que je viens de créer: J'ai créé un tuyau, je crée
  216.         ' maintenant l'ordre (OledbCommand) qui passera dans le tuyau
  217.         ' je dis quel tuyau utiliser
  218.         MyRs.Connection = MyConnection
  219.         ' quel type d'info je veux (table ou ici une requete)
  220.         MyRs.CommandType = CommandType.Text
  221.         ' le texte de la requete
  222.         MyRs.CommandText = MySql
  223.         If MyRs.ExecuteNonQuery() <> 1 Then
  224.             MsgBox("erreur, aucune ligne insérée sur l'entrée!" )
  225.         End If
  226.     End Sub
  227.     Private Sub TT_INPUT_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles TT_INPUT.Validated
  228.         '  Private Sub TT_INPUT_Validated((ByVal sender As Object, ByVal e As System.EventArgs) Handles TT_INPUT.Validated
  229.         If TT_INPUT.Text = "ENTREE" Then
  230.             Call sub_entree()
  231.         ElseIf TT_INPUT.Text = "SORTIE" Then
  232.             Call Sub_Sortie()
  233.         ElseIf Microsoft.VisualBasic.Left(TT_INPUT.Text, 2) = "OF" Then
  234.             Call sub_of()
  235.         Else    ' imputation
  236.             Call sub_imputation()
  237.         End If
  238.         TT_NOM.Text = ""
  239.         TT_INPUT.Text = ""
  240.     End Sub
  241.     Private Sub Sub_Sortie()
  242.         Dim MySql As String
  243.         Dim MyRs, MyRs2 As OleDb.OleDbCommand
  244.         Dim MyData As OleDb.OleDbDataReader
  245.         Dim MyCb_Temps_Ident As Int32
  246.         MyRs = New OleDb.OleDbCommand
  247.         MyRs2 = New OleDb.OleDbCommand
  248.         Do While True
  249.             ' On vérifie qu'il y a déjà une entrée
  250.             MySql = "SELECT IDENT FROM CB_TEMPS WHERE GCPPER_IDENT='" & Gcpper_Ident & "' AND "
  251.             MySql = MySql & "GCPIMP_IDENT is null AND GCPOFRES_IDENT is null AND DATE_FIN is null"
  252.             ' je dis quel tuyau utiliser
  253.             MyRs.Connection = MyConnection
  254.             MyRs.CommandType = CommandType.Text
  255.             MyRs.CommandText = MySql
  256.             MyData = MyRs.ExecuteReader()
  257.             ' si je n'ai pas d'entrée ouverte, il faut la créer
  258.             If MyData.HasRows = False Then
  259.                 MyData.Close()
  260.                 Call sub_entree()
  261.             Else
  262.                 MyData.Read()
  263.                 MyCb_Temps_Ident = MyData.GetInt32(0)
  264.                 MyData.Close()
  265.                 ' sortie réelle
  266.                 MySql = "UPDATE CB_TEMPS SET DATE_FIN='" & DateRef & "' WHERE IDENT=" & MyCb_Temps_Ident
  267.                 MyRs2.Connection = MyConnection
  268.                 MyRs2.CommandType = CommandType.Text
  269.                 MyRs2.CommandText = MySql
  270.                 If MyRs2.ExecuteNonQuery() <> 1 Then
  271.                     MsgBox("Oxygovl!!! sur la requête de sortie" )
  272.                 End If
  273.                 Exit Do
  274.             End If
  275.         Loop
  276.     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'?  

mood
Publicité
Posté le 30-04-2004 à 17:03:25  profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  VB.NET (transformer une application windows form)

 

Sujets relatifs
VB.NET (smart device application) [arrêtez de chercher]Python sous windows : meilleur moyen pour connecter un lecteur reseau?
[Fixed!][HTML] (Form) 'action' avec variables en GET ? (Pb)SqlCommand en VB .net
Programmation OS & API WindowsComment faire tourner son appli en tant que service windows?
[HTML] Frameset & form[php] Controler acces intranet par mot de passe Windows
syntaxe des invits pour application 
Plus de sujets relatifs à : VB.NET (transformer une application windows form)


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR