private async Task FinePayment()
        {
            try
            {
                var borrowId = Guid.Parse(Gv_Borrows.GetFocusedRowCellValue("Id").ToString());
                var penalty  = Convert.ToDouble(Gv_Borrows.GetFocusedRowCellValue("Fine"));
                var result   = await _finePaymentApi.CreateFinePayment(new FinePayment
                {
                    BorrowId = borrowId,
                    Fine     = penalty,
                    IsPay    = true,
                    PayType  = "移动支付",
                    AdminId  = GlobalCache.Admin.Id
                });

                if (result.ResultCode != 1)
                {
                    PopupProvider.Warning(result.ResultMessage);
                    return;
                }

                PopupProvider.Success(result.ResultMessage);
            }
            catch (Exception e)
            {
                PopupProvider.Error("新增罚款登记单异常!!", e);
            }
        }
예제 #2
0
        private async void Sb_Update_Click(object sender, EventArgs e)
        {
            try
            {
                if (Gv_PublishingHouses.FocusedRowHandle < 0)
                {
                    return;
                }
                var name   = Gv_PublishingHouses.GetFocusedRowCellDisplayText("PublishingName");
                var id     = Gv_PublishingHouses.GetFocusedRowCellDisplayText("Id");
                var result = XtraInputBox.Show("请输入", "修改出版社信息", name);
                if (string.IsNullOrEmpty(result))
                {
                    return;
                }
                var resultMessage = await _propertiesApi.UpdatePublishingHouse(id, result);

                if (resultMessage.ResultCode != 1)
                {
                    PopupProvider.Warning(resultMessage.ResultMessage);
                    return;
                }

                PopupProvider.Success(resultMessage.ResultMessage);
            }
            catch (Exception exception)
            {
                PopupProvider.Error("添加异常!", exception);
            }
        }
        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_Update_Click(object sender, EventArgs e)
        {
            try
            {
                if (Gv_Categories.FocusedRowHandle < 0)
                {
                    return;
                }
                var id           = Gv_Categories.GetFocusedRowCellValue("Id").ToString();
                var categoryName = Gv_Categories.GetFocusedRowCellDisplayText("CategoryName");
                var result       = XtraInputBox.Show(this, "请输入", "修改书籍类别信息", categoryName, MessageBoxButtons.YesNo);
                if (string.IsNullOrEmpty(result))
                {
                    return;
                }
                var resultMessage = await _propertiesApi.UpdateCategory(id, result);

                if (resultMessage.ResultCode != 1)
                {
                    PopupProvider.Warning(resultMessage.ResultMessage);
                    return;
                }

                PopupProvider.Success(resultMessage.ResultMessage);
            }
            catch (Exception exception)
            {
                PopupProvider.Error("修改异常!", exception);
            }
        }
        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);
            }
        }
예제 #6
0
        private async void Sb_Empower_Click(object sender, EventArgs e)
        {
            _nodes = new List <TreeListNode>();
            RecursiveNode(Tl_Data.Nodes);
            var permissions = _nodes.Aggregate(string.Empty, (current, node) => current + $"{node["AuthorityNum"]},");
            var id          = Guid.Parse(Gv_Admins.GetFocusedRowCellValue("Id").ToString());
            var result      = await _adminApi.UpdateAdminPower(id, permissions);

            if (!result)
            {
                PopupProvider.Warning("赋权失败!");
                return;
            }

            PopupProvider.Success("赋权成功!");
        }
        private async void Sb_Shelves_Click(object sender, EventArgs e)
        {
            if (Gv_BooksInfo.FocusedRowHandle < 0 || Gv_BooksInfo.RowCount == 0)
            {
                return;
            }
            var id     = Guid.Parse(Gv_BooksInfo.GetFocusedRowCellValue("Id").ToString());
            var result = await _bookApi.CreateBook(id);

            if (result.ResultCode != 1)
            {
                PopupProvider.Warning(result.ResultMessage);
                return;
            }

            PopupProvider.Success(result.ResultMessage);
        }
        private async void Ribe_Delete_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            if (Gv_Reservations.FocusedRowHandle < 0)
            {
                return;
            }
            try
            {
                var isRemove = Convert.ToBoolean(Gv_Reservations.GetFocusedRowCellValue("IsRemove"));
                if (isRemove)
                {
                    PopupProvider.Warning("该预约记录已删除!");
                    return;
                }

                if (Convert.ToInt32(e.Button.Tag) == 1)
                {
                    return;
                }

                if (XtraMessageBox.Show("确认删除!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
                    DialogResult.Yes)
                {
                    return;
                }
                var id     = Gv_Reservations.GetFocusedRowCellDisplayText("Id");
                var result = await _reservationApi.DeleteReservation(id);

                if (result.ResultCode != 1)
                {
                    PopupProvider.Warning(result.ResultMessage);
                    return;
                }

                PopupProvider.Success(result.ResultMessage);
            }
            catch (Exception exception)
            {
                PopupProvider.Error("操作异常!", exception);
            }
        }
        private async void Rits_Toggle_Toggled(object sender, EventArgs e)
        {
            try
            {
                var id     = Guid.Parse(Gv_Categories.GetFocusedRowCellValue("Id").ToString());
                var toggle = (ToggleSwitch)sender;
                var result = await _propertiesApi.UpdateBookCategory(id, Convert.ToBoolean(toggle.EditValue));

                if (result.ResultCode != 1)
                {
                    PopupProvider.Warning(result.ResultMessage);
                    return;
                }

                PopupProvider.Success(result.ResultMessage);
            }
            catch (Exception exception)
            {
                PopupProvider.Error("修改状态异常!", exception);
            }
        }
 private async void Bbi_UpdatePassword_ItemClick(object sender, ItemClickEventArgs e)
 {
     try
     {
         var result = XtraInputBox.Show("请输入", "修改密码", "请输入新密码!");
         if (string.IsNullOrEmpty(result))
         {
             return;
         }
         var res = await new AdminApi().UpdateAdminPassword(GlobalCache.Admin.Id, result);
         if (res.ResultCode != 1)
         {
             PopupProvider.Warning(res.ResultMessage);
             return;
         }
         PopupProvider.Success(res.ResultMessage);
     }
     catch (Exception exception)
     {
         PopupProvider.Error("修改异常!", exception);
     }
 }
        private async void Sb_Add_Click(object sender, EventArgs e)
        {
            try
            {
                var result = XtraInputBox.Show(this, "请输入", "新增书籍类别信息", "", MessageBoxButtons.OK);
                if (string.IsNullOrEmpty(result))
                {
                    return;
                }
                var resultMessage = await _api.CreateBookCategory(new BookCategory { CategoryName = result });

                if (resultMessage.ResultCode != 1)
                {
                    PopupProvider.Warning(resultMessage.ResultMessage);
                    return;
                }
                PopupProvider.Success(resultMessage.ResultMessage);
            }
            catch (Exception exception)
            {
                PopupProvider.Error("新增异常!", exception);
            }
        }
예제 #12
0
        private async void Sb_Add_Click(object sender, EventArgs e)
        {
            try
            {
                var result = XtraInputBox.Show("请输入", "新增出版社信息", string.Empty);
                if (string.IsNullOrEmpty(result))
                {
                    return;
                }
                var resultMessage = await _api.CreatePublishingHouse(new PublishingHouse { PublishingName = result });

                if (resultMessage.ResultCode != 1)
                {
                    PopupProvider.Warning(resultMessage.ResultMessage);
                    return;
                }

                PopupProvider.Success(resultMessage.ResultMessage);
            }
            catch (Exception exception)
            {
                PopupProvider.Error("添加异常!", exception);
            }
        }