Check file input column (SR Category,SR Sub Category,SR Issue,SR Product Line) that match in file master
1.1 Match check column SR # and column Activity # from file input with file report
1.1.1 If found check column Closed Date file report have text or not
1.1.1.1 If text = “working” or blank ----> go to next row file input
1.1.1.2 If text <> “working” but have value ----> copy this row from file input to sheet Correct
1.2 Match check column SR # and column Activity # from file input with file report
1.2.1 If found check column Closed Date file report have text or not
1.2.1.1 If text = “working” or blank ----> go to check input next row
1.2.1.2 If text <> “working” but have value ----> copy this row from file input to sheet Correct
1.3 Not match copy row to sheet incorrect.
Please guide me for solve it. ( I want use switch case or LINQ)
Assuming inputDt, masterDt, and reportDt are DataTable variables containing data from the input, master, and report files respectively
Step 1: Define LINQ query to filter and manipulate data
Dim correctRows = (From inputRow In inputDt.AsEnumerable()
Join masterRow In masterDt.AsEnumerable()
On New With {Key.SRCategory = inputRow(“SR Category”),
Key.SRSubCategory = inputRow(“SR Sub Category”),
Key.SRIssue = inputRow(“SR Issue”),
Key.SRProductLine = inputRow(“SR Product Line”)}
Equals New With {Key.SRCategory = masterRow(“SR Category”),
Key.SRSubCategory = masterRow(“SR Sub Category”),
Key.SRIssue = masterRow(“SR Issue”),
Key.SRProductLine = masterRow(“SR Product Line”)}
Join reportRow In reportDt.AsEnumerable()
On New With {Key.SRNumber = inputRow(“SR #”),
Key.ActivityNumber = inputRow(“Activity #”)}
Equals New With {Key.SRNumber = reportRow(“SR #”),
Key.ActivityNumber = reportRow(“Activity #”)}
Where Not (reportRow(“Closed Date”).ToString().Trim() = “working” Or String.IsNullOrEmpty(reportRow(“Closed Date”).ToString().Trim()))
Select inputRow).CopyToDataTable()
Dim incorrectRows = (From inputRow In inputDt.AsEnumerable()
Where Not masterDt.AsEnumerable().Any(Function(masterRow)
Return inputRow(“SR Category”).ToString() = masterRow(“SR Category”).ToString() AndAlso
inputRow(“SR Sub Category”).ToString() = masterRow(“SR Sub Category”).ToString() AndAlso
inputRow(“SR Issue”).ToString() = masterRow(“SR Issue”).ToString() AndAlso
inputRow(“SR Product Line”).ToString() = masterRow(“SR Product Line”).ToString()
End Function)
Select inputRow).CopyToDataTable()
’ Step 2: Write Correct and Incorrect data to Excel sheets
correctRows.WriteRange(“CorrectSheet”, “A1”)
incorrectRows.WriteRange(“IncorrectSheet”, “A1”)