?? infonew.pas
字號:
unit infoNew;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGridEh, ImgList, Menus, ComCtrls, ToolWin, ExtCtrls,adoDb,
db,EhlibAdo, StdCtrls, Mask, DBCtrlsEh, Buttons, FR_Class, FR_DSet, comobj,
FR_DBSet;
type
TInfoNewForm = class(TForm)
dbGrid1: TDBGridEh;
Tbinfo: TToolBar;
Tbadd: TToolButton;
Tbedit: TToolButton;
Tbdel: TToolButton;
ToolButton4: TToolButton;
tbCopy: TToolButton;
TBsec: TToolButton;
Tbprint: TToolButton;
Tbsave: TToolButton;
ToolButton7: TToolButton;
Tbexit: TToolButton;
PanelCondition1: TPanel;
Label3: TLabel;
Label1: TLabel;
edtTypeCode: TDBEditEh;
edtCode: TDBEditEh;
PMprint: TPopupMenu;
Mpreview: TMenuItem;
ILinfo: TImageList;
SaveDialog1: TSaveDialog;
procedure FormShow(Sender: TObject);
procedure TbaddClick(Sender: TObject);
procedure TbexitClick(Sender: TObject);
procedure TbeditClick(Sender: TObject);
procedure dbGrid1DblClick(Sender: TObject);
procedure TbdelClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
FSql:string;
FTableId:integer;
sTablename:string;
sQueryCode,sFrName:string;
sCdnSql:string;
FMemuItem:TMenuItem;
//Function GetConditionValue(sCondition,sParam:string):string;
//Function GetStoreIdValue(sCondition,sParam:string):integer;
//procedure secCondition;
public
{ Public declarations }
property xSql:string read FSql write FSql;
property xTableId:integer read FTableId write FTableId;
end;
var
InfoNewForm: TInfoNewForm;
implementation
uses datamodule1, CusFile;
{$R *.dfm}
procedure TInfoNewForm.FormShow(Sender: TObject);
var
tmpStream:TADOBlobStream;
dLastMonth:TDateTime;
begin
Application.ProcessMessages;
dLastMonth:=dataE2.GetLastMonth(date);
dbGrid1.DataSource :=nil;
//panelCondition1.caption:=' 查詢條件:[ '+'開單日期: '+dateTostr(dLastMonth)+'至'+dateTostr(date)+' ]';
// read blob field
if dataE2.OpenTable('select * from queryModule where id= :id',FTableId) then
begin
tmpStream := TADOBlobStream.Create(DataE2.adoQuery1.FieldByName('GridColumns') as TBlobField, bmRead);
xSql:=dataE2.ADOQuery1.fieldbyname('Sql1').asstring+' '+dataE2.ADOQuery1.fieldbyname('Sql2').asstring;
sQueryCode:=dataE2.ADOQuery1.fieldbyname('queryCode').asstring;
//相對應的報表文件名
sFrName:=dataE2.ADOQuery1.fieldbyname('RptName').asstring;
dataE2.ADOQuery1.close; end
else exit;
try
tmpStream.Position :=0;
try
dbGrid1.Columns.LoadFromStream(tmpStream); //load columns from gridcolumns
except
dbGrid1.Columns.clear;
end;
finally
tmpStream.Free ;
end;
if fTableId < 90 then
sCdnSql:=' where Billdate between '''+dateTostr(dLastMonth)+''' and '''+dateTostr(date)+'''' //dateTimeTostr(now)+''''
else
sCdnSql:='';
with dataE2 do
begin
if QueryRpt.active then QueryRpt.Close;
QueryRpt.sql.clear;
QueryRpt.sql.add(xSql);
QueryRpt.open;
end;
dbGrid1.DataSource :=dataE2.dsRpt;
end;
procedure TInfoNewForm.TbaddClick(Sender: TObject);
begin
CusFileForm.sStatus:='sInsert';
CusFileForm.ShowModal;
end;
procedure TInfoNewForm.TbexitClick(Sender: TObject);
begin
close;
end;
procedure TInfoNewForm.TbeditClick(Sender: TObject);
begin
CusFileForm.sStatus:='sEdit';
with dataE2 do
begin
if Not QueryRpt.Eof then
begin
CusFileForm.nCLIENTID:=QueryRpt.fieldByName('CLIENTID').AsInteger;
CusFileForm.edtClient.Text:=trim(QueryRpt.fieldByName('ShortName').AsString);
CusFileForm.edtBuyDate.Text:=trim(QueryRpt.fieldByName('BuyDate').AsVariant);
CusFileForm.edtMachineID.Text:=trim(QueryRpt.fieldByName('MachineID').AsString);
CusFileForm.edtCheckNo.Text:=trim(QueryRpt.fieldByName('CheckNo').AsString);
CusFileForm.edtMotorLabel.Text:=trim(QueryRpt.fieldByName('MotorLabel').AsString);
CusFileForm.edtSalePrice.Text:=FloatToStr(QueryRpt.fieldByName('SalePrice').AsFloat);
CusFileForm.ShowModal;
end;
end;
end;
procedure TInfoNewForm.dbGrid1DblClick(Sender: TObject);
begin
Tbedit.Click;
end;
procedure TInfoNewForm.TbdelClick(Sender: TObject);
begin
if MessageDlg('真的要刪除當前記錄嗎?', mtconfirmation, [mbyes, mbno], 0)=idyes then
with DataE2.QueryTmp do
begin
close;
SQL.Clear;
SQL.Add('delete from CusFile where cusFileid=:cusFileid');
Parameters[0].Value:=DataE2.QueryRpt.fieldByName('cusFileid').AsInteger;
ExecSQL;
end;
DataE2.QueryRpt.Close;
DataE2.QueryRpt.Open;
end;
procedure TInfoNewForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
dbGrid1.DataSource :=nil;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -