Ejemplo n.º 1
0
        private void ValidateQuantity(int Id)
        {
            try
            {
                if (customerTxt.Text.Length < 3)
                {
                    MessageBox.Show("Customer's name should consist of at least 3 letters");
                    return;
                }
                var quantity = int.Parse(quantityTxt.Text);

                var dbQuantity = ProductDal.DbQuantity(Id);

                if (quantity > dbQuantity)
                {
                    MessageBox.Show($"Sorry. But there exists only {dbQuantity} Quantity of the selected Product.");
                    return;
                }

                if (dbQuantity < 5)
                {
                    var dialogResult = MessageBox.Show("Only limited stock remaining. Plear Re-Order this product", "Limited Stock!", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        var rol = new ReOrder();
                        rol.Show();
                        Hide();
                    }
                    else
                    {
                        return;
                    }
                    return;
                }

                else
                {
                    var newQuantity = dbQuantity - quantity;

                    ProductDal.UpdateExportRecord(Id, newQuantity);

                    var product = ProductDal.GetProduct(Id);
                    product.Quantity = quantity; //Override

                    ProductDal.UpdateRecentTransaction("Export", product);

                    MessageBox.Show("Succesfully recorded the export transaction with 15% Profit.");
                    this.Close();

                    BaseDAL.showDashboard();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Quantity's " + e.Message);
            }
        }
Ejemplo n.º 2
0
        private void btnOrder_Click(object sender, EventArgs e)
        {
            var productId = (int)comboBoxProduct.SelectedValue;
            var quantity  = Int32.Parse(txtQuantity.Text);

            var previousQuantity = ProductDal.DbQuantity(productId);
            var newQuantity      = previousQuantity + quantity;

            //MessageBox.Show($"qty:{quantity} prev:{previousQuantity} new:{newQuantity}");

            ProductDal.ReOrderTransaction(productId, newQuantity);

            var product = ProductDal.GetProduct(productId);

            product.Quantity = quantity;
            ProductDal.UpdateRecentTransaction("Re-Order", product);

            MessageBox.Show("Succesfully Ordered!");
            Hide();
            BaseDAL.showDashboard();
        }