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); ShowShipping(Id); shipping Shipping = Functions.FindShipping(Id); if (dataGridView1.CurrentCell.ColumnIndex == 1) { DriversForm DF = new DriversForm(Shipping.DriverId); DF.Show(); return; } if (dataGridView1.CurrentCell.ColumnIndex == 2) { CarsForm CF = new CarsForm(Shipping.CarId); CF.Show(); return; } if (dataGridView1.CurrentCell.ColumnIndex == 3) { FreightsForm FF = new FreightsForm(Shipping.FreightId); FF.Show(); return; } }
public static void getFreights() { projektEntities ctx = new projektEntities(); var query = from fr in ctx.freights join ca in ctx.cargo on fr.CargoId equals ca.Id join st in ctx.companies on fr.From equals st.Id join stci in ctx.cities_list on st.CityId equals stci.Id join stco in ctx.company_name_list on st.CompanyId equals stco.Id join de in ctx.companies on fr.To equals de.Id join deci in ctx.cities_list on de.CityId equals deci.Id join deco in ctx.company_name_list on de.CompanyId equals deco.Id select new { Freight = fr, Cargo = ca, Start = st, StartCity = stci, StartCompany = stco, Destination = de, DestinationCity = deci, DestinationCompany = deco }; FreightsForm.clearDataGridView(); foreach (var result in query) { FreightsForm.fillDataGridView(result.Freight.Id, result.Cargo.Name, result.StartCompany.Company + ", " + result.StartCity.City, result.DestinationCompany.Company + ", " + result.DestinationCity.City, result.Freight.ScheduledArrive, result.Freight.Amount, result.Freight.Weight, result.Freight.Comment); } }
private void button5_Click(object sender, EventArgs e) { FreightsForm FF = new FreightsForm(); FF.Show(); }