Exemplo n.º 1
0
        private async void LoadForm(string transaction, Collector collector = null)
        {
            CollectorForm form = new CollectorForm()
            {
                TransactionForm   = transaction,
                CollectorData     = (collector == null) ? new Collector() : collector,
                PrimaryButtonText = (transaction == "Add Collector") ? "Save" : "Update"
            };
            var result = await form.ShowAsync();

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

                switch (form.TransactionResult)
                {
                case 0:
                    message = (form.TransactionForm == "Add Collector") ? "Collector Inserted to the Database" : "Collector 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();
            }
        }
        private async void btnAddCollector_Click(object sender, RoutedEventArgs e)
        {
            CollectorForm form = new CollectorForm()
            {
                TransactionForm   = "Add Collector",
                IsMaintenance     = false,
                PrimaryButtonText = "Save"
            };
            var result = await form.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                var NewData = form.CollectorData;
                NewData.FullName = (NewData.FirstName + " " + NewData.LastName + " " + NewData.NameSuffix).Trim();
                NewCollector     = NewData;

                cbxCollector.Visibility       = Visibility.Collapsed;
                btnAddCollector.Visibility    = Visibility.Collapsed;
                txfCollector.Visibility       = Visibility.Visible;
                btnDeleteCollector.Visibility = Visibility.Visible;
            }
        }