unit u_op_cnt_maintain; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, ExtCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, ADODB, dxDBTLCl, dxGrClms, StdCtrls, Mask, DBCtrls, wwdbdatetimepicker, ComCtrls, bsSkinTabs, RxLookup, Menus, XPMenu, wwdbedit, Wwdotdot, Wwdbcomb, cxTextEdit, cxDBEdit, cxControls, cxContainer, cxEdit, cxLabel, cxMaskEdit, cxDropDownEdit, cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox, wwdblook, DBCtrlsEh,DateUtils, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxDBData, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses, cxGridCustomView, cxGrid, cxCalendar, cxMemo, cxCurrencyEdit, cxNavigator, cxTimeEdit, Grids, Wwdbigrd, Wwdbgrid, cxGridBandedTableView, cxGridDBBandedTableView, dxDBTL; type Tfrm_op_cnt_maintain = class(TForm) Panel2: TPanel; bsSkinButton7: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton1: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; Notebook1: TNotebook; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; bsSkinButton19: TbsSkinButton; XPMenu1: TXPMenu; PopupMenu3: TPopupMenu; N2: TMenuItem; N3: TMenuItem; N4: TMenuItem; t_op_ctn_tainmain: TADOQuery; t_op_ctn_tainmain1: TDataSource; Panel1: TPanel; bsSkinPanel1: TbsSkinPanel; Label1: TLabel; Label36: TLabel; DBEdit1: TDBEdit; DBEdit7: TDBEdit; Label18: TLabel; PopupMenu2: TPopupMenu; N10: TMenuItem; N11: TMenuItem; N14: TMenuItem; N13: TMenuItem; N12: TMenuItem; N15: TMenuItem; N16: TMenuItem; dxDBGrid1Column2: TdxDBGridColumn; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; bsSkinTabSheet3: TbsSkinTabSheet; t_op_ctn_tainmain_Item: TADOQuery; t_op_ctn_tainmain_Item1: TDataSource; t_op_ctn_tainmain_inspect1: TDataSource; t_op_ctn_tainmain_inspect: TADOQuery; t_op_ctn_tainmain_clear1: TDataSource; t_op_ctn_tainmain_clear: TADOQuery; bsSkinPanel9: TbsSkinPanel; Label116: TLabel; Edit1: TEdit; bsSkinButton44: TbsSkinButton; Label210: TLabel; wwDBDateTimePicker18: TwwDBDateTimePicker; wwDBDateTimePicker19: TwwDBDateTimePicker; wwDBGrid1: TwwDBGrid; wwDBGrid2: TwwDBGrid; wwDBGrid3: TwwDBGrid; wwDBLookupCombo3: TwwDBLookupCombo; wwDBLookupCombo1: TwwDBLookupCombo; wwDBLookupCombo2: TwwDBLookupCombo; wwDBGrid4: TwwDBGrid; cxGrid1: TcxGrid; cxGrid1DBTableView1: TcxGridDBTableView; cxGrid1DBTableView3: TcxGridDBTableView; cxGrid1Level1: TcxGridLevel; cxGrid1Level2: TcxGridLevel; cxGrid1DBTableView1DBColumn2: TcxGridDBColumn; cxGrid1DBTableView3DBColumn1: TcxGridDBColumn; cxGrid1DBTableView3DBColumn2: TcxGridDBColumn; cxGrid1DBTableView3DBColumn3: TcxGridDBColumn; cxGrid1DBTableView1DBColumn3: TcxGridDBColumn; cxGrid1DBTableView3DBColumn4: TcxGridDBColumn; cxGrid1DBTableView1DBColumn4: TcxGridDBColumn; cxGrid1DBTableView1DBColumn5: TcxGridDBColumn; cxGrid1DBTableView1DBColumn8: TcxGridDBColumn; cxGrid1DBTableView1DBColumn9: TcxGridDBColumn; cxGrid1DBTableView1DBColumn10: TcxGridDBColumn; cxGrid1DBTableView1DBColumn1: TcxGridDBColumn; procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); procedure Panel2Resize(Sender: TObject); procedure dxDBGrid1Column2CustomDraw(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 N2Click(Sender: TObject); procedure N4Click(Sender: TObject); procedure t_op_ctn_tainmainBeforePost(DataSet: TDataSet); procedure bsSkinButton2Click(Sender: TObject); procedure t_op_ctn_tainmainAfterInsert(DataSet: TDataSet); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure t_op_ctn_tainmain_ItemAfterInsert(DataSet: TDataSet); procedure t_op_ctn_tainmain_inspectAfterInsert(DataSet: TDataSet); procedure t_op_ctn_tainmain_clearAfterInsert(DataSet: TDataSet); procedure bsSkinButton44Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_op_cnt_maintain: Tfrm_op_cnt_maintain; implementation uses u_main, u_data_share, my_sys_function, u_code_send_address, u_op_kuaidi_query, my_sys_chat; {$R *.dfm} procedure Tfrm_op_cnt_maintain.bsSkinButton1Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton1.ClientToScreen(Point(0,bsSkinButton1.Height)); PopupMenu3.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_cnt_maintain.bsSkinButton11Click(Sender: TObject); var answer:TModalResult; begin if bsSkinButton11.Caption='编辑修改' then begin if t_op_ctn_tainmain.IsEmpty then exit; Notebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; end else begin if (t_op_ctn_tainmain.State=dsinsert)or(t_op_ctn_tainmain.State=dsedit) then BEGIN answer:=messagedlg( '数据已经修改,是否保存?',mtWarning,mbYesNoCancel,0); if answer=mrYes then begin t_op_ctn_tainmain.post; end; if answer=mrNo then begin t_op_ctn_tainmain.cancel; end; if answer=mrCancel then begin exit; end; END; Notebook1.PageIndex:=0; bsSkinButton11.Caption:='编辑修改'; end; end; procedure Tfrm_op_cnt_maintain.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_op_cnt_maintain.FormClose(Sender: TObject; var Action: TCloseAction); begin savereggrid(dxdbgrid1,caption); frm_op_cnt_maintain.Hide; frm_op_cnt_maintain.ManualFloat(frm_op_cnt_maintain.BoundsRect); frm_main.freeTabs('frm_op_cnt_maintain'); action:=cafree; frm_op_cnt_maintain:=nil; end; procedure Tfrm_op_cnt_maintain.FormShow(Sender: TObject); begin Notebook1.PageIndex:=0; t_op_ctn_tainmain.Close; t_op_ctn_tainmain.open; t_op_ctn_tainmain_Item.Close; t_op_ctn_tainmain_Item.Open; t_op_ctn_tainmain_inspect.Close; t_op_ctn_tainmain_inspect.Open; t_op_ctn_tainmain_clear.Close; t_op_ctn_tainmain_clear.Open; loadreggrid(dxdbgrid1,false,caption); end; procedure Tfrm_op_cnt_maintain.Panel2Resize(Sender: TObject); var i:integer; begin i:=round(Panel2.Width/10); bsSkinButton7.Width:=i; bsSkinButton6.Width:=i; bsSkinButton9.Width:=i; bsSkinButton1.Width:=i; bsSkinButton11.Width:=i; bsSkinButton2.Width:=i; bsSkinButton4.Width:=i; bsSkinButton3.Width:=i; bsSkinButton19.Width:=i; end; procedure Tfrm_op_cnt_maintain.dxDBGrid1Column2CustomDraw(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 if (ANode.strings[dxDBGrid1Column2.Index]='申请发送') then AColor :=clwhite else if (ANode.strings[dxDBGrid1Column2.Index]='提交申请') then AColor :=clyellow else if (ANode.strings[dxDBGrid1Column2.Index]='驳回申请')then AColor :=clred else if (ANode.strings[dxDBGrid1Column2.Index]='确认发出') then AColor :=$00DDF21C; AFont.Color:=clblack; end; procedure Tfrm_op_cnt_maintain.N2Click(Sender: TObject); begin Notebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; t_op_ctn_tainmain.insert; end; procedure Tfrm_op_cnt_maintain.N4Click(Sender: TObject); var afield : variant; i: Integer; begin Notebook1.PageIndex:=1; bsSkinButton11.Caption:='返回列表'; if t_op_ctn_tainmain.IsEmpty then begin showmessage('没有复制母体,不能复制新建!'); exit; end; afield := vararraycreate([0,t_op_ctn_tainmain.fieldcount-1],varvariant); for i := 0 to (t_op_ctn_tainmain.fieldcount-1) do begin afield[i] :=t_op_ctn_tainmain.fields[i].value ; end; t_op_ctn_tainmain.append; for i := 0 to (t_op_ctn_tainmain.fieldcount-1) do begin if (t_op_ctn_tainmain.fields[i].FieldName<>'编号') and (t_op_ctn_tainmain.fields[i].FieldName<>'业务编号') then t_op_ctn_tainmain.fields[i].value := afield[i] ; end; end; procedure Tfrm_op_cnt_maintain.t_op_ctn_tainmainBeforePost(DataSet: TDataSet); begin if t_op_ctn_tainmain.State=dsinsert then begin if t_op_ctn_tainmain.fieldbyname('业务编号').asstring=''then begin t_op_ctn_tainmain['业务编号']:=get_no(t_op_ctn_tainmain.fieldbyname('会计期间').AsDateTime,'WH'); t_op_ctn_tainmain['编号']:=get_id; end; t_op_ctn_tainmain['主编号']:=t_op_ctn_tainmain['编号']; t_op_ctn_tainmain['业务状态']:='接受委托'; t_op_ctn_tainmain['费用状态']:='录入状态'; end; end; procedure Tfrm_op_cnt_maintain.bsSkinButton2Click(Sender: TObject); begin table_post(t_op_ctn_tainmain); end; procedure Tfrm_op_cnt_maintain.t_op_ctn_tainmainAfterInsert(DataSet: TDataSet); begin t_op_ctn_tainmain['会计期间']:=date; t_op_ctn_tainmain['录入人']:=employee; t_op_ctn_tainmain['录入日期']:=date; t_op_ctn_tainmain['分部名称']:=subComp; t_op_ctn_tainmain['操作员']:=employee; end; procedure Tfrm_op_cnt_maintain.bsSkinButton8Click(Sender: TObject); begin frm_main.view_momo(t_op_ctn_tainmain1,'进口货物名称'); end; procedure Tfrm_op_cnt_maintain.bsSkinButton4Click(Sender: TObject); begin if t_op_ctn_tainmain.IsEmpty then exit; // if t_op_ctn_tainmain.fieldbyname('申请状态').asstring='确认发出' then // exit; if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)<>IDOK then exit; t_op_ctn_tainmain.delete; end; procedure Tfrm_op_cnt_maintain.N10Click(Sender: TObject); begin update_grid_view_no(dxdbgrid1); end; procedure Tfrm_op_cnt_maintain.N14Click(Sender: TObject); begin update_grid_view_all(dxdbgrid1); end; procedure Tfrm_op_cnt_maintain.N12Click(Sender: TObject); begin update_grid(dxdbgrid1,212); end; procedure Tfrm_op_cnt_maintain.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_op_cnt_maintain.bsSkinButton3Click(Sender: TObject); begin if t_op_ctn_tainmain=nil then exit; if (t_op_ctn_tainmain.State=dsinsert)or(t_op_ctn_tainmain.State=dsedit) then t_op_ctn_tainmain.cancel; end; procedure Tfrm_op_cnt_maintain.t_op_ctn_tainmain_ItemAfterInsert( DataSet: TDataSet); begin t_op_ctn_tainmain_Item['编号']:=t_op_ctn_tainmain['编号']; end; procedure Tfrm_op_cnt_maintain.t_op_ctn_tainmain_inspectAfterInsert( DataSet: TDataSet); begin t_op_ctn_tainmain_inspect['编号']:=t_op_ctn_tainmain['编号']; end; procedure Tfrm_op_cnt_maintain.t_op_ctn_tainmain_clearAfterInsert( DataSet: TDataSet); begin t_op_ctn_tainmain_clear['编号']:=t_op_ctn_tainmain['编号']; end; procedure Tfrm_op_cnt_maintain.bsSkinButton44Click(Sender: TObject); var str:widestring; begin str:=''; str:=query_tiaojian(1,str,'t_op_ctn_tainmain.箱号','模糊',Edit1.text); str:=query_tiaojian(1,str,'t_op_ctn_tainmain.会计期间','大于',wwDBDateTimePicker18.text); str:=query_tiaojian(1,str,'t_op_ctn_tainmain.会计期间','小于',wwDBDateTimePicker19.text); str:='select * from t_op_ctn_tainmain where 编号 in (select 主编号 from t_op_ctn_tainmain ' +str+')'; t_op_ctn_tainmain.close; t_op_ctn_tainmain.sql.clear; t_op_ctn_tainmain.sql.add(str); t_op_ctn_tainmain.Open; if t_op_ctn_tainmain.IsEmpty then begin showmessage('没有检索出所需数据!!'); exit; end; end; end.