📄 unitinoutdjqry.~pas
字号:
begin
strTemp:=strTemp+'(a.Exam_Man='''+trim(edtJyr_6.text)+''') and';
end;
//制单人
if edtZdr_6.text<>'' then
begin
strTemp:=strTemp+'(a.Oper_id='''+trim(edtZdr_6.text)+''') and';
end;
//物料类别
if cbbLb_6.text<>'' then
begin
i:=cbbLb_6.Items.IndexOf(cbbLb_6.text);
if i=-1 then
begin
for j:=0 to high(listLb) do
if listLb[j]=cbbLb_6.text then
begin
i:=j;
break;
end;
end;
if i<>-1 then
begin
strtemp:=strtemp+' (b.Mate_Class='''+listLb[i]+''') and';
end;
end;
//起始日期
str1:=copy(meStart_6.text,1,4); //2003
str2:=copy(meStart_6.text,5,2); //07
str3:=copy(meStart_6.text,7,2); //28
strStart:=trim(str1)+trim(str2)+trim(str3); //2003年07月28日
//截止日期
str1:=copy(meEnd_6.text,1,4); //2003
str2:=copy(meEnd_6.text,5,2); //07
str3:=copy(meEnd_6.text,7,2); //28
strEnd:=trim(str1)+trim(str2)+trim(str3); //2003年07月28日
if (meStart_6.text<>'') and (meEnd_6.text<>'') then //
begin
insert('-',strStart,5);
insert('-',strStart,8);
insert('-',strEnd,5);
insert('-',strEnd,8);
//strtemp:=strtemp+' convert(varchar(10),a.In_Date,21)='''+strStart+''' and';
strtemp:=strtemp+' (convert(varchar(10),a.In_Date,21)>='''+strStart+
''' and convert(varchar(10),a.In_Date,21)<='''+strEnd+''') and '
end
else if meStart_6.text<>'' then
begin
insert('-',strStart,5);
insert('-',strStart,8);
strtemp:=strtemp+' convert(varchar(10),a.In_Date,21)>='''+strStart+''' and';
end
else if meEnd_6.text<>'' then
begin
insert('-',strEnd,5);
insert('-',strEnd,8);
strtemp:=strtemp+' convert(varchar(10),a.In_Date,21)<='''+strEnd+''' and'
end;
//
if (edtCkdh_6.text='') and (edtJhbh_6.text='') and (edtNum_6.text='')
and (edtPrice_6.text='') and (edtTotalPrice_6.text='') and (cbbLb_6.text='')
and (edtWlbm_6.text='') and (edtWlmc_6.text='') and (edtType_6.text='')
and (edtJsr_6.text='') and (edtZdr_6.text='') and (edtJyr_6.text='')
and (meStart_6.text='') and (meEnd_6.text='') then
begin
//application.messagebox('请至少输入一个查询条件','提示',mb_ok+mb_iconwarning);
//edtCkdh_6.setfocus;
strTemp:=copy(strtemp,1,length(strtemp)-6);
with qry_6 do
begin
close;
sql.clear;
sql.add(strTemp);
open;
end;
lbl_6.Caption:=inttostr(qry_6.RecordCount)+' 条';
end else
begin
str:=copy(strtemp,1,length(strtemp)-4);
with qry_6 do
begin
close;
sql.clear;
sql.add(str);
open;
end;
lbl_6.Caption:=inttostr(qry_6.RecordCount)+' 条';
end;
//向领用出库添加内容--------------------------------
clistbox6.clear;
clistbox6.Items:=qry_6.FieldDefList;
for i:=0 to clistbox6.items.Count - 1 do
begin
clistbox6.Checked[i]:=true;
end;
//------
maxlength:=0;
for i:=0 to clistbox6.items.count - 1 do
begin
if maxlength < length(clistbox6.Items.Strings[i]) then
begin
maxlength:=length(clistbox6.Items.Strings[i]);
strmax:=clistbox6.Items.Strings[i];
end;
end;
DC:=getDC(0);
savefont:=selectobject(DC,font.handle);
gettextextentpoint32(DC,pchar(strmax),maxlength,Textsize);
MaxWidth:=Textsize.cx+getsystemmetrics(SM_CXBORDER)*4+50;
selectobject(Dc,savefont);
releaseDC(0,DC);
SendMessage(cListBox2.Handle, LB_SETHORIZONTALEXTENT, MaxWidth, 0);
end;
procedure TfrmInOutDjQry.BitBtnBfClick(Sender: TObject);
var
str,strTemp:string;
str1,str2,str3,strStart,strEnd:string;
i,j:integer;
MaxWidth: integer;
DC:HDC;
savefont:Hfont;
Textsize:Tsize;
maxlength:integer;
strmax:string;
begin
if PageControl2.ActivePage=TabSheetBf then //报废出库
begin
TabSheetCg_1.TabVisible:=false;
TabSheetZz_1.TabVisible:=false;
TabSheetProductIn_1.TabVisible:=false;
TabSheetTL_1.TabVisible:=false;
TabSheetProductOut_1.TabVisible:=false;
TabSheetLy_1.TabVisible:=false;
TabSheetBf_1.TabVisible:=true;
end;
strTemp:=' select a.Bf_Bill as 报废单号,a.Plan_id as 计划编号, '+
' a.Mate_Code as 物料编码,b.Mate_Name as 物料名称, '+
' b.Mate_Type as 规格型号,b.Mate_Class as 物料类别, '+
' a.Dept_id as 部门,a.KfNo as 库房,KwNo as 库位, '+
' a.Out_Type as 出库类别,a.Out_Date as 出库日期, '+
' a.Out_Amount as 出库数量,a.Out_Price as 单价, '+
' a.Out_Zj as 总价,a.Out_Post as 过帐标志, '+
' a.Checker as 审核人,a.Exam_man as 检验人, '+
' a.Oper_id as 制单人,a.Out_Memo as 备注 '+
' from mate_Bf a '+
' left outer join Mate_Basic b on a.Mate_Code=b.Mate_Code where';
//出库单号
if edtCkdh_7.text<>'' then
begin
strTemp:=strTemp+'(a.Bf_Bill='''+trim(edtCkdh_7.text)+''') and ';
end;
//计划编号
if edtJhbh_7.text<>'' then
begin
strTemp:=strTemp+'(a.Plan_id='''+trim(edtJhbh_7.text)+''') and ';
end;
//出库数量
if edtNum_7.text<>'' then
begin
strTemp:=strTemp+'(a.Out_Amount='''+trim(edtNum_7.text)+''') and';
end;
//出库单价
if edtPrice_7.text<>'' then
begin
strTemp:=strTemp+'(a.Out_Price='''+trim(edtPrice_7.text)+''') and';
end;
//出库总价
if edtTotalPrice_7.text<>'' then
begin
strTemp:=strTemp+'(a.Out_Zj='''+trim(edtTotalPrice_7.text)+''') and';
end;
//物料编码
if edtWlbm_7.text<>'' then
begin
strTemp:=strTemp+'(a.Mate_Code='''+trim(edtWlbm_7.text)+''') and';
end;
//物料名称
if edtWlmc_7.text<>'' then
begin
strTemp:=strTemp+'(b.Mate_Name='''+trim(edtWlmc_7.text)+''') and';
end;
//规格型号
if edtType_7.text<>'' then
begin
strTemp:=strTemp+'(b.Mate_Type='''+trim(edtType_7.text)+''') and';
end;
//经手人
if edtSpr_7.text<>'' then
begin
strTemp:=strTemp+'(a.Out_Man='''+trim(edtSpr_7.text)+''') and';
end;
//检验人
if edtJyr_7.text<>'' then
begin
strTemp:=strTemp+'(a.Exam_Man='''+trim(edtJyr_7.text)+''') and';
end;
//制单人
if edtZdr_7.text<>'' then
begin
strTemp:=strTemp+'(a.Oper_id='''+trim(edtZdr_7.text)+''') and';
end;
//物料类别
if cbbLb_7.text<>'' then
begin
i:=cbbLb_7.Items.IndexOf(cbbLb_7.text);
if i=-1 then
begin
for j:=0 to high(listLb) do
if listLb[j]=cbbLb_7.text then
begin
i:=j;
break;
end;
end;
if i<>-1 then
begin
strtemp:=strtemp+' (b.Mate_Class='''+listLb[i]+''') and';
end;
end;
//起始日期
str1:=copy(meStart_7.text,1,4); //2003
str2:=copy(meStart_7.text,5,2); //07
str3:=copy(meStart_7.text,7,2); //28
strStart:=trim(str1)+trim(str2)+trim(str3); //2003年07月28日
//截止日期
str1:=copy(meEnd_7.text,1,4); //2003
str2:=copy(meEnd_7.text,5,2); //07
str3:=copy(meEnd_7.text,7,2); //28
strEnd:=trim(str1)+trim(str2)+trim(str3); //2003年07月28日
if (meStart_7.text<>'') and (meEnd_7.text<>'') then //
begin
insert('-',strStart,5);
insert('-',strStart,8);
insert('-',strEnd,5);
insert('-',strEnd,8);
//strtemp:=strtemp+' convert(varchar(10),a.In_Date,21)='''+strStart+''' and';
strtemp:=strtemp+' (convert(varchar(10),a.In_Date,21)>='''+strStart+
''' and convert(varchar(10),a.In_Date,21)<='''+strEnd+''') and '
end
else if meStart_7.text<>'' then
begin
insert('-',strStart,5);
insert('-',strStart,8);
strtemp:=strtemp+' convert(varchar(10),a.In_Date,21)>='''+strStart+''' and';
end
else if meEnd_7.text<>'' then
begin
insert('-',strEnd,5);
insert('-',strEnd,8);
strtemp:=strtemp+' convert(varchar(10),a.In_Date,21)<='''+strEnd+''' and'
end;
//
if (edtCkdh_7.text='') and (edtJhbh_7.text='') and (edtNum_7.text='')
and (edtPrice_7.text='') and (edtTotalPrice_7.text='') and (cbbLb_7.text='')
and (edtWlbm_7.text='') and (edtWlmc_7.text='') and (edtType_7.text='')
and (edtSpr_7.text='') and (edtZdr_7.text='') and (edtJyr_7.text='')
and (meStart_7.text='') and (meEnd_7.text='') then
begin
//application.messagebox('请至少输入一个查询条件','提示',mb_ok+mb_iconwarning);
//edtCkdh_7.setfocus;
strTemp:=copy(strTemp,1,length(strtemp)-6);
with qry_7 do
begin
close;
sql.clear;
sql.add(strTemp);
open;
end;
lbl_7.Caption:=inttostr(qry_7.RecordCount)+' 条';
end else
begin
str:=copy(strtemp,1,length(strtemp)-4);
with qry_7 do
begin
close;
sql.clear;
sql.add(str);
open;
end;
lbl_7.Caption:=inttostr(qry_7.RecordCount)+' 条';
end;
//向报废出库添加内容--------------------------------
clistbox7.clear;
clistbox7.Items:=qry_7.FieldDefList;
for i:=0 to clistbox7.items.Count - 1 do
begin
clistbox7.Checked[i]:=true;
end;
//------
maxlength:=0;
for i:=0 to clistbox7.items.count - 1 do
begin
if maxlength < length(clistbox7.Items.Strings[i]) then
begin
maxlength:=length(clistbox7.Items.Strings[i]);
strmax:=clistbox7.Items.Strings[i];
end;
end;
DC:=getDC(0);
savefont:=selectobject(DC,font.handle);
gettextextentpoint32(DC,pchar(strmax),maxlength,Textsize);
MaxWidth:=Textsize.cx+getsystemmetrics(SM_CXBORDER)*4+50;
selectobject(Dc,savefont);
releaseDC(0,DC);
SendMessage(cListBox2.Handle, LB_SETHORIZONTALEXTENT, MaxWidth, 0);
end;
procedure TfrmInOutDjQry.meStart_4Exit(Sender: TObject);
var
str:string;
begin
str:=meStart_4.text;
if str='' then exit;
insert('-',str,5);
insert('-',str,8);
try
strtodatetime(str);
except
application.MessageBox('日期输入错误!','警告',mb_ok+mb_iconwarning);
meStart_4.Text:='';
meStart_4.setfocus;
exit;
end;
end;
procedure TfrmInOutDjQry.meStart_5Exit(Sender: TObject);
var
str:string;
begin
str:=meStart_5.text;
if str='' then exit;
insert('-',str,5);
insert('-',str,8);
try
strtodatetime(str);
except
application.MessageBox('日期输入错误!','警告',mb_ok+mb_iconwarning);
meStart_5.Text:='';
meStart_5.setfocus;
exit;
end;
end;
procedure TfrmInOutDjQry.meStart_6Exit(Sender: TObject);
var
str:string;
begin
str:=meStart_6.text;
if str='' then exit;
insert('-',str,5);
insert('-',str,8);
try
strtodatetime(str);
except
application.MessageBox('日期输入错误!','警告',mb_ok+mb_iconwarning);
meStart_6.Text:='';
meStart_6.setfocus;
exit;
end;
end;
procedure TfrmInOutDjQry.meStart_7Exit(Sender: TObject);
var
str:string;
begin
str:=meStart_7.text;
if str='' then exit;
insert('-',str,5);
insert('-',str,8);
try
strtodatetime(str);
except
application.MessageBox('日期输入错误!','警告',mb_ok+mb_iconwarning);
meStart_7.Text:='';
meStart_7.setfocus;
exit;
end;
end;
procedure TfrmInOutDjQry.BitBtnPrint1Click(Sender: TObject);
var
p:Tpoint;
begin
p.x:=BitBtnPrint1.left+1;
p.y:=BitBtnPrint1.top+1;
p:=panel2.ClientToScreen(p);
PopupMenu1.Popup(p.x,p.y);
end;
//Tdbgrid
procedure TfrmInOutDjQry.Print(temp:string;query:Tquery;my:TObject);
var
i,j,total,rows: Integer;
Sheet: Variant;
num:integer;
isfind:boolean;
begin
if not VarIsEmpty(XLApp) then
begin
if XLApp.Visible=false then
begin
XLApp.Visible := True;
XLAPP.WindowState := xlMaximized;
XLApp.ScreenUpdating := True;
XLApp.Workbooks.Add(xlWBatWorkSheet);
XLApp.Workbooks[1].WorkSheets[1].Name := temp;
XLApp.Workbooks[1].WorkSheets[1].activate;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -