{$INCLUDE t_main.inc} unit u_crm_client; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, dxDBTLCl, dxGrClms, StdCtrls, DBCtrls, wwdblook, Mask, RxLookup, bsdbctrls, BusinessSkinForm, DB, ADODB, ComCtrls, bsSkinTabs, ExtCtrls, wwdbedit, Wwdotdot, Wwdbcomb, wwdbdatetimepicker, DBCtrlsEh, Grids, Wwdbigrd, Wwdbgrid, bsSkinGrids, bsDBGrids, bsSkinBoxCtrls, Menus, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, cxNavigator, cxDBNavigator; type Tfrm_crm_client = class(TForm) bsSkinPanel2: TbsSkinPanel; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinPanel1: TbsSkinPanel; t_crm_client1: TDataSource; t_crm_client: TADOQuery; v_all_client: TADOQuery; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridMaskColumn; dxDBGrid1Column3: TdxDBGridMaskColumn; bsSkinPanel3: TbsSkinPanel; t_crm_client_limited: TADOQuery; t_crm_client_limited1: TDataSource; bsSkinButton8: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinGroupBox1: TbsSkinGroupBox; Label14: TLabel; wwDBComboBox1: TwwDBComboBox; Label15: TLabel; Edit1: TEdit; Edit2: TEdit; Label16: TLabel; Label17: TLabel; Edit3: TEdit; Label18: TLabel; RxDBLookupCombo2: TRxDBLookupCombo; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; Label4: TLabel; Label12: TLabel; Label5: TLabel; Label2: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label10: TLabel; Label11: TLabel; Label3: TLabel; Label13: TLabel; DBEdit4: TDBEdit; DBEdit1: TDBEdit; DBEdit5: TDBEdit; DBEdit2: TDBEdit; DBEdit6: TDBEdit; DBEdit7: TDBEdit; DBEdit8: TDBEdit; DBEdit10: TDBEdit; DBEdit9: TDBEdit; RxDBLookupCombo14: TRxDBLookupCombo; RxDBLookupCombo1: TRxDBLookupCombo; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox2: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox3: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox4: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox11: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox9: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox8: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox7: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox6: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox5: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox12: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox10: TbsSkinDBCheckRadioBox; bsSkinPageControl2: TbsSkinPageControl; bsSkinTabSheet3: TbsSkinTabSheet; Label9: TLabel; DBMemo2: TDBMemo; bsSkinTabSheet4: TbsSkinTabSheet; bsSkinPanel4: TbsSkinPanel; dxDBGrid2: TdxDBGrid; dxDBGrid2Column1: TdxDBGridMaskColumn; bsSkinPanel5: TbsSkinPanel; bsSkinButton10: TbsSkinButton; bsSkinButton11: TbsSkinButton; bsSkinButton6: TbsSkinButton; dxDBGrid3: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; bsSkinDBCheckRadioBox13: TbsSkinDBCheckRadioBox; t_crm_client_linkman: TADOQuery; t_crm_client_linkman1: TDataSource; bsSkinPanel6: TbsSkinPanel; Label36: TLabel; Label37: TLabel; Label38: TLabel; Label40: TLabel; Label39: TLabel; Label41: TLabel; Label42: TLabel; Label43: TLabel; Label44: TLabel; Label47: TLabel; Label48: TLabel; Label49: TLabel; Label50: TLabel; Label52: TLabel; Label51: TLabel; Label53: TLabel; dxDBGrid4: TdxDBGrid; dxDBGridMaskColumn2: TdxDBGridMaskColumn; dxDBGrid2Column2: TdxDBGridMaskColumn; dxDBGrid4Column4: TdxDBGridColumn; dxDBGrid2Column3: TdxDBGridMaskColumn; bsSkinButton7: TbsSkinButton; bsSkinButton12: TbsSkinButton; bsSkinButton13: TbsSkinButton; bsSkinButton14: TbsSkinButton; DBEdit35: TDBEdit; wwDBComboBox2: TwwDBComboBox; DBEdit37: TDBEdit; DBEdit39: TDBEdit; DBEdit38: TDBEdit; DBEdit36: TDBEdit; DBEdit40: TDBEdit; DBEdit41: TDBEdit; DBEdit42: TDBEdit; DBEdit43: TDBEdit; DBEdit44: TDBEdit; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; wwDBDateTimePicker4: TwwDBDateTimePicker; wwDBDateTimePicker3: TwwDBDateTimePicker; DBMemo3: TDBMemo; bsSkinButton15: TbsSkinButton; bsSkinPanel7: TbsSkinPanel; bsSkinDBCheckRadioBox14: TbsSkinDBCheckRadioBox; ds_crm_client_sales1: TDataSource; crmsalse_sheet: TbsSkinTabSheet; bsSkinPanel8: TbsSkinPanel; bsSkinButton18: TbsSkinButton; bsSkinButton19: TbsSkinButton; bsSkinButton20: TbsSkinButton; bsSkinButton21: TbsSkinButton; bsSkinButton16: TbsSkinButton; bsSkinButton17: TbsSkinButton; t_crm_client_sales: TADOQuery; Label27: TLabel; DBEdit3: TDBEdit; Label28: TLabel; DBEdit11: TDBEdit; DBEdit12: TDBEdit; Label29: TLabel; bsSkinPageControl3: TbsSkinPageControl; bs1: TbsSkinTabSheet; DBMemo1: TDBMemo; bs2: TbsSkinTabSheet; Label20: TLabel; DBEdit13: TDBEdit; Label30: TLabel; DBEdit14: TDBEdit; DBEdit15: TDBEdit; Label31: TLabel; Label32: TLabel; DBEdit16: TDBEdit; Label33: TLabel; Label34: TLabel; Label35: TLabel; DBMemo4: TDBMemo; DBEdit17: TDBEdit; DBEdit18: TDBEdit; DBEdit19: TDBEdit; Label45: TLabel; Label46: TLabel; DBEdit20: TDBEdit; Label54: TLabel; Edit4: TEdit; Label55: TLabel; Edit5: TEdit; bsSkinButton22: TbsSkinButton; bsSkinPanel9: TbsSkinPanel; bsSkinGroupBox3: TbsSkinGroupBox; Label24: TLabel; Label25: TLabel; Label26: TLabel; wwDBDateTimePicker6: TwwDBDateTimePicker; wwDBDateTimePicker7: TwwDBDateTimePicker; wwDBLookupCombo2: TwwDBLookupCombo; bsSkinGroupBox2: TbsSkinGroupBox; Label21: TLabel; Label73: TLabel; lbl1: TLabel; Label22: TLabel; wwDBComboBox13: TwwDBComboBox; wwDBComboBox12: TwwDBComboBox; bsSkinDBCheckRadioBox16: TbsSkinDBCheckRadioBox; DBEdit55: TDBEdit; bsSkinGroupBox12: TbsSkinGroupBox; Label77: TLabel; Label23: TLabel; DBEdit59: TDBEdit; bsSkinGroupBox13: TbsSkinGroupBox; Label79: TLabel; Label86: TLabel; lblmonth: TLabel; lbldate: TLabel; Label91: TLabel; wwDBComboBox14: TwwDBComboBox; wwDBComboBox15: TwwDBComboBox; DBEdit61: TDBEdit; dxDBGrid5: TdxDBGrid; dxDBGrid5ID: TdxDBGridMaskColumn; dxDBGrid5Column2: TdxDBGridMaskColumn; dxDBGrid5Column3: TdxDBGridMaskColumn; dxDBGrid5Column4: TdxDBGridMaskColumn; dxDBGrid5Column5: TdxDBGridMaskColumn; dxDBGrid5Column6: TdxDBGridMaskColumn; dxDBGrid5Column7: TdxDBGridMaskColumn; dxDBGrid5Column8: TdxDBGridMaskColumn; dxDBGrid5Column9: TdxDBGridCurrencyColumn; dxDBGrid5Column10: TdxDBGridDateColumn; dxDBGrid5Column11: TdxDBGridMaskColumn; dxDBGrid5Column12: TdxDBGridMaskColumn; dxDBGrid5Column13: TdxDBGridMaskColumn; dxDBGrid5Column14: TdxDBGridMaskColumn; dxDBGrid52: TdxDBGridMaskColumn; dxDBGrid5Column16: TdxDBGridMaskColumn; dxDBGrid5Column17: TdxDBGridMaskColumn; dxDBGrid5Column18: TdxDBGridCheckColumn; dxDBGrid5Column19: TdxDBGridMaskColumn; dxDBGrid5Column20: TdxDBGridDateColumn; dxDBGrid5Column21: TdxDBGridDateColumn; btab4: TbsSkinTabSheet; DBMemo5: TDBMemo; Label56: TLabel; DBMemo6: TDBMemo; Label57: TLabel; DBEdit23: TDBEdit; Label58: TLabel; Label60: TLabel; DBEdit22: TDBEdit; Label61: TLabel; DBEdit24: TDBEdit; Label62: TLabel; DBEdit25: TDBEdit; bsSkinDBCheckRadioBox15: TbsSkinDBCheckRadioBox; dxDBGrid1Column4: TdxDBGridColumn; Label19: TLabel; wwDBDateTimePicker5: TwwDBDateTimePicker; Label63: TLabel; DBEdit26: TDBEdit; bsSkinDBCheckRadioBox17: TbsSkinDBCheckRadioBox; bsSkinTabSheet5: TbsSkinTabSheet; bsSkinGroupBox4: TbsSkinGroupBox; Label64: TLabel; Label65: TLabel; Label66: TLabel; Label67: TLabel; Label68: TLabel; Label69: TLabel; DBEdit27: TDBEdit; DBEdit28: TDBEdit; DBEdit29: TDBEdit; DBEdit30: TDBEdit; DBEdit50: TDBEdit; DBEdit51: TDBEdit; bsSkinGroupBox5: TbsSkinGroupBox; Label59: TLabel; DBEdit21: TDBEdit; Label70: TLabel; wwDBComboBox3: TwwDBComboBox; bsSkinButton23: TbsSkinButton; bsSkinDBCheckRadioBox18: TbsSkinDBCheckRadioBox; dxDBGrid1Column5: TdxDBGridColumn; dxDBGrid1Column6: TdxDBGridColumn; Label71: TLabel; DBComboBoxEh1: TDBComboBoxEh; Label72: TLabel; DBEdit31: TDBEdit; bsSkinButton24: TbsSkinButton; bsSkinButton25: TbsSkinButton; bsSkinDBCheckRadioBox19: TbsSkinDBCheckRadioBox; Label1: TLabel; bsSkinDBComboBox1: TbsSkinDBComboBox; bsSkinButton26: TbsSkinButton; bsSkinGroupBox6: TbsSkinGroupBox; Label74: TLabel; DBEdit32: TDBEdit; Label75: TLabel; PopupMenu1: TPopupMenu; N16: TMenuItem; dxDBGrid1Column7: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridColumn; dxDBGrid1Column9: TdxDBGridColumn; dxDBGrid1Column10: TdxDBGridColumn; dxDBGrid1Column11: TdxDBGridColumn; dxDBGrid1Column12: TdxDBGridColumn; dxDBGrid1Column13: TdxDBGridColumn; dxDBGrid1Column14: TdxDBGridColumn; dxDBGrid1Column15: TdxDBGridColumn; dxDBGrid1Column16: TdxDBGridColumn; dxDBGrid1Column17: TdxDBGridColumn; dxDBGrid1Column18: TdxDBGridColumn; dxDBGrid1Column19: TdxDBGridColumn; dxDBGrid1Column20: TdxDBGridColumn; dxDBGrid1Column21: TdxDBGridColumn; Label76: TLabel; DBEdit33: TDBEdit; DBEdit46: TDBEdit; Label82: TLabel; DBEdit45: TDBEdit; bsSkinDBCheckRadioBox20: TbsSkinDBCheckRadioBox; bsSkinGroupBox7: TbsSkinGroupBox; Label78: TLabel; wwDBComboBox4: TwwDBComboBox; Label80: TLabel; wwDBComboBox5: TwwDBComboBox; Label81: TLabel; DBEdit34: TDBEdit; cxGrid1DBTableView1: TcxGridDBTableView; cxGrid1Level1: TcxGridLevel; cxGrid1: TcxGrid; t_crm_client_Invoice: TADOQuery; t_crm_client_Invoice1: TDataSource; cxGrid1DBTableView1DBColumn1: TcxGridDBColumn; cxDBNavigator1: TcxDBNavigator; cxGrid1DBTableView1DBColumn2: TcxGridDBColumn; cxGrid1DBTableView1DBColumn3: TcxGridDBColumn; cxGrid1DBTableView1DBColumn4: TcxGridDBColumn; cxGrid1DBTableView1DBColumn5: TcxGridDBColumn; bsSkinDBCheckRadioBox21: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox22: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox23: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox24: TbsSkinDBCheckRadioBox; Label84: TLabel; Label85: TLabel; ComboBox1: TComboBox; wwDBDateTimePicker8: TwwDBDateTimePicker; Label83: TLabel; wwDBDateTimePicker9: TwwDBDateTimePicker; Label87: TLabel; wwDBDateTimePicker10: TwwDBDateTimePicker; bsSkinTabSheet6: TbsSkinTabSheet; t_crm_client_yard: TADOQuery; t_crm_client_yard1: TDataSource; wwDBGrid1: TwwDBGrid; t_crm_client_yardID: TAutoIncField; t_crm_client_yardDSDesigner: TStringField; t_crm_client_yardDSDesigner2: TStringField; t_crm_client_yardDSDesigner3: TBooleanField; t_crm_client_yardDSDesigner4: TDateTimeField; t_crm_client_yardDSDesigner5: TStringField; wwDBLookupCombo3: TwwDBLookupCombo; Label88: TLabel; DBEdit47: TDBEdit; Label89: TLabel; DBEdit48: TDBEdit; DBEdit49: TDBEdit; Label90: TLabel; DBNumberEditEh1: TDBNumberEditEh; Label92: TLabel; DBEdit52: TDBEdit; Label93: TLabel; DBEdit53: TDBEdit; Label94: TLabel; DBEdit54: TDBEdit; Label95: TLabel; DBEdit56: TDBEdit; Label96: TLabel; DBEdit57: TDBEdit; Label97: TLabel; t_sys_country_qycode: TADOQuery; t_sys_country_qycodeDSDesigner: TStringField; t_sys_country_code: TADOQuery; t_sys_country_codeDSDesigner: TStringField; wwDBLookupCombo21: TwwDBLookupCombo; Label98: TLabel; wwDBLookupCombo1: TwwDBLookupCombo; Label99: TLabel; DBEdit58: TDBEdit; bsSkinDBCheckRadioBox25: TbsSkinDBCheckRadioBox; procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure client_filtered(str:string); procedure bsSkinCheckRadioBox2Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure t_crm_clientAfterInsert(DataSet: TDataSet); procedure t_crm_clientBeforePost(DataSet: TDataSet); 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 DBEdit10KeyPress(Sender: TObject; var Key: Char); procedure DBEdit9KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo14KeyPress(Sender: TObject; var Key: Char); procedure bsSkinDBCheckRadioBox1KeyPress(Sender: TObject; var Key: Char); procedure bsSkinDBCheckRadioBox2KeyPress(Sender: TObject; var Key: Char); procedure bsSkinDBCheckRadioBox3KeyPress(Sender: TObject; var Key: Char); procedure bsSkinDBCheckRadioBox4KeyPress(Sender: TObject; var Key: Char); procedure bsSkinDBCheckRadioBox11KeyPress(Sender: TObject; var Key: Char); procedure bsSkinDBCheckRadioBox9KeyPress(Sender: TObject; var Key: Char); procedure bsSkinDBCheckRadioBox8KeyPress(Sender: TObject; var Key: Char); procedure bsSkinDBCheckRadioBox7KeyPress(Sender: TObject; var Key: Char); procedure bsSkinDBCheckRadioBox6KeyPress(Sender: TObject; var Key: Char); procedure bsSkinDBCheckRadioBox5KeyPress(Sender: TObject; var Key: Char); procedure bsSkinDBCheckRadioBox12KeyPress(Sender: TObject; var Key: Char); procedure bsSkinDBCheckRadioBox10KeyPress(Sender: TObject; var Key: Char); procedure t_crm_clientDeleteError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction); procedure t_crm_clientPostError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction); procedure t_crm_clientAfterScroll(DataSet: TDataSet); procedure dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure t_crm_clientBeforeDelete(DataSet: TDataSet); procedure DBEdit1KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo1KeyPress(Sender: TObject; var Key: Char); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinPanel2Resize(Sender: TObject); procedure t_crm_client_limitedAfterInsert(DataSet: TDataSet); procedure t_crm_client_limitedBeforeInsert(DataSet: TDataSet); procedure bsSkinDBCheckRadioBox13KeyPress(Sender: TObject; var Key: Char); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure wwDBComboBox1KeyPress(Sender: TObject; var Key: Char); procedure t_crm_clientAfterPost(DataSet: TDataSet); procedure t_crm_clientBeforeCancel(DataSet: TDataSet); procedure t_crm_clientBeforeEdit(DataSet: TDataSet); procedure t_crm_clientBeforeInsert(DataSet: TDataSet); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure bsSkinButton15Click(Sender: TObject); procedure wwDBDateTimePicker5KeyPress(Sender: TObject; var Key: Char); procedure t_crm_client_salesAfterInsert(DataSet: TDataSet); procedure bsSkinButton17Click(Sender: TObject); procedure bsSkinButton16Click(Sender: TObject); procedure bsSkinButton18Click(Sender: TObject); procedure bsSkinButton19Click(Sender: TObject); procedure bsSkinButton20Click(Sender: TObject); procedure bsSkinButton21Click(Sender: TObject); procedure t_crm_client_salesBeforePost(DataSet: TDataSet); procedure t_crm_client_salesBeforeDelete(DataSet: TDataSet); procedure t_crm_client_salesBeforeEdit(DataSet: TDataSet); procedure t_crm_client_salesBeforeInsert(DataSet: TDataSet); procedure bsSkinButton22Click(Sender: TObject); procedure wwDBComboBox13Change(Sender: TObject); procedure wwDBComboBox15Change(Sender: TObject); procedure bsSkinButton23Click(Sender: TObject); procedure bsSkinButton24Click(Sender: TObject); procedure bsSkinButton25Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure t_crm_client_linkmanNewRecord(DataSet: TDataSet); procedure bsSkinButton26Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure t_crm_client_salesAfterPost(DataSet: TDataSet); procedure ComboBox1KeyPress(Sender: TObject; var Key: Char); procedure wwDBDateTimePicker8KeyPress(Sender: TObject; var Key: Char); procedure wwDBDateTimePicker9KeyPress(Sender: TObject; var Key: Char); procedure wwDBDateTimePicker10KeyPress(Sender: TObject; var Key: Char); procedure t_crm_client_yardNewRecord(DataSet: TDataSet); procedure wwDBLookupCombo21Enter(Sender: TObject); procedure wwDBLookupCombo21Exit(Sender: TObject); procedure wwDBLookupCombo1Enter(Sender: TObject); procedure DBEdit57Exit(Sender: TObject); procedure wwDBLookupCombo1Exit(Sender: TObject); procedure wwDBLookupCombo1MouseEnter(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_crm_client: Tfrm_crm_client; frm_crm_client_num:integer; implementation uses u_main, my_sys_function, u_data_share, my_sys_chat; {$R *.dfm} procedure Tfrm_crm_client.client_filtered(str:string); begin t_crm_client.Filtered:=false; t_crm_client.Filter:=str+'=1'; t_crm_client.Filtered:=true; end; procedure Tfrm_crm_client.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_crm_client.bsSkinButton1Click(Sender: TObject); begin t_crm_client.Insert; end; procedure Tfrm_crm_client.bsSkinButton2Click(Sender: TObject); var LengthQ,PosQ,i:Integer; s:string; begin //为防止改动太多,这里不做字符判断 //若是USCI,则代码为18位字母或数字(注意校验空格),不接受其他字符,发货人代码类型若是OC,则代码为9位字母或数字(注意校验空格),不接受其他字符。 t_crm_client.Active:=True; t_crm_client.Edit; if trim(wwDBLookupCombo1.DisplayValue)<>'' then begin LengthQ :=Length(t_crm_client.fieldbyname('企业代码').AsString); PosQ:=Pos('+',t_crm_client.fieldbyname('企业代码').AsString); if PosQ>0 then begin s:=Copy(t_crm_client.fieldbyname('企业代码').AsString,PosQ+1,LengthQ-POSQ+1); for i:=1 to Length(s) do begin if not ( s[i] in ['0'..'9','A'..'Z']) then begin ShowMessage('企业代码必须为数字和大写字母'); DBEdit57.SetFocus; Exit; end; end; end else begin ShowMessage('企业代码格式不正确!应该是代码类型+企业代码!'); DBEdit5.SetFocus; Exit; end; if Copy(t_crm_client.FieldByName('企业代码').AsString,0,PosQ-1)<>wwDBLookupCombo1.DisplayValue then begin ShowMessage('代码类型不符!'); DBEdit57.SetFocus; Exit; end; if Trim(t_crm_client.FieldByName('企业代码类型').AsString)='USCI' then begin if Length(s)<>18 then begin ShowMessage('USCI类型企业代码必须为18位!您现在输入的是:'+IntToStr(Length(s))+'位,请检查!'); DBEdit57.SetFocus; Exit; end; end; if Trim(t_crm_client.FieldByName('企业代码类型').AsString)='OC' then begin if Length(s)<>9 then begin ShowMessage('OC类型企业代码必须为9位!您现在输入的是:'+IntToStr(Length(s))+'位,请检查!'); DBEdit57.SetFocus; Exit; end; end; end; if trim(wwDBLookupCombo1.DisplayValue)<>'' then begin if PosQ=0 then t_crm_client.FieldByName('企业代码').AsString:=wwDBLookupCombo1.DisplayValue+'+'+DBEdit57.text; end; table_post(t_crm_client); end; procedure Tfrm_crm_client.bsSkinButton4Click(Sender: TObject); begin table_delete(t_crm_client); end; procedure Tfrm_crm_client.bsSkinButton3Click(Sender: TObject); begin table_cancel(t_crm_client); end; procedure Tfrm_crm_client.bsSkinCheckRadioBox2Click(Sender: TObject); begin t_crm_client.Filtered:=false; end; procedure Tfrm_crm_client.FormShow(Sender: TObject); begin { if (wwDBComboBox15.text='固定')and(bsSkinGroupBox13.Visible) then DBEdit61.Visible:=true else DBEdit61.Visible:=false ; lblmonth.Visible:=DBEdit61.Visible ; lbldate.Visible:=DBEdit61.Visible ; } { if not strtobool(get_parameters_value(4,'false')) then begin bsSkinTabSheet2.TabVisible:=false; end else begin } t_sys_country_code.Open; bsSkinTabSheet2.TabVisible:=true; t_crm_client_limited.open; {$IFDEF KHJSXX} {$ELSE} crmsalse_sheet.tabvisible:=false; {$ENDIF} // end; end; procedure Tfrm_crm_client.FormClose(Sender: TObject; var Action: TCloseAction); begin with frm_data_share do begin t_crm_client.requery; t_crm_client_all.requery; t_crm_client_ship.requery; t_crm_client_changzhan.requery; t_crm_client_truck.requery; t_crm_client_hangkong.requery; t_crm_client_baoguan.requery; t_crm_client_weituo.requery; t_crm_client_daili.requery; t_crm_client_huodai.requery; t_crm_client_shiper.requery; t_crm_client_shouhuo.requery; t_crm_client_tongzhi.requery; t_crm_client_other.requery; end; frm_crm_client.Hide; frm_crm_client.ManualFloat(frm_crm_client.BoundsRect ); frm_main.freeTabs('frm_crm_client'); action:=cafree; frm_crm_client:=nil; end; procedure Tfrm_crm_client.t_crm_clientAfterInsert(DataSet: TDataSet); begin t_crm_client['客户性质']:='其他'; frm_crm_client_num:=1; t_crm_client['结费类型']:='约定天数'; t_crm_client['录入人']:=employee; end; procedure Tfrm_crm_client.t_crm_clientBeforePost(DataSet: TDataSet); var aQuery:TAdoQuery; begin table_before_post(t_crm_client,'代码'); table_before_post(t_crm_client,'客户简称'); table_before_post(t_crm_client,'客户全称'); if (t_crm_client.fieldbyname('船公司').asboolean=false)and (t_crm_client.fieldbyname('场站').asboolean=false)and (t_crm_client.fieldbyname('车队').asboolean=false)and (t_crm_client.fieldbyname('报关行').asboolean=false)and (t_crm_client.fieldbyname('委托单位').asboolean=false)and (t_crm_client.fieldbyname('代理').asboolean=false)and (t_crm_client.fieldbyname('货代').asboolean=false)and (t_crm_client.fieldbyname('收货人').asboolean=false)and (t_crm_client.fieldbyname('发货人').asboolean=false)and (t_crm_client.fieldbyname('通知人').asboolean=false)and (t_crm_client.fieldbyname('航空公司').asboolean=false)and (t_crm_client.fieldbyname('其他客户').asboolean=false)and (t_crm_client.fieldbyname('国内代理').asboolean=false)and (t_crm_client.fieldbyname('仓库').asboolean=false)and (t_crm_client.fieldbyname('快递公司').asboolean=false)then begin showmessage('船公司、场站、车队、报关行、委托单位、代理、货代、收货人、发货人、通知人、航空公司、其他客户、快递公司,仓库必须选择其一!'); abort; end; if t_crm_client.State=dsedit then begin if t_crm_client.fieldbyname('客户简称').OldValue<>t_crm_client.fieldbyname('客户简称').AsString then begin frm_crm_client_num:=2; end else frm_crm_client_num:=0; end; aQuery:=CreateAdoQuery; try with aQuery do begin sql.Text:='select count(*) as ct from t_crm_client where 客户简称<>'''+t_crm_client.fieldbyname('客户简称').AsString+''' and 客户全称='''+t_crm_client.fieldbyname('客户全称').AsString+''''; open; if fieldbyname('ct').AsInteger<>0 then showmessage('客户全称重复!'); end; finally freeandnil(aQuery); end; end; procedure Tfrm_crm_client.DBEdit4KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit1); end; procedure Tfrm_crm_client.DBEdit5KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit2); end; procedure Tfrm_crm_client.DBEdit6KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit7); end; procedure Tfrm_crm_client.DBEdit7KeyPress(Sender: TObject; var Key: Char); begin key_wwDBDateTimePicker(key,wwDBDateTimePicker5); end; procedure Tfrm_crm_client.DBEdit8KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit10); end; procedure Tfrm_crm_client.DBEdit10KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit9); end; procedure Tfrm_crm_client.DBEdit9KeyPress(Sender: TObject; var Key: Char); begin key_RxDBLookupCombo(Key,RxDBLookupCombo14); end; procedure Tfrm_crm_client.RxDBLookupCombo14KeyPress(Sender: TObject; var Key: Char); begin key_RxDBLookupCombo(Key,RxDBLookupCombo1); end; procedure Tfrm_crm_client.bsSkinDBCheckRadioBox1KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox2); end; procedure Tfrm_crm_client.bsSkinDBCheckRadioBox2KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox3); end; procedure Tfrm_crm_client.bsSkinDBCheckRadioBox3KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox4); end; procedure Tfrm_crm_client.bsSkinDBCheckRadioBox4KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox11); end; procedure Tfrm_crm_client.bsSkinDBCheckRadioBox11KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox9); end; procedure Tfrm_crm_client.bsSkinDBCheckRadioBox9KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox8); end; procedure Tfrm_crm_client.bsSkinDBCheckRadioBox8KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox7); end; procedure Tfrm_crm_client.bsSkinDBCheckRadioBox7KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox6); end; procedure Tfrm_crm_client.bsSkinDBCheckRadioBox6KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox5); end; procedure Tfrm_crm_client.bsSkinDBCheckRadioBox5KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox12); end; procedure Tfrm_crm_client.bsSkinDBCheckRadioBox12KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox10); end; procedure Tfrm_crm_client.bsSkinDBCheckRadioBox10KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox13); end; procedure Tfrm_crm_client.t_crm_clientDeleteError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction); begin showmessage('客户已经使用,不能删除!!'); end; procedure Tfrm_crm_client.t_crm_clientPostError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction); begin showmessage('客户代码重复,不能保存!'); end; procedure Tfrm_crm_client.t_crm_clientAfterScroll(DataSet: TDataSet); begin if v_all_client.IsEmpty then begin DBEdit4.ReadOnly:=false; DBEdit5.ReadOnly:=false; end else begin DBEdit4.ReadOnly:=true; DBEdit5.ReadOnly:=true; end; end; procedure Tfrm_crm_client.dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,t_crm_client,'代码'); end; procedure Tfrm_crm_client.t_crm_clientBeforeDelete(DataSet: TDataSet); begin if not if_open('202') then begin showmessage('对不起你没有此模块的操作权限!'); abort; end; if do_data('0008',t_crm_client.fieldbyname('录入人').asstring,t_crm_client.fieldbyname('揽货人').asstring,t_crm_client.fieldbyname('客服员').asstring,'','','')=false then begin showmessage('对不起你无权修改此数据!!'); abort; end; if not v_all_client.IsEmpty then begin showmessage('当前客户已经使用,不能删除!!'); abort; end; if strtobool(get_parameters_value(188,'false')) then begin if t_crm_client.State<>dsinsert then SendMsg_gonggao('54',''); end; end; procedure Tfrm_crm_client.DBEdit1KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit5); end; procedure Tfrm_crm_client.RxDBLookupCombo1KeyPress(Sender: TObject; var Key: Char); begin key_bsSkinDBCheckRadioBox(Key,bsSkinDBCheckRadioBox1); end; procedure Tfrm_crm_client.bsSkinButton6Click(Sender: TObject); begin table_post(t_crm_client); IF t_crm_client.IsEmpty then exit; frm_data_share.t_sys_department.first; while not frm_data_share.t_sys_department.eof do begin if not t_crm_client_limited.Locate('部门名称',frm_data_share.t_sys_department.fieldbyname('部门名称').asstring,[])then begin t_crm_client_limited.insert; t_crm_client_limited['部门名称']:=frm_data_share.t_sys_department.fieldbyname('部门名称').asstring; t_crm_client_limited.post; end; frm_data_share.t_sys_department.next; end; end; procedure Tfrm_crm_client.bsSkinButton10Click(Sender: TObject); begin table_post(t_crm_client); IF t_crm_client.IsEmpty then exit; if not t_crm_client_limited.Locate('部门名称',frm_data_share.t_sys_department.fieldbyname('部门名称').asstring,[])then begin t_crm_client_limited.insert; t_crm_client_limited['部门名称']:=frm_data_share.t_sys_department.fieldbyname('部门名称').asstring; t_crm_client_limited.post; end; end; procedure Tfrm_crm_client.bsSkinButton11Click(Sender: TObject); begin if t_crm_client_limited.IsEmpty then exit; t_crm_client_limited.Delete; end; procedure Tfrm_crm_client.bsSkinPanel2Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel2.Width/8); bsSkinButton1.Width:=i; bsSkinButton2.Width:=i; bsSkinButton4.Width:=i; bsSkinButton3.Width:=i; bsSkinButton8.Width:=i; bsSkinButton9.Width:=i; bsSkinButton15.Width:=i; end; procedure Tfrm_crm_client.t_crm_client_limitedAfterInsert( DataSet: TDataSet); begin t_crm_client_limited['客户简称']:=t_crm_client['客户简称']; end; procedure Tfrm_crm_client.t_crm_client_limitedBeforeInsert( DataSet: TDataSet); begin table_post(t_crm_client); end; procedure Tfrm_crm_client.bsSkinDBCheckRadioBox13KeyPress(Sender: TObject; var Key: Char); begin key_DBMemo(Key,DBMemo1); end; procedure Tfrm_crm_client.bsSkinButton9Click(Sender: TObject); begin wwDBComboBox1.text:=''; Edit1.text:=''; Edit2.text:=''; Edit3.text:=''; RxDBLookupCombo2.ClearValue; end; procedure Tfrm_crm_client.bsSkinButton8Click(Sender: TObject); var str:widestring; begin str:='where 客户性质<>'+''''+'目标'+''''; if wwDBComboBox1.text<>'' then begin str:=str+' and '+wwDBComboBox1.text+'=1'; end; if Edit1.text<>''then begin str:=str+' and 代码 like '+''''+'%'+Edit1.text+'%'+''''; end; if Edit2.text<>''then begin str:=str+' and 客户简称 like '+''''+'%'+Edit2.text+'%'+''''; end; if Edit3.text<>''then begin str:=str+' and 客户全称 like '+''''+'%'+Edit3.text+'%'+''''; end; if RxDBLookupCombo2.DisplayValue<>''then begin str:=str+' and 揽货人='+''''+RxDBLookupCombo2.DisplayValue+''''; end; if Edit4.text<>''then begin str:=str+' and 国家 like '+''''+'%'+Edit4.text+'%'+''''; end; if Edit5.text<>''then begin str:=str+' and 城市 like '+''''+'%'+Edit5.text+'%'+''''; end; if trim(ComboBox1.Text)<>'' then begin str:=str+' and 客户简称 in ( select 客户简称 from t_crm_client_sales where 结费类型='''+ComboBox1.Text+''')' ; end; if trim(wwDBDateTimePicker8.text)<>'' then begin str:=str+' and 客户简称 in ( select 客户简称 from t_crm_client_sales where 结束日期<='''+ wwDBDateTimePicker8.text+''')' ; end; if (wwDBDateTimePicker9.text<>'') and (wwDBDateTimePicker10.text<>'') then begin str:=str+' and 录入日期>='+''''+wwDBDateTimePicker9.text+''''; str:=str+' and 录入日期<='+''''+wwDBDateTimePicker10.text+''''; end else if wwDBDateTimePicker9.text<>''then str:=str+' and 录入日期>='+''''+wwDBDateTimePicker9.text+'''' else if wwDBDateTimePicker10.text<>''then str:=str+' and 录入日期<='+''''+wwDBDateTimePicker10.text+''''; t_crm_client.close; t_crm_client.sql.clear; t_crm_client.sql.add('select * from t_crm_client '+str+' and '+open_data('0008','录入人','揽货人','客服员','no','no')+' order by 代码'); t_crm_client.open; end; procedure Tfrm_crm_client.wwDBComboBox1KeyPress(Sender: TObject; var Key: Char); begin IF key=#13 then begin key:=#0; frm_crm_client.bsSkinButton8Click(Sender); end; end; procedure Tfrm_crm_client.t_crm_clientAfterPost(DataSet: TDataSet); begin if strtobool(get_parameters_value(188,'false')) then begin if frm_crm_client_num=1 then SendMsg_gonggao('53','新客户:'+t_crm_client['代码']+','+t_crm_client['客户简称']); if frm_crm_client_num=2 then SendMsg_gonggao('54',''); frm_data_share.t_crm_client.Requery; frm_data_share.t_crm_client_all.Requery; end; frm_crm_client_num:=0; end; procedure Tfrm_crm_client.t_crm_clientBeforeCancel(DataSet: TDataSet); begin frm_crm_client_num:=0; end; procedure Tfrm_crm_client.t_crm_clientBeforeEdit(DataSet: TDataSet); begin if not if_open('283') then begin showmessage('对不起你没有此模块的操作权限!'); abort; end; if do_data('0008',t_crm_client.fieldbyname('录入人').asstring,t_crm_client.fieldbyname('揽货人').asstring,t_crm_client.fieldbyname('客服员').asstring,'','','')=false then begin showmessage('对不起你无权修改此数据!!'); abort; end; end; procedure Tfrm_crm_client.t_crm_clientBeforeInsert(DataSet: TDataSet); begin if not if_open('202') then begin showmessage('对不起你没有此模块的操作权限!'); abort; end; end; procedure Tfrm_crm_client.bsSkinButton7Click(Sender: TObject); begin t_crm_client_linkman.insert; end; procedure Tfrm_crm_client.bsSkinButton12Click(Sender: TObject); begin table_post(t_crm_client_linkman); end; procedure Tfrm_crm_client.bsSkinButton13Click(Sender: TObject); begin table_delete(t_crm_client_linkman); end; procedure Tfrm_crm_client.bsSkinButton14Click(Sender: TObject); begin table_cancel(t_crm_client_linkman); end; procedure Tfrm_crm_client.bsSkinButton15Click(Sender: TObject); begin if not if_open('202') then begin showmessage('对不起你没有此模块的操作权限!'); abort; end; sys_print('客户资料打印',2,nil,nil,nil,nil,t_crm_client1,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_crm_client.wwDBDateTimePicker5KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit8); end; procedure Tfrm_crm_client.t_crm_client_salesAfterInsert(DataSet: TDataSet); begin t_crm_client_sales['客户简称']:=t_crm_client['客户简称']; t_crm_client_sales['揽货人']:=t_crm_client['揽货人']; t_crm_client_sales['状态']:='新建'; t_crm_client_sales['结费金额']:=0; t_crm_client_sales['结费期限']:=0; t_crm_client_sales['结费金额']:=0; t_crm_client_sales['结费日期']:=0; t_crm_client_sales['日期模式']:='不固定'; end; procedure Tfrm_crm_client.bsSkinButton17Click(Sender: TObject); begin t_crm_client_sales.Prior ; end; procedure Tfrm_crm_client.bsSkinButton16Click(Sender: TObject); begin t_crm_client_sales.Next ; end; procedure Tfrm_crm_client.bsSkinButton18Click(Sender: TObject); begin t_crm_client_sales.insert; end; procedure Tfrm_crm_client.bsSkinButton19Click(Sender: TObject); begin table_post(t_crm_client_sales); end; procedure Tfrm_crm_client.bsSkinButton20Click(Sender: TObject); begin table_delete(t_crm_client_sales); end; procedure Tfrm_crm_client.bsSkinButton21Click(Sender: TObject); begin table_cancel(t_crm_client_sales); end; procedure Tfrm_crm_client.t_crm_client_salesBeforePost(DataSet: TDataSet); begin table_before_post(t_crm_client_sales,'揽货人'); table_before_post(t_crm_client_sales,'开始日期'); table_before_post(t_crm_client_sales,'结束日期'); if not DataSet.FieldByName('是否特批客户').AsBoolean then begin if DataSet.FieldByName('结费类型').AsString='' then begin ShowMessage('结费模式不能为空!'); Abort; end; end; if DataSet.FieldByName('结费类型').AsString='约定天数' then begin if DataSet.FieldByName('结费期限').AsInteger=0 then begin ShowMessage('天数不能为空!'); Abort; end; end; if DataSet.FieldByName('结费类型').AsString='约定时间' then begin if DataSet.FieldByName('类型模式').AsString='' then begin ShowMessage('间隔月数不能为空!'); Abort; end; if DataSet.FieldByName('日期模式').AsString='不固定' then DataSet.FieldByName('结费日期').asinteger:=0 ; end; if DataSet.FieldByName('结费类型').AsString='分阶段付费' then begin if DataSet.FieldByName('类型模式').AsString='' then begin ShowMessage('间隔月数不能为空!'); Abort; end; if DataSet.FieldByName('结费结束').AsInteger=0 then begin ShowMessage('分阶段付费不能为空!'); Abort; end; end; end; procedure Tfrm_crm_client.t_crm_client_salesBeforeDelete( DataSet: TDataSet); begin if t_crm_client_sales.FieldByName('状态').AsString='审核' then begin showmessage('对不起此费用账期已审核,不能修改!!'); abort; end; if do_data('0008',t_crm_client.fieldbyname('录入人').asstring,t_crm_client.fieldbyname('揽货人').asstring,'','','','')=false then begin showmessage('对不起你无权修改此数据!!'); abort; end; end; procedure Tfrm_crm_client.t_crm_client_salesBeforeEdit(DataSet: TDataSet); begin if t_crm_client_sales.FieldByName('状态').AsString='审核' then begin showmessage('对不起此费用账期已审核,不能修改!!'); abort; end; if do_data('0008',t_crm_client.fieldbyname('录入人').asstring,t_crm_client.fieldbyname('揽货人').asstring,'','','','')=false then begin showmessage('对不起你无权修改此数据!!'); abort; end; end; procedure Tfrm_crm_client.t_crm_client_salesBeforeInsert( DataSet: TDataSet); begin table_post(t_crm_client); end; procedure Tfrm_crm_client.bsSkinButton22Click(Sender: TObject); begin frm_main.view_momo(t_crm_client1,'备注'); end; procedure Tfrm_crm_client.wwDBComboBox13Change(Sender: TObject); begin if wwDBComboBox13.Text='约定天数' then begin bsSkinGroupBox12.Visible:=true ; bsSkinGroupBox13.Visible:=false ; end else if wwDBComboBox13.Text='约定时间' then begin bsSkinGroupBox12.Visible:=false ; bsSkinGroupBox13.Visible:=true ; end else begin //现结现买 或其他 bsSkinGroupBox12.Visible:=false ; bsSkinGroupBox13.Visible:=false ; end end; procedure Tfrm_crm_client.wwDBComboBox15Change(Sender: TObject); begin { if (wwDBComboBox15.text='固定')and(bsSkinGroupBox13.Visible) then DBEdit61.Visible:=true else DBEdit61.Visible:=false ; lblmonth.Visible:=DBEdit61.Visible ; lbldate.Visible:=DBEdit61.Visible ; } end; procedure Tfrm_crm_client.bsSkinButton23Click(Sender: TObject); var i:Integer; begin if not if_open('283') then begin showmessage('对不起你没有此模块的操作权限!'); abort; end; if do_data('0008',t_crm_client.fieldbyname('录入人').asstring,t_crm_client.fieldbyname('揽货人').asstring,t_crm_client.fieldbyname('客服员').asstring,'','','')=false then begin showmessage('对不起你无权修改此数据!!'); abort; end; if strtobool(get_parameters_value(154,'false')) then begin if t_crm_client.fieldbyname('网上查询').AsBoolean then begin frm_main.qryweb.close; frm_main.qryweb.sql.clear; frm_main.qryweb.sql.add('delete from t_crm_client where 客户简称='''+t_crm_client.fieldbyname('客户简称').AsString+''''); frm_main.qryweb.ExecSQL; t_crm_client.Edit; t_crm_client['网上查询']:=0; t_crm_client.post; end else begin frm_main.qryweb.close; frm_main.qryweb.sql.clear; frm_main.qryweb.sql.add('select * from t_crm_client where 客户简称='''+t_crm_client.fieldbyname('客户简称').AsString+''''); frm_main.qryweb.open; if frm_main.qryweb.IsEmpty then begin frm_main.qryweb.Insert; for i:=0 to frm_main.qryweb.FieldCount-1 do begin if t_crm_client.FindField(frm_main.qryweb.Fields[i].fieldname)<>nil then frm_main.qryweb.Fields[i].Value:=t_crm_client.fieldbyname(frm_main.qryweb.Fields[i].FieldName).Value; end; frm_main.qryweb.post; end else begin frm_main.qryweb.Edit; for i:=0 to frm_main.qryweb.FieldCount-1 do begin if t_crm_client.FindField(frm_main.qryweb.Fields[i].fieldname)<>nil then frm_main.qryweb.Fields[i].Value:=t_crm_client.fieldbyname(frm_main.qryweb.Fields[i].FieldName).Value; end; frm_main.qryweb.post; end; t_crm_client.Edit; t_crm_client['网上查询']:=1; t_crm_client.post; end; end; end; procedure Tfrm_crm_client.bsSkinButton24Click(Sender: TObject); begin t_crm_client.Edit; DBMemo1.Clear; DBMemo1.Lines.Add(t_crm_client.fieldbyname('英文全称').asstring); DBMemo1.Lines.Add('ADDR:'+t_crm_client.fieldbyname('英文地址').asstring); DBMemo1.Lines.Add('TEL:'+t_crm_client.fieldbyname('电话').asstring); DBMemo1.Lines.Add('FAX:'+t_crm_client.fieldbyname('传真').asstring); DBMemo4.Clear; DBMemo4.Lines.Add(t_crm_client.fieldbyname('英文全称').asstring); DBMemo4.Lines.Add('ADDR:'+t_crm_client.fieldbyname('英文地址').asstring); DBMemo4.Lines.Add('TEL:'+t_crm_client.fieldbyname('电话').asstring); DBMemo4.Lines.Add('FAX:'+t_crm_client.fieldbyname('传真').asstring); t_crm_client.Post; end; procedure Tfrm_crm_client.bsSkinButton25Click(Sender: TObject); begin if trim(t_crm_client.fieldbyname('客户全称').asstring)<>'' then begin t_crm_client.Edit; t_crm_client.fieldbyname('发票抬头').asstring:=t_crm_client.fieldbyname('客户全称').asstring; t_crm_client.Post; end; end; procedure Tfrm_crm_client.FormCreate(Sender: TObject); begin t_crm_client.close; t_crm_client.sql.clear; t_crm_client.sql.add('select * from t_crm_client where 客户性质<>''目标'' and '+open_data('0008','录入人','揽货人','客服员','no','no')+' order by 代码'); t_crm_client.open; t_crm_client.Edit; v_all_client.open; t_crm_client_linkman.Open; t_crm_client_sales.Open ; t_crm_client_Invoice.Open; t_crm_client_yard.Open; frm_data_share.t_sys_employee.Requery(); frm_data_share.t_sys_department.Requery(); end; procedure Tfrm_crm_client.t_crm_client_linkmanNewRecord(DataSet: TDataSet); begin t_crm_client_linkman.FieldByName('性别').AsString:='男'; end; procedure Tfrm_crm_client.bsSkinButton26Click(Sender: TObject); var aAdoQuery,aAdoQuerySel:TAdoQuery; begin aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;sql.Clear; sql.Add('Update t_op_seae set 结费类型=:结费类型'); sql.Add('where 委托单位=:委托单位 and 揽货人=:揽货人 and 开船日期>=:Date1 and 开船日期<=:date2 '); finally end; aAdoQuerySel:=CreateAdoQuery; with aAdoQuerySel do try Close;sql.Clear; sql.Add('select 客户简称,开始日期,结束日期,结费类型,揽货人 from t_crm_client_sales'); sql.Add('where 结束日期>=:Date1 and 结费类型<>'''''); Parameters.ParamByName('Date1').Value:='2012-08-25'; Open;First; while not eof do begin aAdoQuery.Close; aAdoQuery.Parameters.ParamByName('委托单位').Value:=Trim(aAdoQuerySel.FieldByName('客户简称').AsString); aAdoQuery.Parameters.ParamByName('揽货人').Value:=Trim(aAdoQuerySel.FieldByName('揽货人').AsString); aAdoQuery.Parameters.ParamByName('结费类型').Value:=Trim(aAdoQuerySel.FieldByName('结费类型').AsString); aAdoQuery.Parameters.ParamByName('Date1').Value:=aAdoQuerySel.FieldByName('开始日期').Value; aAdoQuery.Parameters.ParamByName('Date2').Value:=aAdoQuerySel.FieldByName('结束日期').Value; aAdoQuery.ExecSQL; Next; end; finally Free; end; end; procedure Tfrm_crm_client.N16Click(Sender: TObject); begin grid_save_xls(dxdbgrid1); end; procedure Tfrm_crm_client.t_crm_client_salesAfterPost(DataSet: TDataSet); begin bsSkinButton26.OnClick(bsSkinButton26); end; procedure Tfrm_crm_client.ComboBox1KeyPress(Sender: TObject; var Key: Char); begin IF key=#13 then begin key:=#0; frm_crm_client.bsSkinButton8Click(Sender); end; end; procedure Tfrm_crm_client.wwDBDateTimePicker8KeyPress(Sender: TObject; var Key: Char); begin IF key=#13 then begin key:=#0; frm_crm_client.bsSkinButton8Click(Sender); end; end; procedure Tfrm_crm_client.wwDBDateTimePicker9KeyPress(Sender: TObject; var Key: Char); begin IF key=#13 then begin key:=#0; frm_crm_client.bsSkinButton8Click(Sender); end; end; procedure Tfrm_crm_client.wwDBDateTimePicker10KeyPress(Sender: TObject; var Key: Char); begin IF key=#13 then begin key:=#0; frm_crm_client.bsSkinButton8Click(Sender); end; end; procedure Tfrm_crm_client.t_crm_client_yardNewRecord(DataSet: TDataSet); begin t_crm_client_yard.FieldByName('是否默认').Value:=0; t_crm_client_yard.FieldByName('录入人').Value:=employee; t_crm_client_yard.FieldByName('录入日期').Value:=Now; end; procedure Tfrm_crm_client.wwDBLookupCombo21Enter(Sender: TObject); begin if not t_sys_country_code.Active then t_sys_country_code.Open; end; procedure Tfrm_crm_client.wwDBLookupCombo21Exit(Sender: TObject); begin if Trim(wwDBLookupCombo21.DisplayValue)='' then begin ShowMessage('您没有选择国家代码!'); wwDBLookupCombo21.SetFocus; Exit; end; with t_sys_country_qycode do begin Close; Parameters.ParamByName('国家代码').Value:=wwDBLookupCombo21.DisplayValue; Open; end; end; procedure Tfrm_crm_client.wwDBLookupCombo1Enter(Sender: TObject); begin if Trim(wwDBLookupCombo21.DisplayValue)='' then begin ShowMessage('您没有选择国家代码!'); wwDBLookupCombo21.SetFocus; Exit; end; with t_sys_country_qycode do begin Close; Parameters.ParamByName('国家代码').Value:=wwDBLookupCombo21.DisplayValue; Open; end; end; procedure Tfrm_crm_client.DBEdit57Exit(Sender: TObject); begin { if Trim(t_crm_client.FieldByName('企业代码类型').AsString)='USCI' then begin if Length(DBEdit57.Text)<>18 then begin ShowMessage('USCI类型企业代码必须为18位!您现在输入的是:'+IntToStr(Length(DBEdit57.Text))+'位,请检查!'); Exit; end; end; if Trim(t_crm_client.FieldByName('企业代码类型').AsString)='OC' then begin if Length(DBEdit57.Text)<>9 then begin ShowMessage('OC类型企业代码必须为9位!您现在输入的是:'+IntToStr(Length(DBEdit57.Text))+'位,请检查!'); Exit; end; end; } end; procedure Tfrm_crm_client.wwDBLookupCombo1Exit(Sender: TObject); var LengthQ,PosQ:Integer; s:string; begin t_crm_client.Active:=True; t_crm_client.Edit; LengthQ :=Length(t_crm_client.fieldbyname('企业代码').AsString); PosQ:=Pos('+',t_crm_client.fieldbyname('企业代码').AsString); if PosQ=0 then begin t_crm_client.FieldByName('企业代码').AsString:=wwDBLookupCombo1.DisplayValue+'+'+DBEdit57.text end else begin s:=Copy(t_crm_client.fieldbyname('企业代码').AsString,PosQ+1,LengthQ-POSQ+1); t_crm_client.FieldByName('企业代码').AsString:=wwDBLookupCombo1.DisplayValue+'+'+s; end; end; procedure Tfrm_crm_client.wwDBLookupCombo1MouseEnter(Sender: TObject); var LengthQ,PosQ:Integer; s:string; begin t_crm_client.Active:=True; t_crm_client.Edit; LengthQ :=Length(t_crm_client.fieldbyname('企业代码').AsString); PosQ:=Pos('+',t_crm_client.fieldbyname('企业代码').AsString); if PosQ=0 then begin t_crm_client.FieldByName('企业代码').AsString:=wwDBLookupCombo1.DisplayValue+'+'+DBEdit57.text end else begin s:=Copy(t_crm_client.fieldbyname('企业代码').AsString,PosQ+1,LengthQ-POSQ+1); t_crm_client.FieldByName('企业代码').AsString:=wwDBLookupCombo1.DisplayValue+'+'+s; end; end; end.