Пример #1
0
 private async Task AddProductOnTransaction()
 {
     try
     {
         if (_saleID > 0)
         {
             //get the product id according to its name
             var productID = _productService.GetProductID(txtProductName.Text);
             var transactionProductModel = new SaleProductModel();
             transactionProductModel.ProductID       = productID;
             transactionProductModel.IsPaid          = false;
             transactionProductModel.IsToPay         = true;
             transactionProductModel.SaleID          = _saleID;
             transactionProductModel.Quantity        = 1;
             transactionProductModel.UpdateTimeStamp = DateTime.Now;
             await _transactionProductService.AddNewTransactionProductAsync(transactionProductModel);
             await LoadProductsOnTransaction();
             await SetTransactionData();
         }
         else
         {
             MetroMessageBox.Show(this, "No Point of Sale Transaction Found!", "Product", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (RecordNotFoundException ex)
     {
         MetroMessageBox.Show(this, string.Format("{0} for {1}", ex.Message, txtProductName.Text), "Product", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (LimitMustNotReachException ex)
     {
         MetroMessageBox.Show(this, ex.Message);
     }
     catch (Exception ex)
     {
         MetroMessageBox.Show(this, ex.ToString());
     }
 }
Пример #2
0
        private async void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtProductName.Text == "" || productID == 0)
                {
                    MetroMessageBox.Show(this, "Product is required!", "Quantity Edit", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtProductName.WithError = true;
                    return;
                }
                if (txtQuantity.Text == "" || txtQuantity.Text == "0")
                {
                    MetroMessageBox.Show(this, "Quantity is required!", "Quantity Edit", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtQuantity.WithError = true;
                    return;
                }
                var transactionProduct = new SaleProductModel();
                transactionProduct.IsPaid          = false;
                transactionProduct.IsToPay         = true;
                transactionProduct.SaleID          = _posTransactionID;
                transactionProduct.ProductID       = productID;
                transactionProduct.Quantity        = txtQuantity.Text.ToDecimal();
                transactionProduct.UpdateTimeStamp = DateTime.Now;
                await _transactionProductService.AddNewTransactionProductAsync(transactionProduct);

                this.Close();
            }
            catch (LimitMustNotReachException ex)
            {
                MetroMessageBox.Show(this, ex.Message);
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, ex.ToString());
            }
        }