/// <summary> /// Guarda los cambios realizados /// </summary> /// <history> /// [emoguel] created 26/07/2016 /// </history> private async void btnAccept_Click(object sender, RoutedEventArgs e) { try { btnAccept.Focus(); List <LeadSource> lstLeadSources = dgrLeadSources.ItemsSource as List <LeadSource>; notice.noText = UIRichTextBoxHelper.getRTFFromRichTextBox(ref richTextBox); if (ObjectHelper.IsEquals(notice, oldNotice) && ObjectHelper.IsListEquals(lstLeadSources, _lstOldLeadSources)) { dgrLeadSources.CancelEdit(); _blnIsClosing = true; Close(); } else { if (DateHelper.ValidateValueDate(dtpkFrom, dtpkTo)) { txtStatus.Text = "Saving Data..."; skpStatus.Visibility = Visibility.Visible; btnAccept.Visibility = Visibility.Collapsed; string strMsj = ""; strMsj = ValidateHelper.ValidateForm(this, "Notice", blnDatagrids: true); if (dgrLeadSources.Items.Count == 1) { strMsj += (strMsj != "") ? " \n " : "" + "specify at least one LeadSource."; } if (strMsj == "") { List <LeadSource> lstAddLeadSources = lstLeadSources.Where(ls => !_lstOldLeadSources.Any(lss => lss.lsID == ls.lsID)).ToList(); List <LeadSource> lstDelLeadSources = _lstOldLeadSources.Where(ls => !lstLeadSources.Any(lss => lss.lsID == ls.lsID)).ToList(); int nRes = await BRNotices.SaveNotice(notice, enumMode == EnumMode.Edit, lstAddLeadSources, lstDelLeadSources); UIHelper.ShowMessageResult("Notice", nRes); if (nRes > 0) { _blnIsClosing = true; DialogResult = true; Close(); } } else { UIHelper.ShowMessage(strMsj); } skpStatus.Visibility = Visibility.Collapsed; btnAccept.Visibility = Visibility.Visible; } } } catch (Exception ex) { UIHelper.ShowMessage(ex); } }
/// <summary> /// Trae las noticias y las carga en el rtb /// </summary> /// <history> /// [jorcanche] 19/04/2016 /// </history> private async void GetNotices() { rtbViewerNotice.Document.Blocks.Clear(); RTFNotices = string.Empty; RTFNotice = string.Empty; var notices = await BRNotices.GetNotices(Context.User.LeadSource.lsID, BRHelpers.GetServerDate()); if (notices.Count > 0) { foreach (var notice in notices) { RTFNotices = RTFNotices + Title(notice.noTitle); RTFNotices = RTFNotices + Text(notice.noText); } UIRichTextBoxHelper.LoadRTF(ref rtbViewerNotice, RTFNotices); RTFNotice = UIRichTextBoxHelper.getRTFFromRichTextBox(ref rtbViewerNotice); } }
/// <summary> /// Carga la lista de notices /// </summary> /// <param name="notice">Objeto a seleccionar</param> /// <history> /// [emoguel] created 23/07/2016 /// </history> private async void LoadNotices(Notice notice = null) { try { int nIndex = 0; List <Notice> lstNotices = await BRNotices.GetNotices(_nStatus, _noticeFilter); dgrNotices.ItemsSource = lstNotices; if (lstNotices.Count > 0 && notice != null) { notice = lstNotices.Where(no => no.noID == notice.noID).FirstOrDefault(); nIndex = lstNotices.IndexOf(notice); } GridHelper.SelectRow(dgrNotices, nIndex); StatusBarReg.Content = lstNotices.Count + " Notices."; status.Visibility = Visibility.Collapsed; } catch (Exception ex) { UIHelper.ShowMessage(ex); } }