private async Task BindChartData()
        {
            try
            {
                _handle = OverlayScreenForm.ShowProgressPanel(this);
                #region 饼状图

                var data = await _api.GetBookChartByCategory();

                Ct_BookCategorySum.DataSource = data;
                var series = Ct_BookCategorySum.Series[0];
                series.ValueDataMembers[0] = "Number";
                series.ArgumentDataMember  = "CategoryName";
                var label = (PieSeriesLabel)series.Label;
                label.TextPattern = "{A}: {VP:P0}";
                var title = new ChartTitle {
                    Text = @"馆藏图书分类汇总", Alignment = StringAlignment.Center
                };
                Ct_BookCategorySum.Titles.Add(title);

                #endregion

                #region 柱状图

                var borrowCharts = await _api.GetBorrowByDayChart();

                Ct_Bar.DataSource = borrowCharts;
                var barSeries = Ct_Bar.Series[0];
                barSeries.ValueDataMembers[0] = "Number";
                barSeries.ArgumentDataMember  = "CreateDate";
                var barLabel = (BarSeriesLabel)barSeries.Label;
                barLabel.TextPattern = "{A}: {V}";
                var barTitle = new ChartTitle {
                    Text = @"近一周借阅统计", Alignment = StringAlignment.Center
                };
                Ct_Bar.Titles.Add(barTitle);

                #endregion

                #region 数据合计展示

                var booksTotal       = await new BookApi().GetBookTotal();
                var borrowsTotal     = await new BorrowApi().GetBorrowTotal();
                var studentsTotal    = await new StudentApi().GetStudentTotal();
                var employeesTotal   = await new EmployeeApi().GetEmployeeTotal();
                var reservationTotal = await new ReservationApi().GetReservationTotal();
                Tbi_Books.Elements[1].Text        = booksTotal.ToString();
                Tbi_Borrows.Elements[1].Text      = borrowsTotal.ToString();
                Tbi_Employees.Elements[1].Text    = employeesTotal.ToString();
                Tbi_Students.Elements[1].Text     = studentsTotal.ToString();
                Tbi_Reservations.Elements[1].Text = reservationTotal.ToString();
                #endregion
                OverlayScreenForm.CloseProgressPanel(_handle);
            }
            catch (Exception e)
            {
                OverlayScreenForm.CloseProgressPanel(_handle);
                PopupProvider.Error("获取图表数据或合计数据异常!", e);
            }
        }
        private async void Ribe_Return_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            try
            {
                if (!Gv_Borrows.GetFocusedRowCellDisplayText("ReturnState").Equals("未归还"))
                {
                    PopupProvider.Warning("该书已归还!");
                    return;
                }

                var dialogResult = XtraMessageBox.Show("确认归还?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult != DialogResult.Yes)
                {
                    return;
                }
                _handle = OverlayScreenForm.ShowProgressPanel(this);
                var id     = Gv_Borrows.GetFocusedRowCellDisplayText("Id");
                var result = await _borrowApi.ReturnBook(id);

                OverlayScreenForm.CloseProgressPanel(_handle);
                if (result.ResultCode != 1)
                {
                    PopupProvider.Warning(result.ResultMessage);
                }

                PopupProvider.Success(result.ResultMessage);

                await BindData();
            }
            catch (Exception exception)
            {
                OverlayScreenForm.CloseProgressPanel(_handle);
                PopupProvider.Error(exception.Message, exception);
            }
        }
        private async void Sb_Query_Click(object sender, EventArgs e)
        {
            try
            {
                _handle = OverlayScreenForm.ShowProgressPanel(this);
                var dic = new Dictionary <string, object>()
                {
                    { "CreateTime", $"{De_Begin.DateTime}" },
                    { "BookName", Te_BookName.Text }
                };
                var data = await _api.GetBooks(dic);

                foreach (var book in data)
                {
                    book.Photo = Image.FromFile(book.BookPhoto);
                }

                Gc_Data.DataSource = data;
            }
            catch (Exception ex)
            {
                PopupProvider.Error("获取数据异常!", ex);
            }
            finally
            {
                OverlayScreenForm.CloseProgressPanel(_handle);
            }
        }
        /// <summary>
        /// 绑定学生信息数据
        /// </summary>
        /// <returns></returns>
        private async Task BindStudentInfo()
        {
            var studentNo = Te_StudentNo.Text;

            try
            {
                _handle = OverlayScreenForm.ShowProgressPanel(this);
                var students = await _api.GetStudents(new Dictionary <string, object>
                {
                    { "StudentNo", studentNo }
                });

                var student = students.FirstOrDefault();
                if (student == null)
                {
                    PopupProvider.Warning("未检索到信息!");
                    return;
                }

                Te_Age.EditValue       = student.Age;
                Te_Name.Text           = student.StudentName;
                Te_Class.Text          = student.Class;
                Te_Sex.Text            = student.Sex ? "女" : "男";
                Te_Department.Text     = student.DepartmentName;
                Te_Phone.EditValue     = student.Contact;
                Te_Email.Text          = student.Email;
                Te_StudentNo.EditValue = student.StudentNo;
                Te_StudentId.Text      = student.Id.ToString();

                #region 获取当前学生剩余可借阅数量

                var num = await _borrowApi.GetBorrowInfoTotal(Te_StudentId.Text);

                if (num != -1)
                {
                    Te_BooksNum.EditValue = 3 - num;
                }
                else
                {
                    Te_BooksNum.EditValue = 3;
                }

                #endregion

                OverlayScreenForm.CloseProgressPanel(_handle);
            }
            catch (Exception e)
            {
                OverlayScreenForm.CloseProgressPanel(_handle);
                PopupProvider.Error("获取学生信息异常!", e);
                LogHelper.Error(e.ToString());
            }
        }
        private async void Sb_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(Te_StudentId.Text))
                {
                    PopupProvider.Warning("请填写借阅人信息!");
                    return;
                }
                _handle = OverlayScreenForm.ShowProgressPanel(this);
                var infosTotal = Convert.ToInt32(Te_BooksNum.Text);
                if (infosTotal <= 0)
                {
                    OverlayScreenForm.CloseProgressPanel(_handle);
                    PopupProvider.Warning("已达最大可借阅数!");
                    return;
                }

                var books   = (List <Borrow>)Gv_BookInfos.DataSource;
                var borrows = books.Select(m => new Borrow
                {
                    StudentId = Guid.Parse(Te_StudentId.Text),
                    AdminId   = GlobalCache.Admin.Id,
                    EndTime   = DateTime.Now.AddDays(21),
                    BackTime  = DateTime.MaxValue,
                    BookId    = m.BookId
                }).ToList();
                var res = await _borrowApi.CreateBorrows(borrows);

                if (res.ResultCode != 1)
                {
                    OverlayScreenForm.CloseProgressPanel(_handle);
                    PopupProvider.Warning(res.ResultMessage);
                    return;
                }

                OverlayScreenForm.CloseProgressPanel(_handle);
                Gc_BookInfos.DataSource = new List <Borrow>();
                Clear(3);
                Te_BooksNum.Text  = string.Empty;
                Te_StudentId.Text = string.Empty;
                PopupProvider.Success(res.ResultMessage);
            }
            catch (Exception exception)
            {
                OverlayScreenForm.CloseProgressPanel(_handle);
                PopupProvider.Error("操作异常!", exception);
            }
        }
        public async Task BindData()
        {
            try
            {
                _handle = OverlayScreenForm.ShowProgressPanel(this);
                var data = await _api.GetBooks(false);

                foreach (var book in data)
                {
                    book.Photo = Image.FromFile(book.BookPhoto);
                }

                Gc_Data.DataSource = data;
            }
            catch (Exception ex)
            {
                PopupProvider.Error("获取数据异常!", ex);
            }
            finally
            {
                OverlayScreenForm.CloseProgressPanel(_handle);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Nbc_Menu_LinkClicked(object sender, NavBarLinkEventArgs e)
        {
            var      formName = e.Link.Item.Tag.ToString();
            XtraForm form;

            switch (formName)
            {
            case "101":
                form             = new FrmBorrow();
                GlobalCache.Type = typeof(FrmBorrow);

                #region Test

                //ribbon.Pages[0].Groups[0].ItemLinks.Add(new BarButtonItem() {
                //Caption = "test", ImageOptions = { Image = Image.FromFile(@"C:\Users\ASUS\Pictures\ICON\Exit.png") }
                //});

                #endregion

                break;

            case "102":
                form             = new FrmReservation();
                GlobalCache.Type = typeof(FrmReservation);
                break;

            case "103":
                form             = new FrmBorrowInfos();
                GlobalCache.Type = typeof(FrmBorrowInfos);
                break;

            case "104":
                form             = new FrmReservationInfos();
                GlobalCache.Type = typeof(FrmReservationInfos);
                break;

            case "105":
                form             = new FrmFinePayments();
                GlobalCache.Type = typeof(FrmFinePayments);
                break;

            case "106":
                form             = new FrmBooks();
                GlobalCache.Type = typeof(FrmBooks);
                break;

            case "201":
                form             = new FrmBooksInfo();
                GlobalCache.Type = typeof(FrmBooksInfo);
                break;

            case "202":
                form             = new FrmBooks();
                GlobalCache.Type = typeof(FrmBooks);
                break;

            case "401":
                form             = new FrmEmployees();
                GlobalCache.Type = typeof(FrmEmployees);
                break;

            case "301":
                form             = new FrmStudents();
                GlobalCache.Type = typeof(FrmStudents);
                break;

            case "501":
                form             = new FrmAdmins();
                GlobalCache.Type = typeof(FrmAdmins);
                break;

            case "502":
                form             = new FrmEmpower();
                GlobalCache.Type = typeof(FrmEmpower);
                break;

            case "601":
                form             = new FrmPublishingHouse();
                GlobalCache.Type = typeof(FrmPublishingHouse);
                break;

            case "602":
                form             = new FrmBookCategory();
                GlobalCache.Type = typeof(FrmBookCategory);
                break;

            default:
                form = new XtraForm();
                break;
            }

            if (CheckIsExist(form.Text))
            {
                return;
            }
            form.MdiParent = this;
            _handle        = OverlayScreenForm.ShowProgressPanel(this);
            form.Show();
            OverlayScreenForm.CloseProgressPanel(_handle);
        }
        private async Task BindBookInfo()
        {
            try
            {
                var searchPara = Te_SearchPara.Text.Trim();
                //获取模糊查询书籍信息
                _handle = OverlayScreenForm.ShowProgressPanel(this);
                var bookInfos = await _bookInfoApi.GetBooksInfo(false);

                bookInfos = bookInfos
                            .Where(m => m.Id.ToString().Contains(searchPara) || m.BookName.Contains(searchPara)).ToList();
                OverlayScreenForm.CloseProgressPanel(_handle);
                if (bookInfos.Count == 0)
                {
                    PopupProvider.Warning("未检索到信息!");
                    return;
                }

                //找到对应的书籍信息的已上架书籍
                var books = new List <Book>();


                foreach (var info in bookInfos)
                {
                    books.AddRange(await _bookApi.GetBooks(new Dictionary <string, object>
                    {
                        { "BookInfoId", info.Id }
                    }));
                }


                foreach (var item in books)
                {
                    switch (item.BookState)
                    {
                    case 0:
                        item.BookStateName = "正常";
                        break;

                    case 1:
                        item.BookStateName = "已借阅";
                        break;

                    case 2:
                        item.BookStateName = "已预约";
                        break;
                    }
                }

                //如果存在多个数据,采用列表显示,操作员自行选择.
                if (books.Count > 1)
                {
                    Gc_Books.DataSource = books;
                    Gc_Books.Visible    = true;
                    Gv_Books.Focus();
                    return;
                }
                if (books.Count == 0)
                {
                    PopupProvider.Warning("未找到可借阅的相应书籍!");
                    return;
                }

                //如果只有一条数据则进行数据赋值展示
                var book        = books.First();
                var reservation = await _reservationApi.GetReservations(new Dictionary <string, object>
                {
                    { "BookId", book.Id },
                    { "IsRemove", false },
                    { "StudentId", Te_StudentId.Text }
                });

                if (reservation.Count <= 0 && book.BookStateName.Equals("已预约"))
                {
                    PopupProvider.Warning($"{book.BookStateName}书籍不可借阅!");
                    return;
                }
                if (book.BookStateName.Equals("已借阅"))
                {
                    PopupProvider.Warning($"{book.BookStateName}书籍不可借阅!");
                    return;
                }
                Te_BookName.Text         = book.BookName;
                Te_Author.Text           = book.Author;
                Te_ReleaseTime.EditValue = book.ReleaseDate;
                Te_PublishingHouse.Text  = book.PublishingName;
                Te_Category.Text         = book.CategoryName;
                Pe_BookPhoto.Image       = Image.FromFile(book.BookPhoto);
                Te_BookId.Text           = book.Id.ToString();
                Te_ISBN.Text             = book.ISBN;
                Te_ReleaseTime.Text      = book.ReleaseDate.ToString("yyyy-MM-dd");
                Te_Price.Text            = book.Price.ToString("F");
            }
            catch (Exception e)
            {
                PopupProvider.Error("获取数据信息异常!", e);
            }
        }