📄 reportinput.aspx.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Public Class ReportInput
Inherits clsReport
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents ButtonOk As System.Web.UI.WebControls.Button
Protected WithEvents TableDetail As System.Web.UI.HtmlControls.HtmlTable
Protected WithEvents ProductName As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents TableHead As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents ProductAddress As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents CheckedCompany As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents SampleBase As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents Brand As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents SampleBy As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents CheckBoxReportInputFinish As System.Web.UI.HtmlControls.HtmlInputCheckBox
Protected WithEvents DropDownListReportID As System.Web.UI.WebControls.DropDownList
Protected WithEvents SampleAddress As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents MusterBatch As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents DropDownListAddress As System.Web.UI.WebControls.DropDownList
Protected WithEvents TableSpec As System.Web.UI.HtmlControls.HtmlTable
Protected WithEvents RequiredFileProductName As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldAddress As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents ValidationSummary1 As System.Web.UI.WebControls.ValidationSummary
Protected WithEvents ExpResult As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents TestResult As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents TestDevice As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents RequiredFieldValidatorSampleAddress As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldValidatorCheckedCompany As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldValidatorMusterBatch As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldValidatorSampleBase As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldValidatorSampleBy As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents RequiredFieldValidatorBrand As System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents SelectTestResult As System.Web.UI.HtmlControls.HtmlSelect
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Dim newTr As HtmlTableRow
Dim newTd As HtmlTableCell
Dim strControlID, strControlValue As String '控件ID,控件Value
'显示对应报告编号的录入界面
Private Sub DisplayInputInterFace(ByVal strReportID As String, ByVal strAddress As String)
'普通项目
PubStrSql = "Select * from TaskBookPrj where TestID='" & strReportID _
& "' and Address='" & strAddress & "' order by IceBoxSerial,Project"
PubDataAdapter.SelectCommand.CommandText = PubStrSql
PubDataAdapter.Fill(PubDataSet, "TableTaskBookPrj")
'特殊项目
PubStrSql = "Select * from SpecialProject where TestID='" & strReportID _
& "' and Address='" & strAddress & "' order by IceBoxSerial,ProjectName"
PubDataAdapter.SelectCommand.CommandText = PubStrSql
PubDataAdapter.Fill(PubDataSet, "TableSpecialProject")
'显示与第一个报告编号对应的录入界面
'将静态部分的默认值显示出来
PubStrSql = "select ProductName,ProductAddress,CheckedCompany,SampleAddress," _
& "SampleBase,MusterBatch,SampleBy,Brand,ExpResult,TestDevice from" _
& " report where TestID='" & strReportID _
& "' and Address='" & strAddress & "'"
DisplayInHTMLInput(PubStrSql)
TableDetail.Controls.Clear()
TableSpec.Controls.Clear()
'生成普通项目检测结果录入表格
For i = 0 To PubDataSet.Tables("TableTaskBookPrj").Rows.Count
newTr = New HtmlTableRow()
newTr.Align = HorizontalAlign.Center
For j = 0 To 4
newTd = New HtmlTableCell()
newTd.Controls.Add(New LiteralControl())
newTr.Cells.Add(newTd)
Next
TableDetail.Rows.Add(newTr)
Next
'设置普通项目的第一行表头
With TableDetail.Rows(0)
.Cells(0).InnerText = "实验项目"
.Cells(1).InnerText = "编号"
.Cells(2).InnerText = "检测结果"
.Cells(3).InnerText = "单项判定"
.Cells(4).InnerText = "备注"
End With
Dim objTextArea As HtmlTextArea
Dim strProjectName As String
Dim objDropDown As DropDownList
'具体项目录入
For i = 1 To PubDataSet.Tables("TableTaskBookPrj").Rows.Count
strProjectName = Trim(PubDataSet.Tables("TableTaskBookPrj").Rows(i - 1)("Project"))
With TableDetail.Rows(i)
.Cells(0).InnerText = Trim(PubDataSet.Tables("TableTaskBookPrj").Rows(i - 1)("Project")) _
& Trim(PubDataSet.Tables("TableTaskBookPrj").Rows(i - 1)("TestStandard"))
.Cells(1).InnerText = Trim(PubDataSet.Tables("TableTaskBookPrj").Rows(i - 1)("IceBoxSerial"))
'检测结果
objTextArea = New HtmlTextArea()
With objTextArea
.ID = "TextArea_Result_" & i
.Cols = 20
.Rows = 2
.InnerText = Trim(PubDataSet.Tables("TableTaskBookPrj").Rows(i - 1)("TestResult"))
If .InnerText.Trim = "" Then
If InStr(strProjectName, "℃") Then
.InnerText = "冷藏室平均温度:℃" & vbCrLf & "冷冻室最高温度:℃"
ElseIf InStr(strProjectName, "耗电") Then
.InnerText = "kW.h/24h"
ElseIf InStr(strProjectName, "冷冻能力") Then
.InnerText = "实验过程中M包最高温度:℃" & vbCrLf & "实验结束时M包最高温度:℃"
End If
End If
End With
.Cells(2).Controls.Add(objTextArea)
'单项判定
objDropDown = New DropDownList()
With objDropDown
.ID = "DangXiangPanDing_" & i
.Items.Add("不合格")
.Items.Add("合格")
.Items.Add("不判定")
.SelectedIndex = PubDataSet.Tables("TableTaskBookPrj").Rows(i - 1)("Qualified")
End With
.Cells(3).Controls.Add(objDropDown)
'备注
objTextArea = New HtmlTextArea()
With objTextArea
.ID = "BeiZhu_" & i
.InnerText = Trim(PubDataSet.Tables("TableTaskBookPrj").Rows(i - 1)("Remark"))
End With
.Cells(4).Controls.Add(objTextArea)
End With
Next
'生成特殊项目检测结果录入表格
For i = 0 To PubDataSet.Tables("TableSpecialProject").Rows.Count
newTr = New HtmlTableRow()
For j = 0 To 4
newTd = New HtmlTableCell()
newTd.Controls.Add(New LiteralControl())
newTr.Cells.Add(newTd)
Next
TableSpec.Rows.Add(newTr)
Next
For i = 1 To PubDataSet.Tables("TableSpecialProject").Rows.Count
With TableSpec.Rows(i)
.Cells(0).InnerText = Trim(PubDataSet.Tables("TableSpecialProject").Rows(i - 1)("ProjectName"))
.Cells(1).InnerText = Trim(PubDataSet.Tables("TableSpecialProject").Rows(i - 1)("IceBoxSerial"))
objTextArea = New HtmlTextArea()
With objTextArea
.ID = "Spec_Result_" & i
.InnerText = Trim(PubDataSet.Tables("TableSpecialProject").Rows(i - 1)("TestResult"))
End With
.Cells(2).Controls.Add(objTextArea)
objDropDown = New DropDownList()
With objDropDown
.ID = "Spec_DanXiangPanDing_" & i
.Items.Add("不合格")
.Items.Add("合格")
.Items.Add("不判定")
.SelectedIndex = PubDataSet.Tables("TableSpecialProject").Rows(i - 1)("Qualified")
End With
.Cells(3).Controls.Add(objDropDown)
objTextArea = New HtmlTextArea()
With objTextArea
.ID = "Spec_BeiZhu_" & i
.InnerText = Trim(PubDataSet.Tables("TableSpecialProject").Rows(i - 1)("Remark"))
End With
.Cells(4).Controls.Add(objTextArea)
End With
Next
PubDataSet.Clear()
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'禁用缓存
Response.Cache.SetNoServerCaching()
If Not IsPostBack Then
If DropDownListAddress.Items.Count <> 0 Then
DropDownListAddress.Items.Clear()
End If
DropDownListAddress.Items.Add(Trim(Session("UserAddress")))
'从数据库中将符合条件的报告编号检索出来,并将值赋给DropDownList
'首先从Report中检索出有待录入的报告
PubStrSql = "select Report.TestID from Report,TaskBook where Finished=0" _
& " and Report.TestID=TaskBook.TestID and TaskBook.State>=1" _
& " and TaskBook.AcceptFlag=1 and " _
& " TaskBook.Address=Report.Address and TaskBook.Address='" _
& DropDownListAddress.SelectedItem.Text.Trim & "' order by Report.TestID"
'显示报告编号
DisplayOneColumnInDropDownList(PubStrSql, DropDownListReportID)
With DropDownListReportID
If .Items.Count > 0 Then
'显示第一个实验报告的固定部分
'动态生成实验项目结论录入表格
DisplayInputInterFace(.SelectedItem.Text.Trim, DropDownListAddress.SelectedItem.Text.Trim)
End If
End With
End If
End Sub
Private Sub ButtonOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOk.Click
'使用事务更新数据库
PubSqlTransaction = PubSqlConn.BeginTransaction
PubSqlCmd.Transaction = PubSqlTransaction
Try
'更新任务书表
PubStrSql = "update TaskBook set TestResult='" & SelectTestResult.Value.Trim _
& "' where TestId='" & DropDownListReportID.SelectedItem.Value.Trim _
& "' and Address='" & DropDownListAddress.SelectedItem.Text.Trim & "'"
PubSqlCmd.CommandText = PubStrSql
PubSqlCmd.ExecuteNonQuery()
'修改DataSet中的TaskBookPrj_Value,TaskBookPrj_Project
'更新Report表
'实例化DataSet中的表
PubStrSql = "Select * from Report where TestID='" _
& Trim(DropDownListReportID.SelectedItem.Value) & "' and Address='" _
& DropDownListAddress.SelectedItem.Text.Trim & "'"
PubDataAdapter.SelectCommand.CommandText = PubStrSql
PubDataAdapter.Fill(PubDataSet, "Report")
PubSqlCmdBuilder.DataAdapter = PubDataAdapter
With PubDataSet.Tables("Report")
.Rows(0)("ProductName") = Trim(ProductName.Value)
.Rows(0)("ProductAddress") = Trim(ProductAddress.Value)
.Rows(0)("CheckedCompany") = Trim(CheckedCompany.Value)
.Rows(0)("SampleAddress") = Trim(SampleAddress.Value)
.Rows(0)("SampleBase") = Trim(SampleBase.Value)
.Rows(0)("MusterBatch") = Trim(MusterBatch.Value)
.Rows(0)("SampleBy") = Trim(SampleBy.Value)
.Rows(0)("Brand") = Trim(Brand.Value)
If Trim(ExpResult.Value) = "" Then
.Rows(0)("ExpResult") = ""
Else
.Rows(0)("ExpResult") = Replace(Trim(ExpResult.Value), vbCrLf, "")
End If
If Trim(TestDevice.Value) = "" Then
.Rows(0)("TestDevice") = " "
Else
.Rows(0)("TestDevice") = Replace(Trim(TestDevice.Value), vbCrLf, "")
End If
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -