Esempio n. 1
0
        /// <summary>
        /// Guarda los cambios
        /// </summary>
        /// <history>
        /// [emoguel] created 09/06/2016
        /// </history>
        private async void btnAccept_Click(object sender, RoutedEventArgs e)
        {
            btnAccept.Focus();
            List <LeadSource> lstLeadSources = (List <LeadSource>)dgrLeadSources.ItemsSource;

            if (enumMode != EnumMode.Add && ObjectHelper.IsEquals(zone, oldZone) && ObjectHelper.IsListEquals(lstLeadSources, _lstOldLeadSources))
            {
                _isClosing = true;
                Close();
            }
            else
            {
                string strMsj = ValidateHelper.ValidateForm(this, "Zone", blnDatagrids: true);
                if (strMsj == "")
                {
                    txtStatus.Text       = "Saving Data...";
                    skpStatus.Visibility = Visibility.Visible;
                    btnAccept.Visibility = Visibility.Collapsed;
                    List <LeadSource> lstAdd = lstLeadSources.Where(ls => !_lstOldLeadSources.Any(lss => lss.lsID == ls.lsID)).ToList();
                    List <LeadSource> lstDel = _lstOldLeadSources.Where(ls => !lstLeadSources.Any(lss => lss.lsID == ls.lsID)).ToList();
                    int nRes = await BRZones.SaveZone(zone, lstAdd, lstDel, (enumMode == EnumMode.Edit));

                    UIHelper.ShowMessageResult("Zone", nRes);
                    if (nRes > 0)
                    {
                        _isClosing   = true;
                        DialogResult = true;
                        Close();
                    }
                }
                else
                {
                    UIHelper.ShowMessage(strMsj);
                }
                skpStatus.Visibility = Visibility.Collapsed;
                btnAccept.Visibility = Visibility.Visible;
            }
        }