示例#1
0
        private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0 && e.ColumnIndex == 2) // update record
            {
                //TODO - Button Clicked - Execute Code Here
                Int64           cID      = Int64.Parse(dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString());
                string          cName    = dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString();
                pCategoryUpdate pcUpdate = new pCategoryUpdate(cID, cName, 1);
                pcUpdate.Show();
            }
            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0 && e.ColumnIndex == 3) // delete record
            {
                Int64        cID          = Int64.Parse(dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString());
                DialogResult dialogResult = MessageBox.Show("Are you sure want to Delete record?", "Delete", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    pcBLL = new ProductCategoryBLL();


                    PCategoryDTO DTO = new PCategoryDTO("", 0);
                    DTO.CATID = cID;
                    pcBLL.deleteCatRecord(DTO);

                    searchAll();
                }
                else if (dialogResult == DialogResult.No)
                {
                }
            }
        }