Esempio n. 1
0
        private void bunifuTileButton_CreateStockOrder_Click(object sender, EventArgs e)
        {
            ThreadManager.DisplayLoadingScreen();
            StockOrder newStockOrder = new StockOrder();

            try
            {
                newStockOrder.DateCreated  = Convert.ToDateTime(bunifuCustomTextbox_DateCreated.Text);
                newStockOrder.TotalPayment = double.Parse(bunifuMetroTextbox_GrandTotal.Text);
                newStockOrder.SetStockOrderDetails((List <Ingredient>)bunifuCustomTextbox__list_selectedItems.Tag);
            }
            catch (Exception ex)
            {
                ThreadManager.CloseLoadingScreen();
                ErrorManager.MessageDisplay(ex.Message, "", "Extract data failed");
                return;
            }

            string err = newStockOrder.ValidateFields();

            if (err != "")
            {
                ThreadManager.CloseLoadingScreen();
                ErrorManager.MessageDisplay(err, "", "Data format error");
                return;
            }

            err = manager.AddStockOrder(newStockOrder);
            ThreadManager.CloseLoadingScreen();
            ErrorManager.MessageDisplay(err, "Create stock order successfully", "Create stock order failed");
            if (err == "")
            {
                this.Close();
            }
        }