Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > .NET Framework > Forum > รบกวนดู คอมโบบ็อก ให้หน่อยค่ะ ปัญหาคือว่าเมื่อเรา เอาเม้าท์ไปคลิ๊กที่ข้อมูลใน grid viwe ข้อมูลจะขึ้นมาที่ textBox ที่เอาไว้กรอก


 

[.NET] รบกวนดู คอมโบบ็อก ให้หน่อยค่ะ ปัญหาคือว่าเมื่อเรา เอาเม้าท์ไปคลิ๊กที่ข้อมูลใน grid viwe ข้อมูลจะขึ้นมาที่ textBox ที่เอาไว้กรอก

 
Topic : 031255

Guest



Code (VB.NET)
001.Option Explicit On
002.Option Strict On
003.Imports System.Text
004.Imports System.Data
005.Imports System.Data.SqlClient
006.Imports System.Drawing.Drawing2D
007.Imports System.IO
008.Imports System.Drawing
009.Imports System.Globalization
010. 
011.Public Class frmEmployee
012.    Dim Conn As SqlConnection
013.    Dim com As SqlCommand
014.    Dim dr As SqlDataReader
015.    Dim dtHuman As DataTable
016.    Dim bs As BindingSource = New BindingSource()
017.    Dim tr As SqlTransaction
018.    Dim sb As StringBuilder
019.    Dim CPID As String
020.    Dim CWID As String
021.    Dim Today As DateTime
022.    Dim fs As FileStream
023.    Dim CurrentImage() As Byte
024.    Dim picFileName As String
025.    Dim CBMP As Bitmap
026.    Dim UserName As String
027.    Dim sw As New Stopwatch()
028.    Dim ProcessTime As Double
029.    Dim _ToolStripLabel As New ToolStripLabel
030.    Dim Add As Boolean = False
031.    Dim Edit As Boolean = False
032.    Dim thCul As System.Globalization.CultureInfo = System.Globalization.CultureInfo.GetCultureInfo("th-TH")
033. 
034.    Public Sub New(ByRef refToolStripLabel As ToolStripLabel)
035.        InitializeComponent()
036.        _ToolStripLabel = refToolStripLabel
037.    End Sub
038. 
039.    Private Sub frmAddHuman_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
040.        Me.WindowState = FormWindowState.Maximized
041.        gbxempp.BackColor = Color.FromArgb(0, 0, 0, 0)
042. 
043.        Dim FD As New FormFader
044.        FD.FadeIn(Me, 0.25)
045. 
046.        sw.Reset()
047.        sw.Start()
048. 
049.        Dim strConn As String
050.        strConn = DBMtech.strcnn
051.        Conn = New SqlConnection()
052. 
053.        With Conn
054.            If .State = ConnectionState.Open Then .Close()
055.            .ConnectionString = strConn
056.            .Open()
057.        End With
058. 
059.        sb = New StringBuilder()
060.        sb.Append("SELECT * FROM TbPosition;")
061.        sb.Append("SELECT * FROM TbDepartment;")
062.        Dim sqlIni As String
063.        sqlIni = sb.ToString()
064. 
065.        com = New SqlCommand()
066.        With com
067.            .CommandText = sqlIni
068.            .CommandType = CommandType.Text
069.            .Connection = Conn
070.            dr = .ExecuteReader()
071.        End With
072. 
073.        If dr.HasRows Then
074.            Dim dtPosition As DataTable
075.            dtPosition = New DataTable()
076.            dtPosition.Load(dr)
077.            With cboPosition
078.                .BeginUpdate()
079.                .DisplayMember = "PositionName"
080.                .ValueMember = "PositionID"
081.                .DataSource = dtPosition
082.                .EndUpdate()
083.            End With
084. 
085.            Dim dtDepartment As DataTable
086.            dtDepartment = New DataTable()
087.            dtDepartment.Load(dr)
088.            With cbodepartment
089.                .BeginUpdate()
090.                .DisplayMember = "DepartmentName"
091.                .ValueMember = "DepartmentID"
092.                .DataSource = dtDepartment
093.                .EndUpdate()
094.            End With
095.        End If
096. 
097.       
098.        cbodepartment.ContextMenu = New ContextMenu()
099.        cboPosition.ContextMenu = New ContextMenu()
100. 
101.        Today = DateTime.Today
102. 
103.     
104.        Showdata()
105.        FormatDgvEmployeeList()
106.        Textdisable()
107. 
108.        sw.Stop()
109.        ProcessTime = sw.ElapsedMilliseconds / 1000
110.        _ToolStripLabel.Text = "เวลาที่ใช้ : " & ProcessTime.ToString("0.0000") & " วินาที"
111. 
112.    End Sub
113. 
114.    Private Sub ClearHuman()
115.        txtempid.Text = ""
116.        txtname.Text = ""
117.        txtAddress.Text = ""
118.        txttel.Text = ""
119. 
120.    End Sub
121.    Private Sub Textenable()
122. 
123.        txtempid.Enabled = True
124.        txtname.Enabled = True
125.        cboInitial.Enabled = True
126.        cboPosition.Enabled = True
127.        cbodepartment.Enabled = True
128.        txtAddress.Enabled = True
129.        txttel.Enabled = True
130. 
131.    End Sub
132.    Private Sub Textdisable()
133. 
134.        txtempid.Enabled = False
135.        txtname.Enabled = False
136.        cboInitial.Enabled = False
137.        cboPosition.Enabled = False
138.        cbodepartment.Enabled = False
139.        txtAddress.Enabled = False
140.        txttel.Enabled = False
141. 
142.    End Sub
143.    Private Sub Showdata()
144. 
145.        Dim sqlEmployee As String
146.        sqlEmployee = "SELECT * FROM TbEmployee ORDER BY EmployeeID"
147. 
148.        Dim dr As SqlDataReader
149.        Dim dt As DataTable
150.        com = New SqlCommand()
151. 
152.        With com
153.            .CommandType = CommandType.Text
154.            .CommandText = sqlEmployee
155.            .Connection = Conn
156.            dr = .ExecuteReader()
157.            If dr.HasRows Then
158.                dt = New DataTable()
159.                dt.Load(dr)
160.                dgvemplist.DataSource = dt
161. 
162.            Else
163.                dgvemplist.DataSource = Nothing
164.            End If
165.            dr.Close()
166.        End With
167.    End Sub
168. 
169.    Private Sub FormatDgvEmployeeList()
170.        With dgvemplist
171.            If .RowCount > 0 Then
172.                .Columns(0).HeaderText = "รหัสพนักงาน"
173.                .Columns(1).HeaderText = "คำนำหน้าชื่อ"
174.                .Columns(2).HeaderText = "ชื่อ-นามสกุลพนักงาน"
175.                .Columns(3).HeaderText = "ตำแหน่งงาน"
176.                .Columns(4).HeaderText = "สังกัดฝ่าย"
177.                .Columns(5).HeaderText = "ที่อยู่"
178.                .Columns(6).HeaderText = "เบอร์โทร"
179.                
180.                .Columns(0).Width = 80
181.                .Columns(1).Width = 60
182.                .Columns(2).Width = 120
183.                .Columns(3).Width = 100
184.                .Columns(4).Width = 100
185.                .Columns(5).Width = 220
186.                .Columns(6).Width = 100
187.               
188. 
189.            End If
190.        End With
191.    End Sub
192. 
193.    Private Sub dgvemplist_CellMouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgvemplist.CellMouseUp
194.        If e.RowIndex = -1 Then Exit Sub
195. 
196.        With dgvemplist
197.            txtempid.Text = .Rows.Item(e.RowIndex).Cells(0).Value.ToString()
198.            cboInitial.SelectedValue = .Rows.Item(e.RowIndex).Cells(1).ValueType.ToString()
199.            txtname.Text = .Rows.Item(e.RowIndex).Cells(2).Value.ToString()
200.            cbodepartment.SelectedValue = .Rows.Item(e.RowIndex).Cells(3).Value.ToString()
201.            cboPosition.SelectedValue = .Rows.Item(e.RowIndex).Cells(4).Value.ToString()
202.            txtAddress.Text = .Rows.Item(e.RowIndex).Cells(5).Value.ToString()
203.            txttel.Text = .Rows.Item(e.RowIndex).Cells(6).Value.ToString()
204. 
205.            txtname.Focus()
206.            txtname.SelectAll()
207.        End With
208. 
209.    End Sub
210. 
211.    Private Sub ClearBinding()
212.        txtempid.DataBindings.Clear()
213.        cbodepartment.DataBindings.Clear()
214.        cboPosition.DataBindings.Clear()
215.        txtname.DataBindings.Clear()
216.        txtAddress.DataBindings.Clear()
217.        txttel.DataBindings.Clear()
218. 
219.    End Sub
220. 
221.    Private Sub cmdsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
222.        If (txtname.Text.Trim() = "") OrElse (txtAddress.Text.Trim() = "") OrElse (txttel.Text.Trim() = "") Then
223.            MessageBox.Show("กรุณาป้อนข้อมูลให้ครบทุกช่อง !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
224.            txtname.Focus()
225.            Exit Sub
226.        End If
227. 
228.        If cboPosition.Text.Trim() = "" Then
229.            MessageBox.Show("กรุณาคลิกเลือกตำแหน่งงานก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
230.            Exit Sub
231.        End If
232. 
233.        If cbodepartment.Text.Trim() = "" Then
234.            MessageBox.Show("กรุณาคลิกเลือกตำแหน่งงานก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
235.            Exit Sub
236.        End If
237. 
238.        If Add Then
239.            If MessageBox.Show("คุณต้องการบันทึกข้อมูลพนักงานใหม่ ใช่หรือไม่?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
240. 
241.                sw.Reset()
242.                sw.Start()
243.                tr = Conn.BeginTransaction()
244. 
245.                Dim dtfInfo As DateTimeFormatInfo
246.                dtfInfo = DateTimeFormatInfo.InvariantInfo
247. 
248.                Try
249.                     sb.Remove(0, sb.Length)
250.                    sb.Append(" INSERT INTO TbEmployee (EmployeeID,Initial,EmployeeName,")
251.                    sb.Append(" PositionID,DepartmentID,EmployeeAddress,EmployeeTel)")
252.                    sb.Append(" VALUES (@EmployeeID,@Initial,@EmployeeName,")
253.                    sb.Append(" @PositionID,@DepartmentID,@EmployeeAddress,@EmployeeTel)")
254. 
255.                    Dim sqlAdd As String
256.                    sqlAdd = sb.ToString()
257.                    Dim time As String
258. 
259.                    time = "01/07/2009 9:11:23 pm"
260.                With com
261.                        .CommandText = sqlAdd
262.                        .CommandType = CommandType.Text
263.                        .Connection = Conn
264.                        .Transaction = tr
265.                        .Parameters.Clear()
266.                        .Parameters.Add("@EmployeeID", SqlDbType.NVarChar).Value = txtempid.Text
267.                        .Parameters.Add("@Initial", SqlDbType.NVarChar).Value = cboInitial.SelectedItem.ToString()
268.                        .Parameters.Add("@EmployeeName", SqlDbType.NVarChar).Value = txtname.Text.Trim()
269.                        .Parameters.Add("@EmployeeAddress", SqlDbType.NVarChar).Value = txtAddress.Text.Trim()
270.                        .Parameters.Add("@EmployeeTel", SqlDbType.NVarChar).Value = txttel.Text.Trim()
271.                        .Parameters.Add("@PositionID", SqlDbType.NVarChar).Value = cboPosition.SelectedValue.ToString
272.                        .Parameters.Add("@DepartmentID", SqlDbType.NVarChar).Value = cbodepartment.SelectedValue.ToString
273.                        .ExecuteNonQuery()
274. 
275.                    End With
276.                    tr.Commit()
277. 
278.                    sw.Stop()
279.                    ProcessTime = sw.ElapsedMilliseconds / 1000
280.                    _ToolStripLabel.Text = "เวลาที่ใช้ : " & ProcessTime.ToString("0.0000") & " วินาที"
281. 
282.                    MessageBox.Show("บันทึกข้อมูลพนักงานใหม่ เรียบร้อยแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
283. 
284.                    ClearHuman()
285.                    Showdata()
286.                    FormatDgvEmployeeList()
287. 
288.                    cmdadd.Enabled = True
289.                    cmdsave.Enabled = False
290.                    cmdedit.Enabled = True
291.                    cmdclar.Enabled = True
292.                    cmdcancel.Enabled = False
293.                    cmddel.Enabled = True
294.                    Textdisable()
295. 
296.                Catch ex As Exception
297. 
298.                    MessageBox.Show("เกิดข้อผิดพลาด เนื่องจาก " & ex.Message, "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
299.                    tr.Rollback()
300.                End Try
301.            End If
302.            Add = False
303.        End If
304. 
305.        If Edit Then
306.            If MessageBox.Show("คุณต้องการ แก้ไขข้อมูลพนักงานใหม่ ใช่หรือไม่?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
307. 
308.                sw.Reset()
309.                sw.Start()
310.                tr = Conn.BeginTransaction()
311. 
312.                Try
313.                    sb.Remove(0, sb.Length)
314.                    sb.Append("UPDATE TbEmployee ")
315.                    sb.Append(" SET EmployeeName=@EmployeeName,")
316.                    sb.Append("Initial=@Initial,")
317.                    sb.Append("PositionID=@PositionID,")
318.                    sb.Append("EmployeeAddress=@EmployeeAddress,")
319.                    sb.Append("EmployeeTel=@EmployeeTel,")
320.                    sb.Append("DepartmentID=@DepartmentID)")
321.                    sb.Append(" WHERE (EmployeeID=@EmployeeID)")
322.                    Dim sqlEdit As String
323.                    sqlEdit = sb.ToString()
324. 
325.                    With com
326.                        .CommandText = sqlEdit
327.                        .CommandType = CommandType.Text
328.                        .Connection = Conn
329.                        .Transaction = tr
330.                        .Parameters.Clear()
331.                        .Parameters.Add("@Initial", SqlDbType.NVarChar).Value = CStr(cboInitial.SelectedValue)
332.                        .Parameters.Add("@EmployeeName", SqlDbType.NVarChar).Value = txtname.Text.Trim()
333.                        .Parameters.Add("@EmployeeAddress", SqlDbType.NVarChar).Value = txtAddress.Text.Trim()
334.                        .Parameters.Add("@EmployeeTel", SqlDbType.NVarChar).Value = txttel.Text.Trim()
335.                        .Parameters.Add("@PositinID", SqlDbType.NVarChar).Value = CStr(cboPosition.SelectedValue)
336.                        .Parameters.Add("@DepartmentID", SqlDbType.NVarChar).Value = CStr(cbodepartment.SelectedValue)
337.                        '.ExecuteNonQuery()
338.                    End With
339. 
340.                    tr.Commit()
341. 
342.                    sw.Stop()
343.                    ProcessTime = sw.ElapsedMilliseconds / 1000
344.                    _ToolStripLabel.Text = "เวลาที่ใช้ : " & ProcessTime.ToString("0.0000") & " วินาที"
345. 
346.                    MessageBox.Show("บันทึกข้อมูลพนักงานใหม่ เรียบร้อยแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
347. 
348.                    ClearHuman()
349.                    Showdata()
350.                    FormatDgvEmployeeList()
351. 
352.                    cmdadd.Enabled = True
353.                    cmdsave.Enabled = False
354.                    cmdedit.Enabled = True
355.                    cmdclar.Enabled = True
356.                    cmdcancel.Enabled = True
357.                    cmddel.Enabled = True
358.                     
359. 
360.                Catch ex As Exception
361.                    tr.Rollback()
362.                    MessageBox.Show("เกิดข้อผิดพลาด เนื่องจาก " & ex.Message, "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
363.                End Try
364.            End If
365.            Edit = False
366.        End If
367.        txtempid.Focus()
368.    End Sub
369. 
370.    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
371.        Dim lgb As New LinearGradientBrush(ClientRectangle, Color.FloralWhite, Color.Moccasin, LinearGradientMode.Vertical)
372.        e.Graphics.FillRectangle(lgb, ClientRectangle)
373. 
374.        lgb.Dispose()
375.    End Sub
376. 
377.    Private Sub frmAddHuman_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
378.        If Conn IsNot Nothing Then
379.            Conn.Close()
380.        End If
381.    End Sub
382. 
383.    Private Sub cboPosition_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cboPosition.KeyPress
384.        e.Handled = True
385.    End Sub
386. 
387.    Private Sub cboProvince_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
388.        e.Handled = True
389.    End Sub
390. 
391.    Private Sub cboDepartment_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cbodepartment.KeyPress
392.        e.Handled = True
393.    End Sub
394. 
395.    Private Sub cmdadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdadd.Click
396.        Textenable()
397.        Add = True
398.        cmdadd.Enabled = False
399.        cmdsave.Enabled = True
400.        cmdedit.Enabled = False
401.        cmdclar.Enabled = False
402.        cmddel.Enabled = False
403.        cmdcancel.Enabled = True
404.        txtempid.Focus()
405. 
406.    End Sub
407. 
408.    Private Sub cmdAutoID_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAutoID.Click
409.        Dim sqlAuto As String
410.        Dim dr As SqlDataReader
411.        Dim temp As String = ""
412.        Dim nextnum As Int32
413.        sqlAuto = "SELECT MAX(EmployeeID) EmployeeID  FROM TbEmployee"
414. 
415. 
416.        com = New SqlCommand()
417.        With com
418.            .CommandType = CommandType.Text
419.            .CommandText = sqlAuto
420.            .Connection = Conn
421.            dr = .ExecuteReader()
422.            If dr.HasRows Then
423.                While dr.Read
424.                    temp = CStr(dr.Item("EmployeeID"))
425. 
426.                    temp = temp.Substring(3, 3)
427. 
428.                    nextnum = CInt(temp)
429.                    nextnum += 1
430.                     
431.                End While
432.            End If
433.            dr.Close()
434.        End With
435.        If nextnum < 10 Then
436.            txtempid.Text = "MT-00" & nextnum
437.        ElseIf nextnum > 9 And nextnum < 100 Then
438.            txtempid.Text = "MT-0" & nextnum
439.        ElseIf nextnum > 99 And nextnum < 1000 Then
440.            txtempid.Text = "MT-" & nextnum
441.        End If
442.       
443.    End Sub
444. 
445.    Private Sub cmdedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdedit.Click
446. 
447.        If (txtname.Text.Trim() = "") OrElse (txtAddress.Text.Trim() = "") OrElse (txttel.Text.Trim() = "") Then
448.            MessageBox.Show("กรุณาป้อนข้อมูลให้ครบทุกช่อง !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
449.            txtname.Focus()
450.            Exit Sub
451.        End If
452. 
453.        If cboPosition.Text.Trim() = "" Then
454.            MessageBox.Show("กรุณาคลิกเลือกตำแหน่งงานก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
455.            Exit Sub
456.        End If
457. 
458.        If cbodepartment.Text.Trim() = "" Then
459.            MessageBox.Show("กรุณาคลิกเลือกตำแหน่งงานก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
460.            Exit Sub
461.        End If
462. 
463.        Edit = True
464.        cmdadd.Enabled = False
465.        cmdsave.Enabled = True
466.        cmdedit.Enabled = False
467.        cmdclar.Enabled = False
468.        cmdcancel.Enabled = True
469.        cmddel.Enabled = False
470. 
471.        txtempid.Focus()
472.    End Sub
473. 
474.    Private Sub cmdclar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdclar.Click
475.        ClearHuman()
476.        txtempid.Focus()
477.        Showdata()
478. 
479.    End Sub
480. 
481.    Private Sub cmdcancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcancel.Click
482.        cmdadd.Enabled = True
483.        cmdsave.Enabled = False
484.        cmdedit.Enabled = False
485.        cmdclar.Enabled = False
486.        cmdcancel.Enabled = False
487.        Textdisable()
488.        txtempid.Focus()
489.        ClearHuman()
490.    End Sub
491. 
492.    Private Sub cmddel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmddel.Click
493.        If txtempid.Text.Trim() = "" Then
494.            MessageBox.Show("กรุณาป้อนรหัสพนักงานก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
495.            txtempid.Focus()
496.            Exit Sub
497.        End If
498. 
499.        If MessageBox.Show("คุณต้องการลบข้อมูลพนักงาน ใช่หรือไม่?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
500.            sw.Reset()
501.            sw.Start()
502.            tr = Conn.BeginTransaction()
503.            Try
504.                sb = New StringBuilder()
505.                sb.Append("DELETE FROM TbEmployee")
506.                sb.Append(" WHERE (EmployeeID=@EmployeeID)")
507.                Dim sqlDel As String
508.                sqlDel = sb.ToString()
509. 
510.                With com
511.                    .CommandText = sqlDel
512.                    .CommandType = CommandType.Text
513.                    .Connection = Conn
514.                    .Transaction = tr
515.                    .Parameters.Clear()
516.                    .Parameters.Add("@EmployeeID", SqlDbType.NVarChar).Value = txtempid.Text.Trim()
517. 
518. 
519.                    Dim result As Integer
520.                    result = .ExecuteNonQuery()
521.                    If result = 0 Then
522.                        tr.Rollback()
523.                        MessageBox.Show("รหัสพนักงานที่คุณป้อน ไม่ถูกต้อง !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
524. 
525.                        txtempid.SelectAll()
526.                    Else
527.                        tr.Commit()
528. 
529.                        sw.Stop()
530.                        ProcessTime = sw.ElapsedMilliseconds / 1000
531.                        _ToolStripLabel.Text = "เวลาที่ใช้ : " & ProcessTime.ToString("0.0000") & " วินาที"
532. 
533.                        MessageBox.Show("ลบข้อมูลพนักงาน เรียบร้อยแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
534. 
535.                        ClearHuman()
536.                        Showdata()
537.                        FormatDgvEmployeeList()
538. 
539.                        cmdadd.Enabled = True
540.                        cmdsave.Enabled = True
541.                        cmdedit.Enabled = True
542.                        cmdclar.Enabled = True
543.                        cmdcancel.Enabled = True
544.                        cmddel.Enabled = True
545.                        Textdisable()
546. 
547.                    End If
548.                End With
549.            Catch ex As Exception
550.                tr.Rollback()
551. 
552.                MessageBox.Show("เกิดข้อผิดพลาด เนื่องจาก ข้อมูลที่จะลบถูกใช้งานอยู่ค่ะ " & ex.Message, "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
553.            End Try
554.        End If
555. 
556.        txtempid.Focus()
557.    End Sub
558. 
559.    Private Sub cmdexitform_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdexitform.Click
560.        Me.Close()
561.    End Sub
562. 
563.     
564.    Private Sub btfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
565.        Dim cmd As SqlCommand
566. 
567.        With Conn
568.            If .State = ConnectionState.Open Then .Close()
569.            Conn.Open()
570.        End With
571.        Dim sqlSelect As String
572.            If Txtenpfind.Text = "" Then
573.            MessageBox.Show("กรุณากรอกข้อมูลที่ต้องการค้นหา", "ตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Information)
574.            Exit Sub
575.        Else
576.            sqlSelect = "SELECT EmployeeID,Initial,EmployeeName,PositionID,DepartmentID,EmployeeAddress,EmployeeTel" & " FROM TbEmployee" & _
577.                        " WHERE EmployeeName LIKE'" & Txtenpfind.Text & "%'"
578. 
579. 
580.        End If
581. 
582.        cmd = New SqlCommand()
583.        With cmd
584.            .CommandType = CommandType.Text
585.            .CommandText = sqlSelect
586.            .Connection = Conn
587.            dr = .ExecuteReader()
588.            Dim dt As DataTable
589.            If dr.HasRows Then
590.                dt = New DataTable
591.                dt.Load(dr)
592.                dgvemplist.DataSource = dt
593.            Else
594.                dgvemplist.DataSource = Nothing
595.            End If
596.        End With
597.        dr.Close()
598.        If dgvemplist.RowCount > 0 Then
599.            FormatDgvEmployeeList()
600.        Else
601.            FormatDgvEmployeeList()
602.            MessageBox.Show("ไม่พบข้อมูลที่คุณค้นหา", "ตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Information)
603.            Showdata()
604.        End If
605.        Txtenpfind.Clear()
606.        dr.Close()
607.        Conn.Close()
608.    End Sub
609. 
610.End Class



ปัญหาคือว่าเมื่อเรา เอาเม้าท์ไปคลิ๊กที่ข้อมูลใน grid viwe ข้อมูลจะขึ้นมาที่ textBox ที่เอาไว้กรอก แต่ว่าข้อมูลมันไม่ขึ้นมาโชว์ที่ช่อง คอมโบบ็อก อยากทราบว่าจะทำไงดี รบกวนด้วยนะคะ



Tag : - - - -

Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-09-03 18:20:20 By : moo View : 1733 Reply : 1
 

 

No. 1

Guest


แก้ไขได้แล้วคะ
Date : 2009-09-04 15:48:55 By : zuna_kib@hotmail.com
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : รบกวนดู คอมโบบ็อก ให้หน่อยค่ะ ปัญหาคือว่าเมื่อเรา เอาเม้าท์ไปคลิ๊กที่ข้อมูลใน grid viwe ข้อมูลจะขึ้นมาที่ textBox ที่เอาไว้กรอก
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่