/// <summary> /// Agrega|Actualiza registros en el catalogo LeadSources /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 16/05/2016 /// </history> private async void btnAccept_Click(object sender, RoutedEventArgs e) { btnAccept.Focus(); List <Location> lstLocations = (List <Location>)dgrLocations.ItemsSource; List <Agency> lstAgencies = (List <Agency>)dgrAgencies.ItemsSource; #region Save if (enumMode != EnumMode.Search) { if (enumMode != EnumMode.Add && ObjectHelper.IsEquals(leadSource, oldLeadSource) && ObjectHelper.IsListEquals(_oldAgencies, lstAgencies) && ObjectHelper.IsListEquals(_oldLocations, lstLocations)) { blnClosing = true; Close(); } else { #region Save txtStatus.Text = "Saving Data..."; skpStatus.Visibility = Visibility.Visible; btnAccept.Visibility = Visibility.Collapsed; string strMsj = ValidateHelper.ValidateForm(this, "Lead Source", blnDatagrids: true); if (strMsj == "") { #region Locations List <Location> lstLocAdd = lstLocations.Where(lc => !_oldLocations.Any(lcc => lcc.loID == lc.loID)).ToList(); List <Location> lstLocDel = _oldLocations.Where(lc => !lstLocations.Any(lcc => lcc.loID == lc.loID)).ToList(); #endregion #region Agencies List <Agency> lstAgeAdd = lstAgencies.Where(ag => !_oldAgencies.Any(agg => agg.agID == ag.agID)).ToList(); List <Agency> lstAgeDel = _oldAgencies.Where(ag => !lstAgencies.Any(agg => agg.agID == ag.agID)).ToList(); #endregion int nRes = await BRLeadSources.SaveLeadSource(leadSource, lstLocAdd, lstLocDel, lstAgeAdd, lstAgeDel, (enumMode == EnumMode.Edit)); UIHelper.ShowMessageResult("Lead Source", nRes); if (nRes > 0) { blnClosing = true; DialogResult = true; Close(); } btnAccept.Visibility = Visibility.Visible; } else { UIHelper.ShowMessage(strMsj); } skpStatus.Visibility = Visibility.Collapsed; #endregion } } #endregion #region Search else { blnClosing = true; DialogResult = true; nStatus = Convert.ToInt32(cmbStatus.SelectedValue); nRegen = Convert.ToInt32(cmbRegen.SelectedValue); nAnimation = Convert.ToInt32(cmbAnimation.SelectedValue); Close(); } #endregion }