Private Sub cboOvenNumber_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboOvenNumber.SelectedValueChanged
If cboOvenNumber.Text = "" Then Exit Sub
For i = 1 To dgvDryingOrganicLonganFleshGoldenBake.Rows.Count
If CStr(dgvDryingOrganicLonganFleshGoldenBake.Rows(i - 1).Cells(8).Value) = cboOvenNumber.Text Then
MessageBox.Show("หมายเลขเตานี้อยู่ในรายการแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
Next
Dim Sql As String = ""
Dim dtSDLGB As New DataTable()
Dim ReadId As String = ""
Dim NewId As Integer = 0
Com = New SqlCommand()
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
'################แสดงชื่อผู้ครวจสอบ###########################
Dim dtdgvOpenStaff As New DataTable()
Sql = "SELECT IDFactoryStaff,Name_F FROM FactoryStaff"
With Com
.Parameters.Clear()
.CommandType = CommandType.Text
.CommandText = Sql
.Connection = Conn
dr = .ExecuteReader()
If dr.HasRows Then
dtdgvOpenStaff.Load(dr)
End If
End With
dr.Close()
'#########################################################
Sql = "SELECT OvenNumber,BarCode"
Sql &= " FROM StorkDLGB AS D"
Sql &= " WHERE OvenNumber=@OvenNumber"
With Com
.CommandType = CommandType.Text
.CommandText = Sql
.Connection = Conn
.Parameters.Clear()
.Parameters.Add("@OvenNumber", SqlDbType.NVarChar).Value = cboOvenNumber.SelectedValue()
dr = .ExecuteReader()
If dr.HasRows Then
dtSDLGB.Load(dr)
Dim dtpDryingOrganicLonganFleshGoldenBake As New CalendarCell
dgvDryingOrganicLonganFleshGoldenBake.Rows.Add()
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value = "00000" & dtSDLGB.Rows(0).Item("BarCode").ToString().Remove(0, 5).Remove(2, 6) & "310000"
dgvDryingOrganicLonganFleshGoldenBake(1, dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1) = dtpDryingOrganicLonganFleshGoldenBake
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(1).Value = Date.Today()
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(2).Value = ""
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(3).Value = "เนื้อลำไยสด"
For i = 0 To dgvStorageDryingOrganicLonganFleshGoldenBake.Rows.Count - 1
If dtSDLGB.Rows(0).Item("OvenNumber").ToString() = CStr(dgvStorageDryingOrganicLonganFleshGoldenBake.Rows(i).Cells(0).Value) Then
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(4).Value = CStr(dgvStorageDryingOrganicLonganFleshGoldenBake.Rows(i).Cells(3).Value)
Exit For
End If
Next
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(5).Value = ""
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(6).Value = ""
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(7).Value = dtSDLGB.Rows(0).Item("OvenNumber").ToString()
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(8).Value = ""
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(9).Value = ""
With dgvOpenStaff
.DisplayMember = "Name_F"
.ValueMember = "IDFactoryStaff"
.DataSource = dtdgvOpenStaff
End With
cmdOk.Enabled = True
cmdCancle.Enabled = True
lblcmdCancle.Enabled = True
lblcmdOk.Enabled = True
lblRecodeDateAdd.Enabled = True
dtpRecodeDateAdd.Enabled = True
lblRecodeName.Enabled = True
cboFactoryStaff.Enabled = True
cmdDeldgv.Enabled = True
Else
dr.Close()
Conn.Close()
End If
End With
dr.Close()
'###############################################################
If dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1 = 0 Then
Sql = "SELECT TOP 1 NoListOven FROM OrganicLonganControlOven WHERE ProductionYear=@ProductionYear ORDER BY NoListOven DESC"
With Com
.Parameters.Clear()
.CommandType = CommandType.Text
.CommandText = Sql
.Connection = Conn
.Parameters.Add("@ProductionYear", SqlDbType.NVarChar).Value = CStr(dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value).Remove(0, 5).Remove(2, 6)
dr = .ExecuteReader()
If dr.HasRows Then
dr.Read()
ReadId = dr.Item("NoListOven").ToString()
NewId = CInt(ReadId) + 1
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value = "00000" & dtSDLGB.Rows(0).Item("BarCode").ToString().Remove(0, 5).Remove(2, 6) & "31" & NewId.ToString("0000")
Else
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value = "00000" & dtSDLGB.Rows(0).Item("BarCode").ToString().Remove(0, 5).Remove(2, 6) & "310001"
End If
End With
dr.Close()
Else
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value = "00000" & dtSDLGB.Rows(0).Item("BarCode").ToString().Remove(0, 5).Remove(2, 6) & "31" & _
CInt(CInt(CStr(dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 2).Cells(0).Value).Remove(0, 9)) + 1).ToString("0000")
End If
Conn.Close()
End Sub
Private Sub cboOvenNumber_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboOvenNumber.SelectedValueChanged
If cboOvenNumber.Text = "" Then Exit Sub
For i = 1 To dgvDryingOrganicLonganFleshGoldenBake.Rows.Count
If CStr(dgvDryingOrganicLonganFleshGoldenBake.Rows(i - 1).Cells(8).Value) = cboOvenNumber.Text Then
MessageBox.Show("หมายเลขเตานี้อยู่ในรายการแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
Next
Dim Sql As String = ""
Dim dtSDLGB As New DataTable()
Dim ReadId As String = ""
Dim NewId As Integer = 0
Com = New SqlCommand()
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
'################แสดงชื่อผู้ครวจสอบ###########################
Dim dtdgvOpenStaff As New DataTable()
Sql = "SELECT IDFactoryStaff,Name_F FROM FactoryStaff"
With Com
.Parameters.Clear()
.CommandType = CommandType.Text
.CommandText = Sql
.Connection = Conn
dr = .ExecuteReader()
If dr.HasRows Then
dtdgvOpenStaff.Load(dr)
End If
End With
dr.Close()
'#########################################################
Sql = "SELECT OvenNumber,BarCode"
Sql &= " FROM StorkDLGB AS D"
Sql &= " WHERE OvenNumber=@OvenNumber"
With Com
.CommandType = CommandType.Text
.CommandText = Sql
.Connection = Conn
.Parameters.Clear()
.Parameters.Add("@OvenNumber", SqlDbType.NVarChar).Value = cboOvenNumber.SelectedValue()
dr = .ExecuteReader()
If dr.HasRows Then
dtSDLGB.Load(dr)
Dim dtpDryingOrganicLonganFleshGoldenBake As New CalendarCell
dgvDryingOrganicLonganFleshGoldenBake.Rows.Add()
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value = "00000" & dtSDLGB.Rows(0).Item("BarCode").ToString().Remove(0, 5).Remove(2, 6) & "310000"
dgvDryingOrganicLonganFleshGoldenBake(1, dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1) = dtpDryingOrganicLonganFleshGoldenBake
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(1).Value = Date.Today()
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(2).Value = ""
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(3).Value = "เนื้อลำไยสด"
For i = 0 To dgvStorageDryingOrganicLonganFleshGoldenBake.Rows.Count - 1
If dtSDLGB.Rows(0).Item("OvenNumber").ToString() = CStr(dgvStorageDryingOrganicLonganFleshGoldenBake.Rows(i).Cells(0).Value) Then
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(4).Value = CStr(dgvStorageDryingOrganicLonganFleshGoldenBake.Rows(i).Cells(3).Value)
Exit For
End If
Next
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(5).Value = ""
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(6).Value = ""
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(7).Value = dtSDLGB.Rows(0).Item("OvenNumber").ToString()
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(8).Value = ""
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(9).Value = ""
With dgvOpenStaff
.DisplayMember = "Name_F"
.ValueMember = "IDFactoryStaff"
.DataSource = dtdgvOpenStaff
End With
cmdOk.Enabled = True
cmdCancle.Enabled = True
lblcmdCancle.Enabled = True
lblcmdOk.Enabled = True
lblRecodeDateAdd.Enabled = True
dtpRecodeDateAdd.Enabled = True
lblRecodeName.Enabled = True
cboFactoryStaff.Enabled = True
cmdDeldgv.Enabled = True
Else
dr.Close()
Conn.Close()
End If
End With
dr.Close()
'###############################################################
If dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1 = 0 Then
Sql = "SELECT TOP 1 NoListOven FROM OrganicLonganControlOven WHERE ProductionYear=@ProductionYear ORDER BY NoListOven DESC"
With Com
.Parameters.Clear()
.CommandType = CommandType.Text
.CommandText = Sql
.Connection = Conn
.Parameters.Add("@ProductionYear", SqlDbType.NVarChar).Value = CStr(dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value).Remove(0, 5).Remove(2, 6)
dr = .ExecuteReader()
If dr.HasRows Then
dr.Read()
ReadId = dr.Item("NoListOven").ToString()
NewId = CInt(ReadId) + 1
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value = "00000" & dtSDLGB.Rows(0).Item("BarCode").ToString().Remove(0, 5).Remove(2, 6) & "31" & NewId.ToString("0000")
Else
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value = "00000" & dtSDLGB.Rows(0).Item("BarCode").ToString().Remove(0, 5).Remove(2, 6) & "310001"
End If
End With
dr.Close()
Else
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value = "00000" & dtSDLGB.Rows(0).Item("BarCode").ToString().Remove(0, 5).Remove(2, 6) & "31" & _
CInt(CInt(CStr(dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 2).Cells(0).Value).Remove(0, 9)) + 1).ToString("0000")
End If
Conn.Close()
End Sub
Date :
2011-11-09 11:14:46
By :
pStudio
No. 5
Guest
Code (VB.NET)
Private Sub cboOvenNumber_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboOvenNumber.SelectedValueChanged
If cboOvenNumber.Text = "" Then Exit Sub
For i = 1 To dgvDryingOrganicLonganFleshGoldenBake.Rows.Count
If CStr(dgvDryingOrganicLonganFleshGoldenBake.Rows(i - 1).Cells(8).Value) = cboOvenNumber.Text Then
MessageBox.Show("หมายเลขเตานี้อยู่ในรายการแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
End If
Next
Dim Sql As String = ""
Dim dtSDLGB As New DataTable()
Dim ReadId As String = ""
Dim NewId As Integer = 0
Com = New SqlCommand()
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
'################แสดงชื่อผู้ครวจสอบ###########################
Dim dtdgvOpenStaff As New DataTable()
Sql = "SELECT IDFactoryStaff,Name_F FROM FactoryStaff"
With Com
.Parameters.Clear()
.CommandType = CommandType.Text
.CommandText = Sql
.Connection = Conn
dr = .ExecuteReader()
If dr.HasRows Then
dtdgvOpenStaff.Load(dr)
End If
End With
dr.Close()
'#########################################################
Sql = "SELECT OvenNumber,BarCode"
Sql &= " FROM StorkDLGB AS D"
Sql &= " WHERE OvenNumber=@OvenNumber"
With Com
.CommandType = CommandType.Text
.CommandText = Sql
.Connection = Conn
.Parameters.Clear()
.Parameters.Add("@OvenNumber", SqlDbType.NVarChar).Value = cboOvenNumber.SelectedValue()
dr = .ExecuteReader()
If dr.HasRows Then
dtSDLGB.Load(dr)
Dim dtpDryingOrganicLonganFleshGoldenBake As New CalendarCell
dgvDryingOrganicLonganFleshGoldenBake.Rows.Add()
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value = "00000" & dtSDLGB.Rows(0).Item("BarCode").ToString().Remove(0, 5).Remove(2, 6) & "310000"
dgvDryingOrganicLonganFleshGoldenBake(1, dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1) = dtpDryingOrganicLonganFleshGoldenBake
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(1).Value = Date.Today()
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(2).Value = ""
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(3).Value = "เนื้อลำไยสด"
For i = 0 To dgvStorageDryingOrganicLonganFleshGoldenBake.Rows.Count - 1
If dtSDLGB.Rows(0).Item("OvenNumber").ToString() = CStr(dgvStorageDryingOrganicLonganFleshGoldenBake.Rows(i).Cells(0).Value) Then
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(4).Value = CStr(dgvStorageDryingOrganicLonganFleshGoldenBake.Rows(i).Cells(3).Value)
Exit For
End If
Next
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(5).Value = ""
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(6).Value = ""
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(7).Value = dtSDLGB.Rows(0).Item("OvenNumber").ToString()
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(8).Value = ""
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(9).Value = ""
With dgvOpenStaff
.DisplayMember = "Name_F"
.ValueMember = "IDFactoryStaff"
.DataSource = dtdgvOpenStaff
End With
cmdOk.Enabled = True
cmdCancle.Enabled = True
lblcmdCancle.Enabled = True
lblcmdOk.Enabled = True
lblRecodeDateAdd.Enabled = True
dtpRecodeDateAdd.Enabled = True
lblRecodeName.Enabled = True
cboFactoryStaff.Enabled = True
cmdDeldgv.Enabled = True
Else
dr.Close()
Conn.Close()
End If
End With
dr.Close()
'###############################################################
If dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1 = 0 Then
Sql = "SELECT TOP 1 NoListOven FROM OrganicLonganControlOven WHERE ProductionYear=@ProductionYear ORDER BY NoListOven DESC"
With Com
.Parameters.Clear()
.CommandType = CommandType.Text
.CommandText = Sql
.Connection = Conn
.Parameters.Add("@ProductionYear", SqlDbType.NVarChar).Value = CStr(dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value).Remove(0, 5).Remove(2, 6)
dr = .ExecuteReader()
If dr.HasRows Then
dr.Read()
ReadId = dr.Item("NoListOven").ToString()
NewId = CInt(ReadId) + 1
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value = "00000" & dtSDLGB.Rows(0).Item("BarCode").ToString().Remove(0, 5).Remove(2, 6) & "31" & NewId.ToString("0000")
Else
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value = "00000" & dtSDLGB.Rows(0).Item("BarCode").ToString().Remove(0, 5).Remove(2, 6) & "310001"
End If
End With
dr.Close()
Else
dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 1).Cells(0).Value = "00000" & dtSDLGB.Rows(0).Item("BarCode").ToString().Remove(0, 5).Remove(2, 6) & "31" & _
CInt(CInt(CStr(dgvDryingOrganicLonganFleshGoldenBake.Rows(dgvDryingOrganicLonganFleshGoldenBake.Rows.Count - 2).Cells(0).Value).Remove(0, 9)) + 1).ToString("0000")
End If
Conn.Close()
End Sub