📄 ustore.pas
字号:
procedure Tfrmstore.PDJComEdit1ClickButton(Sender: TObject);
var
s,str1,str2,str3,str4:string;
i, ii,jj:integer;
ini:textfile;
Searcht, usercode:string;
begin
inherited;
if cdsmaster.State in [dsedit,dsinsert] then
begin
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select a.fitemid,a.fqty,a.fprice,a.gno,a.colorno,a.color,a.fnote,b.fpurno,b.fprovider,b.fpurer,b.fpurstore,');
adoquery1.SQL.add(' b.frefno,b.fdelivdate,b.fnote as note2,b.fcreauser,b.pno,b.fprice as price2,');
adoquery1.SQL.add(' c.fid,c.fcode,c.fname,c.funit,c.ftype,c.zs from Tpurchasesub a,Tpurchase b ,titem c');
adoquery1.SQL.add(' where a.fresid=b.fresid and c.fid=a.fitemid');
if billno.text<>'' then
begin
adoquery1.SQL.add(' and b.frefno =:frefno');
adoquery1.Parameters.ParamByName('frefno').Value:=billno.Text;
end;
adoquery1.Open;
adoquery1.First;
while not adoquery1.Eof do
begin
spbtnadd.Click;
CdsSub.Append;
GetsqlData(CDSselectsub,'Vitem','fid','fid='+vartosql(adoquery1.fieldbyname('fID').Value),1);
if CDSselectsub.RecordCount > 0 then
begin
CDSsub['fitemid']:=adoquery1.fieldbyname('fID').Value;
CDSsub['fcode']:=CDSselectsub['fcode'];
CDSsub['fname']:=CDSselectsub['fname'];
CDSsub['ftype'] :=CDSselectsub['ftype'];
CDSsub['funit']:=CDSselectsub['funit'];
CDSsub['zs']:=CDSselectsub['zs'];
CDSsub['gno'] :=adoquery1.fieldbyname('gno').Value;
GetsqlData(CDSselectsub,'Vpurchasesub','colorno','colorno='+vartosql(adoquery1.fieldbyname('colorno').value),1);
// if CDSselectsub.RecordCount > 0 then
CDSsub['color']:=CDSselectsub['color'];
CDSsub['colorno'] :=CDSselectsub['colorno'];
CDSsub['fqty'] := adoquery1.fieldbyname('fqty').Value;
CDSsub['fprice'] := adoquery1.fieldbyname('fprice').Value;
CDSsub['total'] :=adoquery1.fieldbyname('fqty').Value*adoquery1.fieldbyname('fprice').Value;
end;
adoquery1.Next;
end;
if adoquery1.RecordCount>0 then
BEGIN
GetsqlData(CDSselectsub,'Vpurchase','frefno','frefno='+vartosql(adoquery1.fieldbyname('frefno').asstring),1);
if cdsselectsub.RecordCount>0 then
begin
if CDSselectsub['frefno']<>NULL then
CDSmaster['fstoreno']:=CDSselectsub['frefno'];//searq.fieldbyname('fpurstore').asstring;//'采购编号';
if CDSselectsub['fpurstore']<>NULL then
CDSmaster['fpurstore']:=CDSselectsub['fpurstore'];//searq.fieldbyname('fpurstore').asstring;//'仓库';
if CDSselectsub['fpurer']<>NULL then
CDSmaster['fpurer']:=CDSselectsub['fpurer'];//searq.fieldbyname('fpurer').asstring;//'负责人';
if CDSselectsub['fprovider']<>null then
CDSmaster['fprovider']:=CDSselectsub['fprovider'];//searq.fieldbyname('fprovider').asstring;//'供应商';
if CDSselectsub['fnote']<>null then
CDSmaster['fnote']:=CDSselectsub['fnote'];//searq.fieldbyname('fnote').asstring;//'备注';
if CDSselectsub['fdelivdate']<>null then
CDSmaster['fdelivdate']:=CDSselectsub['fdelivdate'];//searq.fieldbyname('fdelivdate').asstring;//'交货日期';
if CDSselectsub['fcreauser']<>null then
CDSmaster['fcreauser']:=CDSselectsub['fcreauser'];//searq.fieldbyname('fcreauser').asstring;//'创建人';
end;
END;
// Grid.SelectedIndex:=7;
end;
end;
procedure Tfrmstore.p05Execute(Sender: TObject);
var
excelid, mybook: variant;
row, col, i, j, colcount, frow: integer;
excelflg: boolean;
rpstr: string;
per_count, datasum, dsum1, dsum2: integer;
datas1, datas2, datas3: string;
begin
//inherited;
CDSsub.DisableControls;
try
excelid := createoleobject('excel.application');
mybook := createoleobject('excel.sheet');
mybook := excelid.workbooks.add;
row := 1;
col := 1;
excelflg := true;
except
excelflg := false;
application.MessageBox('请确定EXCEL是否正确安装!', '提示信息', mb_ok);
end;
if excelflg then
begin
colcount :=grid.VisibleColCount;
excelid.range['A' + inttostr(row), chr(64 + colcount) +
inttostr(row)].merge();
mybook.worksheets[1].cells.item[row, col] := '基本报表';
mybook.worksheets[1].cells.item[row, col].font.size := 18;
mybook.worksheets[1].cells.item[row, col].font.bold := true;
mybook.worksheets[1].cells.item[row, col].HorizontalAlignment := xlcenter;
row := row + 1;
excelid.range['A' + inttostr(row), chr(64 + colcount) +
inttostr(row)].merge();
mybook.worksheets[1].cells.item[row, col] := '报表日期:' +
datetostr(date);
row := row + 1;
frow := row;
CDSsub.First;
excelid.columns[1].ColumnWidth := Grid.Columns[0].Width / 8;
excelid.columns[1].NumberFormatLocal := '@';
mybook.worksheets[1].cells.item[row, 1] := grid.Columns[0].Title.Caption;
excelid.columns[2].ColumnWidth := Grid.Columns[1].Width / 8;
excelid.columns[2].NumberFormatLocal := '@';
mybook.worksheets[1].cells.item[row, 2] := grid.Columns[1].Title.Caption;
excelid.columns[3].ColumnWidth := Grid.Columns[2].Width / 8;
excelid.columns[3].NumberFormatLocal := '@';
mybook.worksheets[1].cells.item[row, 3] := grid.Columns[2].Title.Caption;
excelid.columns[4].ColumnWidth := Grid.Columns[3].Width / 8;
excelid.columns[4].NumberFormatLocal := '@';
mybook.worksheets[1].cells.item[row, 4] := grid.Columns[3].Title.Caption;
excelid.columns[5].ColumnWidth := Grid.Columns[4].Width / 8;
excelid.columns[5].NumberFormatLocal := '@';
mybook.worksheets[1].cells.item[row, 5] := grid.Columns[4].Title.Caption;
excelid.columns[6].ColumnWidth := Grid.Columns[5].Width / 8;
excelid.columns[6].NumberFormatLocal := '@';
mybook.worksheets[1].cells.item[row, 6] := grid.Columns[5].Title.Caption;
excelid.columns[7].ColumnWidth := Grid.Columns[6].Width / 8;
excelid.columns[7].NumberFormatLocal := '@';
mybook.worksheets[1].cells.item[row, 7] := grid.Columns[6].Title.Caption;
row := row + 1;
while not CDSsub.Eof do
begin
mybook.worksheets[1].cells.item[row, 1] :=CDSsub['fid'];
mybook.worksheets[1].cells.item[row, 2] := CDSsub['fcode'];
mybook.worksheets[1].cells.item[row, 3] := CDSsub['fname'];
mybook.worksheets[1].cells.item[row, 4] := CDSsub['funit'];
mybook.worksheets[1].cells.item[row, 5] := CDSsub['fqty'];
mybook.worksheets[1].cells.item[row, 6] := CDSsub['unitqty'];
mybook.worksheets[1].cells.item[row, 7] := CDSsub['total'];
row := row + 1;
CDSsub.Next;
end;
excelid.range['A' + inttostr(row), chr(64 + colcount) +
inttostr(row)].merge();
mybook.worksheets[1].cells.item[row, col].font.size := 12;
mybook.worksheets[1].cells.item[row, col].font.bold := true;
mybook.worksheets[1].cells.item[row, col].HorizontalAlignment := xlcenter;
mybook.worksheets[1].cells.item[row, col] := '总记录数:' +
inttostr(CDssub.RecordCount) + '条';
row := row + 1;
rpstr := '报表条件:';
excelid.range['A' + inttostr(row), chr(64 + colcount) +
inttostr(row)].merge();
mybook.worksheets[1].cells.item[row, col] := rpstr;
row := row + 1;
excelid.range[chr(65) + inttostr(frow), chr(64 + colcount) + inttostr(row
- 1)].Borders[1].LineStyle := xlContinuous;
excelid.range[chr(65) + inttostr(frow), chr(64 + colcount) + inttostr(row
- 1)].Borders[2].LineStyle := xlContinuous;
excelid.range[chr(65) + inttostr(frow), chr(64 + colcount) + inttostr(row
- 1)].Borders[3].LineStyle := xlContinuous;
excelid.range[chr(65) + inttostr(frow), chr(64 + colcount) + inttostr(row
- 1)].Borders[4].LineStyle := xlContinuous;
excelid.visible := true;
end;
CDSsub.EnableControls;
end;
procedure Tfrmstore.acaddExecute(Sender: TObject);
var
i:integer;
begin
inherited;
query1.SQL.clear;
query1.SQL.Add('select fname from tfuli');
query1.Open;
cdsmaster['fcreauser']:=Global.gs_username;
cdsmaster['fcreadate']:=date;
cdsmaster['fdelivdate']:=global.gs_date;
CDSmaster['fpurstore']:=query1.fieldbyname('fname').asstring;
CDSmaster['bc']:=global.gs_bc;
listbox1.Clear;
i:=1;
with adoquery1 do
begin
SQL.Clear;
sql.add(' select fname ');
sql.add(' from titem ');
Open;
end;
while not adoquery1.Eof do
begin
listbox1.Items.Add(inttostr(i)+'.'+adoquery1.fieldbyname('fname').value);
adoquery1.next;
i:=i+1;
end;
grid.SelectedIndex:=0;
end;
procedure Tfrmstore.acdeleteExecute(Sender: TObject);
var
yy,mm,dd:word;
begin
decodedate(wwDBDateTimePicker2.Date,yy,mm,dd);
inherited;
end;
procedure Tfrmstore.GridColExit(Sender: TObject);
begin
inherited;
case grid.SelectedIndex of
0,1,2,3, 4,5:begin
if CDSsub.State in [dsEdit,dsinsert] then
begin
with query2 do
begin
SQL.Clear;
sql.add(' select fcode,fname,fid ');
sql.add(' from titem ');
sql.add(' where fcode=:fcode ');
ParamByName('fcode').asstring:=cdssub.fieldbyname('fcode').asstring;
Open;
if recordcount>0 then
begin
cdssub['hname']:= fieldbyname('fname').Value;
cdssub['fitemid']:=fieldbyname('fid').AsInteger;
end;
end;
// CDSsub['total'] :=strtofloat(floattostrf(CDSsub['fqty']*CDSsub['fprice'],ffFixed,18,2));
end;
end;
end;
end;
procedure Tfrmstore.GridKeyPress(Sender: TObject; var Key: Char);
begin
inherited;
{ if Key=#13 then
begin
if CDSsub.State in [dsEdit,dsinsert] then
begin
if grid.Col< grid.VisibleColumns.Count then
grid.SelectedIndex:=grid.SelectedIndex+1 else
begin
SpeedButton3.Click;
grid.SelectedIndex:=0;
end;
end;
end; }
end;
procedure Tfrmstore.CDSsubBeforePost(DataSet: TDataSet);
begin
inherited;
{ with query2 do
begin
SQL.Clear;
sql.add(' select a.fqty,a.cgyrqty, a.fitemid,b.fresid,a.colorno,a.gno');
sql.add(' ,a.color,b.frefno,b.fpurno from tpurchasesub a,tpurchase b ');
sql.add(' where a.fresid=b.fresid and a.colorno =:colorno ');
sql.add(' and a.fitemid=:fitemid and b.fpurno=:fpurno ');
ParamByName('colorno').asstring:=cdssub.fieldbyname('colorno').asstring;
// ParamByName('gno').asstring:=cdssub.fieldbyname('gno').asstring;
ParamByName('fitemid').asinteger:=cdssub.fieldbyname('fitemid').asinteger;
ParamByName('fpurno').asstring:=wwdbedit2.text;
Open;
end;
if query2.RecordCount>0 then
begin
if (query2.FieldByName('cgyrqty').asfloat+cdssub.FieldByName('fqty').AsFloat)/query2.FieldByName('fqty').asfloat>=1.05 then
// MessageDlg('进货数量已经大於采购数的5%!请检查 ',mtWarning,[MBOK],0);
end; }
end;
procedure Tfrmstore.GridKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if grid.SelectedIndex=0 then
if char(key)='p' then
if cdssub.State in [dsedit,dsinsert] then
Selectsub;
end;
procedure Tfrmstore.acmodifyExecute(Sender: TObject);
var
i:integer;
begin
inherited;
listbox1.Clear;
i:=1;
with adoquery1 do
begin
SQL.Clear;
sql.add(' select fname ');
sql.add(' from titem ');
Open;
end;
while not adoquery1.Eof do
begin
listbox1.Items.Add(inttostr(i)+'.'+adoquery1.fieldbyname('fname').value);
adoquery1.next;
i:=i+1;
end;
grid.SelectedIndex:=0;
end;
procedure Tfrmstore.SpeedButton4Click(Sender: TObject);
begin
inherited;
close;
end;
procedure Tfrmstore.acsearchExecute(Sender: TObject);
begin
// inherited;
CDSsub.DisableControls;
frMD.LoadFromFile(frname);
frMD.PrepareReport;
frMD.PrintPreparedReport('',1,True,frAll);
CDSsub.EnableControls;
end;
procedure Tfrmstore.CDSmasterAfterOpen(DataSet: TDataSet);
begin
inherited;
spbtnadd.Click;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -