示例#1
0
        private void deleteProject_Click(object sender, EventArgs e)
        {
            dataGridViewProjects.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            if (dataGridViewProjects.SelectedRows.Count > 0)
            {
                selectedIdFromProjects = Convert.ToInt32(dataGridViewProjects.SelectedRows[0].Cells[0].Value.ToString());

                DialogResult dialogResult = MessageBox.Show("Are you sure to want to delete this project?", "Delete project", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    var success = projectPresenter.DeleteProject(selectedIdFromProjects);
                    if (success)
                    {
                        MessageBox.Show("Success!", "Message");
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                    MessageBox.Show("Nothing was deleted!", "Message");
                }

                dataGridViewClients.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                if (dataGridViewClients.SelectedRows.Count > 0)
                {
                    selectedIdFromProjects          = Convert.ToInt32(dataGridViewClients.SelectedRows[0].Cells[0].Value.ToString());
                    dataContact                     = projectPresenter.GetAllProjects(selectedIdFromProjects);
                    dataGridViewProjects.DataSource = dataContact;
                    dataGridViewProjects.DataMember = dataContact.TableName;
                }
            }
            else
            {
                MessageBox.Show("There is not any row selected!");
            }
        }