001.
Imports
MySql.Data.MySqlClient
002.
003.
Public
Class
frm_physic_edit
004.
005.
Private
Sub
txt_hn_KeyDown(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.Windows.Forms.KeyEventArgs)
Handles
txt_hn.KeyDown
006.
If
(e.KeyCode = Keys.Enter)
Then
007.
Dim
strID =
Me
.txt_hn.Text
008.
009.
010.
strID = strID.Trim.PadLeft(9,
"0"
)
011.
txt_hn.Text = strID
012.
013.
Dim
contxt
As
String
=
"c:\ProgramData\sn_tool.txt"
014.
Dim
line()
As
String
= IO.File.ReadAllLines(contxt)
015.
Dim
host
As
String
= line(0)
016.
Dim
user
As
String
= line(1)
017.
Dim
pwd
As
String
= line(2)
018.
Dim
db
As
String
= line(3)
019.
Dim
con
As
MySqlConnection =
New
MySqlConnection()
020.
021.
con.ConnectionString =
String
.Format(
"server={0}; user id={1}; password={2}; database={3}; pooling=false"
, host, user, pwd, db)
022.
sql =
"select intdate,person_deform_head_id as id "
& _
023.
"from person_deform_head "
& _
024.
"where hn='"
& txt_hn.Text &
"' order by intdate desc "
025.
con.Open()
026.
command =
New
MySqlCommand(sql, con)
027.
adapter =
New
MySqlDataAdapter(command)
028.
datast =
New
DataSet()
029.
adapter.Fill(datast,
"dint"
)
030.
031.
gc_int.DataSource = datast.Tables(
"dint"
)
032.
End
If
033.
034.
End
Sub
035.
036.
037.
038.
Private
Sub
gridview1_rowclick(
ByVal
sender
As
Object
,
ByVal
e
As
DevExpress.XtraGrid.Views.Grid.RowClickEventArgs)
Handles
GridView1.RowClick
039.
040.
intdate.Text = GridView1.GetFocusedRowCellValue(
"intdate"
).ToString
041.
txt_id.Text = GridView1.GetFocusedRowCellValue(
"id"
)
042.
043.
044.
showdetails()
045.
046.
End
Sub
047.
Private
Sub
gridview1_SelectionChanged(sender
As
Object
, e
As
EventArgs)
Handles
GridView1.SelectionChanged
048.
GridView1.GetFocusedDataSourceRowIndex()
049.
050.
End
Sub
051.
Private
Sub
showdetails()
052.
If
Not
(datast.Tables(
"pdh"
)
Is
Nothing
)
Then
053.
datast.Tables(
"pdh"
).Clear()
054.
End
If
055.
sql =
"select pid,hn,cid,intdate from person_deform_head where person_deform_head_id = '"
& txt_id.Text &
"'"
056.
command.CommandText = sql
057.
adapter.SelectCommand = command
058.
adapter.Fill(datast,
"pdh"
)
059.
GridControl1.DataSource = datast.Tables(
"pdh"
)
060.
061.
End
Sub
062.
Private
Sub
updatebinding()
063.
txt_hn.DataBindings.Clear()
064.
txt_cid.DataBindings.Clear()
065.
txt_id.DataBindings.Clear()
066.
Dim
contxt
As
String
=
"c:\ProgramData\sn_tool.txt"
067.
068.
Dim
line()
As
String
= IO.File.ReadAllLines(contxt)
069.
Dim
host
As
String
= line(0)
070.
Dim
user
As
String
= line(1)
071.
Dim
pwd
As
String
= line(2)
072.
Dim
db
As
String
= line(3)
073.
Dim
con
As
MySqlConnection =
New
MySqlConnection()
074.
con.ConnectionString =
String
.Format(
"server={0}; user id={1}; password={2}; database={3}; pooling=false"
, host, user, pwd, db)
075.
For
Each
ctrl
As
Control
In
Me
.Controls
076.
ctrl.DataBindings.Clear()
077.
If
TypeOf
ctrl
Is
TextBox
Then
078.
ctrl.Text =
""
079.
End
If
080.
Next
081.
pic.Image =
Nothing
082.
083.
084.
sql =
"select pdh.hn,pdh.vn,pdh.cid,pdh.person_deform_head_id from person_deform_head pdh "
& _
085.
"left outer join patient pt on pdh.cid = pt.cid where person_deform_head_id = 1 "
086.
con.Open()
087.
command =
New
MySqlCommand(sql, con)
088.
adapter =
New
MySqlDataAdapter(command)
089.
datast =
New
DataSet
090.
adapter.Fill(datast,
"master"
)
091.
bidingsrc =
New
BindingSource()
092.
bidingsrc.DataSource = datast.Tables(
"master"
)
093.
txt_hn.DataBindings.Add(
"Text"
, bidingsrc,
"hn"
)
094.
txt_cid.DataBindings.Add(
"text"
, bidingsrc,
"cid"
)
095.
096.
txt_vn.DataBindings.Add(
"text"
, bidingsrc,
"vn"
)
097.
098.
099.
End
Sub
100.
Private
Sub
ListBox1_SelectedIndexChanged(sender
As
Object
, e
As
EventArgs)
Handles
GridView1.FocusedRowChanged
101.
If
(bidingsrc
Is
Nothing
)
Then
102.
Exit
Sub
103.
End
If
104.
bidingsrc.Position = GridView1.GetVisibleIndex(0)
105.
106.
showdetails()
107.
End
Sub
108.
109.
End
Class