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 datagrid1Doldur(DatabaseClass database, bool tarihBazli) { string sorgu = ""; string yil, ay, gun, tarih, tarih_2; dataGridView1.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; 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; if (tarihBazli) { sorgu = "SELECT `ID`, `TL`, `DOLAR`, `EURO`, `Tarih`, `P_ID` FROM `para_degerleri` WHERE Tarih between '" + tarih1 + "' and '" + tarih2 + "' ORDER by Tarih , P_ID"; } else { sorgu = "Select * FROM `para_degerleri` "; } int num = 0; foreach (ParaDegerleriGelir gelir in database.gelirDegerleri(sorgu)) { if (gelir.P_ID == 1) { DateTime time = Convert.ToDateTime(gelir.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 _tarih = string.Concat(textArray1); object[] values = new object[] { _tarih, gelir.EURO, gelir.DOLAR, gelir.TL }; this.dataGridView1.Rows.Add(values); continue; } if (gelir.P_ID == 2) { this.dataGridView1.Rows[num].Cells[4].Value = gelir.EURO; this.dataGridView1.Rows[num].Cells[5].Value = gelir.DOLAR; this.dataGridView1.Rows[num].Cells[6].Value = gelir.TL; continue; } if (gelir.P_ID == 3) { this.dataGridView1.Rows[num].Cells[7].Value = gelir.EURO; this.dataGridView1.Rows[num].Cells[8].Value = gelir.DOLAR; this.dataGridView1.Rows[num].Cells[9].Value = gelir.TL; continue; } if (gelir.P_ID == 4) { this.dataGridView1.Rows[num].Cells[10].Value = gelir.EURO; this.dataGridView1.Rows[num].Cells[11].Value = gelir.DOLAR; this.dataGridView1.Rows[num].Cells[12].Value = gelir.TL; continue; } if (gelir.P_ID == 5) { this.dataGridView1.Rows[num].Cells[13].Value = gelir.EURO; this.dataGridView1.Rows[num].Cells[14].Value = gelir.DOLAR; this.dataGridView1.Rows[num].Cells[15].Value = gelir.TL; num++; } } this.dataGridView1.Rows.Add(this.dataGridView1.Rows[num - 1].Cells[0].Value.ToString()); //boş satır için son tarih bilgisi eklendi satır başı için eklendi this.dataGridView1.Rows.Add(this.dataGridView1.Rows[num - 1].Cells[0].Value.ToString()); //boş satır için son tarih bilgisi eklendi satır başı için eklendi this.dataGridView1.Columns[0].HeaderText = "TARİH"; this.dataGridView1.Columns[1].HeaderText = "EURO"; this.dataGridView1.Columns[2].HeaderText = "DOLAR"; this.dataGridView1.Columns[3].HeaderText = "TL"; this.dataGridView1.Columns[4].HeaderText = "EURO"; this.dataGridView1.Columns[5].HeaderText = "DOLAR"; this.dataGridView1.Columns[6].HeaderText = "TL"; this.dataGridView1.Columns[7].HeaderText = "EURO"; this.dataGridView1.Columns[8].HeaderText = "DOLAR"; this.dataGridView1.Columns[9].HeaderText = "TL"; this.dataGridView1.Columns[10].HeaderText = "EURO"; this.dataGridView1.Columns[11].HeaderText = "DOLAR"; this.dataGridView1.Columns[12].HeaderText = "TL"; this.dataGridView1.Columns[13].HeaderText = "EURO"; this.dataGridView1.Columns[14].HeaderText = "DOLAR"; this.dataGridView1.Columns[15].HeaderText = "TL"; int num3 = 0; this.dataGridView1.ColumnHeadersHeight = 24; while (true) { if (num3 >= this.dataGridView1.ColumnCount) { this.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing; this.dataGridView1.ColumnHeadersHeight *= 2; this.dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter; this.dataGridView1.CellPainting += new DataGridViewCellPaintingEventHandler(this.dataGridView1_CellPainting); this.dataGridView1.Paint += new PaintEventHandler(this.dataGridView1_Paint); this.dataGridView1.Scroll += new ScrollEventHandler(this.dataGridView1_Scroll); this.dataGridView1.ColumnWidthChanged += new DataGridViewColumnEventHandler(this.dataGridView1_ColumnWidthChanged); return; } this.dataGridView1.Columns[num3].Width = 2; num3++; } }