Пример #1
0
 public void probarConexion()
 {
     using (DataAccess.Conexion con = new DataAccess.Conexion())
     {
         SqlConnection c = con.getConexion();
     }
 }
        public void guardarFoto(object sender, EventArgs e)
        {
            using (DataAccess.Conexion con = new DataAccess.Conexion())
            {
                SqlConnection c     = con.getConexion();
                string        query = "INSERT INTO imagen (IMG) VALUES(@imagenWeb)";



                try
                {
                    String base64 = this.HiddenField1.Value;
                    //base64.Replace("\"", "");
                    String p1 = base64.Replace("data:image/png;base64,", String.Empty);

                    byte[] pr1 = Convert.FromBase64String(p1);
                    //byte[] imagenInBytes = Convert.FromBase64String(this.HiddenField1.Value.ToString());
                    //byte[] a = File.ReadAllBytes(@"C:\Users\Administrador\Downloads\CapturaImagen (54).png");
                    SqlCommand comando = new SqlCommand(query, c);
                    //comando.Parameters.AddWithValue("@imagen", FileUpload1.FileBytes);
                    comando.Parameters.AddWithValue("@imagenWeb", pr1);
                    comando.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }
Пример #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (camara != null && camara.IsRunning)
            {
                pictureBox1.Image = imagen.Image;
                //pictureBox1.Image.Save(path + "imagen.jpg", ImageFormat.Jpeg);

                DataAccess.Conexion c = new DataAccess.Conexion();
                c.getConexion();
            }
        }
Пример #4
0
        public bool guardarFoto()
        {
            using (DataAccess.Conexion con = new DataAccess.Conexion())
            {
                SqlConnection c     = con.getConexion();
                string        query = "INSERT INTO imagen (IMG) VALUES(@imagen)";


                try
                {
                    SqlCommand comando = new SqlCommand(query, c);
                }
                catch (Exception ex)
                {
                }
            }
            return(false);
        }
Пример #5
0
        private void imagen_Load(object sender, EventArgs e)
        {
            DataAccess.Conexion con = new DataAccess.Conexion();
            String        query     = "SELECT IMG FROM imagen ORDER BY ID DESC";
            SqlConnection c         = con.getConexion();
            SqlCommand    comand    = new SqlCommand(query, c);

            SqlDataAdapter dp    = new SqlDataAdapter(comand);
            DataSet        datos = new DataSet("IMG");

            byte[] imagen = new byte[0];

            dp.Fill(datos, "IMG");

            DataRow linea = datos.Tables["IMG"].Rows[0];

            imagen = (byte[])linea["IMG"];
            MemoryStream ms = new MemoryStream(imagen);

            this.pictureBox1.Image = Image.FromStream(ms);
        }
Пример #6
0
        private void button3_Click(object sender, EventArgs e)
        {
            DataAccess.Conexion con = new DataAccess.Conexion();
            SqlConnection       c   = con.getConexion();

            String query = "INSERT INTO imagen(IMG) VALUES(@imagen)";

            try
            {
                // Image img = this.pictureBox1.Image;
                byte[]     img     = imagenToArray(this.pictureBox1.Image);
                SqlCommand comando = new SqlCommand(query, c);
                comando.Parameters.AddWithValue("@imagen", img);
                comando.ExecuteNonQuery();
                MessageBox.Show("Guardado en la DB");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error");
                MessageBox.Show(ex.ToString());
            }
        }
 public void mostrarUltimaImagen(object sender, EventArgs e)
 {
     using (DataAccess.Conexion con = new DataAccess.Conexion())
     {
         SqlConnection c     = con.getConexion();
         string        query = "SELECT imagen FROM imagen ORDER BY ID DESC";
         //string query = "SELECT IMG FROM imagen ORDER BY ID DESC";
         try
         {
             SqlCommand    comando = new SqlCommand(query, c);
             SqlDataReader lector  = comando.ExecuteReader();
             if (lector.Read())
             {
                 this.dbImage.Src = lector["imagen"].ToString();
                 //this.dbImage.Src = lector["imagen"].ToString();
             }
         }
         catch (Exception ex)
         {
         }
     }
 }
Пример #8
0
 public Controlador()
 {
     con = new DataAccess.Conexion();
     rel = obtenerRel();
 }