หมายเหตุ : ผมยังไม่ได้เปลี่ยนชื่อ control ต่างอาจจะดูแล้วงงๆนิดๆนะครับ
Code (VB.NET)
Private Sub ToolStripMenuItemReciept_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItemReciept.Click
conn.Open()
Dim sql As String = "select * from t_report_receive " &
"where report_number_receive = @report_number_receive"
Dim command As New SqlCommand(sql, conn)
Dim check_report_number As String = InputBox("กรุณากรอก IR Number!", "INPUT")
Dim da As New SqlDataAdapter(command)
Dim ds As New DataSet
command.Parameters.AddWithValue("report_number_receive", check_report_number)
Dim rd As SqlDataReader = command.ExecuteReader
If rd.HasRows Then
MessageBox.Show("IR NUMBER ถูกต้อง!", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information)
receive.Show()
receive.Label20.Text = check_report_number
rd.Close()
da.Fill(ds, "t_report_receive")
If ds.Tables("t_report_receive").Rows(0)("nurse_cause") = "เห็นด้วย" Then
receive.RadioButton1.Checked = True
ElseIf ds.Tables("t_report_receive").Rows(0)("nurse_cause") = "ไม่เห็นด้วย" Then
receive.RadioButton2.Checked = True
ElseIf ds.Tables("t_report_receive").Rows(0)("nurse_cause") = "ข้อเสนอแนะเพิ่มเติม" Then
receive.RadioButton3.Checked = True
receive.TextBox4.Text = ds.Tables("t_report_receive").Rows(0)("nurse_cause2")
End If
receive.TextBox1.Text = ds.Tables("t_report_receive").Rows(0)("cause")
receive.TextBox2.Text = ds.Tables("t_report_receive").Rows(0)("correction")
receive.DateTimePicker1.Value = ds.Tables("t_report_receive").Rows(0)("correction_date")
Me.Hide()
Else
MessageBox.Show("IR NUMBER ไม่ถูกต้อง!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Show()
End If
conn.Close()
End Sub
Dim check_report_number As String = InputBox("กรุณากรอก IR Number!", "INPUT")
Dim dt As new DataTable()
Dim dt1 As new DataTable();
dt.Load(new SqlCommand("select * from t_report_receive where report_number_receive =" & check_report_number, conn).ExecuteReader())
DataRow dr = dt.Rows(0);
dt1.Load(new SqlCommand("select * from t_employee where employee_id =" & dr("employee_id"), conn).ExecuteReader());
DataRow dr1= dt1.Rows[0];