void PopulateGridview() { DataTable dtbl = new DataTable(); using (SqlConnection sqlCon = new SqlConnection(connectionString)) { sqlCon.Open(); SqlDataAdapter sqlDa = new SqlDataAdapter("SELECT * FROM parts_master", sqlCon); sqlDa.Fill(dtbl); } if (dtbl.Rows.Count > 0) { PartsGrid.DataSource = dtbl; PartsGrid.DataBind(); } else { dtbl.Rows.Add(dtbl.NewRow()); PartsGrid.DataSource = dtbl; PartsGrid.DataBind(); PartsGrid.Rows[0].Cells.Clear(); PartsGrid.Rows[0].Cells.Add(new TableCell()); PartsGrid.Rows[0].Cells[0].ColumnSpan = dtbl.Columns.Count; PartsGrid.Rows[0].Cells[0].Text = "No Data Found ..!"; PartsGrid.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; } }
private void RefreshData() { PartsGrid.Invoke(new MethodInvoker(delegate { PartsGrid.DataSource = _parts.Parts.ToList(); PartsGrid.Columns["_id"].Visible = false; Parallel.ForEach(PartsGrid.Rows.OfType <DataGridViewRow>(), row => { var _part = _parts.Parts.Find(x => x._id == row.Cells["_id"].Value); if (_part != null) { switch (_part.status) { case PartClass.Status.Completed: row.DefaultCellStyle.BackColor = Color.LightGreen; break; case PartClass.Status.Unknown: row.DefaultCellStyle.BackColor = Color.LightGray; break; case PartClass.Status.Ready: row.DefaultCellStyle.BackColor = Color.LightYellow; break; case PartClass.Status.Resolving: row.DefaultCellStyle.BackColor = Color.LightBlue; break; case PartClass.Status.Target_Partition_Not_Found: row.DefaultCellStyle.BackColor = Color.LightPink; break; case PartClass.Status.Part_Not_Found: row.DefaultCellStyle.BackColor = Color.LightPink; break; } } }); PartsGrid.ClearSelection(); })); RunButton.Invoke(new MethodInvoker(delegate { if (_parts.Parts.FindAll(x => x.status == PartClass.Status.Ready).Count > 0) { RunButton.Enabled = true; } else { RunButton.Enabled = false; } })); }
public TcNestingTemplatePartList() { mTableView = new Lazy <TcRegularTableView <TcNestingTemplatePartRow> >(() => PartsGrid.GetTableView(r => new TcNestingTemplatePartRow(r))); }