Jfisher387
Member
- Joined
- Dec 14, 2022
- Messages
- 21
- Programming Experience
- Beginner
Hello,
Working through a problem, I cannot quite grasp why this nested foreach does not run. While I am at it, I would like to think its not the fastest way to sift through the data, maybe someone has a suggestion for another approach? My data comes from a sql database with 10's of thousands of entries. I have 3 tables I am trying to grab data from. It just takes a couple seconds to loop through but its enough to bother me.
Working through a problem, I cannot quite grasp why this nested foreach does not run. While I am at it, I would like to think its not the fastest way to sift through the data, maybe someone has a suggestion for another approach? My data comes from a sql database with 10's of thousands of entries. I have 3 tables I am trying to grab data from. It just takes a couple seconds to loop through but its enough to bother me.
problem code:
private void Active_Jobs_Drill_Down_Load(object sender, EventArgs e)
{
//TODO: Highlight due dates that are past due in red, yellow if within 7 days from being due?
DataList.Clear();
string jobID = job_Label.Text;
try
{
this.job_OperationTableAdapter.Fill(this.pRODUCTIONDataSet2.Job_Operation);
}
catch(Exception ex)
{
//MessageBox.Show(ex.Message);
}
foreach (DataRow row in pRODUCTIONDataSet2.Tables["Job_Operation"].Rows)
{
if(row["Job"].ToString() == jobID)
{
DrilldownData entry = new DrilldownData();
entry.Job = Convert.ToString(row["Job"]);
entry.Run_Qty = Convert.ToString(row["Run_Qty"]);
entry.Description = Convert.ToString(row["Description"]);
entry.Job_Operation = Convert.ToString(row["Job_Operation"]);
entry.Vendor = Convert.ToString(row["Vendor"]);
entry.Work_Center = Convert.ToString(row["Work_Center"]);
entry.Est_Total_Hrs = Convert.ToString(row["Est_Total_Hrs"]);
entry.Act_Run_Labor_Hrs = Convert.ToString(row["Act_Run_Labor_Hrs"]);
entry.Sched_Start = Convert.ToString(row["Sched_Start"]);
entry.Promised_Date = Convert.ToString(row["Due_Date"]);
entry.Status = Convert.ToString(row["Status"]);
string topJob;
topJob = entry.Job.Substring(0,6);
foreach (DataRow deliveryrow in pRODUCTIONDataSet2.Tables["Delivery"].Rows)
{
if (deliveryrow["Job"].ToString() == topJob)
{
entry.Promised_Date = Convert.ToString(deliveryrow["Promised_Date"]);
}
}
DataList.Add(entry);
}
}
dataGridView1.DataSource = DataList;
dataGridView1.Refresh();
}