private void btnAdd_Click(object sender, EventArgs e) { DFormCargo dFormCargo = new DFormCargo(); dFormCargo.cmbCargoType.DataSource = db.CargoTypes.ToList(); dFormCargo.cmbSupplier.DataSource = db.Suppliers.ToList(); DialogResult dialogResult = dFormCargo.ShowDialog(); if (dialogResult == DialogResult.Cancel) return; Cargo cargo = new Cargo() { Name = dFormCargo.tbName.Text, CargoType = (CargoType)dFormCargo.cmbCargoType.SelectedItem, Number = (int)dFormCargo.ntbNumber.Value, UnitMeasurement = dFormCargo.tbUnitMeasurement.Text, Weight = (int)dFormCargo.ntbWeight.Value, Supplier = (Supplier)dFormCargo.cmbSupplier.SelectedItem, Lenght = (int)dFormCargo.ntbLenght.Value, Width = (int)dFormCargo.ntbWidth.Value, Height = (int)dFormCargo.ntbHeight.Value }; db.Cargoes.Add(cargo); db.SaveChanges(); SearchObjects(this, EventArgs.Empty); MessageBox.Show("Новый объект добавлен.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnAdd_Click(object sender, EventArgs e) { DFormDriver dFormDriver = new DFormDriver(); DialogResult dialogResult = dFormDriver.ShowDialog(); if (dialogResult == DialogResult.Cancel) { return; } Driver driver = new Driver { Name = dFormDriver.tbName.Text, Phone = dFormDriver.tbPhone.Text, DrivingCategory = dFormDriver.tbDrivengCategory.Text, Comments = dFormDriver.rtbComments.Text }; db.Drivers.Add(driver); db.SaveChanges(); SearchObjects(this, EventArgs.Empty); MessageBox.Show("Новый объект добавлен.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnAdd_Click(object sender, EventArgs e) { DFormSupplier dFormSupplier = new DFormSupplier(); DialogResult dialogResult = dFormSupplier.ShowDialog(); if (dialogResult == DialogResult.Cancel) { return; } Supplier supplier = new Supplier { Name = dFormSupplier.tbName.Text, Address = dFormSupplier.tbAddress.Text, Phone = dFormSupplier.tbPhone.Text, ContactPerson = dFormSupplier.tbContactPerson.Text, Description = dFormSupplier.rtbDescription.Text }; db.Suppliers.Add(supplier); db.SaveChanges(); SearchObjects(this, EventArgs.Empty); MessageBox.Show("Новый объект добавлен.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnAdd_Click(object sender, EventArgs e) { DFormTariff dFormTariff = new DFormTariff(); DialogResult dialogResult = dFormTariff.ShowDialog(this); if (dialogResult == DialogResult.Cancel) { return; } Tariff tariff = new Tariff { Name = dFormTariff.tbName.Text, PerHour = (int)dFormTariff.ntbPerHour.Value, PerKG = (int)dFormTariff.ntbPerKG.Value, PerKM = (int)dFormTariff.ntbPerKM.Value, Description = dFormTariff.rtbDescription.Text }; db.Tariffs.Add(tariff); db.SaveChanges(); SearchObjects(this, EventArgs.Empty); MessageBox.Show("Новый объект добавлен.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnAdd_Click(object sender, EventArgs e) { DFormClient dFormClient = new DFormClient(); DialogResult dialogResult = dFormClient.ShowDialog(this); if (dialogResult == DialogResult.Cancel) { return; } Client client = new Client { Name = dFormClient.tbName.Text, Address = dFormClient.tbAddress.Text, Phone = dFormClient.tbPhone.Text, ContactPerson = dFormClient.tbContactPerson.Text, Comments = dFormClient.rtbComments.Text }; db.Clients.Add(client); db.SaveChanges(); SearchObjects(sender, EventArgs.Empty); MessageBox.Show("Новый объект добавлен.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnAdd_Click(object sender, EventArgs e) { DFormBrand dFormBrand = new DFormBrand(); DialogResult dialogResult = dFormBrand.ShowDialog(this); if (dialogResult == DialogResult.Cancel) { return; } Brand brand = new Brand() { Name = dFormBrand.tbName.Text, Carrying = (int)dFormBrand.ntbCarrying.Value, Description = dFormBrand.rtbDescription.Text, Lenght = (int)dFormBrand.ntbLenght.Value, Width = (int)dFormBrand.ntbWidth.Value, Height = (int)dFormBrand.ntbHeight.Value }; db.Brands.Add(brand); db.SaveChanges(); SearchObjects(this, EventArgs.Empty); MessageBox.Show("Новый объект добавлен", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnAdd_Click(object sender, EventArgs e) { DFormTransport dFormTransport = new DFormTransport(); dFormTransport.cmbBrand.DataSource = db.Brands.ToList(); dFormTransport.cmbDriver.DataSource = db.Drivers.ToList(); DialogResult dialogResult = dFormTransport.ShowDialog(this); if (dialogResult == DialogResult.Cancel) { return; } Transport transport = new Transport() { StateNumber = dFormTransport.tbStateNumber.Text, Brand = (Brand)dFormTransport.cmbBrand.SelectedItem, Driver = (Driver)dFormTransport.cmbDriver.SelectedItem, DateEntry = dFormTransport.dtpDateEntry.Value }; db.Transports.Add(transport); db.SaveChanges(); SearchObjects(this, EventArgs.Empty); MessageBox.Show("Новый объект добавлен.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnAdd_Click(object sender, EventArgs e) { DFormUser dFormUser = new DFormUser(); dFormUser.cmbPosition.DataSource = db.Positions.ToList(); DialogResult dialogResult = dFormUser.ShowDialog(); if (dialogResult == DialogResult.Cancel) { return; } User user = new User() { Name = dFormUser.tbName.Text, Position = (Position)dFormUser.cmbPosition.SelectedItem }; db.Users.Add(user); db.SaveChanges(); SearchObjects(this, EventArgs.Empty); MessageBox.Show("Новый объект добавлен.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnAdd_Click(object sender, EventArgs e) { DFormTransportation dFormTransportation = new DFormTransportation(); dFormTransportation.cmbClient.DataSource = db.Clients.ToList(); dFormTransportation.cmbTariff.DataSource = db.Tariffs.ToList(); dFormTransportation.cmbTransport.DataSource = db.Transports.ToList(); dFormTransportation.lbCargoes.DataSource = db.Cargoes.ToList(); dFormTransportation.lbCargoes.SelectedIndex = -1; DialogResult dialogResult = dFormTransportation.ShowDialog(this); if (dialogResult == DialogResult.Cancel) { return; } Transportation transportation = new Transportation() { DateOrder = dFormTransportation.dtpDateOrder.Value, PlaceDelivery = dFormTransportation.tbPlaceDelivery.Text, Kilometrage = (int)dFormTransportation.ntbKilometrage.Value, TravelTime = (int)dFormTransportation.ntbTravelTime.Value, Transport = (Transport)dFormTransportation.cmbTransport.SelectedItem, Client = (Client)dFormTransportation.cmbClient.SelectedItem, Tariff = (Tariff)dFormTransportation.cmbTariff.SelectedItem, FuelQuantityDeparture = (int)dFormTransportation.ntbFuelDeparture.Value, FuelQuantityComing = (int)dFormTransportation.ntbFuelComing.Value, SpeedometerValueDeparture = (int)dFormTransportation.ntbSpeedometerDeparture.Value, SpeedometerValueComing = (int)dFormTransportation.ntbSpeedometerComing.Value, DateArrival = dFormTransportation.dtpDateArrival.Value, AdditionalData = dFormTransportation.rtbAdditionalData.Text, }; foreach (var cargo in dFormTransportation.lbCargoes.SelectedItems) { transportation.Cargoes.Add((Cargo)cargo); } db.Transportations.Add(transportation); db.SaveChanges(); ResetSearch(this, EventArgs.Empty); MessageBox.Show("Новый объект добавлен.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnAdd_Click(object sender, EventArgs e) { DFormCargoType dFormCargoType = new DFormCargoType(); DialogResult dialogResult = dFormCargoType.ShowDialog(); if (dialogResult == DialogResult.Cancel) { return; } CargoType cargoType = new CargoType() { Name = dFormCargoType.tbName.Text, Description = dFormCargoType.rtbDescription.Text, Photo = ImageExtension.ImageToByteArray(dFormCargoType.pbPhoto.Image) }; db.CargoTypes.Add(cargoType); db.SaveChanges(); SearchObjects(this, EventArgs.Empty); MessageBox.Show("Новый объект добавлен.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); }