Exemplo n.º 1
0
        public void RemoveClick(object sender, EventArgs e)
        {
            int         row         = editedTableLayoutPanel.GetRow(((Label)sender));
            Label       titleLabel  = (Label)editedTableLayoutPanel.GetControlFromPosition(0, row);
            EditedLemma toBeRemoved = null;

            foreach (EditedLemma ed in EditedLemmas)
            {
                if (ed.LemmaTitle == titleLabel.Text)
                {
                    toBeRemoved = ed;
                    break;
                }
            }
            int result = DBConnect.Delete(toBeRemoved, StartPage.account.User);

            if (result != 1)
            {
                MessageBox.Show("  Something went wrong trying to remove that Lemma.");
            }
            else
            {
                //now remove and update
                EditedLemmas.Remove(toBeRemoved);
                StartPage.editedLemmaList = EditedLemmas;
                SetLemmas();
            }
        }
Exemplo n.º 2
0
 public LemmaEditor(EditedLemma editedLemma, int mode)
 {
     InitializeComponent();
     this.EditedLemma     = editedLemma;
     this.Mode            = mode;
     lemmaTitleLabel.Text = editedLemma.LemmaTitle + " - Edited By '" + StartPage.account.User.Name + "'";
 }
Exemplo n.º 3
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            //Determine if we are creating a new edited Lemma or updating one
            byte[] newBody = Encoding.UTF8.GetBytes(htmlTextBox1.WebBrowser.Document.Body.InnerHtml);
            //if new one
            if (Mode == 0)
            {
                //make EditedLemma
                EditedLemma = new EditedLemma(Lemma.Title, StartPage.account.User, newBody, DateTime.Now, DateTime.Now);

                int res = DBConnect.Insert(EditedLemma);
                if (res == 1)
                {
                    MessageBox.Show("  The edited lemma \"" + Lemma.Title + "\"\n  was saved successfully to your account!\n");
                    StartPage.editedLemmaList = DBConnect.GetEditedLemmasByUser(StartPage.account.User);
                    EditedLemmataUserControl.Instance.EditedLemmas = StartPage.editedLemmaList;
                    EditedLemmataUserControl.Instance.SetLemmas();
                    Close();
                }
                else
                {
                    MessageBox.Show("  Something went wrong! Please try again.\n");
                }
            }
            else if (Mode == 1)
            {
                //if updating existing one
                EditedLemma           = DBConnect.GetEditedLemmaByUserAndTitle(EditedLemma.LemmaTitle, StartPage.account.User);
                EditedLemma.Body      = htmlTextBox1.WebBrowser.Document.Body.InnerHtml;
                EditedLemma.UpdatedAt = DateTime.Now;

                int res = DBConnect.Update(EditedLemma, StartPage.account.User);
                if (res == 1)
                {
                    MessageBox.Show("  The edited lemma \"" + EditedLemma.LemmaTitle + "\"\n  was saved successfully to your account!\n");
                    StartPage.editedLemmaList = DBConnect.GetEditedLemmasByUser(StartPage.account.User);
                    EditedLemmataUserControl.Instance.EditedLemmas = StartPage.editedLemmaList;
                    EditedLemmataUserControl.Instance.SetLemmas();
                    Close();
                }
                else
                {
                    MessageBox.Show("  Something went wrong! Please try again.\n");
                }
            }
        }
Exemplo n.º 4
0
        private static void ConfigureLemma(int userID, string lemmaTitle, out Lemma lemma, out EditedLemma editedLemma)
        {
            byte[] lemmaBody     = null;
            int    lemmaCategory = -999;

            lemma       = null;
            editedLemma = null;
            if (LemmaViewUserControl.Instance.Mode == 0)
            {
                //Get the properties needed for the creation of Lemma object
                lemmaBody     = DBConnect.GetLemmaBodyByTitle(lemmaTitle);
                lemmaCategory = DBConnect.GetLemmaCategoryByTitle(lemmaTitle);
                lemma         = new Lemma(lemmaTitle, lemmaBody, lemmaCategory);
            }
            else
            {
                User user = new User();
                user.Id     = userID;
                editedLemma = DBConnect.GetEditedLemmaByUserAndTitle(lemmaTitle, user);
            }
        }