Esempio n. 1
0
        private void addGridView(List <TechnologicalCard> et)
        {
            dataGridView1.Rows.Clear();
            foreach (var item in et)
            {
                cel0 = new DataGridViewTextBoxCell();
                cel1 = new DataGridViewTextBoxCell();
                cel2 = new DataGridViewTextBoxCell();
                cel3 = new DataGridViewTextBoxCell();
                cel4 = new DataGridViewTextBoxCell();
                row  = new DataGridViewRow();

                cel1.Value = item.Title;
                string s1 = "", s2 = "";
                List <ProductAmountTable> listWithAmountProducts = query.querySelectTechCardProducts(item.Id);

                if (listWithAmountProducts.Count > 0)
                {
                    foreach (var item2 in listWithAmountProducts)
                    {
                        if (item2.type == 1)
                        {
                            s1 += item2.product.Name + " " + item2.amount + "; ";
                        }
                        else
                        {
                            s2 += item2.product.Name + " " + item2.amount + "; ";
                        }
                    }
                    cel2.Value = s1.Substring(0, s1.Length - 2);
                    cel3.Value = s2.Substring(0, s2.Length - 2);
                }
                cel0.Value = item.Id;
                cel4.Value = item.Date;
                row.Cells.AddRange(cel0, cel1, cel2, cel3, cel4);
                dataGridView1.Rows.Add(row);
            }
        }