📄 dincome.pas
字号:
unit DInCome;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Unitmb, ImgList, Menus, ComCtrls, ToolWin, Grids, DBGridEh,
Buttons, StdCtrls, ExtCtrls, FR_Ctrls, Mask, DBCtrls, dbcgrids, DBCtrlsEh;
type
TDInComeForm = class(TmbForm)
lblAmount: TLabel;
edtAmount: TEdit;
edtChkNo: TEdit;
edtPayStyle: TfrComboEdit;
lblStyle: TLabel;
procedure edtStoreButtonClick(Sender: TObject);
procedure cmdEditClick(Sender: TObject);
procedure edtPayStyleButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure DBGrid1Columns0EditButtonClick(Sender: TObject;
var Handled: Boolean);
private
{ Private declarations }
nBankId,nPayTypeid:integer;
nOldBankId,nOldPayTypeid:integer;
sOldChkNo:string;
procedure InitInfo;override;
procedure InsertDetail;override;
procedure UpdateDetail;override;
procedure InsertMaster(sInvono:string);override;
procedure UpdateMaster;override;
procedure ShowMasterSpecial(bAdd:boolean);override;
public
{ Public declarations }
end;
var
DInComeForm: TDInComeForm;
implementation
uses datamodule1, selPaytype, TreeIEType;
{$R *.dfm}
procedure TDInComeForm.InitInfo;
begin
inherited;
nCusId:=100;
end;
procedure TDInComeForm.InsertDetail;
var
sSql:string;
begin
with dataE2 do
begin
sSql:='( :billid, :itemno, :IETypecode, :amount, :memo1)';
adoCmd.commandtext:='insert into '+myTable+'D values '+sSql;
adoCmd.parameters[0].value:=nBillId;
adoCmd.parameters[1].value:=queryDetail.fieldbyname('itemno').asinteger;
adoCmd.parameters[2].value:=queryDetail.fieldbyname('ietypecode').asstring;
adoCmd.parameters[3].value:=queryDetail.fieldbyname('amount').ascurrency;
adoCmd.parameters[4].value:=queryDetail.fieldbyname('memo1').asstring;
adoCmd.execute;
end;
end;
procedure TDInComeForm.UpdateDetail;
begin
with dataE2 do
begin
adoCmd.commandtext:='update '+myTable+'D set Amount = :Amount, memo1= :memo1 where billid= :billid and itemno= :itemno';
adoCmd.parameters[0].value:=queryDetail.fieldbyname('Amount').ascurrency;
adoCmd.parameters[1].value:=queryDetail.fieldbyname('memo1').asstring;
adoCmd.parameters[2].value:=nBillId;
adoCmd.parameters[3].value:=queryDetail.fieldbyname('itemno').asstring;
adoCmd.execute;
end;
end;
procedure TDInComeForm.InsertMaster(sInvoNo:string);
begin
with dataE2 do
InsertDIncome(nBillid,nEmployid,nBankId,nPayTypeId,edtBillDate.date,sInvoNo,edtMemo.text,edtChkNo.text,myTable);
end;
procedure TDInComeForm.UpdateMaster;
var
i:integer;
begin
sMasterMemo:=trim(edtMemo.text);
//dynamic sql sentence
i:=0;
with dataE2 do
begin
adoCmd.CommandText:='update '+mytable+' set ';
if nBankId <> nOldBankId then
begin
if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';
adoCmd.CommandText :=adoCmd.CommandText +' BankId= :BankId ';
adoCmd.Parameters[i].value:=nBankId;
inc(i);
end;
if nPayTypeId <> nOldPayTypeId then
begin
if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';
adoCmd.CommandText :=adoCmd.CommandText +' PayTypeid= :Paytypeid ';
adoCmd.Parameters[i].value:=nPaytypeId;
inc(i);
end;
if sOldchkNo <> edtChkNo.text then
begin
if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';
adoCmd.CommandText :=adoCmd.CommandText +' CheckNo= :CheckNo ';
adoCmd.Parameters[i].value:=edtChkNO.text;
inc(i);
end;
if sMasterMemo <> sOldMasterMemo then
begin
if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';
adoCmd.CommandText :=adoCmd.CommandText +' Memo= :Memo ';
adoCmd.Parameters[i].value:=sMastermemo;
inc(i);
end;
if i>0 then
begin
adoCmd.CommandText :=adoCmd.CommandText +' where BillId= :Billid ';
adoCmd.parameters[i].value:=nBillid;
adoCmd.Execute ;
end;
end; //dataE2
end;
procedure TDInComeForm.ShowMasterSpecial(bAdd:boolean);
var
s,sSql:string;
begin
with DataE2 do
if not bAdd then
begin
nEmployId:=adoquery1.fieldbyname('EmployId').asinteger;
nPayTypeId:=adoquery1.fieldbyname('PaytypeId').asinteger;
nBankId:=adoquery1.fieldbyname('BankId').asinteger;
sMasterMemo:=trim(adoquery1.fieldbyname('Memo').asstring);
edtChkNo.Text:=trim(adoquery1.fieldbyname('CheckNo').asstring);
edtMemo.text:=sMastermemo;
s:='';
if OpenTable('select * from employ where EmployId= :employid',nEmployid) then
s:=adoquery1.fieldbyname('name').asstring;
edtEmp.text:=s;
s:='';
if OpenTable('select * from bank where bankId= :bankid',nBankid) then
s:=adoquery1.fieldbyname('name').asstring;
edtPayStyle.text:=s;
adoQuery1.close;
s:='';
if OpenTable('select * from Paytype where PaytypeId= :Paytypeid',nPaytypeId) then
s:=adoquery1.fieldbyname('name').asstring;
edtStore.text:=s;
adoQuery1.close;
end
else begin //add emptye record,so clear last infomation
edtAmount.Text:='';
//edtPayStyle.Text:='';
//edtStore.Text:='';
//edtEmp.Text:='';
edtchkNo.Text:='';
edtMemo.text:='';
s:='';
nEmployId:=1;
if OpenTable('select * from employ where EmployId= :employid',nEmployid) then
s:=adoquery1.fieldbyname('name').asstring;
edtEmp.text:=s;
s:='';
nBankId:=1;
if OpenTable('select * from bank where bankId= :bankid',nBankid) then
s:=adoquery1.fieldbyname('name').asstring;
edtPayStyle.text:=s;
adoQuery1.close;
s:='';
nPaytypeId:=1;
if OpenTable('select * from Paytype where PaytypeId= :Paytypeid',nPaytypeId) then
s:=adoquery1.fieldbyname('name').asstring;
edtStore.text:=s;
adoQuery1.close;
end;
end;
procedure TDInComeForm.edtStoreButtonClick(Sender: TObject);
begin
// inherited;
if not cmdSave.Enabled then exit;
dlgselPayType.Newsql:='select Paytypeid as id,name from paytype ';
dlgSelpaytype.Top :=self.top+(sender as TComboBox).Top +81;//toolbar1.height+edtInstore.Height+20 ;
dlgSelpaytype.Left :=self.Left+(sender as TComboBox).left+4 ;
if dlgselPayType.showmodal=mrok then
with dataE2 do
begin
(sender as TComboBox).Text :=dlgselPayType.xName;
nPayTypeId:=dlgSelPaytype.xid;
end;
end;
procedure TDInComeForm.cmdEditClick(Sender: TObject);
begin
inherited;
nOldBankId:=nBankId;
nOldPaytypeId:=nPaytypeId;
sOldChkNo:=edtChkNo.Text;
end;
procedure TDInComeForm.edtPayStyleButtonClick(Sender: TObject);
begin
inherited;
if not cmdSave.Enabled then exit;
dlgselPayType.Newsql:='select Bankid as id,name from bank ';
dlgSelpaytype.Top :=self.top+(sender as TComboBox).Top +81;//toolbar1.height+edtInstore.Height+20 ;
dlgSelpaytype.Left :=self.Left+(sender as TComboBox).left+4 ;
if dlgselPayType.showmodal=mrok then
with dataE2 do
begin
(sender as TComboBox).Text :=dlgselPayType.xName;
nBankId:=dlgSelPaytype.xid;
end;
end;
procedure TDInComeForm.FormCreate(Sender: TObject);
begin
inherited;
if nTableid=43 then
begin
LblFormName.Caption :='费用开支';
caption:=lblFormName.caption;
lblAmount.Caption:='付款金额';
lblStyle.Caption:='付款类型';
lblStore.Caption:='付款方式';
end;
end;
procedure TDInComeForm.DBGrid1Columns0EditButtonClick(Sender: TObject;
var Handled: Boolean);
begin
inherited;
if TreeIETypefrm.showmodal=mrok then
with dataE2 do
begin
queryDetail.Edit;
if dataE2.gTableId =33 then
queryDetail.FieldByName('IETypeCode').AsString :=TreeIETypefrm.xName
else
queryDetail.FieldByName('IETypeCode').AsString :=TreeIETypefrm.xCode;
queryDetail.FieldByName('Memo1').AsString :=TreeIETypefrm.xName;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -