public static int agregarComentario(Comentario a) { SqlConnection con = Conexion.agregarConexion(); SqlCommand cmd = new SqlCommand(String.Format("insert into comentarios(idComentario, recomendacion, titulo, contenido, idDisfraz) values ('{0}', '{1}', '{2}', '{3}','{4}')", a.idComentario, a.recomendacion, a.titulo, a.contenido, a.idDisfraz), con); int res = cmd.ExecuteNonQuery(); return(res); }
public static int agregarCliente(Cliente a) { SqlConnection con = Conexion.agregarConexion(); SqlCommand cmd = new SqlCommand(String.Format("INSERT INTO cliente (correo, passwd, nombre) values ('{0}','{1}','{2}')", a.correo, a.password, a.nombre), con); int res = cmd.ExecuteNonQuery(); con.Close(); return(res); }
private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { SqlConnection con = Conexion.agregarConexion(); SqlCommand cmd = new SqlCommand("select comentarios.contenido from comentarios, disfraces where comentarios.idDisfraz=disfraces.idDisfraz and disfraces.nombre = '" + comboBox.SelectedItem.ToString() + "'", con); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { comboBox1.Items.Add(dr["contenido"].ToString()); } }
private void btVerRecomendacion_Click(object sender, RoutedEventArgs e) { SqlConnection con = Conexion.agregarConexion(); SqlCommand cmd = new SqlCommand(String.Format("SELECT passwd FROM cliente WHERE correo = '{0}'", txCorreo.Text), con); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read() && (dr.GetString(0).Equals(txPassword.Text))) { Disfraces a = new Disfraces(); a.Show(); this.Hide(); } else { MessageBox.Show("Este usuario no esta registrado"); } }
private void button1_Click(object sender, RoutedEventArgs e) { SqlConnection con = Conexion.agregarConexion(); SqlCommand cmm = new SqlCommand(String.Format("select max(idComentario) from comentarios"), con); Object o = cmm.ExecuteScalar(); int idComentario = int.Parse(o.ToString()) + 1; Comentario a = new Comentario(idComentario, textBox.Text, textBox1.Text, textBox2.Text, int.Parse(comboBox.SelectedItem.ToString())); int res = Comentario.agregarComentario(a); if (res > 0) { MessageBox.Show("Comentario registrado"); } else { MessageBox.Show("Error: No se pudo registrar el comentario"); } }