Пример #1
0
        private void BtnValidClick(object sender, EventArgs e)
        {
            ScanFocusHandler();
            if (_saleItemBindingList.Count == 0)
                return;

            try
            {
                if ((_returnEnabled) || (btnValid.Text.Equals(Resources.ConstSalePrint)))
                {
                    InvoicePrinting(
                        _saleOrder.FkCustomer,
                        _saleOrder.SaleOrderNumber,
                        (DateTime)_saleOrder.SaleOrderDate,
                        _saleOrder.Discount,
                        0,
                        _saleOrder.AmountPaidInt,
                        _saleOrder.AmountReturnInt,
                        false);
                }
                else
                {
                    Visible = false;
                    using (var frmPayment = new FrmPayment())
                    {
                        frmPayment.CommonService = _commonService;
                        frmPayment.CustomerService = _customerService;
                        frmPayment.TotalAmountInt = _totalAmountInt;
                        if (frmPayment.ShowDialog(this) == DialogResult.OK)
                        {
                            Visible = true;
                            var discountPercentage = frmPayment.Customer.FkDiscountCard.DiscountPercentage;
                            _saleOrder = _saleOrderService.RecordSaleOrder(
                                _saleItemBindingList,
                                _totalAmountInt,
                                frmPayment.AmountPaidInt,
                                frmPayment.AmountPaidRiel,
                                frmPayment.AmountPaidInt - (_totalAmountInt - ((_totalAmountInt * discountPercentage) / 100)),
                                frmPayment.Customer,
                                false,
                                string.Empty,
                                frmPayment.Customer.FkDiscountCard.DiscountPercentage,
                                0,
                                false);

                            if (_saleOrder == null)
                                return;

                            DoActivateControls(false);
                            SetCustomerInfo(frmPayment.Customer);
                            SetInvoiceInfo(
                                _saleOrder.SaleOrderNumber,
                                _saleOrder.AmountSoldInt,
                                _saleOrder.AmountPaidInt,
                                _saleOrder.AmountPaidRiel,
                                _saleOrder.AmountReturnInt);
                            InvoicePrinting(
                                _saleOrder.FkCustomer,
                                _saleOrder.SaleOrderNumber,
                                (DateTime)_saleOrder.SaleOrderDate,
                                _saleOrder.Discount,
                                0,
                                _saleOrder.AmountPaidInt,
                                _saleOrder.AmountReturnInt,
                                false);

                            LocalStockHandler();

                            var frmThank = new FrmThank();
                            frmThank.ShowDialog(this);
                        }
                        Visible = true;
                    }
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Пример #2
0
        private void BtnDepositClick(object sender, EventArgs e)
        {
            if (!UserService.AllowToPerform(Resources.PermissionAddDeposit))
            {
                const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                var detailMsg = Resources.MsgUserPermissionDeny;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }
            }

            ScanFocusHandler();

            if (_saleItemBindingList.Count == 0)
                return;

            Visible = false;
            try
            {
                using (var frmPayment = new FrmPayment())
                {
                    frmPayment.CommonService = _commonService;
                    frmPayment.CustomerService = _customerService;
                    frmPayment.TotalAmountInt = _totalAmountInt;
                    frmPayment.IsDeposit = true;
                    if (frmPayment.ShowDialog(this) == DialogResult.OK)
                    {
                        Visible = true;
                        var depositItemList = _depositService.GetDepositItems(_saleItemBindingList);

                        _deposit = _depositService.RecordDeposit(
                            depositItemList,
                            _totalAmountInt,
                            frmPayment.AmountPaidInt,
                            frmPayment.AmountPaidRiel,
                            frmPayment.Customer,
                            string.Empty,
                            frmPayment.Customer.FkDiscountCard.DiscountPercentage,
                            false);

                        if (_deposit == null)
                            return;

                        DoActivateControls(false);
                        SetCustomerInfo(frmPayment.Customer);
                        SetInvoiceInfo(
                            _deposit.DepositNumber,
                            _deposit.AmountSoldInt,
                            _deposit.AmountPaidInt,
                            _deposit.AmountPaidRiel,
                            _deposit.AmountReturnInt);
                        InvoicePrinting(
                            _deposit.FkCustomer,
                            _deposit.DepositNumber,
                            (DateTime)_deposit.DepositDate,
                            _deposit.Discount,
                            _deposit.AmountPaidInt,
                            0,
                            0,
                            true);

                        LocalStockHandler();

                        var frmThank = new FrmThank();
                        frmThank.ShowDialog(this);
                    }
                    Visible = true;
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }