private void datetpislemtarihi_ValueChanged(object sender, EventArgs e)
        {
            string yil, ay, gun, tarih;

            try
            {
                DateTime DTIME = Convert.ToDateTime(datetpislemtarihi.Text);
                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 `ID`, `TL`, `DOLAR`, `EURO`, `Tarih`, `P_ID` FROM `para_degerleri` WHERE Tarih = '" + tarih + "'";
                List <ParaDegerleriGelir> gelirler = database.gelirDegerleri(sorgu);

                if (gelirler.Count > 0)
                {
                    foreach (ParaDegerleriGelir gelir in gelirler)
                    {
                        if (gelir.P_ID == 1)
                        {
                            tb_gunluksTL.Text = gelir.TL.ToString();
                            tb_gunluksE.Text  = gelir.EURO.ToString();
                            tb_gunluksD.Text  = gelir.DOLAR.ToString();
                            continue;
                        }
                        if (gelir.P_ID == 2)
                        {
                            tb_veresiyesTL.Text = gelir.TL.ToString();
                            tb_veresiyesE.Text  = gelir.EURO.ToString();
                            tb_veresiyesD.Text  = gelir.DOLAR.ToString();
                            continue;
                        }
                        if (gelir.P_ID == 3)
                        {
                            tb_veresiyetahTL.Text = gelir.TL.ToString();
                            tb_veresiyetahE.Text  = gelir.EURO.ToString();
                            tb_veresiyetahD.Text  = gelir.DOLAR.ToString();
                            continue;
                        }
                        if (gelir.P_ID == 4)
                        {
                            tb_kksatisTL.Text = gelir.TL.ToString();
                            tb_kksatisE.Text  = gelir.EURO.ToString();
                            tb_kksatisD.Text  = gelir.DOLAR.ToString();
                            continue;
                        }
                        if (gelir.P_ID == 5)
                        {
                            tbkaporaTL.Text = gelir.TL.ToString();
                            tbkaporaE.Text  = gelir.EURO.ToString();
                            tbkaporaD.Text  = gelir.DOLAR.ToString();
                            continue;
                        }
                    }

                    //gridviewde select yapsın

                    /* dataGridgKasa.ClearSelection();
                     * int rowIndex = -1;
                     * string aranacakDeger = datetpislemtarihi.Text;
                     *
                     * DataGridViewRow row = dataGridgKasa.Rows
                     *    .Cast<DataGridViewRow>()
                     *    .First(r => r.Cells[0].Value.ToString().Equals(aranacakDeger));
                     *
                     * rowIndex = row.Index;
                     *
                     * dataGridgKasa.Rows[rowIndex].Selected = true;*/
                }
                else
                {
                    degerleri_temizle();
                }

                string sorgu2 = "SELECT `ID`, `TL`, `DOLAR`, `EURO`, `Tarih`, `P_ID` FROM `para_degerleri_giderler` WHERE Tarih = '" + tarih + "'";
                List <ParaDegerleriGider> giderler = database.giderDegerleri(sorgu2);

                if (giderler.Count > 0)
                {
                    foreach (ParaDegerleriGider gider in giderler)
                    {
                        if (gider.P_ID == 1)
                        {
                            tb_dukkangiderTL.Text = gider.TL.ToString();
                            tb_dukkangiderE.Text  = gider.EURO.ToString();
                            tb_dukkangiderD.Text  = gider.DOLAR.ToString();
                            continue;
                        }
                        if (gider.P_ID == 2)
                        {
                            tb_iadealinanTL.Text = gider.TL.ToString();
                            tb_iadealinanE.Text  = gider.EURO.ToString();
                            tb_iadealinanD.Text  = gider.DOLAR.ToString();
                            continue;
                        }
                        if (gider.P_ID == 3)
                        {
                            tb_firmaödTL.Text = gider.TL.ToString();
                            tb_firmaödE.Text  = gider.EURO.ToString();
                            tb_firmaödD.Text  = gider.DOLAR.ToString();
                            continue;
                        }
                        if (gider.P_ID == 4)
                        {
                            tb_pesinalinanTL.Text = gider.TL.ToString();
                            tb_pesinalinanE.Text  = gider.EURO.ToString();
                            tb_pesinalinanD.Text  = gider.DOLAR.ToString();
                            continue;
                        }
                        if (gider.P_ID == 5)
                        {
                            tb_ResulDödemeTL.Text = gider.TL.ToString();
                            tb_ResulDödemeE.Text  = gider.EURO.ToString();
                            tb_ResulDödemeD.Text  = gider.DOLAR.ToString();
                            continue;
                        }
                        if (gider.P_ID == 6)
                        {
                            tb_eleman1TL.Text = gider.TL.ToString();
                            tb_eleman1E.Text  = gider.EURO.ToString();
                            tb_eleman1D.Text  = gider.DOLAR.ToString();
                            continue;
                        }
                        if (gider.P_ID == 7)
                        {
                            tb_eleman2TL.Text = gider.TL.ToString();
                            tb_eleman2E.Text  = gider.EURO.ToString();
                            tb_eleman2D.Text  = gider.DOLAR.ToString();
                            continue;
                        }
                    }
                }
                else
                {
                    degerleri_temizle();
                }
            }
            catch (Exception e21)
            {
                Console.Write(e21);
            }
        }
        private void datagrid2Doldur(DatabaseClass database, bool tarihBazli)
        {
            string sorgu = "";
            string yil, ay, gun, tarih, tarih_2, yil2, ay2, gun2;

            dataGridView2.Rows.Clear();

            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;

            yil2 = DTIME2.Date.Year.ToString();
            ay2  = DTIME2.Date.Month.ToString();
            gun2 = DTIME2.Date.Day.ToString();

            if (ay2.Length <= 1)
            {
                ay2 = "0" + ay2;
            }
            if (gun2.Length <= 1)
            {
                gun2 = "0" + gun2;
            }
            tarih_2 = yil2 + "-" + ay2 + "-" + gun2;

            String tarih1 = tarih;
            String tarih2 = tarih_2;


            if (tarihBazli)
            {
                sorgu = "SELECT `ID`, `TL`, `DOLAR`, `EURO`, `Tarih`, `P_ID` FROM `para_degerleri_giderler` WHERE Tarih between '" + tarih1 + "' and '" + tarih2 + "' ORDER by Tarih , P_ID";
            }
            else
            {
                sorgu = "Select * FROM `para_degerleri_giderler` ";
            }

            int num = 0;

            foreach (ParaDegerleriGider gider in database.giderDegerleri(sorgu))
            {
                if (gider.P_ID == 1)
                {
                    DateTime time = Convert.ToDateTime(gider.Tarih.ToString());
                    string   str2 = time.Date.Year.ToString();
                    string   str3 = time.Date.Month.ToString();
                    string   str4 = time.Date.Day.ToString();
                    if (str3.Length <= 1)
                    {
                        str3 = "0" + str3;
                    }
                    if (str4.Length <= 1)
                    {
                        str4 = "0" + str4;
                    }
                    string[] textArray1 = new string[] { str4, "-", str3, "-", str2 };
                    string   str5       = string.Concat(textArray1);
                    object[] values     = new object[] { str5, gider.EURO, gider.DOLAR, gider.TL };
                    this.dataGridView2.Rows.Add(values);
                    continue;
                }

                if (gider.P_ID == 2)
                {
                    this.dataGridView2.Rows[num].Cells[4].Value = gider.EURO;
                    this.dataGridView2.Rows[num].Cells[5].Value = gider.DOLAR;
                    this.dataGridView2.Rows[num].Cells[6].Value = gider.TL;
                    continue;
                }
                if (gider.P_ID == 3)
                {
                    this.dataGridView2.Rows[num].Cells[7].Value = gider.EURO;
                    this.dataGridView2.Rows[num].Cells[8].Value = gider.DOLAR;
                    this.dataGridView2.Rows[num].Cells[9].Value = gider.TL;
                    continue;
                }
                if (gider.P_ID == 4)
                {
                    this.dataGridView2.Rows[num].Cells[10].Value = gider.EURO;
                    this.dataGridView2.Rows[num].Cells[11].Value = gider.DOLAR;
                    this.dataGridView2.Rows[num].Cells[12].Value = gider.TL;
                    continue;
                }
                if (gider.P_ID == 5)
                {
                    this.dataGridView2.Rows[num].Cells[13].Value = gider.EURO;
                    this.dataGridView2.Rows[num].Cells[14].Value = gider.DOLAR;
                    this.dataGridView2.Rows[num].Cells[15].Value = gider.TL;
                    continue;
                }
                if (gider.P_ID == 6)
                {
                    this.dataGridView2.Rows[num].Cells[16].Value = gider.EURO;
                    this.dataGridView2.Rows[num].Cells[17].Value = gider.DOLAR;
                    this.dataGridView2.Rows[num].Cells[18].Value = gider.TL;
                    continue;
                }
                if (gider.P_ID == 7)
                {
                    this.dataGridView2.Rows[num].Cells[19].Value = gider.EURO;
                    this.dataGridView2.Rows[num].Cells[20].Value = gider.DOLAR;
                    this.dataGridView2.Rows[num].Cells[21].Value = gider.TL;
                    num++;
                }
            }
            this.dataGridView2.Rows.Add(this.dataGridView2.Rows[num - 1].Cells[0].Value.ToString()); //boş satır için son tarih bilgisi eklendi satır başı için eklendi
            this.dataGridView2.Rows.Add(this.dataGridView2.Rows[num - 1].Cells[0].Value.ToString()); //boş satır için son tarih bilgisi eklendi satır başı için eklendi

            this.dataGridView2.Columns[0].HeaderText  = "TARİH";
            this.dataGridView2.Columns[1].HeaderText  = "EURO";
            this.dataGridView2.Columns[2].HeaderText  = "DOLAR";
            this.dataGridView2.Columns[3].HeaderText  = "TL";
            this.dataGridView2.Columns[4].HeaderText  = "EURO";
            this.dataGridView2.Columns[5].HeaderText  = "DOLAR";
            this.dataGridView2.Columns[6].HeaderText  = "TL";
            this.dataGridView2.Columns[7].HeaderText  = "EURO";
            this.dataGridView2.Columns[8].HeaderText  = "DOLAR";
            this.dataGridView2.Columns[9].HeaderText  = "TL";
            this.dataGridView2.Columns[10].HeaderText = "EURO";
            this.dataGridView2.Columns[11].HeaderText = "DOLAR";
            this.dataGridView2.Columns[12].HeaderText = "TL";
            this.dataGridView2.Columns[13].HeaderText = "EURO";
            this.dataGridView2.Columns[14].HeaderText = "DOLAR";
            this.dataGridView2.Columns[15].HeaderText = "TL";
            this.dataGridView2.Columns[16].HeaderText = "EURO";
            this.dataGridView2.Columns[17].HeaderText = "DOLAR";
            this.dataGridView2.Columns[18].HeaderText = "TL";
            this.dataGridView2.Columns[19].HeaderText = "EURO";
            this.dataGridView2.Columns[20].HeaderText = "DOLAR";
            this.dataGridView2.Columns[21].HeaderText = "TL";
            int num3 = 0;

            this.dataGridView2.ColumnHeadersHeight = 24;
            while (true)
            {
                if (num3 >= this.dataGridView2.ColumnCount)
                {
                    this.dataGridView2.ColumnHeadersHeightSizeMode             = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
                    this.dataGridView2.ColumnHeadersHeight                    *= 2;
                    this.dataGridView2.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
                    this.dataGridView2.CellPainting       += new DataGridViewCellPaintingEventHandler(this.dataGridView2_CellPainting);
                    this.dataGridView2.Paint              += new PaintEventHandler(this.dataGridView2_Paint);
                    this.dataGridView2.Scroll             += new ScrollEventHandler(this.dataGridView2_Scroll);
                    this.dataGridView2.ColumnWidthChanged += new DataGridViewColumnEventHandler(this.dataGridView2_ColumnWidthChanged);
                    return;
                }
                this.dataGridView2.Columns[num3].Width = 2;


                num3++;

                if (dataGridView2.RowCount > 1)
                {
                    double veresiyeToplamE  = 0;
                    double veresiyeToplamD  = 0;
                    double veresiyeToplamTl = 0;


                    for (int i = 0; i < dataGridView2.Rows.Count; i++)
                    {
                        veresiyeToplamTl += Convert.ToDouble(dataGridView2.Rows[i].Cells[4].Value);
                        veresiyeToplamE  += Convert.ToDouble(dataGridView2.Rows[i].Cells[5].Value);
                        veresiyeToplamD  += Convert.ToDouble(dataGridView2.Rows[i].Cells[6].Value);
                    }

                    label7.Text  = "€ : " + veresiyeToplamE.ToString();
                    label8.Text  = "$ : " + veresiyeToplamD.ToString();
                    label10.Text = "TL : " + veresiyeToplamTl.ToString();
                }
            }
            //
        }