📄 leftandtopunit.pas
字号:
unit LeftAndTopUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Mask, DBCtrls, ExtCtrls, Db, ADODB,IniFiles, ImgList, Buttons,
ComCtrls;
type
TLeftAndTopFrm = class(TForm)
Button1: TButton;
Button2: TButton;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Upsbtn1: TSpeedButton;
Downsbtn1: TSpeedButton;
codelbl: TLabel;
FirstLabl1: TLabel;
SecondLabl2: TLabel;
SecondLabl3: TLabel;
DownAllsbtn1: TSpeedButton;
UpAllsbtn1: TSpeedButton;
YesPrintLBx: TListBox;
NoPrintLBx: TListBox;
FieldAQey: TADOQuery;
ADOQuery3: TADOQuery;
ADOQuery2: TADOQuery;
ImageList2: TImageList;
TabSheet2: TTabSheet;
Bevel1: TBevel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
LeftEdt: TEdit;
TopEdt: TEdit;
RBtnPor: TRadioButton;
RBtnLan: TRadioButton;
TabSheet3: TTabSheet;
ADOQuery1: TADOQuery;
EdtKind: TEdit;
Label5: TLabel;
CBxDateFormat: TComboBox;
AQeyFormat: TADOQuery;
ADOQuery4: TADOQuery;
procedure FormShow(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
procedure DBEdit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure LeftEdtEnter(Sender: TObject);
procedure LeftEdtExit(Sender: TObject);
procedure TopEdtEnter(Sender: TObject);
procedure TopEdtExit(Sender: TObject);
procedure LeftEdtKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure TopEdtKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Downsbtn1Click(Sender: TObject);
procedure Upsbtn1Click(Sender: TObject);
procedure YesPrintLBxClick(Sender: TObject);
procedure NoPrintLBxClick(Sender: TObject);
procedure YesPrintLBxDblClick(Sender: TObject);
procedure NoPrintLBxDblClick(Sender: TObject);
procedure DownAllsbtn1Click(Sender: TObject);
procedure UpAllsbtn1Click(Sender: TObject);
private
{ Private declarations }
StrSelect:string;
public
{ Public declarations }
strCode:string;
strTabelName:string; //票据打印配置数据表名
strKind:string; // 票据种类
strDateName:string; // 日期字段名称
procedure UpdateDisplay1();
function GetFirstSelection(List: TCustomListBox): Integer;
end;
var
LeftAndTopFrm:TLeftAndTopFrm;
borderini:Tinifile;
implementation
uses GlobalLibUnit, DataLinkUnit;
{$R *.DFM}
procedure TLeftAndTopFrm.FormShow(Sender: TObject);
var
f:string;
i:integer;
strName:string;//传递参数
begin
// 日期格式设置
AQeyFormat.SQL.Text:='select 数据格式 from TC07 where 票据种类='''
+strKind+''''+' and 打印项='''+strDateName+'''';
AQeyFormat.Open;
if AQeyFormat.FieldByName('数据格式').AsString='大写' then
CBxDateFormat.ItemIndex:=0
else
CBxDateFormat.ItemIndex:=1;
AQeyFormat.Close;
// 打印设置
UpdateDisplay1;
// 页面设置
{ 备注释的程序是李刚使用数据库用来查询某一票据的边距,
由于不能对修改的数据进行保存所以修改它
TC10ATbl.Active :=true;
TC10ATbl.Locate('D01',strCode,[loCaseInsensitive]);
TC10ATbl.Edit;}
{
以下程序是王海修改的,经原来用使用数据库存储边距改为
使用border.ini文件存储边距,文件路径为/ini/border.ini
修改日期2001-12-24
}
borderini:=Tinifile.Create(ExtractFilePath(Application.EXEName)+'ini\Border.ini');
LeftEdt.text:=inttostr(borderini.ReadInteger(strcode,'left',0));
TopEdt.text:=inttostr(borderini.ReadInteger(strcode,'Top',0));
if borderini.ReadInteger(strcode,'orientation',0)=0 then
RBtnPor.Checked :=true
else
RBtnLan.Checked :=true;
// leftedt.SetFocus;
end;
procedure TLeftAndTopFrm.Button2Click(Sender: TObject);
begin
Close;
end;
procedure TLeftAndTopFrm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TLeftAndTopFrm.Button1Click(Sender: TObject);
begin
if leftedt.text='' then
leftedt.text:='0';
if topedt.text='' then
topedt.text:='0';
borderini.writeInteger(strcode,'left',strtoint(LeftEdt.text));
borderini.writeInteger(strcode,'Top',strtoint(TopEdt.text));
if RBtnPor.Checked then
borderini.writeInteger(strcode,'orientation',0)
else
borderini.writeInteger(strcode,'orientation',1);
close;
AQeyFormat.SQL.Text:='select * from TC07 where 票据种类='''
+strKind+''''+' and 打印项='''+strDateName+'''';
AQeyFormat.Open;
if AQeyFormat.RecordCount=0 then Exit;
AQeyFormat.Edit;
if CBxDateFormat.ItemIndex=0 then
AQeyFormat.FieldByName('数据格式').AsString:='大写'
else
AQeyFormat.FieldByName('数据格式').AsString:='小写';
AQeyFormat.Post;
AQeyFormat.Close;
{此代码为李刚写的代码,现已经修改为使用INI文件的方法保存打印边距
TC10ATbl.Post ;}
{
以下是王海利用写入border.ini文件的方法将设置的边距写入border.ini
}
{ if leftedt.text='' then
leftedt.text:='0';
if topedt.text='' then
topedt.text:='0';
borderini.writeInteger(strcode,'left',strtoint(LeftEdt.text));
borderini.writeInteger(strcode,'Top',strtoint(TopEdt.text));
if RBtnPor.Checked then
borderini.writeInteger(strcode,'orientation',0)
else
borderini.writeInteger(strcode,'orientation',1);
close;
}
end;
procedure TLeftAndTopFrm.DBEdit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=13 then
Button1.SetFocus;
end;
procedure TLeftAndTopFrm.LeftEdtEnter(Sender: TObject);
begin
setfocuscolor(leftEdt);
end;
procedure TLeftAndTopFrm.LeftEdtExit(Sender: TObject);
begin
setexitcolor(LeftEdt);
end;
procedure TLeftAndTopFrm.TopEdtEnter(Sender: TObject);
begin
setfocuscolor(Topedt);
end;
procedure TLeftAndTopFrm.TopEdtExit(Sender: TObject);
begin
setexitcolor(Topedt);
end;
procedure TLeftAndTopFrm.LeftEdtKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=13 then
Topedt.SetFocus;
end;
procedure TLeftAndTopFrm.TopEdtKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=13 then
Button1.SetFocus;
end;
procedure TLeftAndTopFrm.UpdateDisplay1();
var
i:integer;
begin
strSelect:='select 打印项,打印标志 From '+StrTabelName+' where 票据种类='''
+strKind+'''';
DMMain.AdoQueryOpen1(strSelect,ADOQuery2,'0','1');
YesPrintLBx.Clear;
NoPrintLBx.Clear;
For i:=0 to ADOQuery2.RecordCount-1 do
begin
if ADOQuery2.Fields[1].AsString='Y' then
YesPrintLBx.Items.Add(ADOQuery2.Fields[0].AsString);
if ADOQuery2.Fields[1].AsString='N' then
NoPrintLBx.Items.Add(ADOQuery2.Fields[0].AsString);
ADOQuery2.Next;
end;
end;
{
procedure TLeftAndTopFrm.Downsbtn1Click(Sender: TObject);
var
i:integer;
strDelSQL:string; //查询参数
Index:integer;
begin
if NoPrintLBx.ItemIndex =-1 then
begin
NoPrintLBx.ItemIndex:=0;
end
else
begin
Index := GetFirstSelection(NoPrintLBx);
if Index+1=NoPrintLBx.Items.Count then Index:=Index-1;
if Index=-1 then Index:=0;
for i:=0 to (NoPrintLBx.Items.Count -1) do
if NoPrintLBx.Selected[i] then
strDelSQL:='update '+strTabelName+' set 打印标志'+'='''
+'Y'+''' where 票据种类='''
+strKind
+''' and 打印项='''+NoPrintLBx.Items[i]+'''';
DMMain.AdoQueryOpen(strDelSQL,FieldAQey,'1','1');
UpdateDisplay1;
NoPrintLBx.ItemIndex :=Index;
end;
end; }
procedure TLeftAndTopFrm.Downsbtn1Click(Sender: TObject);
var
i:integer;
strDelSQL:string; //查询参数
Index:integer;
begin
if NoPrintLBx.ItemIndex =-1 then
begin
NoPrintLBx.ItemIndex:=0;
end
else
begin
Index := GetFirstSelection(NoPrintLBx);
if Index+1=NoPrintLBx.Items.Count then Index:=Index-1;
if Index=-1 then Index:=0;
for i:=0 to (NoPrintLBx.Items.Count -1) do
if NoPrintLBx.Selected[i] then
strDelSQL:='update '+strTabelName+' set 打印标志'+'='''
+'Y'+''' where 票据种类='''
+strKind
+''' and 打印项='''+NoPrintLBx.Items[i]+'''';
ADOQuery4.SQL.Text:=strDelSQL;
try
ADOQuery4.Prepared;
ADOQuery4.ExecSQL;
except
application.MessageBox('数据库操作错误','提示',mb_iconstop);
end;
//DMMain.AdoQueryOpen(strDelSQL,ADOQuery4,'1','1');
FieldAQey.Close;
UpdateDisplay1;
NoPrintLBx.ItemIndex :=Index;
end;
end;
procedure TLeftAndTopFrm.Upsbtn1Click(Sender: TObject);
var
i:integer;
strAddSQL:string; //查询参数
Index:integer;
begin
if YesPrintLBx.ItemIndex =-1 then
begin
YesPrintLBx.ItemIndex:=0;
end
else
begin
Index := GetFirstSelection(YesPrintLBx);
if Index+1=YesPrintLBx.Items.Count then Index:=Index-1;
if Index=-1 then Index:=0;
for i:=0 to (YesPrintLBx.Items.Count -1) do
if YesPrintLBx.Selected[i] then
strAddSQL:='update '+strTabelName+' set 打印标志'+'='''
+'N'+''' where 票据种类='''
+strKind
+''' and 打印项='''+YesPrintLBx.Items[i]+'''';
DMMain.AdoQueryOpen1(strAddSQL,FieldAQey,'1','1');
UpdateDisplay1;
YesPrintLBx.ItemIndex :=Index;
end;
end;
procedure TLeftAndTopFrm.YesPrintLBxClick(Sender: TObject);
var
i:Integer;
begin
for i:=0 to (YesPrintLBx.Items.Count -1) do
if YesPrintLBx.Selected[i] then
begin
if YesPrintLBx.Items[i]='' then Exit;
Upsbtn1.Enabled :=true;
end;
end;
procedure TLeftAndTopFrm.NoPrintLBxClick(Sender: TObject);
var
i:Integer;
begin
for i:=0 to (NoPrintLBx.Items.Count -1) do
if NoPrintLBx.Selected[i] then
begin
if NoPrintLBx.Items[i]='' then Exit;
Downsbtn1.Enabled :=true;
end;
end;
procedure TLeftAndTopFrm.YesPrintLBxDblClick(Sender: TObject);
begin
if Upsbtn1.Enabled then
Upsbtn1Click(Sender);
end;
procedure TLeftAndTopFrm.NoPrintLBxDblClick(Sender: TObject);
begin
if Downsbtn1.Enabled then
Downsbtn1Click(Sender);
end;
function TLeftAndTopFrm.GetFirstSelection(List: TCustomListBox): Integer;
begin
for Result := 0 to List.Items.Count - 1 do
if List.Selected[Result] then Exit;
Result := LB_ERR;
end;
procedure TLeftAndTopFrm.DownAllsbtn1Click(Sender: TObject);
var
i:integer;
strDelSQL:string; //查询参数
begin
for i:=0 to (NoPrintLBx.Items.Count -1) do
begin
strDelSQL:='update '+strTabelName+' set 打印标志'+'='''
+'Y'+''' where 票据种类='''
+strKind
+''' and 打印项='''+NoPrintLBx.Items[i]+'''';
DMMain.AdoQueryOpen1(strDelSQL,FieldAQey,'1','1');
end;
UpdateDisplay1;
end;
procedure TLeftAndTopFrm.UpAllsbtn1Click(Sender: TObject);
var
i:integer;
strAddSQL:string; //查询参数
begin
for i:=0 to (YesPrintLBx.Items.Count -1) do
begin
strAddSQL:='update '+strTabelName+' set 打印标志'+'='''
+'N'+''' where 票据种类='''
+strKind
+''' and 打印项='''+YesPrintLBx.Items[i]+'''';
DMMain.AdoQueryOpen1(strAddSQL,FieldAQey,'1','1');
end;
UpdateDisplay1;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -