unit u_op_sate; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, ADODB, dxDBTLCl, dxGrClms, bsdbctrls, RxLookup, StdCtrls, Mask, DBCtrls, wwdbedit, Wwdotdot, Wwdbcomb, Menus, XPMenu, ExtCtrls; type Tfra_op_state = class(TFrame) t_op_state1: TDataSource; t_op_state: TADOQuery; Panel1: TPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; edit_state: TEdit; PopupMenu1: TPopupMenu; bsSkinButton11: TbsSkinButton; N1: TMenuItem; bsSkinButton5: TbsSkinButton; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridCheckColumn; dxDBGrid1Column3: TdxDBGridDateColumn; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column5: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridDateColumn; bsSkinButton6: TbsSkinButton; bsSkinButton7: TbsSkinButton; dxDBGrid1Column8: TdxDBGridColumn; procedure t_op_stateAfterInsert(DataSet: TDataSet); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure t_op_stateBeforePost(DataSet: TDataSet); procedure Panel1Resize(Sender: TObject); procedure t_op_stateBeforeDelete(DataSet: TDataSet); procedure add_state_menu(n1:TPopupMenu); procedure add_state(Sender:TObject); procedure t_op_stateBeforeInsert(DataSet: TDataSet); procedure FrameEnter(Sender: TObject); procedure add_all(Sender:TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure dxDBGrid1Column1CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure t_op_stateBeforeEdit(DataSet: TDataSet); private { Private declarations } public { Public declarations } end; implementation uses u_main, u_data_share, my_sys_function, u_op_state_add; {$R *.dfm} procedure Tfra_op_state.add_state(Sender:TObject); var menu_skins:Tmenuitem; begin menu_skins:= Sender as Tmenuitem; try modify_all:=true; t_op_state.Append; t_op_state['业务状态']:=menu_skins.caption; try t_op_state['顺序']:=strtoint(menu_skins.Hint); except t_op_state['顺序']:=0; end; t_op_state.post; finally modify_all:=false; end; end; procedure Tfra_op_state.add_all(Sender:TObject); var menu_skins:Tmenuitem; begin menu_skins:= Sender as Tmenuitem; try modify_all:=true; frm_data_share.t_code_state.first; while not frm_data_share.t_code_state.eof do begin t_op_state.Append; t_op_state['业务状态']:=frm_data_share.t_code_state.fieldbyname('业务状态').asstring; t_op_state['顺序']:=frm_data_share.t_code_state.fieldbyname('顺序').asinteger; t_op_state.post; frm_data_share.t_code_state.next; end; finally modify_all:=false; end; end; procedure Tfra_op_state.add_state_menu(n1:TPopupMenu); var nn:Tmenuitem; i:integer; begin nn:=Tmenuitem.Create(application); with nn do begin caption:='添加所有状态 '; onclick:=add_all; n1.Items.Add(nn); end; i:=0; frm_data_share.t_code_state.first; while not frm_data_share.t_code_state.eof do begin i:=i+1; nn:=Tmenuitem.Create(application); with nn do begin caption:='-'; n1.Items.Add(nn); end; nn:=Tmenuitem.Create(application); with nn do begin caption:=frm_data_share.t_code_state.fieldbyname('业务状态').asstring; nn.Hint:=frm_data_share.t_code_state.fieldbyname('顺序').asstring; onclick:=add_state; n1.Items.Add(nn); end; frm_data_share.t_code_state.next; end; end; procedure Tfra_op_state.t_op_stateAfterInsert(DataSet: TDataSet); begin t_op_state['编号']:=t_op_state.DataSource.DataSet['编号']; t_op_state['录入人']:=employee; t_op_state['录入日期']:=date; end; procedure Tfra_op_state.bsSkinButton1Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton1.ClientToScreen(Point(0,bsSkinButton1.Height)); PopupMenu1.Popup(Pnt.x,Pnt.y); end; procedure Tfra_op_state.bsSkinButton2Click(Sender: TObject); begin table_post(t_op_state); end; procedure Tfra_op_state.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_op_state); end; procedure Tfra_op_state.t_op_stateBeforePost(DataSet: TDataSet); begin table_before_post(t_op_state,'业务状态'); end; procedure Tfra_op_state.Panel1Resize(Sender: TObject); var i:integer; begin i:=round(Panel1.Width/8); bsSkinButton1.Width:=i; bsSkinButton2.Width:=i; bsSkinButton4.Width:=i; bsSkinButton11.Width:=i; bsSkinButton5.Width:=i; bsSkinButton7.Width:=i; bsSkinButton6.Width:=i; end; procedure Tfra_op_state.t_op_stateBeforeDelete(DataSet: TDataSet); begin if t_op_state.FieldByName('是否完成').asboolean then begin showmessage('业务状态已经完成,不能删除!!'); abort; end; end; procedure Tfra_op_state.t_op_stateBeforeInsert(DataSet: TDataSet); begin if t_op_state.DataSource.DataSet.State=dsinsert then t_op_state.DataSource.DataSet.post; if (if_open('776')) then begin showmessage('此票业务不能修改!'); abort; end; if not modify_all then begin abort; end; end; procedure Tfra_op_state.FrameEnter(Sender: TObject); begin case strtoint(edit_state.text) of 1: begin frm_data_share.t_code_state.Filtered:=false; frm_data_share.t_code_state.Filter:='业务种类='+''''+'海运出口'+''''; frm_data_share.t_code_state.Filtered:=true; end; 2: begin frm_data_share.t_code_state.Filtered:=false; frm_data_share.t_code_state.Filter:='业务种类='+''''+'海运进口'+''''; frm_data_share.t_code_state.Filtered:=true; end; 3: begin frm_data_share.t_code_state.Filtered:=false; frm_data_share.t_code_state.Filter:='业务种类='+''''+'空运出口'+''''; frm_data_share.t_code_state.Filtered:=true; end; 4: begin frm_data_share.t_code_state.Filtered:=false; frm_data_share.t_code_state.Filter:='业务种类='+''''+'空运进口'+''''; frm_data_share.t_code_state.Filtered:=true; end; end; PopupMenu1.Items.Clear; add_state_menu(PopupMenu1); end; procedure Tfra_op_state.bsSkinButton11Click(Sender: TObject); var str:string; begin str:=t_op_state.fieldbyname('业务状态').asstring; if t_op_state.IsEmpty then exit; table_post(t_op_state); try modify_all:=true; if not (t_op_state.DataSource.DataSet['业务状态']='批准删除') then begin t_op_state.DataSource.DataSet.edit; t_op_state.DataSource.DataSet['业务状态']:=str; t_op_state.DataSource.DataSet.Post; end; finally modify_all:=false; end; end; procedure Tfra_op_state.bsSkinButton7Click(Sender: TObject); begin if t_op_state.isempty then exit; if not t_op_state.FieldByName('是否完成').asboolean then begin t_op_state.edit; t_op_state['是否完成']:=1; t_op_state['完成时间']:=date; t_op_state['完成人']:=employee; t_op_state.post; end; end; procedure Tfra_op_state.bsSkinButton6Click(Sender: TObject); begin if t_op_state.isempty then exit; if t_op_state.FieldByName('是否完成').asboolean then begin t_op_state.edit; t_op_state['是否完成']:=0; t_op_state['完成时间']:=null; t_op_state['完成人']:=null; t_op_state.post; end; end; procedure Tfra_op_state.dxDBGrid1Column1CustomDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont; var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean); begin case strtoint(edit_state.text) of 1: begin AColor:=dxgrid_color('海运出口',ANode.Strings[dxDBGrid1Column1.Index]); end; 2: begin AColor:=dxgrid_color('海运进口',ANode.Strings[dxDBGrid1Column1.Index]); end; 3: begin AColor:=dxgrid_color('空运出口',ANode.Strings[dxDBGrid1Column1.Index]); end; 4: begin AColor:=dxgrid_color('空运进口',ANode.Strings[dxDBGrid1Column1.Index]); end; end; AFont.Color:=clblack; end; procedure Tfra_op_state.bsSkinButton5Click(Sender: TObject); begin if t_op_state.DataSource.DataSet=nil then exit; if t_op_state.DataSource.DataSet.state=dsinsert then t_op_state.DataSource.DataSet.post; try frm_op_state_add:=tfrm_op_state_add.Create (self); case strtoint(edit_state.text) of 1: begin frm_data_share.t_code_state_project.Filtered:=false; frm_data_share.t_code_state_project.requery; frm_data_share.t_code_state_project.Filter:='业务种类='+''''+'海运出口'+''''; frm_data_share.t_code_state_project.Filtered:=true; end; 2: begin frm_data_share.t_code_state_project.Filtered:=false; frm_data_share.t_code_state_project.requery; frm_data_share.t_code_state_project.Filter:='业务种类='+''''+'海运进口'+''''; frm_data_share.t_code_state_project.Filtered:=true; end; 3: begin frm_data_share.t_code_state_project.Filtered:=false; frm_data_share.t_code_state_project.requery; frm_data_share.t_code_state_project.Filter:='业务种类='+''''+'空运出口'+''''; frm_data_share.t_code_state_project.Filtered:=true; end; 4: begin frm_data_share.t_code_state_project.Filtered:=false; frm_data_share.t_code_state_project.requery; frm_data_share.t_code_state_project.Filter:='业务种类='+''''+'空运进口'+''''; frm_data_share.t_code_state_project.Filtered:=true; end; end; frm_op_state_add.DataSource1.DataSet:=t_op_state; frm_op_state_add.ShowModal; finally frm_op_state_add.Free; frm_op_state_add:=nil; end; end; procedure Tfra_op_state.bsSkinButton4Click(Sender: TObject); begin if t_op_state.isempty then exit; if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)<>IDOK then exit; if dxDBGrid1.SelectedCount>=1 then begin while dxDBGrid1.SelectedCount>0 do begin t_op_state.GotoBookmark(pointer(dxDBGrid1.selectedrows[0])); t_op_state.Delete; end; end else begin t_op_state.Delete; end; end; procedure Tfra_op_state.t_op_stateBeforeEdit(DataSet: TDataSet); begin if (if_open('776')) then begin showmessage('此票业务不能修改!'); abort; end; end; end.