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; XPMenu1: TXPMenu; bsSkinButton8: TbsSkinButton; dxDBGrid1Column9: TdxDBGridColumn; dxDBGrid1Column10: 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 bsSkinButton8Click(Sender: TObject); private { Private declarations } public { Public declarations } end; implementation uses u_main, u_data_share, my_sys_function, u_op_state_add, u_send_msg; {$R *.dfm} procedure Tfra_op_state.add_state(Sender:TObject); var menu_skins:Tmenuitem; strstate:string;//业务状体 begin //根据菜单添加状态 menu_skins:= Sender as Tmenuitem; try modify_all:=true; t_op_state.Append; strstate :=menu_skins.caption; t_op_state['业务状态']:=strstate; try t_op_state['顺序']:=strtoint(menu_skins.Hint); except t_op_state['顺序']:=0; end; t_op_state.post; if(strstate='提单签回') then try frm_main.db.Execute(Format('update t_op_seae set 业务状态=''提单签回'' where 编号=''%s''' ,[t_op_state.DataSource.DataSet['编号']])); except ShowMessage('提单签回状态更新失败'); end; 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 t_op_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/9); bsSkinButton1.Width:=i; bsSkinButton2.Width:=i; bsSkinButton4.Width:=i; bsSkinButton11.Width:=i; bsSkinButton5.Width:=i; bsSkinButton7.Width:=i; bsSkinButton6.Width:=i; bsSkinButton8.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 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; 5: 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; 6: 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); if (yctx<>'启用') then bsSkinButton8.Visible:=false; end; procedure Tfra_op_state.bsSkinButton11Click(Sender: TObject); var str:string; i:integer; begin //状态更新的业务信息中,并提醒 str:=t_op_state.fieldbyname('业务状态').asstring; if t_op_state.IsEmpty then exit; table_post(t_op_state); try frm_main.db.BeginTrans; modify_all:=true; t_op_state.DataSource.DataSet.edit; t_op_state.DataSource.DataSet['封帐前状态']:=str; t_op_state.DataSource.DataSet['业务状态']:=str; t_op_state.DataSource.DataSet.Post; if strtobool(get_parameters_value(154,'false')) then begin frm_main.qryweb.close; frm_main.qryweb.sql.clear; frm_main.qryweb.sql.add('select * from t_op_seae where 编号=:编号'); frm_main.qryweb.Parameters.ParamByName('编号').Value:=t_op_state.DataSource.DataSet.fieldbyname('编号').AsString; frm_main.qryweb.open; if frm_main.qryweb.IsEmpty then exit; frm_main.qryweb.close; frm_main.qryweb.sql.clear; frm_main.qryweb.sql.add('select * from t_op_state where 编号=:编号'); frm_main.qryweb.Parameters.ParamByName('编号').Value:=t_op_state.DataSource.DataSet.fieldbyname('编号').AsString; frm_main.qryweb.open; t_op_state.First; while not t_op_state.Eof do begin if t_op_state.FieldByName('是否完成').AsBoolean then begin if frm_main.qryweb.Locate('OS',t_op_state.fieldbyname('OS').AsInteger,[]) then begin { frm_main.qryweb.Edit; for i:=0 to frm_main.qryweb.FieldCount-1 do begin if frm_main.qryweb.Fields[i].FieldName<>'OS' then frm_main.qryweb.Fields[i].Value:=t_op_state.fieldbyname(frm_main.qryweb.Fields[i].FieldName).Value; end; frm_main.qryweb.post; } end else begin frm_main.qryweb.Insert; t_op_state.edit; t_op_state['确认时间']:=date; t_op_state['确认人']:=employee; t_op_state.post; for i:=0 to frm_main.qryweb.FieldCount-1 do begin frm_main.qryweb.Fields[i].Value:=t_op_state.fieldbyname(frm_main.qryweb.Fields[i].FieldName).Value; end; frm_main.qryweb.post; end; end; t_op_state.Next; end; end; frm_main.db.CommitTrans; finally if frm_main.db.InTransaction then begin MessageDlg('上传费用时出错,请关闭当前业务重试!',mterror,[mbok],0); frm_main.db.RollbackTrans; end; 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; 5: begin AColor:=dxgrid_color('监管车',ANode.Strings[dxDBGrid1Column1.Index]); end; 6: 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; 5: 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; 6: 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.bsSkinButton8Click(Sender: TObject); begin //发送状态提醒 if (yctx<>'启用') then exit; if (trim(get_parameters_value(134,'无'))='无') then exit; frm_send_msg:=Tfrm_send_msg.Create(self); frm_send_msg.transtype:=strtoint(edit_state.text); case strtoint(edit_state.text) of 1: begin frm_send_msg.t_msg_mold.Close; frm_send_msg.t_msg_mold.sql.text:='select * from t_sys_msgmold where 消息类型=''海运出口'' '; frm_send_msg.t_msg_mold.open; end; 2: begin frm_send_msg.t_msg_mold.Close; frm_send_msg.t_msg_mold.sql.text:='select * from t_sys_msgmold where 消息类型=''海运进口'' '; frm_send_msg.t_msg_mold.open; end; 3: begin frm_send_msg.t_msg_mold.Close; frm_send_msg.t_msg_mold.sql.text:='select * from t_sys_msgmold where 消息类型=''空运出口'' '; frm_send_msg.t_msg_mold.open; end; 4: begin frm_send_msg.t_msg_mold.Close; frm_send_msg.t_msg_mold.sql.text:='select * from t_sys_msgmold where 消息类型=''空运进口'' '; frm_send_msg.t_msg_mold.open; end; end; try frm_data_share.t_crm_client_all.Locate('客户简称',t_op_state.DataSource.DataSet['委托单位'],[]); frm_send_msg.t_crm_client_link.Open; frm_send_msg.memmsg.open; frm_send_msg.memmsg.insert; frm_send_msg.memmsg.FieldByName('收件单位').AsString:=t_op_state.DataSource.DataSet['委托单位']; if not frm_send_msg.t_crm_client_link.IsEmpty then begin frm_send_msg.t_crm_client_link.Locate('默认联系人',true,[]); frm_send_msg.memmsg.FieldByName('收件人').AsString:=frm_send_msg.t_crm_client_link.fieldbyname('姓名').AsString; end; frm_send_msg.memmsg.FieldByName('内容').AsString:=getstrfromdataset(t_op_state.DataSource.DataSet,frm_send_msg.t_msg_mold.fieldbyname('模板内容').asstring); { frm_send_msg.memmsg.FieldByName('内容').AsString:=frm_data_share.t_sys_company.fieldbyname('全称').AsString+'提示:贵司委托我司' +'主提单号:'+t_op_state.DataSource.DataSet.fieldbyname('主提单号').AsString+',' +'分提单号:'+t_op_state.DataSource.DataSet.fieldbyname('分提单号').AsString+'开船日期:'+t_op_state.DataSource.DataSet.Fieldbyname('开船日期').AsString+#10#13+ '业务状态为'+str; } if (trim(get_parameters_value(134,'无'))='默认') and (frm_send_msg.t_crm_client_link.fieldbyname('默认提醒方式').AsString<>'') then begin if trim(frm_send_msg.t_crm_client_link.fieldbyname('默认提醒方式').AsString)='MSN' then frm_send_msg.checkboxMSN.Checked:=true; if trim(frm_send_msg.t_crm_client_link.fieldbyname('默认提醒方式').AsString)='邮件' then frm_send_msg.checkboxMAIL.Checked:=true; if trim(frm_send_msg.t_crm_client_link.fieldbyname('默认提醒方式').AsString)='短信' then frm_send_msg.checkboxMSG.Checked:=true; end else begin if trim(get_parameters_value(134,'无'))='MSN' then frm_send_msg.checkboxMSN.Checked:=true; if trim(get_parameters_value(134,'无'))='邮件' then frm_send_msg.checkboxMAIL.Checked:=true; if trim(get_parameters_value(134,'无'))='短信' then frm_send_msg.checkboxMSG.Checked:=true; end; frm_send_msg.ShowModal; finally FreeAndNil(frm_send_msg); end; end; end.