VisualStudio 2008 Smart Device Project SQL bağlantısı TextBox

Public Class Form1
Dim SqlConnStr As String = “server=192.168.0.144;database=TEST;uid=fdonmez;pwd=2051970025;”
Dim SqlConn As New System.Data.SqlClient.SqlConnection(SqlConnStr)
Dim kullanici As String

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conf, pos, ckont As String

If TextBox8.Text <> “” Then
TextBox8.Text = UCase(TextBox8.Text)
ckont = Mid(TextBox8.Text, 1, 1)
If ckont = “C” Then
conf = Mid(TextBox8.Text, 2, 8)
pos = Mid(TextBox8.Text, 10, 8)
Else
conf = Mid(TextBox8.Text, 1, 8)
pos = Mid(TextBox8.Text, 9, 8)
End If
SqlConn.Open()
Dim mySelectQuery As String = “SELECT CONFIRMATION,CONFIRMPOS,MATERIAL,VOPTIONS,QUANTITY,QUNIT,BATCHNUM ,PROJECT,INVDOCTYPE,INVDOCNUM,INVDOCITEM,WAREHOUSE,STOCKPLACE,B.STEXT BEDEN,R.STEXT RENK FROM IASINVITEM WITH (NOLOCK),IASVAROPTIONX B WITH (NOLOCK), IASVAROPTIONX R WITH (NOLOCK) WHERE (INVDOCTYPE = ‘IG’ OR INVDOCTYPE = ‘BG’ OR INVDOCTYPE = ‘TR’ ) AND QPOSTWAY = 0 AND ISCANCELED = 0 AND (TRANTYPE = ‘ISG’ OR TRANTYPE = ‘BLG’ OR TRANTYPE = ‘TRF’ ) AND WAREHOUSE <> ’300′ AND CONFIRMATION = ‘” & conf & “‘ AND CONFIRMPOS = ‘” & pos & “‘ AND CREATEDAT IN ( SELECT MAX( CREATEDAT ) AS CREATEDAT FROM IASINVITEM WHERE( INVDOCTYPE = ‘IG’ OR INVDOCTYPE = ‘BG’ OR INVDOCTYPE = ‘TR’ ) AND QPOSTWAY = 0 AND ISCANCELED = 0 AND (TRANTYPE = ‘ISG’ OR TRANTYPE = ‘BLG’ OR TRANTYPE = ‘TRF’ ) AND WAREHOUSE <> ’300′ AND CONFIRMATION = ‘” & conf & “‘ AND CONFIRMPOS = ‘” & pos & “‘) AND B.VARIANTKEY=’RB’ AND B.ATTRIBUTEKEY=’01′ AND B.OPTIONKEY=SUBSTRING(VOPTIONS,4,2) AND R.VARIANTKEY=’RB’ AND R.ATTRIBUTEKEY=’02′ AND R.OPTIONKEY=SUBSTRING(VOPTIONS,10,3);”

Dim SqlComm As New System.Data.SqlClient.SqlCommand(mySelectQuery, SqlConn)

Dim reader As System.Data.SqlClient.SqlDataReader
reader = SqlComm.ExecuteReader()
While reader.Read()

TextBox8.Text = “”
TextBox1.Text = reader(“CONFIRMATION”).ToString() + reader(“CONFIRMPOS”).ToString()
TextBox2.Text = reader(“MATERIAL”).ToString()
TextBox3.Text = reader(“RENK”).ToString()
TextBox4.Text = reader(“BEDEN”).ToString()
TextBox5.Text = reader(“BATCHNUM”).ToString()
TextBox6.Text = reader(“QUANTITY”).ToString()
TextBox9.Text = reader(“INVDOCTYPE”).ToString()
TextBox10.Text = reader(“INVDOCNUM”).ToString()
TextBox11.Text = reader(“INVDOCITEM”).ToString()
TextBox7.Focus()

End While

SqlConn.Close()

Else
If TextBox6.Text <> “” Then
SqlConn.Open()
If TextBox7.Text <> “” Then
TextBox6.Text = TextBox6.Text + TextBox7.Text / 12
End If
If TextBox12.Text <> “” Then
TextBox6.Text = TextBox6.Text – TextBox12.Text / 12
End If
Dim mySelectQuery As String = “UPDATE IASINVITEM SET CHANGEDBY=’PARCA’ , QUANTITY=’” & TextBox6.Text & “‘,SKQUANTITY=’” & TextBox6.Text & “‘ WHERE INVDOCTYPE=’” & TextBox9.Text & “‘ AND INVDOCNUM=’” & TextBox10.Text & “‘ AND INVDOCITEM=’” & TextBox11.Text & “‘;”

Dim SqlComm As New System.Data.SqlClient.SqlCommand(mySelectQuery, SqlConn)
SqlComm.ExecuteNonQuery()
SqlConn.Close()
Else
MessageBox.Show(“barkod okutun”)
End If

End If
TextBox7.Text = “”
TextBox8.Text = “”
TextBox12.Text = “”

 

End Sub

Private Sub TextBox8_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox8.GotFocus
TextBox1.Text = “”
TextBox2.Text = “”
TextBox3.Text = “”
TextBox4.Text = “”
TextBox5.Text = “”
TextBox6.Text = “”
TextBox7.Text = “”
TextBox9.Text = “”
TextBox10.Text = “”
TextBox11.Text = “”
TextBox12.Text = “”
End Sub

Private Sub TextBox8_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox8.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then
Button1_Click(sender, New System.EventArgs())
End If
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

TextBox2.Text = “”
TextBox3.Text = “”
End Sub

Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
Me.Close()
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox8.Focus()
Try
SqlConn.Open()
Catch ex As Exception
MessageBox.Show(ex.Message, “baglantı yok”)

Me.Close()
End Try
If SqlConn.State = 1 Then

Me.Text = “sql bağlandı”
End If
TextBox1.Text = “”
TextBox2.Text = “”
TextBox3.Text = “”
SqlConn.Close()
End Sub

Private Sub TextBox8_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox8.TextChanged
TextBox1.Text = “”
TextBox2.Text = “”
TextBox3.Text = “”
TextBox4.Text = “”
TextBox5.Text = “”
TextBox6.Text = “”
TextBox7.Text = “”
TextBox9.Text = “”
TextBox10.Text = “”
TextBox11.Text = “”
TextBox12.Text = “”
End Sub

Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged
kullanici = “PARCAGIR”
End Sub

Private Sub TextBox12_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox12.TextChanged
kullanici = “PARCACIK”
End Sub
End Class

Bir Cevap Yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir