private void BTN_Insertar_Click(object sender, RoutedEventArgs e) { Random random = new Random(); try { string RPT = ""; if (TXT_numero.Text == "" || CBX_Estado.SelectedItem.ToString() == "") { System.Windows.MessageBox.Show("Por favor, llene la informacion solicitada", "Hotel Royal S.V", MessageBoxButton.OK, MessageBoxImage.Information); TXT_ID.Focus(); } else { A: int id = random.Next(1, 100000); DataTable exist = N_Random.Random_Exist("HABITACIONES", id); if (exist.Rows.Count >= 1) { goto A; } else { if (TXT_numero.Text == "" || CBX_Estado.SelectedItem.ToString() == "" || CBX_Costo.SelectedItem.ToString() == "") { System.Windows.MessageBox.Show("Por favor, llenar los datos solicitados", "Hotel Royal S.V", MessageBoxButton.OK, MessageBoxImage.Information); } else { RPT = N_Habitaciones.Insertar(id, 0, Convert.ToInt32(CBX_Costo.Text), Convert.ToInt32(TXT_numero.Text), Convert.ToString(CBX_Estado.Text)); } if (RPT.Equals("OK")) { System.Windows.MessageBox.Show("Se inserto la habitacion", "Hotel Royal S.V", MessageBoxButton.OK, MessageBoxImage.Information); } else { System.Windows.MessageBox.Show(RPT, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } Limpiar(); TXT_numero.Focus(); } } } catch (Exception err) { System.Windows.MessageBox.Show(err.Message, err.Source, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void BTN_Insertar_Click(object sender, RoutedEventArgs e) { Random random = new Random(); try { if (TXT_Nombre.Text != "" || TXT_Apellido.Text != "" || TXT_Edad.Text != "" || TXT_Correo.Text != "" || TXT_Telefono.Text != "" || TXT_Celular.Text != "" || TXT_Dui.Text != "" || TXT_Nit.Text != "" || TXT_Isss.Text != "" || TXT_Usuario.Text != "" || TXT_Contraseña.Text != "" || TXT_Puesto.Text != "" || TXT_Departamento.Text != "") { A: int id = random.Next(1, 100000); DataTable datEmpleado = N_Random.Random_Exist("EMPLEADO", id); if (datEmpleado.Rows.Count >= 1) { goto A; } else { string RPT = N_Empleado.Insertar(id, TXT_Nombre.Text, TXT_Apellido.Text, Convert.ToInt32(TXT_Edad.Text), TXT_Correo.Text, TXT_Telefono.Text , TXT_Celular.Text, TXT_Dui.Text, TXT_Nit.Text, TXT_Isss.Text, TXT_Usuario.Text, TXT_Contraseña.Text, TXT_Puesto.Text, TXT_Departamento.Text); if (RPT.Equals("OK")) { System.Windows.MessageBox.Show("Se inserto correctamente el empleado", "Hotel Royal S.V", MessageBoxButton.OK, MessageBoxImage.Information); } else { System.Windows.MessageBox.Show(RPT, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } } } } catch (Exception err) { System.Windows.MessageBox.Show(err.Message + "\n" + err.StackTrace); } }