unit u_op_letter; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,DateUtils, Dialogs, DB, ADODB, bsSkinCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, StdCtrls, Mask, DBCtrls, Menus, wwdbdatetimepicker, Grids, DBGrids, XPMenu, RxLookup, bsdbctrls, ExtCtrls, DBCtrlsEh, bsSkinBoxCtrls; type Tfrm_op_letter = class(TForm) t_op_letter1: TDataSource; t_op_letter_cq: TADOQuery; t_op_letter_cq1: TDataSource; t_op_letter_cz: TADOQuery; t_op_letter_cz1: TDataSource; t_op_letter_df: TADOQuery; t_op_letter_df1: TDataSource; t_op_letter_dq: TADOQuery; t_op_letter_dq1: TDataSource; t_op_letter_gg: TADOQuery; t_op_letter_gg1: TDataSource; t_op_letter_hc: TADOQuery; t_op_letter_hc1: TDataSource; t_op_letter_pc: TADOQuery; t_op_letter_pc1: TDataSource; t_op_letter_rh: TADOQuery; t_op_letter_rh1: TDataSource; t_op_letter_yj1: TDataSource; t_op_letter_yj: TADOQuery; bsSkinPanel2: TbsSkinPanel; bsSkinPanel1: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1HEAD_TO: TdxDBGridMaskColumn; dxDBGrid1Column4: TdxDBGridColumn; dxDBGrid1Column5: TdxDBGridColumn; bsSkinButton9: TbsSkinButton; bsSkinPanel3: TbsSkinPanel; Label1: TLabel; DBEdit1: TDBEdit; Label2: TLabel; PopupMenu1: TPopupMenu; N3: TMenuItem; N4: TMenuItem; N5: TMenuItem; N6: TMenuItem; N7: TMenuItem; N8: TMenuItem; N9: TMenuItem; N10: TMenuItem; N11: TMenuItem; N12: TMenuItem; N13: TMenuItem; N14: TMenuItem; N15: TMenuItem; N16: TMenuItem; N17: TMenuItem; N18: TMenuItem; N19: TMenuItem; DBEdit3: TDBEdit; DataSource1: TDataSource; PopupMenu2: TPopupMenu; N1: TMenuItem; N2: TMenuItem; N20: TMenuItem; t_op_letter: TADOQuery; XPMenu1: TXPMenu; N21: TMenuItem; N22: TMenuItem; t_op_letter_hd: TADOQuery; t_op_letter_hd1: TDataSource; N23: TMenuItem; N24: TMenuItem; N25: TMenuItem; N26: TMenuItem; bsSkinNotebook1: TbsSkinNotebook; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; DBMemo1: TDBMemo; DBMemo2: TDBMemo; DBMemo3: TDBMemo; DBMemo4: TDBMemo; DBMemo5: TDBMemo; Label8: TLabel; Label9: TLabel; DBEdit4: TDBEdit; DBMemo6: TDBMemo; Label10: TLabel; Label11: TLabel; Label12: TLabel; Label13: TLabel; DBEdit5: TDBEdit; DBEdit6: TDBEdit; DBEdit7: TDBEdit; DBMemo7: TDBMemo; Label14: TLabel; Label15: TLabel; DBEdit8: TDBEdit; DBMemo8: TDBMemo; Label16: TLabel; Label17: TLabel; Label18: TLabel; DBMemo9: TDBMemo; DBMemo10: TDBMemo; DBMemo11: TDBMemo; Label19: TLabel; Label20: TLabel; Label21: TLabel; Label22: TLabel; Label23: TLabel; Label24: TLabel; Label25: TLabel; Label26: TLabel; Label27: TLabel; DBEdit9: TDBEdit; DBEdit10: TDBEdit; DBEdit12: TDBEdit; DBEdit13: TDBEdit; DBEdit15: TDBEdit; DBEdit16: TDBEdit; DBMemo12: TDBMemo; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; Label29: TLabel; Label30: TLabel; Label31: TLabel; Label32: TLabel; Label33: TLabel; Label28: TLabel; Label34: TLabel; Label35: TLabel; Label36: TLabel; Label37: TLabel; Label38: TLabel; Label39: TLabel; Label49: TLabel; Label50: TLabel; DBEdit14: TDBEdit; DBEdit17: TDBEdit; DBEdit18: TDBEdit; DBEdit19: TDBEdit; DBEdit20: TDBEdit; DBEdit11: TDBEdit; DBEdit21: TDBEdit; DBEdit22: TDBEdit; DBEdit23: TDBEdit; DBEdit24: TDBEdit; DBEdit25: TDBEdit; DBMemo13: TDBMemo; Button1: TButton; Button2: TButton; Button3: TButton; DBEdit31: TDBEdit; DBEdit32: TDBEdit; Label40: TLabel; Label41: TLabel; Label42: TLabel; Label43: TLabel; Label44: TLabel; Label51: TLabel; DBEdit26: TDBEdit; DBEdit27: TDBEdit; DBEdit29: TDBEdit; DBMemo14: TDBMemo; Button4: TButton; DBEdit33: TDBEdit; DBComboBox1: TDBComboBox; Label45: TLabel; Label46: TLabel; DBEdit30: TDBEdit; DBMemo15: TDBMemo; Label47: TLabel; Label48: TLabel; DBMemo16: TDBMemo; DBMemo17: TDBMemo; Label52: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; t_crm_client_cd: TADOQuery; t_crm_client_cd1: TDataSource; DBEdit28: TDBEdit; Label53: TLabel; DBEdit34: TDBEdit; Label54: TLabel; Label55: TLabel; DBEdit35: TDBEdit; Label56: TLabel; DBEdit36: TDBEdit; Label57: TLabel; DBMemo18: TDBMemo; Label58: TLabel; DBMemo19: TDBMemo; Label59: TLabel; DBEdit37: TDBEdit; DBMemo20: TDBMemo; Label60: TLabel; Label61: TLabel; DBMemo21: TDBMemo; Label62: TLabel; Label63: TLabel; Label64: TLabel; DBEdit38: TDBEdit; DBEdit39: TDBEdit; DBEdit40: TDBEdit; Label65: TLabel; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; DBEdit41: TDBEdit; Label66: TLabel; bsSkinDBCheckRadioBox2: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox3: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox4: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox5: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox6: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox7: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox8: TbsSkinDBCheckRadioBox; DBEdit42: TDBEdit; DBEdit43: TDBEdit; t_op_letter_bgmx: TADOQuery; t_op_letter_bgmx1: TDataSource; DBMemo22: TDBMemo; Label67: TLabel; N27: TMenuItem; N28: TMenuItem; DBEdit44: TDBEdit; Label68: TLabel; DBEdit45: TDBEdit; Label69: TLabel; Button5: TButton; DBComboBox2: TDBComboBox; N29: TMenuItem; N30: TMenuItem; bsSkinStdLabel1: TbsSkinStdLabel; bsSkinStdLabel2: TbsSkinStdLabel; bsSkinStdLabel3: TbsSkinStdLabel; bsSkinStdLabel4: TbsSkinStdLabel; bsSkinStdLabel5: TbsSkinStdLabel; bsSkinStdLabel6: TbsSkinStdLabel; bsSkinStdLabel7: TbsSkinStdLabel; bsSkinStdLabel8: TbsSkinStdLabel; bsSkinStdLabel9: TbsSkinStdLabel; bsSkinStdLabel10: TbsSkinStdLabel; bsSkinStdLabel11: TbsSkinStdLabel; bsSkinStdLabel12: TbsSkinStdLabel; bsSkinStdLabel13: TbsSkinStdLabel; bsSkinStdLabel14: TbsSkinStdLabel; bsSkinDBEdit1: TbsSkinDBEdit; bsSkinDBEdit2: TbsSkinDBEdit; bsSkinDBEdit3: TbsSkinDBEdit; bsSkinDBEdit4: TbsSkinDBEdit; bsSkinDBEdit5: TbsSkinDBEdit; bsSkinDBEdit6: TbsSkinDBEdit; bsSkinDBEdit7: TbsSkinDBEdit; bsSkinDBEdit8: TbsSkinDBEdit; bsSkinDBEdit9: TbsSkinDBEdit; bsSkinDBEdit10: TbsSkinDBEdit; bsSkinDBEdit11: TbsSkinDBEdit; bsSkinDBEdit12: TbsSkinDBEdit; bsSkinDBEdit13: TbsSkinDBEdit; bsSkinDBEdit14: TbsSkinDBEdit; bsSkinStdLabel15: TbsSkinStdLabel; bsSkinDBMemo1: TbsSkinDBMemo; t_op_railway_cnt: TADOQuery; t_op_railway_cnt1: TDataSource; Label70: TLabel; DBEdit2: TDBEdit; Label71: TLabel; DBEdit46: TDBEdit; Label72: TLabel; DBEdit47: TDBEdit; Label73: TLabel; DBEdit48: TDBEdit; Label74: TLabel; DBEdit49: TDBEdit; DataSource2: TDataSource; procedure bsSkinButton1Click(Sender: TObject); procedure DBEdit3Change(Sender: TObject); procedure t_op_letterAfterInsert(DataSet: TDataSet); procedure N3Click(Sender: TObject); procedure N7Click(Sender: TObject); procedure N5Click(Sender: TObject); procedure N9Click(Sender: TObject); procedure N11Click(Sender: TObject); procedure N13Click(Sender: TObject); procedure N19Click(Sender: TObject); procedure N17Click(Sender: TObject); procedure N15Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure t_op_letter_yjBeforeInsert(DataSet: TDataSet); procedure t_op_letter_cqAfterInsert(DataSet: TDataSet); procedure t_op_letter_czAfterInsert(DataSet: TDataSet); procedure t_op_letter_dfAfterInsert(DataSet: TDataSet); procedure t_op_letter_dqAfterInsert(DataSet: TDataSet); procedure t_op_letter_ggAfterInsert(DataSet: TDataSet); procedure t_op_letter_hcAfterInsert(DataSet: TDataSet); procedure t_op_letter_pcAfterInsert(DataSet: TDataSet); procedure t_op_letter_rhAfterInsert(DataSet: TDataSet); procedure t_op_letter_yjAfterInsert(DataSet: TDataSet); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); procedure t_op_letterBeforeInsert(DataSet: TDataSet); procedure N20Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinPanel1Resize(Sender: TObject); procedure N21Click(Sender: TObject); procedure t_op_letter_hdAfterInsert(DataSet: TDataSet); procedure N23Click(Sender: TObject); procedure DBEdit1KeyPress(Sender: TObject; var Key: Char); procedure DBEdit2KeyPress(Sender: TObject; var Key: Char); procedure DBEdit4KeyPress(Sender: TObject; var Key: Char); procedure DBEdit5KeyPress(Sender: TObject; var Key: Char); procedure DBEdit6KeyPress(Sender: TObject; var Key: Char); procedure DBEdit7KeyPress(Sender: TObject; var Key: Char); procedure DBEdit8KeyPress(Sender: TObject; var Key: Char); procedure DBEdit9KeyPress(Sender: TObject; var Key: Char); procedure DBEdit10KeyPress(Sender: TObject; var Key: Char); procedure DBEdit12KeyPress(Sender: TObject; var Key: Char); procedure DBEdit13KeyPress(Sender: TObject; var Key: Char); procedure wwDBDateTimePicker1KeyPress(Sender: TObject; var Key: Char); procedure wwDBDateTimePicker2KeyPress(Sender: TObject; var Key: Char); procedure DBEdit15KeyPress(Sender: TObject; var Key: Char); procedure DBEdit16KeyPress(Sender: TObject; var Key: Char); procedure DBEdit14KeyPress(Sender: TObject; var Key: Char); procedure DBEdit17KeyPress(Sender: TObject; var Key: Char); procedure DBEdit18KeyPress(Sender: TObject; var Key: Char); procedure DBEdit19KeyPress(Sender: TObject; var Key: Char); procedure DBEdit20KeyPress(Sender: TObject; var Key: Char); procedure DBEdit11KeyPress(Sender: TObject; var Key: Char); procedure DBEdit21KeyPress(Sender: TObject; var Key: Char); procedure DBEdit22KeyPress(Sender: TObject; var Key: Char); procedure DBEdit23KeyPress(Sender: TObject; var Key: Char); procedure DBEdit24KeyPress(Sender: TObject; var Key: Char); procedure DBEdit25KeyPress(Sender: TObject; var Key: Char); procedure DBEdit26KeyPress(Sender: TObject; var Key: Char); procedure DBEdit27KeyPress(Sender: TObject; var Key: Char); procedure DBEdit28KeyPress(Sender: TObject; var Key: Char); procedure DBEdit29KeyPress(Sender: TObject; var Key: Char); procedure DBEdit30KeyPress(Sender: TObject; var Key: Char); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure DBEdit31KeyPress(Sender: TObject; var Key: Char); procedure DBEdit32KeyPress(Sender: TObject; var Key: Char); procedure dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure N26Click(Sender: TObject); procedure t_op_letterBeforeEdit(DataSet: TDataSet); procedure DBComboBox1Change(Sender: TObject); procedure DBComboBox1KeyPress(Sender: TObject; var Key: Char); procedure DBEdit33KeyPress(Sender: TObject; var Key: Char); procedure N28Click(Sender: TObject); procedure t_op_letter_bgmxAfterInsert(DataSet: TDataSet); procedure DBComboBox2DropDown(Sender: TObject); procedure bsSkinPanel3Resize(Sender: TObject); procedure N30Click(Sender: TObject); procedure DBComboBox2Change(Sender: TObject); private { Private declarations } public { Public declarations } bsTypeid:Integer; carrs,trucks,ships:string; function GetCorpCName(SName:string):string; end; var frm_op_letter: Tfrm_op_letter; frm_op_letter_insert:boolean; implementation uses u_main, my_sys_function, u_data_share, u_code_truck_client, u_code_truck_changzhan, u_code_send_head, u_op_letter_his; {$R *.dfm} function Tfrm_op_letter.GetCorpCName(SName:string):string; var AdoQuery:TAdoQuery; begin Result:=''; AdoQuery:=CreateAdoQuery; with AdoQuery do try Close;SQL.Clear; SQL.Add('Select 客户全称 From t_crm_Client'); SQL.Add('Where 客户简称='+''''+SName+''''); Open; if not IsEmpty then Result:=FieldByName('客户全称').AsString else Result:=''; finally FreeAndNil(AdoQuery); end; end; procedure Tfrm_op_letter.bsSkinButton1Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton1.ClientToScreen(Point(0,bsSkinButton1.Height)); PopupMenu1.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_letter.DBEdit3Change(Sender: TObject); begin DataSource1.Enabled:=false; if t_op_letter.IsEmpty then begin bsSkinNotebook1.PageIndex:=9; end else if DBEdit3.Text='报关明细单' then begin bsSkinNotebook1.PageIndex:=11; DataSource1.Enabled:=false; DataSource1.DataSet:=t_op_letter_bgmx; end else if DBEdit3.Text='重签保函' then begin bsSkinNotebook1.PageIndex:=0; DataSource1.Enabled:=false; DataSource1.DataSet:=t_op_letter_cq; end else if DBEdit3.Text='超重保函' then begin bsSkinNotebook1.PageIndex:=1; DataSource1.DataSet:=t_op_letter_cz; end else if DBEdit3.Text='电放保函' then begin bsSkinNotebook1.PageIndex:=2; DataSource1.DataSet:=t_op_letter_df; end else if DBEdit3.Text='倒签保函' then begin bsSkinNotebook1.PageIndex:=3; DataSource1.DataSet:=t_op_letter_dq; end else if DBEdit3.Text='更改通知' then begin bsSkinNotebook1.PageIndex:=4; DataSource1.DataSet:=t_op_letter_gg; end else if DBEdit3.Text='换船通知' then begin bsSkinNotebook1.PageIndex:=5; DataSource1.DataSet:=t_op_letter_hc; end else if DBEdit3.Text='派车通知' then begin bsSkinNotebook1.PageIndex:=6; DataSource1.DataSet:=t_op_letter_pc; end else if DBEdit3.Text='入货通知' then begin bsSkinNotebook1.PageIndex:=7; DataSource1.DataSet:=t_op_letter_rh; end else if DBEdit3.Text='预借保函' then begin bsSkinNotebook1.PageIndex:=8; DataSource1.DataSet:=t_op_letter_yj; end else if DBEdit3.Text='业务函电' then begin bsSkinNotebook1.PageIndex:=10; DataSource1.DataSet:=t_op_letter_hd; end else if DBEdit3.Text='内贸派车' then begin bsSkinNotebook1.PageIndex:=12; DataSource1.DataSet:=t_op_letter_pc; end; DataSource1.Enabled:=true; end; procedure Tfrm_op_letter.t_op_letterAfterInsert(DataSet: TDataSet); begin t_op_letter['编号']:=t_op_letter.DataSource.DataSet['编号']; t_op_letter['签发人']:=employee; t_op_letter['签发日期']:=date; //ShowMessage(N3.Caption); t_op_letter['HEAD_TO']:=GetCorpCName(t_op_letter.DataSource.DataSet.FieldByName('委托单位').asstring); frm_op_letter_insert:=false; end; procedure Tfrm_op_letter.N3Click(Sender: TObject); begin frm_op_letter_insert:=true; t_op_letter.Insert; t_op_letter['函电名称']:=N3.Caption; t_op_letter['HEAD_TO']:=GetCorpCName(t_op_letter.DataSource.DataSet.FieldByName('承运车队').asstring); t_op_letter.Post; t_op_letter_pc.insert; end; procedure Tfrm_op_letter.N7Click(Sender: TObject); begin frm_op_letter_insert:=true; t_op_letter.Insert; t_op_letter['函电名称']:=N7.Caption; t_op_letter['HEAD_TO']:=GetCorpCName(t_op_letter.DataSource.DataSet.FieldByName('委托单位').asstring); t_op_letter.Post; t_op_letter_rh.insert; end; procedure Tfrm_op_letter.N5Click(Sender: TObject); begin frm_op_letter_insert:=true; t_op_letter.Insert; t_op_letter['函电名称']:=N5.Caption; t_op_letter['HEAD_TO']:=GetCorpCName(t_op_letter.DataSource.DataSet.FieldByName('委托单位').asstring); t_op_letter.Post; t_op_letter_hc.insert; end; procedure Tfrm_op_letter.N9Click(Sender: TObject); begin frm_op_letter_insert:=true; t_op_letter.Insert; t_op_letter['函电名称']:=N9.Caption; t_op_letter['HEAD_TO']:=GetCorpCName(t_op_letter.DataSource.DataSet.FieldByName('船公司').asstring); t_op_letter.Post; t_op_letter_gg.insert; end; procedure Tfrm_op_letter.N11Click(Sender: TObject); begin frm_op_letter_insert:=true; t_op_letter.Insert; t_op_letter['函电名称']:=N11.Caption; t_op_letter['HEAD_TO']:=GetCorpCName(t_op_letter.DataSource.DataSet.FieldByName('船公司').asstring); t_op_letter.Post; t_op_letter_yj.insert; end; procedure Tfrm_op_letter.N13Click(Sender: TObject); begin frm_op_letter_insert:=true; t_op_letter.Insert; t_op_letter['函电名称']:=N13.Caption; t_op_letter['HEAD_TO']:=GetCorpCName(t_op_letter.DataSource.DataSet.FieldByName('船公司').asstring); t_op_letter.Post; t_op_letter_dq.insert; end; procedure Tfrm_op_letter.N19Click(Sender: TObject); begin frm_op_letter_insert:=true; t_op_letter.Insert; t_op_letter['函电名称']:=N19.Caption; t_op_letter['HEAD_TO']:=GetCorpCName(t_op_letter.DataSource.DataSet.FieldByName('船公司').asstring); t_op_letter.Post; t_op_letter_cq.insert; end; procedure Tfrm_op_letter.N17Click(Sender: TObject); begin frm_op_letter_insert:=true; t_op_letter.Insert; t_op_letter['函电名称']:=N17.Caption; t_op_letter['HEAD_TO']:=GetCorpCName(t_op_letter.DataSource.DataSet.FieldByName('船公司').asstring); t_op_letter.Post; t_op_letter_cz.insert; end; procedure Tfrm_op_letter.N15Click(Sender: TObject); begin frm_op_letter_insert:=true; t_op_letter.Insert; t_op_letter['函电名称']:=N15.Caption; t_op_letter['HEAD_TO']:=GetCorpCName(t_op_letter.DataSource.DataSet.FieldByName('船公司').asstring); t_op_letter.Post; t_op_letter_df.insert; end; procedure Tfrm_op_letter.bsSkinButton2Click(Sender: TObject); begin if (t_op_letter.State=dsinsert)or(t_op_letter.State=dsedit) then t_op_letter.post; if DataSource1.DataSet=nil then exit; if (DataSource1.DataSet.State=dsinsert)or(DataSource1.DataSet.State=dsedit) then DataSource1.DataSet.post; end; procedure Tfrm_op_letter.bsSkinButton3Click(Sender: TObject); begin if DataSource1.DataSet=nil then exit; if (DataSource1.DataSet.State=dsinsert)or(DataSource1.DataSet.State=dsedit) then DataSource1.DataSet.cancel; if (t_op_letter.State=dsinsert)or(t_op_letter.State=dsedit) then t_op_letter.cancel; end; procedure Tfrm_op_letter.bsSkinButton4Click(Sender: TObject); begin if t_op_letter.IsEmpty then exit; if DataSource1.DataSet=nil then exit; if application.MessageBox('您确定要删除数据吗?','警告:',MB_OKCANCEL)=IDOK then begin if not DataSource1.DataSet.IsEmpty then DataSource1.DataSet.Delete; t_op_letter.delete; end; end; procedure Tfrm_op_letter.t_op_letter_yjBeforeInsert(DataSet: TDataSet); begin if (t_op_letter.DataSource.DataSet.FieldByName('业务状态').AsString='业务封帐') then begin showmessage('业务已经封帐,不能修改!!'); abort; end; if (t_op_letter.State=dsinsert)or(t_op_letter.State=dsedit) then t_op_letter.post; end; procedure Tfrm_op_letter.t_op_letter_cqAfterInsert(DataSet: TDataSet); begin t_op_letter_cq['LE_ID']:=t_op_letter['LE_ID']; end; procedure Tfrm_op_letter.t_op_letter_czAfterInsert(DataSet: TDataSet); begin t_op_letter_cz['LE_ID']:=t_op_letter['LE_ID']; end; procedure Tfrm_op_letter.t_op_letter_dfAfterInsert(DataSet: TDataSet); begin t_op_letter_df['LE_ID']:=t_op_letter['LE_ID']; end; procedure Tfrm_op_letter.t_op_letter_dqAfterInsert(DataSet: TDataSet); begin t_op_letter_dq['LE_ID']:=t_op_letter['LE_ID']; end; procedure Tfrm_op_letter.t_op_letter_ggAfterInsert(DataSet: TDataSet); begin t_op_letter_gg['LE_ID']:=t_op_letter['LE_ID']; end; procedure Tfrm_op_letter.t_op_letter_hcAfterInsert(DataSet: TDataSet); begin t_op_letter_hc['LE_ID']:=t_op_letter['LE_ID']; t_op_letter_hc['原船名']:=t_op_letter.DataSource.DataSet['船名']; t_op_letter_hc['原航次']:=t_op_letter.DataSource.DataSet['航次']; t_op_letter_hc['原船期']:=t_op_letter.DataSource.DataSet['开船日期']; t_op_letter_hc['原提单号']:=t_op_letter.DataSource.DataSet['主提单号']; end; procedure Tfrm_op_letter.t_op_letter_pcAfterInsert(DataSet: TDataSet); begin t_op_letter_pc['LE_ID']:=t_op_letter['LE_ID']; t_op_letter_pc['箱型箱量']:=t_op_letter.DataSource.DataSet.fieldbyname('集装箱').asstring; if frm_data_share.t_code_truck_client.Locate('厂家名称',t_op_letter.DataSource.DataSet.fieldbyname('委托单位').asstring,[])then begin t_op_letter_pc['厂家地址']:=frm_data_share.t_code_truck_client['厂家地址']; t_op_letter_pc['厂家联系人']:=frm_data_share.t_code_truck_client['厂家联系人']; t_op_letter_pc['厂家联系电话']:=frm_data_share.t_code_truck_client['厂家联系电话']; end else begin if frm_data_share.t_crm_client.Locate('客户简称',t_op_letter.DataSource.DataSet.fieldbyname('委托单位').asstring,[])then begin t_op_letter_pc['厂家地址']:=frm_data_share.t_crm_client['通讯地址']; t_op_letter_pc['厂家联系人']:=frm_data_share.t_crm_client['海运联系人']; t_op_letter_pc['厂家联系电话']:=frm_data_share.t_crm_client['海运电话']; end; end; t_op_letter_pc['背箱场站']:=t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring; t_op_letter_pc['返箱地址']:=t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring; if frm_data_share.t_code_truck_changzhan.Locate('场站名称',t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring,[])then begin t_op_letter_pc['背箱场站']:=frm_data_share.t_code_truck_changzhan['场站名称']; t_op_letter_pc['场站联系人']:=frm_data_share.t_code_truck_changzhan['场站联系人']; t_op_letter_pc['场站电话']:=frm_data_share.t_code_truck_changzhan['场站电话']; t_op_letter_pc['返箱地址']:=frm_data_share.t_code_truck_changzhan['场站名称']; t_op_letter_pc['返箱联系人']:=frm_data_share.t_code_truck_changzhan['场站联系人']; t_op_letter_pc['返箱联系电话']:=frm_data_share.t_code_truck_changzhan['场站电话']; end else begin if frm_data_share.t_crm_client.Locate('场站名称',t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring,[])then begin t_op_letter_pc['背箱场站']:=t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring; t_op_letter_pc['场站联系人']:=frm_data_share.t_crm_client['海运联系人']; t_op_letter_pc['场站电话']:=frm_data_share.t_crm_client['海运电话']; t_op_letter_pc['返箱地址']:=t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring; t_op_letter_pc['返箱联系人']:=frm_data_share.t_crm_client['海运联系人']; t_op_letter_pc['返箱联系电话']:=frm_data_share.t_crm_client['海运电话']; end; end; { if frm_data_share.t_crm_client.Locate('客户简称',t_op_letter.DataSource.DataSet.fieldbyname('委托单位').asstring,[])then begin t_op_letter_pc['厂家地址']:=frm_data_share.t_crm_client['通讯地址']; t_op_letter_pc['厂家联系人']:=frm_data_share.t_crm_client['海运联系人']; t_op_letter_pc['厂家联系电话']:=frm_data_share.t_crm_client['海运电话']; end; t_op_letter_pc['背箱场站']:=t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring; t_op_letter_pc['返箱地址']:=t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring; if frm_data_share.t_crm_client.Locate('场站名称',t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring,[])then begin t_op_letter_pc['背箱场站']:=t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring; t_op_letter_pc['场站联系人']:=frm_data_share.t_crm_client['海运联系人']; t_op_letter_pc['场站电话']:=frm_data_share.t_crm_client['海运电话']; t_op_letter_pc['返箱地址']:=t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring; t_op_letter_pc['返箱联系人']:=frm_data_share.t_crm_client['海运联系人']; t_op_letter_pc['返箱联系电话']:=frm_data_share.t_crm_client['海运电话']; end; } end; procedure Tfrm_op_letter.t_op_letter_rhAfterInsert(DataSet: TDataSet); var aQuery,bQuery:TADOQuery; Hour, Min, Sec, MSec: Word; aDateTime:TDateTime; begin t_op_letter_rh['LE_ID']:=t_op_letter['LE_ID']; t_op_letter_rh['入货场站']:=t_op_letter.DataSource.DataSet['场站']; aDateTime:=t_op_letter.DataSource.DataSet.FieldByName('截港日期').AsDateTime; DecodeTime(aDateTime,Hour, Min, Sec, MSec); if t_op_letter.DataSource.DataSet['截港日期']<>null then if Hour<>0 then t_op_letter_rh['入货截至时间']:=FormatDateTime('YYYY-MM-DD hh:mm',t_op_letter.DataSource.DataSet['截港日期']) else t_op_letter_rh['入货截至时间']:=FormatDateTime('YYYY-MM-DD',t_op_letter.DataSource.DataSet['截港日期']) else t_op_letter_rh['入货截至时间']:=FormatDateTime('YYYY-MM-DD',Now); bQuery:=CreateAdoQuery; with bQuery do try Close;SQL.Clear; SQL.Add('Select voy.截单日期'); SQL.Add('From t_code_voyage voy'); SQL.Add('Left join t_code_vessel vsl on (voy.vs_id=vsl.vs_id)'); SQL.Add('Where vsl.英文船名=:VSL and voy.航次=:Voy'); Parameters.ParamByName('VSL').Value:=t_op_letter.DataSource.DataSet.FieldByName('船名').AsString; Parameters.ParamByName('Voy').Value:=t_op_letter.DataSource.DataSet.FieldByName('航次').AsString; Open; if not IsEmpty then begin aDateTime:=FieldByName('截单日期').AsDateTime; end; finally FreeAndNil(bQuery); end; DecodeTime(aDateTime,Hour, Min, Sec, MSec); if YearOf(aDateTime)<>1899 then if Hour<>0 then t_op_letter_rh['截单时间']:=FormatDateTime('YYYY-MM-DD hh:mm',aDateTime) else t_op_letter_rh['截单时间']:=FormatDateTime('YYYY-MM-DD',aDateTime) else t_op_letter_rh['截单时间']:=FormatDateTime('YYYY-MM-DD hh:mm',Now); if not t_op_letter.DataSource.DataSet.FieldByName('截单日期').IsNull then t_op_letter_rh['截单时间']:=FormatDateTime('YYYY-MM-DD hh:mm',t_op_letter.DataSource.DataSet['截单日期']); DBComboBox1.Items.Clear; if frm_data_share.t_crm_client_changzhan.Locate('客户简称',t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring,[])then begin t_op_letter_rh['场站地址']:=frm_data_share.t_crm_client_changzhan['通讯地址']; t_op_letter_rh['场站联系电话']:=frm_data_share.t_crm_client_changzhan['电话']; try aQuery:=CreateAdoQuery; with aQuery do begin Close;SQL.Clear; SQL.Add('Select 姓名,办公电话,家庭电话 from t_crm_client_linkman where 客户简称='''+t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring+''''); if t_op_letter.DataSource.DataSet.fieldbyname('场站联系人').asstring<>'' then SQL.Add('and 姓名 ='''+t_op_letter.DataSource.DataSet.fieldbyname('场站联系人').asstring+''''); Open; if not IsEmpty then begin while not Eof do begin DBComboBox1.Items.Add(FieldByName('姓名').AsString); Next; end; t_op_letter_rh['场站联系人']:=FieldByName('姓名').AsString; t_op_letter_rh['场站联系电话']:=FieldByName('办公电话').AsString; t_op_letter_rh['场站联系传真']:=FieldByName('家庭电话').AsString; end; end; finally FreeAndNil(aQuery); end; end; if t_op_letter.DataSource.DataSet.fieldbyname('场站联系人').asstring<>'' then t_op_letter_rh['场站联系人']:=t_op_letter.DataSource.DataSet.fieldbyname('场站联系人').asstring; end; procedure Tfrm_op_letter.t_op_letter_yjAfterInsert(DataSet: TDataSet); begin t_op_letter_yj['LE_ID']:=t_op_letter['LE_ID']; end; procedure Tfrm_op_letter.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_op_letter.Hide; frm_op_letter.ManualFloat(frm_op_letter.BoundsRect ); action:=cafree; frm_op_letter:=nil; end; procedure Tfrm_op_letter.FormShow(Sender: TObject); begin bsSkinNotebook1.PageIndex:=9; t_op_letter.Open; t_op_letter_cq.Open; t_op_letter_cz.Open; t_op_letter_df.Open; t_op_letter_dq.Open; t_op_letter_gg.Open; t_op_letter_hc.Open; t_op_letter_pc.Open; t_op_letter_rh.Open; t_op_letter_yj.Open; t_op_letter_hd.Open; t_op_letter_bgmx.Open; t_crm_client_cd.Open ; // carrs:=GetCorpCName('船公司'):string; // trucks:=GetCorpCName(''):string; // ships:=GetCorpCName('委托单位'):string; bsSkinButton1.Width:=round(bsSkinPanel1.Width/5); bsSkinButton2.Width:=round(bsSkinPanel1.Width/5); bsSkinButton3.Width:=round(bsSkinPanel1.Width/5); bsSkinButton4.Width:=round(bsSkinPanel1.Width/5); DBEdit1.Width:=bsSkinPanel3.Width-DBEdit1.Left-6; // DBComboBox2.Width:=DBEdit1.Width-20; N26.Visible:=false; //历史引入 N25.Visible:=false; //--- N23.Visible:=false; //'业务函电' N24.Visible:=false; // '-' N3.Visible:=false; // '派车通知' N4.Visible:=false; // '-' N5.Visible:=false; // '换船通知' N6.Visible:=false; // '-' N7.Visible:=false; //'入货通知' N8.Visible:=false; // '-' N9.Visible:=false; //'更改通知' N27.Visible:=false; // '-' N28.Visible:=false; //'报关明细单' N10.Visible:=false; // '-' N11.Visible:=false; //'预借保函' N12.Visible:=false; // '-' N13.Visible:=false; //'倒签保函' N14.Visible:=false; // '-' N15.Visible:=false; //'电放保函' N16.Visible:=false; //'-' N17.Visible:=false; //'超重保函' N18.Visible:=false; // '-' N19.Visible:=false; //'重签保函' N29.Visible:=false; // '-' N30.Visible:=false; //'内贸派车' case bsTypeid of 0: begin N26.Visible:=True; //历史引入 N25.Visible:=True; //--- N23.Visible:=True; //'业务函电' N24.Visible:=True; // '-' N3.Visible:=True; // '派车通知' N4.Visible:=True; // '-' N5.Visible:=True; // '换船通知' N6.Visible:=True; // '-' N7.Visible:=True; //'入货通知' N8.Visible:=True; // '-' N9.Visible:=True; //'更改通知' N27.Visible:=True; // '-' N28.Visible:=True; //'报关明细单' N10.Visible:=True; // '-' N11.Visible:=True; //'预借保函' N12.Visible:=True; // '-' N13.Visible:=True; //'倒签保函' N14.Visible:=True; // '-' N15.Visible:=True; //'电放保函' N16.Visible:=True; //'-' N17.Visible:=True; //'超重保函' N18.Visible:=True; // '-' N19.Visible:=True; //'重签保函' end; 1: begin N29.Visible:=True; // '-' N30.Visible:=True; //'内贸派车' end; end; end; procedure Tfrm_op_letter.t_op_letterBeforeInsert(DataSet: TDataSet); begin if (t_op_letter.DataSource.DataSet.FieldByName('业务状态').AsString='业务封帐') then begin showmessage('业务已经封帐,不能修改!!'); abort; end; if t_op_letter.DataSource.DataSet.State=dsinsert then t_op_letter.DataSource.DataSet.post; if not frm_op_letter_insert then abort; end; procedure Tfrm_op_letter.N20Click(Sender: TObject); var book1:Tbookmark; begin if t_op_letter.IsEmpty then exit; if (t_op_letter.State=dsinsert)or(t_op_letter.State=dsedit) then t_op_letter.post; if (DataSource1.DataSet.State=dsinsert)or(DataSource1.DataSet.State=dsedit) then DataSource1.DataSet.post; with t_op_railway_cnt do begin Close;SQL.Clear; sql.Add('select * from t_op_railway'); sql.Add('where 主编号=:bsno and 主编号<>编号'); Parameters.ParamByName('bsno').Value:=t_op_letter.FieldByName('编号').AsString; Open; end; try t_op_letter.DataSource.DataSet.DisableControls; // book1:=t_op_letter.GetBookmark; t_op_letter.DisableControls; sys_print('海运出口'+DBEdit3.Text,2,t_op_letter.DataSource,t_op_letter1,DataSource1,t_op_railway_cnt1,DataSource2,nil,nil,nil,nil,nil,nil); finally t_op_letter.DataSource.DataSet.EnableControls; // t_op_letter.GotoBookmark(book1); t_op_letter.EnableControls; end; end; procedure Tfrm_op_letter.N1Click(Sender: TObject); var book1:Tbookmark; begin if t_op_letter.IsEmpty then exit; if (t_op_letter.State=dsinsert)or(t_op_letter.State=dsedit) then t_op_letter.post; if (DataSource1.DataSet.State=dsinsert)or(DataSource1.DataSet.State=dsedit) then DataSource1.DataSet.post; with t_op_railway_cnt do begin Close;SQL.Clear; sql.Add('select * from t_op_railway'); sql.Add('where 主编号=:bsno and 主编号<>编号'); Parameters.ParamByName('bsno').Value:=t_op_letter.FieldByName('编号').AsString; Open; end; try // book1:=t_op_letter.GetBookmark; t_op_letter.DisableControls; t_op_letter.DataSource.DataSet.DisableControls; sys_print('海运出口'+DBEdit3.Text,1,t_op_letter.DataSource,t_op_letter1,DataSource1,t_op_railway_cnt1,DataSource2,nil,nil,nil,nil,nil,nil); finally t_op_letter.DataSource.DataSet.EnableControls; // t_op_letter.GotoBookmark(book1); t_op_letter.EnableControls; end; end; procedure Tfrm_op_letter.bsSkinButton9Click(Sender: TObject); var Pnt:Tpoint; begin Pnt:=bsSkinButton9.ClientToScreen(Point(0,bsSkinButton9.Height)); PopupMenu2.Popup(Pnt.x,Pnt.y); end; procedure Tfrm_op_letter.bsSkinPanel1Resize(Sender: TObject); begin bsSkinButton1.Width:=round(bsSkinPanel1.Width/5); bsSkinButton2.Width:=round(bsSkinPanel1.Width/5); bsSkinButton3.Width:=round(bsSkinPanel1.Width/5); bsSkinButton4.Width:=round(bsSkinPanel1.Width/5); end; procedure Tfrm_op_letter.N21Click(Sender: TObject); var book1:Tbookmark; begin if t_op_letter.IsEmpty then exit; if (t_op_letter.State=dsinsert)or(t_op_letter.State=dsedit) then t_op_letter.post; if (DataSource1.DataSet.State=dsinsert)or(DataSource1.DataSet.State=dsedit) then DataSource1.DataSet.post; with t_op_railway_cnt do begin Close;SQL.Clear; sql.Add('select * from t_op_railway'); sql.Add('where 主编号=:bsno and 主编号<>编号'); Parameters.ParamByName('bsno').Value:=t_op_letter.FieldByName('编号').AsString; Open; end; try // book1:=t_op_letter.GetBookmark; t_op_letter.DataSource.DataSet.DisableControls; t_op_letter.DisableControls; sys_print('海运出口'+DBEdit3.Text,3,t_op_letter.DataSource,t_op_letter1,DataSource1,t_op_railway_cnt1,DataSource2,nil,nil,nil,nil,nil,nil); finally t_op_letter.DataSource.DataSet.EnableControls; // t_op_letter.GotoBookmark(book1); t_op_letter.EnableControls; end; end; procedure Tfrm_op_letter.t_op_letter_hdAfterInsert(DataSet: TDataSet); begin t_op_letter_hd['LE_ID']:=t_op_letter['LE_ID']; end; procedure Tfrm_op_letter.N23Click(Sender: TObject); begin frm_op_letter_insert:=true; t_op_letter.Insert; t_op_letter['函电名称']:=N23.Caption; t_op_letter['Head_To']:=GetCorpCName(t_op_letter.DataSource.DataSet.FieldByName('船公司').AsString); t_op_letter.Post; t_op_letter_hd.insert; end; procedure Tfrm_op_letter.DBEdit1KeyPress(Sender: TObject; var Key: Char); begin key_DBComboBox(Key,DBComboBox2); end; procedure Tfrm_op_letter.DBEdit2KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; bsSkinNotebook1.SetFocus; end; end; procedure Tfrm_op_letter.DBEdit4KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo6); end; procedure Tfrm_op_letter.DBEdit5KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit6); end; procedure Tfrm_op_letter.DBEdit6KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit7); end; procedure Tfrm_op_letter.DBEdit7KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo7); end; procedure Tfrm_op_letter.DBEdit8KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo8); end; procedure Tfrm_op_letter.DBEdit9KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit10); end; procedure Tfrm_op_letter.DBEdit10KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit12); end; procedure Tfrm_op_letter.DBEdit12KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit13); end; procedure Tfrm_op_letter.DBEdit13KeyPress(Sender: TObject; var Key: Char); begin key_wwDBDateTimePicker(Key,wwDBDateTimePicker1); end; procedure Tfrm_op_letter.wwDBDateTimePicker1KeyPress(Sender: TObject; var Key: Char); begin key_wwDBDateTimePicker(Key,wwDBDateTimePicker2); end; procedure Tfrm_op_letter.wwDBDateTimePicker2KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit15); end; procedure Tfrm_op_letter.DBEdit15KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit16); end; procedure Tfrm_op_letter.DBEdit16KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo12); end; procedure Tfrm_op_letter.DBEdit14KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit31); end; procedure Tfrm_op_letter.DBEdit17KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit18); end; procedure Tfrm_op_letter.DBEdit18KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit19); end; procedure Tfrm_op_letter.DBEdit19KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit20); end; procedure Tfrm_op_letter.DBEdit20KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit11); end; procedure Tfrm_op_letter.DBEdit11KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit21); end; procedure Tfrm_op_letter.DBEdit21KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit22); end; procedure Tfrm_op_letter.DBEdit22KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit23); end; procedure Tfrm_op_letter.DBEdit23KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit24); end; procedure Tfrm_op_letter.DBEdit24KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit25); end; procedure Tfrm_op_letter.DBEdit25KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo13); end; procedure Tfrm_op_letter.DBEdit26KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit27); end; procedure Tfrm_op_letter.DBEdit27KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit28); end; procedure Tfrm_op_letter.DBEdit28KeyPress(Sender: TObject; var Key: Char); begin if key=#13 then begin key:=#0; DBComboBox1.SetFocus; end; end; procedure Tfrm_op_letter.DBEdit29KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit33); end; procedure Tfrm_op_letter.DBEdit30KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo15); end; procedure Tfrm_op_letter.Button1Click(Sender: TObject); begin if t_op_letter_pc.IsEmpty then exit; try frm_code_truck_client:=tfrm_code_truck_client.Create (self); code_truck_client_num:=1; frm_code_truck_client.ShowModal; finally frm_code_truck_client.Free; frm_code_truck_client:=nil; end; end; procedure Tfrm_op_letter.Button2Click(Sender: TObject); begin if t_op_letter_pc.IsEmpty then exit; try frm_code_truck_changzhan:=tfrm_code_truck_changzhan.Create (self); code_truck_changzhan_num:=1; frm_code_truck_changzhan.ShowModal; finally frm_code_truck_changzhan.Free; frm_code_truck_changzhan:=nil; end; end; procedure Tfrm_op_letter.Button3Click(Sender: TObject); begin if t_op_letter_pc.IsEmpty then exit; try frm_code_truck_changzhan:=tfrm_code_truck_changzhan.Create (self); code_truck_changzhan_num:=2; frm_code_truck_changzhan.ShowModal; finally frm_code_truck_changzhan.Free; frm_code_truck_changzhan:=nil; end; end; procedure Tfrm_op_letter.Button4Click(Sender: TObject); begin if t_op_letter_rh.IsEmpty then exit; try frm_code_truck_changzhan:=tfrm_code_truck_changzhan.Create (self); code_truck_changzhan_num:=3; frm_code_truck_changzhan.ShowModal; finally frm_code_truck_changzhan.Free; frm_code_truck_changzhan:=nil; end; end; procedure Tfrm_op_letter.Button5Click(Sender: TObject); begin if t_op_letter.isempty then exit; { if not if_open('144') then begin showmessage('对不起你没有此模块的操作权限!'); exit; end; } try frm_code_send_head:=tfrm_code_send_head.Create (self); code_send_head_num:=1; frm_code_send_head.ShowModal; finally frm_code_send_head.Free; frm_code_send_head:=nil; end; end; procedure Tfrm_op_letter.DBEdit31KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit32); end; procedure Tfrm_op_letter.DBEdit32KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit17); end; procedure Tfrm_op_letter.dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,t_op_letter,'LF'); end; procedure Tfrm_op_letter.N26Click(Sender: TObject); begin try if not assigned(frm_op_letter_his) then frm_op_letter_his:=tfrm_op_letter_his.Create (self); frm_op_letter_his.ShowModal; finally frm_op_letter_his.free; frm_op_letter_his:=nil; end; end; procedure Tfrm_op_letter.t_op_letterBeforeEdit(DataSet: TDataSet); begin if (t_op_letter.DataSource.DataSet.FieldByName('业务状态').AsString='业务封帐') then begin showmessage('业务已经封帐,不能修改!!'); abort; end; if not do_data('0001',t_op_letter.FieldByName('签发人').asstring,'','','','','') then begin showmessage('对不起此函电您无权修改!!'); abort; end; end; procedure Tfrm_op_letter.DBComboBox1Change(Sender: TObject); var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 姓名,办公电话 from t_crm_client_linkman where 客户简称='''+t_op_letter.DataSource.DataSet.fieldbyname('场站').asstring+''' AND 姓名='''+DBComboBox1.Text+''''); Open; if not IsEmpty then begin t_op_letter_rh['场站联系电话']:=FieldByName('办公电话').AsString; end; end; finally FreeAndNil(aQuery); end; //选择输入 end; procedure Tfrm_op_letter.DBComboBox1KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit29); end; procedure Tfrm_op_letter.DBEdit33KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo14); end; procedure Tfrm_op_letter.N28Click(Sender: TObject); begin frm_op_letter_insert:=true; t_op_letter.Insert; t_op_letter['函电名称']:=N28.Caption; t_op_letter['HEAD_TO']:=GetCorpCName(t_op_letter.DataSource.DataSet.FieldByName('委托单位').asstring); t_op_letter.Post; t_op_letter_bgmx.insert; end; procedure Tfrm_op_letter.t_op_letter_bgmxAfterInsert(DataSet: TDataSet); begin t_op_letter_bgmx['LE_ID']:=t_op_letter['LE_ID']; end; procedure Tfrm_op_letter.DBComboBox2DropDown(Sender: TObject); var aAdoQuery:TAdoQuery; begin aAdoQuery:=createAdoQuery; with aAdoQuery do try Close;Sql.Clear; Sql.Add('Select 姓名,办公电话,家庭电话 From t_crm_client_linkman'); Sql.Add('Where 客户简称=:客户简称'); Parameters.ParamByName('客户简称').Value:=t_op_letter.DataSource.DataSet.FieldByName('委托单位').AsString; Open;First; DBComboBox2.Clear; while not eof do begin DBComboBox2.Items.Add(FieldByName('姓名').AsString); Next; end; finally FreeAndNil(aAdoQuery); end; end; procedure Tfrm_op_letter.bsSkinPanel3Resize(Sender: TObject); begin DBEdit1.Width:=bsSkinPanel3.Width-DBEdit1.left-6; // DBComboBox2.Width:=DBEdit1.Width-20; // Button5.Left:=DBComboBox2.left+DBComboBox2.Width; end; procedure Tfrm_op_letter.N30Click(Sender: TObject); begin frm_op_letter_insert:=true; t_op_letter.Insert; t_op_letter['函电名称']:=N30.Caption; t_op_letter['HEAD_TO']:=GetCorpCName(t_op_letter.DataSource.DataSet.FieldByName('委托单位').asstring); t_op_letter.Post; t_op_letter_pc.insert; end; procedure Tfrm_op_letter.DBComboBox2Change(Sender: TObject); var aAdoQuery:TAdoQuery; begin aAdoQuery:=createAdoQuery; with aAdoQuery do try Close;Sql.Clear; Sql.Add('Select 姓名,办公电话,家庭电话,邮箱 From t_crm_client_linkman'); Sql.Add('Where 客户简称=:客户简称 and 姓名=:姓名'); Parameters.ParamByName('客户简称').Value:=t_op_letter.DataSource.DataSet.FieldByName('委托单位').AsString; Parameters.ParamByName('姓名').Value:=Trim(DBComboBox2.Text); Open;First; if not IsEmpty then begin t_op_letter.FieldByName('HEAD_TEL').AsString:=FieldByName('办公电话').AsString; t_op_letter.FieldByName('HEAD_FAX').AsString:=FieldByName('家庭电话').AsString; t_op_letter.FieldByName('HEAD_MAIL').AsString:=FieldByName('邮箱').AsString; end; finally FreeAndNil(aAdoQuery); end; end; end.