Esempio n. 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);
            }
        }
Esempio n. 2
0
        private void CancelSale()
        {
            _saleOrder = null;
            _saleItemBindingList.Clear();
            _returnEnabled = false;

            ResetProductInfo();
            ResetCustomerInfo();
            DoActivateControls(true);
            ScanFocusHandler();
        }
Esempio n. 3
0
        private void BtnSearchSaleOrderClick(object sender, EventArgs e)
        {
            ScanFocusHandler();
            try
            {
                if (!_returnEnabled)
                {
                    Visible = false;
                    using (var frmSaleSearch = new FrmSaleSearch())
                    {
                        if (frmSaleSearch.ShowDialog(this) == DialogResult.OK)
                        {
                            var saleOrderNumber = frmSaleSearch.SearchSoNumber;
                            var indexOf = saleOrderNumber.IndexOf(" (");
                            if(indexOf > 0)
                                saleOrderNumber = StringHelper.Left(saleOrderNumber, indexOf);

                            var searchCriteria = new List<string> { "SaleOrderNumber|" + saleOrderNumber };
                            var saleOrderList = _saleOrderService.GetSaleOrders(searchCriteria);
                            if (saleOrderList.Count == 0)
                            {
                                Visible = true;
                                return;
                            }

                            _saleOrder = (SaleOrder)saleOrderList[0];
                            if (_saleOrder == null)
                            {
                                Visible = true;
                                return;
                            }

                            dgvSaleItem.SelectionChanged += DgvSaleItemSelectionChanged;
                            IListToBindingList(
                                _saleOrderService.GetSaleItems(_saleOrder.SaleOrderId));
                            _saleOrder.FkCustomer.DiscountPercentage = _saleOrder.Discount;
                            SetCustomerInfo(_saleOrder.FkCustomer);
                            CalculateSale();
                            SetInvoiceInfo(
                                _saleOrder.SaleOrderNumber,
                                _saleOrder.AmountSoldInt,
                                _saleOrder.AmountPaidInt,
                                _saleOrder.AmountPaidRiel,
                                _saleOrder.AmountReturnInt);

                            ////If invoice has already been voided
                            //searchCriteria = new List<string> {"ReferenceNum|" + _saleOrder.SaleOrderNumber};
                            //saleOrderList = _saleOrderService.GetSaleOrders(searchCriteria);

                            //if (saleOrderList.Count != 0)
                            //{
                            //    _returnEnabled = false;
                            //    SaleItemBindingListChanged(null, null);
                            //}
                            //else
                            //{
                                DoActivateControls(false);
                                ReturnHandler(_returnEnabled = true);
                            //}
                        }
                        Visible = true;
                    }
                }
                else
                {
                    string briefMsg, detailMsg;
                    if (!UserService.AllowToPerform(Resources.PermissionReturnProduct))
                    {
                        briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                        detailMsg = Resources.MsgUserPermissionDeny;
                        using (var frmMessageBox = new FrmExtendedMessageBox())
                        {
                            frmMessageBox.BriefMsgStr = briefMsg;
                            frmMessageBox.DetailMsgStr = detailMsg;
                            frmMessageBox.IsCanceledOnly = true;
                            frmMessageBox.ShowDialog(this);
                            return;
                        }
                    }

                    if (_saleOrder == null)
                        return;

                    if (_saleItemBindingList.Count == 0)
                        return;

                    briefMsg = "អំពីការសង";
                    detailMsg = "សូម​មេត្តា​ចុច​លើ​ប៊ូតុង យល់​ព្រម ដើម្បី​បញ្ជាក់​ពី​ការ​ប្រគល់​សង​។";
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr = briefMsg;
                        frmMessageBox.DetailMsgStr = detailMsg;
                        if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                            return;
                    }

                    _saleOrder = _saleOrderService.RecordSaleOrder(
                        _saleItemBindingList,
                        _totalAmountInt,
                        _totalAmountInt,
                        _totalAmountInt * AppContext.ExchangeRate.ExchangeValue,
                        0,
                        _saleOrder.FkCustomer,
                        true,
                        _saleOrder.SaleOrderNumber,
                        _saleOrder.Discount,
                        0,
                        false);

                    ReturnHandler(_returnEnabled = false);
                    SetInvoiceInfo(
                        _saleOrder.SaleOrderNumber,
                        _saleOrder.AmountSoldInt,
                        _saleOrder.AmountPaidInt,
                        _saleOrder.AmountPaidRiel,
                        _saleOrder.AmountReturnInt);

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