Beispiel #1
0
 private void searchbyname_TextChanged(object sender, EventArgs e)
 {
     product_list.Rows.Clear();
     /*getting data products and add it to the cells*/
     row_index = 0;
     product_list.Rows.Clear();
     products      = Product_data.GetsoldproductData(); //get data from database
     product_count = 0;
     row_index     = 0;                                 //row index
     for (int i = 0; i < products.Length; i++)          //add to table
     {
         if (products[i].Product_name.StartsWith(searchbyname.Text))
         {
             product_list.Rows.Add();                                                               //add new row
             product_list.Rows[row_index].Cells[0].Value   = products[i].Product_id.ToString();     //add product id
             product_list.Rows[row_index].Cells[1].Value   = products[i].Product_name.ToString();   //add product name
             product_list.Rows[row_index].Cells[2].Value   = products[i].Price.ToString();          // add product price
             product_list.Rows[row_index].Cells[3].Value   = products[i].Product_amount.ToString(); //add product count how many in inventory
             product_list.Rows[row_index].Cells[4].Value   = products[i].Suppliername;              //add product supplier
             product_list.Rows[row_index++].Cells[5].Value = products[i].Solddate;                  //add product supplier
             product_count += products[i].Product_amount;                                           //count products
         }
     }
     productcount.Text = product_count.ToString();//add to label
 }