📄 partout.pas
字号:
begin
action:=cafree;
end;
procedure TForm_partout.btn_filterfieldClick(Sender: TObject);
begin
//unit_wxp.TransADO :=self.Query1 ;
Application.CreateForm(TForm_search, Form_search);
//
form_search.TransADO :=self.Query1 ;
unit_wxp.WhichForm:=3;
form_search.Showmodal ;
//showmessage(inttostr(form_search.TransADO.FieldDefList.Count ));
end;
procedure TForm_partout.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Key := #0;
Perform(WM_NEXTDLGCTL, 0, 0);
end;
end;
procedure TForm_partout.DBEdit2Enter(Sender: TObject);
begin
dbedit2.Text :=datetostr(date);
end;
procedure TForm_partout.Query1AfterOpen(DataSet: TDataSet);
var
i:integer;
tempName:string;
begin
Label23.Caption :=inttostr(query1.Recordset.RecordCount) ;
if NotFirst=false then
begin
StringGrid1.Cells [0,1]:='合计';
StringGrid1.Cells [0,0]:='统计数据';
j:=0;
for i:=0 to self.Query1 .FieldList.Count-1 do
begin
//list_fields.Items.Add (TransADO.Fields[i].FieldName );
//将每个字段的字段类型放在数组中
unit_wxp.FieldType[i]:= self.Query1.Fields[i].DataType;
tempName:= self.Query1 .Fields[i].FieldName;
if (tempName<>'单价') and (tempName<>'序号') then
begin
if (unit_wxp.GetFieldType(i)='number') or (unit_wxp.GetFieldType(i)='money') then
begin
j:=j+1;
StringGrid1.Cells [j,0]:=tempName ;
stringgrid1.ColCount := stringgrid1.ColCount +1;
myIndex[j]:=i;
end;
end;
end;
NotFirst:=true;
end;
while not Query1.Eof do
begin
for i:=1 to j do
begin
myValue[i]:=myValue[i]+Query1.Fields.Fields[myIndex[i]].AsFloat ;
end;
Query1.Next ;
end;
for i:=1 to j do
begin
stringgrid1.Cells[i,1]:=floattostr(myValue[i]);
myValue[i]:=0;
end;
end;
procedure TForm_partout.EditDBEdit12Exit(Sender: TObject);
begin
if (EditDBEdit12.Text<>'') and (EditDBEdit11.Text<>'') then
EditDBEdit13.Text :=floattostr(strtofloat(EditDBEdit11.Text )*strtofloat(EditDBEdit12.Text ));
end;
procedure TForm_partout.Button2Click(Sender: TObject);
begin
self.Query1.Active :=false;
self.Query1.SQL.Clear ;
self.Query1.SQL.Add('select * from pub_z_partout ');
self.Query1.Active :=true;
end;
procedure TForm_partout.Query1AfterPost(DataSet: TDataSet);
var
tempNum:string;
begin
tempNum:=editdbedit11.Text ;
dm_wxp.ADOQuery1.Close ;
dm_wxp.ADOQuery1.SQL.Clear ;
dm_wxp.ADOQuery1.SQL.Add('update pub_z_part set 库存量=库存量-'+tempNum +' where 编号='''+
DBComboBox1.Text +'''' );
dm_wxp.ADOQuery1.ExecSQL ;
end;
procedure TForm_partout.AddPartNum();
begin
dm_wxp.ADOQuery1.Close ;
dm_wxp.ADOQuery1.SQL.Clear ;
dm_wxp.ADOQuery1.SQL.Add('select 编号,名称 from pub_z_part' );
dm_wxp.ADOQuery1.Active :=true ;
while not dm_wxp.ADOQuery1.Eof do
begin
DBComboBox1.Items.Add(dm_wxp.ADOQuery1.Fields.Fields[0].asstring) ;
DBComboBox3.Items.Add(dm_wxp.ADOQuery1.Fields.Fields[1].asstring);
dm_wxp.ADOQuery1.Next ;
end;
dm_wxp.ADOQuery1.Active :=false ;
end;
procedure TForm_partout.btn_deleteClick(Sender: TObject);
var
tempNum:string;
tempStr:string;
begin
NumDelete:=editdbedit11.Text ;
StrDelete:=DBComboBox1.Text;
if application.MessageBox(pchar('确信要删除这条记录嘛?'),
pchar('注意'),MB_OKCANCEL)=IDOK then
self.Query1.Delete ;
if self.Query1.Recordset.RecordCount =0 then
begin
btn_delete.Enabled :=false;
btn_edit.Enabled :=false;
end;
label23.Caption :=inttostr(self.Query1.Recordset.RecordCount);
end;
procedure TForm_partout.EditDBEdit11Exit(Sender: TObject);
begin
if (EditDBEdit12.Text<>'') and (EditDBEdit11.Text<>'') then
EditDBEdit13.Text :=floattostr(strtofloat(EditDBEdit11.Text )*strtofloat(EditDBEdit12.Text ));
if (EditDBEdit11.Text<>'') and (DBEdit7.Text<>'') then
DBEdit8.Text :=floattostr(strtofloat(EditDBEdit11.Text )*strtofloat(DBEdit7.Text ));
end;
procedure TForm_partout.DBComboBox1Exit(Sender: TObject);
begin
if DbComboBox1.Text <>'' then
begin
dm_wxp.ADOQuery1.Active :=false;
dm_wxp.ADOQuery1.SQL.Clear ;
//showmessage('select 名称,机型,型号 from pub_z_part where 编号='''
//+self.EditDBEdit2.Text +'''');
dm_wxp.ADOQuery1.SQL.Add('select 名称,型号,单位,进价,机型 from pub_z_part where 编号='''
+trim(self.DBComboBox1.Text) +'''');
dm_wxp.ADOQuery1.Active :=true;
//showmessage(inttostr(dm_wxp.ADOQuery1.RecordCount ));
//dm_wxp.ADOQuery1.First ;
if dm_wxp.ADOQuery1.eof then
begin
showmessage('该零件不存在');
end ;
end;
end;
procedure TForm_partout.DBComboBox3Exit(Sender: TObject);
begin
if DBComBoBox3.Text <>'' then
begin
dm_wxp.ADOQuery1.Active :=false;
dm_wxp.ADOQuery1.SQL.Clear ;
//showmessage('select 名称,机型,型号 from pub_z_part where 编号='''
//+self.EditDBEdit2.Text +'''');
dm_wxp.ADOQuery1.SQL.Add('select 编号,型号,单位,进价,机型 from pub_z_part where 名称='''
+trim(self.DBComboBox3.Text) +'''');
dm_wxp.ADOQuery1.Active :=true;
//showmessage(inttostr(dm_wxp.ADOQuery1.RecordCount ));
//dm_wxp.ADOQuery1.First ;
if dm_wxp.ADOQuery1.eof then
begin
showmessage('该零件不存在');
end ;
end;
end;
procedure TForm_partout.DBEdit7Exit(Sender: TObject);
begin
if (EditDBEdit11.Text<>'') and (DBEdit7.Text<>'') then
dBEdit8.Text :=floattostr(strtofloat(EditDBEdit11.Text )*strtofloat(DBEdit7.Text ));
end;
procedure TForm_partout.FormDestroy(Sender: TObject);
begin
Form_partout:=nil;
end;
procedure TForm_partout.Query1BeforeDelete(DataSet: TDataSet);
begin
dm_wxp.ADOQuery1.Close ;
dm_wxp.ADOQuery1.SQL.Clear ;
dm_wxp.ADOQuery1.SQL.Add('update pub_z_part set 库存量=库存量+'+NumDelete +' where 编号='''+
StrDelete +'''' );
dm_wxp.ADOQuery1.ExecSQL ;
end;
procedure TForm_partout.DBComboBox1Click(Sender: TObject);
begin
dm_wxp.ADOQuery1.Active :=false;
dm_wxp.ADOQuery1.SQL.Clear ;
//showmessage('select 名称,机型,型号 from pub_z_part where 编号='''
//+self.EditDBEdit2.Text +'''');
dm_wxp.ADOQuery1.SQL.Add('select 名称,型号,单位,进价,机型,物资类别 from pub_z_part where 编号='''
+trim(self.DBComboBox1.Text) +'''');
dm_wxp.ADOQuery1.Active :=true;
//showmessage(inttostr(dm_wxp.ADOQuery1.RecordCount ));
//dm_wxp.ADOQuery1.First ;
if dm_wxp.ADOQuery1.RecordCount<>0 then
begin
//editdbedit9.SetFocus ;
query1.FieldValues['名称']:=
//DBComboBox3.Text :=
dm_wxp.ADOQuery1.Fields.Fields[0].AsString;
self.EditDBEdit10.Text :=dm_wxp.ADOQuery1.Fields.Fields[1].AsString ;
self.DBEdit4.Text :=dm_wxp.ADOQuery1.Fields.Fields[2].AsString ;
self.EditDBEdit12.Text := dm_wxp.ADOQuery1.Fields.Fields[3].AsString ;
self.DBEdit6.Text := dm_wxp.ADOQuery1.Fields.Fields[4].AsString ;
self.DBEdit9.Text := dm_wxp.ADOQuery1.Fields.Fields[5].AsString ;
end;
end;
procedure TForm_partout.DBComboBox3Click(Sender: TObject);
begin
dm_wxp.ADOQuery1.Active :=false;
dm_wxp.ADOQuery1.SQL.Clear ;
//showmessage('select 名称,机型,型号 from pub_z_part where 编号='''
//+self.EditDBEdit2.Text +'''');
dm_wxp.ADOQuery1.SQL.Add('select 编号,型号,单位,进价,机型,物资类别 from pub_z_part where 名称='''
+trim(self.DBComboBox3.Text) +'''');
dm_wxp.ADOQuery1.Active :=true;
//showmessage(inttostr(dm_wxp.ADOQuery1.RecordCount ));
//dm_wxp.ADOQuery1.First ;
if dm_wxp.ADOQuery1.RecordCount<>0 then
begin
//self.DBComboBox1.SetFocus ;
//self.DBComboBox1.Text :=dm_wxp.ADOQuery1.Fields.Fields[0].AsString ;
query1.FieldValues['物资编号']:=dm_wxp.ADOQuery1.Fields.Fields[0].AsString ;
self.EditDBEdit10.Text :=dm_wxp.ADOQuery1.Fields.Fields[1].AsString ;
self.DBEdit4.Text :=dm_wxp.ADOQuery1.Fields.Fields[2].AsString ;
self.EditDBEdit12.Text :=dm_wxp.ADOQuery1.Fields.Fields[3].AsString ;
self.DBEdit6.Text := dm_wxp.ADOQuery1.Fields.Fields[4].AsString ;
self.DBEdit9.Text := dm_wxp.ADOQuery1.Fields.Fields[5].AsString ;
end;
end;
procedure TForm_partout.PageControl1Change(Sender: TObject);
begin
if pagecontrol1.TabIndex =0 then
begin
panel1.Enabled :=true;
end
else
begin
panel1.Enabled :=false;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -