Exemplo n.º 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;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void AbbreviationsDataGridViewMouseDownEvent(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                int visibleRows = (AbbreviationsDataGridView.RowCount == 0) ? 0 : AbbreviationsDataGridView.Rows.GetRowCount(DataGridViewElementStates.Visible);

                AbbreviationMenuItemEdit.Enabled   = visibleRows != 0;
                AbbreviationMenuItemDelete.Enabled = visibleRows != 0;

                DataGridView.HitTestInfo hitTest = AbbreviationsDataGridView.HitTest(e.X, e.Y);

                switch (hitTest.Type)
                {
                case DataGridViewHitTestType.ColumnHeader:

                    AbbreviationsDataGridView.ClearSelection();

                    AbbreviationMenuItemEdit.Enabled   = false;
                    AbbreviationMenuItemDelete.Enabled = false;

                    break;

                case DataGridViewHitTestType.RowHeader:

                    break;

                case DataGridViewHitTestType.Cell:

                    if (hitTest.RowIndex >= 0)
                    {
                        if (AbbreviationsDataGridView.SelectedRows.Count <= 1)
                        {
                            AbbreviationsDataGridView.ClearSelection();
                            AbbreviationsDataGridView.CurrentCell = AbbreviationsDataGridView[AbbreviationsDataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible).DisplayIndex, hitTest.RowIndex];
                            AbbreviationsDataGridView.Rows[hitTest.RowIndex].Selected = true;
                        }
                        else
                        {
                            if (!ClassLibraryFramework.DataGridViewMethods.GetSelectedRowsIndex(AbbreviationsDataGridView).Contains(hitTest.RowIndex))
                            {
                                AbbreviationsDataGridView.ClearSelection();
                                AbbreviationsDataGridView.CurrentCell = AbbreviationsDataGridView[AbbreviationsDataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible).DisplayIndex, hitTest.RowIndex];
                                AbbreviationsDataGridView.Rows[hitTest.RowIndex].Selected = true;
                            }
                        }
                    }

                    break;

                default:

                    break;
                }
            }
        }
Exemplo n.º 3
0
        private void EditAbbreviationWord(object sender, EventArgs e)
        {
            DataGridViewRow row = AbbreviationsDataGridView.CurrentRow;

            if (row == null)
            {
                return;
            }

            AbbreviationsDataGridView.ClearSelection();
            AbbreviationsDataGridView.CurrentCell = AbbreviationsDataGridView[AbbreviationsDataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible).DisplayIndex, row.Index];
            AbbreviationsDataGridView.Rows[row.Index].Selected = true;

            using (NAVSymbolForm navSymbolForm = new NAVSymbolForm(true))
            {
                if (navSymbolForm.ShowDialog() == DialogResult.OK)
                {
                    Dapper.DynamicParameters param = new Dapper.DynamicParameters();

                    param.Add("@" + Constants.COLUMN_USER_ID, UserHelper.UserPropertiesModel.iUserID);
                    param.Add("@" + Constants.COLUMN_ABBREVIATION_ID, row.Cells[Constants.COLUMN_ABBREVIATION_ID].Value);
                    param.Add("@" + Constants.COLUMN_ABBREVIATION_WORD, navSymbolForm.nvWord);
                    param.Add("@" + Constants.COLUMN_ABBREVIATION, navSymbolForm.nvAbbreviation);
                    param.Add("@" + Constants.COLUMN_ABBREVIATION_DESCRIPTION, navSymbolForm.nvAbbreviationDescription);
                    param.Add("@" + Constants.COLUMN_ABBREVIATION_FLAG, navSymbolForm.bAlwaysUse);
                    param.Add("@" + Constants.COLUMN_ABBREVIATION_RETURNCODE, dbType: System.Data.DbType.Int32, direction: System.Data.ParameterDirection.ReturnValue);

                    try
                    {
                        if (Convert.ToBoolean(DataAccess.EditAbbreviation(param)))
                        {
                            GetAbbreviationDataGridView(navSymbolForm.nvWord, navSymbolForm.nvAbbreviation);
                        }
                    }
                    catch (System.Data.SqlClient.SqlException ex)
                    {
                        MessageBox.Show(Properties.Resources.NOTIFY_ABBREVIATION_EDIT, Properties.Resources.CAPTION_ABBREVIATIONS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        if (log != null)
                        {
                            log.Error(Properties.Resources.NOTIFY_ABBREVIATION_EDIT, ex);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
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);
                }
            }
        }