📄 sprcdcx.pas
字号:
unit sprcdcx;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
Tfrm_sprcdcx = class(TForm)
GroupBox1: TGroupBox;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
txtjhdh: TEdit;
txtzdrq: TEdit;
txthcbh: TEdit;
txthcmc: TEdit;
txtczybh: TEdit;
czymc: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
txtpc: TEdit;
procedure SpeedButton1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure showdj;
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_sprcdcx: Tfrm_sprcdcx;
implementation
uses date1, sprcd;
{$R *.dfm}
procedure Tfrm_sprcdcx.SpeedButton1Click(Sender: TObject);
var str,where1,group1:string;
flag:boolean;
i:integer;
begin
if (txtjhdh.text='') and (txtzdrq.text='') and (txthcbh.text='') and
(txtpc.text='') and (txtczybh.text='') then
begin
str:='select DISTINCT jhdh from hcrkd0 ';
where1:='';
end
else
begin
flag:=false;
str:='select DISTINCT jhdh from hcrkd0 ';
where1:=' where ';
//当单据编号为空
if txtjhdh.Text<>'' then
begin
if not flag then
begin
where1:=where1+' djbh='+QuotedStr(trim(txtjhdh.Text));
flag:=true;
end
else
where1:=where1;
end;
//制单日期
if txtzdrq.text<>'' then
begin
if not flag then
begin
where1:=where1+' convert(char(10),zdrq,120)='+QuotedStr(trim(txtzdrq.text));
flag:=true;
end
else
where1:=where1;
end;
//耗材编号
if txthcbh.Text<>'' then
begin
if not flag then
begin
where1:=where1+' hcbh='+QuotedStr(trim(txthcbh.Text));
flag:=true;
end
else
where1:=where1;
end;
//操作员编号
if txtczybh.Text<>'' then
begin
if not flag then
begin
where1:=where1+' czybh='+QuotedStr(trim(txtczybh.Text));
flag:=true;
end
else
where1:=where1;
end;
end;
screen.Cursor:=crHourGlass;
str:=str+where1+' order by jhdh';
with data do
begin
aq1.Connection:=adoc1;
with aq1 do
begin
close;
sql.clear;
sql.Add(str);
open;
if aq1.Recordset.RecordCount>0 then
begin
frm_sprcd.mainnumber:=aq1.Recordset.RecordCount;
frm_sprcd.nownumber:= frm_sprcd.mainnumber-1;
setlength(frm_sprcd.number,frm_sprcd.mainnumber);
while not aq1.Eof do
begin
for i:=0 to frm_sprcd.mainnumber-1 do
begin
frm_sprcd.number[i]:=aq1.Fields.Fieldbyname('jhdh').Value;
aq1.next;
end;
end;
showdj;
screen.Cursor:=crDefault;
frm_sprcdcx.close;
end
else
begin
showmessage('没有满足条件的记录');
screen.Cursor:=crDefault;
exit;
end;
end;
end;
end;
procedure Tfrm_sprcdcx.FormCreate(Sender: TObject);
begin
end;
//显示第一个单据
procedure Tfrm_sprcdcx.showdj;
var i:integer;
begin
//if frm_sprcd.ComboBox1.Items.Count>0 then
if frm_sprcd.mainnumber>0 then
begin
with data do
begin
aq1.Connection:=adoc1;
with aq1 do
begin
close;
sql.Clear;
aq1.SQL.Add('select a.jhdh,b.hcbh,b.hcmc,b.gg,b.jldw,a.zdrq,t1.jhsl,'+
' t1.jhdj,t1.jhje,a.czybh,a.csbh,t1.pc,c.csbh,a.flag from hcda b,hcrkd0 a,csda c,hcrkd1 t1 '+
' where t1.hcbh=b.hcbh and a.csbh=c.csbh and a.jhdh=:jhdh and a.jhdh=t1.jhdh '+
' order by a.jhdh,t1.hcbh');
{sql.Add(' select a.djbh,a.mcbh,a.bmbh,a.dlbh,a.xlbh,a.czybh,c.czymc,a.zdrq,a.flag,'+
' b.csbh,b.csmc,t1.spbh,t1.spmc,t1.spgg,t1.jldw,t1.shdj,t1.hydj,'+
' t1.jhdj,t1.cbdj,t1.cdbh,t1.aqcl,t1.jxcjl,t1.mxsl,t1.spxz,t1.state,'+
' t1.czsp,t1.bzsx,t1.jhtax,t1.xstax,t1.lykl,a.xzbh from sprcd01 a,sprcd02 t1, '+
' czyda c,csda b where a.csbh=b.csbh and a.djbh=:djbh and c.czybh=a.czybh'+
' and t1.djbh=a.djbh'); }
aq1.Parameters.ParamByName('jhdh').Value:=frm_sprcd.number[frm_sprcd.mainnumber-1];
//frm_sprcd.ComboBox1.Items[frm_sprcd.ComboBox1.Items.Count-1];
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
frm_sprcd.txtjhdh.Text:=aq1.Fields.Fieldbyname('jhdh').Value;
frm_sprcd.txtzdrq.Text:=aq1.Fields.Fieldbyname('zdrq').Value;
frm_sprcd.txtczybh.Text:=aq1.Fields.Fieldbyname('czybh').Value;
for i:=0 to frm_sprcd.txtcsbh.items.count-1 do
begin
if copy(frm_sprcd.txtcsbh.items[i],1,4)=aq1.Fields.Fieldbyname('csbh').Value then
frm_sprcd.txtcsbh.itemindex:=i;
end;
if trim(aq1.Fields.Fieldbyname('flag').Value)='0' then
frm_sprcd.txtshflag.Text:='0-未审核';///aq1.Fields.Fieldbyname('csbh').Value;
if trim(aq1.Fields.Fieldbyname('flag').Value)='1' then
frm_sprcd.txtshflag.Text:='1-已审核';
aq1.First;
frm_sprcd.txtpc.Text:=aq1.Fields.Fieldbyname('pc').Value;
while not aq1.Eof do
begin
frm_sprcd.StringGrid1.RowCount:=aq1.Recordset.RecordCount+2;
for i:=1 to frm_sprcd.StringGrid1.RowCount-2 do
begin
frm_sprcd.StringGrid1.Cells[1,i]:=aq1.fields.fieldbyname('hcbh').value; //编号
frm_sprcd.StringGrid1.Cells[2,i]:=aq1.fields.fieldbyname('hcmc').value; //名称
frm_sprcd.StringGrid1.Cells[3,i]:=aq1.fields.fieldbyname('gg').value;//规格
frm_sprcd.StringGrid1.Cells[4,i]:=aq1.fields.fieldbyname('jldw').value;//单位
frm_sprcd.StringGrid1.Cells[5,i]:=aq1.fields.fieldbyname('jhdj').value; //进货单价
frm_sprcd.StringGrid1.Cells[6,i]:=aq1.fields.fieldbyname('jhsl').value; //进货数量
frm_sprcd.StringGrid1.Cells[7,i]:=aq1.fields.fieldbyname('jhje').value; // 进货金额
frm_sprcd.StringGrid1.Cells[8,i]:=aq1.fields.fieldbyname('pc').value; // 进货金额
aq1.Next;
end;
end;
end;
end;
end;
{with data do
begin
aq1.Connection:=adoc1;
with aq1 do
begin
close;
sql.Clear;
sql.Add(' select a.djbh,a.mcbh,a.bmbh,a.dlbh,a.xlbh,a.czybh,c.czymc,a.zdrq,a.flag,'+
' b.csbh,b.csmc,t1.spbh,t1.spmc,t1.spgg,t1.jldw,t1.shdj,t1.hydj,'+
' t1.jhdj,t1.cbdj,t1.cdbh,t1.aqcl,t1.jxcjl,t1.mxsl,t1.spxz,t1.state,'+
' t1.czsp,t1.bzsx,t1.jhtax,t1.xstax,t1.lykl from sprcd01 a,sprcd02 t1, '+
' czyda c,csda b where a.csbh=b.csbh and a.djbh=:djbh and c.czybh=a.czybh'+
' and t1.djbh=a.djbh');
aq1.Parameters.ParamByName('djbh').Value:=frm_sprcd.number[frm_sprcd.mainnumber-1];
//frm_sprcd.ComboBox1.Items[frm_sprcd.ComboBox1.Items.Count-1];
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
frm_sprcd.Edit1.Text:=aq1.Fields.Fieldbyname('djbh').Value;
frm_sprcd.Edit2.Text:=aq1.Fields.Fieldbyname('zdrq').Value;
frm_sprcd.Edit3.Text:=aq1.Fields.Fieldbyname('czybh').Value;
//frm_sprcd.Edit4.Text:=aq1.Fields.Fieldbyname('czymc').Value;
frm_sprcd.Edit6.Text:=aq1.Fields.Fieldbyname('mcbh').Value;
if aq1.Fields.Fieldbyname('flag').Value <>'1' then
frm_sprcd.edit5.Text:='0-未审核'
else
frm_sprcd.edit5.Text:='1-已审核';
while not aq1.Eof do
begin
frm_sprcd.StringGrid1.RowCount:=aq1.Recordset.RecordCount+1;
for i:=1 to frm_sprcd.StringGrid1.RowCount-1 do
begin
frm_sprcd.StringGrid1.Cells[1,i]:=aq1.fields.fieldbyname('spbh').value; //编号
frm_sprcd.StringGrid1.Cells[2,i]:=aq1.fields.fieldbyname('spmc').value; //名称
frm_sprcd.StringGrid1.Cells[3,i]:=aq1.fields.fieldbyname('spgg').value;//规格
frm_sprcd.StringGrid1.Cells[4,i]:=aq1.fields.fieldbyname('jldw').value;//单位
frm_sprcd.StringGrid1.Cells[5,i]:=aq1.fields.fieldbyname('shdj').value; //单价
frm_sprcd.StringGrid1.Cells[6,i]:=aq1.fields.fieldbyname('hydj').value; //状态
frm_sprcd.StringGrid1.Cells[7,i]:=aq1.fields.fieldbyname('jhdj').value; //进货单价
frm_sprcd.StringGrid1.Cells[8,i]:=aq1.fields.fieldbyname('cbdj').value; //成本单价
frm_sprcd.StringGrid1.Cells[9,i]:=aq1.fields.fieldbyname('cdbh').value;//产地编号
frm_sprcd.StringGrid1.Cells[10,i]:=aq1.fields.fieldbyname('aqcl').value;//缺货标志;
frm_sprcd.StringGrid1.Cells[11,i]:=aq1.fields.fieldbyname('jxcjl').value;//进销差价率
frm_sprcd.StringGrid1.Cells[12,i]:=aq1.fields.fieldbyname('mxsl').value;//包装量
frm_sprcd.StringGrid1.Cells[13,i]:=aq1.fields.fieldbyname('spxz').value;
frm_sprcd.StringGrid1.Cells[14,i]:=aq1.fields.fieldbyname('state').value;
frm_sprcd.StringGrid1.Cells[15,i]:=aq1.fields.fieldbyname('czsp').value;
frm_sprcd.StringGrid1.Cells[16,i]:=aq1.fields.fieldbyname('bzsx').value;
frm_sprcd.StringGrid1.Cells[17,i]:=aq1.fields.fieldbyname('jhtax').value;
frm_sprcd.StringGrid1.Cells[18,i]:=aq1.fields.fieldbyname('xstax').value;
frm_sprcd.StringGrid1.Cells[19,i]:=aq1.fields.fieldbyname('lykl').value;
aq1.Next;
end;
end; }
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -