private void button2_Click(object sender, EventArgs e) { frmCikisFisiEkle frmCikisFisiEkle = new frmCikisFisiEkle(); frmCikisFisiEkle.Show(); this.Hide(); }
private void dataGridView1_MouseClick(object sender, MouseEventArgs e) { int row_index = dataGridView1.HitTest(e.X, e.Y).RowIndex; int[] selectedIndexes = new int[dataGridView1.SelectedRows.Count]; if (girisfistable.Rows.Count < 1) { return; } if (e.Button == MouseButtons.Right) { ContextMenu menu = new ContextMenu(); MenuItem item = new MenuItem("Güncelle"); if (row_index == null || row_index < 0 || row_index >= girisfistable.Rows.Count) { return; } item.Click += new EventHandler(delegate(object s, EventArgs args) { string fisid = dataGridView1.Rows[row_index].Cells["FisId"].Value.ToString(); frmCikisFisiEkle ckisekle = new frmCikisFisiEkle(); ckisekle.fisid = fisid; ckisekle.Show(); this.Hide(); }); menu.MenuItems.Add(item); item = new MenuItem("Sil"); item.Click += new EventHandler(delegate(object s, EventArgs args) { if (row_index == null || row_index < 0 || row_index >= girisfistable.Rows.Count) { return; } string fisidsil = dataGridView1.Rows[row_index].Cells["FisId"].Value.ToString(); string fisharaketid = dataGridView1.Rows[row_index].Cells["FisHaraketId"].Value.ToString(); if (MessageBox.Show("Silmek İstediğinize Eminmisiniz?", "Uyarı", MessageBoxButtons.YesNo) == DialogResult.Yes) { string adet = "select * from FisHaraket where FisTipi=2 and FisId=" + fisidsil; DataTable kontroltable = DataBase.select(adet); if (kontroltable.Rows.Count > 1) { string fisharaketsil = "Delete from FisHaraket where FisHaraketId=" + fisharaketid; DataBase.ExecSql(fisharaketsil); string stoksil = "Delete from Stok where FisHaraketId=" + fisharaketid; DataBase.ExecSql(stoksil); MessageBox.Show("Silindi"); string sorgu = @"select fb.FisId,fb.FisNo,fb.Tarih,urn.UrunAdi,fh.Miktar,fh.Birim,fh.FisHaraketId from FisBaslik fb, FisHaraket fh ,Urunler urn where fb.FisId = fh.FisId and fh.UrunRef = urn.UrunRef and fh.FisTipi = 2"; girisfistable = DataBase.select(sorgu); dataGridView1.DataSource = girisfistable; dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[6].Visible = false; } else { string fisbasliksil = "Delete from FisBaslik where FisId=" + fisidsil; string fisharaketsil = "Delete from FisHaraket where FisHaraketId=" + fisharaketid; string stoksil = "Delete from Stok where FisHaraketId=" + fisharaketid; DataBase.ExecSql(fisbasliksil); DataBase.ExecSql(fisharaketsil); DataBase.ExecSql(stoksil); MessageBox.Show("Silindi"); string sorgu = @"select fb.FisId,fb.FisNo,fb.Tarih,urn.UrunAdi,fh.Miktar,fh.Birim,fh.FisHaraketId from FisBaslik fb, FisHaraket fh ,Urunler urn where fb.FisId = fh.FisId and fh.UrunRef = urn.UrunRef and fh.FisTipi = 2"; girisfistable = DataBase.select(sorgu); dataGridView1.DataSource = girisfistable; dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[6].Visible = false; } } }); menu.MenuItems.Add(item); menu.Show(dataGridView1, new Point(e.X, e.Y)); } }