public ItalianMunicipality(string name) { Name = name; using (var db = new LocalDataEntities()) { Province = db.Comuni.FirstOrDefault(i => i.Comune == name).Provincia; Code = db.Comuni.FirstOrDefault(i => i.Comune == name).Codice; } }
public ForeignCountry(string name) { Name = name; using (var db = new LocalDataEntities()) { Code = (from country in db.Stati where country.Nome == name select country.Codice).FirstOrDefault(); } }
public virtual bool ShowForm() { _entities = new LocalDataEntities(Session.LocalDataConnection); this.txtNetworkId.Text = System.Environment.UserName; RefreshEnvironmentCombo(); ShowVersionNumber(); groupLogin.Visible = true; return this.ShowDialog() == System.Windows.Forms.DialogResult.OK; }
public void RetrieveForeignCountriesAsList() { try { using (var db = new LocalDataEntities()) { foreach (var country in db.Stati) { if (ForeignCounties.Contains(country.Nome) == false) { ForeignCounties.Add(country.Nome); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Errore nel recupero del database!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } ForeignCounties.Sort(); }
public void RetrieveProvincesAsList() { try { using (var db = new LocalDataEntities()) { foreach (var prov in db.Comuni) { if (Provinces.Contains(prov.Provincia) == false) { Provinces.Add(prov.Provincia); } } } Provinces.Sort(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Errore nel recupero del database!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
public void RetrieveCurrentProvinceMunicipalities() { CurrentProviceMunicipalities.Clear(); try { using (var db = new LocalDataEntities()) { foreach (var municipality in db.Comuni) { if (municipality.Provincia == CurrentProvince) { CurrentProviceMunicipalities.Add(municipality.Comune); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Errore nel recupero del database!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } CurrentProviceMunicipalities.Sort(); }
/// <summary> /// Функция обновления наработки /// </summary> /// <param name="obj"></param> private void UpdateWorkTime(object obj) { try { foreach (var device in Devices) { if (device.IsComm == false && device.IsActive && device.FreqEngine > 0) { device.FullWork++; device.WorkToTO--; //Обновляем наработку и время до то в БД. LocalDataEntities ent = new LocalDataEntities(); var devFromDb = ent.Devices.FirstOrDefault(d => d.ID == device.ID); devFromDb.WorkToTO = device.WorkToTO; devFromDb.FullWork = device.FullWork; ent.SaveChanges(); } } } catch (Exception ex) { } }
public bool Refresh(string networkId) { var refreshed = false; try { _menuOptions.Clear(); _entities = new LocalDataEntities(Session.LocalDataConnection); // Add list of restricted options the user has been authorised to use. var qry = from user in _entities.eUsers where user.NetworkId == networkId from option in user.vMenuOptions where option.IsRestricted == true select option; foreach (var option in qry.ToList()) _menuOptions.Add(new UserMenuOption { ApplicationId = option.ApplicationId, Tab = option.Tab.ToLower(), MenuOption = option.MenuOption.ToLower(), IsRestricted = true }); // Add list of non-restricted options all users can use. qry = from o in _entities.eMenuOptions where o.IsRestricted == false select o; foreach (var option in qry.ToList()) _menuOptions.Add(new UserMenuOption { ApplicationId = option.ApplicationId, Tab = option.Tab.ToLower(), MenuOption = option.MenuOption.ToLower(), IsRestricted = false }); refreshed = true; } catch (Exception ex) { ExceptionHandler.RaiseException(ex, "Refresh"); } return refreshed; }