Ejemplo n.º 1
0
        private void dgvReturnItems_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvReturnItems.DataSource != null && dgvReturnItems.RowCount > 0)
            {
                int    rowIndex       = dgvReturnItems.CurrentCell.RowIndex;
                String depreciationId = dgvReturnItems.Rows[rowIndex].Cells[1].Value.ToString();
                String dateProcured   = dgvReturnItems.Rows[rowIndex].Cells[8].Value.ToString();
                String cost           = dgvReturnItems.Rows[rowIndex].Cells[11].Value.ToString();


                if (depreciationId != "")
                {
                    frmDepreciation depreciation = new frmDepreciation();
                    depreciation.isLoad         = true;
                    depreciation.Cost           = double.Parse(cost);
                    depreciation.DateProcured   = dateProcured;
                    depreciation.depreciationId = depreciationId;
                    depreciation.ShowDialog();
                }
                else
                {
                    MessageBox.Show(null, "No depreciation assigned to this item.", "Depreciation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Ejemplo n.º 2
0
        private void btnLost_Click(object sender, EventArgs e)
        {
            if (dgvItems.RowCount > 0)
            {
                int rowIndex = -1;

                try
                {
                    rowIndex = dgvItems.CurrentCell.RowIndex;
                }
                catch (Exception)
                {
                    MessageBox.Show("Please select an item.");
                    return;
                }

                if (rowIndex > -1)
                {
                   
                    String depreciationId = dgvItems.Rows[rowIndex].Cells[1].Value.ToString();
                    String dateProcured = dgvItems.Rows[rowIndex].Cells[7].Value.ToString();
                    String cost = dgvItems.Rows[rowIndex].Cells[10].Value.ToString();

                    if (depreciationId != "")
                    {
                        frmDepreciation depreciation = new frmDepreciation();
                        depreciation.isLost = true;
                        depreciation.dispose = this;
                        depreciation.Cost = double.Parse(cost);
                        depreciation.DateProcured = dateProcured;
                        depreciation.depreciationId = depreciationId;
                        depreciation.ShowDialog();
                    }
                    else
                    {
                        DialogResult result = MessageBox.Show(null,"Are you sure that the item is lost?","Lost item",MessageBoxButtons.YesNo,MessageBoxIcon.Question,MessageBoxDefaultButton.Button2);
                        if (result == System.Windows.Forms.DialogResult.Yes)
                            markAsLost();
                    }
                    
                }
            }
        }