|
|
|
สอบถามคำสั่ง dgv_CellMouseUp เเต่ก่อนได้ เเต่มาใส่ฟอร์มเเม่เเล้วไม่ได้ ย้ายข้อมูลเเล้วไม่ไป ติดที่ ฟอร์มเเม่ (frmmain) |
|
|
|
|
|
|
|
เเต่ก่อนได้ เเต่มาใส่ฟอร์มเเม่เเล้วไม่ได้ ย้ายข้อมูลเเล้วไม่ไป ติดที่ ฟอร์มเเม่ (frmmain)
ตัวอย่างโค้ดครัต้องเเก้ยังไง
Code (VB.NET)
Imports System.Data.SqlClient
Public Class search_land
Dim Conn As SqlConnection = New SqlConnection
Dim ds As New DataSet
Dim da As SqlDataAdapter
Private Sub btnsearch_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
'If MsgBox("คุณต้องการค้นหาข้อมูลใช่หรือไม่ ?", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "ค้นหาข้อมูล") = MsgBoxResult.Ok Then
Try
ds.Tables.Clear()
Dim ra As String = ""
If RadioButton1.Checked Then
'Me.Label1.Text = "ตามรหัส"
ra = "LANDID"
End If
If RadioButton2.Checked Then
ra = "PARCEL_CODE"
End If
If TextBox4.Text = "" Then
MsgBox("กรุณากรอกข้อมูลที่ต้องการค้นหา", MsgBoxStyle.Information)
Me.Close()
Else
Dim strConn As String
strConn = "Data Source=.\SQLEXPRESS;Initial Catalog=SSPEGIS;Integrated Security=True"
With Conn
If .State = ConnectionState.Open Then .Close() 'ถ้าเปิดอยู่ให้ปิดการเชื่อมต่อ Connection ก่อน
.ConnectionString = strConn ' กำหนดรูปแบบและฐานข้อมูลสำหรับการติดต่อ
.Open() 'ทำการติดต่อฐานข้อมูล
End With
Dim sql As String = "SELECT * from landView_1 where " & ra & " like '" & TextBox4.Text & "%'"
da = New SqlDataAdapter(sql, Conn)
da.Fill(ds, "landView_1")
myGridView.DataSource = ds.Tables("landView_1")
TextBox4.Clear()
End If
' If dgv1.DataSource = "" Then
'MsgBox("iiii")
' End If
Catch ex As Exception
MessageBox.Show(ex.ToString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
' End If
Dim cs As New DataGridViewCellStyle
cs.Font = New Font("ms sans serif", 10, FontStyle.Regular)
cs.Alignment = DataGridViewContentAlignment.MiddleCenter
cs.ForeColor = Color.Blue
With myGridView
.ColumnHeadersDefaultCellStyle = cs
.Columns(0).HeaderText = "LANDID"
.Columns(1).HeaderText = "รหัสภาษี"
.Columns(2).HeaderText = "รหัสเเผนที่"
.Columns(0).Width = 180
.Columns(1).Width = 140
.Columns(2).Width = 100
.Columns(0).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(1).SortMode = DataGridViewColumnSortMode.NotSortable
.Columns(2).SortMode = DataGridViewColumnSortMode.NotSortable
End With
End Sub
Private Sub dgv_CellMouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles myGridView.CellMouseUp
If e.RowIndex = -1 Then Exit Sub
With myGridView
frmland.txtLANDID.Text = .Rows.Item(e.RowIndex).Cells(0).Value.ToString()
frmland.txtPARCEL_CODE.Text = .Rows.Item(e.RowIndex).Cells(1).Value.ToString()
frmland.txtPICTURE_CODE.Text = .Rows.Item(e.RowIndex).Cells(2).Value.ToString()
frmland.txtTAMBON_TH.Text = .Rows.Item(e.RowIndex).Cells(5).Value.ToString()
frmland.txtDISTRICT_TH.Text = .Rows.Item(e.RowIndex).Cells(6).Value.ToString()
frmland.txtPROVINCE_TH.Text = .Rows.Item(e.RowIndex).Cells(7).Value.ToString()
frmland.txtLDOC_NO.Text = .Rows.Item(e.RowIndex).Cells(8).Value.ToString()
frmland.txtUTM_RATIO.Text = .Rows.Item(e.RowIndex).Cells(9).Value.ToString()
frmland.txtUTM_CODE.Text = .Rows.Item(e.RowIndex).Cells(10).Value.ToString()
frmland.txtUTM_NO.Text = .Rows.Item(e.RowIndex).Cells(11).Value.ToString()
frmland.txtUTM_NO_P.Text = .Rows.Item(e.RowIndex).Cells(12).Value.ToString()
frmland.txtLAND_NO.Text = .Rows.Item(e.RowIndex).Cells(14).Value.ToString()
frmland.txtSURVEY_NO.Text = .Rows.Item(e.RowIndex).Cells(15).Value.ToString()
frmland.txtDOL_RAI.Text = .Rows.Item(e.RowIndex).Cells(18).Value.ToString()
frmland.txtDOL_NGAN.Text = .Rows.Item(e.RowIndex).Cells(17).Value.ToString()
frmland.txtDOL_WA.Text = .Rows.Item(e.RowIndex).Cells(16).Value.ToString()
frmland.txtLAND_VALUE .Text = .Rows.Item(e.RowIndex).Cells(19).Value.ToString()
frmland.txtTAXED_RAI.Text = .Rows.Item(e.RowIndex).Cells(24).Value.ToString()
frmland.txtTAXED_NGAN.Text = .Rows.Item(e.RowIndex).Cells(25).Value.ToString()
frmland.txtTAXED_WA.Text = .Rows.Item(e.RowIndex).Cells(26).Value.ToString()
frmland.txtTAXRATE.Text = .Rows.Item(e.RowIndex).Cells(27).Value.ToString()
frmland.txtEXTENUATE.Text = .Rows.Item(e.RowIndex).Cells(28).Value.ToString()
frmland.lblEVALUATE_TAX.Text = .Rows.Item(e.RowIndex).Cells(30).Value.ToString()
' frmland.PictureBox1.Image = Image.FromFile(.Rows.Item(e.RowIndex).Cells(36).Value.ToString())
frmland.txtREMARK .Text = .Rows.Item(e.RowIndex).Cells(37).Value.ToString()
frmland.cboEXTENID .Text = .Rows.Item(e.RowIndex).Cells(38).Value.ToString()
frmland.cboAREATAX .Text = .Rows.Item(e.RowIndex).Cells(39).Value.ToString()
frmland.cboLAND_USE .Text = .Rows.Item(e.RowIndex).Cells(41).Value.ToString()
frmland.cboLDOC_TYPE .Text = .Rows.Item(e.RowIndex).Cells(43).Value.ToString()
frmland.txtOWNERID .Text = .Rows.Item(e.RowIndex).Cells(44).Value.ToString()
frmland.txtNAMECODE .Text = .Rows.Item(e.RowIndex).Cells(45).Value.ToString()
frmland.txtFIRSTNAME .Text = .Rows.Item(e.RowIndex).Cells(46).Value.ToString()
frmland.txtPOPID .Text = .Rows.Item(e.RowIndex).Cells(47).Value.ToString()
frmland.txtHOUSENO .Text = .Rows.Item(e.RowIndex).Cells(48).Value.ToString()
frmland.txtMOO.Text = .Rows.Item(e.RowIndex).Cells(49).Value.ToString()
frmland.txtVILLAGENAME_TH .Text = .Rows.Item(e.RowIndex).Cells(50).Value.ToString()
frmland.txtTAMBONID .Text = .Rows.Item(e.RowIndex).Cells(51).Value.ToString()
frmland.txtDISTRICTID .Text = .Rows.Item(e.RowIndex).Cells(52).Value.ToString()
frmland.txtPROVINCE .Text = .Rows.Item(e.RowIndex).Cells(53).Value.ToString()
frmland.txtZIPCODE .Text = .Rows.Item(e.RowIndex).Cells(54).Value.ToString()
frmland.txtOCCUID .Text = .Rows.Item(e.RowIndex).Cells(44).Value.ToString()
frmland.txtFULLNAME1 .Text = .Rows.Item(e.RowIndex).Cells(46).Value.ToString()
frmland.POPID .Text = .Rows.Item(e.RowIndex).Cells(47).Value.ToString()
frmland.HOUSENO .Text = .Rows.Item(e.RowIndex).Cells(48).Value.ToString()
frmland.MOO .Text = .Rows.Item(e.RowIndex).Cells(49).Value.ToString()
frmland.VILLAGENAME_TH .Text = .Rows.Item(e.RowIndex).Cells(50).Value.ToString()
frmland.txtTAMBON_TH .Text = .Rows.Item(e.RowIndex).Cells(51).Value.ToString()
frmland.txtDISTRICT_TH .Text = .Rows.Item(e.RowIndex).Cells(52).Value.ToString()
frmland.txtPROVINCE_TH .Text = .Rows.Item(e.RowIndex).Cells(53).Value.ToString()
frmland.ZIPCODE .Text = .Rows.Item(e.RowIndex).Cells(54).Value.ToString()
If .Rows.Item(e.RowIndex).Cells(42).Value.ToString() = "1"
frmland.RadioButton1 .Checked =True
ElseIf .Rows.Item(e.RowIndex).Cells(42).Value.ToString() = "2"
frmland.RadioButton2.Checked =True
End If
End With
Me.Close()
End Sub
End Class
Tag : .NET, Ms SQL Server 2008, VBScript, Win (Windows App), VB.NET, VS 2010 (.NET 4.x)
|
|
|
|
|
|
Date :
2011-05-30 18:01:52 |
By :
pisansri |
View :
1130 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่มีใครรู้เลยหรอครับ หรือว่าไม่เข้าใจคำถาม
|
|
|
|
|
Date :
2011-06-06 22:01:21 |
By :
pisansri |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|