Example #1
0
        public void displayAllSuppliers()
        {
            ClassLibrary.Supplier supplier = new ClassLibrary.Supplier();

            dtSuppliers = supplier.GetAll().Tables[0];

            //set the customer_id column as primary key so you can search the table later
            dtSuppliers.PrimaryKey   = new DataColumn[] { dtSuppliers.Columns["SUPPLIER_id"] };
            dataGridView1.DataSource = dtSuppliers;

            dataGridView1.Columns["SUPPLIER_id"].HeaderText          = "ID";
            dataGridView1.Columns["SUPPLIER_name"].HeaderText        = "Name";
            dataGridView1.Columns["SUPPLIER_timesfailed"].HeaderText = "Failed";
            dataGridView1.Columns["SUPPLIER_phone"].HeaderText       = "Phone";
            dataGridView1.Columns["SUPPLIER_email"].HeaderText       = "Email";
            dataGridView1.Columns["SUPPLIER_address"].HeaderText     = "Address";
            dataGridView1.Columns["SUPPLIER_postalcode"].HeaderText  = "Postalcode";
            dataGridView1.Columns["SUPPLIER_province"].HeaderText    = "Province";
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
        }
Example #2
0
        //-------------------------------------------------------------------------------------------------
        private void frmAddPart_Load(object sender, EventArgs e)
        {
            supplerlist = new BindingList <SupplierList>();

            //add parts to the combobox
            ClassLibrary.Supplier supplier = new ClassLibrary.Supplier();
            dtSupplier = supplier.GetAll().Tables[0];
            cmbSuppliers.DataSource    = dtSupplier;
            cmbSuppliers.DisplayMember = "SUPPLIER_name";



            if (drRow == null)
            {
            }
            else
            {
                txtName.Text  = drRow.ItemArray[1].ToString();
                txtColor.Text = drRow.ItemArray[2].ToString();

                ClassLibrary.SupplierPart supplierpart = new ClassLibrary.SupplierPart();
                supplierpart.PartId = Convert.ToInt32(drRow.ItemArray[0]);
                DataTable thisTable = supplierpart.GetSupplierPartsByPartId().Tables[0];
                foreach (DataRow row in thisTable.Rows)
                {
                    //add to generic list
                    supplerlist.Add(new SupplierList
                    {
                        SupplierID   = Convert.ToInt32(row.ItemArray[0]),
                        SupplierName = row.ItemArray[1].ToString(),
                        price        = String.Format("{0:c}", row.ItemArray[2]),
                    });
                }
                dataGridView1.DataSource = supplerlist;
            }
        }