Exemplo n.º 1
0
        private void submitButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (_saleList.Count == 0)
                {
                    MessageBox.Show("Please Add Item First...!!", "Warning", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }

                if (_saleManager.AddSale(_saleList))
                {
                    MessageBox.Show("Successfully sold..!", "Sale", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    _saleList.Clear();
                    customerComboBox.SelectedValue = 0;
                    Reset();
                }
                else
                {
                    MessageBox.Show("Failed..!", "Sale", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Exemplo n.º 2
0
 private void submitButton_Click(object sender, EventArgs e)
 {
     if (_saleManager.AddSale(_saleList))
     {
         MessageBox.Show("Successfully sold..!", "Sale", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Failed..!", "Sale", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 3
0
    private void CalculatePrice(Product product)
    {
        float amountToPrice = Random.Range(7, 10);

        for (int i = 0; i < amountToPrice - 1; i++)
        {
            float packWeight = ChooseRandomPackWeight();
            float packPrice  = packWeight * product.sellPrice;
            saleManager.AddSale(packPrice);
            Debug.Log("Pack Price: " + packPrice);
        }
    }
Exemplo n.º 4
0
        private async void AddSale()
        {
            int insertedSaleID   = 0;
            var insertSaleResult = await _saleManager.AddSale(new Sale()
            {
                AmountPaid    = Convert.ToDouble(textBox1.Text),
                Change        = Convert.ToDouble(Convert.ToDecimal(textBox1.Text) - Total),
                DateCreated   = DateTime.Now,
                DateTime      = DateTime.Now,
                IsDeleted     = false,
                StoreID       = Global.Store.StoreID,
                Total         = Convert.ToDecimal(Total),
                UserCreatedID = Global.User.UserID,
                UserID        = Global.User.UserID
            });

            insertedSaleID = insertSaleResult.ID;

            if (insertSaleResult.IsSuccess)
            {
                SaleProducts = SaleProducts.Select(m =>
                {
                    m.SaleID = insertSaleResult.ID;
                    return(m);
                }).ToList();

                foreach (var saleProduct in SaleProducts)
                {
                    insertSaleResult = await _saleManager.AddSaleProduct(saleProduct);
                }
            }

            if (insertSaleResult.IsSuccess)
            {
                //bawasan quantity sa store
                await _storeManager.DecreaseProductLeft(Global.Store.StoreID, SaleProducts);

                Close();
                TransactionDone = true;
            }
            else
            {
                //delete sale by id
                //delete saleproduct by saleid
                await _saleManager.DeleteSale(insertedSaleID);

                await _saleManager.DeleteSaleProductBySaleID(insertedSaleID);

                MessageBox.Show("An error occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }