예제 #1
0
        /// <summary>
        /// This method is responsible for adding the newest record in the database
        /// into the GUI table.
        /// </summary>
        /// <param name="table">A Table Layout Panel you want to add a new record to.</param>
        /// <param name="rowIndex">The row index where you want to add the new record.</param>
        static public void addNewRecord(TableLayoutPanel table, int rowIndex)
        {
            // Gets latest sale record from the database
            SalesRecord record = SalesDatabase.GetNewestSalesRecord();

            // Finds the corresponding Product Record for the SalesRecord
            ProductRecord pRecord = ProductDatabase.GetProductByProductID(record.ProductID);

            // Creates a new row in the table and updates the text in the cells
            table.Controls.Add(new Label()
            {
                Text = record.SaleID.ToString()
            }, 0, rowIndex);
            table.Controls.Add(new Label()
            {
                Text = pRecord.Name.ToString()
            }, 1, rowIndex);
            table.Controls.Add(new Label()
            {
                Text = record.DateSold.ToString()
            }, 2, rowIndex);
            table.Controls.Add(new Label()
            {
                Text = record.Quantity.ToString()
            }, 3, rowIndex);
            table.Controls.Add(new Label()
            {
                Text = "$" + (pRecord.Price * record.Quantity).ToString()
            }, 4, rowIndex);
        }