Imports System.Data
Imports System.Data.OracleClient
Partial Class Sum_salary_grupt
Inherits System.Web.UI.Page
Dim Conn As OracleConnection
Dim Cmd As OracleCommand
Dim Cmd2 As OracleCommand
Dim Cmd3 As OracleCommand
Dim sqlx As String
Dim dtReader As OracleDataReader
Dim dtReader2 As OracleDataReader
Dim dtReader3 As OracleDataReader
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strconnstring As String
strconnstring = "Data Source=pkmreg;User Id=pkmreg;Password=oracle;"
Conn = New OracleConnection(strconnstring)
Conn.Open()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
select_per()
End Sub
Sub select_per()
If ComboBox1.Text <> "" And DropDownList2.Text <> "" Then
sqlx = "SELECT OFFICERCODE FROM PEROFFICER WHERE FACULTYID = '" & Me.ComboBox1.Text & "'"
Cmd = New OracleCommand(sqlx, Conn)
dtReader = Cmd.ExecuteReader()
While dtReader.Read()
Dim sum_in As Single
Dim sum_ina As Single
Dim sumz As Single
Dim sum_ex As Single
Dim all_sum_pay As Single
Dim code As String = dtReader.Item("OFFICERCODE")
'############ รายหัก ############################################
Dim sqlx_cou2 As String = "SELECT COUNT(REX_ID) AS COU_EX FROM PER_SALARY_ROUTINE_EX WHERE OFFICERCODE = '" & code & "' AND REX_IOD_CODE = '" & Me.DropDownList2.Text & "'"
Cmd = New OracleCommand(sqlx_cou2, Conn)
dtReader = Cmd.ExecuteReader
dtReader.Read()
Dim cou_ex As String = dtReader.Item("COU_EX")
If cou_ex <> "0" Then
Dim sqlx_ex As String = "SELECT SUM(REX_NUM) AS REX_SUM FROM PER_SALARY_ROUTINE_EX WHERE OFFICERCODE = '" & code & "' AND REX_IOD_CODE = '" & Me.DropDownList2.Text & "'"
Cmd3 = New OracleCommand(sqlx_ex, Conn)
dtReader3 = Cmd3.ExecuteReader
dtReader3.Read()
sum_ex = dtReader3.Item("REX_SUM")
MsgBox("pay : " & sum_ex & "code : " & code)
End If
''############ รายได้ ############################################
Try
Dim sqlx_cou1 As String = "SELECT COUNT(RIN_ID) AS COU_IN FROM PER_SALARY_ROUTINE_IN WHERE OFFICERCODE = '" & code & "'"
Cmd = New OracleCommand(sqlx_cou1, Conn)
dtReader = Cmd.ExecuteReader
dtReader.Read()
Dim cou_in As String = dtReader.Item("COU_IN")
If cou_in <> "0" Then
Dim sqlx_in As String = "SELECT SUM(RIN_NUM) AS RIN_SUM FROM PER_SALARY_ROUTINE_IN WHERE OFFICERCODE = '" & code & "'"
Cmd2 = New OracleCommand(sqlx_in, Conn)
dtReader2 = Cmd2.ExecuteReader
dtReader2.Read()
sum_in = dtReader2.Item("RIN_SUM")
End If
'------------------------------------------------------------------------
Dim sqlx_cou3 As String = "SELECT COUNT(AD_ID) AS COU_INA FROM PER_SALARY_ROUTINE_ADD WHERE OFFICERCODE = '" & code & "' AND AD_IOD_CODE = '" & Me.DropDownList2.Text & "'"
Cmd = New OracleCommand(sqlx_cou3, Conn)
dtReader = Cmd.ExecuteReader
dtReader.Read()
Dim cou_inx As String = dtReader.Item("COU_INA")
If cou_inx <> "0" Then
Dim sqlx_in As String = "SELECT SUM(AD_NUM) AS ADD_SUM FROM PER_SALARY_ROUTINE_ADD WHERE OFFICERCODE = '" & code & "' AND AD_IOD_CODE = '" & Me.DropDownList2.Text & "'"
Cmd2 = New OracleCommand(sqlx_in, Conn)
dtReader2 = Cmd2.ExecuteReader
dtReader2.Read()
sum_ina = dtReader2.Item("ADD_SUM")
End If
'############ ทำงานเดือน ######################################
If sum_in <> "0" And sum_ina <> "0" Then
sumz = sum_in + sum_ina
Dim muney_pay1 As Single = sumz - sum_ex
all_sum_pay = muney_pay1 'จ่ายจริง
ElseIf sum_ina = "0" Then
Dim muney_pay2 As Single = sum_in - sum_ex
all_sum_pay = muney_pay2 'จ่ายจริง
End If
Catch ex As Exception
End Try
End While
End If
End Sub
End Class
ทั่งๆที่ พนักงานมีอยู่ สองคน
ช่วยดูให้หน่อยน่ะคับ ทำไม่มันทำแค่ คนเดี่ยว....
Tag : .NET, Oracle, jQuery, Web (ASP.NET), VB.NET, C#
sqlx = String.Format("SELECT COUNT(rex_id) AS cou_ex, SUM(rex_num) AS rex_sum, COUNT(rin_id) AS cou_in, " & vbCrLf & _
"SUM(rin_num) AS rin_sum, COUNT(ad_id) AS cou_ina, SUM(ad_num) AS add_sum FROM per_salary_routine_ex AS a " & vbCrLf & _
"JOIN perofficer AS b ON a.officercode = b.officercode AND rex_iod_code = '{1}', per_salary_routine_in AS c " & vbCrLf & _
"ON a.officercode = c.officercode, per_salary_routine_add AS d ON a.officercode = d.officercode " & vbCrLf & _
"AND ad_iod_code = '{1}' WHERE b.facultyid = '{0}';", Me.ComboBox1.Text.Trim, Me.DropDownList2.Text.Trim)