看到各位老师写的代码都是错落有致,美观大方,就好比一篇Word格式的文章,段落有致,才好看,如果乱排一通则让人看得头晕.
请教各位老师,写代码时格式是否有一个标准?标准是怎样的?请指教.
下面是自己的一段代码,看起来就是难看.
Dim dr1,dr2,dr3 As DataRow
Dim ld As Date
Dim str1,str2,str3,str4,str5,str6,mk As string
Dim r As integer
str1 = e.form.Controls("ComboBox3").Value
str2 = e.form.Controls("TextBox19").Value
str3 = e.form.Controls("TextBox7").Value
str4 = date.today
str5 = e.form.Controls("TextBox18").Value
str6 = e.form.controls("TextBox17").Value
if str1 is nothing then
msgbox("请选择出院患者住院号!",64,"提示")
Else
if str6 is nothing then
msgbox("此患者未办理出院申请!",64,"提示")
Else
dr1 = DataTables("住院登记").Find("住院号 = '"& str1 &"'")
If dr1("出院结账") = True Then
msgbox("此患者已出院结账!",64,"提示")
Else
dr1("出院结账") = True
dr2 = DataTables("出院结账").Find("住院ID = '"& str2 &"'")
If dr2 IsNot nothing Then
msgbox("已存在相同结账记录,请联系管理员修正程序!",64,"提示")
Else
Dim cmd As New SQLcommand
cmd.C
cmd.CommandText = "Insert Into 出院结账 (住院号, 住院ID, 姓名,结账日期,入院日期) Values('" & str1 & "', '" & str2 & "', '" & str3 & "', '" & str4 & "', '" & str5 & "')"
cmd.ExecuteNonQuery()
DataTables("出院结账").Load()
Dim dtb As New DataTableBuilder("清单0")
dtb.AddDef("住院ID", GetType(String), 32)
dtb.AddDef("类别", GetType(String), 32)
dtb.AddDef("项目", GetType(String), 32)
dtb.AddDef("规格", GetType(String), 32)
dtb.AddDef("单位", GetType(String), 32)
dtb.AddDef("单价", GetType(Double))
dtb.AddDef("用量", GetType(Double))
dtb.AddDef("小计", GetType(Double))
dtb.Build()
Dim Cz As DataTable = DataTables("长嘱")
Dim Lz As DataTable = DataTables("临嘱")
mk = "[住院ID] = '" & str2 & "'"
dim f As New Filler
f.SourceTable = Cz
f.SourceCols = "住院ID,类别,项目,规格,单位,单价,总用量,金额"
f.DataTable = DataTables("清单0")
f.DataCols = "住院ID,类别,项目,规格,单位,单价,用量,小计"
f.Filter = mk
f.Fill()
f.SourceTable = Lz
f.SourceCols = "住院ID,类别,项目,规格,单位,单价,用量,小计"
f.DataTable = DataTables("清单0") '指定数据接收表
f.DataCols = "住院ID,类别,项目,规格,单位,单价,用量,小计"
f.Filter = mk
f.Fill()
Dim dst0 As WinForm.DataList = e.Form.Controls("DataList5")
dst0.DataTable = DataTables("清单0")
dst0.Build()
dr3 = DataTables("出院结账").Find("住院ID = '"& str2 &"'")
r = Tables("出院结账").FindRow(dr3)
Dim ColNames() As String = {"西药","中成药","中草药","床位","诊查","检查","护理","治疗","手术","检验","其他","特需服务","其他"}
For Each ColName As String In ColNames
Tables("出院结账").Rows(r)(ColName) = DataTables("清单0").Compute("sum(小计)","[类别] = '" & ColName & "'")+0
Next
For Each dt As DataTable In DataTables
dt.Save()
Next
if MessageBox.Show("'"& str3 &"'结账成功,打印fa piao吗?","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) = 1
Forms("fa piao打印").Open
end if
'生成在院患者情况列表
cmd.CommandText = "Select 入院日期,住院号,姓名,性别,年龄,入院诊断,费用类别,出院诊断,出院申请 From [住院登记] where 出院结账 = false"
Dim dst As WinForm.DataList = e.Form.Controls("DataList3")
dst.DataTable = cmd.ExecuteReader()
dst.Build()
End If
End If
End If
End If
[此贴子已经被作者于2009-1-14 15:40:05编辑过]