예제 #1
0
        private void WindowDisplayCommand_OnLoaded(object sender, RoutedEventArgs e)
        {
            try
            {
                DialogHostWait.IsOpen = true;

                foreach (var command in Context.Commands.Where(c => !c.IsDeleted))
                {
                    UserControlCommand userControlCommand = new UserControlCommand(this);


                    userControlCommand.ButtonDelete.CommandParameter = command.Id;
                    userControlCommand.ButtonEdit.CommandParameter   = command.Id;



                    userControlCommand.GroupBoxCommand.Header = command.Description;



                    userControlCommand.RichTextBoxQuery.AppendText(command.Query);



                    WrapPanelCommand.Children.Add(userControlCommand);
                }

                DialogHostWait.IsOpen = false;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
            }
        }
예제 #2
0
        public ModifyCommand(UserControlCommand userControlCommand)
        {
            InitializeComponent();

            UserControlCommand = new UserControlCommand(WindowDisplayCommand);

            UserControlCommand = userControlCommand;

            TextBoxDescription.Text = UserControlCommand.GroupBoxCommand.Header.ToString();

            var QueryText = new TextRange(userControlCommand.RichTextBoxQuery.Document.ContentStart, userControlCommand.RichTextBoxQuery.Document.ContentEnd);

            TextBoxQuery.Text = QueryText.Text;
        }
예제 #3
0
        private void ButtonModify_OnClick(object sender, RoutedEventArgs e)
        {
            //ADD
            if (UserControlCommand == null)
            {
                try
                {
                    if (TextBoxQuery.Text != String.Empty && TextBoxQuery.Text != "" && TextBoxQuery.Text.Trim() != "")
                    {
                        DialogHostWait.IsOpen = true;


                        UserControlCommand userControlCommand = new UserControlCommand(WindowDisplayCommand);

                        var CommandSet = new Command()
                        {
                            Description = TextBoxDescription.Text,
                            Query       = TextBoxQuery.Text
                        };
                        Context.Commands.Add(CommandSet);
                        Context.SaveChanges();

                        Context.Dispose();

                        userControlCommand.ButtonDelete.CommandParameter = CommandSet.Id;
                        userControlCommand.ButtonEdit.CommandParameter   = CommandSet.Id;



                        userControlCommand.GroupBoxCommand.Header = TextBoxDescription.Text;

                        //string richText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd).Text;


                        userControlCommand.RichTextBoxQuery.AppendText(TextBoxQuery.Text);



                        WindowDisplayCommand.WrapPanelCommand.Children.Add(userControlCommand);


                        DialogHostWait.IsOpen = false;

                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("يجب إدخال كورية");
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.ToString());
                }
            }
            else //Edit
            {
                try
                {
                    if (TextBoxQuery.Text != String.Empty && TextBoxQuery.Text != "" && TextBoxQuery.Text.Trim() != "")
                    {
                        DialogHostWait.IsOpen = true;
                        var CommandEdit = Context.Commands.Find(UserControlCommand.ButtonEdit.CommandParameter);

                        CommandEdit.Description = TextBoxDescription.Text;
                        CommandEdit.Query       = TextBoxQuery.Text;

                        Context.SaveChanges();

                        UserControlCommand.RichTextBoxQuery.Document.Blocks.Clear();

                        UserControlCommand.GroupBoxCommand.Header = TextBoxDescription.Text;
                        UserControlCommand.RichTextBoxQuery.AppendText(TextBoxQuery.Text);


                        DialogHostWait.IsOpen = true;

                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("يجب إدخال كورية");
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.ToString());
                }
            }
        }