Exemple #1
0
        private void FrmMarkalar_Load(object sender, EventArgs e)
        {
            var degerler = db.TBLURUN.OrderBy(x => x.MARKA).GroupBy(y => y.MARKA).Select(z => new
            {
                Marka       = z.Key,
                Toplam_Ürün = z.Count()
            });

            gridControl1.DataSource = degerler.ToList();
            labelControl2.Text      = db.TBLURUN.Count().ToString();
            labelControl3.Text      = (from x in db.TBLURUN
                                       select x.MARKA).Distinct().Count().ToString();
            labelControl5.Text = (from x in db.TBLURUN
                                  orderby x.SATISFIYAT descending
                                  select x.MARKA).FirstOrDefault();
            labelControl7.Text = db.maksmarka().FirstOrDefault();


            SqlConnection baglanti = new SqlConnection(@"Data Source=DESKTOP-N5F5PJT;Initial Catalog=DbTeknikServis;Integrated Security=True");

            baglanti.Open();
            SqlCommand    komut = new SqlCommand("SELECT MARKA,COUNT(*) FROM TBLURUN GROUP BY MARKA", baglanti);
            SqlDataReader dr    = komut.ExecuteReader();

            while (dr.Read())
            {
                chartControl1.Series["Series 1"].Points.AddPoint(Convert.ToString(dr[0]), int.Parse(dr[1].ToString()));
            }
            baglanti.Close();

            baglanti.Open();
            SqlCommand    komut2 = new SqlCommand("SELECT COUNT(*), TBLKATEGORI.AD FROM TBLURUN INNER JOIN TBLKATEGORI ON TBLKATEGORI.ID = TBLURUN.KATEGORI GROUP BY TBLKATEGORI.AD", baglanti);
            SqlDataReader dr2    = komut.ExecuteReader();

            while (dr2.Read())
            {
                chartControl2.Series["Kategoriler"].Points.AddPoint(Convert.ToString(dr2[0]), int.Parse(dr2[1].ToString()));
            }
            baglanti.Close();
        }