private void button4_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") { return; } int Id = int.Parse(id.Text); projektEntities context = new projektEntities(); var query = (from f in context.shipping where f.Id == Id select new { Shipping = f }).First(); if (query.Shipping.ArriveTime.HasValue) { MessageBox.Show("To zlecenie zostało już ukończone"); return; } query.Shipping.Comment = comment.Text; query.Shipping.ArriveTime = DateTime.Now; context.Entry(query.Shipping).State = EntityState.Modified; context.SaveChanges(); updateResources(); ClearForm(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }
private void button1_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") { return; } int Id = int.Parse(id.Text); projektEntities context = new projektEntities(); var query = (from f in context.shipping where f.Id == Id select new { Shipping = f }).First(); query.Shipping.Comment = comment.Text; context.Entry(query.Shipping).State = EntityState.Modified; context.SaveChanges(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }
private void button1_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") { return; } int Id = int.Parse(id.Text); projektEntities context = new projektEntities(); var query = (from c in context.cargo where c.Id == Id select new { Cargo = c }).First(); if (query.Cargo == null) { MessageBox.Show("Nie znaleziono auta o takim Id"); return; } query.Cargo.Name = name.Text; query.Cargo.ADR = adr.Checked.ToString(); query.Cargo.Type = Types[Functions.FindStringIndex(TypesPL, type.Text)]; query.Cargo.Comment = comment.Text; string adrClass = ""; foreach (var item in CheckBoxList) { if (item.Checked) { adrClass += Functions.classes[(int)item.Tag]; } adrClass += ","; //Cargo.AdrClass[(int)item.Tag] = item.Checked; } adrClass = adrClass.Remove(adrClass.LastIndexOf(',')); query.Cargo.ADR_Class = adrClass; context.Entry(query.Cargo).State = EntityState.Modified; context.SaveChanges(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }
private void button1_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") { return; } int Id = int.Parse(id.Text); projektEntities context = new projektEntities(); var query = (from car in context.cars where car.Id == Id select new { Car = car }).First(); if (query.Car == null) { MessageBox.Show("Nie znaleziono auta o takim Id"); return; } if (!Functions.AllowedPlate(plate.Text) && plate.Text != query.Car.Number_plate) { MessageBox.Show("Taki numer rejestracji już występuje"); return; } query.Car.Make = make.Text; query.Car.Model = model.Text; query.Car.Comment = comment.Text; query.Car.Number_plate = plate.Text; query.Car.Carry = (int)carry.Value; query.Car.Sold = sold.Checked.ToString(); context.Entry(query.Car).State = EntityState.Modified; context.SaveChanges(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }
private void button1_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") { return; } int Id = int.Parse(id.Text); projektEntities context = new projektEntities(); var query = (from company in context.companies where company.Id == Id select new { company }).First(); try { getOrAddCity(cities.SelectedIndex); getOrAddCompany(companies.SelectedIndex); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } query.company.Address = address.Text; query.company.Comment = comment.Text; query.company.CityId = ((Transport)cities.SelectedItem).Id; query.company.CompanyId = ((Transport)companies.SelectedItem).Id; context.Entry(query.company).State = EntityState.Modified; context.SaveChanges(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }
private void button1_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") { return; } int Id = int.Parse(id.Text); if (cargo.SelectedIndex < 0 || start.SelectedIndex < 0 || destination.SelectedIndex < 0) { MessageBox.Show("Towar, miejsce startowe i miejsce docelowe nie mogą być puste"); return; } projektEntities context = new projektEntities(); var query = (from f in context.freights where f.Id == Id select new { Freight = f }).First(); query.Freight.Amount = (byte)amount.Value; query.Freight.CargoId = ((Transport)cargo.SelectedItem).Id; query.Freight.Comment = comment.Text; query.Freight.From = ((Transport)start.SelectedItem).Id; query.Freight.ScheduledArrive = date.Value; query.Freight.To = ((Transport)destination.SelectedItem).Id; query.Freight.Weight = (int)weight.Value; context.Entry(query.Freight).State = EntityState.Modified; context.SaveChanges(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }
private void button1_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") { return; } int Id = int.Parse(id.Text); projektEntities context = new projektEntities(); var query = (from driver in context.drivers where driver.Id == Id select new { Driver = driver }).First(); if (query.Driver == null) { MessageBox.Show("Nie znaleziono kierowcy o takim Id"); return; } query.Driver.Name = name.Text; query.Driver.Surname = surname.Text; query.Driver.Comment = comment.Text; query.Driver.Wage = (int)wage.Value; query.Driver.Employed = employed.Checked.ToString(); query.Driver.ADR_License = adr.Checked.ToString(); context.Entry(query.Driver).State = EntityState.Modified; context.SaveChanges(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }
private void button1_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") return; int Id = int.Parse(id.Text); projektEntities context = new projektEntities(); var query = (from f in context.shipping where f.Id == Id select new { Shipping = f }).First(); query.Shipping.Comment = comment.Text; context.Entry(query.Shipping).State = EntityState.Modified; context.SaveChanges(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }
private void button4_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") return; int Id = int.Parse(id.Text); projektEntities context = new projektEntities(); var query = (from f in context.shipping where f.Id == Id select new { Shipping = f }).First(); if (query.Shipping.ArriveTime.HasValue) { MessageBox.Show("To zlecenie zostało już ukończone"); return; } query.Shipping.Comment = comment.Text; query.Shipping.ArriveTime = DateTime.Now; context.Entry(query.Shipping).State = EntityState.Modified; context.SaveChanges(); updateResources(); ClearForm(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }
private void button1_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") return; int Id = int.Parse(id.Text); projektEntities context = new projektEntities(); var query = (from c in context.cargo where c.Id == Id select new { Cargo = c }).First(); if (query.Cargo == null) { MessageBox.Show("Nie znaleziono auta o takim Id"); return; } query.Cargo.Name = name.Text; query.Cargo.ADR = adr.Checked.ToString(); query.Cargo.Type = Types[Functions.FindStringIndex(TypesPL, type.Text)]; query.Cargo.Comment = comment.Text; string adrClass = ""; foreach (var item in CheckBoxList) { if (item.Checked) { adrClass += Functions.classes[(int)item.Tag]; } adrClass += ","; //Cargo.AdrClass[(int)item.Tag] = item.Checked; } adrClass = adrClass.Remove(adrClass.LastIndexOf(',')); query.Cargo.ADR_Class = adrClass; context.Entry(query.Cargo).State = EntityState.Modified; context.SaveChanges(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }
private void button1_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") return; int Id = int.Parse(id.Text); if (cargo.SelectedIndex < 0 || start.SelectedIndex < 0 || destination.SelectedIndex < 0) { MessageBox.Show("Towar, miejsce startowe i miejsce docelowe nie mogą być puste"); return; } projektEntities context = new projektEntities(); var query = (from f in context.freights where f.Id == Id select new { Freight = f }).First(); query.Freight.Amount = (byte)amount.Value; query.Freight.CargoId = ((Transport)cargo.SelectedItem).Id; query.Freight.Comment = comment.Text; query.Freight.From = ((Transport)start.SelectedItem).Id; query.Freight.ScheduledArrive = date.Value; query.Freight.To = ((Transport)destination.SelectedItem).Id; query.Freight.Weight = (int)weight.Value; context.Entry(query.Freight).State = EntityState.Modified; context.SaveChanges(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }
private void button1_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") return; int Id = int.Parse(id.Text); projektEntities context = new projektEntities(); var query = (from company in context.companies where company.Id == Id select new { company }).First(); try { getOrAddCity(cities.SelectedIndex); getOrAddCompany(companies.SelectedIndex); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } query.company.Address = address.Text; query.company.Comment = comment.Text; query.company.CityId = ((Transport)cities.SelectedItem).Id; query.company.CompanyId = ((Transport)companies.SelectedItem).Id; context.Entry(query.company).State = EntityState.Modified; context.SaveChanges(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }
private void button1_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") return; int Id = int.Parse(id.Text); projektEntities context = new projektEntities(); var query = (from car in context.cars where car.Id == Id select new { Car = car }).First(); if (query.Car == null) { MessageBox.Show("Nie znaleziono auta o takim Id"); return; } if (!Functions.AllowedPlate(plate.Text) && plate.Text != query.Car.Number_plate) { MessageBox.Show("Taki numer rejestracji już występuje"); return; } query.Car.Make = make.Text; query.Car.Model = model.Text; query.Car.Comment = comment.Text; query.Car.Number_plate = plate.Text; query.Car.Carry = (int)carry.Value; query.Car.Sold = sold.Checked.ToString(); context.Entry(query.Car).State = EntityState.Modified; context.SaveChanges(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }
private void button1_Click(object sender, EventArgs e) { int currentRow = dataGridView1.CurrentRow.Index; int currentCol = dataGridView1.CurrentCell.ColumnIndex; if (id.Text == "") return; int Id = int.Parse(id.Text); projektEntities context = new projektEntities(); var query = (from driver in context.drivers where driver.Id == Id select new { Driver = driver }).First(); if (query.Driver == null) { MessageBox.Show("Nie znaleziono kierowcy o takim Id"); return; } query.Driver.Name = name.Text; query.Driver.Surname = surname.Text; query.Driver.Comment = comment.Text; query.Driver.Wage = (int)wage.Value; query.Driver.Employed = employed.Checked.ToString(); query.Driver.ADR_License = adr.Checked.ToString(); context.Entry(query.Driver).State = EntityState.Modified; context.SaveChanges(); LoadData(); dataGridView.CurrentCell = dataGridView[currentCol, currentRow]; }