public SaleOrder GetOrder(int id)
 {
     return(soService.GetSaleOrder(id));
 }
Exemplo n.º 2
0
        private void BtnDeliverClick(object sender, EventArgs e)
        {
            try
            {
                if (_depositList == null)
                {
                    return;
                }

                if (_depositList.Count == 0)
                {
                    return;
                }

                if (dgvDeposit.CurrentRow == null)
                {
                    return;
                }

                _deposit = _depositList[dgvDeposit.CurrentRow.Index];
                if (_deposit == null)
                {
                    return;
                }

                var briefMsg  = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                var detailMsg = Resources.MsgUserPermissionDeny;
                if (!UserService.AllowToPerform(Resources.PermissionEditDeposit))
                {
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                var saleOrder = _saleOrderService.GetSaleOrder(_deposit);
                if (saleOrder == null)
                {
                    return;
                }

                briefMsg  = "អំពីការប្រគល់របស់";
                detailMsg = Resources.MsgConfirmDeliverProduct;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr  = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }
                }

                _depositItemList = _depositService.GetDepositItems(_deposit.DepositId);
                var saleItemList = _saleOrderService.GetSaleItems(_depositItemList);

                _saleOrderService.RecordSaleOrder(
                    saleItemList,
                    saleOrder.AmountSoldInt,
                    saleOrder.AmountSoldInt - saleOrder.AmountPaidInt,
                    0,
                    0,
                    saleOrder.FkCustomer,
                    false,
                    _deposit.DepositNumber,
                    saleOrder.Discount,
                    _deposit.AmountPaidInt,
                    true);

                _deposit.AmountPaidInt   += (_deposit.AmountSoldInt - _deposit.AmountPaidInt);
                _deposit.AmountReturnInt  = 0f;
                _deposit.AmountReturnRiel = 0f;
                _deposit.UpdateDate       = DateTime.Now;
                _depositService.UpdateDeposit(_deposit);

                var paymentService = ServiceFactory.GenerateServiceInstance().GeneratePaymentService();
                var payment        =
                    new Model.Payments.Payment
                {
                    PaymentDate   = _deposit.DepositDate,
                    PaymentAmount = _deposit.AmountPaidInt,
                    SalesOrderId  = _deposit.DepositId,
                    CashierId     = _deposit.CashierId
                };
                paymentService.ManagePayment(Resources.OperationRequestInsert, payment);

                RetrieveDataHandler();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(Resources.MsgCaptionUnknownError, exception.Message);
            }
        }