Exemple #1
0
        /// <summary>
        /// 保存&更新书源
        /// </summary>
        private void Keep_Click(object sender, RoutedEventArgs e)
        {
            BookSource bookSource = new BookSource();

            bookSource.Title                   = sourceName.Text.Trim();
            bookSource.Url                     = sourceUrl.Text.Trim();
            bookSource.SearchUrl               = SearchUrl.Text;
            bookSource.AddressRangeRegular     = AddressRangeRegular.Text.Replace("'", "''");
            bookSource.AddressCuttingRegular   = AddressCuttingRegular.Text.Replace("'", "''");
            bookSource.AddressRegular          = AddressRegular.Text.Replace("'", "''");
            bookSource.BookNameRegular         = BookNameRegular.Text.Replace("'", "''");
            bookSource.AuthorRegular           = AuthorRegular.Text.Replace("'", "''");
            bookSource.UpdateRegular           = UpdateRegular.Text.Replace("'", "''");
            bookSource.NewestRegular           = NewestRegular.Text.Replace("'", "''");
            bookSource.DetailsRegular          = DetailsRegular.Text.Replace("'", "''");
            bookSource.StateRegular            = StateRegular.Text.Replace("'", "''");
            bookSource.DirectoryScopeRegular   = DirectoryScopeRegular.Text.Replace("'", "''");
            bookSource.DirectoryCuttingRegular = DirectoryCuttingRegular.Text.Replace("'", "''");
            bookSource.DirectoryTieleRegular   = DirectoryTieleRegular.Text.Replace("'", "''");
            bookSource.DirectoryUrlRegular     = DirectoryUrlRegular.Text.Replace("'", "''");
            bookSource.ContentTitleRegular     = ContentTitleRegular.Text.Replace("'", "''");
            bookSource.ContentRegular          = ContentRegular.Text.Replace("'", "''");
            bookSource.ImageRegular            = ImageRegular.Text.Replace("'", "''");
            bookSource.State                   = 1;


            //这个是更新原有源
            if (((Button)sender).Content.ToString() != "保存当前书源")
            {
                int id = Convert.ToInt32(Keep.Tag);
                bookSource.Id = id;
                string Msg  = DataFetch.SourceUpdate(bookSource) ? "更新成功~" : "更新失败!";
                Tips   tips = new Tips(Msg);
                tips.Show();
                //加载书源
                ListSource.ItemsSource = DataFetch.GetBookSources();
            }
            else //这个是增加新源
            {
                if (state_search && state_details && state_Catalog && state_Text)
                {
                    if (sourceName.Text.Trim().Length > 0 && sourceName.Text != "请输入新书源名~" && sourceUrl.Text.Trim().Length > 0 && sourceUrl.Text != "请输入新书源URL~")
                    {
                        string Msg = DataFetch.SourceAdd(bookSource) ? "添加成功~" : "添加失败!";
                        new Tips(Msg).Show();
                    }
                    else
                    {
                        new Tips("请输入书源名和书源链接!").Show();
                    }
                }
                else
                {
                    new Tips("请将其他页面的内容全部填写完毕,并保证准确无误后在进行提交!").Show();
                }
            }
            //加载书源
            ListSource.ItemsSource = DataFetch.GetBookSources();
            Empty();
        }