private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (dataGridView.CurrentRow.Index >= dataGridView.RowCount - 1) { return; } id.Text = dataGridView1[0, dataGridView1.CurrentRow.Index].Value.ToString(); int Id = int.Parse(id.Text); ShowFreight(Id); freights Freight = Functions.FindFreights(Id); if (dataGridView1.CurrentCell.ColumnIndex == 1) { CargoForm CF = new CargoForm(Freight.CargoId); CF.Show(); return; } if (dataGridView1.CurrentCell.ColumnIndex == 2) { CompaniesForm CF = new CompaniesForm(Freight.From); CF.Show(); return; } if (dataGridView1.CurrentCell.ColumnIndex == 3) { CompaniesForm CF = new CompaniesForm(Freight.To); CF.Show(); return; } }
public static void getCargo() { projektEntities ctx = new projektEntities(); var query = from c in ctx.cargo select new { Cargo = c }; CargoForm.clearDataGridView(); foreach (var result in query) { CargoForm.fillDataGridView(result.Cargo.Id, result.Cargo.Name, result.Cargo.Type, result.Cargo.ADR, result.Cargo.ADR_Class, result.Cargo.Comment); } }
private void button3_Click(object sender, EventArgs e) { CargoForm CF = new CargoForm(); CF.Show(); }
private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (dataGridView.CurrentRow.Index >= dataGridView.RowCount - 1) { return; } id.Text = dataGridView1[0, dataGridView1.CurrentRow.Index].Value.ToString(); int Id = int.Parse(id.Text); ShowFreight(Id); freights Freight = Functions.FindFreights(Id); if(dataGridView1.CurrentCell.ColumnIndex == 1) { CargoForm CF = new CargoForm(Freight.CargoId); CF.Show(); return; } if (dataGridView1.CurrentCell.ColumnIndex == 2) { CompaniesForm CF = new CompaniesForm(Freight.From); CF.Show(); return; } if (dataGridView1.CurrentCell.ColumnIndex == 3) { CompaniesForm CF = new CompaniesForm(Freight.To); CF.Show(); return; } }