예제 #1
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);
                        }
                    }
                }
            }
        }
예제 #2
0
        private void InsertAbbreviationWord(object sender, EventArgs e)
        {
            using (NAVSymbolForm navSymbolForm = new NAVSymbolForm())
            {
                if (navSymbolForm.ShowDialog() == DialogResult.OK)
                {
                    DataGridViewRow row = AbbreviationsDataGridView.CurrentRow;

                    if (row == null)
                    {
                        return;
                    }

                    Dapper.DynamicParameters param = new Dapper.DynamicParameters();

                    param.Add("@" + Constants.COLUMN_ABBREVIATION_LANGUAGE_ID, UserHelper.UserPropertiesModel.iLanguageID);
                    param.Add("@" + Constants.COLUMN_ABBREVIATIONTYPE_ID, row.Cells[Constants.COLUMN_ABBREVIATIONTYPE_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
                    {
                        int returnCode = DataAccess.InsertAbbreviation(param);

                        if (returnCode > 0)
                        {
                            try
                            {
                                string nvAbbreviationType = DataAccess.GetAbbreviationType(returnCode);
                                bool   bPlural            = navSymbolForm.nvWord.Contains(" ");

                                MessageBox.Show(string.Format(UserHelper.culture, Properties.Resources.NOTIFY_ABBREVIATION_UPDATE, System.Environment.NewLine, (bPlural ? "phrase" : "word"), (bPlural ? "words" : "word"), navSymbolForm.nvWord, navSymbolForm.nvAbbreviation, nvAbbreviationType), Properties.Resources.CAPTION_ABBREVIATIONS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                if (log != null)
                                {
                                    log.Info(string.Format(UserHelper.culture, Properties.Resources.NOTIFY_ABBREVIATION_UPDATE, System.Environment.NewLine, (bPlural ? "phrase" : "word"), (bPlural ? "words" : "word"), navSymbolForm.nvWord, navSymbolForm.nvAbbreviation, nvAbbreviationType));
                                }
                            }
                            catch (System.Data.SqlClient.SqlException ex)
                            {
                                MessageBox.Show(Properties.Resources.NOTIFY_ABBREVIATION_TYPE, Properties.Resources.CAPTION_ABBREVIATIONS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                if (log != null)
                                {
                                    log.Error(Properties.Resources.NOTIFY_ABBREVIATION_TYPE, ex);
                                }
                            }
                        }

                        GetAbbreviationDataGridView(navSymbolForm.nvWord, navSymbolForm.nvAbbreviation);
                    }
                    catch (System.Data.SqlClient.SqlException ex)
                    {
                        MessageBox.Show(Properties.Resources.NOTIFY_ABBREVIATION_INSERT, Properties.Resources.CAPTION_ABBREVIATIONS, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        if (log != null)
                        {
                            log.Error(Properties.Resources.NOTIFY_ABBREVIATION_INSERT, ex);
                        }
                    }
                }
            }
        }