コード例 #1
0
        private void Save_Customer(object sender, RoutedEventArgs e)
        {
            var      customer   = Controller.controller.GetCustomer();
            var      controller = Controller.controller;
            long     telefon    = 0;
            DateTime birdth;


            var result = true;

            if (FIO.Text != "")
            {
                customer.Name = FIO.Text;
            }
            else
            {
                MessageShowUi.ShowNoneName();
                result = false;
            }

            if (long.TryParse(Telefon.Text, out telefon))
            {
                var flag = controller.Search(telefon);
                if (flag == false)
                {
                    customer.TelefonNumber = telefon;
                }
                else
                {
                    MessageShowUi.ShowPhoneIsInDatabase();
                    result = false;
                }
            }
            else
            {
                MessageShowUi.ShowNoneTelefon();
                result = false;
            }

            if (DateTime.TryParse(Birdth.Text, out birdth))
            {
                string bird = birdth.ToString("dd/MM/yyyy");
                customer.DateOfBirdh = bird;
            }
            else
            {
                MessageShowUi.ShowNoneDateOfBirdth();
                result = false;
            }

            if (result)
            {
                controller.ChangeCustomer(customer);
                Info.Visibility     = Visibility.Visible;
                SaveInfo.Visibility = Visibility.Collapsed;
                GetCustomerInfo();
            }
        }
コード例 #2
0
        /// <summary>
        /// Обработчик создания нового Покупателя.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void New_Save(object sender, RoutedEventArgs e)
        {
            var  controller = Controller.controller;
            var  name       = NameCustomer.Text;
            long telefon    = 0;

            long.TryParse(TelefonNumberCustomer.Text, out telefon);
            DateTime birdh;

            var result = true;

            if (name == "")
            {
                MessageShowUi.ShowNoneName();
            }

            if (telefon == 0)
            {
                MessageShowUi.ShowNoneTelefon();
                result = false;
            }

            if (!DateTime.TryParse(DateOfBirdhCustomer.Text, out birdh))
            {
                MessageShowUi.ShowNoneDateOfBirdth();

                result = false;
            }

            if (birdh == null)
            {
                MessageShowUi.ShowNoneDateOfBirdth();

                result = false;
            }



            if (result == true)
            {
                string bird = birdh.ToString("dd/MM/yyyy");

                var customerNew = controller.NewCustomer(name, telefon, bird);
                if (customerNew == null)
                {
                    MessageShowUi.ShowPhoneIsInDatabase();
                    return;
                }

                MessageShowUi.ShowSave();
                Close();
            }
        }