Esempio n. 1
0
        private void btnAddCustomerID_Click(object sender, RoutedEventArgs e)
        {
            UCCustomerSearch ucCustomerSearch = new UCCustomerSearch();

            ucCustomerSearch.SelectionMode = SelectionMode.Multiple;
            ucCustomerSearch.DialogHandle  = CurrentWindow.ShowDialog(ResCustomerPicker.Dialog_Title, ucCustomerSearch, (obj, args) =>
            {
                if (args.DialogResult == DialogResultType.OK)
                {
                    CouponsInfoViewModel vm = this.DataContext as CouponsInfoViewModel;
                    if (vm.CustomerCondition.RelCustomers.CustomerIDList == null)
                    {
                        vm.CustomerCondition.RelCustomers.CustomerIDList = new List <CustomerAndSendViewModel>();
                    }

                    List <CustomerVM> selectedList = args.Data as List <CustomerVM>;
                    foreach (CustomerVM cv in selectedList)
                    {
                        vm.CustomerCondition.RelCustomers.CustomerIDList.Add(new CustomerAndSendViewModel()
                        {
                            CustomerSysNo = cv.SysNo,
                            CustomerID    = cv.CustomerID,
                            CustomerName  = cv.CustomerName,
                            IsChecked     = false
                        });
                    }
                    dgCustomerID.ItemsSource = vm.CustomerCondition.RelCustomers.CustomerIDList;
                    dgCustomerID.Bind();
                }
            });
        }
Esempio n. 2
0
        private void LoadCustomerByPhone()
        {
            viewModel.Phone = tbCustomerPhone.Text.Trim();
            List <ValidationEntity> list = new List <ValidationEntity>();

            list.Add(new ValidationEntity(ValidationEnum.RegexCheck, @"\d{7}", string.Format(ResCustomerCallingMaintain.msg_VaildatePhone, viewModel.Phone.Length)));
            if (!ValidationHelper.Validation(this.tbCustomerPhone, list))
            {
                return;
            }

            CustomerQueryFilter filter = new CustomerQueryFilter();

            filter.Phone      = viewModel.Phone;
            filter.PagingInfo = new PagingInfo()
            {
                PageIndex = 0, PageSize = int.MaxValue
            };
            new CustomerQueryFacade(CPApplication.Current.CurrentPage).QueryCustomer(filter, (obj, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }
                if (args.Result != null && args.Result.TotalCount != 0)
                {
                    if (args.Result.TotalCount > 1)//>1的话就让用户选择具体的用户
                    {
                        UCCustomerSearch ucCustomerSearch = new UCCustomerSearch();
                        ucCustomerSearch.SelectionMode    = SelectionMode.Single;
                        ucCustomerSearch.DialogHandle     = CPApplication.Current.CurrentPage.Context.Window.ShowDialog(ResCustomerPicker.Dialog_Title, ucCustomerSearch, (param, dialogRes) =>
                        {
                            if (dialogRes.DialogResult == DialogResultType.OK)
                            {
                                BindControl(dialogRes.Data, string.Empty, viewModel.Phone);
                            }
                        });
                        ucCustomerSearch._viewModel.CustomerPhone = viewModel.Phone;
                        ucCustomerSearch.BindDataGrid(1, null);
                    }
                    else
                    {
                        BindControl(args.Result.Rows[0], string.Empty, viewModel.Phone);
                    }
                }
                else
                {
                    ClearControl();
                }
            });
        }