private void gridSales_CellClick(object sender, DataGridViewCellEventArgs e) { try { string strSno = gridSales.Rows[gridSales.CurrentCell.RowIndex].Cells[0].Value.ToString(); string strIno = gridSales.Rows[gridSales.CurrentCell.RowIndex].Cells[1].Value.ToString(); refundedSale.returnSaleItem(Int32.Parse(strSno), Int32.Parse(strIno)); grpUpdate.Visible = true; refundedSale.returnSaleItem(Int32.Parse(strSno), Int32.Parse(strIno)); txtPrice.Text = (refundedSale.getPrice() * refundedSale.getQuantity()).ToString(); txtItemId.Text = refundedSale.getItemId().ToString(); txtSaleId.Text = refundedSale.getSaleId().ToString(); } catch (Exception) { MessageBox.Show("Cannot Find Item"); } }
private void btnCheckOut_Click(object sender, EventArgs e) { //sets Sale id of sale item to current sale id ItemSold.setSaleId(makeSale.getSaleId()); int i, id, somethingelse = 0; double totalPrice = 0; for (i = 0; i < listCart.Items.Count; i++) { id = Int32.Parse(listCart.Items[i].ToString().Substring(0, 1)); ItemSold.setItemId(id); listItem.returnItem(id); ItemSold.setItemDesc(listItem.getDesc()); ItemSold.setPrice(listItem.getPrice()); try { somethingelse = Int32.Parse(listCart.Items[i].ToString().Substring(12)); } catch (ArgumentException) { MessageBox.Show(" cannot have minus stock "); } ItemSold.setQuantity(somethingelse); totalPrice += listItem.getPrice() * ItemSold.getQuantity(); ItemSold.setPrice(listItem.getPrice()); ItemSold.insSale(); } txtTotal.Text = totalPrice.ToString(); grpCheckout.Visible = true; }