Exemplo n.º 1
0
        // Добавление нового Email

        private void btnAddNewEmail_Click(object sender, RoutedEventArgs e)
        {
            if (Regex.IsMatch(_newEmail.Email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase))
            {
                _emailList.Add(_newEmail);
                gNewEmail.DataContext = _newEmail = new EmailPeople();
                dgEmail.ItemsSource   = _emailList.ToArray();
            }
            else
            {
                MessageService.MetroMessageDialogError("Вы ввели неверный Email адрес!");
            }
        }
Exemplo n.º 2
0
        // Удаление email

        private async void dgEmail_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete && dgEmail.SelectedItem != null)
            {
                MessageDialogResult dialogResult = await MessageService.MetroMessageDialogQuestion("Подтверждение удаления", "Вы действительно хотите удалить выбранный элемент?");

                if (dialogResult == MessageDialogResult.Affirmative)
                {
                    EmailPeople emailPeople = dgEmail.SelectedItem as EmailPeople;

                    if (emailPeople.ID != 0)
                    {
                        _delEmailList.Add(emailPeople);
                    }

                    _emailList.Remove(emailPeople);
                    dgEmail.ItemsSource = _emailList.ToArray();
                }
            }
        }
Exemplo n.º 3
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    People people             = _newPeople = new People();
                    _newCardClient            = new CardClient();
                    _newPhone                 = new PhonePeople();
                    _newEmail                 = new EmailPeople();
                    _phoneList                = new List <PhonePeople>();
                    _emailList                = new List <EmailPeople>();
                    CardClient cardClient     = _newCardClient;
                    Deal[] dealArr            = null;
                    TaskBD[] taskBDArr        = null;
                    People[] peopleCompanyArr = null;

                    if (!_isNewRecord)
                    {
                        people     = _databasenEtities.People.Single(a => a.ID == _ID_Row);
                        cardClient = _databasenEtities.CardClient.Single(a => a.ID == people.ID_CardClient);
                        _phoneList.AddRange(_databasenEtities.PhonePeople.Where((a) => a.ID_People == _ID_Row).ToArray());
                        _emailList.AddRange(_databasenEtities.EmailPeople.Where((a) => a.ID_People == _ID_Row).ToArray());
                        dealArr   = _databasenEtities.Deal.Where(a => a.People.ID_CardClient == cardClient.ID).ToArray();
                        taskBDArr = _databasenEtities.TaskBD.Where(a => a.ID_Client == cardClient.ID || a.ID_People == _ID_Row).ToArray();
                    }

                    PostPeople[] postPeopleArr = _databasenEtities.PostPeople.ToArray();
                    CardClient[] companyArr    = _databasenEtities.CardClient.Where(a => !String.IsNullOrEmpty(a.NameCompany) || a.ID == people.ID_CardClient).OrderBy(a => a.NameCompany).ToArray();
                    Country[] countryArr       = _databasenEtities.Country.OrderBy(a => a.Name).ToArray();
                    TypePhone[] typePhoneArr   = _databasenEtities.TypePhone.OrderBy(a => a.Name).ToArray();
                    TypeEmail[] typeEmailArr   = _databasenEtities.TypeEmail.OrderBy(a => a.Name).ToArray();

                    if (!_isNewRecord && !String.IsNullOrEmpty(people.CardClient.NameCompany))
                    {
                        peopleCompanyArr = _databasenEtities.People.Where(a => a.ID_CardClient == people.ID_CardClient && a.ID != people.ID).ToArray();
                    }

                    Dispatcher.Invoke(() =>
                    {
                        gGeneralInfo.DataContext = people;
                        gContactInfo.DataContext = dpCreateCard.DataContext = cardClient;
                        cbPost.ItemsSource       = postPeopleArr;

                        List <CardClient> tempCardClient = new List <CardClient>();

                        if (_isNewRecord || !String.IsNullOrEmpty(cardClient.NameCompany))
                        {
                            tempCardClient.Add(_newCardClient);
                        }

                        tempCardClient.AddRange(companyArr);

                        cbCompany.ItemsSource = tempCardClient;
                        cbCountry.ItemsSource = countryArr;

                        dgcbTypePhone.ItemsSource = cbTypePhone.ItemsSource = typePhoneArr;
                        dgcbTypeEmail.ItemsSource = cbTypeEmail.ItemsSource = typeEmailArr;
                        gNewPhone.DataContext     = _newPhone;
                        gNewEmail.DataContext     = _newEmail;
                        dgPhone.ItemsSource       = _phoneList.ToArray();
                        dgEmail.ItemsSource       = _emailList.ToArray();
                        dgPeople.ItemsSource      = peopleCompanyArr;

                        cbEntity.IsChecked = String.IsNullOrEmpty(cardClient.NameCompany) ? false : true;

                        if (!_isNewRecord)
                        {
                            dgDeal.ItemsSource = dealArr;
                            dgTask.ItemsSource = taskBDArr;

                            if (!String.IsNullOrEmpty(people.CardClient.NameCompany))
                            {
                                ePeopleCompany.Visibility = Visibility.Visible;
                            }
                        }

                        gMain.IsEnabled = true;

                        if (_isNewRecord)
                        {
                            dpCreateCard.SelectedDate = DateTime.Now;
                            dpCreateCard.IsEnabled    = false;
                        }
                    });
                }
                catch (Exception ex)
                {
                    MessageService.MetroMessageDialogError(ex.Message);
                }
            });
        }