コード例 #1
0
        private void AbbreviationsMouseUp(object sender, EventArgs e)
        {
            if (AbbreviationsDataGridView.GetCellCount(DataGridViewElementStates.Selected) > 0)
            {
                if (AbbreviationsDataGridView.AreAllCellsSelected(true))
                {
                    throw new NotImplementedException();
                }
                else
                {
                    foreach (DataGridViewRow row in AbbreviationsDataGridView.Rows)
                    {
                        GetSelectedRows(row);
                    }
                }
            }

            void GetSelectedRows(DataGridViewRow row)
            {
                foreach (DataGridViewCell cell in row.Cells)
                {
                    if ((cell.ColumnIndex == 3) && (cell.Selected))
                    {
                        row.Selected = true;
                        break;
                    }
                }
            }
        }
コード例 #2
0
        private void DeleteAbbreviationWords(object sender, EventArgs e)
        {
            int selectedCellCount = AbbreviationsDataGridView.GetCellCount(DataGridViewElementStates.Selected);

            if (selectedCellCount > 0)
            {
                int iRowCount = 0;

                foreach (DataGridViewRow row in AbbreviationsDataGridView.Rows)
                {
                    foreach (DataGridViewCell cell in row.Cells)
                    {
                        if ((cell.ColumnIndex == 3) && (cell.Selected))
                        {
                            iRowCount++;
                            break;
                        }
                    }
                }

                if (iRowCount > 0)
                {
                    switch (MessageBox.Show((iRowCount == 1) ? Properties.Resources.NOTIFY_DELETE_ROW : Properties.Resources.NOTIFY_DELETE_SELECTED_ROWS, Properties.Resources.CAPTION_ABBREVIATIONS, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button3))
                    {
                    case DialogResult.Yes:

                        Cursor.Current = Cursors.WaitCursor;

                        if (AbbreviationsDataGridView.AreAllCellsSelected(true))
                        {
                            throw new NotImplementedException();
                        }
                        else
                        {
                            foreach (DataGridViewRow row in AbbreviationsDataGridView.Rows)
                            {
                                foreach (DataGridViewCell cell in row.Cells)
                                {
                                    if ((cell.ColumnIndex == 3) && (cell.Selected))
                                    {
                                        Dapper.DynamicParameters param = new Dapper.DynamicParameters();

                                        param.Add("@" + Constants.COLUMN_ABBREVIATIONWORD_ID, row.Cells[Constants.COLUMN_ABBREVIATIONWORD_ID].Value);

                                        try
                                        {
                                            DataAccess.DeleteAbbreviation(param);
                                            break;
                                        }
                                        catch (System.Data.SqlClient.SqlException ex)
                                        {
                                            MessageBox.Show(Properties.Resources.NOTIFY_DELETE_ABBREVIATION, Properties.Resources.CAPTION_ABBREVIATIONS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                            if (log != null)
                                            {
                                                log.Error(Properties.Resources.NOTIFY_DELETE_ABBREVIATION, ex);
                                            }
                                        }
                                    }
                                }
                            }

                            GetAbbreviationDataGridView();
                        }

                        break;

                    default: break;
                    }
                }
                else
                {
                    MessageBox.Show(Properties.Resources.NOTIFY_SELECT_ABBREVIATION, Properties.Resources.CAPTION_ABBREVIATIONS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }