Private Function EXSISTdataVALIDATION() As Boolean
Dim bolformValidate As Boolean = True
Dim colERRCollection As New Collection
Dim colControls As New Collection
Dim dsValidate As DataSet
Dim dtTempData As New DataTable
Dim strSearch As String = ""
Dim drData As DataRow
Dim dvData As DataView
dtTempData.Columns.Add("Cus_ID_N", GetType(Int64))
dtTempData.Columns.Add("Mjm_ID_N", GetType(Int64))
dtTempData.Columns.Add("Epm_ID_N", GetType(Int64))
dtTempData.Columns.Add("Gem_ID_N", GetType(Int64))
dtTempData.Columns.Add("Sos_Date_D", GetType(DateTime))
dtTempData.Columns.Add("Emp_ID_N", GetType(Int64))
If dgvEdit.Rows.Count > 0 Then
For intRcnt As Integer = 0 To dgvEdit.RowCount - 1
drData = dtTempData.NewRow
With dgvEdit.Rows(intRcnt)
If Convert.ToString(.Cells("colCus_ID_N").Value) <> "" Then drData("Cus_ID_N") = Convert.ToInt64(.Cells("colCus_ID_N").Value)
If Convert.ToString(.Cells("colMjm_ID_N").Value) <> "" Then drData("Mjm_ID_N") = Convert.ToInt64(.Cells("colMjm_ID_N").Value)
If Convert.ToString(.Cells("colEquipment").Value) <> "" Then drData("Epm_ID_N") = Convert.ToInt64(.Cells("colEquipment").Value)
If Convert.ToString(.Cells("colServiceActivity").Value) <> "" Then drData("Gem_ID_N") = Convert.ToInt64(.Cells("colServiceActivity").Value)
If Convert.ToString(.Cells("colScd_Date_D").Value) <> "" Then drData("Sos_Date_D") = CDate(Format(.Cells("colScd_Date_D").Value, "dd-MMM-yyyy"))
If Convert.ToString(.Cells("colEmp_ID_N").Value) <> "" Then drData("Emp_ID_N") = Convert.ToInt64(.Cells("colEmp_ID_N").Value)
End With
dtTempData.Rows.Add(drData)
Next
For intRcnt As Integer = 0 To dgvEdit.RowCount - 1
drData = dtTempData.NewRow
strSearch = " 1=1 "
With dgvEdit.Rows(intRcnt)
If Convert.ToString(.Cells("colCus_ID_N").Value) <> "" Then strSearch = strSearch & " and Cus_ID_N = " & Convert.ToString(.Cells("colCus_ID_N").Value)
If Convert.ToString(.Cells("colMjm_ID_N").Value) <> "" Then strSearch = strSearch & " And Mjm_ID_N = " & Convert.ToString(.Cells("colMjm_ID_N").Value)
If Convert.ToString(.Cells("colEquipment").Value) <> "" Then strSearch = strSearch & " And Epm_ID_N = " & Convert.ToString(.Cells("colEquipment").Value)
If Convert.ToString(.Cells("colServiceActivity").Value) <> "" Then strSearch = strSearch & " And Gem_ID_N = " & Convert.ToString(.Cells("colServiceActivity").Value)
If Convert.ToString(.Cells("colScd_Date_D").Value) <> "" Then strSearch = strSearch & " And Sos_Date_D = '" & Format(.Cells("colScd_Date_D").Value, "dd-MMM-yyyy") & "'"
If Convert.ToString(.Cells("colEmp_ID_N").Value) <> "" Then strSearch = strSearch & " And Emp_ID_N = " & Convert.ToString(.Cells("colEmp_ID_N").Value)
End With
'If Convert.ToString(dgvEdit.Rows(intRcnt).Cells("colScd_ID_N").Value).Trim <> "" Then
'=======================
dsValidate = New DataSet
dsValidate = ServiceInterfaceProxy.GetSrvServiceSchedule(CDate(Format(dgvEdit.Rows(intRcnt).Cells("colScd_Date_D").Value, "dd-MMM-yyyy")), CDate(Format(dgvEdit.Rows(intRcnt).Cells("colScd_Date_D").Value, "dd-MMM-yyyy")), gblintOutletID.ToString(), intUserID.ToString())
Dim strSearchcolScd_ID_N As String = ""
If Convert.ToString(dgvEdit.Rows(intRcnt).Cells("colScd_ID_N").Value).Trim <> "" Then
strSearchcolScd_ID_N = " And Scd_ID_N <> " & Convert.ToString(dgvEdit.Rows(intRcnt).Cells("colScd_ID_N").Value).Trim
End If
For Each drRow As DataRow In dsValidate.Tables(0).Select(strSearch & strSearchcolScd_ID_N)
colControls.Add(New MissingFieldException("Duplicate Schedule of Sl No : " & (intRcnt + 1).ToString))
colERRCollection.Add(dgvEdit)
Next
'=======================
'Else
If dtTempData.Rows.Count > 0 Then
dvData = New DataView(dtTempData, strSearch, "", DataViewRowState.CurrentRows)
If dvData.Count > 1 Then
colControls.Add(New MissingFieldException("Duplicate Schedule of Sl No : " & (intRcnt + 1).ToString))
colERRCollection.Add(dgvEdit)
End If
End If
'=======================
'End If
Next
Else
End If
If colERRCollection.Count > 0 Then
bolformValidate = False
ShowMessagebox(colControls, Me)
If colERRCollection.Count > 0 Then
If colERRCollection.Item(1).GetType.Name = "Usr_AlphaNumeric" Then
Dim objControl As Usr_AlphaNumeric.Usr_AlphaNumeric
objControl = CType(colERRCollection.Item(1), Usr_AlphaNumeric.Usr_AlphaNumeric)
objControl.Focus()
ElseIf colERRCollection.Item(1).GetType.Name = "DateTimePicker" Then
Dim objControl As DateTimePicker
objControl = CType(colERRCollection.Item(1), DateTimePicker)
objControl.Focus()
ElseIf colERRCollection.Item(1).GetType.Name = "DataGridViewTextBoxCell" Then
Dim objDataGridViewTextBoxCell As New DataGridViewTextBoxCell
objDataGridViewTextBoxCell = CType(colERRCollection.Item(1), DataGridViewTextBoxCell)
dgvEdit.Focus()
ElseIf colERRCollection.Item(1).GetType.Name = "DataGridViewComboBoxCell" Then
Dim objDataGridViewComboBoxCell As New DataGridViewComboBoxCell
objDataGridViewComboBoxCell = CType(colERRCollection.Item(1), DataGridViewComboBoxCell)
dgvEdit.Focus()
ElseIf colERRCollection.Item(1).GetType.Name = "DataGridViewCell" Then
Dim objDataGridViewTextBoxCell As DataGridViewCell
objDataGridViewTextBoxCell = CType(colERRCollection.Item(1), DataGridViewTextBoxCell)
dgvEdit.Focus()
Else
Dim objControl As Control
objControl = CType(colERRCollection.Item(1), Control)
objControl.Focus()
End If
End If
End If
Return bolformValidate
End Function
No comments:
Post a Comment