public void updateView(Guid guid) { SystemLazy systemLazy = new SystemLazy(guid); systems = new List <ClassLibrary.classes.System>(); systems = systemLazy.Systems; List <ExpandoObject> systemListView = new List <ExpandoObject>(); int count = 0; foreach (ClassLibrary.classes.System sys in systems) { count++; dynamic javascript = new ExpandoObject(); javascript.Name = string.Format("System {0}", count); javascript.Active = sys.Contract.IsActive ? "Yes" : "No"; javascript.Guid = sys.Contract.GUID; systemListView.Add(javascript); } lvClientSystems.ItemsSource = systemListView; if (systems.Count != 0) { currentSystem = systems.First(system => system.GUID == systems.ElementAt(0).GUID); updateInnerView(currentSystem); lvClientSystems.SelectedIndex = 0; } else { updateInnerView(); } }
private void lvClientSystems_Click(object sender, RoutedEventArgs e) { var item = (sender as ListView).SelectedItem; if (item != null) { try { dynamic selectedClient = (ExpandoObject)item; currentSystem = systems.First(system => system.Contract.GUID == selectedClient.Guid); updateInnerView(currentSystem); } catch (InvalidOperationException exception) { ErrorHandler.ErrorHandle error = ErrorHandler.ErrorHandle.getInstance(); error.handle(exception, true, true); } } }
public void updateInnerView(ClassLibrary.classes.System singleSystem) { if (singleSystem != null) { txtContractIdentifier.Text = singleSystem.Contract.ContractIdentifier; txtIsActive.Text = singleSystem.Contract.IsActive ? "Yes" : "No"; txtServiceLevel.Text = singleSystem.Contract.ServiceLevel; txtStartDate.Text = singleSystem.Contract.StartDate.ToString("d MMMM, yyyy"); txtEndDate.Text = singleSystem.Contract.EndDate.ToString("d MMMM, yyyy"); txtUpgradeOptions.Text = singleSystem.Contract.UpgradeOptions; txtCritical.Text = singleSystem.Status.Citical == 1 ? singleSystem.Status.Messages : "None"; txtWarning.Text = singleSystem.Status.Warning == 1 ? singleSystem.Status.Messages : "None"; OptionLazy optionLoad = new OptionLazy(singleSystem.GUID); singleSystem.Options = optionLoad.OptionList; List <ExpandoObject> optionListView = new List <ExpandoObject>(); foreach (OptionLazy option in singleSystem.Options) { dynamic javascript = new ExpandoObject(); javascript.Name = option.Name; javascript.Price = string.Format("R {0:0.00}", (option.CombinedPrice + option.Price)).EndsWith("00") ? string.Format("R {0}", Convert.ToInt32((option.CombinedPrice + option.Price))) : string.Format("R {0:0.00}", (option.CombinedPrice + option.Price)); javascript.Guid = option.GUID; optionListView.Add(javascript); } lvClientOptions.ItemsSource = optionListView; if (optionListView.Count != 0) { lvClientOptions.SelectedIndex = 0; } // string.Format("R {0:0.00}", accountLazy.CostPerMonth).EndsWith("00") ? string.Format("R {0}", Convert.ToInt32(accountLazy.CostPerMonth)) : string.Format("R {0:0.00}", accountLazy.CostPerMonth); //.ToString("d MMMM, yyyy"); } else { // Error message } }