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); } }
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_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); } }