unit u_piliang_seae_state; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, BusinessSkinForm, dxExEdtr, dxDBTLCl, dxGrClms, dxDBGrid, dxTL, dxDBCtrl, dxCntner, DB, ADODB, Grids, DBGrids, kbmMemTable, ExtCtrls, XPMenu, Menus; type Tfrm_piliang_seae_state = class(TForm) bsSkinPanel1: TbsSkinPanel; bsBusinessSkinForm1: TbsBusinessSkinForm; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridMaskColumn; dxDBGrid1Column5: TdxDBGridMaskColumn; dxDBGrid1Column6: TdxDBGridMaskColumn; dxDBGrid1Column7: TdxDBGridMaskColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column14: TdxDBGridMaskColumn; dxDBGrid1Column15: TdxDBGridMaskColumn; dxDBGrid1Column16: TdxDBGridDateColumn; dxDBGrid1Column19: TdxDBGridMaskColumn; dxDBGrid1Column20: TdxDBGridMaskColumn; dxDBGrid1TEU: TdxDBGridMaskColumn; dxDBGrid1Column63: TdxDBGridMaskColumn; dxDBGrid1Column64: TdxDBGridMaskColumn; dxDBGrid1Column65: TdxDBGridDateColumn; dxDBGrid1Column66: TdxDBGridMaskColumn; dxDBGrid1Column67: TdxDBGridMaskColumn; t_op_seae: TADOStoredProc; t_op_state: TkbmMemTable; Panel1: TPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsSkinButton9: TbsSkinButton; dxDBGrid2: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridCheckColumn; dxDBGrid1Column3: TdxDBGridDateColumn; dxDBGridMaskColumn2: TdxDBGridMaskColumn; dxDBGridMaskColumn3: TdxDBGridMaskColumn; dxDBGridMaskColumn4: TdxDBGridMaskColumn; dxDBGridDateColumn1: TdxDBGridDateColumn; dxDBGrid1Column8: TdxDBGridColumn; PopupMenu1: TPopupMenu; N1: TMenuItem; XPMenu1: TXPMenu; bsSkinButton5: TbsSkinButton; bsSkinSplitter1: TbsSkinSplitter; t_op_state1: TDataSource; t_op_seae1: TDataSource; t_op_stateField2: TStringField; t_op_stateField3: TBooleanField; t_op_stateField4: TDateTimeField; t_op_stateField5: TStringField; t_op_stateField6: TStringField; t_op_stateField7: TStringField; t_op_stateField8: TDateTimeField; t_op_stateField9: TIntegerField; bsSkinButton6: TbsSkinButton; t_op_state2: TADOQuery; bsSkinButton8: TbsSkinButton; procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure t_op_stateAfterInsert(DataSet: TDataSet); procedure t_op_stateBeforeDelete(DataSet: TDataSet); procedure bsSkinButton11Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure t_op_state2AfterInsert(DataSet: TDataSet); procedure bsSkinButton8Click(Sender: TObject); private procedure add_state_menu(n1:TPopupMenu); procedure add_state(Sender:TObject); procedure add_all(Sender:TObject); { Private declarations } public { Public declarations } end; var frm_piliang_seae_state: Tfrm_piliang_seae_state; implementation uses u_main, my_sys_function, u_data_share, u_op_state_add, u_piliang_send_msg; {$R *.dfm} procedure Tfrm_piliang_seae_state.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_piliang_seae_state.bsSkinButton1Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton1.ClientToScreen(Point(0,bsSkinButton1.Height)); PopupMenu1.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_piliang_seae_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 Tfrm_piliang_seae_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 Tfrm_piliang_seae_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 Tfrm_piliang_seae_state.bsSkinButton6Click(Sender: TObject); begin try frm_op_state_add:=tfrm_op_state_add.Create (self); 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; 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 Tfrm_piliang_seae_state.t_op_stateAfterInsert(DataSet: TDataSet); begin t_op_state['录入人']:=employee; t_op_state['录入日期']:=date; end; procedure Tfrm_piliang_seae_state.t_op_stateBeforeDelete( DataSet: TDataSet); begin if t_op_state.FieldByName('是否完成').asboolean then begin showmessage('业务状态已经完成,不能删除!!'); abort; end; end; procedure Tfrm_piliang_seae_state.bsSkinButton11Click(Sender: TObject); var str:string; begin str:=t_op_state.fieldbyname('业务状态').asstring; if t_op_state.IsEmpty then exit; t_op_seae.First; while not t_op_seae.Eof do begin try modify_all:=true; t_op_seae.edit; t_op_seae['业务状态']:=str; t_op_seae['封帐前状态']:=str; t_op_seae.Post; finally modify_all:=false; end; t_op_seae.Next; end; end; procedure Tfrm_piliang_seae_state.FormShow(Sender: TObject); begin frm_data_share.t_code_state.Filtered:=false; frm_data_share.t_code_state.Filter:='业务种类='+''''+'海运出口'+''''; frm_data_share.t_code_state.Filtered:=true; PopupMenu1.Items.Clear; add_state_menu(PopupMenu1); if (yctx<>'启用') then bsSkinButton8.Visible:=false; end; procedure Tfrm_piliang_seae_state.bsSkinButton9Click(Sender: TObject); var book1:Tbookmark; 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; book1:=t_op_state.GetBookmark; t_op_seae.First; while not t_op_seae.Eof do begin t_op_state2.Open; t_op_state.First; while not t_op_state.Eof do begin if t_op_state2.Locate('业务状态',t_op_state['业务状态'],[]) then begin t_op_state2.Edit; t_op_state2['是否完成']:=t_op_state['是否完成']; t_op_state2['完成人']:=t_op_state['完成人']; t_op_state2['完成时间']:=t_op_state['完成时间']; t_op_state2['备注']:=t_op_state['备注']; t_op_state2['录入人']:=t_op_state['录入人']; t_op_state2['录入日期']:=t_op_state['录入日期']; t_op_state2.Post; end else begin t_op_state2.insert; t_op_state2['业务状态']:=t_op_state['业务状态']; t_op_state2['是否完成']:=t_op_state['是否完成']; t_op_state2['完成时间']:=t_op_state['完成时间']; t_op_state2['完成人']:=t_op_state['完成人']; t_op_state2['备注']:=t_op_state['备注']; t_op_state2['录入人']:=t_op_state['录入人']; t_op_state2['录入日期']:=t_op_state['录入日期']; t_op_state2.Post; end; t_op_state.Next; end; t_op_state2.close; t_op_seae.next; end; t_op_state.GotoBookmark(book1); showmessage('更新完毕!'); end; procedure Tfrm_piliang_seae_state.bsSkinButton7Click(Sender: TObject); var book1:Tbookmark; 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; book1:=t_op_state.GetBookmark; t_op_seae.First; while not t_op_seae.Eof do begin t_op_state2.Open; t_op_state.First; while not t_op_state.Eof do begin if t_op_state2.Locate('业务状态',t_op_state['业务状态'],[]) then begin t_op_state2.Edit; t_op_state2['是否完成']:=t_op_state['是否完成']; t_op_state2['完成人']:=t_op_state['完成人']; t_op_state2['完成时间']:=t_op_state['完成时间']; t_op_state2['备注']:=t_op_state['备注']; t_op_state2['录入人']:=t_op_state['录入人']; t_op_state2['录入日期']:=t_op_state['录入日期']; t_op_state2.Post; end else begin t_op_state2.insert; t_op_state2['业务状态']:=t_op_state['业务状态']; t_op_state2['是否完成']:=t_op_state['是否完成']; t_op_state2['完成时间']:=t_op_state['完成时间']; t_op_state2['完成人']:=t_op_state['完成人']; t_op_state2['备注']:=t_op_state['备注']; t_op_state2['录入人']:=t_op_state['录入人']; t_op_state2['录入日期']:=t_op_state['录入日期']; t_op_state2.Post; end; t_op_state.Next; end; t_op_state2.close; t_op_seae.next; end; t_op_state.GotoBookmark(book1); end; procedure Tfrm_piliang_seae_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_seae.First; while not t_op_seae.Eof do begin t_op_state2.Open; if t_op_state2.Locate('业务状态',t_op_state['业务状态'],[]) then begin t_op_state2.Delete; end; t_op_state2.close; t_op_seae.next; end; t_op_state.Delete; end; end else begin t_op_seae.First; while not t_op_seae.Eof do begin t_op_state2.Open; if t_op_state2.Locate('业务状态',t_op_state['业务状态'],[]) then begin t_op_state2.Delete; end; t_op_state2.close; t_op_seae.next; end; t_op_state.Delete; end; end; procedure Tfrm_piliang_seae_state.bsSkinButton2Click(Sender: TObject); begin t_op_seae.First; while not t_op_seae.Eof do begin t_op_state2.Open; t_op_state.First; while not t_op_state.Eof do begin if t_op_state2.Locate('业务状态',t_op_state['业务状态'],[]) then begin t_op_state2.Edit; t_op_state2['是否完成']:=t_op_state['是否完成']; t_op_state2['完成人']:=t_op_state['完成人']; t_op_state2['完成时间']:=t_op_state['完成时间']; t_op_state2['备注']:=t_op_state['备注']; t_op_state2['录入人']:=t_op_state['录入人']; t_op_state2['录入日期']:=t_op_state['录入日期']; t_op_state2.Post; end else begin t_op_state2.insert; t_op_state2['业务状态']:=t_op_state['业务状态']; t_op_state2['是否完成']:=t_op_state['是否完成']; t_op_state2['完成时间']:=t_op_state['完成时间']; t_op_state2['完成人']:=t_op_state['完成人']; t_op_state2['备注']:=t_op_state['备注']; t_op_state2['录入人']:=t_op_state['录入人']; t_op_state2['录入日期']:=t_op_state['录入日期']; t_op_state2.Post; end; t_op_state.Next; end; t_op_state2.close; t_op_seae.next; end; showmessage('更新完毕!'); end; procedure Tfrm_piliang_seae_state.t_op_state2AfterInsert( DataSet: TDataSet); begin t_op_state2['编号']:=t_op_seae['编号']; end; procedure Tfrm_piliang_seae_state.bsSkinButton8Click(Sender: TObject); begin if (yctx<>'启用') or (trim(get_parameters_value(134,'无'))='无') then begin end else frm_piliang_send_msg:=Tfrm_piliang_send_msg.Create(self); piliangsend:=false; frm_piliang_send_msg.transtype:=1; frm_piliang_send_msg.t_msg_mold.Close; frm_piliang_send_msg.t_msg_mold.sql.text:='select * from t_sys_msgmold where 消息类型=''海运出口'' '; frm_piliang_send_msg.t_msg_mold.open; t_op_seae.First; while not t_op_seae.Eof do begin if (yctx<>'启用') or (trim(get_parameters_value(134,'无'))='无') then begin end else begin frm_data_share.t_crm_client_all.Locate('客户简称',t_op_seae['委托单位'],[]); frm_piliang_send_msg.t_crm_client_link.Open; frm_piliang_send_msg.memmsg.open; frm_piliang_send_msg.memmsg.insert; frm_piliang_send_msg.memmsg.FieldByName('收件单位').AsString:=t_op_seae.fieldbyname('委托单位').AsString; frm_piliang_send_msg.memmsg.FieldByName('业务编号').AsString:=t_op_seae.fieldbyname('业务编号').AsString; frm_piliang_send_msg.memmsg.FieldByName('委托编号').AsString:=t_op_seae.fieldbyname('委托编号').AsString; frm_piliang_send_msg.memmsg.FieldByName('主提单号').AsString:=t_op_seae.fieldbyname('主提单号').AsString; frm_piliang_send_msg.memmsg.FieldByName('分提单号').AsString:=t_op_seae.fieldbyname('分提单号').AsString; frm_piliang_send_msg.memmsg.FieldByName('发送方式').AsString:=trim(get_parameters_value(134,'无')); if not frm_piliang_send_msg.t_crm_client_link.IsEmpty then begin frm_piliang_send_msg.t_crm_client_link.first; frm_piliang_send_msg.t_crm_client_link.Locate('默认联系人',true,[]); frm_piliang_send_msg.memmsg.FieldByName('收件人').AsString:=frm_piliang_send_msg.t_crm_client_link.fieldbyname('姓名').AsString; if (trim(get_parameters_value(134,'无'))='默认') and (frm_piliang_send_msg.t_crm_client_link.fieldbyname('默认提醒方式').AsString<>'') then begin if trim(frm_piliang_send_msg.t_crm_client_link.fieldbyname('默认提醒方式').AsString)='MSN' then frm_piliang_send_msg.memmsg.FieldByName('发送号码').AsString:=frm_piliang_send_msg.t_crm_client_link.fieldbyname('MSN').AsString; if trim(frm_piliang_send_msg.t_crm_client_link.fieldbyname('默认提醒方式').AsString)='邮件' then frm_piliang_send_msg.memmsg.FieldByName('发送号码').AsString:=frm_piliang_send_msg.t_crm_client_link.fieldbyname('邮箱').AsString; if trim(frm_piliang_send_msg.t_crm_client_link.fieldbyname('默认提醒方式').AsString)='短信' then frm_piliang_send_msg.memmsg.FieldByName('发送号码').AsString:=frm_piliang_send_msg.t_crm_client_link.fieldbyname('手机').AsString; end else begin if trim(get_parameters_value(134,'无'))='MSN' then frm_piliang_send_msg.memmsg.FieldByName('发送号码').AsString:=frm_piliang_send_msg.t_crm_client_link.fieldbyname('MSN').AsString; if trim(get_parameters_value(134,'无'))='邮件' then frm_piliang_send_msg.memmsg.FieldByName('发送号码').AsString:=frm_piliang_send_msg.t_crm_client_link.fieldbyname('邮箱').AsString; if trim(get_parameters_value(134,'无'))='短信' then frm_piliang_send_msg.memmsg.FieldByName('发送号码').AsString:=frm_piliang_send_msg.t_crm_client_link.fieldbyname('手机').AsString; end; end; frm_piliang_send_msg.memmsg.FieldByName('内容').AsString:=getstrfromdataset(t_op_seae,frm_piliang_send_msg.t_msg_mold.fieldbyname('模板内容').asstring); { frm_piliang_send_msg.memmsg.FieldByName('内容').AsString:=frm_data_share.t_sys_company.fieldbyname('全称').AsString+'提示:贵司委托我司' +'主提单号:'+t_op_seae.fieldbyname('主提单号').AsString+',' +'分提单号:'+t_op_seae.fieldbyname('分提单号').AsString+'开船日期:'+t_op_seae.Fieldbyname('开船日期').AsString+#10#13+ '业务状态已更改为'+str; } frm_piliang_send_msg.memmsg.post; end; t_op_seae.Next; end; if (yctx<>'启用') or (trim(get_parameters_value(134,'无'))='无') then begin end else begin frm_piliang_send_msg.ShowModal; FreeAndNil(frm_piliang_send_msg); end; end; end.