Exemplo n.º 1
0
        private void dgvTransactionDetails_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvTransactionDetails.Columns[e.ColumnIndex].Name == "TransactQuantityColumn" && e.RowIndex >= 0)
            {
                TransactionDataSet.TransactionDetailsRow tr = (TransactionDataSet.TransactionDetailsRow)((DataRowView)(dgvTransactionDetails.Rows[e.RowIndex].DataBoundItem)).Row;
                ViewStockChangeInformation frmStock         = new ViewStockChangeInformation();
                frmStock.dt = dtTransactionStockInformation;
                frmStock.TransactionDetailID = tr.TransactionDetailID;
                frmStock.ActionType          = WhistlingPalms.ActionType.Deduction.ToString();
                frmStock.WareHouseName       = tr.FromWareHouseName;
                frmStock.FullProductName     = tr.ProductName + ", " + tr.Manufacturer;
                if (frmStock.ShowDialog() == DialogResult.OK)
                {
                    decimal TotalTransactQty = 0;
                    foreach (TransactionDataSet.TransactionStockInformationRow tsr in frmStock.dt.Rows)
                    {
                        if (tsr.TransactionDetailID == tr.TransactionDetailID)
                        {
                            TotalTransactQty += tsr.TransactQuantity;
                        }
                    }
                    tr.TransactQuantity = TotalTransactQty;
                    tr.TotalCost        = tr.TransactCost * tr.TransactQuantity;

                    dgvTransactionDetails.Refresh();
                }
            }
        }
Exemplo n.º 2
0
        private void dgvTransactionDetails_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvTransactionDetails.Columns[e.ColumnIndex].Name == "DeleteColumn" && e.RowIndex >= 0)
            {
                if (MessageBox.Show("Are you sure you want to delete this transaction record?", "Confirm Delete", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    TransactionDataSet.TransactionDetailsRow tr = (TransactionDataSet.TransactionDetailsRow)((DataRowView)(dgvTransactionDetails.Rows[e.RowIndex].DataBoundItem)).Row;

                    DataRow[] drs = dtTransactionStockInformation.Select("TransactionDetailID=" + tr.TransactionDetailID.ToString());
                    foreach (DataRow r in drs)
                    {
                        r.Delete();
                    }
                    dtTransactionDetails.Rows.Find(tr.TransactionDetailID).Delete();

                    dgvTransactionDetails.Refresh();
                }
            }
            else if (dgvTransactionDetails.Columns[e.ColumnIndex].Name == "StockInformationButtonColumn" && e.RowIndex >= 0)
            {
                TransactionDataSet.TransactionDetailsRow tr = (TransactionDataSet.TransactionDetailsRow)((DataRowView)(dgvTransactionDetails.Rows[e.RowIndex].DataBoundItem)).Row;

                ViewStockChangeInformation frmStock = new ViewStockChangeInformation();
                frmStock.dt = dtTransactionStockInformation;
                frmStock.TransactionDetailID = tr.TransactionDetailID;
                frmStock.ActionType          = WhistlingPalms.ActionType.Addition.ToString();
                frmStock.WareHouseName       = tr.FromWareHouseName;
                frmStock.FullProductName     = tr.ProductName + ", " + tr.Manufacturer;
                if (frmStock.ShowDialog() == DialogResult.OK)
                {
                    decimal TotalTransactQty = 0;
                    foreach (TransactionDataSet.TransactionStockInformationRow tsr in frmStock.dt.Rows)
                    {
                        if (tsr.TransactionDetailID == tr.TransactionDetailID)
                        {
                            TotalTransactQty += tsr.TransactQuantity;
                        }
                    }
                    tr.TransactQuantity = TotalTransactQty;
                    tr.TotalCost        = tr.TransactCost * tr.TransactQuantity;

                    dgvTransactionDetails.Refresh();
                }
            }
        }