private void LoadReceiptsData(int statusValue)
        {
            receiptsService = Program.kernel.Get <IReceiptsService>();

            switch (statusValue)
            {
            case 0:
                receiptsList = receiptsService.GetReceiptsForAcceptance().Where(r => r.StatusId == 5).ToList();
                break;

            case 1:
                receiptsList = receiptsService.GetReceiptsForAcceptance().Where(r => r.StatusId == 6).ToList();
                break;

            case 2:
                receiptsList = receiptsService.GetReceiptsForAcceptance().ToList();
                break;

            default:
                break;
            }

            receiptsBS.DataSource   = receiptsList;
            receiptsGrid.DataSource = receiptsBS;
        }
        private void cancelAcceptanceBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            receiptAcceptancesService = Program.kernel.Get <IReceiptAcceptancesService>();
            receiptsService           = Program.kernel.Get <IReceiptsService>();
            ordersService             = Program.kernel.Get <IOrdersService>();

            if (receiptsBS.List.Count == 0)
            {
                return;
            }

            var currentReceipt = (ReceiptsForAcceptanceDTO)receiptsBS.Current;

            if ((currentReceipt.StatusId == 6) && (!receiptAcceptancesList.Any(ra => ra.StatusId > 6))) // отменить прием можно если статус Принят и нет не одной записи в receiptAcceptances со статусом Выше (хранение, частично обработан или отгружен)
            {
                if (MessageBox.Show("Отменить прием выбранной номенклатуры?", "Сохранение", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (receiptsService.GetReceiptsForAcceptance().Any(m => m.OrderId == currentReceipt.OrderId && m.StatusId == 6 && m.ReceiptId != currentReceipt.ReceiptId))
                    {
                        var orderItem = ordersService.GetOrderById(currentReceipt.OrderId);
                        orderItem.StatusId = 1;
                        ordersService.OrderUpdate(orderItem);
                    }

                    var receiptItem = receiptsService.GetReceiptById(currentReceipt.ReceiptId);
                    receiptItem.StatusId = 5;
                    receiptsService.ReceiptUpdate(receiptItem);

                    receiptAcceptancesService.UpdateRange(receiptAcceptancesList.Select(ra => { ra.StatusId = 5; return(ra); }).ToList());

                    receiptsGridView.BeginDataUpdate();

                    LoadReceiptsData((int)statusItem.EditValue);

                    receiptsGridView.EndDataUpdate();

                    int handle = receiptsGridView.LocateByValue("ReceiptId", currentReceipt.ReceiptId);
                    receiptsGridView.FocusedRowHandle = handle;
                }
            }
            else
            {
                MessageBox.Show("Нельзя отменить принятие, поскольку один или несколько комплектов находятся на хранении.", "Отменить принятие прихода", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }