unit u_ch_fee_truck; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, ExtCtrls, Grids, Wwdbigrd, Wwdbgrid, bsSkinCtrls, StdCtrls, wwdblook, BusinessSkinForm; type Tfrm_ch_fee_truck = class(TForm) t_ch_fee_truck: TADOQuery; t_ch_fee_truck1: TDataSource; Panel1: TPanel; wwDBGrid1: TwwDBGrid; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton8: TbsSkinButton; wwDBLookupCombo1: TwwDBLookupCombo; wwDBLookupCombo2: TwwDBLookupCombo; wwDBLookupCombo3: TwwDBLookupCombo; wwDBLookupCombo4: TwwDBLookupCombo; wwDBLookupCombo5: TwwDBLookupCombo; bsSkinButton5: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsBusinessSkinForm1: TbsBusinessSkinForm; procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure t_ch_fee_truckAfterInsert(DataSet: TDataSet); procedure t_ch_fee_truckBeforePost(DataSet: TDataSet); procedure wwDBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure t_ch_fee_truckBeforeEdit(DataSet: TDataSet); procedure FormShow(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_ch_fee_truck: Tfrm_ch_fee_truck; implementation uses u_op_seae, u_main, my_sys_function, u_data_share; {$R *.dfm} procedure Tfrm_ch_fee_truck.bsSkinButton1Click(Sender: TObject); begin t_ch_fee_truck.insert; end; procedure Tfrm_ch_fee_truck.bsSkinButton2Click(Sender: TObject); begin table_post(t_ch_fee_truck); end; procedure Tfrm_ch_fee_truck.bsSkinButton4Click(Sender: TObject); begin table_delete(t_ch_fee_truck); end; procedure Tfrm_ch_fee_truck.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_ch_fee_truck); end; procedure Tfrm_ch_fee_truck.t_ch_fee_truckAfterInsert(DataSet: TDataSet); begin t_ch_fee_truck['收费金额']:=0; t_ch_fee_truck['付费金额']:=0; t_ch_fee_truck['余额']:=0; t_ch_fee_truck['费用状态']:='录入状态'; t_ch_fee_truck['录入人']:=employee; t_ch_fee_truck['录入日期']:=now; end; procedure Tfrm_ch_fee_truck.t_ch_fee_truckBeforePost(DataSet: TDataSet); begin t_ch_fee_truck['费用状态']:=t_ch_fee_truck['费用状态']; t_ch_fee_truck['余额']:=t_ch_fee_truck['收费金额']-t_ch_fee_truck['付费金额']; end; procedure Tfrm_ch_fee_truck.wwDBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); begin fee_color(t_ch_fee_truck,wwDBGrid1,Rect,Field); end; procedure Tfrm_ch_fee_truck.bsSkinButton11Click(Sender: TObject); var i:integer; begin if t_ch_fee_truck.isempty then exit; if (t_ch_fee_truck.State=dsinsert) or (t_ch_fee_truck.State=dsedit) then begin t_ch_fee_truck.post; end; if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_ch_fee_truck.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); if (t_ch_fee_truck.FieldByName('费用状态').asstring<>'录入状态') and (t_ch_fee_truck.FieldByName('费用状态').asstring<>'驳回提交') and (t_ch_fee_truck.FieldByName('费用状态').asstring<>'批准修改') then begin showmessage('当前费用状态不能提交审核!!'); exit; end; end; end else begin if (t_ch_fee_truck.FieldByName('费用状态').asstring<>'录入状态') and (t_ch_fee_truck.FieldByName('费用状态').asstring<>'驳回提交') and (t_ch_fee_truck.FieldByName('费用状态').asstring<>'批准修改') then begin showmessage('当前费用状态不能提交审核!!'); exit; end; end; try frm_main.db.BeginTrans; if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_ch_fee_truck.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); t_ch_fee_truck.edit; t_ch_fee_truck['费用状态']:='提交审核'; t_ch_fee_truck.post; end; end else begin t_ch_fee_truck.edit; t_ch_fee_truck['费用状态']:='提交审核'; t_ch_fee_truck.post; end; frm_main.db.CommitTrans; except frm_main.db.RollbackTrans; showmessage('费用提交审核失败!'); exit; end; end; procedure Tfrm_ch_fee_truck.bsSkinButton6Click(Sender: TObject); var i:integer; begin if t_ch_fee_truck.isempty then exit; if (t_ch_fee_truck.State=dsinsert) or (t_ch_fee_truck.State=dsedit) then begin t_ch_fee_truck.post; end; if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_ch_fee_truck.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); if (t_ch_fee_truck.FieldByName('收费结算').asfloat<>0) and (t_ch_fee_truck.FieldByName('付费结算').asfloat<>0) then begin showmessage('当前费用已经结算不可以申请修改!!'); exit; end; if (t_ch_fee_truck.FieldByName('费用状态').asstring<>'审核通过') and (t_ch_fee_truck.FieldByName('费用状态').asstring<>'禁止修改') then begin showmessage('当前费用状态不可以申请修改!!'); exit; end; end; end else begin if (t_ch_fee_truck.FieldByName('收费结算').asfloat<>0) and (t_ch_fee_truck.FieldByName('付费结算').asfloat<>0) then begin showmessage('当前费用已经结算不可以申请修改!!'); exit; end; if (t_ch_fee_truck.FieldByName('费用状态').asstring<>'审核通过') and (t_ch_fee_truck.FieldByName('费用状态').asstring<>'禁止修改') then begin showmessage('当前费用状态不可以申请修改!!'); exit; end; end; try frm_main.db.BeginTrans; if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_ch_fee_truck.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); t_ch_fee_truck.edit; t_ch_fee_truck['费用状态']:='申请修改'; t_ch_fee_truck.post; end; end else begin t_ch_fee_truck.edit; t_ch_fee_truck['费用状态']:='申请修改'; t_ch_fee_truck.post; end; frm_main.db.CommitTrans; except frm_main.db.RollbackTrans; showmessage('费用申请修改失败!'); exit; end; end; procedure Tfrm_ch_fee_truck.bsSkinButton8Click(Sender: TObject); var i:integer; begin if t_ch_fee_truck.isempty then exit; if (t_ch_fee_truck.State=dsinsert) or (t_ch_fee_truck.State=dsedit) then begin t_ch_fee_truck.post; end; if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_ch_fee_truck.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); if (t_ch_fee_truck.FieldByName('费用状态').asstring<>'申请修改') then begin showmessage('当前费用状态不可以取消申请修改!!'); exit; end; end; end else begin if (t_ch_fee_truck.FieldByName('费用状态').asstring<>'申请修改') then begin showmessage('当前费用状态不可以取消申请修改!!'); exit; end; end; try frm_main.db.BeginTrans; if wwDBGrid1.SelectedList.Count>=1 then begin for i:=0 to wwDBGrid1.SelectedList.Count-1 do begin t_ch_fee_truck.GotoBookmark(pointer(wwDBGrid1.SelectedList[i])); t_ch_fee_truck.edit; t_ch_fee_truck['费用状态']:='审核通过'; t_ch_fee_truck.post; end; end else begin t_ch_fee_truck.edit; t_ch_fee_truck['费用状态']:='审核通过'; t_ch_fee_truck.post; end; frm_main.db.CommitTrans; except frm_main.db.RollbackTrans; showmessage('费用取消申请修改失败!'); exit; end; end; procedure Tfrm_ch_fee_truck.t_ch_fee_truckBeforeEdit(DataSet: TDataSet); begin if not modify_all then begin if t_ch_fee_truck.IsEmpty then exit; if (t_ch_fee_truck.FieldByName('费用状态').asstring<>'录入状态') and (t_ch_fee_truck.FieldByName('费用状态').asstring<>'驳回提交') and (t_ch_fee_truck.FieldByName('费用状态').asstring<>'提交审核') and (t_ch_fee_truck.FieldByName('费用状态').asstring<>'批准修改') then begin showmessage('当前费用状态不能进行更改!!'); abort; end end; end; procedure Tfrm_ch_fee_truck.FormShow(Sender: TObject); begin t_ch_fee_truck.open; end; procedure Tfrm_ch_fee_truck.FormClose(Sender: TObject; var Action: TCloseAction); begin t_ch_fee_truck.close; end; procedure Tfrm_ch_fee_truck.bsSkinButton5Click(Sender: TObject); var afield : variant; i: Integer; begin if t_ch_fee_truck.IsEmpty then exit; afield := vararraycreate([0,t_ch_fee_truck.fieldcount-1],varvariant); for i := 0 to (t_ch_fee_truck.fieldcount-1) do begin afield[i] :=t_ch_fee_truck.fields[i].value ; end; t_ch_fee_truck.append; for i :=0 to (t_ch_fee_truck.fieldcount-1) do begin if t_ch_fee_truck.fields[i].FieldName<>'TF_ID' then t_ch_fee_truck.fields[i].value := afield[i] ; end; t_ch_fee_truck['费用状态']:='录入状态'; t_ch_fee_truck['录入人']:=employee; t_ch_fee_truck['录入日期']:=now; t_ch_fee_truck['收费结算']:=0; t_ch_fee_truck['付费结算']:=0; end; procedure Tfrm_ch_fee_truck.bsSkinButton7Click(Sender: TObject); begin close; end; end.