private void Btn_Insert_Click(object sender, RoutedEventArgs e) { try { if (TextBox_Name.Text == "" || TextBox_Address.Text == "" || TextBox_Email.Text == "") { if (TextBox_Name.Text == "") { MessageBox.Show("Name is required", "Warning", MessageBoxButton.OK); TextBox_Name.Focus(); } else if (TextBox_Address.Text == "") { MessageBox.Show("Address is required", "Warning", MessageBoxButton.OK); TextBox_Address.Focus(); } else if (TextBox_Email.Text == "") { MessageBox.Show("Email is required", "Warning", MessageBoxButton.OK); TextBox_Email.Focus(); } } else { var check_email = connection.Suppliers.FirstOrDefault(S => S.Email == TextBox_Email.Text); if (check_email == null) { MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are You Sure?", "Insert Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { var input_supplier = new Supplier(TextBox_Name.Text, TextBox_Address.Text, TextBox_Email.Text); connection.Suppliers.Add(input_supplier); var insert = connection.SaveChanges(); if (insert >= 1) { MessageBox.Show(insert + " Supplier has been inserted"); } TB_M_Supplier.ItemsSource = connection.Suppliers.ToList(); } } else { MessageBox.Show("Email has been used"); } } } catch (Exception) { } reset_supplier(); Combo_Supplier.ItemsSource = connection.Suppliers.ToList(); }
private void TextBox_Email_TextChanged(object sender, EventArgs e) { int cursorPos = TextBox_Email.SelectionStart; TextBox_Email_Validating(new object(), new CancelEventArgs()); TextBox_Email.Select(cursorPos, 0); }
private void CleanPanel() { TextBox_DNI.Clear(); TextBox_Nombre.Clear(); TextBox_Email.Clear(); //dateTimePicker1.Value = null; panel1.Enabled = false; }
private void ClearFields() { TextBox_Estado.Clear(); MaskedTextBox_Cep.Clear(); TextBox_Cidade.Clear(); TextBox_Bairro.Clear(); TextBox_Nome.Clear(); TextBox_Email.Clear(); TextBox_Endereco.Clear(); MaskedTextBox_Telefone.Clear(); TextBox_Nome.Focus(); }
private void ClearTextBoxes() { TextBox_HoTen.Clear(); TextBox_DiaChi.Clear(); TextBox_Email.Clear(); }