{$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,ComObj, cxStyles,DateUtil, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, cxNavigator, cxDBNavigator, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid; 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; 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; bsSkinDBCheckRadioBox20: TbsSkinDBCheckRadioBox; bsSkinButton26: TbsSkinButton; bsSkinDBCheckRadioBox21: TbsSkinDBCheckRadioBox; Label1: TLabel; DBEdit32: TDBEdit; bsSkinButton55: TbsSkinButton; ADOQuerySub: TADOQuery; Label75: TLabel; RxDBLookupCombo31: TRxDBLookupCombo; bsSkinTabSheet6: TbsSkinTabSheet; bsSkinPanel10: TbsSkinPanel; bsSkinButton27: TbsSkinButton; bsSkinButton28: TbsSkinButton; bsSkinButton29: TbsSkinButton; bsSkinButton30: TbsSkinButton; bsSkinButton31: TbsSkinButton; bsSkinButton32: TbsSkinButton; dxDBGrid6: TdxDBGrid; dxDBGridMaskColumn4: TdxDBGridMaskColumn; dxDBGridDateColumn1: TdxDBGridDateColumn; dxDBGridMaskColumn12: TdxDBGridMaskColumn; t_crm_client_sales_tmp: TADOQuery; ds_crm_client_sales_tmp1: TDataSource; Label76: TLabel; Label78: TLabel; wwDBDateTimePicker8: TwwDBDateTimePicker; wwDBDateTimePicker9: TwwDBDateTimePicker; Label80: TLabel; DBEdit33: TDBEdit; Label81: TLabel; DBEdit34: TDBEdit; Label82: TLabel; DBEdit45: TDBEdit; Label83: TLabel; DBEdit46: TDBEdit; Label84: TLabel; DBEdit47: TDBEdit; Label85: TLabel; DBEdit48: TDBEdit; bsSkinButton33: TbsSkinButton; OpenDialog1: TOpenDialog; dbedt1: TDBEdit; lbl2: TLabel; Label87: TLabel; DBEdit49: TDBEdit; Label88: TLabel; DBEdit52: TDBEdit; Label89: TLabel; DBComboBox1: TDBComboBox; DBMemo7: TDBMemo; Label90: TLabel; bskndbchckrdbxd: TbsSkinDBCheckRadioBox; Label92: TLabel; DBEdit53: TDBEdit; Label93: TLabel; DBEdit54: TDBEdit; RxDBLookupCombo14: TRxDBLookupCombo; RxDBLookupCombo1: TRxDBLookupCombo; Label94: TLabel; DBEdit56: TDBEdit; RxDBLookupCombo9: TRxDBLookupCombo; wwDBComboBox16: TwwDBComboBox; Label95: TLabel; Label96: TLabel; DBEdit57: TDBEdit; Label97: TLabel; Label98: TLabel; DBEdit58: TDBEdit; Label99: TLabel; DBEdit60: TDBEdit; bsSkinDBCheckRadioBox22: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox23: TbsSkinDBCheckRadioBox; t_crm_client_Invoice1: TDataSource; t_crm_client_Invoice: TADOQuery; cxGrid1: TcxGrid; cxGrid1DBTableView1: TcxGridDBTableView; cxGrid1DBTableView1DBColumn1: TcxGridDBColumn; cxGrid1DBTableView1DBColumn2: TcxGridDBColumn; cxGrid1DBTableView1DBColumn3: TcxGridDBColumn; cxGrid1DBTableView1DBColumn4: TcxGridDBColumn; cxGrid1DBTableView1DBColumn5: TcxGridDBColumn; cxGrid1Level1: TcxGridLevel; DBNumberEditEh1: TDBNumberEditEh; Label74: TLabel; cxDBNavigator1: TcxDBNavigator; bsSkinDBCheckRadioBox24: TbsSkinDBCheckRadioBox; cxGrid1DBTableView1DBColumn6: TcxGridDBColumn; DBEdit62: TDBEdit; Label100: TLabel; dxDBGrid7: TdxDBGrid; dxDBGridMaskColumn3: TdxDBGridMaskColumn; dxDBGrid7Column2: TdxDBGridColumn; dxDBGrid7Column3: TdxDBGridColumn; dxDBGrid7Column4: TdxDBGridColumn; dxDBGrid7Column5: TdxDBGridColumn; dxDBGrid7Column6: TdxDBGridPickColumn; Label101: TLabel; Edit6: TEdit; 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 DBEdit2KeyPress(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 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 t_crm_client_salesAfterPost(DataSet: TDataSet); procedure bsSkinButton26Click(Sender: TObject); procedure bsSkinButton55Click(Sender: TObject); procedure bsSkinButton32Click(Sender: TObject); procedure bsSkinButton31Click(Sender: TObject); procedure bsSkinButton27Click(Sender: TObject); procedure bsSkinButton28Click(Sender: TObject); procedure bsSkinButton29Click(Sender: TObject); procedure bsSkinButton30Click(Sender: TObject); procedure t_crm_client_sales_tmpAfterInsert(DataSet: TDataSet); procedure t_crm_client_sales_tmpBeforePost(DataSet: TDataSet); procedure bsSkinButton33Click(Sender: TObject); procedure dxDBGrid1ChangeNode(Sender: TObject; OldNode, Node: TdxTreeListNode); procedure dxDBGrid1Click(Sender: TObject); procedure crmsalse_sheetShow(Sender: TObject); procedure RxDBLookupCombo14KeyPress(Sender: TObject; var Key: Char); procedure RxDBLookupCombo1Enter(Sender: TObject); procedure RxDBLookupCombo1Exit(Sender: TObject); procedure RxDBLookupCombo14Enter(Sender: TObject); procedure RxDBLookupCombo14Exit(Sender: TObject); procedure DBEdit4Exit(Sender: TObject); procedure wwDBComboBox16DropDown(Sender: TObject); private { Private declarations } procedure dzhllrVisible(); 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, u_sys_progress; {$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); begin table_post(t_crm_client_Invoice); 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 } bsSkinTabSheet2.TabVisible:=true; t_crm_client_limited.open; t_crm_client_Invoice.Open; {$IFDEF KHJSXX} {$ELSE} crmsalse_sheet.tabvisible:=false; {$ENDIF} // end; if trim(get_parameters_value(159,'false'))<>'' then bsSkinButton55.Visible:=True else bsSkinButton55.Visible:=false; if (not if_open('283')) and (not if_open('202')) then begin bsSkinTabSheet6.TabVisible:=false; bsSkinTabSheet5.TabVisible:=false; btab4.TabVisible:=false; crmsalse_sheet.TabVisible:=false; bsSkinTabSheet2.TabVisible:=false; 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 if t_crm_client.State=dsinsert then begin if Length(Trim(DBEdit4.Text))>6 then begin ShowMessage('客户代码不能大于六位!请检查!'); abort; end ; end; 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.DBEdit2KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit6); 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,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; v_all_client.Open; if not v_all_client.IsEmpty then begin showmessage('当前客户已经使用,不能删除!!'); v_all_client.Close; abort; end; v_all_client.Close; //if t_crm_client.State<>dsinsert then //SendMsg_gonggao('54',''); 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_RxDBLookupCombo(Key,RxDBLookupCombo14); 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 Edit6.text<>''then begin str:=str+' and EXISTS (select 1 from t_crm_client_Invoice WHERE t_crm_client_Invoice.客户简称=t_crm_client.客户简称 AND 发票抬头 like '+''''+'%'+Edit6.text+'%'+''')'; end; 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; dzhllrVisible(); 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 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; 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); var dstype,dsdsricp:string; begin table_before_post(t_crm_client_sales,'揽货人'); table_before_post(t_crm_client_sales,'开始日期'); table_before_post(t_crm_client_sales,'结束日期'); if (MonthsBetween(DataSet.FieldByName('开始日期').asDatetime,DataSet.FieldByName('结束日期').asDatetime)>18) then begin if MessageDlg('该客户账期超18个月,请确认是否保存?',mtWarning,[mbYes,mbNo],0)<>mrYes then begin Abort; end; end; 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; if (DataSet.State in [dsinsert]) then begin dstype:='添加账期'; dsdsricp:='客户名称:'+t_crm_client.fieldbyname('客户简称').AsString+';'; dsdsricp:=dsdsricp+'揽货人:'+DataSet.fieldbyname('揽货人').AsString+';'; dsdsricp:=dsdsricp+'开始日期:'+DataSet.fieldbyname('开始日期').AsString+';'; dsdsricp:=dsdsricp+'结束日期:'+DataSet.fieldbyname('结束日期').AsString+';'; dsdsricp:=dsdsricp+'结费模式:'+DataSet.fieldbyname('结费类型').AsString+';'; dsdsricp:=dsdsricp+'结费日期:'+DataSet.fieldbyname('结费日期').AsString+';'; dsdsricp:=dsdsricp+'间隔月数:'+DataSet.fieldbyname('类型模式').AsString+';'; dsdsricp:=dsdsricp+'付费习惯:'+DataSet.fieldbyname('付费习惯').AsString+';'; dsdsricp:=dsdsricp+'分阶段付费:'+DataSet.fieldbyname('结费结束').AsString+';'; dsdsricp:=dsdsricp+'是否特批客户:'+DataSet.fieldbyname('是否特批客户').AsString+';'; end else begin dstype:='修改账期'; dsdsricp:='客户名称:'+t_crm_client.fieldbyname('客户简称').AsString+';'; dsdsricp:=dsdsricp+'揽货人:'+VarToStrDef(DataSet.fieldbyname('揽货人').NewValue,'')+'['+VarToStrDef(DataSet.fieldbyname('揽货人').OldValue,'')+']'; dsdsricp:=dsdsricp+'开始日期:'+VarToStrDef(DataSet.fieldbyname('开始日期').NewValue,'')+'['+VarToStrDef(DataSet.fieldbyname('开始日期').OldValue,'')+']'; dsdsricp:=dsdsricp+'结束日期:'+VarToStrDef(DataSet.fieldbyname('结束日期').NewValue,'')+'['+VarToStrDef(DataSet.fieldbyname('结束日期').OldValue,'')+']'; dsdsricp:=dsdsricp+'结费模式:'+VarToStrDef(DataSet.fieldbyname('结费类型').NewValue,'')+'['+VarToStrDef(DataSet.fieldbyname('结费类型').OldValue,'')+']'; dsdsricp:=dsdsricp+'结费日期:'+VarToStrDef(DataSet.fieldbyname('结费日期').NewValue,'')+'['+VarToStrDef(DataSet.fieldbyname('结费日期').OldValue,'')+']'; dsdsricp:=dsdsricp+'间隔月数:'+VarToStrDef(DataSet.fieldbyname('类型模式').NewValue,'')+'['+VarToStrDef(DataSet.fieldbyname('类型模式').OldValue,'')+']'; dsdsricp:=dsdsricp+'付费习惯:'+VarToStrDef(DataSet.fieldbyname('付费习惯').NewValue,'')+'['+VarToStrDef(DataSet.fieldbyname('付费习惯').OldValue,'')+']'; dsdsricp:=dsdsricp+'分阶段付费:'+VarToStrDef(DataSet.fieldbyname('结费结束').NewValue,'')+'['+VarToStrDef(DataSet.fieldbyname('结费结束').OldValue,'')+']'; dsdsricp:=dsdsricp+'是否特批客户:'+VarToStrDef(DataSet.fieldbyname('是否特批客户').NewValue,'')+'['+VarToStrDef(DataSet.fieldbyname('是否特批客户').OldValue,'')+']'; end; InsertSysLog(dstype,dsdsricp); end; procedure Tfrm_crm_client.t_crm_client_salesBeforeDelete( DataSet: TDataSet); var dstype,dsdsricp:string; 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; dstype:='删除账期'; dsdsricp:='客户名称:'+t_crm_client.fieldbyname('客户简称').AsString+';'; dsdsricp:=dsdsricp+'揽货人:'+DataSet.fieldbyname('揽货人').AsString+';'; dsdsricp:=dsdsricp+'开始日期:'+DataSet.fieldbyname('开始日期').AsString+';'; dsdsricp:=dsdsricp+'结束日期:'+DataSet.fieldbyname('结束日期').AsString+';'; dsdsricp:=dsdsricp+'结费模式:'+DataSet.fieldbyname('结费类型').AsString+';'; dsdsricp:=dsdsricp+'结费日期:'+DataSet.fieldbyname('结费日期').AsString+';'; dsdsricp:=dsdsricp+'间隔月数:'+DataSet.fieldbyname('类型模式').AsString+';'; dsdsricp:=dsdsricp+'付费习惯:'+DataSet.fieldbyname('付费习惯').AsString+';'; dsdsricp:=dsdsricp+'分阶段付费:'+DataSet.fieldbyname('结费结束').AsString+';'; dsdsricp:=dsdsricp+'是否特批客户:'+DataSet.fieldbyname('是否特批客户').AsString+';'; InsertSysLog(dstype,dsdsricp); 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 top 50 * from t_crm_client where 1=1 and '+open_data('0008','录入人','揽货人','客服员','no','no')+' order by 代码'); t_crm_client.open; // v_all_client.open; // t_crm_client_linkman.Open; t_crm_client_sales.Open; t_crm_client_sales_tmp.Open ; t_crm_client_linkman.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.t_crm_client_salesAfterPost(DataSet: TDataSet); var aAdoQuery:TAdoQuery; begin if Trim(t_crm_client_sales.FieldByName('结费类型').AsString)<>'' then begin aAdoQuery:=CreateAdoQuery; with aAdoQuery do try Close;sql.Clear; sql.Add('Update t_op_seae set 结费类型=:结费类型'); sql.Add('where 委托单位=:委托单位 and 开船日期>=:Date1 and 开船日期<=:date2'); Parameters.ParamByName('委托单位').Value:=Trim(t_crm_client_sales.FieldByName('客户简称').AsString); Parameters.ParamByName('结费类型').Value:=Trim(t_crm_client_sales.FieldByName('结费类型').AsString); Parameters.ParamByName('Date1').Value:=t_crm_client_sales.FieldByName('开始日期').Value; Parameters.ParamByName('Date2').Value:=t_crm_client_sales.FieldByName('结束日期').Value; ExecSQL; finally Free; end; end; 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 开船日期>=: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(getzq(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; ShowMessage('更新完毕!'); end; procedure Tfrm_crm_client.bsSkinButton55Click(Sender: TObject); var srcbsNo:string; aQuery,aQuery2:TADOQuery; aRate:double; begin with ADOQuerySub do try Close;sql.Clear; sql.Add('select * from t_crm_client_sales'); sql.Add('where 客户简称=:sname'); Parameters.ParamByName('sname').Value:=t_crm_client.FieldByName('客户简称').AsString; Open;First; if IsEmpty then begin ShowMessage('A系统不存在客户为:'+t_crm_client.FieldByName('客户简称').AsString+'的结费信息'); Exit; end; finally end; if t_crm_client_sales.RecordCount>=1 then begin ShowMessage('已经存在结费信息,请校验'); Exit; end; t_crm_client_sales.Insert; t_crm_client_sales.FieldByName('开始日期').Value:=ADOQuerySub.FieldByName('开始日期').Value; t_crm_client_sales.FieldByName('结束日期').Value:=ADOQuerySub.FieldByName('结束日期').Value; t_crm_client_sales.FieldByName('结费类型').Value:=ADOQuerySub.FieldByName('结费类型').Value; t_crm_client_sales.FieldByName('结费金额').Value:=ADOQuerySub.FieldByName('结费金额').Value; t_crm_client_sales.FieldByName('类型模式').Value:=ADOQuerySub.FieldByName('类型模式').Value; t_crm_client_sales.FieldByName('日期模式').Value:=ADOQuerySub.FieldByName('日期模式').Value; t_crm_client_sales.FieldByName('结费日期').Value:=ADOQuerySub.FieldByName('结费日期').Value; t_crm_client_sales.Post; end; procedure Tfrm_crm_client.bsSkinButton32Click(Sender: TObject); begin t_crm_client_sales_tmp.Prior ; end; procedure Tfrm_crm_client.bsSkinButton31Click(Sender: TObject); begin t_crm_client_sales_tmp.Next ; end; procedure Tfrm_crm_client.bsSkinButton27Click(Sender: TObject); begin t_crm_client_sales_tmp.insert; end; procedure Tfrm_crm_client.bsSkinButton28Click(Sender: TObject); begin table_post(t_crm_client_sales_tmp); end; procedure Tfrm_crm_client.bsSkinButton29Click(Sender: TObject); begin table_delete(t_crm_client_sales_tmp); end; procedure Tfrm_crm_client.bsSkinButton30Click(Sender: TObject); begin table_cancel(t_crm_client_sales_tmp); end; procedure Tfrm_crm_client.t_crm_client_sales_tmpAfterInsert( DataSet: TDataSet); begin t_crm_client_sales_tmp['客户简称']:=t_crm_client['客户简称']; t_crm_client_sales_tmp['揽货人']:=t_crm_client['揽货人']; t_crm_client_sales_tmp['状态']:='新建'; t_crm_client_sales_tmp['结费金额']:=0; t_crm_client_sales_tmp['结费期限']:=0; t_crm_client_sales_tmp['结费金额']:=0; t_crm_client_sales_tmp['结费日期']:=0; t_crm_client_sales_tmp['日期模式']:='不固定'; end; procedure Tfrm_crm_client.t_crm_client_sales_tmpBeforePost( DataSet: TDataSet); begin table_before_post(t_crm_client_sales_tmp,'开始日期'); if t_crm_client_sales_tmp.FieldByName('结束日期').IsNull then begin t_crm_client_sales_tmp.FieldByName('结束日期').AsDateTime:=IncMonth(t_crm_client_sales_tmp.FieldByName('开始日期').AsDateTime,1); end; // table_before_post(t_crm_client_sales_tmp,'结束日期'); end; procedure Tfrm_crm_client.bsSkinButton33Click(Sender: TObject); var Ext,sname,s:String; ExcelTemplet:Variant; i,j:integer; imp:boolean; aAdoQuery:TAdoQuery; begin if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(application); frm_sys_progress.bsSkinGauge1.ProgressText:='正在生成核销数据请等候。。。'; frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=300; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; try aAdoQuery:=CreateAdoquery; with aAdoQuery do begin Close;sql.Clear; sql.Add('Update t_crm_client_sales set 对账联系人=:对账联系人,对账联系人邮箱=:对账联系人邮箱,对账联系人电话=:对账联系人电话'); sql.Add('where 客户简称=:客户简称'); end; if OpenDialog1.Execute then begin Ext:=lowercase(ExtractFileExt(OpenDialog1.FileName)); if Ext='.xls' then begin ExcelTemplet:= CreateOleObject('Excel.Application'); try ExcelTemplet.Workbooks.Open(OpenDialog1.FileName); imp:=true; if imp then begin I:=2; //showmessage(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value)); while VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value)<>'' do begin frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; s:=trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value)); // s:=trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value))+' '+trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,4].Value))+' '+trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,5].Value))+' '+trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,6].Value)); frm_sys_progress.bsSkinGauge1.ProgressText:=s; with aAdoQuery do begin close; Parameters.ParamByName('客户简称').Value:=trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,2].Value)); Parameters.ParamByName('对账联系人').Value:=trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,4].Value)); Parameters.ParamByName('对账联系人电话').Value:=trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,5].Value)); Parameters.ParamByName('对账联系人邮箱').Value:=trim(VartoStr(ExcelTemplet.ActiveSheet.Cells[I,6].Value)); ExecSQL; end; i:=i+1; end; end; finally ExcelTemplet.DisplayAlerts := false;//是否提示存盘 ExcelTemplet.Quit;//如果出错则退出 end; end; end; finally aAdoQuery.Free; frm_sys_progress.close; frm_sys_progress:=nil; end end; procedure Tfrm_crm_client.dxDBGrid1ChangeNode(Sender: TObject; OldNode, Node: TdxTreeListNode); begin dzhllrVisible(); end; /// /// 对账联系人是否可见 /// procedure Tfrm_crm_client.dzhllrVisible(); begin bskndbchckrdbxd.Visible:=False; if(t_crm_client.IsEmpty=False) and (t_crm_client.FieldByName('客户简称').AsString='美商宏鹰') then begin bskndbchckrdbxd.Visible:=True; end; end; procedure Tfrm_crm_client.dxDBGrid1Click(Sender: TObject); begin dzhllrVisible(); end; procedure Tfrm_crm_client.crmsalse_sheetShow(Sender: TObject); begin if not if_open('452') then begin bsSkinPanel8.Enabled:=false; bsSkinGroupBox3.Enabled:=False; bsSkinGroupBox2.Enabled:=False; bsSkinGroupBox13.Enabled:=false; dxDBGrid5.Enabled:=False; end else begin bsSkinPanel8.Enabled:=True; bsSkinGroupBox3.Enabled:=True; bsSkinGroupBox2.Enabled:=True; bsSkinGroupBox13.Enabled:=True; dxDBGrid5.Enabled:=True; end; end; procedure Tfrm_crm_client.RxDBLookupCombo14KeyPress(Sender: TObject; var Key: Char); begin key_DBEdit(Key,DBEdit3); end; procedure Tfrm_crm_client.RxDBLookupCombo1Enter(Sender: TObject); begin TRxDBLookupCombo(Sender).LookupDisplay:='代码;姓名'; end; procedure Tfrm_crm_client.RxDBLookupCombo1Exit(Sender: TObject); begin TRxDBLookupCombo(Sender).LookupDisplay:='姓名'; end; procedure Tfrm_crm_client.RxDBLookupCombo14Enter(Sender: TObject); begin TRxDBLookupCombo(Sender).LookupDisplay:='代码;姓名'; end; procedure Tfrm_crm_client.RxDBLookupCombo14Exit(Sender: TObject); begin TRxDBLookupCombo(Sender).LookupDisplay:='姓名' end; procedure Tfrm_crm_client.DBEdit4Exit(Sender: TObject); begin if t_crm_client.State=dsinsert then begin if Length(Trim(DBEdit4.Text))>6 then begin ShowMessage('客户代码不能大于六位!请检查!'); DBEdit4.SetFocus; end; end; end; procedure Tfrm_crm_client.wwDBComboBox16DropDown(Sender: TObject); var aAdoQuery:TAdoQuery; begin if RxDBLookupCombo9.Value='' then Exit; aAdoQuery:=CreateAdoQuery; wwDBComboBox16.Items.Clear; with aAdoQuery do try Close;SQL.Clear; SQL.Add('Select * from t_crm_client_linkman'); SQL.Add('where 客户简称=:SNAME'); SQL.Add('Order by 姓名'); Parameters.ParamByName('SNAME').Value:=trim(RxDBLookupCombo9.Value); Open;First; while not Eof do begin wwDBComboBox16.Items.Add(Trim(FieldByName('姓名').AsString)); Next; end; finally; Free; end; end; end.