📄 gysghhz.pas
字号:
unit gysghhz;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGridEh, ComCtrls, StdCtrls, DBCtrls, ExtCtrls, Mask,
DBCtrlsEh, Spin, DBLookupEh, StdActns, ActnList, ActnMan, Menus, PrnDbgeh,
DBGridEhImpExp, Buttons,ADODB,db;
type
Tgysghfrm = class(TForm)
Panel1: TPanel;
DBNavigator1: TDBNavigator;
GroupBox1: TGroupBox;
Label8: TLabel;
Edit1: TEdit;
Button1: TButton;
slcb1: TComboBox;
sled1: TSpinEdit;
slxx1: TComboBox;
Label2: TLabel;
Button2: TButton;
dblkbox: TDBLookupComboboxEh;
stb: TStatusBar;
SaveDialog1: TSaveDialog;
MYPDBGEh: TPrintDBGridEh;
PopupMenu1: TPopupMenu;
N2: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
PrintSetup1: TMenuItem;
N1: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
ActionManager1: TActionManager;
EditCut1: TEditCut;
EditCopy1: TEditCopy;
EditPaste1: TEditPaste;
EditDelete1: TEditDelete;
FilePrintSetup1: TFilePrintSetup;
FontEdit1: TFontEdit;
ColorSelect1: TColorSelect;
PrintDlg1: TPrintDlg;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
Panel2: TPanel;
GroupBox2: TGroupBox;
nf_spe: TSpinEdit;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
yf_spe: TSpinEdit;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
DBGridEh2: TDBGridEh;
DBGridEh1: TDBGridEh;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FontEdit1Accept(Sender: TObject);
procedure PrintSetup1Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N8Click(Sender: TObject);
procedure N9Click(Sender: TObject);
procedure nf_speChange(Sender: TObject);
procedure TabSheet2Show(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
private
{ Private declarations }
public
sxtjtx:string;
{ Public declarations }
end;
var
gysghfrm: Tgysghfrm;
implementation
uses data, main, zlflashfrm;
{$R *.dfm}
procedure Tgysghfrm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action:=cafree;
gysghfrm:=nil;
end;
procedure Tgysghfrm.FormCreate(Sender: TObject);
var year,month,day:Word;
begin
if not Assigned(OKBottomDlg) then
OKBottomDlg := tOKBottomDlg.Create(Self);
OKBottomDlg.Show;
OKBottomDlg.Refresh;
decodedate(now,year,month,day);
yf_spe.Value:=month;
dm.jzxxbads.Close;
dm.jzxxbads.Open;
dm.jzxxbads.Filter:='结转项目='+''''+'材料'+'''';
dm.jzxxbads.Filtered:=true;
nf_spe.MinValue:=dm.jzxxbads.fieldbyname('开始年份').Value;
nf_spe.MaxValue:=dm.jzxxbads.fieldbyname('最后年份').Value;
nf_spe.Value:=dm.jzxxbads.fieldbyname('最后年份').Value;
dm.whcllxdmads.Open;
dm.whclbmads.Open;
dm.whgysdmads.Open;
dm.whysrads.Open;
dm.whjclxdmads.Open;
dm.cxads_gysmyjh.Close;
dm.cxads_gysmyjh.Parameters.ParamByName('nf').Value:=nf_spe.Value;
dm.cxads_gysmyjh.Parameters.ParamByName('yf').Value:=yf_spe.Value;
dm.cxads_gysmyjh.Prepared;
dm.cxads_gysmyjh.Open;
OKBottomDlg.Close;
end;
procedure Tgysghfrm.Button1Click(Sender: TObject);
begin
close;
end;
procedure Tgysghfrm.Button2Click(Sender: TObject);
var sxtj:string;
begin
sxtj:='';
if trim(edit1.Text)<>'' then
sxtj:='材料编码 like %'+trim(edit1.Text)+'%';
if slxx1.ItemIndex>0 then
if sxtj<>'' then
sxtj:=sxtj+' and '+slxx1.Text+slcb1.Text+sled1.Text
else
sxtj:=slxx1.Text+slcb1.Text+sled1.Text;
if checkbox2.Checked then
if (dblkbox.KeyValue<>'') and
(dblkbox.KeyValue<>null) then
if sxtj<>'' then
sxtj:=sxtj+' and 供应商ID='+''''+dblkbox.KeyValue+''''
else
sxtj:='供应商ID='+''''+dblkbox.KeyValue+'''';
dm.cxads_gysmyjh.Filtered:=false;
dm.cxads_gysghmx.Filtered:=false;
if trim(sxtj)<>'' then
begin
dm.cxads_gysmyjh.Filter:=sxtj;
dm.cxads_gysmyjh.Filtered:=true;
dm.cxads_gysghmx.Filter:=sxtj;
dm.cxads_gysghmx.Filtered:=true;
end;
sxtjtx:=sxtj;
sxtjtx:=StringReplace(sxtjtx,'and','以及',[rfReplaceAll]);
sxtjtx:=StringReplace(sxtjtx,'like %','包含"',[rfReplaceAll]);
sxtjtx:=StringReplace(sxtjtx,'%','"',[rfReplaceAll]);
sxtjtx:='查询条件:'+sxtjtx;
stb.SimpleText:=sxtjtx;
end;
procedure Tgysghfrm.FontEdit1Accept(Sender: TObject);
begin
TDBGridEh(ActiveControl).Font:=FontEdit1.Dialog.Font;
TDBGridEh(ActiveControl).FooterFont:=FontEdit1.Dialog.Font;
TDBGridEh(ActiveControl).TitleFont:=FontEdit1.Dialog.Font;
end;
procedure Tgysghfrm.PrintSetup1Click(Sender: TObject);
var bt,tj:string;
begin
if PageControl1.ActivePageIndex=0 then
bt:='供应商供货汇总表';
if PageControl1.ActivePageIndex=1 then
bt:='供应商供货明细表';
tj:=inttostr(nf_spe.value)+'年'+inttostr(yf_spe.Value)+'月. '+sxtjtx;
if (ActiveControl is TDBGridEh) then
begin
MYPDBGEh.DBGridEh := TDBGridEh(ActiveControl);
MYPDBGEh.SetSubstitutes(['%[Today]',DateToStr(Now),'%[bt]',bt,'%[tj]',tj]);
MYPDBGEh.print;
end;
end;
procedure Tgysghfrm.N1Click(Sender: TObject);
var bt,tj:string;
begin
if PageControl1.ActivePageIndex=0 then
bt:='供应商供货汇总表';
if PageControl1.ActivePageIndex=1 then
bt:='供应商供货明细表';
tj:=inttostr(nf_spe.value)+'年'+inttostr(yf_spe.Value)+'月. '+sxtjtx;
begin
MYPDBGEh.DBGridEh := TDBGridEh(ActiveControl);
MYPDBGEh.SetSubstitutes(['%[Today]',DateToStr(Now),'%[bt]',bt,'%[tj]',tj]);
MYPDBGEh.Preview;
end;
end;
procedure Tgysghfrm.N4Click(Sender: TObject);
var ExpClass:TDBGridEhExportClass;
Ext:String;
begin
SaveDialog1.FileName := 'file1';
if (ActiveControl is TDBGridEh) then
if SaveDialog1.Execute then
begin
case SaveDialog1.FilterIndex of
1: begin ExpClass := TDBGridEhExportAsXLS; Ext := 'xls'; end;
2: begin ExpClass := TDBGridEhExportAsCSV; Ext := 'csv'; end;
3: begin ExpClass := TDBGridEhExportAsHTML; Ext := 'htm'; end;
4: begin ExpClass := TDBGridEhExportAsRTF; Ext := 'rtf'; end;
5: begin ExpClass := TDBGridEhExportAsText; Ext := 'txt'; end;
else
ExpClass := nil; Ext := '';
end;
if ExpClass <> nil then
begin
if UpperCase(Copy(SaveDialog1.FileName,Length(SaveDialog1.FileName)-2,3)) <>
UpperCase(Ext) then
SaveDialog1.FileName := SaveDialog1.FileName + '.' + Ext;
SaveDBGridEhToExportFile(ExpClass,TDBGridEh(ActiveControl),
SaveDialog1.FileName,true);
end;
end;
end;
procedure Tgysghfrm.N8Click(Sender: TObject);
begin
TDBGridEh(ActiveControl).Columns
[TDBGridEh(ActiveControl).SelectedIndex].Visible:=false;
if TDBGridEh(ActiveControl).SelectedIndex<
TDBGridEh(ActiveControl).Columns.Count-1 then
TDBGridEh(ActiveControl).SelectedIndex:=
TDBGridEh(ActiveControl).SelectedIndex+1;
end;
procedure Tgysghfrm.N9Click(Sender: TObject);
var i:integer;
begin
for i:=1 to TDBGridEh(ActiveControl).Columns.Count-1 do
begin
TDBGridEh(ActiveControl).Columns[i].Visible:=true;
end;
end;
procedure Tgysghfrm.nf_speChange(Sender: TObject);
begin
if nf_spe.Value>nf_spe.MaxValue then
nf_spe.Value:=nf_spe.MaxValue;
if nf_spe.Value<nf_spe.MinValue then
nf_spe.Value:=nf_spe.MinValue;
dm.cxads_gysmyjh.Close;
dm.cxads_gysmyjh.Parameters.ParamByName('nf').Value:=nf_spe.Value;
dm.cxads_gysmyjh.Parameters.ParamByName('yf').Value:=yf_spe.Value;
dm.cxads_gysmyjh.Prepared;
dm.cxads_gysmyjh.Open;
dm.cxads_gysghmx.Close;
dm.cxads_gysghmx.Parameters.ParamByName('nf').Value:=nf_spe.Value;
dm.cxads_gysghmx.Parameters.ParamByName('yf').Value:=yf_spe.Value;
dm.cxads_gysghmx.Parameters.ParamByName('gys').Value:=
dm.cxads_gysmyjh.FieldByName('供应商id').Value;
dm.cxads_gysghmx.Prepared;
dm.cxads_gysghmx.Open;
end;
procedure Tgysghfrm.TabSheet2Show(Sender: TObject);
begin
dm.cxads_gysghmx.Close;
dm.cxads_gysghmx.Parameters.ParamByName('nf').Value:=nf_spe.Value;
dm.cxads_gysghmx.Parameters.ParamByName('yf').Value:=yf_spe.Value;
dm.cxads_gysghmx.Parameters.ParamByName('gys').Value:=
dm.cxads_gysmyjh.FieldByName('供应商id').Value;
dm.cxads_gysghmx.Prepared;
dm.cxads_gysghmx.Open;
end;
procedure Tgysghfrm.CheckBox1Click(Sender: TObject);
begin
dbgrideh1.AutoFitColWidths:=checkbox1.Checked;
end;
procedure Tgysghfrm.CheckBox2Click(Sender: TObject);
begin
dblkbox.Enabled:=checkbox2.Checked;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -