private void dtgridaylikkasa_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (dtgridaylikkasa.ColumnCount > 0)
                {
                    dtgridaylikayrintlikasa.Columns.Clear();

                    string secili_ay = dtgridaylikkasa.CurrentRow.Cells[0].Value.ToString();

                    DatabaseClass database = new DatabaseClass();

                    string sorgu = "Select * FROM `günlük_kasa` WHERE aylar = '" + secili_ay + "'";

                    dtgridaylikayrintlikasa.DataSource = database.ListData(sorgu);

                    dtgridaylikayrintlikasa.Columns[0].HeaderText = "TARİH";
                    dtgridaylikayrintlikasa.Columns[1].HeaderText = "AYLAR";
                    dtgridaylikayrintlikasa.Columns[2].HeaderText = "EURO";
                    dtgridaylikayrintlikasa.Columns[3].HeaderText = "DOLAR";
                    dtgridaylikayrintlikasa.Columns[4].HeaderText = "TL";
                    dtgridaylikayrintlikasa.Columns[5].HeaderText = "Hangi Yıl";
                }
            }
            catch (Exception)
            {
            }
        }
        private void datagridYillikKasa_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DatabaseClass database = new DatabaseClass();

            try
            {
                if (datagridYillikKasa.ColumnCount > 0)
                {
                    dtgridaylikkasa.Columns.Clear();

                    string secili_yil = datagridYillikKasa.CurrentRow.Cells[0].Value.ToString();

                    string sqlay = "select aylar, SUM(Euro) as EuroT, SUM(Dolar) as DolarT, SUM(TL) as TLT FROM `günlük_kasa` WHERE HANGI_YIL = '" + secili_yil + "' GROUP BY aylar";

                    dtgridaylikkasa.DataSource = database.ListData(sqlay);

                    dtgridaylikkasa.Columns[0].HeaderText = "HANGİ AY?";
                    dtgridaylikkasa.Columns[1].HeaderText = "EURO";
                    dtgridaylikkasa.Columns[2].HeaderText = "DOLAR";
                    dtgridaylikkasa.Columns[3].HeaderText = "TL";
                }
            }
            catch (Exception)
            {
            }
        }
        private void kasadevirHesapla()
        {
            string tarih, yil, ay, gun;

            try
            {
                if (dataGridgKasa.ColumnCount > 0)
                {
                    string secili_tarih = dataGridgKasa.CurrentRow.Cells[0].Value.ToString();
                    //dataGridgKasa_CellClick(sender, e);
                    DateTime DTIME = Convert.ToDateTime(secili_tarih);
                    yil = DTIME.Date.Year.ToString();
                    ay  = DTIME.Date.Month.ToString();
                    gun = DTIME.Date.Day.ToString();

                    if (ay.Length <= 1)
                    {
                        ay = "0" + ay;
                    }
                    if (gun.Length <= 1)
                    {
                        gun = "0" + gun;
                    }


                    tarih = yil + "-" + ay + "-" + gun;

                    DatabaseClass database = new DatabaseClass();

                    string sorgu =
                        "select " +
                        " SUM(CAST(REPLACE(TL, ',', '.') as DECIMAL(9, 2))) as TLT, " +
                        " SUM(CAST(REPLACE(Euro, ',', '.') as DECIMAL(9,2))) EuroT," +
                        "SUM(CAST(REPLACE(Dolar, ',', '.') as DECIMAL(9, 2))) as DolarT " +

                        "FROM günlük_kasa WHERE Tarih <= '" + tarih + "'";

                    dataGVKasaDevir.Columns.Clear();
                    dataGVKasaDevir.DataSource = database.ListData(sorgu);

                    dataGVKasaDevir.Columns[0].HeaderText = "TL";
                    dataGVKasaDevir.Columns[1].HeaderText = "EURO";
                    dataGVKasaDevir.Columns[2].HeaderText = "DOLAR";


                    lblTarih.Text          = "-" + Convert.ToDateTime(secili_tarih).ToShortDateString() + "-";
                    datetpislemtarihi.Text = dataGridgKasa.CurrentRow.Cells[0].Value.ToString();
                }
            }
            catch (Exception)
            {
            }
        }
        private void Ayrintilar_Load(object sender, EventArgs e)
        {
            DatabaseClass database = new DatabaseClass();

            string sql = "select HANGI_YIL, SUM(CAST(REPLACE(Euro, ',', '.') as DECIMAL(9, 2))) as EuroT, SUM(CAST(REPLACE(Dolar, ',', '.') as DECIMAL(9, 2))) as DolarT, SUM(CAST(REPLACE(TL, ',', '.') as DECIMAL(9, 2))) as TLT FROM `günlük_kasa` GROUP BY HANGI_YIL";

            datagridYillikKasa.DataSource = database.ListData(sql);

            datagridYillikKasa.Columns[0].HeaderText = "HANGİ YIL?";
            datagridYillikKasa.Columns[1].HeaderText = "EURO";
            datagridYillikKasa.Columns[2].HeaderText = "DOLAR";
            datagridYillikKasa.Columns[3].HeaderText = "TL";



            string sqlay = "select aylar, SUM(CAST(REPLACE(Euro, ',', '.') as DECIMAL(9, 2))) as EuroT, SUM(CAST(REPLACE(Dolar, ',', '.') as DECIMAL(9, 2))) as DolarT, SUM(CAST(REPLACE(TL, ',', '.') as DECIMAL(9, 2))) as TLT FROM `günlük_kasa` GROUP BY aylar";

            dtgridaylikkasa.DataSource = database.ListData(sqlay);

            dtgridaylikkasa.Columns[0].HeaderText = "HANGİ AY?";
            dtgridaylikkasa.Columns[1].HeaderText = "EURO";
            dtgridaylikkasa.Columns[2].HeaderText = "DOLAR";
            dtgridaylikkasa.Columns[3].HeaderText = "TL";
        }
        private void listele()
        {
            string yil, ay, gun, tarih, tarih_2;

            dataGridgKasa.Columns.Clear();

            DatabaseClass database = new DatabaseClass();
            //
            DateTime DTIME = dateTimePicker1.Value;

            yil = DTIME.Date.Year.ToString();
            ay  = DTIME.Date.Month.ToString();
            gun = DTIME.Date.Day.ToString();

            if (ay.Length <= 1)
            {
                ay = "0" + ay;
            }
            if (gun.Length <= 1)
            {
                gun = "0" + gun;
            }

            tarih = yil + "-" + ay + "-" + gun;
            DateTime DTIME2 = dateTimePicker2.Value;

            yil = DTIME2.Date.Year.ToString();
            ay  = DTIME2.Date.Month.ToString();
            gun = DTIME2.Date.Day.ToString();

            if (ay.Length <= 1)
            {
                ay = "0" + ay;
            }
            if (gun.Length <= 1)
            {
                gun = "0" + gun;
            }


            tarih_2 = yil + "-" + ay + "-" + gun;

            String tarih1 = tarih;
            String tarih2 = tarih_2;
            //

            /* TARİH BAZLIYA DÖNÜŞTÜRÜLDÜ
             * yil = DateTime.Now.Date.Year.ToString();
             * ay = DateTime.Now.Date.Month.ToString();
             * gun = DateTime.Now.Date.Day.ToString();
             *
             * string secili_gun, secili_gunt; // henuz kullanılmıyor.
             * if (gun.Length > 1)
             * {
             *  secili_gun = (Convert.ToDouble(gun) - 1).ToString();
             *  secili_gunt = secili_gun + "/" + ay + "/" + yil;
             * }
             * else
             * {
             *  secili_gun = "0";
             *  secili_gunt = gun + "/" + ay + "/" + yil;
             * }
             *
             * string secili_ay;
             * if (ay.Length > 1)
             * {
             *  secili_ay =ay + "/" + yil;
             * }
             * else secili_ay = "0" + ay + "/" + yil;*/

            string sql = "Select `Tarih`, `TL`, `Euro`, `Dolar` from günlük_kasa WHERE Tarih between '" + tarih1 + "' and '" + tarih2 + "' ORDER BY Tarih";;

            dataGridgKasa.DataSource = database.ListData(sql);

            dataGridgKasa.Columns[0].HeaderText = "TARİH";

            dataGridgKasa.Columns[1].HeaderText = "TL";
            dataGridgKasa.Columns[2].HeaderText = "EURO";
            dataGridgKasa.Columns[3].HeaderText = "DOLAR";


            // dataGridgKasa.Columns[0].Visible = false;
            if (dataGridgKasa.RowCount > 1)
            {
                double veresiyeToplamE  = 0;
                double veresiyeToplamD  = 0;
                double veresiyeToplamTl = 0;


                for (int i = 0; i < dataGridgKasa.Rows.Count; i++)
                {
                    veresiyeToplamTl += Convert.ToDouble(dataGridgKasa.Rows[i].Cells[1].Value);
                    veresiyeToplamE  += Convert.ToDouble(dataGridgKasa.Rows[i].Cells[2].Value);
                    veresiyeToplamD  += Convert.ToDouble(dataGridgKasa.Rows[i].Cells[3].Value);
                }

                lblEuro.Text  = "€ : " + veresiyeToplamE.ToString();
                lblDolar.Text = "$ : " + veresiyeToplamD.ToString();
                lblTL.Text    = "TL : " + veresiyeToplamTl.ToString();

                /*List<string> topalmdegerler = database.ListDatatab(secili_ay);
                 * lblEuro.Text = " € : " + topalmdegerler[0];
                 * lblDolar.Text = " $ : " + topalmdegerler[1];
                 * lblTL.Text = " TL : " + topalmdegerler[2];*/

                dataGridgKasa.ClearSelection();
                // dataGridgKasa.Rows[dataGridgKasa.RowCount - 2].Selected = true;

                int nRowIndex    = dataGridgKasa.Rows.Count - 1;
                int nColumnIndex = 2;

                dataGridgKasa.Rows[nRowIndex].Selected = true;
                dataGridgKasa.Rows[nRowIndex].Cells[nColumnIndex].Selected = true;
                dataGridgKasa.CurrentCell = dataGridgKasa.Rows[nRowIndex].Cells[nColumnIndex];
                //In case if you want to scroll down as well.
                //  dataGridgKasa.FirstDisplayedScrollingRowIndex = nRowIndex;
                kasadevirHesapla();
                veresiyeHesapla();
            }
            else
            {
                lblEuro.Text  = " € : 0";
                lblDolar.Text = " $ : 0";
                lblTL.Text    = " TL : 0";
            }
        }