Пример #1
0
        private void add_record_Click(object sender, RoutedEventArgs e)
        {
            fcb_public.publicDataSet publicDataSet = (fcb_public.publicDataSet)(this.FindResource("publicDataSet"));
            fcb_public.publicDataSetTableAdapters.elementTableAdapter publicDataSetTableAdapters = new publicDataSetTableAdapters.elementTableAdapter();
            System.Windows.Data.CollectionViewSource elementViewSource = (System.Windows.Data.CollectionViewSource)(this.FindResource("elementViewSource"));

            if (add_record.Content.ToString() == "新增")
            {
                add_record.Content         = "保存";
                titleTextBox.Text          = "";
                typeComboBox.SelectedIndex = 0;
                //elementViewSource.View.MoveCurrentToLast();
                publicDataSetTableAdapters.Update(publicDataSet.element);
                publicDataSet.element.AcceptChanges();
                publicDataSetTableAdapters.Fill(publicDataSet.element);
                elementViewSource.View.MoveCurrentToLast();
                elementViewSource.View.MoveCurrentToNext();
            }
            else
            {
                add_record.Content = "新增";


                if (typeComboBox.Text != "文档")
                {
                    string t = typeComboBox.Text;
                    File.Copy(openname, PublicClass.background_url);
                }
                if (typeComboBox.Text == "文档")
                {
                    MemoryStream stream = new MemoryStream();
                    TextRange    range  = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd);
                    if (range.Text != "")
                    {
                        range.Save(stream, DataFormats.Xaml);
                        stream.Position = 0;
                        StreamReader r = new StreamReader(stream);
                        contentTextBox.Text = r.ReadToEnd();
                    }

                    publicDataSet.element.AddelementRow(titleTextBox.Text, contentTextBox.Text, typeComboBox.Text, DateTime.Parse(start_timeDatePicker.Text), DateTime.Parse(end_timeDatePicker.Text), (bool)statusCheckBox.IsChecked, int.Parse(show_timeTextBox.Text));
                }
                else if (typeComboBox.Text == "图片" || typeComboBox.Text == "视频")
                {
                    TextRange TRB = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd);
                    publicDataSet.element.AddelementRow(titleTextBox.Text, TRB.Text, typeComboBox.Text, DateTime.Parse(start_timeDatePicker.Text), DateTime.Parse(end_timeDatePicker.Text), (bool)statusCheckBox.IsChecked, int.Parse(show_timeTextBox.Text));
                }

                publicDataSetTableAdapters.Update(publicDataSet.element);
                publicDataSet.element.AcceptChanges();
            }
            System.Windows.Documents.FlowDocument doc = richTextBox1.Document;
            doc.Blocks.Clear();
            //contentTextBox.Clear();
            //publicDataSetTableAdapters.Fill(publicDataSet.element);
            //System.Windows.Data.CollectionViewSource elementViewSource = (System.Windows.Data.CollectionViewSource)(this.FindResource("elementViewSource"));
            //elementDataGrid.CanUserAddRows = false;
        }
Пример #2
0
 private void gridDelete_Click(object sender, RoutedEventArgs e)
 {
     fcb_public.publicDataSet publicDataSet = (fcb_public.publicDataSet)(this.FindResource("publicDataSet"));
     fcb_public.publicDataSetTableAdapters.elementTableAdapter publicDataSetTableAdapters = new publicDataSetTableAdapters.elementTableAdapter();
     System.Windows.Data.CollectionViewSource elementViewSource = (System.Windows.Data.CollectionViewSource)(this.FindResource("elementViewSource"));
     publicDataSet.element.Rows[elementDataGrid.SelectedIndex].Delete();
     //publicDataSet.element.AcceptChanges();
     publicDataSetTableAdapters.Update(publicDataSet.element);
     publicDataSet.element.AcceptChanges();
 }
Пример #3
0
 private void gridDelete_Click(object sender, RoutedEventArgs e)
 {
     fcb_public.publicDataSet publicDataSet = (fcb_public.publicDataSet)(this.FindResource("publicDataSet"));
     fcb_public.publicDataSetTableAdapters.elementTableAdapter publicDataSetTableAdapters = new publicDataSetTableAdapters.elementTableAdapter();
     System.Windows.Data.CollectionViewSource elementViewSource = (System.Windows.Data.CollectionViewSource)(this.FindResource("elementViewSource"));
     publicDataSet.element.Rows[elementDataGrid.SelectedIndex].Delete();
        //publicDataSet.element.AcceptChanges();
     publicDataSetTableAdapters.Update(publicDataSet.element);
     publicDataSet.element.AcceptChanges();
 }
        public void savechanges()
        {
            fcb_public.publicDataSet publicDataSet = (fcb_public.publicDataSet)(this.FindResource("publicDataSet"));
            fcb_public.publicDataSetTableAdapters.elementTableAdapter publicDataSetTableAdapters = new publicDataSetTableAdapters.elementTableAdapter();
            System.Windows.Data.CollectionViewSource elementViewSource = (System.Windows.Data.CollectionViewSource)(this.FindResource("elementViewSource"));

            //publicDataSetTableAdapters.Fill(publicDataSet.element);
            elementViewSource.View.MoveCurrentToNext();
            publicDataSetTableAdapters.Update(publicDataSet.element);
               // publicDataSet.element.AcceptChanges();
        }
Пример #5
0
        public void savechanges()
        {
            fcb_public.publicDataSet publicDataSet = (fcb_public.publicDataSet)(this.FindResource("publicDataSet"));
            fcb_public.publicDataSetTableAdapters.elementTableAdapter publicDataSetTableAdapters = new publicDataSetTableAdapters.elementTableAdapter();
            System.Windows.Data.CollectionViewSource elementViewSource = (System.Windows.Data.CollectionViewSource)(this.FindResource("elementViewSource"));

            //publicDataSetTableAdapters.Fill(publicDataSet.element);
            elementViewSource.View.MoveCurrentToNext();
            publicDataSetTableAdapters.Update(publicDataSet.element);
            // publicDataSet.element.AcceptChanges();
        }
Пример #6
0
        private void element_quedin_Click(object sender, RoutedEventArgs e)
        {
            fcb_public.publicDataSet publicDataSet = (fcb_public.publicDataSet)(this.FindResource("publicDataSet"));
            fcb_public.publicDataSetTableAdapters.elementTableAdapter publicDataSetTableAdapters = new publicDataSetTableAdapters.elementTableAdapter();
            System.Windows.Data.CollectionViewSource elementViewSource = (System.Windows.Data.CollectionViewSource)(this.FindResource("elementViewSource"));
            if (element_quedin.Content.ToString() == "添加")
            {
                publicDataSet.element.AddelementRow(title_textbox.Text, content_textbox.Text, type_textbox.Text, DateTime.Parse(starttime_textbox.Text), DateTime.Parse(endtime_textbox.Text), true, 1);
                elementViewSource.View.MoveCurrentToLast();

                publicDataSetTableAdapters.Update(publicDataSet.element);
                publicDataSet.element.AcceptChanges();
                elementViewSource.View.MoveCurrentToNext();
            }
        }
Пример #7
0
        private void element_quedin_Click(object sender, RoutedEventArgs e)
        {
            fcb_public.publicDataSet publicDataSet = (fcb_public.publicDataSet)(this.FindResource("publicDataSet"));
            fcb_public.publicDataSetTableAdapters.elementTableAdapter publicDataSetTableAdapters = new publicDataSetTableAdapters.elementTableAdapter();
            System.Windows.Data.CollectionViewSource elementViewSource = (System.Windows.Data.CollectionViewSource)(this.FindResource("elementViewSource"));
            if (element_quedin.Content.ToString() == "添加")
            {
                publicDataSet.element.AddelementRow(title_textbox.Text, content_textbox.Text, type_textbox.Text, DateTime.Parse(starttime_textbox.Text), DateTime.Parse(endtime_textbox.Text), true, 1);
                elementViewSource.View.MoveCurrentToLast();

                publicDataSetTableAdapters.Update(publicDataSet.element);
                publicDataSet.element.AcceptChanges();
                elementViewSource.View.MoveCurrentToNext();
            }
        }
Пример #8
0
 private void delete_record_Click(object sender, RoutedEventArgs e)
 {
     fcb_public.publicDataSet publicDataSet = (fcb_public.publicDataSet)(this.FindResource("publicDataSet"));
     fcb_public.publicDataSetTableAdapters.elementTableAdapter publicDataSetTableAdapters = new publicDataSetTableAdapters.elementTableAdapter();
     if (publicDataSet.element.Count > 0)
     {
         try
         {
             id_index = int.Parse(iDTextBox.Text);
             publicDataSet.element.FindByID(id_index).Delete();
             publicDataSetTableAdapters.Update(publicDataSet.element);
             publicDataSet.element.AcceptChanges();
             publicDataSetTableAdapters.Fill(publicDataSet.element);
             System.Windows.Documents.FlowDocument doc = richTextBox1.Document;
             doc.Blocks.Clear();
         }
         catch { }
     }
 }
        private void add_record_Click(object sender, RoutedEventArgs e)
        {
            fcb_public.publicDataSet publicDataSet = (fcb_public.publicDataSet)(this.FindResource("publicDataSet"));
            fcb_public.publicDataSetTableAdapters.elementTableAdapter publicDataSetTableAdapters = new publicDataSetTableAdapters.elementTableAdapter();
            System.Windows.Data.CollectionViewSource elementViewSource = (System.Windows.Data.CollectionViewSource)(this.FindResource("elementViewSource"));

            if (add_record.Content.ToString() == "新增")
            {
                add_record.Content = "保存";
                titleTextBox.Text = "";
                typeComboBox.SelectedIndex = 0;
                //elementViewSource.View.MoveCurrentToLast();
                publicDataSetTableAdapters.Update(publicDataSet.element);
                publicDataSet.element.AcceptChanges();
                publicDataSetTableAdapters.Fill(publicDataSet.element);
                elementViewSource.View.MoveCurrentToLast();
                elementViewSource.View.MoveCurrentToNext();
            }
            else
            {
                add_record.Content = "新增";

                if (typeComboBox.Text !="文档")
                {
                    string t = typeComboBox.Text;
                    File.Copy(openname, PublicClass.background_url);
                }
                if (typeComboBox.Text == "文档")
                {
                    MemoryStream stream = new MemoryStream();
                    TextRange range = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd);
                    if (range.Text != "")
                    {
                        range.Save(stream, DataFormats.Xaml);
                        stream.Position = 0;
                        StreamReader r = new StreamReader(stream);
                        contentTextBox.Text = r.ReadToEnd();
                    }

                    publicDataSet.element.AddelementRow(titleTextBox.Text, contentTextBox.Text, typeComboBox.Text, DateTime.Parse(start_timeDatePicker.Text), DateTime.Parse(end_timeDatePicker.Text), (bool)statusCheckBox.IsChecked, int.Parse(show_timeTextBox.Text));
                }
                else if (typeComboBox.Text == "图片" || typeComboBox.Text == "视频")
                {
                    TextRange TRB = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd);
                    publicDataSet.element.AddelementRow(titleTextBox.Text, TRB.Text, typeComboBox.Text, DateTime.Parse(start_timeDatePicker.Text), DateTime.Parse(end_timeDatePicker.Text), (bool)statusCheckBox.IsChecked, int.Parse(show_timeTextBox.Text));
                }

                publicDataSetTableAdapters.Update(publicDataSet.element);
                publicDataSet.element.AcceptChanges();

            }
            System.Windows.Documents.FlowDocument doc = richTextBox1.Document;
            doc.Blocks.Clear();
            //contentTextBox.Clear();
            //publicDataSetTableAdapters.Fill(publicDataSet.element);
            //System.Windows.Data.CollectionViewSource elementViewSource = (System.Windows.Data.CollectionViewSource)(this.FindResource("elementViewSource"));
            //elementDataGrid.CanUserAddRows = false;
        }
 private void delete_record_Click(object sender, RoutedEventArgs e)
 {
     fcb_public.publicDataSet publicDataSet = (fcb_public.publicDataSet)(this.FindResource("publicDataSet"));
     fcb_public.publicDataSetTableAdapters.elementTableAdapter publicDataSetTableAdapters = new publicDataSetTableAdapters.elementTableAdapter();
     if (publicDataSet.element.Count > 0)
     {
         try
         {
             id_index = int.Parse(iDTextBox.Text);
             publicDataSet.element.FindByID(id_index).Delete();
             publicDataSetTableAdapters.Update(publicDataSet.element);
             publicDataSet.element.AcceptChanges();
             publicDataSetTableAdapters.Fill(publicDataSet.element);
             System.Windows.Documents.FlowDocument doc = richTextBox1.Document;
             doc.Blocks.Clear();
         }
         catch { }
     }
 }