コード例 #1
0
 private void btnRefundSelected_Click(object sender, EventArgs e)
 {
     if (DGVItems.SelectedCells.Count == 1)
     {
         if (Convert.ToInt32(DGVItems.CurrentRow.Cells[4].Value) > 0)
         {
             btnRefundSelected.Enabled = false;
             Basket basket = new Basket();
             basket.AddProduct(new Product(Convert.ToInt32(DGVItems.CurrentRow.Cells[0].Value), Convert.ToInt32(DGVItems.CurrentRow.Cells[4].Value), Convert.ToDecimal(DGVItems.CurrentRow.Cells[3].Value)));
             shop.RefundProduct(new Receipt(selectedReceipt.ID, shop, selectedReceipt.Client, selectedReceipt.Assistant, basket, Convert.ToDecimal(DGVItems.CurrentRow.Cells[3].Value) * Convert.ToInt32(DGVItems.CurrentRow.Cells[4].Value)));
             UpdateLastInvoices();
             selectedReceipt = shop.GetReceipt(selectedReceipt.ID);
             LoadReceipt(selectedReceipt);
             MessageBox.Show("Refund successfully completed.");
             btnRefundSelected.Enabled = true;
         }
         else
         {
             DirectMessage.ShowInfo("Refund quantity must be at least 1.");
         }
     }
     else
     {
         DirectMessage.ShowError("You have to select an item.");
     }
 }
コード例 #2
0
 private void btnRefresh_Click(object sender, EventArgs e)
 {
     UpdateLastInvoices();
     if (selectedReceipt != null)
     {
         selectedReceipt = shop.GetReceipt(selectedReceipt.ID);
         LoadReceipt(selectedReceipt);
     }
     DirectMessage.ShowInfo("Successfully updated.");
 }
コード例 #3
0
        private void btnRefundAll_Click(object sender, EventArgs e)
        {
            if (DGVItems.SelectedCells.Count == 1)
            {
                Basket basket = new Basket();
                for (int i = 0; i < DGVItems.Rows.Count; ++i)
                {
                    if (Convert.ToInt32(DGVItems.Rows[i].Cells[5].Value) > 0)
                    {
                        basket.AddProduct(new Product(Convert.ToInt32(DGVItems.Rows[i].Cells[0].Value), Convert.ToInt32(DGVItems.Rows[i].Cells[5].Value), Convert.ToDecimal(DGVItems.Rows[i].Cells[3].Value)));
                    }
                }
                if (basket.BasketProducts.Count == 0)
                {
                    DirectMessage.ShowInfo("There are no products left for refund.");
                }
                else
                {
                    string            messageBoxText = "This will refund all products in their ORIGINAL quantities from the invoice. Do you want to proceed?";
                    string            caption        = "Important";
                    MessageBoxButtons button         = MessageBoxButtons.YesNoCancel;
                    MessageBoxIcon    icon           = MessageBoxIcon.Warning;
                    DialogResult      result         = MessageBox.Show(messageBoxText, caption, button, icon);
                    switch (result)
                    {
                    case DialogResult.Yes:
                        btnRefundSelected.Enabled = false;
                        shop.RefundProduct(new Receipt(selectedReceipt.ID, shop, selectedReceipt.Client, selectedReceipt.Assistant, basket, Convert.ToDecimal(tbxNetAmount.Text)));
                        UpdateLastInvoices();
                        selectedReceipt = shop.GetReceipt(selectedReceipt.ID);
                        LoadReceipt(selectedReceipt);
                        MessageBox.Show("Refund successfully completed.");
                        btnRefundSelected.Enabled = true;
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                DirectMessage.ShowError("You have to select an invoice.");
            }
        }
コード例 #4
0
 private void btnInvoiceSearch_Click(object sender, EventArgs e)
 {
     try
     {
         Receipt r = shop.GetReceipt(Convert.ToInt32(tbxInvoiceSearch.Text));
         if (r != null)
         {
             selectedReceipt = r;
             LoadReceipt(r);
         }
         else
         {
             DirectMessage.ShowInfo("Invoice not found.");
         }
     }
     catch (FormatException)
     {
         DirectMessage.ShowError("Input is not in correct format.");
     }
 }