/// <summary> /// Initializes view model's details object asynchronously. /// </summary> protected virtual async Task InitializeObjectAsync(CancellationToken token) { DetailsObject.UpdateComputed(); await DetailsObject.SetValuesAsync(Params, token); if (ViewParams.Action.Create == Params[ViewParams.Action.Param]) { DetailsObject.SetModified(false, true); } }
/// <summary> /// Initializes view model's details object. /// </summary> protected virtual void InitializeObject() { DetailsObject.UpdateComputed(); DetailsObject.SetValues(Params); if (ViewParams.Action.Create == Params[ViewParams.Action.Param]) { DetailsObject.SetModified(false, true); } }
/// <summary>Адрес по объекту</summary> protected void ObjectAdres(Objecte objecte, bool full) { CP = new Control_Print(); if (objecte.Separate) { DetailsObject details = objecte.Detail; if (details.MailAdres.Length > 0) { Substitute.AddExchange(StaticMark.adres_abonent, details.MailAdres.CutAdres(full), 0); } else if (details.LegalAdres.Length > 0) { Substitute.AddExchange(StaticMark.adres_abonent, details.LegalAdres.CutAdres(full), 0); } else { MessageBox.Show("Объект имеет индикатор абособленный, но адрес не задан!"); } } else { DetailsClient Details = objecte.Client.Detail; string Storege = string.Empty; bool PostAdres = Details.AdresPostID != 0; if (PostAdres) { Substitute.AddExchange(StaticMark.adres_abonent, Helpers.LogicHelper.AdresLogic.FirstModel(Details.AdresPostID).Adr.CutAdres(full), 0); } else { CP.Elems.SetRowFromGrid(MyTools.GL_Auto); WrapPanel wp = new WrapPanel(); wp.Orientation = Orientation.Vertical; if (Details.AdresLegalID > 0) { RadioButton AdresLegal = new RadioButton(); AdresLegal.Content = Helpers.LogicHelper.AdresLogic.FirstModel(Details.AdresLegalID).Adr; AdresLegal.Checked += (sender, e) => { Storege = AdresLegal.Content.ToString(); }; wp.Children.Add(AdresLegal); } RadioButton AdresObj = new RadioButton(); AdresObj.Content = objecte.Adres; AdresObj.Checked += (sender, e) => { Storege = objecte.Adres; }; wp.Children.Add(AdresObj); CP.Elems.SetFromGrid(wp); CP.ShowDialog(); } if (!PostAdres) { Substitute.AddExchange(StaticMark.adres_abonent, Storege.CutAdres(full), 0); } } }
/// <summary> /// Activates the view model and the view /// </summary> /// <param name="parameters">Parameters to activate the view with</param> /// <returns>True if the view was successfully activated, False otherwise</returns> public override bool Activate(NameValueCollection parameters) { if (!base.Activate(parameters) || DetailsObject == null) { return(false); } DetailsObject.SetValues(Params); if (ViewParams.Action.Create != Params[ViewParams.Action.Param]) { LoadData(); } return(true); }
/// <summary> /// Checks if the view can be closed /// </summary> /// <returns>True if the view can be closed, False otherwise</returns> public override bool CanClose() { bool isModified = DetailsObject?.IsModified() ?? false; if (isModified && MessageBox.Show( Model?.GetString(Messages.View_UnsavedMessage), Model?.GetString(Messages.View_UnsavedTitle), MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No) == MessageBoxResult.No) { return(false); } return(base.CanClose()); }