Ejemplo n.º 1
0
        /// <summary>
        /// Обработчик создания нового визита.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void New_SaveVisit(object sender, RoutedEventArgs e)
        {
            var controlCustomer = Controller.controller;


            var  result       = true;
            var  searchResult = false;
            long search       = 0;

            long.TryParse(Telefon.Text, out search);
            double visitSale = 0;

            double.TryParse(VisitSale.Text, out visitSale);
            int drink = 0;

            int.TryParse(NumberOfDrunk.Text, out drink);
            if (search != 0)
            {
                searchResult = controlCustomer.SearchCustomer(search);
            }
            else
            {
                result = false;
            }

            if (visitSale == 0)
            {
                MessageShowUi.ShowSaleVisit();

                result = false;
            }

            if (result)
            {
                if (searchResult == true)
                {
                    var customer       = controlCustomer.GetCustomer();
                    var visit          = controlCustomer.NewVisit(customer, visitSale, drink);
                    var customerChange = controlCustomer.GetCustomer();


                    if (visit == true)
                    {
                        MessageShowUi.ShowSave();
                        Telefon.Text       = "";
                        VisitSale.Text     = "";
                        NumberOfDrunk.Text = "";
                    }
                    Close();
                }
                else
                {
                    MessageShowUi.ShowNoneCustomer();
                }
            }
        }
Ejemplo n.º 2
0
        private void Delete_Customer(object sender, RoutedEventArgs e)
        {
            var controller = Controller.controller;

            var customer = controller.GetCustomer();

            controller.DeleteCustomer(customer);
            MessageShowUi.ShowSave();
            Close();
        }
Ejemplo n.º 3
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();
            }
        }