public void AddAddedDep(Department c) { GMapOverlay markersOverlay = new GMapOverlay(c.Bank1.Id.ToString()); GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(c.Сoordinate_y, c.Сoordinate_x), GMarkerGoogleType.green); //Добавляем описание marker.ToolTip = new GMapRoundedToolTip(marker); marker.ToolTipText = c.Bank1.Name + "\n" + c.Name + "\n" + c.Address + "\n" + c.Phone + "\n"; var departmentCurrencies = (from depCurr in Program.banksSystem.DeprtmentsСurrencies join curr in Program.banksSystem.Сurrency on depCurr.Сurrency equals curr where depCurr.Department == c.Id select new { Currency = curr.Name, Buy = depCurr.Buy, Sell = depCurr.Sell }).ToList(); foreach (var cur in departmentCurrencies) { marker.ToolTipText += cur.Currency + " " + cur.Buy + " " + cur.Sell + "\n"; } //Добавляем на карту markersOverlay.Markers.Add(marker); gMapControl1.Overlays.Add(markersOverlay); //fix ставим на правильное место gMapControl1.Position = gMapControl1.Position; }
private void buttonSave_Click(object sender, EventArgs e) { if(this.IsValid()) { Department dep = new Department() { Name = textBoxDepartment.Text, Bank = (from bank in Program.banksSystem.Bank where bank.Name==comboBoxBanks.SelectedItem.ToString() select bank.Id).ToList()[0], Phone = (textBoxPhone.Text == "" ? null : textBoxPhone.Text), Address = (textBoxAddress.Text == "" ? null : textBoxAddress.Text), Сoordinate_x = (float)Convert.ToDouble(textBoxX.Text), Сoordinate_y = (float)Convert.ToDouble(textBoxY.Text)}; Program.banksSystem.Department.Add(dep); Program.banksSystem.SaveChanges(); for (int i = 0; i < dgVDepCerrency.RowCount; i++) { var currencyIsFind = dgVDepCerrency[3, i].Value; if(currencyIsFind != null && (bool)currencyIsFind != false) { DeprtmentsСurrencies depc = new DeprtmentsСurrencies() { Department = dep.Id, Buy = Convert.ToDecimal(dgVDepCerrency[1, i].Value), Sell = Convert.ToDecimal(dgVDepCerrency[2, i].Value)}; var currency = dgVDepCerrency[0, i].Value.ToString(); var list = (from c in Program.banksSystem.Сurrency where c.Name == currency select c.Id).ToList(); var temp = list[0]; depc.Currency = temp; Program.banksSystem.DeprtmentsСurrencies.Add(depc); } } Program.banksSystem.SaveChanges(); MessageBox.Show("Department is added!"); ((Form1)parent).AddAddedDep(dep); this.Close(); } }