Exemple #1
0
        private void AddWorkerButton_Click(object sender, RoutedEventArgs e)
        {
            DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption);

            if (CheckFullInfo())
            {
                bool isExistWorker = dataBase.CheckFullStaff(secondNameTextBox.Text, firstNameTextBox.Text, middleNameTextBox.Text,
                                                             staffComboBox.SelectedItem.ToString());

                if (isExistWorker)
                {
                    MessageBox.Show("Такой работник уже записан");
                }

                else
                {
                    dataBase.CreateNewWorker(secondNameTextBox.Text, firstNameTextBox.Text, middleNameTextBox.Text,
                                             staffComboBox.SelectedItem.ToString());

                    MessageBox.Show("Уcпешно создан");

                    dataBase.OutputTableStaff(staffTableDataGrid);
                }

                firstNameTextBox.Clear();
                secondNameTextBox.Clear();
                middleNameTextBox.Clear();

                staffComboBox.SelectedIndex = -1;
            }
        }
Exemple #2
0
        private void AddProductButton_Click(object sender, RoutedEventArgs e)
        {
            if (CheckFullData())
            {
                DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption);

                bool isSuccessfulAdd = dataBase.CreateNewTechnic(nameProductTextBox.Text, typeProductTextBox.Text,
                                                                 priceProductTextBox.Text, nameFabricatorTextBox.Text);

                if (isSuccessfulAdd)
                {
                    MessageBox.Show("Товар создан");
                    dataBase.OutputTableProduct(listProductDataGrid);

                    nameProductTextBox.Clear();
                    nameFabricatorTextBox.Clear();
                    typeProductTextBox.Clear();
                    priceProductTextBox.Clear();
                }

                else
                {
                    MessageBox.Show("Такой товар уже существует");

                    nameProductTextBox.Clear();
                    nameFabricatorTextBox.Clear();
                    typeProductTextBox.Clear();
                    priceProductTextBox.Clear();
                }
            }
        }
Exemple #3
0
        public AddProduct()
        {
            InitializeComponent();

            DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption);
            dataBase.OutputTableProduct(listProductDataGrid);
        }
Exemple #4
0
        public MainWindow()
        {
            InitializeComponent();

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

            typeList.SelectedIndex = 0;
        }
Exemple #5
0
        public AddDiscount()
        {
            InitializeComponent();

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

            technicComboBox.ItemsSource         = dataBase.OutputAllTechnic();
            currentDiscountComboBox.ItemsSource = dataBase.OutputAllDiscount();

            dataBase.OutputTableDiscount(discountDataGrid);
        }
Exemple #6
0
        public CreateWorker()
        {
            InitializeComponent();

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

            string[] staff = { "Продавец-консультант", "Менеджер", "Кассир" };

            staffComboBox.ItemsSource = staff;
        }
Exemple #7
0
        public addSale(int selectedIndex, DataGrid salesTable)
        {
            InitializeComponent();

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

            workersListComboBox.ItemsSource = dataBase.GetStaff();
            productComboBox.ItemsSource     = dataBase.OutputProduct();

            this.selectedIndex = selectedIndex;
            this.salesTable    = salesTable;
        }
Exemple #8
0
        private void DeleteDiscountButton_Click(object sender, RoutedEventArgs e)
        {
            if (CheckFullProductDelete())
            {
                DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption);

                dataBase.DeleteDiscount(currentDiscountComboBox.SelectedItem.ToString());

                currentDiscountComboBox.SelectedIndex = -1;
                discountDataGrid.Items.Clear();
                currentDiscountComboBox.ItemsSource = null;

                currentDiscountComboBox.ItemsSource = dataBase.OutputAllDiscount();
                dataBase.OutputTableDiscount(discountDataGrid);

                MessageBox.Show("        Удаление прошло успешно");
            }
        }
Exemple #9
0
        private void deleteSaleButton_Click(object sender, RoutedEventArgs e)
        {
            DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption);

            if (CheckFullNumber())
            {
                if (dataBase.DeleteSale(numberSaleTextBox.Text))
                {
                    MessageBox.Show("Удаление прошло успешно");
                    dataBase.OutputTable(dataGrid, selectedIndex);

                    numberSaleTextBox.Clear();
                }
                else
                {
                    MessageBox.Show("Неверный номер покупки");
                    numberSaleTextBox.Clear();
                }
            }
        }
Exemple #10
0
        private void UpdateSaleButton_Click(object sender, RoutedEventArgs e)
        {
            DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption);

            if (CheckFullNumber())
            {
                if (dataBase.UpdateSaleStatus(numberSaleTextBox.Text))
                {
                    MessageBox.Show("Статус изменён");
                    dataBase.OutputTable(salesTable, selectedIndex);

                    numberSaleTextBox.Clear();
                }
                else
                {
                    MessageBox.Show("Невозможно изменить статус");

                    numberSaleTextBox.Clear();
                }
            }
        }
Exemple #11
0
        private void AddDiscountButton_Click(object sender, RoutedEventArgs e)
        {
            if (CheckFullDiscount())
            {
                DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption);

                if (dataBase.AddDiscount(technicComboBox.SelectedItem.ToString(), discountTextBox.Text))
                {
                    Tuple <string, int> tuple = new Tuple <string, int>
                                                    (technicComboBox.SelectedItem.ToString(), Convert.ToInt32(discountTextBox.Text));

                    currentDiscountComboBox.SelectedIndex = -1;
                    discountDataGrid.Items.Clear();
                    currentDiscountComboBox.ItemsSource = null;

                    dataBase.OutputTableDiscount(discountDataGrid);
                    currentDiscountComboBox.ItemsSource = dataBase.OutputAllDiscount();

                    technicComboBox.SelectedIndex = -1;
                    discountTextBox.Text          = "";
                }
                else
                {
                    bool isMessageResultAgree = MessageBox.Show
                                                    ("Скидка на этот товар существует. Изменить существующую скидку?", "Изменнение скидки",
                                                    MessageBoxButton.YesNo) == MessageBoxResult.Yes;

                    if (isMessageResultAgree)
                    {
                        dataBase.UpdateDiscount(technicComboBox.SelectedItem.ToString(), discountTextBox.Text);

                        discountDataGrid.Items.Clear();
                        dataBase.OutputTableDiscount(discountDataGrid);
                    }

                    technicComboBox.SelectedIndex = -1;
                    discountTextBox.Text          = "";
                }
            }
        }
Exemple #12
0
        private void DeleteAllDiscountButton_Click(object sender, RoutedEventArgs e)
        {
            bool isMessageResultAgree = MessageBox.Show
                                            ("                    Удалить всё?", "Подтверждение операции",
                                            MessageBoxButton.YesNo) == MessageBoxResult.Yes;

            if (isMessageResultAgree)
            {
                DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption);

                dataBase.DeleteDiscount();

                currentDiscountComboBox.SelectedIndex = -1;
                currentDiscountComboBox.ItemsSource   = null;
                discountDataGrid.Items.Clear();

                currentDiscountComboBox.ItemsSource = dataBase.OutputAllDiscount();
                dataBase.OutputTableDiscount(discountDataGrid);

                MessageBox.Show("        Удаление прошло успешно");
            }
        }
Exemple #13
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("Истёк срок");
                }
            }
        }
Exemple #14
0
 private void typeList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     DataBaseClass.DataBase dataBase = new DataBaseClass.DataBase(DataBaseOption.dataBaseOption);
     dataBase.OutputTable(salesDataBase, typeList.SelectedIndex);
 }
Exemple #15
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;
                }
            }
        }