Example #1
0
        /// <summary>
        /// Copies a XML Learning Module to the database.
        /// </summary>
        /// <returns></returns>
        /// <remarks>Documented by Dev03, 2008-11-18</remarks>
        private void CopyLM()
        {
            if (!File.Exists(textBoxSource.Text))
            {
                return;
            }
            ConnectionStringStruct connectionTarget;
            ConnectionStringStruct connectionSource = new ConnectionStringStruct(DatabaseType.Xml, textBoxSource.Text, false);
            int newLmId = dictionaries.AddNew(MLifter.DAL.Category.DefaultCategory, string.Empty).Id;

            connectionTarget      = dictionaries.Parent.CurrentUser.ConnectionString;
            connectionTarget.LmId = importedId = newLmId;

            ShowStatusMessage(true);
            LearnLogic.CopyToFinished += new EventHandler(LearnLogic_CopyToFinished);
            try
            {
                LearnLogic.CopyLearningModule(connectionSource, connectionTarget,
                                              (GetLoginInformation)LoginForm.OpenLoginForm, (CopyToProgress)UpdateStatusMessage,
                                              (DataAccessErrorDelegate) delegate(object o, Exception ex) { return; }, m_learnLogic.User);
            }
            catch
            {
                HideStatusMessage();

                //delete partially created dictionary
                dictionaries.Delete(connectionTarget);

                MessageBox.Show(Properties.Resources.DIC_ERROR_LOADING_TEXT,
                                Properties.Resources.DIC_ERROR_LOADING_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        /// <summary>
        /// Handles the Click event of the buttonDelete control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev02, 2008-07-31</remarks>
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            if (listViewLMs.SelectedItems.Count > 0 && dictionaries != null)
            {
                try
                {
                    string messageBoxText = listViewLMs.SelectedItems.Count > 1 ?
                                            string.Format("Are you sure to delete {0} Learning Modules?", listViewLMs.SelectedItems.Count) :
                                            string.Format("Are you sure to delete the Learning Module \"{0}\"?", dictionaries.Get(SelectedLMId).Title);

                    if (MessageBox.Show(messageBoxText, "Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        foreach (ListViewItem selectedItem in listViewLMs.SelectedItems)
                        {
                            if (selectedItem.Tag is int)
                            {
                                dictionaries.Delete(new ConnectionStringStruct(DatabaseType.PostgreSQL, string.Empty, (int)selectedItem.Tag));
                            }
                        }

                        UpdateList();
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.ToString(), "Exception during attempt to delete.");
                }
            }
        }
Example #3
0
        /// <summary>
        /// Deletes a specific LM.
        /// </summary>
        /// <param name="css">The connection string struct.</param>
        public void Delete(ConnectionStringStruct css)
        {
            switch (css.Typ)
            {
            case DatabaseType.Xml:
                xmlDictionaries.Delete(css);
                break;

            case DatabaseType.PostgreSQL:
                throw new NotImplementedException();

            case DatabaseType.Unc:
                throw new NotImplementedException();

            case DatabaseType.MsSqlCe:
                dbDictionaries.Delete(css);
                break;

            default:
                throw new NotImplementedException();
            }
        }