private void CheckOutButton_Click(object sender, EventArgs e) { BillPage _CashForm = new BillPage(); _CashForm.TotalBillBox.Text = TotalBillBox.Text; if (_CashForm.ShowDialog() == DialogResult.OK) { ArrayList ProductsList = new ArrayList(); foreach (DataGridViewRow Row in ProductsGridView.Rows) { try { string ProductName = Row.Cells["ProductNameColumn"].Value.ToString(); decimal ProductPrice = Convert.ToDecimal(Row.Cells["ProductPriceColumn"].Value); int ProductQuantity = Convert.ToInt32(Row.Cells["ProductQuantityColumn"].Value); decimal ProductTotal = Convert.ToDecimal(Row.Cells["TotalPriceColumn"].Value); ProductsList.Add(new Food() { FName = ProductName, FPrice = ProductPrice, FQuantity = ProductQuantity, Total = ProductTotal }); } catch { //means Rows are ended } } FoodRepository _DataAccess = new FoodRepository(); if (_DataAccess.RecordASale(ProductsList, DateTime.Now, Convert.ToDecimal(_CashForm.CashGivenBox.Text), Convert.ToDecimal(_CashForm.TotalBillBox.Text), Convert.ToDecimal(_CashForm.CashReturnBox.Text))) { MessageBox.Show("Sale Added"); } else { MessageBox.Show("Sale Not Added"); } } }