Esempio n. 1
0
        private void dgvCompras_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewImageColumn &&
                e.RowIndex >= 0)
            {
                var row = senderGrid.Rows[e.RowIndex];
                var id  = Convert.ToInt32(row.Cells[11].Value);
                var pid = Convert.ToInt32(row.Cells[12].Value);
                if (pid != 3)
                {
                    return;
                }
                if (MessageBox.Show($"Tem certeza que deseja cancelar esta compra?", "Atenção", MessageBoxButtons.YesNo) ==
                    DialogResult.Yes)
                {
                    var sku    = row.Cells[1].Value.ToString();
                    var amount = Convert.ToInt32(Convert.ToDecimal(row.Cells[5].Value) * 100);
                    var txid   = row.Cells[7].Value.ToString();
                    var result = proxy.Cancellation(amount, sku, txid);
                    repository.CancelPurchase(id);
                    btnPesquisar_Click(null, null);
                    MessageBox.Show($"Compra cancelada com sucesso.", "Sucesso", MessageBoxButtons.OK);
                }
            }
        }