private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            CrystalPrintConfigModel validConfig = GetValidationModel();

            if (validConfig != null)
            {
                var model = this.gpConfig.DataContext as CrystalPrintConfigModel;
                if (model.Id == 0) // 插入打印配置
                {
                    string result = new CrystalPrintConfigService().AddConfig(validConfig);
                    MessageBox.Show(result);
                }
                else // 更新打印配置
                {
                    validConfig.Id = model.Id;
                    string result = new CrystalPrintConfigService().ModifyConfig(validConfig);
                    MessageBox.Show(result);
                }
                this.gpConfig.DataContext = new CrystalPrintConfigService().GetCrystalPrintConfig(1, Dns.GetHostName());
            }
            else
            {
                MessageBox.Show(" 参数录入不合法 ");
            }
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            this.MainGrid.Height = SystemParameters.PrimaryScreenHeight - 160;
            #region 组织机构
            var org = new OrganizationService().GetOrganization(user.SuperAdmin, user.OrgId);
            this.CbOrganization.DataContext   = org;
            this.CbOrganization.ItemsSource   = org;
            this.CbOrganization.SelectedIndex = 0;
            #endregion

            #region 打印机配置
            var printers = PrintHelper.GetComputerPrinter();
            this.CbPrinter.ItemsSource = printers;
            var config = new CrystalPrintConfigService().GetCrystalPrintConfig(1, Dns.GetHostName());
            if (config != null)
            {
                string printer = config.PrinterName;

                if (!printers.Contains(printer))
                {
                    this.CbPrinter.SelectedIndex   = -1;
                    this.CbPaperSize.SelectedIndex = -1;
                }
            }

            this.gpConfig.DataContext = config ?? new CrystalPrintConfigModel {
                MarginRight = 10, MarginLeft = 10, MarginBottom = 0, MarginTop = 0, Orientation = "横向"
            };

            this.CbOrientation.ItemsSource = new List <string> {
                "横向", "竖向"
            };
            #endregion

            #region 列表
            lists = new CustomerService().GetCustomers(Convert.ToInt32((this.CbOrganization.SelectedItem as OrganizationModel).Id));
            this.MainDataGrid.ItemsSource = new ObservableCollection <CustomerModel>(lists);
            #endregion
        }