/// <summary> /// Establece la configuracion de la impresora /// </summary> private void SetPrinterConfig() { try { PrinterConfigRequest printerConfigRequest = new PrinterConfigRequest(); printerConfigRequest.CodigoCaja = this.token.CodeBox; printerConfigRequest.CodigoTienda = this.token.CodeStore; PrinterConfigResponse printerConfigResponse = repository.getPrinterConfig(printerConfigRequest); //Configuracion de la impresora PrinterSettings ps = new PrinterSettings(); PrinterName = printerConfigResponse.NombreImpresora; ps.PrinterName = printerConfigResponse.NombreImpresora; // IEnumerable<PaperSize> paperSizes = ps.PaperSizes.Cast<PaperSize>(); // PaperSize sizeA4 = paperSizes.First<PaperSize>(size => size.Kind == PaperKind.Letter); // this.printDocument.DefaultPageSettings.PaperSize = sizeA4; this.printDocument.PrinterSettings = ps; this.printDocument.PrintPage += new PrintPageEventHandler(this.printDocument1_PrintPage); } catch (Exception exception) { TryCatchBusinessExecutor tryCatch = new TryCatchBusinessExecutor(); tryCatch.AddErrorLog <OperationResponse>(exception.Message, exception.StackTrace, "Negocio", exception.ToString(), "Error de impresión"); } }
/// <summary> /// Establece la configuracion de la impresora /// </summary> private void SetPrinterConfig() { PrinterConfigRequest printerConfigRequest = new PrinterConfigRequest(); printerConfigRequest.CodigoCaja = this.token.CodeBox; printerConfigRequest.CodigoTienda = this.token.CodeStore; this.printerConfigResponse = printTicketRepository.getPrinterConfig(printerConfigRequest); this.PrinterName = this.printerConfigResponse.NombreImpresora; }
/// <summary> /// Establece la configuracion de la impresora /// </summary> private void SetPrinterConfig() { PrinterConfigRequest printerConfigRequest = new PrinterConfigRequest(); printerConfigRequest.CodigoCaja = this.token.CodeBox; printerConfigRequest.CodigoTienda = this.token.CodeStore; this.printerConfigResponse = repository.getPrinterConfig(printerConfigRequest); this.PrinterName = this.printerConfigResponse.NombreImpresora; printDocument.PrinterSettings.PrinterName = this.PrinterName; this.drawFont = new Font("Courier New", 8); this.drawBrush = new SolidBrush(System.Drawing.Color.Black); this.pos = new System.Drawing.Point(10, 10); printDocument.PrintPage += new PrintPageEventHandler(this.pd_PrintPage); }
/// <summary> /// Trae la configuracion de la impresora /// </summary> /// <param name="printerConfigRequest"></param> /// <returns></returns> public PrinterConfigResponse getPrinterConfig(PrinterConfigRequest printerConfigRequest) { PrinterConfigResponse printerConfigResponse = new PrinterConfigResponse(); var parameters = new Dictionary <string, object>(); parameters.Add("@CodigoCaja", printerConfigRequest.CodigoCaja); parameters.Add("@CodigoTienda", printerConfigRequest.CodigoTienda); foreach (var c in data.GetDataReader("dbo.sp_vanti_ObtenerConfigImpresoraReportes", parameters)) { printerConfigResponse.NombreImpresora = c.GetValue(0).ToString(); } return(printerConfigResponse); }
/// <summary> /// Imprime el reporte de la relacion de caja del id dado /// </summary> /// <param name="idReporte"></param> /// <returns></returns> public OperationResponse printReporte(int idReporte) { OperationResponse operationResponse = new OperationResponse(); try { Boolean isValid = printDocument.PrinterSettings.IsValid; Boolean isDefault = printDocument.PrinterSettings.IsDefaultPrinter; if (isValid) { PrinterConfigRequest printerConfigRequest = new PrinterConfigRequest(); printerConfigRequest.CodigoTienda = this.token.CodeStore; printDocument.PrinterSettings.PrintFileName = "RelacionCaja"; this.CurrentData = this.repository.getReporteRelacionCaja(idReporte); //Trayendo la info de la tienda this.rch = this.repository.getHeader(printerConfigRequest, idReporte); printDocument.Print(); operationResponse.CodeNumber = "100"; operationResponse.CodeDescription = "ok"; } else { string err = "Error de configuracion Impresora:" + PrinterName + " Tienda:" + token.CodeStore + " Caja: " + token.CodeBox; TryCatchBusinessExecutor tryCatch = new TryCatchBusinessExecutor(); tryCatch.AddErrorLog <OperationResponse>(err, "", "Negocio", "", "Error de impresión"); operationResponse.CodeNumber = "200"; operationResponse.CodeDescription = err; } } catch (Exception exception) { TryCatchBusinessExecutor tryCatch = new TryCatchBusinessExecutor(); tryCatch.AddErrorLog <OperationResponse>(exception.Message, exception.StackTrace, "Negocio", exception.ToString(), "Error de impresión"); operationResponse.CodeNumber = "200"; operationResponse.CodeDescription = exception.ToString(); } // operationResponse.CodeDescription = JsonConvert.SerializeObject(this.CurrentData); return(operationResponse); }
/// <summary> /// Trae la configuracion de la impresora /// </summary> /// <param name="printerConfigRequest"></param> /// <param name="idRelacionCaja"></param> /// <returns></returns> public RelacionCajaHeaderResponse getHeader(PrinterConfigRequest printerConfigRequest, int idRelacionCaja) { RelacionCajaHeaderResponse relacionCajaHeader = new RelacionCajaHeaderResponse(); var parameters = new Dictionary <string, object>(); parameters.Add("@CodigoTienda", printerConfigRequest.CodigoTienda); parameters.Add("@IdRelacionCaja", idRelacionCaja); foreach (var c in data.GetDataReader("dbo.sp_vanti_ObtenerCabeceraRelacionCaja", parameters)) { relacionCajaHeader.CodigoTienda = Convert.ToInt32(c.GetValue(0)); relacionCajaHeader.Marca = c.GetValue(1).ToString(); relacionCajaHeader.Direccion = c.GetValue(2).ToString(); relacionCajaHeader.Telefono = c.GetValue(3).ToString(); relacionCajaHeader.Fecha = c.GetValue(4).ToString(); relacionCajaHeader.DescripcionTienda = c.GetValue(5).ToString(); } return(relacionCajaHeader); }