private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value);

            if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
            {
                string command = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                if (command.ToLower() == "delete")
                {
                    try
                    {
                        if (MessageBox.Show("Are you sure to Delete", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            string       query = "delete from Reference where id=" + id;;
                            DBConnection db    = new DBConnection(query);
                            db.ExecuteQuery();
                            MessageBox.Show("Reference Successfully deleted");
                            LoadReferences();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else if (command.ToLower() == "edit")
                {
                    AddReference r = new AddReference(userId, id);
                    r.Show();
                }
            }
        }
Пример #2
0
        private void addReferenceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddReference addRerence = new AddReference(UserId, 0);

            addRerence.Show();
        }