示例#1
0
        private async Task AddNewSale()
        {
            try
            {
                if (_saleID == 0)
                {
                    if (VAlidateFields())
                    {
                        var newPOSTransaction = new SaleModel();
                        newPOSTransaction.SaleDate        = dtSalesTransactionDate.Value;
                        newPOSTransaction.Cost            = txtCost.Text;
                        newPOSTransaction.CreateTimeStamp = DateTime.Now;
                        newPOSTransaction.CustomerID      = customerID;
                        newPOSTransaction.SIDR            = txtSIDR.Text;
                        newPOSTransaction = await _saleService.AddNewAsync(newPOSTransaction);

                        _saleID = newPOSTransaction.SaleID;
                        MetroMessageBox.Show(this, "New Point of Sale Transaction has been generated!", "New Point of Sale Transaction", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    DialogResult d = MetroMessageBox.Show(this, "A Transaction is currently loaded. Do you want to reload unfinished Point of Sale Transaction?", "New Point of Sale Transaction", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (d == DialogResult.Yes)
                    {
                        await GenerateNewOrLoadUnFinishedSale();
                    }
                }
            }
            catch (CustomBaseException ex)
            {
                MetroMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }