Exemplo n.º 1
0
        private async void UpdateBarBtn_Click(object sender, RoutedEventArgs e)
        {
            Contact c = new Contact();

            //validate FirstName is empty
            if (String.IsNullOrEmpty(ConFNameTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Name in field", "Wrong Name");
                await md.ShowAsync();

                ConFNameTxtBox.Focus(FocusState.Programmatic);
                ConFNameTxtBox.SelectAll();
                return;
            }
            else
            {
                c.FirstName = ConFNameTxtBox.Text;
            }

            //validate LastName is empty
            if (String.IsNullOrEmpty(ConLNameTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Name in field", "Wrong Name");
                await md.ShowAsync();

                ConLNameTxtBox.Focus(FocusState.Programmatic);
                ConLNameTxtBox.SelectAll();
                return;
            }
            else
            {
                c.LastName = ConLNameTxtBox.Text;
            }

            //validate CompanyName is empty
            if (String.IsNullOrEmpty(ConCompNameTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Name in field", "Wrong Company Name");
                await md.ShowAsync();

                ConCompNameTxtBox.Focus(FocusState.Programmatic);
                ConCompNameTxtBox.SelectAll();
                return;
            }
            else
            {
                c.CompanyName = ConCompNameTxtBox.Text;
            }

            //validate Mobile number is empty
            if (String.IsNullOrEmpty(MobNoTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Mobile Number in field", "Wrong Mobile Number");
                await md.ShowAsync();

                MobNoTxtBox.Focus(FocusState.Programmatic);
                MobNoTxtBox.SelectAll();
                return;
            }
            else
            {
                c.MobilePhone = MobNoTxtBox.Text;
            }


            //show update is successed
            if (viewModel.SaveEditedProduct(viewModel.Contact))
            {
                MessageDialog md = new MessageDialog("Contact changes updated", "UPDATE OUTCOME");
                await md.ShowAsync();
            }
            else
            {
                MessageDialog md = new MessageDialog("Contact changes NOT updated", "UPDATE OUTCOME");
                await md.ShowAsync();
            }

            Frame.Navigate(typeof(ContactViewPage), viewModel.Contact.ContactID);
        }
Exemplo n.º 2
0
        private async void SubmitBarBtn_Click(object sender, RoutedEventArgs e)
        {
            Contact c = new Contact();

            //validate FirstName is empty
            if (String.IsNullOrEmpty(ConFNameTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Name in field", "Wrong Name");
                await md.ShowAsync();

                ConFNameTxtBox.Focus(FocusState.Programmatic);
                ConFNameTxtBox.SelectAll();
                return;
            }
            else
            {
                c.FirstName = ConFNameTxtBox.Text;
            }

            //validate LastName is empty
            if (String.IsNullOrEmpty(ConLNameTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Name in field", "Wrong Name");
                await md.ShowAsync();

                ConLNameTxtBox.Focus(FocusState.Programmatic);
                ConLNameTxtBox.SelectAll();
                return;
            }
            else
            {
                c.LastName = ConLNameTxtBox.Text;
            }

            //validate CompanyName is empty
            if (String.IsNullOrEmpty(ConCompNameTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Name in field", "Wrong Company Name");
                await md.ShowAsync();

                ConCompNameTxtBox.Focus(FocusState.Programmatic);
                ConCompNameTxtBox.SelectAll();
                return;
            }
            else
            {
                c.CompanyName = ConCompNameTxtBox.Text;
            }

            //validate Mobile number is empty
            if (String.IsNullOrEmpty(MobNoTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Mobile Number in field", "Wrong Mobile Number");
                await md.ShowAsync();

                MobNoTxtBox.Focus(FocusState.Programmatic);
                MobNoTxtBox.SelectAll();
                return;
            }
            else
            {
                c.MobilePhone = MobNoTxtBox.Text;
            }

            viewModel.AddNewContact(c);


            Frame.Navigate(typeof(ContactPage));
        }