Forum

c# datagridviewde t...
 
Bildirimler
Hepsini Temizle

c# datagridviewde timer picker ile dinamik veri gosterimi

7 Yazılar
2 Üyeler
0 Reactions
1,030 Görüntüleme
(@inanodabasi)
Gönderiler: 130
Estimable Member
Konu başlatıcı
 

iyi gunler...ben yazdigim programda datagridviewde timer kullanarak her dakika guncel veri cekiyorum ve burdan odemeleri takip ediyorlar,odemesi biten faturalar ise otomatikmen gridde gizleniyor ve gozukmuyor...buraya kadar normal hersey...sirkete koydugum LCD ile herkes bu guncel tabloyu goruyor...yanliz cok fazla kayit oldugu icin gridde gozukmeyen kisimlari goremiyorlar...ben havaalanlarinda ucaklarin kalkis inislerini gosteren panolar tarzi her dakika ekrana 10 kayit gostersin ve surekli bu sekilde devir dayim olsun...birinci dakika ilk 10 kaydi,sonraki dakika 10.kayittan sonraki 10 adet kaydi,sonraki dakikada devami,hepsi bitincede yeniden en bastaki ilk kayidi gostererek,islemi surekli tekrar etsin...bu konuda yardimci olabilirseniz cok sevinirim...tskler

 
Gönderildi : 27/02/2012 17:55

(@YavuzKIVANC)
Gönderiler: 32
Eminent Member
 

Merhaba,

Sorguladığın tablo/view den 10 arlı gruplar halinde data çekebilirsin.

Ör:  

degisken+=10; //doğal olarak bir süre sonra 0 lanmalı

select * from tablo where id=degisken%kayitSayisi

 
Gönderildi : 27/02/2012 18:19

(@inanodabasi)
Gönderiler: 130
Estimable Member
Konu başlatıcı
 
 private void dgvmonitor_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            int sayi = 0;
            DataTable mydatatable = sqlbaglanti.verigetir(@"SELECT *
FROM _SIP LEFT join _SAT on _SAT.LOGICALREF =_SIP.SIPREF LEFT join _ODEME on _ODEME.SIPREF=_SIP.SIPREF LEFT join _DEPO on   _DEPO.SIPREF=_SIP.SIPREF
    ", out sayi);
            //mydatatable.Rows[I]["OD.TUTAR"].ToString() != null && mydatatable.Rows[I]["DEP.TESLIMEDILEN"].ToString() != null && 
            for (int I = 0; I < dgvmonitor.Rows.Count - 1; I++)
            {
                dgvmonitor.Rows[I].Cells[0].Style.Font = new System.Drawing.Font("times new roman", 13, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[1].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[2].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[3].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[4].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[5].Style.Font = new System.Drawing.Font("times new roman", 13, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[6].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[7].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[8].Style.Font = new System.Drawing.Font("times new roman", 13, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[9].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[10].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[11].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[12].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[13].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[14].Style.Font = new System.Drawing.Font("times new roman", 13, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[15].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[I].Cells[16].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                if (Convert.ToString(dgvmonitor.Rows[I].Cells[7].Value.ToString()) != Convert.ToString(DBNull.Value) && Convert.ToString(dgvmonitor.Rows[I].Cells[10].Value.ToString()) == Convert.ToString(DBNull.Value) && Convert.ToString(dgvmonitor.Rows[I].Cells[12].Value.ToString()) == Convert.ToString(DBNull.Value) && Convert.ToString(dgvmonitor.Rows[I].Cells[16].Value.ToString()) == Convert.ToString(DBNull.Value))
                {
                    dgvmonitor.Rows[I].Cells[0].Style.BackColor = Color.Blue;
                    dgvmonitor.Rows[I].Cells[1].Style.BackColor = Color.Blue;
                    dgvmonitor.Rows[I].Cells[2].Style.BackColor = Color.Blue;
                    dgvmonitor.Rows[I].Cells[3].Style.BackColor = Color.Blue;
                    dgvmonitor.Rows[I].Cells[4].Style.BackColor = Color.Blue;
                    dgvmonitor.Rows[I].Cells[5].Style.BackColor = Color.Blue;
                    dgvmonitor.Rows[I].Cells[6].Style.BackColor = Color.Blue;
                    dgvmonitor.Rows[I].Cells[7].Style.BackColor = Color.Blue;
                    dgvmonitor.Rows[I].DefaultCellStyle.BackColor = Color.DarkGray;
                    dgvmonitor.Rows[I].DefaultCellStyle.ForeColor = Color.White;
                }
                else
                    if (Convert.ToString(dgvmonitor.Rows[I].Cells[7].Value.ToString()) != Convert.ToString(DBNull.Value) && Convert.ToString(dgvmonitor.Rows[I].Cells[10].Value.ToString()) != Convert.ToString(DBNull.Value) && Convert.ToString(dgvmonitor.Rows[I].Cells[12].Value.ToString()) == Convert.ToString(DBNull.Value) && Convert.ToString(dgvmonitor.Rows[I].Cells[16].Value.ToString()) == Convert.ToString(DBNull.Value))
                    {
                        dgvmonitor.Rows[I].Cells[0].Style.BackColor = Color.Blue;
                        dgvmonitor.Rows[I].Cells[1].Style.BackColor = Color.Blue;
                        dgvmonitor.Rows[I].Cells[2].Style.BackColor = Color.Blue;
                        dgvmonitor.Rows[I].Cells[3].Style.BackColor = Color.Blue;
                        dgvmonitor.Rows[I].Cells[4].Style.BackColor = Color.Blue;
                        dgvmonitor.Rows[I].Cells[5].Style.BackColor = Color.Blue;
                        dgvmonitor.Rows[I].Cells[6].Style.BackColor = Color.Blue;
                        dgvmonitor.Rows[I].Cells[7].Style.BackColor = Color.Blue;
                        dgvmonitor.Rows[I].Cells[8].Style.BackColor = Color.Blue;
                        dgvmonitor.Rows[I].Cells[9].Style.BackColor = Color.Blue;
                        dgvmonitor.Rows[I].Cells[10].Style.BackColor = Color.Blue;
                        dgvmonitor.Rows[I].DefaultCellStyle.BackColor = Color.DarkGray;
                        dgvmonitor.Rows[I].DefaultCellStyle.ForeColor = Color.White;
                    }
                    else
                        if (Convert.ToString(dgvmonitor.Rows[I].Cells[7].Value.ToString()) != Convert.ToString(DBNull.Value) && Convert.ToString(dgvmonitor.Rows[I].Cells[10].Value.ToString()) != Convert.ToString(DBNull.Value) && Convert.ToString(dgvmonitor.Rows[I].Cells[12].Value.ToString()) != Convert.ToString(DBNull.Value) && Convert.ToString(dgvmonitor.Rows[I].Cells[16].Value.ToString()) == Convert.ToString(DBNull.Value))
                        {
                            dgvmonitor.Rows[I].Cells[0].Style.BackColor = Color.Blue;
                            dgvmonitor.Rows[I].Cells[1].Style.BackColor = Color.Blue;
                            dgvmonitor.Rows[I].Cells[2].Style.BackColor = Color.Blue;
                            dgvmonitor.Rows[I].Cells[3].Style.BackColor = Color.Blue;
                            dgvmonitor.Rows[I].Cells[4].Style.BackColor = Color.Blue;
                            dgvmonitor.Rows[I].Cells[5].Style.BackColor = Color.Blue;
                            dgvmonitor.Rows[I].Cells[6].Style.BackColor = Color.Blue;
                            dgvmonitor.Rows[I].Cells[7].Style.BackColor = Color.Blue;
                            dgvmonitor.Rows[I].Cells[8].Style.BackColor = Color.Blue;
                            dgvmonitor.Rows[I].Cells[9].Style.BackColor = Color.Blue;
                            dgvmonitor.Rows[I].Cells[10].Style.BackColor = Color.Blue;
                            dgvmonitor.Rows[I].Cells[11].Style.BackColor = Color.Blue;
                            dgvmonitor.Rows[I].Cells[12].Style.BackColor = Color.Blue;
                            dgvmonitor.Rows[I].DefaultCellStyle.BackColor = Color.DarkGray;
                            dgvmonitor.Rows[I].DefaultCellStyle.ForeColor = Color.White;
                        }
                        else
                            if (Convert.ToString(dgvmonitor.Rows[I].Cells[7].Value.ToString()) != Convert.ToString(DBNull.Value) && Convert.ToString(dgvmonitor.Rows[I].Cells[10].Value.ToString()) != Convert.ToString(DBNull.Value) && Convert.ToString(dgvmonitor.Rows[I].Cells[12].Value.ToString()) != Convert.ToString(DBNull.Value) && Convert.ToString(dgvmonitor.Rows[I].Cells[16].Value.ToString()) != Convert.ToString(DBNull.Value))
                            {
                                //dgvmonitor.Rows[I].Cells[0].Style.BackColor = Color.DeepSkyBlue;
                                //dgvmonitor.Rows[I].Cells[1].Style.BackColor = Color.DeepSkyBlue;
                                //dgvmonitor.Rows[I].Cells[2].Style.BackColor = Color.DeepSkyBlue;
                                //dgvmonitor.Rows[I].Cells[3].Style.BackColor = Color.DeepSkyBlue;
                                //dgvmonitor.Rows[I].Cells[4].Style.BackColor = Color.DeepSkyBlue;
                                //dgvmonitor.Rows[I].Cells[5].Style.BackColor = Color.DeepSkyBlue;
                                //dgvmonitor.Rows[I].Cells[6].Style.BackColor = Color.DeepSkyBlue;
                                //dgvmonitor.Rows[I].Cells[7].Style.BackColor = Color.DeepSkyBlue;
                                //dgvmonitor.Rows[I].Cells[8].Style.BackColor = Color.DeepSkyBlue;
                                //dgvmonitor.Rows[I].Cells[9].Style.BackColor = Color.DeepSkyBlue;
                                //dgvmonitor.Rows[I].Cells[10].Style.BackColor = Color.DeepSkyBlue;
                                //dgvmonitor.Rows[I].Cells[11].Style.BackColor = Color.DeepSkyBlue;
                                //dgvmonitor.Rows[I].Cells[12].Style.BackColor = Color.DeepSkyBlue;
                                dgvmonitor.Rows[I].DefaultCellStyle.BackColor = Color.Blue;
                                dgvmonitor.Rows[I].DefaultCellStyle.ForeColor = Color.White;
                            }
            }
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            int sayi = 0;
            //string select = "SELECT [SIPARISNO] ,[SIPARISTARIHI],[SIPARISVEREN],[SIPARISALAN],[ALIMSHOTNO] ,[ALIMSHOTTARIHI],[ALIMTUTAR] ,[ODEMENO],[ODEMETARIHI] ,[DEPOTESLIMTARIHI] ,[FATURANO],[TESLIMALAN]  ,[URETIMTESLIMALAN],[DURUM] ,[BANKA] ,[PLATOSHKANO],[PRICE]FROM [SIP2012].[dbo].[SIPFATURA]";
            //dgvmonitor.DataSource = sqlbaglanti.verigetir(select, out sayi);
            dgvmonitor.DataSource = sqlbaglanti.verigetir(@"SELECT *
            FROM
            (SELECT *,
            (select od.FISHENO from _ODEME od where  od.SIPREF = A.SIPLOG) AS [№ ПЛАТЕЖКИ],
            (select DATE_ from _ODEME od where  od.SIPREF = A.SIPLOG) AS [ДАТА ПЛАТЕЖКИ],
            (select TUTAR from _ODEME od where  od.SIPREF = A.SIPLOG) AS [СУММА ПЛАТЕЖКИ],
            (select DATE_ from _TRANSPORT TR where  TR.SIPREF = A.SIPLOG) AS [ДАТА ТРАНСПОРТИРОВКИ],
            (select FIRMA from _TRANSPORT TR where  TR.SIPREF = A.SIPLOG) AS [ТРАНСПОРТНАЯ ФИРМА],
            (select DATE_ from _DEPO dep where dep.SIPREF = A.SIPLOG) AS [ДАТА ПОЛУЧЕНИЕ (СКЛАД)],
            (select FATURANO from _DEPO dep where dep.SIPREF = A.SIPLOG) AS [№ СЧЕТ ФАТУРЫ],
            (select TESLIMALAN from _DEPO dep where dep.SIPREF = A.SIPLOG) AS [КТО ПРИНЯЛ (СКЛАД)],
            (select TESLIMEDILEN from _DEPO dep where dep.SIPREF = A.SIPLOG) AS [КОМУ ПЕРЕДАНО (СКЛАД)]
            FROM
            (select sat.FISHENO AS [№ ЗАЯВКИ],sat.DATE_ AS [ДАТА ЗАЯВКИ],sat.[SIPARISI VEREN] AS[ЗАКАЗЧИК],sat.[SIPARISI ALAN] AS [ПРИНЯЛ ЗАКАЗ],
            SIP.LOGICALREF AS SIPLOG,SIP.FISHENO AS [№ СЧЕТА],SIP.DATE_ AS [ДАТА СЧЕТА],SIP.TOTAL AS [СУММА СЧЕТА]
            from _SAT sat
            INNER JOIN _SIP SIP ON sat.LOGICALREF =SIP.SIPREF where SIP.ACTIVE = 0) A)B
                
            
                ", out sayi);
            //dgvmonitor.Rows[0].Cells[1].Style.BackColor = Color.Khaki;
            int sayim = Convert.ToInt32(dgvmonitor.Columns.Count);
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            dgvmonitor.ColumnHeadersHeight.ToString(Convert.ToString(50));
            btnok.BackColor = Color.Blue;
            btnok.ForeColor = Color.Red;
            btnbekle.BackColor = Color.Gray;
            btnbekle.Font = new System.Drawing.Font("Tahoma", 9, FontStyle.Bold);
            btnbekle.ForeColor = Color.Red;
            //StatusBar stat = new StatusBar();
            //stat.Panels.Add("ILK PANEL");
            //stat.Panels[0].Text = "ODABASI YAZILIM";
            //stat.Panels[0].AutoSize = StatusBarPanelAutoSize.Spring;
            //stat.Panels[0].BorderStyle = StatusBarPanelBorderStyle.None;
            //stat.ShowPanels = true;
            timer1.Start();
            timer2.Stop();
            int sayi = 0;
            dgvmonitor.DataSource = sqlbaglanti.verigetir(@"SELECT *
FROM
(SELECT *,
(select od.FISHENO from _ODEME od where  od.SIPREF = A.SIPLOG) AS [№ ПЛАТЕЖКИ],
(select DATE_ from _ODEME od where  od.SIPREF = A.SIPLOG) AS [ДАТА ПЛАТЕЖКИ],
(select TUTAR from _ODEME od where  od.SIPREF = A.SIPLOG) AS [СУММА ПЛАТЕЖКИ],
(select DATE_ from _TRANSPORT TR where  TR.SIPREF = A.SIPLOG) AS [ДАТА ТРАНСПОРТИРОВКИ],
(select FIRMA from _TRANSPORT TR where  TR.SIPREF = A.SIPLOG) AS [ТРАНСПОРТНАЯ ФИРМА],
(select DATE_ from _DEPO dep where dep.SIPREF = A.SIPLOG) AS [ДАТА ПОЛУЧЕНИЕ (СКЛАД)],
(select FATURANO from _DEPO dep where dep.SIPREF = A.SIPLOG) AS [№ СЧЕТ ФАТУРЫ],
(select TESLIMALAN from _DEPO dep where dep.SIPREF = A.SIPLOG) AS [КТО ПРИНЯЛ (СКЛАД)],
(select TESLIMEDILEN from _DEPO dep where dep.SIPREF = A.SIPLOG) AS [КОМУ ПЕРЕДАНО (СКЛАД)]
FROM
(select sat.FISHENO AS [№ ЗАЯВКИ],sat.DATE_ AS [ДАТА ЗАЯВКИ],sat.[SIPARISI VEREN] AS[ЗАКАЗЧИК],sat.[SIPARISI ALAN] AS [ПРИНЯЛ ЗАКАЗ],
SIP.LOGICALREF AS SIPLOG,SIP.FISHENO AS [№ СЧЕТА],SIP.DATE_ AS [ДАТА СЧЕТА],SIP.TOTAL AS [СУММА СЧЕТА]
from _SAT sat
INNER JOIN _SIP SIP ON sat.LOGICALREF =SIP.SIPREF where SIP.ACTIVE = 0) A)B
    ", out sayi);
            dgvmonitor.ColumnHeadersDefaultCellStyle.ForeColor = Color.Yellow;
            dgvmonitor.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("Tahoma", 9, FontStyle.Bold);
            dgvmonitor.Columns[4].Visible = false;
            int sayim = Convert.ToInt32(dgvmonitor.Columns.Count);
            for (int i = 0; i < sayim; i++)
            {
                DataGridViewColumn column = dgvmonitor.Columns[i];
                column.Width = 82;
                DataGridViewRow satir = dgvmonitor.Rows[i];
                satir.Height = 40;
                DataGridViewCellStyle style = dgvmonitor.Rows[i].Cells[1].Style;
                dgvmonitor.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("times new roman", 11, FontStyle.Bold);
                // dgvmonitor.Font = new System.Drawing.Font("times new roman", 15, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[0].Style.Font = new System.Drawing.Font("times new roman", 13, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[1].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[2].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[3].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[4].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[5].Style.Font = new System.Drawing.Font("times new roman", 13, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[6].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[7].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[8].Style.Font = new System.Drawing.Font("times new roman", 13, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[9].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[10].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[11].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[12].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[13].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[14].Style.Font = new System.Drawing.Font("times new roman", 13, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[15].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
                dgvmonitor.Rows[i].Cells[16].Style.Font = new System.Drawing.Font("times new roman", 12, FontStyle.Bold);
            }
            try
            {
                for (int i = 0; i < dgvmonitor.RowCount - 1; i++)
                {
                    if (dgvmonitor.Rows[i].Cells[10].Value != null &&
                    dgvmonitor.Rows[i].Cells[10].Value != DBNull.Value)
                    {
                        // dgvmonitor.Rows[i].Cells[10].Value = String.Format("{0:N2}",
                        int.Parse(dgvmonitor.Rows[i].Cells[10].Value.ToString());
                    }
                }
                MessageBox.Show(" Gncelleme tamamland!", "˜žLEM TAMAM");
            }
            catch (Exception hata)
            {
                MessageBox.Show(hata.Message.ToString(), "HATA MESAJI", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally { }
        }
        private void dgvmonitor_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            //for (int i = 0; i < dgvmonitor.Rows.Count - 1; i++)
            //{
            //    if (Convert.ToString(dgvmonitor.Rows[i].Cells[16].Value) != Convert.ToString(DBNull.Value))
            //    {
            //        dgvmonitor.Rows[i].Visible = false;
            //    }
            //}
            if (e.RowIndex == -1)
                //sütun başlıklarını dikey konuma çeviriyoruz
                //{ if (e.ColumnIndex> -1)
                //{ e.Paint(e.CellBounds, DataGridViewPaintParts.All& ~ DataGridViewPaintParts.ContentForeground); using (SolidBrush br = new SolidBrush(e.CellStyle.ForeColor)) using (StringFormat sf = new StringFormat()) { sf.FormatFlags = StringFormatFlags.DirectionVertical; e.Graphics.DrawString(e.Value.ToString(), e.CellStyle.Font, br, e.CellBounds, sf); } e.Handled = true; } } 
                for (int i = 0; i < dgvmonitor.Rows.Count; i++)
                {
                    DataGridViewRow satir = dgvmonitor.Rows[i];
                    satir.Height = 40;
                }
        }
        private void dgvmonitor_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
        }
        private void timer2_Tick(object sender, EventArgs e)
        {
            int sayi = 0;
            DataTable mydatatabel = new DataTable(@"SELECT * FROM " +
"(SELECT *," +
"(select od.FISHENO from _ODEME od where  od.SIPREF = A.SIPLOG) AS [№ ПЛАТЕЖКИ]," +
"(select DATE_ from _ODEME od where  od.SIPREF = A.SIPLOG) AS [ДАТА ПЛАТЕЖКИ]," +
"(select TUTAR from _ODEME od where  od.SIPREF = A.SIPLOG) AS [СУММА ПЛАТЕЖКИ]," +
"(select DATE_ from _TRANSPORT TR where  TR.SIPREF = A.SIPLOG) AS [ДАТА ТРАНСПОРТИРОВКИ]," +
"(select FIRMA from _TRANSPORT TR where  TR.SIPREF = A.SIPLOG) AS [ТРАНСПОРТНАЯ ФИРМА]," +
"(select DATE_ from _DEPO dep where dep.SIPREF = A.SIPLOG) AS [ДАТА ПОЛУЧЕНИЕ (СКЛАД)]," +
"(select FATURANO from _DEPO dep where dep.SIPREF = A.SIPLOG) AS [№ СЧЕТ ФАТУРЫ]," +
"(select TESLIMALAN from _DEPO dep where dep.SIPREF = A.SIPLOG) AS [КТО ПРИНЯЛ (СКЛАД)]," +
"(select TESLIMEDILEN from _DEPO dep where dep.SIPREF = A.SIPLOG) AS [КОМУ ПЕРЕДАНО (СКЛАД)]" +
"FROM" +
"(select sat.FISHENO AS [№ ЗАЯВКИ],sat.DATE_ AS [ДАТА ЗАЯВКИ],sat.[SIPARISI VEREN] AS[ЗАКАЗЧИК],sat.[SIPARISI ALAN] AS [ПРИНЯЛ ЗАКАЗ]," +
"SIP.LOGICALREF AS SIPLOG,SIP.FISHENO AS [№ СЧЕТА],SIP.DATE_ AS [ДАТА СЧЕТА],SIP.TOTAL AS [СУММА СЧЕТА] from _SAT sat INNER JOIN _SIP SIP ON sat.LOGICALREF =SIP.SIPREF where SIP.ACTIVE = 0) A)B ");
            if (timer2.Interval<= 10000)
            {
                for (int i = 0; i < 2; i++)
                {
                    dgvmonitor.Rows[i].Cells[0].Value = mydatatabel.Rows[i]["№ ЗАЯВКИ"];
                    dgvmonitor.Rows[i].Cells[1].Value = mydatatabel.Rows[i]["ДАТА ЗАЯВКИ"];
                    dgvmonitor.Rows[i].Cells[2].Value = mydatatabel.Rows[i]["ЗАКАЗЧИК"];
                    dgvmonitor.Rows[i].Cells[3].Value = mydatatabel.Rows[i]["ПРИНЯЛ ЗАКАЗ"];
                    dgvmonitor.Rows[i].Cells[4].Value = mydatatabel.Rows[i]["№ СЧЕТА"];
                    dgvmonitor.Rows[i].Cells[5].Value = mydatatabel.Rows[i]["ДАТА СЧЕТА"];
                    dgvmonitor.Rows[i].Cells[6].Value = mydatatabel.Rows[i]["СУММА СЧЕТА"];
                    dgvmonitor.Rows[i].Cells[7].Value = mydatatabel.Rows[i]["№ ПЛАТЕЖКИ"];
                    dgvmonitor.Rows[i].Cells[8].Value = mydatatabel.Rows[i]["ДАТА ПЛАТЕЖКИ"];
                    dgvmonitor.Rows[i].Cells[9].Value = mydatatabel.Rows[i]["СУММА ПЛАТЕЖКИ"];
                    dgvmonitor.Rows[i].Cells[10].Value = mydatatabel.Rows[i]["ДАТА ТРАНСПОРТИРОВКИ"];
                    dgvmonitor.Rows[i].Cells[11].Value = mydatatabel.Rows[i]["ТРАНСПОРТНАЯ ФИРМА"];
                    dgvmonitor.Rows[i].Cells[12].Value = mydatatabel.Rows[i]["ДАТА ПОЛУЧЕНИЕ (СКЛАД)"];
                    dgvmonitor.Rows[i].Cells[13].Value = mydatatabel.Rows[i]["№ СЧЕТ ФАТУРЫ"];
                    dgvmonitor.Rows[i].Cells[14].Value = mydatatabel.Rows[i]["[КТО ПРИНЯЛ (СКЛАД)"];
                    dgvmonitor.Rows[i].Cells[15].Value = mydatatabel.Rows[i]["КОМУ ПЕРЕДАНО (СКЛАД)"];
                }
               
               if (timer2.Interval <= 20000)
                {
                    for (int i = 2; i < 5; i++)
                    {
                        dgvmonitor.Rows[i].Cells[0].Value = mydatatabel.Rows[i]["№ ЗАЯВКИ"];
                        dgvmonitor.Rows[i].Cells[1].Value = mydatatabel.Rows[i]["ДАТА ЗАЯВКИ"];
                        dgvmonitor.Rows[i].Cells[2].Value = mydatatabel.Rows[i]["ЗАКАЗЧИК"];
                        dgvmonitor.Rows[i].Cells[3].Value = mydatatabel.Rows[i]["ПРИНЯЛ ЗАКАЗ"];
                        dgvmonitor.Rows[i].Cells[4].Value = mydatatabel.Rows[i]["№ СЧЕТА"];
                        dgvmonitor.Rows[i].Cells[5].Value = mydatatabel.Rows[i]["ДАТА СЧЕТА"];
                        dgvmonitor.Rows[i].Cells[6].Value = mydatatabel.Rows[i]["СУММА СЧЕТА"];
                        dgvmonitor.Rows[i].Cells[7].Value = mydatatabel.Rows[i]["№ ПЛАТЕЖКИ"];
                        dgvmonitor.Rows[i].Cells[8].Value = mydatatabel.Rows[i]["ДАТА ПЛАТЕЖКИ"];
                        dgvmonitor.Rows[i].Cells[9].Value = mydatatabel.Rows[i]["СУММА ПЛАТЕЖКИ"];
                        dgvmonitor.Rows[i].Cells[10].Value = mydatatabel.Rows[i]["ДАТА ТРАНСПОРТИРОВКИ"];
                        dgvmonitor.Rows[i].Cells[11].Value = mydatatabel.Rows[i]["ТРАНСПОРТНАЯ ФИРМА"];
                        dgvmonitor.Rows[i].Cells[12].Value = mydatatabel.Rows[i]["ДАТА ПОЛУЧЕНИЕ (СКЛАД)"];
                        dgvmonitor.Rows[i].Cells[13].Value = mydatatabel.Rows[i]["№ СЧЕТ ФАТУРЫ"];
                        dgvmonitor.Rows[i].Cells[14].Value = mydatatabel.Rows[i]["[КТО ПРИНЯЛ (СКЛАД)"];
                        dgvmonitor.Rows[i].Cells[15].Value = mydatatabel.Rows[i]["КОМУ ПЕРЕДАНО (СКЛАД)"];
                    }
                 
                }
 
 
 
kullandigim sqlbaglanti sinifida su sekilde
 
 
 public static string veriyolu = "data source=192.168.0.*;initial catalog=SIP2012;user id=sa;password=1******";
      
        public static DataTable verigetir(string cumle, out int recount)
        {
            recount = 0;
            DataTable dt = null;
            using (SqlConnection baglanti = new SqlConnection(veriyolu))
            {
                SqlCommand komut = baglanti.CreateCommand();
                komut.CommandText = cumle;
                komut.CommandType = System.Data.CommandType.Text;
                try
                {
                    baglanti.Open();
                    SqlDataReader dr = komut.ExecuteReader();
                    dt = new DataTable("cumle");
                    dt.Load(dr);
                    if (dt != null)
                    {
                        recount = dt.Rows.Count;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("VERI TABANI HATASI" + ex.Message, "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    if (baglanti.State == ConnectionState.Open)
                    {
                        baglanti.Close();
                    }
                }
            }
            return dt;
        }
        public static DataTable verigetir(string cumle, SqlParameter[] param, out int recount)
        {
            recount = 0;
            DataTable dt = null;
            using (SqlConnection baglanti = new SqlConnection(veriyolu))
            {
                SqlCommand komut = baglanti.CreateCommand();
                komut.CommandText = cumle;
                komut.Parameters.AddRange(param);
                komut.CommandType = System.Data.CommandType.Text;
                try
                {
                    baglanti.Open();
                    SqlDataReader dr = komut.ExecuteReader();
                    dt = new DataTable("cumle");
                    dt.Load(dr);
                    if (dt != null)
                    {
                        recount = dt.Rows.Count;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("VERI TABANI HATASI" + ex.Message, "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    if (baglanti.State == ConnectionState.Open)
                    {
                        baglanti.Close();
                    }
                }
            }
            return dt;
        }
 
 
 
bu sorunu viewle nasil cozerim tam anlayamadim...aciklarsaniz cok sevinirim... 
 
Gönderildi : 27/02/2012 18:38

(@YavuzKIVANC)
Gönderiler: 32
Eminent Member
 

1- Sorgu sabit anladığım kadarıyla, dolayısıyla bu bir view içine konarak kod karmaşası azaltılabilir.
create view vw_name
as
select * from tablo

2- Bu view'de(create ettiğini varsayıyorum) artan sırada bir id var ise Timer1_Tick'de "select * from vw_name where id=degisken%kayitSayisi" şeklinde sorgulama yapabilirsin.

Yada;

Gridin paging özelliği kullanılarak kayıtlar 10 arlı listelenir, Tick olayında DataGrid.CurrentPageIndex değeri artırılarak sonraki 10 lu gösterilebilir.

Umarım anlatabilmişimdir.

 
Gönderildi : 27/02/2012 19:49

(@inanodabasi)
Gönderiler: 130
Estimable Member
Konu başlatıcı
 

ilginiz icin tskler hocam,yanliz datagridviewde paging ve currenpageindex ozeliklerini goremiyorum...ben bunu sql deilde c# boyutunda haletmek istiyorum..

 
Gönderildi : 27/02/2012 21:12

(@YavuzKIVANC)
Gönderiler: 32
Eminent Member
 

Paging için örnek kod;

SqlDataAdapter adapter;
DataSet DS;
int startPos = 0;
int rowCount=16;


private void Form1_Load(object sender, EventArgs e){
string connectionString = @"Data Source=.\sqlexpress;Initial Catalog=abc;User=sa;Password=abc";
string sql = "SELECT * FROM abc";
SqlConnection connection = new SqlConnection(connectionString);
adapter =
new SqlDataAdapter(sql, connection);
DS =
new DataSet();
connection.Open();
adapter.Fill(DS, startPos, 10,
"abc");
connection.Close();
dataGridView1.DataSource = DS;
dataGridView1.DataMember =
"abc";
}


private void timer1_Tick(object sender, EventArgs e){
startPos = (startPos + 10 > rowCount ? 0 : startPos + 10);
DS.Clear();
adapter.Fill(DS, startPos, 10,
"abc");
}

 
Gönderildi : 28/02/2012 01:19

(@inanodabasi)
Gönderiler: 130
Estimable Member
Konu başlatıcı
 

tskler hocam sorunu tavsiyeleriniz sayesinde cozdum...oncelikle kod karmasikligi yuzunden en son verdiginiz dataset ozeliginde verileri datagridviewe cekemeyince kodlar icin bir view tanimladim...sonra en son verdiginiz paging ornek kodunu kendi kodlarima entegre edince sorun cozuldu...aslinda hersey kod karmasikligindan kaynaklaniyormus....tskler

 
Gönderildi : 29/02/2012 17:43

Paylaş: