Пример #1
0
        private void Button_accept_Click(object sender, RoutedEventArgs e)
        {
            if (TextBox_color_code.Text != "" && TextBox_description.Text != "" &&
                TextBox_color_code.Text.Length == 6)
            {
                bool success = true;
                switch (mode)
                {
                case QueryMode.add:
                    success = Shortcuts.add("colors", new string[] { "color_code", "description" },
                                            new string[] { TextBox_color_code.Text, TextBox_description.Text },
                                            connection);
                    break;

                case QueryMode.change:
                    success = Shortcuts.change("colors", new string[] { "color_code", "description" },
                                               new string[] { TextBox_color_code.Text, TextBox_description.Text },
                                               primary_key_value,
                                               connection);
                    break;
                }
                if (success)
                {
                    parent.Focus();
                    parent.fill_table();
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Заполните все пустые поля!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #2
0
        private void Button_accept_Click(object sender, RoutedEventArgs e)
        {
            int dot_count1 = TextBox_product_amount.Text.Split('.').Length - 1;
            int dot_count2 = TextBox_average_purchase_price.Text.Split('.').Length - 1;

            if (ComboBox_product_name.Text != "" && TextBox_product_amount.Text != "" &&
                ComboBox_supplier.Text != "" && TextBox_average_purchase_price.Text != "" &&
                dot_count1 <= 1 && dot_count2 <= 1)
            {
                string count = Shortcuts.get_one_string_data_from($"SELECT count(*) FROM " +
                                                                  $"`storage` WHERE `product_name` = '{ComboBox_product_name.Text}' AND " +
                                                                  $"`supplier` = '{ComboBox_supplier.Text}';", connection);
                if (int.Parse(count) >= 1 && mode == QueryMode.add)
                {
                    MessageBox.Show("Уже существует запись с такой краской и поставщиком!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                bool   success     = true;
                string measurement = Shortcuts.get_one_string_data_from($"SELECT `measurement` FROM `products` where `name` = '{ComboBox_product_name.Text}';", connection);
                switch (mode)
                {
                case QueryMode.add:
                    success = Shortcuts.execute_command($"INSERT INTO `storage` (`id`, `product_name`, `product_amount`, `measurement`, `supplier`, `average_purchase_price`) " +
                                                        $"VALUES (DEFAULT, '{ComboBox_product_name.Text}', {TextBox_product_amount.Text}, '{measurement}', " +
                                                        $"'{ComboBox_supplier.Text}', {TextBox_average_purchase_price.Text});", connection);
                    break;

                case QueryMode.change:
                    success = Shortcuts.change("storage", new string[] { "id", "product_name", "product_amount", "measurement", "supplier", "average_purchase_price" },
                                               new string[] { primary_key_value, ComboBox_product_name.Text, TextBox_product_amount.Text, measurement,
                                                              ComboBox_supplier.Text, TextBox_average_purchase_price.Text },
                                               primary_key_value,
                                               connection);
                    break;
                }
                if (success)
                {
                    parent.Focus();
                    if (parent is MainWindow)
                    {
                        ((MainWindow)parent).fill_table();
                    }
                    if (parent is SupplyManagerWindow)
                    {
                        ((SupplyManagerWindow)parent).fill_table();
                    }
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Заполните корректно все числовые поля и поля с выбором!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #3
0
        private void Button_accept_Click(object sender, RoutedEventArgs e)
        {
            if (TextBox_vin.Text != "" && TextBox_number.Text != "" && ComboBox_owner_mail.Text != "" && TextBox_color.Text != "" && TextBox_model.Text != "")
            {
                bool success = true;
                switch (mode)
                {
                case QueryMode.add:
                    success = Shortcuts.add("cars", new string[] { "vin", "number", "owner_mail", "color", "model" },
                                            new string[] { TextBox_vin.Text.ToUpper(),
                                                           TextBox_number.Text,
                                                           ComboBox_owner_mail.Text,
                                                           TextBox_color.Text,
                                                           TextBox_model.Text },
                                            connection);
                    break;

                case QueryMode.change:
                    success = Shortcuts.change("cars", new string[] { "vin", "number", "owner_mail", "color", "model" },
                                               new string[] { TextBox_vin.Text.ToUpper(),
                                                              TextBox_number.Text,
                                                              ComboBox_owner_mail.Text,
                                                              TextBox_color.Text,
                                                              TextBox_model.Text },
                                               primary_key_value, connection);
                    break;
                }
                if (success)
                {
                    parent.Focus();
                    if (parent is MainWindow)
                    {
                        ((MainWindow)parent).fill_table();
                    }
                    if (parent is RequestManagerWindow)
                    {
                        ((RequestManagerWindow)parent).fill_table();
                    }
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Заполните все пустые поля!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 private void Button_accept_Click(object sender, RoutedEventArgs e)
 {
     if (TextBox_surface_size.Text != "" && TextBox_cost.Text != "")
     {
         if (Shortcuts.change("car_parts", new string[] { "id", "name", "surface_size", "cost" },
                              new string[] { primary_key_value, Label_name.Content.ToString(), TextBox_surface_size.Text, TextBox_cost.Text },
                              primary_key_value, connection))
         {
             parent.Focus();
             parent.fill_table();
             Close();
         }
     }
     else
     {
         MessageBox.Show("Введите правильные значения и не оставляйте пустых полей!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Пример #5
0
        private void Button_accept_Click(object sender, RoutedEventArgs e)
        {
            if (TextBox_name.Text != "" && ComboBox_city.Text != "" && TextBox_address.Text != "" && TextBox_phone.Text != "")
            {
                bool success = true;
                switch (mode)
                {
                case QueryMode.add:
                    success = Shortcuts.add("suppliers", new string[] { "name", "city", "address", "phone" },
                                            new string[] { TextBox_name.Text,
                                                           ComboBox_city.Text,
                                                           TextBox_address.Text,
                                                           TextBox_phone.Text },
                                            connection);
                    break;

                case QueryMode.change:
                    success = Shortcuts.change("suppliers", new string[] { "name", "city", "address", "phone" },
                                               new string[] { TextBox_name.Text,
                                                              ComboBox_city.Text,
                                                              TextBox_address.Text,
                                                              TextBox_phone.Text },
                                               primary_key_value, connection);
                    break;
                }
                if (success)
                {
                    parent.Focus();
                    if (parent is MainWindow)
                    {
                        ((MainWindow)parent).fill_table();
                    }
                    if (parent is SupplyManagerWindow)
                    {
                        ((SupplyManagerWindow)parent).fill_table();
                    }
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Заполните все пустые поля!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void Button_action_Click(object sender, RoutedEventArgs e)
        {
            bool success = true;

            if (mode == QueryMode.change)
            {
                success = Shortcuts.change(table_name, new string[] { field_name },
                                           new string[] { Textbox_item_value.Text },
                                           old_value,
                                           connection);
            }
            else
            {
                success = Shortcuts.add(table_name, new string[] { field_name }, new string[] { Textbox_item_value.Text }, connection);
            }
            if (success)
            {
                Close();
                parent_window.fill_table();
                parent_window.Focus();
            }
        }
        private void Button_accept_Click(object sender, RoutedEventArgs e)
        {
            if (TextBox_name.Text != "" && ComboBox_paint_type.Text != "" &&
                ComboBox_color_code.SelectedIndex != -1)
            {
                bool success = true;
                switch (mode)
                {
                case QueryMode.add:
                    success = Shortcuts.add("products", new string[] { "name", "paint_type", "color_code", "measurement" },
                                            new string[] { TextBox_name.Text, ComboBox_paint_type.Text,
                                                           (string)(ComboBox_color_code.Items[ComboBox_color_code.SelectedIndex] as ComboBoxItem).Tag,
                                                           (ComboBox_paint_type.Text == "Плёнка")? "рулон": "литр" },
                                            connection);
                    break;

                case QueryMode.change:
                    success = Shortcuts.change("products", new string[] { "name", "paint_type", "color_code", "measurement" },
                                               new string[] { TextBox_name.Text, ComboBox_paint_type.Text,
                                                              (string)(ComboBox_color_code.Items[ComboBox_color_code.SelectedIndex] as ComboBoxItem).Tag,
                                                              (ComboBox_paint_type.Text == "Плёнка")? "рулон": "литр" },
                                               primary_key_value,
                                               connection);
                    break;
                }
                if (success)
                {
                    parent.Focus();
                    parent.fill_table();
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Заполните все пустые поля!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void Button_accept_Click(object sender, RoutedEventArgs e)
        {
            if (TextBox_mail.Text != "" && TextBox_phone.Text != "" &&
                TextBox_surname.Text != "" && TextBox_first_name.Text != "" &&
                TextBox_second_name.Text != "" && ComboBox_gender.Text != "")
            {
                string m = TextBox_mail.Text.ToLower();
                if (m.Split('@').Length != 2)
                {
                    MessageBox.Show("Неправильный ввод почты!");
                    return;
                }
                if (!(m.Contains('.') && m.Split('@')[1].Split('.')[1].Length >= 2 &&
                      m.Split('@')[1].Split('.')[1].Length <= 4))
                {
                    MessageBox.Show("Неправильный ввод почты!");
                    return;
                }
                if (m.LastIndexOf('.') - m.IndexOf('@') <= 1)
                {
                    MessageBox.Show("Неправильный ввод почты!");
                    return;
                }
                if (m.IndexOf('@') == 0)
                {
                    MessageBox.Show("Неправильный ввод почты!");
                    return;
                }

                /*Regex reg = new Regex("^[A-Za-z0-9._-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}$");
                 * if (!reg.IsMatch(TextBox_mail.Text.ToLower()))
                 * {
                 *      MessageBox.Show("Неправильный ввод почты!");
                 *      return;
                 * }*/
                bool success = true;
                switch (mode)
                {
                case QueryMode.add:
                    success = Shortcuts.add("clients", new string[] { "mail", "phone", "surname", "first_name", "second_name", "gender" },
                                            new string[] { TextBox_mail.Text.ToLower(), TextBox_phone.Text,
                                                           TextBox_surname.Text, TextBox_first_name.Text,
                                                           TextBox_second_name.Text, ComboBox_gender.Text },
                                            connection);
                    break;

                case QueryMode.change:
                    success = Shortcuts.change("clients", new string[] { "mail", "phone", "surname", "first_name", "second_name", "gender" },
                                               new string[] { TextBox_mail.Text.ToLower(), TextBox_phone.Text,
                                                              TextBox_surname.Text, TextBox_first_name.Text,
                                                              TextBox_second_name.Text, ComboBox_gender.Text },
                                               primary_key_value,
                                               connection);
                    break;
                }
                if (success)
                {
                    parent.Focus();
                    if (parent is MainWindow)
                    {
                        ((MainWindow)parent).fill_table();
                    }
                    if (parent is RequestManagerWindow)
                    {
                        ((RequestManagerWindow)parent).fill_table();
                    }
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Заполните все пустые поля!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }