Created
August 7, 2013 05:02
-
-
Save anonymous/6171325 to your computer and use it in GitHub Desktop.
Impresión de documentos de programa de Gestión desde 0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit UIMPPPAF; | |
interface | |
uses | |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
Dialogs, StdCtrls, Buttons, Spin, Printers, ExtCtrls, rpcompobase, rpvclreport, | |
rplabelitem, DB; | |
type | |
TFIMPPPAF = class(TForm) | |
Label1: TLabel; | |
Label2: TLabel; | |
CheckBox1: TCheckBox; | |
GroupBox1: TGroupBox; | |
GroupBox2: TGroupBox; | |
Label3: TLabel; | |
CheckBox2: TCheckBox; | |
Label4: TLabel; | |
CheckBox3: TCheckBox; | |
Edit1: TEdit; | |
Edit2: TEdit; | |
SBImprimir: TSpeedButton; | |
SB_Salir: TSpeedButton; | |
SpinEdit1: TSpinEdit; | |
SpinEdit2: TSpinEdit; | |
ComboBox1: TComboBox; | |
CheckBox4: TCheckBox; | |
CheckBox5: TCheckBox; | |
Label5: TLabel; | |
Panel1: TPanel; | |
CheckBox6: TCheckBox; | |
VCLReport1: TVCLReport; | |
Label6: TLabel; | |
Memo1: TMemo; | |
SpinEdit3: TSpinEdit; | |
DsPre: TDataSource; | |
DsPe: TDataSource; | |
DsAl: TDataSource; | |
DsFa: TDataSource; | |
procedure FormActivate(Sender: TObject); | |
procedure CheckBox6Click(Sender: TObject); | |
procedure SBImprimirClick(Sender: TObject); | |
procedure SpinEdit3Change(Sender: TObject); | |
procedure VCLReport1BeforePrint(Sender: TObject); | |
procedure SB_SalirClick(Sender: TObject); | |
private | |
{ Private declarations } | |
public | |
{ Public declarations } | |
end; | |
var | |
FIMPPPAF: TFIMPPPAF; | |
VarBIMPPPAFOriginal:Boolean; | |
implementation | |
{$R *.dfm} | |
uses UXPAF,UDM, Fun; | |
procedure TFIMPPPAF.CheckBox6Click(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*********************************************************[ Mostrar Texto ]**** | |
// Selecciona o no las palabras ORIGINA Y COPIA EN EL DOCUMENTO | |
//------------------------------------------------------------------------------ | |
begin | |
if CheckBox6.Checked then | |
begin | |
CheckBox2.Checked:=True; | |
CheckBox3.Checked:=True; | |
end else | |
begin | |
CheckBox2.Checked:=False; | |
CheckBox3.Checked:=False; | |
end; | |
end; | |
procedure TFIMPPPAF.FormActivate(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************************[ ONACTIVE ]**** | |
// Al activarse el FORM | |
//------------------------------------------------------------------------------ | |
begin | |
ComboBox1.Items := Printer.Printers; | |
ComboBox1.ItemIndex:=Printer.PrinterIndex; | |
SpinEdit3.Value:=1; | |
SpinEdit3Change(Sender); | |
end; | |
procedure TFIMPPPAF.SBImprimirClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//************************************************************[ IMPRIME ]******* | |
// Muestra directamente este reporte | |
//------------------------------------------------------------------------------ | |
var VarSIMPPPAFNumREP,VarScadTit:string; | |
VarIIMPPPAFPNumREP,VarIIMPPPAFFNumREP, I:Integer; | |
begin | |
if VarSTipoDocumento='FACTURA' then ShowMessage('Carga la factura'); | |
if VarSTipoDocumento='ALBARAN' then ShowMessage('Carga el albarán'); | |
if VarSTipoDocumento='PEDIDO' then ShowMessage('Carga el pedido'); | |
if VarSTipoDocumento='PRESUPUESTO' then ShowMessage('Carga el presupuesto'); | |
VarSIMPPPAFNumREP:=Edit1.Text; | |
VarIIMPPPAFPNumREP:=SoloInteger(Edit1.Text); | |
VarIIMPPPAFFNumREP:=SoloInteger(Edit2.Text); | |
//Carga los parametros (pongo el ejemplo de lo que yo hago) | |
{ | |
VCLReport1.Report.Params.ParamByName('LDPD').AsString := Memo1.Lines.Text; | |
VCLReport1.Preview :=CheckBox4.Checked; | |
VCLReport1.ShowPrintDialog:=CheckBox5.Checked; | |
while not (VarIIMPPPAFPNumREP>VarIIMPPPAFFNumREP) do | |
begin //ORIGINALES | |
VarBIMPPPAFOriginal:=True; | |
if SpinEdit1.Value>0 then | |
begin | |
VCLReport1.Title:=VarScadTit+' O-'+IntToStr(VarIIMPPPAFPNumREP); | |
VCLReport1.Report.Params.ParamByName('VREPNDOC1').AsString := VarSIMPPPAFNumREP; | |
if VarSTipoDocumento='FACTURA' then if DsPre.DataSet.Locate('NUM_DOC',VarSIMPPPAFNumREP,[loCaseInsensitive,loPartialKey]) then VCLReport1.Report.Params.ParamByName('NOTAS').AsString :=DsPre.DataSet.FieldByName('NOTAS').AsString; | |
if VarSTipoDocumento='ALBARAN' then if DsPe.DataSet.Locate('NUM_DOC',VarSIMPPPAFNumREP,[loCaseInsensitive,loPartialKey]) then VCLReport1.Report.Params.ParamByName('NOTAS').AsString :=DsPe.DataSet.FieldByName('NOTAS').AsString; | |
if VarSTipoDocumento='PEDIDO' then if Dsal.DataSet.Locate('NUM_DOC',VarSIMPPPAFNumREP,[loCaseInsensitive,loPartialKey]) then VCLReport1.Report.Params.ParamByName('NOTAS').AsString :=DsAl.DataSet.FieldByName('NOTAS').AsString; | |
if VarSTipoDocumento='PRESUPUESTO' then IF DsFa.DataSet.Locate('NUM_DOC',VarSIMPPPAFNumREP,[loCaseInsensitive,loPartialKey]) then VCLReport1.Report.Params.ParamByName('NOTAS').AsString :=DsFa.DataSet.FieldByName('NOTAS').AsString; | |
VCLReport1.Report.PrepareParamsBeforeOpen; | |
for I := 1 to SpinEdit1.Value do | |
begin | |
VCLReport1.Execute; | |
end; | |
end; | |
//COPIAS | |
VarBIMPPPAFOriginal:=False; | |
if SpinEdit2.Value>0 then | |
begin | |
VCLReport1.Title:=VarScadTit+' C-'+IntToStr(VarIIMPPPAFPNumREP); | |
VCLReport1.Report.Params.ParamByName('VREPNDOC1').AsString := VarSIMPPPAFNumREP; | |
if VarSTipoDocumento='FACTURA' then if DsPre.DataSet.Locate('NUM_DOC',VarSIMPPPAFNumREP,[loCaseInsensitive,loPartialKey]) then VCLReport1.Report.Params.ParamByName('NOTAS').AsString :=DsPre.DataSet.FieldByName('NOTAS').AsString; | |
if VarSTipoDocumento='ALBARAN' then if DsPe.DataSet.Locate('NUM_DOC',VarSIMPPPAFNumREP,[loCaseInsensitive,loPartialKey]) then VCLReport1.Report.Params.ParamByName('NOTAS').AsString :=DsPe.DataSet.FieldByName('NOTAS').AsString; | |
if VarSTipoDocumento='PEDIDO' then if Dsal.DataSet.Locate('NUM_DOC',VarSIMPPPAFNumREP,[loCaseInsensitive,loPartialKey]) then VCLReport1.Report.Params.ParamByName('NOTAS').AsString :=DsAl.DataSet.FieldByName('NOTAS').AsString; | |
if VarSTipoDocumento='PRESUPUESTO' then IF DsFa.DataSet.Locate('NUM_DOC',VarSIMPPPAFNumREP,[loCaseInsensitive,loPartialKey]) then VCLReport1.Report.Params.ParamByName('NOTAS').AsString :=DsFa.DataSet.FieldByName('NOTAS').AsString; | |
VCLReport1.Report.PrepareParamsBeforeOpen; | |
for I := 1 to SpinEdit2.Value do | |
begin | |
VCLReport1.Execute; | |
end; | |
end; | |
VarIIMPPPAFPNumREP:=VarIIMPPPAFPNumREP+1; | |
VarSIMPPPAFNumREP:=IntToStr(VarIIMPPPAFPNumREP); | |
end;} | |
end; | |
procedure TFIMPPPAF.SB_SalirClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*****************************************************************[ CLOSE ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
FIMPPPAF.close | |
end; | |
procedure TFIMPPPAF.SpinEdit3Change(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*********************************************************[ Onchange LDPD ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
Memo1.Lines.Clear; | |
case SpinEdit3.value of | |
1: Memo1.Lines.Text:=DM.IBDCONFILDPD1.AsString; | |
2: Memo1.Lines.Text:=DM.IBDCONFILDPD2.AsString; | |
3: Memo1.Lines.Text:=DM.IBDCONFILDPD3.AsString; | |
end; | |
end; | |
procedure TFIMPPPAF.VCLReport1BeforePrint(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*****************************************************[ Antes de imprimir ]**** | |
//------------------------------------------------------------------------------ | |
var VarSCadena:string; | |
begin //(pongo el ejemplo de lo que yo hago) | |
{ if VarBIMPPPAFOriginal then | |
begin | |
if CheckBox2.Checked then VarSCadena:='ORIGINAL' | |
else VarSCadena:=''; | |
end else | |
begin | |
if CheckBox3.Checked then VarSCadena:='COPIA' | |
else VarSCadena:=''; | |
end; | |
with VCLReport1.Report do | |
begin | |
if FindComponent('TrpLabel37') is TRpLabel then | |
begin | |
( FindComponent('TrpLabel37') as TRpLabel).Text:=VarSCadena; | |
end; | |
if FindComponent('TrpLabel25') is TRpLabel then | |
begin | |
if CheckBox1.Checked then ( FindComponent('TrpLabel25') as TRpLabel).Text:='DUPLICADO' | |
else ( FindComponent('TrpLabel25') as TRpLabel).Text:=''; | |
end; | |
end; } | |
end; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment