コード例 #1
0
        private void btnBook_Click(object sender, EventArgs e)
        {
            switch (mode)
            {
            case MODE.StockMovement:
            {
                decimal currentStock = Convert.ToDecimal(lblCurrentStock.Text);
                int     costplaceId  = Convert.ToInt32(ddlCostPlace.SelectedValue);
                decimal quantity     = Convert.ToDecimal(txtAmount.Text);
                service.BookStockMovement(lblNo.Text, lblDescription.Text, currentStock, costplaceId, quantity, lblAmountUOM.Text, ParentForm.CurrentUser);

                MessageBox.Show("Stockbeweging geboekt", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                ClearAllValues();

                break;
            }

            case MODE.StockCount:
            {
                decimal currentStock = Convert.ToDecimal(lblCurrentStock.Text);
                decimal newStock     = Convert.ToDecimal(txtNewStock.Text);

                if (newStock != currentStock)
                {
                    var result = MessageBox.Show("Bent u zeker?", "Bevestiging", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                    if (result == DialogResult.Yes)
                    {
                        service.BookStockCount(lblNo.Text, lblDescription.Text, currentStock, newStock, lblNewStockUOM.Text, ParentForm.CurrentUser);

                        MessageBox.Show("Stocktelling geboekt", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                        ClearAllValues();
                    }
                    else if (result == DialogResult.No)
                    {
                        MessageBox.Show("Stocktelling niet geboekt", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                    }
                }
                else
                {
                    service.BookStockCount(lblNo.Text, lblDescription.Text, currentStock, newStock, lblNewStockUOM.Text, ParentForm.CurrentUser);

                    MessageBox.Show("Stocktelling geboekt", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                    ClearAllValues();
                }

                break;
            }
            }
        }