예제 #1
0
        private void Discount_Change(object sender, RoutedEventArgs e)
        {
            int glasses    = 0;
            var result     = true;
            var controller = Controller.controller;

            if (!int.TryParse(Glasses.Text, out glasses))
            {
                MessageShowUi.ShowNonePole();
                result = false;
            }

            if (result)
            {
                controller.SetDiscountChange(glasses);


                Info.Visibility     = Visibility.Visible;
                SaveInfo.Visibility = Visibility.Collapsed;

                Change.Visibility         = Visibility.Visible;
                DiscountChange.Visibility = Visibility.Visible;


                GetCustomerInfo();
            }
        }
예제 #2
0
        private void Search_Info(object sender, RoutedEventArgs e)
        {
            CanvasGrid.Visibility = Visibility.Collapsed;
            CanvasGrid.Visibility = Visibility.Collapsed;
            var textSearch = SearchText.Text;
            var result     = true;

            if (textSearch == null)
            {
                SearchInfoCustomer.Visibility = Visibility.Collapsed;
                MessageShowUi.ShowNoneSearch();
                result          = false;
                SearchText.Text = "";
            }

            if (result)
            {
                var  controller = Controller.controller;
                long telefon    = 0;
                long.TryParse(textSearch, out telefon);

                if (controller.SearchCustomer(telefon))
                {
                    GetCustomerInfo();
                    SearchText.Text = "";
                }
                else
                {
                    SearchInfoCustomer.Visibility = Visibility.Collapsed;
                    MessageShowUi.ShowNoneCustomer();
                }
            }
        }
예제 #3
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();
            }
        }
예제 #4
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();
                }
            }
        }
예제 #5
0
        private void Delete_Customer(object sender, RoutedEventArgs e)
        {
            var controller = Controller.controller;

            var customer = controller.GetCustomer();

            controller.DeleteCustomer(customer);
            MessageShowUi.ShowSave();
            Close();
        }
예제 #6
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();
            }
        }
예제 #7
0
        private void Close_Kart(object sender, RoutedEventArgs e)
        {
            var controller = Controller.controller;
            var val        = controller.SetDiscount(1);

            if (val)
            {
                MessageShowUi.ShowKart();
            }

            GetCustomerInfo();
        }
예제 #8
0
        private void InputNew(object sender, RoutedEventArgs e)
        {
            var controller = new ControllerUser();
            var result     = false;

            var login = controller.SearchUser(UserLogin.Text);

            if (login)
            {
                var password = controller.PasswordControl(PassUser.Text);
                if (!password)
                {
                    MessageShowUi.PassFalse();
                    _flag++;
                    //var main = new MainWindow();
                    //Close();
                }
                else
                {
                    result = true;
                }
            }
            else
            {
                MessageShowUi.UserNone();
                _flag++;
            }

            if (result)
            {
                var main = new MainWindow();
                Close();
            }

            if (_flag >= 6)
            {
                System.Environment.Exit(0);
            }


            //System.Environment.Exit(0);
        }