Example #1
0
 public MainWindow()
 {
     InitializeComponent();
     AdditionalInitializeComponent();
     VisualInitializeComponent();
     PageSwitcher.Switch(new StartPage()); // Страница по умолчанию
 }
Example #2
0
        public void ClickLoginButton(object sender, RoutedEventArgs e)
        {
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = ConfigurationManager.ConnectionStrings["DataBaseProject.Properties.Settings.NTUT_DataBaseConnectionString"].ConnectionString;
            connection.Open();
            SqlDataAdapter adapter = new SqlDataAdapter("SELECT	[Account], [IsAdmin] FROM [dbo].[Member] WHERE Account='" + _loginPanel.Account + "' and Password='******'", connection);
            DataSet        dataSet = new DataSet();

            adapter.Fill(dataSet);
            if (dataSet.Tables[0].Rows.Count > 0)
            {
                _loginPanel.NoticeMessage = "";
                PageSwitcher._account     = _loginPanel.Account;
                if (Convert.ToBoolean(dataSet.Tables[0].Rows[0].ItemArray[1]))
                {
                    PageSwitcher.Switch(new ManagerHomeForm());
                }
                else
                {
                    PageSwitcher.Switch(new DrinkInformationForm());
                }
            }
            else
            {
                _loginPanel.NoticeMessage = "帳號密碼錯誤,請重新輸入";
            }
            connection.Close();
        }
Example #3
0
        private void OnDrinkLogoItemMouseUp(object sender, MouseButtonEventArgs e)
        {
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = ConfigurationManager.ConnectionStrings["DataBaseProject.Properties.Settings.NTUT_DataBaseConnectionString"].ConnectionString;
            connection.Open();
            SqlCommand command1 = new SqlCommand("SELECT count(*) FROM [dbo].[Member] inner join [dbo].[OrderRecord] ON [dbo].[Member].Account=[dbo].[OrderRecord].FKAccount WHERE Account='" + PageSwitcher._account + "' and ConfirmState='false'", connection);

            if (Convert.ToBoolean(command1.ExecuteScalar()))
            {
                SqlCommand command2 = new SqlCommand("SELECT count(*) FROM [dbo].[Member] inner join [dbo].[OrderRecord] ON Account=FKAccount inner join [dbo].[Has] ON Oid=FKOid inner join [dbo].[Drink] ON FKName=ENName WHERE Account='" + PageSwitcher._account + "' and ConfirmState='false' and ENName='" + _drinkName.Substring(1, _drinkName.Length - 1) + "'", connection);
                if (!Convert.ToBoolean(command2.ExecuteScalar()))
                {
                    SqlCommand command3 = new SqlCommand("INSERT INTO [dbo].[Has] ([FKName],[FKOid],[Quantity],[MakeState]) VALUES (('" + _drinkName.Substring(1, _drinkName.Length - 1) + "'), (SELECT [Oid] FROM [dbo].[Member] inner join [dbo].[OrderRecord] ON Account=FKAccount WHERE ConfirmState='false' and Account='" + PageSwitcher._account + "' ),('1'),('false'))", connection);
                    command3.ExecuteScalar();
                }
            }
            else
            {
                SqlCommand command4 = new SqlCommand("INSERT INTO [dbo].[OrderRecord] ([Oid],[ConfirmState],[ConfirmDate],[DeliveryState],[PS],[FKAccount]) VALUES (NEWID(),'false',NULL,'false','','" + PageSwitcher._account + "')", connection);
                command4.ExecuteScalar();
                SqlCommand command5 = new SqlCommand("INSERT INTO [dbo].[Has] ([FKName],[FKOid],[Quantity],[MakeState]) VALUES (('" + _drinkName.Substring(1, _drinkName.Length - 1) + "'), (SELECT [Oid] FROM [dbo].[Member] inner join [dbo].[OrderRecord] ON Account=FKAccount WHERE ConfirmState='false' and Account='" + PageSwitcher._account + "' ),('1'),('false'))", connection);
                command5.ExecuteScalar();
            }
            connection.Close();
            PageSwitcher.Switch(new ShopCarForm());
        }
Example #4
0
        private void MouseUpRefreshButton(object sender, MouseButtonEventArgs e)
        {
            TextBlock block = sender as TextBlock;

            block.Foreground = Brushes.White;
            block.Background = Brushes.Black;
            PageSwitcher.Switch(new OrderListForm());
        }
Example #5
0
        /// <summary>
        /// Валидация, сохранение и выход к списку сущностей
        /// </summary>
        private void SaveAndExit()
        {
            // Получение значений и подписей полей
            var name           = NameTextBox.Text.Trim();
            var shortName      = ShortNameTextBox.Text.Trim();
            var fieldShortName = ShortNameLabel.Content.ToString();
            var fieldName      = NameLabel.Content.ToString();
            var idMeasure      = IdTextBox.Value;

            // Валидация полей
            var isValidFields = IsValidFieldsWithShowMessageOtherwise();

            if (!isValidFields)
            {
                return;
            }
            // Если краткое название ед. изм. содержит некиррилические символы - получение подтверждение пользователя
            if (!Validator.IsCyrillicWithUserConfirmOtherwise(shortName, fieldShortName))
            {
                return;
            }

            // Если название ед. изм. содержит некиррилические символы - получение подтверждение пользователя
            if (!Validator.IsCyrillicWithUserConfirmOtherwise(name, fieldName))
            {
                return;
            }

            // Проверка на дубликат
            foreach (var measure in _measuresList)
            {
                if (measure.OldDbCode == idMeasure)
                {
                    const string message = "Такой код уже имеется!";
                    const string header  = "Ошибка валидации";
                    MessageBox.Show(message, header, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }

            try
            {
                // Такое не произайдет из за валидации, но анализатор Resharper ругается
                if (idMeasure == null)
                {
                    return;
                }

                MeasuresService.Insert((long)idMeasure, shortName, name);
            }
            catch (StorageException ex)
            {
                Common.ShowDetailExceptionMessage(ex);
            }

            PageSwitcher.Switch(new MeasuresTable());
        }
 /// <summary>
 /// Обработка нажатия клавиш в фокусе всей страницы
 /// </summary>
 /// <inheritdoc />
 public void Page_OnKeyDown(object senderIsPageOrWindow, KeyEventArgs eventArgs)
 {
     if (eventArgs.Key != Key.Escape)
     {
         return;
     }
     // Если нажат [Esc] - выходим к списку доверенностей
     eventArgs.Handled = true;
     PageSwitcher.Switch(new StartPage());
 }
Example #7
0
        /// <summary>
        /// Проверка, изменились ли поля ввода, и запрос подтверждения, если изменились. Далее выход к списку сущностей
        /// </summary>
        private void ConfirmExitIfDataHasBeenChanged()
        {
            var isFieldsNotChanged = _editedKart == null;

            // Если введённые поля изменились - запрос у пользователя подтверждения намерение выхода к списку сущностей
            if (!isFieldsNotChanged && !PageUtil.ConfirmBackToListWhenFieldChanged())
            {
                return;
            }
            PageSwitcher.Switch(new StartPage());
        }
Example #8
0
        /// <summary>
        /// Проверка, изменились ли поля ввода, и запрос подтверждения, если изменились. Далее выход к списку сущностей
        /// </summary>
        private void ConfirmExitIfDataHasBeenChanged()
        {
            var isFieldsNotChanged = true;

            isFieldsNotChanged &= string.IsNullOrWhiteSpace(ShortNameTextBox.Text);
            isFieldsNotChanged &= string.IsNullOrWhiteSpace(NameTextBox.Text);
            isFieldsNotChanged &= string.IsNullOrWhiteSpace(IdTextBox.Text);

            // Если введённые поля изменились - запрос у пользователя подтверждения намерение выхода к списку сущностей
            if (!isFieldsNotChanged && !PageUtil.ConfirmBackToListWhenFieldChanged())
            {
                return;
            }
            PageSwitcher.Switch(new MeasuresTable());
        }
 private void ClickBackButton(object sender, RoutedEventArgs e)
 {
     if (_tempGrid == null)
     {
         PageSwitcher.Switch(new DrinkInformationForm());
     }
     else
     {
         _secondGrid.Children.Remove(_panel);
         _thirdGrid.Children.Remove(_imagePanel);
         _fourGrid.Children.Remove(_pricePanel);
         _imagePanel = null;
         _panel      = null;
         ArrangeItems(_tempGrid);
         _tempGrid  = null;
         _canScroll = true;
     }
 }
Example #10
0
        private void MouseUpCheckButton(object sender, MouseButtonEventArgs e)
        {
            TextBlock block = sender as TextBlock;

            block.Foreground = Brushes.White;
            block.Background = Brushes.Black;

            int total = 0;

            if (_psTextBox.Text.Length > 200)
            {
                MessageBox.Show("飲品需求及意見長度不可超過200");
            }
            else if (SumUp(ref total))
            {
                MessageBox.Show("數量輸入錯誤");
            }
            else if (_quantityStackPanel.Children.Count == 0)
            {
                MessageBox.Show("請先選擇欲購買之飲料");
            }
            else if (total == 0)
            {
                MessageBox.Show("數量不可為零");
            }
            else
            {
                SqlConnection connection = new SqlConnection();
                connection.ConnectionString = ConfigurationManager.ConnectionStrings["DataBaseProject.Properties.Settings.NTUT_DataBaseConnectionString"].ConnectionString;
                connection.Open();
                SqlCommand command = new SqlCommand("UPDATE [dbo].[OrderRecord] SET [ConfirmState] = 'true', [ConfirmDate] = '" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "', [PS] = '" + _psTextBox.Text + "' WHERE FKAccount='" + PageSwitcher._account + "' and ConfirmState='False'", connection);
                command.ExecuteScalar();
                connection.Close();

                if (MessageBox.Show("是否繼續購買?", "結帳成功", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    PageSwitcher.Switch(new DrinkInformationForm());
                }
                else
                {
                    Environment.Exit(0);
                }
            }
        }
Example #11
0
        private void MouseUpCheckButton(object sender, MouseButtonEventArgs e)
        {
            TextBlock block = sender as TextBlock;

            block.Foreground = Brushes.White;
            block.Background = Brushes.Black;
            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = ConfigurationManager.ConnectionStrings["DataBaseProject.Properties.Settings.NTUT_DataBaseConnectionString"].ConnectionString;
            connection.Open();
            SqlCommand command1 = new SqlCommand("SELECT count(*) FROM [dbo].[Member] inner join [dbo].[OrderRecord] ON [dbo].[Member].Account=[dbo].[OrderRecord].FKAccount WHERE Account='" + PageSwitcher._account + "' and ConfirmState='false'", connection);

            if (!Convert.ToBoolean(command1.ExecuteScalar()))
            {
                SqlCommand command2 = new SqlCommand("INSERT INTO [dbo].[OrderRecord] ([Oid],[ConfirmState],[ConfirmDate],[DeliveryState],[PS],[FKAccount]) VALUES (NEWID(),'false',NULL,'false','','" + PageSwitcher._account + "')", connection);
                command2.ExecuteScalar();
            }
            connection.Close();
            PageSwitcher.Switch(new ShopCarForm());
        }
Example #12
0
        /// <summary>
        /// Нажатие кнопки [Сохранить]
        /// </summary>
        private void SaveButton_OnClick(object sender, RoutedEventArgs e)
        {
            var payDate = PayDatePicker.SelectedDate;

            if (payDate == null)
            {
                const string           errorMessage = "Срок оплаты по договору не указана";
                const MessageBoxButton buttons      = MessageBoxButton.OK;
                const MessageBoxImage  messageType  = MessageBoxImage.Error;
                MessageBox.Show(errorMessage, PageLiterals.HeaderValidation, buttons, messageType);
                return;
            }

            var foxproDbFolderFin = Properties.Settings.Default.FoxproDbFolder_Fin;

            try
            {
                using (var oleDbConnection = DbControl.GetConnection(foxproDbFolderFin))
                {
                    oleDbConnection.TryConnectOpen();
                    oleDbConnection.VerifyInstalledEncoding("Kart");
                    TestConnectionKart(oleDbConnection);

                    const string queryUpdate = "UPDATE kart SET dopl_dog = ? WHERE nom = ? and nomdog = ?";
                    using (var oleDbCommand = new OleDbCommand(queryUpdate, oleDbConnection))
                    {
                        oleDbCommand.Parameters.AddWithValue("@dopl_dog", payDate);
                        oleDbCommand.Parameters.AddWithValue("@nom", _editedKart.TtnNumber);
                        oleDbCommand.Parameters.AddWithValue("@nomdog", _editedKart.ContractNumber);
                        oleDbCommand.ExecuteNonQuery();
                    }
                }

                PageSwitcher.Switch(new StartPage());
            }
            catch (OleDbException ex)
            {
                throw DbControl.HandleKnownDbFoxProAndMssqlServerExceptions(ex);
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            AdditionalInitializeComponent();
            VisualInitializeComponent();

            var loginWindow = new LoginWindow();

            loginWindow.ShowDialog();

            if (!loginWindow.DialogResult.HasValue || loginWindow.DialogResult != true)
            {
                Close();
                return;
            }
            Login          = loginWindow.GetLogin();
            SideMenu.Login = Login;
            SideMenu.LvlVisual();
            TopMenu.Login = Login;
            TopMenu.LvlVisual();

            PageSwitcher.Switch(new StartPage()); // Страница по умолчанию
        }
Example #14
0
 /// <summary>
 /// Нажатие кнопки [Сводная по изделиям по профессиям в разрезе разрядов]
 /// </summary>
 private void SummeryOfProductsInContextOfProfessionOfDischargesButton_OnClick(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new SummeryOfProductInContextOfProfessionAndOfDischargeReport());
 }
Example #15
0
 private void ClickBackButton(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new DrinkInformationForm());
 }
Example #16
0
 private void OnDrinkGraphicItemMouseUp(object sender, MouseButtonEventArgs e)
 {
     PageSwitcher.Switch(new SellInfomaionGraphicForm());
 }
Example #17
0
 /// <summary>
 /// Нажатие кнопки [Сводная по изделиям в разрезе цехов, участков(для цехов)]
 /// </summary>
 private void SummeryOfProductsInContextOfWorkGuildAndAreaForWorkGuildButton_OnClick(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new SummeryOfProductInContextOfWorkGuildAndAreaForWorkGuildReport());
 }
Example #18
0
 /// <summary>
 /// Нажатие кнопки [Печать аннулируемых изделий за месяц]
 /// </summary>
 private void PrintCancelledDetailForMonthButton_OnClick(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new CancelledDetailsForMonthReport());
 }
Example #19
0
 /// <summary>
 /// Нажатие кнопки [Расчёт численности работников по цехам на выпуск]
 /// </summary>
 private void CalculationNumberWorkguildWorkersRealaseButton_OnClick(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new CalculationNumberWorkguildWorkersRealasesReport());
 }
Example #20
0
 /// <summary>
 /// Нажатие кнопки [Трудоемкости и зарплаты на сбор.ед. по цехам]
 /// </summary>
 private void ComplexityAndSalaryOnUnitByWorkGuildsButton_OnClick(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new ComplexityAndSalaryOnUnitByWorkGuildsReport());
 }
Example #21
0
 /// <summary>
 /// Нажатие кнопки [Просмотр аннулируемых изделий]
 /// </summary>
 private void CancelledDetailButton_OnClick(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new CancelledDetailTable());
 }
Example #22
0
 /// <summary>
 /// Нажатие кнопки [Редактирование выпуска изделий]
 /// </summary>
 private void ReleaseTableButton_OnClick(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new ReleaseTable());
 }
Example #23
0
 /// <summary>
 /// Нажатие кнопки [Отметка деталей для печати]
 /// </summary>
 private void DetailsForPrintButton_OnClick(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new DetailsForPrintTable());
 }
Example #24
0
 /// <summary>
 /// Нажатие кнопки [Отметка деталей для расчета]
 /// </summary>
 private void DetailsForCalculationButton_OnClick(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new DetailsForCalculationTable());
 }
Example #25
0
 /// <summary>
 /// Выбор пункта меню [Печать по изделиям в разрезе деталей]
 /// </summary>
 private void PrintingOfProductInContextOfDetailsButton_OnClick(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new PrintingOfProsuctInContextOfDetailsReport());
 }
Example #26
0
 private void OnOrderRecordItemMouseUp(object sender, MouseButtonEventArgs e)
 {
     PageSwitcher.Switch(new OrderListForm());
 }
Example #27
0
 /// <summary>
 /// Нажатие кнопки [Добавить ед.измерения]
 /// </summary>
 private void AddButton_OnClick(object senderIsButton, RoutedEventArgs eventArgs)
 {
     PageSwitcher.Switch(new MeasureEdit(_measures));
 }
 private void ClickBackButton(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new ManagerHomeForm());
 }
Example #29
0
 /// <summary>
 /// Нажатие кнопки [Отмена]
 /// </summary>
 private void CancelButton_OnClick(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new CopyMaterialToProducts());
 }
Example #30
0
 /// <summary>
 /// Нажатие кнопки [Сводная по изделиям по профессиям в разрезе цехов, участков]
 /// </summary>
 private void SummeryOfProductsOfProfessionInContextOfWorkGuildAndAreaButton_OnClick(object sender, RoutedEventArgs e)
 {
     PageSwitcher.Switch(new SummeryOfProductOfProfessionInContextOfWorkGuildAndOfAreaReport());
 }