private void ADD_DATA(string PRODUCT_NAME, int PRODUCT_PRICE, int PRODUCT_QUANTITY, int PRODUCT_TOTAL) { bool Product_Found = false; int Row_Number = 0; foreach (POS_TRANSACTION TRANSACTION_ITEM in PUYO_FUNCTION.POS_TRANSACTIONS) { if (TRANSACTION_ITEM.PRODUCT_NAME.Equals(PRODUCT_NAME)) { TRANSACTION_ITEM.PRODUCT_QUANTITY += PRODUCT_QUANTITY; TRANSACTION_ITEM.TOTAL_PRICE = TRANSACTION_ITEM.PRODUCT_PRICE * TRANSACTION_ITEM.PRODUCT_QUANTITY; TransactionData.Rows[Row_Number].Cells[2].Value = TRANSACTION_ITEM.PRODUCT_QUANTITY; TransactionData.Rows[Row_Number].Cells[3].Value = TRANSACTION_ITEM.TOTAL_PRICE; Product_Found = true; } Row_Number = Row_Number + 1; } if (Product_Found == false) { TransactionData.Rows.Add(PRODUCT_NAME, PRODUCT_PRICE, PRODUCT_QUANTITY, PRODUCT_TOTAL); POS_TRANSACTION NEW_ITEM = new POS_TRANSACTION(PRODUCT_NAME, PRODUCT_PRICE, PRODUCT_QUANTITY, PRODUCT_TOTAL); PUYO_FUNCTION.POS_TRANSACTIONS.Add(NEW_ITEM); } int sum = PUYO_FUNCTION.GET_SUM(); UPDATE_TOTAL(sum); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int rowindex = TransactionData.CurrentCell.RowIndex; int columnindex = TransactionData.CurrentCell.ColumnIndex; if (columnindex == 4) { TransactionData.Rows.RemoveAt(rowindex); PUYO_FUNCTION.POS_TRANSACTIONS.RemoveAt(rowindex); int sum = PUYO_FUNCTION.GET_SUM(); UPDATE_TOTAL(sum); } }