/// <summary> /// 检查是否设置了默认打印机和打印模板 /// </summary> static void CheckInitData() { var defaultTemplate = BillPrintHelper.GetDefaultTemplatePath(); var defaultPrinter = BillPrintHelper.GetDefaultPrinter(); if (string.IsNullOrEmpty(defaultPrinter) || string.IsNullOrEmpty(defaultTemplate)) { new FrmWizard().ShowDialog(); } }
/// <summary> /// 保存默认打印机 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveDefaultPrinter_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var printName = gvPrinter.GetFocusedDisplayText(); if (!string.IsNullOrEmpty(printName)) { BillPrintHelper.SaveDefaultPrinterName(printName); PrinterHelper.SetDefaultPrinter(printName); XtraMessageBox.Show("保存成功", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information); var defaultPrinter = BillPrintHelper.GetDefaultPrinter(); if (!string.IsNullOrEmpty(defaultPrinter)) { lblDefaultPrinter.Text = @"默认打印机:" + defaultPrinter; } } }
/// <summary> /// 窗体加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmPrinterSetting_Load(object sender, EventArgs e) { // 加载系统默认打印机信息到系统中 var list = PrinterHelper.GetLocalPrinters(); gcPrinter.DataSource = list; gvPrinter.Columns["Column"].Width = 22; gvPrinter.Columns["Column"].OptionsColumn.ShowCaption = false; gvPrinter.Columns["Column"].OptionsColumn.AllowSort = DefaultBoolean.False; var defaultPrinter = BillPrintHelper.GetDefaultPrinter(); if (!string.IsNullOrEmpty(defaultPrinter)) { lblDefaultPrinter.Text = @"默认打印机:" + defaultPrinter; } }
private void FrmSystemSetting_Load(object sender, EventArgs e) { BindTemplate(); BindPrinter(); var defaultPrinter = BillPrintHelper.GetDefaultPrinter(); if (!string.IsNullOrEmpty(defaultPrinter)) { lsbPrinter.SelectedValue = defaultPrinter; lblDefaultPrinter.Text = @"默认打印机:" + defaultPrinter; } var defaultPrintTemplate = BillPrintHelper.GetDefaultTemplatePath(); if (!string.IsNullOrEmpty(defaultPrintTemplate)) { var templateEntity = _baseTemplateManager.GetList <BaseTemplateEntity>(new KeyValuePair <string, object>(BaseTemplateEntity.FieldFilePath, defaultPrintTemplate)).FirstOrDefault(); if (templateEntity != null) { var expressEntity = _expressManager.GetObject(templateEntity.ExpressId.ToString()); lsbTemplate.SelectedValue = expressEntity.Name + "-" + templateEntity.Name; lblDefaultPrintTemplate.Text = @"默认打印模板:" + expressEntity.Name + "-" + templateEntity.Name; } } }