Ejemplo n.º 1
0
        private void FillProduct(String eventID)

        {
            string sqlEventText = "SELECT  tblEventProduct.EventProductID, tblProduct.ProductName, tblProduct.ProductType " +
                                  "FROM tblEventProduct INNER JOIN " +
                                  "tblProduction ON tblEventProduct.ProductionID = tblProduction.ProductionID INNER JOIN " +
                                  "tblProductItem ON tblProduction.ProductItemID = tblProductItem.ProductItemID INNER JOIN " +
                                  "tblProductSize ON tblProductItem.SizeID = tblProductSize.SizeID INNER JOIN " +
                                  "tblProduct ON tblProductItem.ProductID = tblProduct.ProductID " +
                                  " WHERE        tblEventProduct.EventID = " + eventID + " and tblEventProduct.Quantity > tblEventProduct.soldQuantity";

            // Declare the connection
            SqlConnection dbConnection = new SqlConnection(DBMethod.GetConnectionString());

            // Create new SQL command
            SqlCommand     command = new SqlCommand(sqlEventText, dbConnection);
            SqlDataAdapter adapter = new SqlDataAdapter(command);

            // Declare a DataTable object that will hold the return value
            DataTable productTable = new DataTable();

            // Try to connect to the database, and use the adapter to fill the table
            try
            {
                dbConnection.Open();
                adapter.Fill(productTable);
                cmbProduct.Items.Clear();
                DBMethod.FillCombBoxPerson(productTable, cmbProduct);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                dbConnection.Close();
            }

            // Return the populated DataTable
        }