Ejemplo n.º 1
0
        private void createTemplateTouchButton_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(tamplateTitleTextBox.Text) & !string.IsNullOrEmpty(messageRichTextBox.Text))
            {
                if (isNewTitle)
                {
                    titleLabel.BackColor = Color.FromArgb(0, 64, 64);
                    int templateID = 0;
                    if (My.MyProject.Forms.FrmDisplayTemplates.isupdate)
                    {
                        templateID = Conversions.ToInteger(My.MyProject.Forms.FrmDisplayTemplates.templatesListView.Items[My.MyProject.Forms.FrmDisplayTemplates.templatesListView.FocusedItem.Index].SubItems[3].Text);
                    }

                    db.saveTemplate(templateID, Strings.Trim(tamplateTitleTextBox.Text), Conversions.ToString(typeComboBox.SelectedItem), Conversions.ToString(departmentComboBox.SelectedItem), messageRichTextBox);
                    // display confirmation message and clean fields

                    if (My.MyProject.Forms.FrmDisplayTemplates.isupdate)
                    {
                        titleLabel.Text = "Template updated!";
                    }
                    else
                    {
                        titleLabel.Text = "Template created!";
                    }

                    titleLabel.BackColor             = Color.Green;
                    messageRichTextBox.Text          = "";
                    tamplateTitleTextBox.Text        = "";
                    typeComboBox.SelectedIndex       = 0;
                    departmentComboBox.SelectedIndex = 0;
                    MdlScripts.populateTemplates(My.MyProject.Forms.FrmDisplayTemplates.searchWordToolStripTextBox1.Text, Conversions.ToString(My.MyProject.Forms.FrmDisplayTemplates.typeToolStripComboBox.SelectedItem), My.MyProject.Forms.FrmDisplayTemplates.templatesListView);
                    if (My.MyProject.Forms.FrmDisplayTemplates.isupdate)
                    {
                        titleLabel.Text = "Template updated!";
                    }
                    // Me.Close()
                    else
                    {
                        titleLabel.Text = "Template created!";
                    }
                }
                else
                {
                    titleLabel.Text      = "Template title already exists";
                    titleLabel.BackColor = Color.Firebrick;
                }
            }
        }