public void getComboboxData2() { string sqlDB; sqlDB = @"SELECT dbo.PARTS_OF_THE_WORLD.ID_PART_OF_THE_WORLD, dbo.PARTS_OF_THE_WORLD.NAME_PART_OF_THE_WORLD FROM dbo.PARTS_OF_THE_WORLD "; SqlDataAdapter sqlDA = new SqlDataAdapter(sqlDB, f3.sqlCon); DataTable dtTable = new DataTable(); sqlDA.Fill(dtTable); List <Part_of_the_world> lmf5 = new List <Part_of_the_world>(); for (int i = 0; i < dtTable.Rows.Count; i++) { Part_of_the_world t = new Part_of_the_world(); t.ID_PART_OF_THE_WORLD = (int)dtTable.Rows[i]["ID_PART_OF_THE_WORLD"]; t.NAME_PART_OF_THE_WORLD = dtTable.Rows[i]["NAME_PART_OF_THE_WORLD"].ToString(); lmf5.Add(t); } comboBox1Partoftheworld.DataSource = null; comboBox1Partoftheworld.DataSource = lmf5; }
private void button1POKDANNIE_Click(object sender, EventArgs e) { string sqlDB; sqlDB = @"SELECT dbo.PARTS_OF_THE_WORLD.ID_PART_OF_THE_WORLD, dbo.PARTS_OF_THE_WORLD.NAME_PART_OF_THE_WORLD FROM dbo.PARTS_OF_THE_WORLD "; SqlDataAdapter sqlDA = new SqlDataAdapter(sqlDB, f5.sqlCon); DataTable dtTable = new DataTable(); sqlDA.Fill(dtTable); lmf3 = new List <Part_of_the_world>(); for (int i = 0; i < dtTable.Rows.Count; i++) { Part_of_the_world t = new Part_of_the_world(); t.ID_PART_OF_THE_WORLD = (int)dtTable.Rows[i]["ID_PART_OF_THE_WORLD"]; t.NAME_PART_OF_THE_WORLD = dtTable.Rows[i]["NAME_PART_OF_THE_WORLD"].ToString(); lmf3.Add(t); } dgvPOW.DataSource = null; dgvPOW.DataSource = lmf3; }
private void dgvPOW_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 2) { return; } Part_of_the_world part = lmf3[e.RowIndex]; string Sqlsg; Sqlsg = @" Delete From PARTS_OF_THE_WORLD Where ID_PART_OF_THE_WORLD = " + part.ID_PART_OF_THE_WORLD; }