Пример #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;
                ViewTransferredStockChangeInformation    frmStock = new ViewTransferredStockChangeInformation();
                frmStock.dt = dtTransactionStockInformation;
                frmStock.TransactionDetailID = tr.TransactionDetailID;
                frmStock.ActionType          = WhistlingPalms.ActionType.Transfer.ToString();
                frmStock.FromWareHouseName   = tr.FromWareHouseName;
                frmStock.ToWareHouseName     = tr.ToWareHouseName;
                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 && tsr.IsFromWareHouse == true)
                        {
                            TotalTransactQty += tsr.TransactQuantity;
                        }
                    }
                    tr.TransactQuantity = TotalTransactQty;

                    dgvTransactionDetails.Refresh();
                }
            }
        }
Пример #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;
                ViewTransferredStockChangeInformation    frmStock = new ViewTransferredStockChangeInformation();
                frmStock.dt = dtTransactionStockInformation;
                frmStock.TransactionDetailID = tr.TransactionDetailID;
                frmStock.ActionType          = WhistlingPalms.ActionType.Transfer.ToString();
                frmStock.FromWareHouseName   = tr.FromWareHouseName;
                frmStock.ToWareHouseName     = tr.ToWareHouseName;
                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 && tsr.IsFromWareHouse == true)
                        {
                            TotalTransactQty += tsr.TransactQuantity;
                        }
                    }
                    tr.TransactQuantity = TotalTransactQty;

                    dgvTransactionDetails.Refresh();
                }
            }
        }