Beispiel #1
0
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyboardDevice.Modifiers == ModifierKeys.Shift && e.Key == Key.F1)
            {
                FileClass saveFile = new FileClass();
                saveFile.SaveDocExcel(salesDataBase);
            }

            if (e.KeyboardDevice.Modifiers == ModifierKeys.Shift && e.Key == Key.F2)
            {
                NewSale_Click(sender, e);
            }

            if (e.KeyboardDevice.Modifiers == ModifierKeys.Shift && e.Key == Key.F3)
            {
                BackSale_Click(sender, e);
            }

            if (e.KeyboardDevice.Modifiers == ModifierKeys.Shift && e.Key == Key.F4)
            {
                DeleteSale_Click(sender, e);
            }

            if (e.KeyboardDevice.Modifiers == ModifierKeys.Shift && e.Key == Key.F5)
            {
                UpdateSale_Click(sender, e);
            }

            if (e.KeyboardDevice.Modifiers == ModifierKeys.Shift && e.Key == Key.F6)
            {
                AddProduct_Click(sender, e);
            }

            if (e.KeyboardDevice.Modifiers == ModifierKeys.Shift && e.Key == Key.F7)
            {
                AddDiscount_Click(sender, e);
            }

            if (e.KeyboardDevice.Modifiers == ModifierKeys.Shift && e.Key == Key.F8)
            {
                AddWorker_Click(sender, e);
            }

            if (e.Key == Key.Escape)
            {
                Close();
            }
        }
Beispiel #2
0
        private void BackSale_Click(object sender, RoutedEventArgs e)
        {
            FileClass file = new FileClass();

            DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption);

            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Title  = "Выбрать чек";
            openFile.Filter = "Word documents(*.docx)|*.docx";

            string       saleNumber   = string.Empty;
            TextFromFile textFromFile = file.GetTextDocWord;

            if (openFile.ShowDialog() == true)
            {
                if (dataBase.IssueRefund(textFromFile(openFile.FileName), ref saleNumber))
                {
                    dataBase.DeleteSale(saleNumber);
                    MessageBox.Show("Возврат выполнен");

                    dataBase.OutputTable(salesDataBase, typeList.SelectedIndex);

                    FileInfo fileInf = new FileInfo(openFile.FileName);

                    if (fileInf.Exists)
                    {
                        fileInf.Delete();
                    }
                }

                else
                {
                    MessageBox.Show("Истёк срок");
                }
            }
        }
Beispiel #3
0
        private void SaveTable_Click(object sender, RoutedEventArgs e)
        {
            FileClass saveFile = new FileClass();

            saveFile.SaveDocExcel(salesDataBase);
        }
Beispiel #4
0
        private void addSaleButton_Click(object sender, RoutedEventArgs e)
        {
            if (deliveryCheckBox.IsChecked == false)
            {
                if (CheckFullSale())
                {
                    DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption);

                    var Tuple = GetWorkerInformation();

                    dataBase.CreateNewSale(Tuple.Item2, Tuple.Item1, Tuple.Item3, Tuple.Item4,
                                           productComboBox.SelectedItem.ToString());

                    SaveFileDialog saveFile = new SaveFileDialog();
                    saveFile.FileName = String.Format("Чек №{0}", dataBase.GetLastSaleNumber());
                    saveFile.Filter   = "DocX document (.docx)|(*.docx)";

                    MessageBoxResult dialogResult = MessageBox.Show("Сохранить чек?\n(Внимание! Без чека вы не сможете вернуть товар)",
                                                                    "Сохранение чека", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);

                    if (dialogResult == MessageBoxResult.Yes)
                    {
                        if (saveFile.ShowDialog() == true)
                        {
                            DateTime date         = DateTime.Now;
                            string   dateForMySql = date.ToString("yyyy-MM-dd");

                            string text = String.Format("Номер покупки: {0}\nТовар:\n{1}\nДата покупки: {2}",
                                                        dataBase.GetLastSaleNumber(), productComboBox.SelectedItem.ToString(), dateForMySql);

                            FileClass file = new FileClass();
                            file.SaveDocWord(saveFile.FileName, text);
                        }
                    }

                    dataBase.OutputTable(salesTable, selectedIndex);



                    MessageBox.Show("Покупка оформлена");

                    workersListComboBox.SelectedIndex = -1;
                    productComboBox.SelectedIndex     = -1;
                }
            }
            else
            {
                // Переменные создаются для того, чтобы подсказки появлись
                // сразу и у ComboBox, и у TextBox-ов;

                bool checkFullAddress = CheckFullAddress();
                bool checkFullSale    = CheckFullSale();

                if (checkFullAddress && checkFullSale)
                {
                    DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption);
                    var tuple = GetWorkerInformation();

                    dataBase.CreateNewSale(tuple.Item2, tuple.Item1, tuple.Item3, tuple.Item4,
                                           productComboBox.SelectedItem.ToString(), countryTextBox.Text, cityTextBox.Text, streetTextBox.Text);

                    MessageBoxResult dialogResult = MessageBox.Show("Сохранить чек?\n(Внимание! Без чека вы не сможете вернуть товар)",
                                                                    "Сохранение чека", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);

                    if (dialogResult == MessageBoxResult.Yes)
                    {
                        SaveFileDialog saveFile = new SaveFileDialog();
                        saveFile.FileName = String.Format("Чек №{0}", dataBase.GetLastSaleNumber());
                        saveFile.Filter   = "DocX document (.docx)|(*.docx)";

                        if (saveFile.ShowDialog() == true)
                        {
                            DateTime date         = DateTime.Now;
                            string   dateForMySql = date.ToString("yyyy-MM-dd");

                            string text = String.Format("Номер покупки: {0}\nТовар:\n" +
                                                        "{1}\nДата покупки: {2}",
                                                        dataBase.GetLastSaleNumber(), productComboBox.SelectedItem.ToString(), dateForMySql);

                            FileClass file = new FileClass();
                            file.SaveDocWord(saveFile.FileName, text);
                        }
                    }

                    dataBase.OutputTable(salesTable, selectedIndex);

                    MessageBox.Show("Покупка оформлена");

                    workersListComboBox.SelectedIndex = -1;
                    productComboBox.SelectedIndex     = -1;

                    cityTextBox.Clear();
                    countryTextBox.Clear();
                    streetTextBox.Clear();

                    deliveryCheckBox.IsChecked = false;
                }
            }
        }