Exemple #1
0
        private void resimGetir(int index)
        {
            ilan          ilan_sor = edm.ilans.SingleOrDefault(x => x.ID == index);
            foto          ft       = edm.fotoes.SingleOrDefault(x => x.ID == ilan_sor.fotoID);
            SqlConnection bag      = new SqlConnection(@"Data Source=SERKAN\SQLEXPRESS;Initial Catalog=EmlakServer;Integrated Security=True");

            bag.Open();
            SqlCommand    komut = new SqlCommand("Select * from foto where ID = '" + ilan_sor.fotoID + "' ", bag);
            SqlDataReader oku   = komut.ExecuteReader();

            while (oku.Read())
            {
                try
                {
                    byte[]       Pic    = (byte[])oku["fotograf"];
                    MemoryStream Resim1 = new MemoryStream(Pic);
                    Image        img    = Image.FromStream(Resim1);
                    picture_Foto_Duzenle.Image = img;
                }
                catch
                {
                    MessageBox.Show("Resim yüklenirken bir hata oluştu..");
                }
            }
            bag.Close();
        }
Exemple #2
0
        private void btnIlanSil_Click(object sender, EventArgs e)
        {
            try
            {
                ilan      iln_sil = edm.ilans.SingleOrDefault(x => x.ID == ilan_index);
                ilanDetay dty_sil = edm.ilanDetays.SingleOrDefault(x => x.ilanID == iln_sil.detay_ID);
                foto      ft_sil  = edm.fotoes.SingleOrDefault(x => x.ID == iln_sil.fotoID);

                if (MessageBox.Show("Silmek istediğinize eminmisiniz", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    edm.ilans.Remove(iln_sil);
                    edm.ilanDetays.Remove(dty_sil);
                    if (ft_sil.ID != 18)
                    {
                        edm.fotoes.Remove(ft_sil);
                    }
                    edm.SaveChanges();
                    listele();
                }
            }
            catch
            {
                MessageBox.Show("Bir hata oluştu", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }