Beispiel #1
0
        private void borow_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("确定借阅该书吗?", "", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
            {
                return;
            }
            API.Book b = bookName.Tag as API.Book;

            bool   flag = false;
            object usr  = users.Txt.Text;

            if (users.SelectedValue != null)
            {
                usr  = users.SelectedValue;
                flag = true;
            }

            RequestHelper.RequestAsync(this.busy, (int)MethodType.Borow, new List <object>()
            {
                flag, usr, new List <int>()
                {
                    b.BID
                }
            }, new EventHandler <API.ExecuteCompletedEventArgs>(BorowCompleted));
        }
Beispiel #2
0
        private void Save_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            if (GridList.SelectedItem == null)
            {
                MessageBox.Show("请选择需添加关键字的书籍!");
                return;
            }
            API.Book b = GridList.SelectedItem as API.Book;

            List <API.BookKey> models = GridScan.ItemsSource as List <API.BookKey>;

            foreach (var item in models)
            {
                item.BID = b.BID;
            }

            if (MessageBox.Show("确定为 " + b.BookName + "添加关键字吗?", "", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
            {
                return;
            }

            RequestHelper.RequestAsync(this.busy, (int)MethodType.AddBKeys, new List <object>()
            {
                models
            }, new EventHandler <API.ExecuteCompletedEventArgs>(SaveCompleted));
        }
Beispiel #3
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RadMenuItem_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            if (GridList.SelectedItems == null)
            {
                MessageBox.Show("请选择要删除的书籍!");
                return;
            }
            if (MessageBox.Show("确定删除选中的书籍吗?", "", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
            {
                return;
            }

            List <int> bids = new List <int>();

            foreach (var item in GridList.SelectedItems)
            {
                API.Book b = item as API.Book;
                bids.Add(b.BID);
            }

            RequestHelper.RequestAsync(this.busy, (int)MethodType.DeleteBook, new List <object>()
            {
                bids
            }, new EventHandler <API.ExecuteCompletedEventArgs>(DeleteCompleted));
        }
Beispiel #4
0
        private void GridList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            API.BorowInfo b = GridList.SelectedItem as API.BorowInfo;

            API.Book bok = new  API.Book();
            bok.BAuthor    = b.BAuthor;
            bok.BID        = b.BID;
            bok.BookName   = b.BookName;
            bok.BPrice     = b.BPrice;
            bok.BTypeID    = b.BTypeID;
            bok.BTypeName  = b.BTypeName;
            bok.IsBorow    = !b.IsReturn;
            bok.PubDate    = b.PubDate;
            bok.Publisher  = b.Publisher;
            bok.SerialNum  = b.SerialNum;
            bok.SMPosition = b.SMPosition;

            RadTabItem rb = new RadTabItem();

            rb.Header = bok.BookName;//"图书简介"
            //Frame newframe = new Frame();
            //newframe.NavigationUIVisibility = NavigationUIVisibility.Hidden;
            //newframe.JournalOwnership = System.Windows.Navigation.JournalOwnership.OwnsJournal;
            //newframe.BorderThickness = new Thickness(1);
            //newframe.Source = new Uri("BookDetail.xaml", UriKind.Relative);

            BookDetail bd = new BookDetail(bok);

            rb.Content    = bd;
            rb.IsSelected = true;

            Main.AddTabItem(rb);
        }
Beispiel #5
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Sumbit_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(bookName.Text))
            {
                Tool.PlayBackgAnimation(bookName);
                return;
            }
            if (string.IsNullOrEmpty(author.Text))
            {
                Tool.PlayBackgAnimation(author);
                return;
            }
            if (string.IsNullOrEmpty(outline.Text))
            {
                Tool.PlayBackgAnimation(outline);
                return;
            }
            if (string.IsNullOrEmpty(publisher.Text))
            {
                Tool.PlayBackgAnimation(publisher);
                return;
            }
            //if (string.IsNullOrEmpty(serialNum.Text))
            //{
            //    Tool.PlayBackgAnimation(serialNum);
            //    return;
            //}
            if (string.IsNullOrEmpty(position.Text))
            {
                Tool.PlayBackgAnimation(position);
                return;
            }
            if (string.IsNullOrEmpty(pubDate.DateTimeText))
            {
                Tool.PlayBackgAnimation(pubDate);
                return;
            }
            API.Book b = new API.Book();
            b.BID        = Convert.ToInt32(bookName.Tag);
            b.BAuthor    = author.Text.Trim();
            b.BookName   = bookName.Text.Trim();
            b.BPrice     = (double)price.Value;
            b.BTypeID    = (int)type.SelectedValue;
            b.OutLine    = this.outline.Text.Trim();
            b.PubDate    = (DateTime)pubDate.SelectedDate;
            b.Publisher  = publisher.Text;
            b.SerialNum  = serialNum.Text;
            b.SMPosition = position.Text;

            RequestHelper.RequestAsync(this.busy, (int)MethodType.UpdateBook, new List <object>()
            {
                b
            }, new EventHandler <API.ExecuteCompletedEventArgs>(SaveCompleted));
        }
Beispiel #6
0
        private void GridList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            API.Book bok = GridList.SelectedItem as API.Book;

            RadTabItem rb = new RadTabItem();

            rb.Header     = bok.BookName;
            rb.Content    = new BookDetail(bok);
            rb.IsSelected = true;

            Main.AddTabItem(rb);
        }
Beispiel #7
0
 private void GridList_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
 {
     if (GridList.SelectedItem == null)
     {
         return;
     }
     API.Book b = GridList.SelectedItem as API.Book;
     GridKey.Tag = b.BID;
     RequestHelper.RequestAsync(this.busy, (int)MethodType.GetBKeyByBID, new List <object>()
     {
         b.BID
     }, new EventHandler <API.ExecuteCompletedEventArgs>(GetBKeyCompleted));
 }
Beispiel #8
0
        private void Return_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("确定归还该书吗?", "", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
            {
                return;
            }
            API.Book b = bookName.Tag as API.Book;

            RequestHelper.RequestAsync(this.busy, (int)MethodType.Return, new List <object>()
            {
                users.Txt.Text, new List <int>()
                {
                    b.BID
                }
            }, new EventHandler <API.ExecuteCompletedEventArgs>(ReturnCompleted));
        }
Beispiel #9
0
        public BookDetail(API.Book book)
        {
            InitializeComponent();

            users.ItemsSource       = Store.UserInfos;
            users.DisplayMemberPath = "UserName";
            users.SelectedValuePath = "UserID";
            users.SelectedIndex     = 0;

            bookName.Text  = book.BookName;
            bookName.Tag   = book;
            author.Text    = book.BAuthor;
            position.Text  = book.SMPosition;
            serialNum.Text = book.SerialNum;
            price.Text     = book.BPrice.ToString();
            publisher.Text = book.Publisher;
            pubDate.Text   = book.PubDate.ToString("yyyy-MM-dd");

            borow.IsEnabled  = true;
            Return.IsEnabled = true;
            if (book.IsBorow)
            {
                borow.IsEnabled  = false;
                state.Text       = "已借";
                state.Foreground = new SolidColorBrush(Colors.Red);
            }
            else
            {
                Return.IsEnabled = false;
                state.Text       = "可借";
                state.Foreground = new SolidColorBrush(Colors.Green);
            }
            var t = from a in Store.TypeInfos
                    where a.TypeID == book.BTypeID
                    select a;

            if (t.Count() != 0)
            {
                type.Text = t.First().BTypeName;
            }
            RequestHelper.RequestAsync(this.busy, (int)MethodType.GetOutLine, new List <object>()
            {
                book.BID
            }, new EventHandler <API.ExecuteCompletedEventArgs>(GetDetailCompleted));
        }
Beispiel #10
0
        public void SaveCompleted(object sender, API.ExecuteCompletedEventArgs e)
        {
            this.busy.IsBusy = false;

            MessageBox.Show(e.Result.Message);
            if (e.Result.ReturnValue)
            {
                if (GridList.SelectedItem == null)
                {
                    return;
                }
                API.Book b = GridList.SelectedItem as API.Book;
                GridKey.Tag = b.BID;
                RequestHelper.RequestAsync(this.busy, (int)MethodType.GetBKeyByBID, new List <object>()
                {
                    b.BID
                }, new EventHandler <API.ExecuteCompletedEventArgs>(GetBKeyCompleted));
            }
        }
Beispiel #11
0
        public override Style SelectStyle(object item, DependencyObject container)
        {
            if (item is API.Book)
            {
                API.Book model = item as API.Book;

                if (model.IsBorow)
                {
                    model.Note = "已借";
                    return(RedStyle);
                }
                else
                {
                    model.Note = "可借";
                }
                return(null);
            }

            return(null);
        }
Beispiel #12
0
        private void GridList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            API.Book bok = GridList.SelectedItem as API.Book;

            RadTabItem rb = new RadTabItem();

            rb.Header = bok.BookName;//"图书简介"
            //Frame newframe = new Frame();
            //newframe.NavigationUIVisibility = NavigationUIVisibility.Hidden;
            //newframe.JournalOwnership = System.Windows.Navigation.JournalOwnership.OwnsJournal;
            //newframe.BorderThickness = new Thickness(1);
            //newframe.Source = new Uri("BookDetail.xaml", UriKind.Relative);

            BookDetail bd = new BookDetail(bok);

            rb.Content    = bd;
            rb.IsSelected = true;

            Main.AddTabItem(rb);
        }
Beispiel #13
0
        private void GridList_SelectionChanged(object sender, SelectionChangeEventArgs e)
        {
            if (GridList.SelectedItem == null)
            {
                return;
            }
            API.Book b = GridList.SelectedItem as API.Book;
            position.Text        = b.SMPosition;
            serialNum.Text       = b.SerialNum;
            pubDate.DateTimeText = b.PubDate.ToString("yyyy-MM-dd");
            publisher.Text       = b.Publisher;
            price.Value          = b.BPrice;
            bookName.Text        = b.BookName;
            bookName.Tag         = b.BID;
            author.Text          = b.BAuthor;
            type.SelectedValue   = b.BTypeID;

            RequestHelper.RequestAsync(this.busy, (int)MethodType.GetOutLine, new List <object>()
            {
                b.BID
            }, new EventHandler <API.ExecuteCompletedEventArgs>(GetDetailCompleted));
        }
Beispiel #14
0
        private void add_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(position.Text))
            {
                Tool.PlayBackgAnimation(position);
                return;
            }

            if (string.IsNullOrEmpty(serialNum.Text))
            {
                Tool.PlayBackgAnimation(serialNum); return;
            }

            if (string.IsNullOrEmpty(bookName.Text))
            {
                Tool.PlayBackgAnimation(bookName); return;
            }

            if (string.IsNullOrEmpty(author.Text))
            {
                Tool.PlayBackgAnimation(author); return;
            }

            if (type.SelectedIndex == -1)
            {
                Tool.PlayBackgAnimation(type); return;
            }

            if (price.Value == 0)
            {
                Tool.PlayBackgAnimation(price); return;
            }

            if (string.IsNullOrEmpty(publisher.Text))
            {
                Tool.PlayBackgAnimation(publisher); return;
            }

            if (string.IsNullOrEmpty(pubDate.DateTimeText) || pubDate.SelectedDate == null)
            {
                Tool.PlayBackgAnimation(pubDate); return;
            }


            API.Book b = new API.Book();
            b.BAuthor    = author.Text.Trim();
            b.BookName   = bookName.Text.Trim();
            b.OutLine    = outline.Text.Trim();
            b.SMPosition = position.Text.Trim();
            b.BPrice     = (double)price.Value;
            b.Publisher  = publisher.Text;
            b.PubDate    = (DateTime)pubDate.SelectedDate;
            b.BTypeID    = (int)type.SelectedValue;
            b.SerialNum  = serialNum.Text;

            API.Result ret = RequestHelper.Request(this.busy, (int)MethodType.AddBook, new List <object>()
            {
                b
            });
            MessageBox.Show(ret.Message);
            if (ret.ReturnValue)
            {
                Clear();
            }
        }