private void buttonSave_Click(object sender, EventArgs e) { //MessageBox.Show("I am Clicked"); TransactionClass transaction = new TransactionClass(); transaction.TransactionType = labelPurchase.Text.Trim(); transaction.TransactioDate = DateTime.Now; transaction.SysUser = "******"; transaction.GrandTotal = decimal.Parse(labelGrandTotal.Text); transaction.TransactionDetails = dtTransaction; bool success = false; using (TransactionScope scope = new TransactionScope()) { int transactionID = -1; bool w = transactionDAL.Insert_Transaction(transaction, out transactionID);//Error in this section for (int i = 0; i < dtTransaction.Rows.Count; i++) { int ProductID = int.Parse(dtTransaction.Rows[i][0].ToString()); //string ProductName = dtTransaction.Rows[i][1].ToString(); decimal Rate = decimal.Parse(dtTransaction.Rows[i][2].ToString()); decimal Quantity = decimal.Parse(dtTransaction.Rows[i][3].ToString()); decimal Discount = decimal.Parse(dtTransaction.Rows[i][4].ToString()); decimal Tax = decimal.Parse(dtTransaction.Rows[i][5].ToString()); decimal Total = decimal.Parse(dtTransaction.Rows[i][6].ToString()); TransactionDetails td = new TransactionDetails(); td.ProductID = ProductID; td.Rate = Rate; td.Quantity = Quantity; td.Discount = Discount; td.Tax = Tax; td.Total = Total; bool x = invDAL.Increase_Inventory(ProductID, Quantity); //For Decreasing Product Quantity bool y = transactionDAL.Insert_TransactionDetails(td); success = w && x && y; // DO this after solving error //success = y; //Comment this after solving error } if (success == true) { scope.Complete(); MessageBox.Show("Purchase Transaction Completed."); } else { MessageBox.Show("Purchase Transaction Failed."); } } //MessageBox.Show("Print Me"); }