public void kategorilendir() { Baglanti baglanti = new Baglanti(); SqlCommand cmd = new SqlCommand(); baglanti.sorguCalistir("select DISTINCT KategoriAdi from FilmListele", ref cmd); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { liste(dr["KategoriAdi"].ToString()); } baglanti.baglantiKapat(); }
void yorumlariEkle() { flp.Controls.Clear(); Baglanti baglanti = new Baglanti(); SqlCommand cmd = new SqlCommand(); string sorgu = $"select * from YorumListele where FilmID='{filmId}'"; baglanti.sorguCalistir(sorgu, ref cmd); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Panel panel = new Panel(); panelDoldur(dr, ref panel); flp.Controls.Add(panel); } baglanti.baglantiKapat(); }
private void liste(string kategori) { Baglanti baglanti = new Baglanti(); SqlCommand cmd = new SqlCommand(); string sorgu = $"select * from FilmListele where KategoriAdi='{kategori}'"; baglanti.sorguCalistir(sorgu, ref cmd); SqlDataReader dr = cmd.ExecuteReader(); FlowLayoutPanel fr = new FlowLayoutPanel(); while (dr.Read()) { Panel panel = new Panel(); flpDoldur(fr); panelDoldur(ref panel, dr); fr.Controls.Add(panel); fr.Tag = dr["KategoriAdi"]; } baglanti.baglantiKapat(); Flp.Add(fr); }
Baglanti baglan = new Baglanti(); //bağlan sınıfından sql bağlantısını al public void Doldur(string tablo, string columName, ComboBox cmb) //comboboxa veritabanından veri çek { List <string> cmbList = new List <string>(); AutoCompleteStringCollection collection = new AutoCompleteStringCollection(); string sorgu = "select " + columName + " from " + tablo + " ";//tablo adı ve veri adı ile komutu ver SqlCommand cmd = new SqlCommand(); baglan.sorguCalistir(sorgu, ref cmd); SqlDataReader dr = cmd.ExecuteReader();//verileri oku while (dr.Read()) { cmb.Items.Add(dr[columName]);//verileri cmb itemlerine ekle cmbList.Add(dr[columName].ToString()); collection.Add(dr[columName].ToString()); } baglan.baglantiKapat(); cmb.AutoCompleteCustomSource = collection; cmb.AutoCompleteMode = AutoCompleteMode.Suggest; cmb.AutoCompleteSource = AutoCompleteSource.CustomSource; cmb.SelectedIndex = -1; }
private void btnKaydet_Click(object sender, EventArgs e) { try { cmb.Düzenle(ref cmbYonetmen); cmb.Düzenle(ref cmbKategori); } catch (Exception exception) { } string sorgu = $"FilmEkle '{txtFilmAdi.Text}','{cmbKategori.SelectedItem}','{cmbYonetmen.SelectedItem}',@Gorsel,@filminfo"; baglanti.sorguCalistir(sorgu, ref cmd); if (resim != null) { cmd.Parameters.AddWithValue("@Gorsel", resim);//resim seçildi ise resmi DB ye aktarılıyor } else { cmd.Parameters.Add("@Gorsel", SqlDbType.Image, 0).Value = DBNull.Value;//Resim yok ise null değeri döndürür } cmd.Parameters.Add("@filminfo", SqlDbType.Text, richTextBoxFilmInfo.Text.Length).Value = richTextBoxFilmInfo.Text; try { cmd.ExecuteNonQuery(); MessageBox.Show("eklendi"); frmFilmListe.listele();//film eklenince sayfayı yenileme işlemi } catch (Exception exception) { MessageBox.Show(exception.Message); } cmd.Parameters.Clear(); baglanti.baglantiKapat(); this.Close(); }
void panelDoldur(ref Panel panel, SqlDataReader dr) { panel.Controls.Clear(); Button btnBegen = new Button(); Button btnYorum = new Button(); Button btnSil = new Button(); PictureBox pictureBox1 = new PictureBox(); RichTextBox richTextBox1 = new RichTextBox(); Label label1 = new Label(); Label label = new Label(); Label lblFilmAdi = new Label(); Label lblYonetmen = new Label(); panel.SuspendLayout(); ((ISupportInitialize)(pictureBox1)).BeginInit(); // // panel // panel.AutoScroll = true; panel.Controls.Add(btnYorum); panel.Controls.Add(btnBegen); panel.Controls.Add(richTextBox1); panel.Controls.Add(pictureBox1); panel.Controls.Add(label1); panel.Controls.Add(label); panel.Controls.Add(btnSil); panel.Controls.Add(lblFilmAdi); panel.Controls.Add(lblYonetmen); panel.Size = new Size(268, 388); panel.BackColor = Color.Gray; // //lblFilmAdi // lblFilmAdi.AutoSize = true; lblFilmAdi.Text = "Film adı: " + dr["FilmAdi"]; lblFilmAdi.ForeColor = Color.White; lblFilmAdi.Font = new Font("Times New Roman", 10.2F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(162))); lblFilmAdi.Location = new Point(panel.Width / 2 - lblFilmAdi.Width / 2, 221); // //lblYonetmen // lblYonetmen.AutoSize = true; lblYonetmen.Text = "Yönetmen adı: " + dr["Ad"]; lblYonetmen.ForeColor = Color.White; lblYonetmen.Font = new Font("Times New Roman", 10.2F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(162))); lblYonetmen.Location = new Point(panel.Width / 2 - lblYonetmen.Width / 2, 221 + lblFilmAdi.Height); // // richTextBox1 // richTextBox1.Location = new Point(39, 221 + lblFilmAdi.Height + lblYonetmen.Height); richTextBox1.ReadOnly = true; richTextBox1.Size = new Size(189, 99 - (lblFilmAdi.Height + lblYonetmen.Height)); richTextBox1.Text = dr["FilmInfo"].ToString(); // //btnSil // btnSil.Location = new Point(240, 0); btnSil.Size = new Size(30, 26); btnSil.BackColor = Color.Gray; btnSil.Visible = false; btnSil.Click += new EventHandler(btnSil_Click); btnSil.Tag = Convert.ToInt32(dr["FilmID"]); btnSil.BackgroundImage = Properties.Resources.times_circle_solid; btnSil.BackgroundImageLayout = ImageLayout.Zoom; if (admin) { btnSil.Visible = true; } // // btnYorum // btnYorum.BackgroundImage = Properties.Resources.comment_regular; btnYorum.BackgroundImageLayout = ImageLayout.Zoom; btnYorum.Location = new Point(173, 326); btnYorum.Size = new Size(30, 26); btnYorum.UseVisualStyleBackColor = true; btnYorum.Click += new EventHandler(this.btnYorum_Click); BtnBilgi yorum = new BtnBilgi(); yorum.FilmId = Convert.ToInt32(dr["FilmID"]); yorum.KullaniciID = kullaniciId; yorum.Label = label; btnYorum.Tag = yorum; // // btnBegen // Baglanti baglanti = new Baglanti(); SqlCommand cmd = new SqlCommand(); baglanti.sorguCalistir($"select *from tblLikes where kullaniciID='{kullaniciId}' and FilmID={dr["FilmID"]}", ref cmd); SqlDataReader dr2 = cmd.ExecuteReader(); bool begen = false; while (dr2.Read()) { begen = Convert.ToBoolean(dr2["Begendi"]); } baglanti.baglantiKapat(); btnBegen.BackgroundImage = Properties.Resources.e6925a934d0c279e4bd98e2ddff557ee; btnBegen.BackgroundImageLayout = ImageLayout.Zoom; btnBegen.Location = new Point(39, 326); btnBegen.Size = new Size(30, 26); btnBegen.UseVisualStyleBackColor = true; if (begen) { btnBegen.BackColor = Color.Red; } else { btnBegen.BackColor = Color.AliceBlue; } btnBegen.FlatStyle = FlatStyle.Flat; BtnBilgi begeni = new BtnBilgi(); begeni.FilmId = Convert.ToInt32(dr["FilmID"]); begeni.KullaniciID = kullaniciId; begeni.Label = label1; btnBegen.Tag = begeni; btnBegen.Click += new EventHandler(this.btnBegen_Click); // // pictureBox1 // pictureBox1.Location = new Point(39, 12); pictureBox1.Size = new Size(189, 203); pictureBox1.TabIndex = 0; pictureBox1.TabStop = false; pictureBox1.BackgroundImageLayout = ImageLayout.Zoom; pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; if (dr["Gorsel"] != DBNull.Value) { pictureBox1.Image = Bitmap.FromStream(new MemoryStream((byte[])dr["Gorsel"])); } // // label1 // label1.AutoSize = true; label1.Font = new Font("Microsoft Sans Serif", 10.2F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(162))); label1.Location = new Point(35, 355); label1.Size = new Size(63, 20); label1.TabIndex = 5; Baglanti baglanti2 = new Baglanti(); SqlCommand cmd2 = new SqlCommand(); baglanti2.sorguCalistir($"select count(*) as begeniSayisi from tblLikes where FilmID='{dr["FilmID"]}' and Begendi=1", ref cmd2); SqlDataReader dataReader = cmd2.ExecuteReader(); while (dataReader.Read()) { label1.Text = dataReader["begeniSayisi"].ToString(); } baglanti.baglantiKapat(); // // label // label.AutoSize = true; label.Font = new Font("Microsoft Sans Serif", 10.2F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(162))); label.Location = new Point(170, 355); label.Size = new Size(63, 20); Baglanti baglanti3 = new Baglanti(); SqlCommand cmd3 = new SqlCommand(); baglanti3.sorguCalistir($"select count(*) as yorumSayisi from tblYorumlar where FilmID='{dr["FilmID"]}'", ref cmd3); SqlDataReader dataReader2 = cmd3.ExecuteReader(); while (dataReader2.Read()) { label.Text = dataReader2["yorumSayisi"].ToString(); } baglanti2.baglantiKapat(); }