This code generated code had a break in the wrong location. Made the Delete ineffective. private void DeleteButton_Click (object sender, EventArgs e) { string MethodName = "DeleteButton_Click"; try { if (SearchResultDataGridView.SelectedRows.Count > 0) { System.Windows.Forms.DialogResult result = MessageBox.Show ("Do you want to delete the record?", "Delete", MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { System.Decimal Od = 0; System.Decimal Width = 0; PLWinCasingForm PLWinCasingForm = new PLWinCasingForm (); if (SearchResultDataGridView.SelectedRows.Count > 0) { foreach (DataGridViewColumn column in SearchResultDataGridView.Columns) { if (column.DataPropertyName == "Od") { Od = (System.Decimal)SearchResultDataGridView.SelectedRows[0].Cells[column.Index].Value; break; } // break; use to be here } foreach (DataGridViewColumn column in SearchResultDataGridView.Columns) { if (column.DataPropertyName == "Width") { Width = (System.Decimal)SearchResultDataGridView.SelectedRows[0].Cells[column.Index].Value; break; } // break; use to be here } } BLCasing.DeleteRecord (Od, Width); Search (); } } } catch (System.Exception ex) { PublishException (ex, MethodName); } } |