dwyjfrm.pas
来自「本人编写的有关军队营房工作的管理系统」· PAS 代码 · 共 263 行
PAS
263 行
unit dwyjfrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons,db, Grids, DBGridEh, StdCtrls, ExtCtrls, dxdbtrel,
ImgList;
type
Tdwyj = class(TForm)
Panel1: TPanel;
Label1: TLabel;
DBGridEh1: TDBGridEh;
DBGridEh2: TDBGridEh;
Panel2: TPanel;
SpeedButton3: TSpeedButton;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton4: TSpeedButton;
Label2: TLabel;
ImageList1: TImageList;
dxLookupTreeView1: TdxLookupTreeView;
Edit1: TEdit;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
Label3: TLabel;
Edit2: TEdit;
SpeedButton13: TSpeedButton;
SpeedButton5: TSpeedButton;
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure DBGridEh2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DBGridEh2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure DBGridEh2DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
procedure DBGridEh2CellClick(Column: TColumnEh);
procedure SpeedButton7Click(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton13Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
dwyj: Tdwyj;
implementation
uses datafrm,yjxgfrm,yjczfrm,bbdcfrm,dwyjhzfrm;
{$R *.dfm}
procedure Tdwyj.SpeedButton3Click(Sender: TObject);
begin
yfgldata.Qdwyj1.Filter:='';
yfgldata.Qdwyj1.Filtered:=false;
close;
end;
procedure Tdwyj.SpeedButton2Click(Sender: TObject);
begin
if yfgldata.Qdwyj.RecordCount>0 then
begin
application.CreateForm(tyjxg,yjxg);
with yjxg do
begin
edit1.Text:=yfgldata.Qdwyj.FieldByName('编号').AsString;
edit2.Text:=yfgldata.Qdwyj.FieldByName('营具名称').AsString;
try
ShowModal;
finally
free;
end;
end;
end
else
messagebox(dwyj.handle,'没有营具可以修改。','营房工作管理系统',16);
end;
procedure Tdwyj.SpeedButton1Click(Sender: TObject);
var
bh,dm:string;
begin
if messagebox(dwyj.Handle,'确认要删除本营具吗?','营房工作管理系统',33)=1 then
begin
bh:=yfgldata.Qdwyj.FieldByName('编号').AsString;
dm:=yfgldata.Qdwyj.FieldByName('代码').AsString;
yfgldata.yj.Locate('编号',bh,[loCaseInsensitive]);
yfgldata.yj.Delete;
yfgldata.yj1.Locate('代码',dm,[loCaseInsensitive]);
yfgldata.yj1.edit;
yfgldata.yj1.FieldByName('数量').AsInteger:=yfgldata.yj1.FieldByName('数量').AsInteger-1;
yfgldata.yj1.FieldByName('合计金额').AsCurrency:=yfgldata.yj1.FieldByName('数量').AsInteger*yfgldata.yj1.FieldByName('单价').AsFloat;
yfgldata.yj1.Post;
if yfgldata.yj1.FieldByName('数量').AsInteger=0 then
yfgldata.yj1.Delete;
if yfgldata.kcyj.Locate('编号',bh,[loCaseInsensitive]) then
begin
yfgldata.kcyj.Delete;
yfgldata.kcyj1.Locate('代码',dm,[loCaseInsensitive]);
yfgldata.kcyj1.Edit;
yfgldata.kcyj1.FieldByName('数量').AsInteger:=yfgldata.kcyj1.FieldByName('数量').AsInteger-1;
yfgldata.kcyj1.FieldByName('合计金额').AsCurrency:=yfgldata.kcyj1.FieldByName('数量').AsInteger*yfgldata.kcyj1.FieldByName('单价').AsFloat;
yfgldata.kcyj1.Post;
if yfgldata.kcyj1.FieldByName('数量').AsInteger=0 then
yfgldata.kcyj1.Delete;
end;
if yfgldata.dwyj.Locate('编号',bh,[loCaseInsensitive]) then
begin
yfgldata.dwyj.Delete;
yfgldata.dwyj1.Locate('代码',dm,[loCaseInsensitive]);
yfgldata.dwyj1.Edit;
yfgldata.dwyj1.FieldByName('数量').AsInteger:=yfgldata.dwyj1.FieldByName('数量').AsInteger-1;
yfgldata.dwyj1.FieldByName('合计金额').AsCurrency:=yfgldata.dwyj1.FieldByName('数量').AsInteger*yfgldata.dwyj1.FieldByName('单价').AsFloat;
yfgldata.dwyj1.Post;
if yfgldata.dwyj1.FieldByName('数量').AsInteger=0 then
yfgldata.dwyj1.Delete;
end;
if yfgldata.grjyyj.Locate('编号',bh,[loCaseInsensitive]) then
begin
yfgldata.grjyyj1.Filter:='代码='''+dm+''' and 借用人='''+yfgldata.grjyyj.FieldByName('借用人').AsString+'''';
yfgldata.grjyyj1.Filtered:=true;
yfgldata.grjyyj1.Edit;
yfgldata.grjyyj1.FieldByName('数量').AsInteger:=yfgldata.grjyyj1.FieldByName('数量').AsInteger-1;
yfgldata.grjyyj1.FieldByName('合计金额').AsFloat:=yfgldata.grjyyj1.FieldByName('数量').AsFloat*yfgldata.grjyyj1.FieldByName('单价').AsFloat;
yfgldata.grjyyj1.Post;
if yfgldata.grjyyj1.FieldByName('数量').AsInteger=0 then
yfgldata.grjyyj1.Delete;
yfgldata.grjyyj1.Filtered:=false;
yfgldata.grjyyj.Delete;
end;
yfgldata.Qdwyj.Active:=false;
yfgldata.Qdwyj.Active:=true;
yfgldata.Qdwyj1.Active:=false;
yfgldata.Qdwyj1.Active:=true;
end;
end;
procedure Tdwyj.FormShow(Sender: TObject);
begin
yfgldata.Qdwyj.Active:=false;
yfgldata.Qdwyj.Active:=true;
yfgldata.Qdwyj1.Active:=false;
yfgldata.Qdwyj1.Active:=true;
if yfgldata.qdwyj1.RecordCount>0 then
dwyj.Edit1.Text:=yfgldata.dw.Lookup('单位代码',yfgldata.Qdwyj1.FieldByName('使用单位').AsString,'单位名称');
end;
procedure Tdwyj.DBGridEh2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if yfgldata.Qdwyj1.RecordCount>0 then
dwyj.Edit1.Text:=yfgldata.dw.Lookup('单位代码',yfgldata.Qdwyj1.FieldByName('使用单位').AsString,'单位名称');
end;
procedure Tdwyj.DBGridEh2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if yfgldata.Qdwyj1.RecordCount>0 then
dwyj.Edit1.Text:=yfgldata.dw.Lookup('单位代码',yfgldata.Qdwyj1.FieldByName('使用单位').AsString,'单位名称');
end;
procedure Tdwyj.DBGridEh2DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
if yfgldata.Qdwyj1.RecordCount>0 then
dwyj.Edit1.Text:=yfgldata.dw.Lookup('单位代码',yfgldata.Qdwyj1.FieldByName('使用单位').AsString,'单位名称');
end;
procedure Tdwyj.DBGridEh2CellClick(Column: TColumnEh);
begin
if yfgldata.Qdwyj1.RecordCount>0 then
dwyj.Edit1.Text:=yfgldata.dw.Lookup('单位代码',yfgldata.Qdwyj1.FieldByName('使用单位').AsString,'单位名称');
end;
procedure Tdwyj.SpeedButton7Click(Sender: TObject);
begin
dwyj.dxLookupTreeView1.Text:='';
dwyj.Edit2.Text:='';
yfgldata.Qdwyj1.Filtered:=false;
end;
procedure Tdwyj.SpeedButton6Click(Sender: TObject);
begin
yfgldata.Qdwyj1.Filter:='';
if dwyj.dxLookupTreeView1.Text<>'' then
yfgldata.Qdwyj1.Filter:=yfgldata.Qdwyj1.Filter+'使用单位='''+dwyj.dxLookupTreeView1.Text+'''';
if dwyj.Edit2.Text<>'' then
if yfgldata.Qdwyj1.Filter<>'' then
yfgldata.Qdwyj1.Filter:=yfgldata.Qdwyj1.Filter+' and 营具名称='''+dwyj.Edit2.Text+''''
else
yfgldata.Qdwyj1.Filter:=yfgldata.Qdwyj1.Filter+'营具名称='''+dwyj.Edit2.Text+'''';
yfgldata.Qdwyj1.Filtered:=true;
if yfgldata.Qdwyj1.RecordCount>0 then
dwyj.Edit1.Text:=yfgldata.dw.Lookup('单位代码',yfgldata.Qdwyj1.FieldByName('使用单位').AsString,'单位名称');
end;
procedure Tdwyj.SpeedButton4Click(Sender: TObject);
begin
application.CreateForm(tyjcz,yjcz);
yjcz.vps_name:='yfgldata.ddwyj';
try
yjcz.ShowModal;
finally
yjcz.Free;
end;
end;
procedure Tdwyj.SpeedButton13Click(Sender: TObject);
begin
application.CreateForm(tbbdc,bbdc);
with bbdc do
begin
listbox1.Items.Add('代码');
listbox1.Items.Add('营具名称');
listbox1.Items.Add('单位');
listbox1.Items.Add('单价');
listbox1.Items.Add('数量');
listbox1.Items.Add('合计金额');
listbox1.Items.Add('使用单位');
vps_filter:='';
if dwyj.dxLookupTreeView1.Text<>'' then
vps_filter:=vps_filter+'使用单位='''+dwyj.dxLookupTreeView1.Text+'''';
if dwyj.Edit2.Text<>'' then
if vps_filter<>'' then
vps_filter:=vps_filter+' and 营具名称='''+dwyj.Edit2.Text+''''
else
vps_filter:=vps_filter+'营具名称='''+dwyj.Edit2.Text+'''';
vps_name:='yfgl_dwyj1';
if dwyj.dxLookupTreeView1.Text<>'' then
edit1.Text:=yfgldata.dw.Lookup('单位代码',dwyj.dxLookupTreeView1.Text,'单位名称')+'营具报表'
else
edit1.text:='所有单位营具报表';
try
ShowModal;
finally
free;
end;
end;
end;
procedure Tdwyj.SpeedButton5Click(Sender: TObject);
begin
application.CreateForm(tdwyjhz,dwyjhz);
try
yfgldata.Qdwyj1.Filter:='';
yfgldata.Qdwyj1.Filtered:=false;
dwyjhz.ShowModal;
finally
dwyjhz.Free;
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?