private void btnReturnItem_Click(object sender, EventArgs e) { Regex numeric = new Regex("^[0-9]*$"); if (txtQtySold.Text.Equals("")) { MessageBox.Show("Quantity Sold was left blank"); txtQtySold.Focus(); return; } else if (!numeric.IsMatch(txtQtySold.Text)) { MessageBox.Show("Quantity Sold must use numeric characters"); txtQtySold.Clear(); txtQtySold.Focus(); return; } else if (Convert.ToInt16(txtQtySold.Text) > Convert.ToInt32(grdCart.Rows[grdCart.CurrentCell.RowIndex].Cells[2].Value)) { MessageBox.Show("The quantity you are returning is greater than the quantity you have bought"); } else { grdCart.Rows[0].Selected = true; Saleitem.returnStock(Convert.ToInt32(grdCart.Rows[grdCart.CurrentCell.RowIndex].Cells[0].Value), Convert.ToInt16(txtQtySold.Text), Convert.ToInt16(txtSaleID.Text)); Sale.returnSale(Convert.ToInt32(txtSaleID.Text), Convert.ToDecimal(grdCart.Rows[grdCart.CurrentCell.RowIndex].Cells[2].Value) * Convert.ToInt16(txtQtySold.Text)); if (rdoTrue.Checked) { Stock.returnStock(Convert.ToInt32(grdCart.Rows[grdCart.CurrentCell.RowIndex].Cells[0].Value), Convert.ToInt32(txtQtySold.Text)); } MessageBox.Show("Item has been returned"); this.Close(); parent.Show(); } }