Exemplo n.º 1
0
        private async void LoadForm(string transaction, PlantType type = null)
        {
            PlantTypeForm form = new PlantTypeForm()
            {
                TransactionForm   = transaction,
                PlantTypeData     = (type == null) ? new PlantType() : type,
                PrimaryButtonText = (transaction == "Add Plant Type") ? "Save" : "Update"
            };
            var result = await form.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                string message = "";

                switch (form.TransactionResult)
                {
                case 0:
                    message = (form.TransactionForm == "Add Plant Type") ? "Plant Type Inserted to the Database" : "Plant Type Updated in the Database";
                    break;

                case 1:
                    message = "The System had run to an Error";
                    break;

                case 2:
                    message = "Information is Already Exists in the Database";
                    break;
                }

                MessageDialog dialog = new MessageDialog(message);
                await dialog.ShowAsync();

                this.InitializePage();
            }
        }
        // Event Methods
        private async void btnAddPlantType_Click(object sender, RoutedEventArgs e)
        {
            PlantTypeForm form = new PlantTypeForm()
            {
                TransactionForm   = "Add Plant Type",
                IsMaintenance     = false,
                PrimaryButtonText = "Save"
            };
            var result = await form.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                NewPlantType                  = form.PlantTypeData;
                cbxPlantType.Visibility       = Visibility.Collapsed;
                btnAddPlantType.Visibility    = Visibility.Collapsed;
                txfPlantType.Visibility       = Visibility.Visible;
                btnDeletePlantType.Visibility = Visibility.Visible;
            }
        }