unit u_crm_client_check; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, DB, ADODB, dxDBTLCl, dxGrClms, wwdbdatetimepicker, StdCtrls, DBCtrls, wwdbedit, Wwdotdot, Wwdbcomb, RxLookup, bsSkinCtrls, bsdbctrls, Mask, ComCtrls, bsSkinTabs, ExtCtrls, dxTL, dxDBCtrl, dxDBGrid, dxCntner, Grids, Wwdbigrd, Wwdbgrid, RxDBComb; type Tfrm_crm_client_check = class(TForm) t_crm_client: TADOQuery; t_crm_client1: TDataSource; t_crm_client_linkman: TADOQuery; t_crm_client_linkman1: TDataSource; t_crm_client_link: TADOQuery; t_crm_client_link1: TDataSource; Panel1: TPanel; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinGroupBox1: TbsSkinGroupBox; Label1: TLabel; Label3: TLabel; Label9: TLabel; Label12: TLabel; DBEdit1: TDBEdit; DBEdit3: TDBEdit; DBEdit11: TDBEdit; DBEdit12: TDBEdit; bsSkinGroupBox2: TbsSkinGroupBox; Label13: TLabel; Label14: TLabel; Label15: TLabel; Label16: TLabel; DBEdit13: TDBEdit; DBEdit14: TDBEdit; DBEdit15: TDBEdit; DBEdit16: TDBEdit; bsSkinGroupBox4: TbsSkinGroupBox; bsSkinTabSheet2: TbsSkinTabSheet; bsSkinGroupBox5: TbsSkinGroupBox; Label20: TLabel; Label21: TLabel; Label22: TLabel; Label164: TLabel; DBEdit20: TDBEdit; DBEdit21: TDBEdit; DBEdit22: TDBEdit; RxDBLookupCombo11: TRxDBLookupCombo; bsSkinGroupBox6: TbsSkinGroupBox; Label19: TLabel; Label24: TLabel; Label45: TLabel; Label46: TLabel; DBEdit19: TDBEdit; DBEdit24: TDBEdit; DBEdit25: TDBEdit; wwDBComboBox5: TwwDBComboBox; DBEdit30: TDBEdit; bsSkinGroupBox7: TbsSkinGroupBox; Label23: TLabel; Label26: TLabel; Label27: TLabel; Label28: TLabel; DBEdit26: TDBEdit; DBEdit23: TDBEdit; DBEdit27: TDBEdit; bsSkinDBCheckRadioBox9: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox10: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox11: TbsSkinDBCheckRadioBox; DBEdit28: TDBEdit; bsSkinGroupBox8: TbsSkinGroupBox; Label29: TLabel; Label30: TLabel; Label31: TLabel; Label32: TLabel; Label33: TLabel; Label34: TLabel; Label35: TLabel; DBEdit29: TDBEdit; DBEdit31: TDBEdit; DBEdit32: TDBEdit; DBEdit33: TDBEdit; DBEdit34: TDBEdit; wwDBComboBox1: TwwDBComboBox; DBMemo1: TDBMemo; bsSkinTabSheet3: TbsSkinTabSheet; Label36: TLabel; Label37: TLabel; Label38: TLabel; Label39: TLabel; Label40: TLabel; Label41: TLabel; Label42: TLabel; Label43: TLabel; Label44: TLabel; Label47: TLabel; Label48: TLabel; Label49: TLabel; Label50: TLabel; Label51: TLabel; Label52: TLabel; Label53: TLabel; dxDBGrid2: TdxDBGrid; dxDBGrid2Column1: TdxDBGridMaskColumn; dxDBGrid2Column2: TdxDBGridMaskColumn; dxDBGrid2Column3: TdxDBGridMaskColumn; DBEdit35: TDBEdit; DBEdit37: TDBEdit; DBEdit38: TDBEdit; DBEdit39: TDBEdit; wwDBComboBox2: TwwDBComboBox; DBEdit36: TDBEdit; DBEdit40: TDBEdit; DBEdit41: TDBEdit; DBEdit42: TDBEdit; DBEdit43: TDBEdit; DBEdit44: TDBEdit; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; wwDBDateTimePicker3: TwwDBDateTimePicker; wwDBDateTimePicker4: TwwDBDateTimePicker; DBMemo2: TDBMemo; bsSkinTabSheet4: TbsSkinTabSheet; Label54: TLabel; Label55: TLabel; Label56: TLabel; Label57: TLabel; Label58: TLabel; Label59: TLabel; Label60: TLabel; Label61: TLabel; dxDBGrid3: TdxDBGrid; dxDBGrid3Column1: TdxDBGridMaskColumn; dxDBGrid3Column2: TdxDBGridDateColumn; DBEdit46: TDBEdit; DBEdit47: TDBEdit; DBEdit49: TDBEdit; wwDBComboBox3: TwwDBComboBox; RxDBLookupCombo8: TRxDBLookupCombo; wwDBDateTimePicker5: TwwDBDateTimePicker; wwDBComboBox4: TwwDBComboBox; DBMemo3: TDBMemo; bsSkinTabSheet5: TbsSkinTabSheet; p_client_liushi: TADOStoredProc; p_client_state: TADOStoredProc; p_update: TADOStoredProc; bsSkinGroupBox3: TbsSkinGroupBox; Label4: TLabel; Label5: TLabel; Label2: TLabel; Label7: TLabel; Label6: TLabel; Label10: TLabel; Label11: TLabel; Label8: TLabel; Label62: TLabel; DBEdit4: TDBEdit; DBEdit5: TDBEdit; DBEdit2: TDBEdit; DBEdit7: TDBEdit; DBEdit6: TDBEdit; DBEdit10: TDBEdit; DBEdit9: TDBEdit; DBEdit8: TDBEdit; DBEdit45: TDBEdit; Panel2: TPanel; bsSkinButton5: TbsSkinButton; bsSkinButton10: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton8: TbsSkinButton; bsSkinButton12: TbsSkinButton; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton3: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinButton7: TbsSkinButton; bsSkinDBCheckRadioBox5: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox12: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox2: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox4: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox3: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox6: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox7: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox8: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox13: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox14: TbsSkinDBCheckRadioBox; bsSkinDBCheckRadioBox15: TbsSkinDBCheckRadioBox; Label63: TLabel; Label69: TLabel; Label70: TLabel; Label71: TLabel; wwDBComboBox10: TwwDBComboBox; wwDBComboBox7: TwwDBComboBox; DBEdit48: TDBEdit; wwDBComboBox9: TwwDBComboBox; wwDBComboBox8: TwwDBComboBox; DBEdit52: TDBEdit; bsSkinTabSheet6: TbsSkinTabSheet; ds_crm_client_sales1: TDataSource; t_crm_client_sales: TADOQuery; bsSkinPanel3: TbsSkinPanel; wwDBGrid1: TwwDBGrid; bskngrpbx1: TbsSkinGroupBox; bskngrpbx2: TbsSkinGroupBox; Label74: TLabel; Label75: TLabel; Label76: TLabel; Label80: TLabel; Label81: TLabel; Label82: TLabel; Label83: TLabel; Label84: TLabel; Label88: TLabel; Label89: TLabel; Label78: TLabel; Label85: TLabel; bvl1: TBevel; Bevel1: TBevel; DBEdit50: TDBEdit; DBEdit54: TDBEdit; DBEdit56: TDBEdit; DBEdit57: TDBEdit; DBEdit58: TDBEdit; DBEdit60: TDBEdit; wwDBComboBox11: TwwDBComboBox; bsSkinPanel5: TbsSkinPanel; Label25: TLabel; lbl1: TLabel; Label64: TLabel; DBEdit51: TDBEdit; wwDBComboBox6: TwwDBComboBox; wwDBComboBox12: TwwDBComboBox; bsSkinDBCheckRadioBox16: TbsSkinDBCheckRadioBox; bsSkinGroupBox12: TbsSkinGroupBox; Label65: TLabel; DBEdit55: TDBEdit; bsSkinGroupBox13: TbsSkinGroupBox; Label77: TLabel; Label66: TLabel; Label67: TLabel; Label72: TLabel; Label73: TLabel; wwDBComboBox13: TwwDBComboBox; wwDBComboBox14: TwwDBComboBox; DBEdit59: TDBEdit; bsSkinPanel1: TbsSkinPanel; bsSkinButton11: TbsSkinButton; bsSkinButton13: TbsSkinButton; Label68: TLabel; RxDBComboBox1: TRxDBComboBox; Label79: TLabel; RxDBComboBox3: TRxDBComboBox; Label86: TLabel; RxDBComboBox2: TRxDBComboBox; Label87: TLabel; RxDBComboBox4: TRxDBComboBox; Label91: TLabel; RxDBComboBox5: TRxDBComboBox; Label92: TLabel; DBEdit61: TDBEdit; Label17: TLabel; RxDBLookupCombo14: TRxDBLookupCombo; Label18: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; Label93: TLabel; wwDBDateTimePicker6: TwwDBDateTimePicker; Label94: TLabel; DBEdit17: TDBEdit; bsSkinGroupBox9: TbsSkinGroupBox; Label90: TLabel; DBEdit18: TDBEdit; GroupBox1: TGroupBox; Memo1: TMemo; GroupBox4: TGroupBox; Memo3: TMemo; GroupBox2: TGroupBox; Memo2: TMemo; dxDBGrid1: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGridMaskColumn4: TdxDBGridMaskColumn; dxDBGridMaskColumn5: TdxDBGridMaskColumn; dxDBGridMaskColumn6: TdxDBGridMaskColumn; dxDBGrid1Column5: TdxDBGridColumn; dxDBGrid1Column6: TdxDBGridColumn; dxDBGrid1Column7: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridColumn; dxDBGrid1Column9: TdxDBGridColumn; dxDBGrid1Column10: TdxDBGridColumn; dxDBGrid1Column11: TdxDBGridColumn; dxDBGrid1Column12: TdxDBGridColumn; dxDBGrid1Column13: TdxDBGridColumn; dxDBGrid1Column14: TdxDBGridColumn; dxDBGrid1Column15: TdxDBGridColumn; dxDBGrid1Column16: TdxDBGridColumn; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton5Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure Panel2Resize(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); function get_client_state(i:real):string; procedure dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton11Click(Sender: TObject); procedure bsSkinButton13Click(Sender: TObject); procedure dxDBGrid1Click(Sender: TObject); procedure t_crm_clientAfterScroll(DataSet: TDataSet); private { Private declarations } procedure GetDetail; public { Public declarations } end; var frm_crm_client_check: Tfrm_crm_client_check; implementation uses u_main, u_data_share, my_sys_function, u_sys_progress, u_crm_client_check_do, my_sys_chat; {$R *.dfm} procedure Tfrm_crm_client_check.GetDetail; var i:Integer; s,str:string; begin Memo1.Lines.Clear; Memo2.Lines.Clear; Memo3.Lines.Clear; //出货方向 s:=t_crm_client.fieldbyname('出货方向').AsString; str:=''; while (Trim(s)<>'') do begin str:=Copy(s,0,Pos(',',s)-1); if Pos(',',s)>0 then Memo1.Lines.Add(str); s:=Copy(s,Pos(',',s)+1,Length(s)-Pos(',',s)); end; //合作船东 s:=t_crm_client.fieldbyname('合作船东').AsString; str:=''; while (Trim(s)<>'') do begin str:=Copy(s,0,Pos(',',s)-1); if Pos(',',s)>0 then Memo2.Lines.Add(str); s:=Copy(s,Pos(',',s)+1,Length(s)-Pos(',',s)); end; //主营产品 s:=t_crm_client.fieldbyname('主营产品').AsString; str:=''; while (Trim(s)<>'') do begin str:=Copy(s,0,Pos(',',s)-1); if Pos(',',s)>0 then Memo3.Lines.Add(str); s:=Copy(s,Pos(',',s)+1,Length(s)-Pos(',',s)); end; end; function Tfrm_crm_client_check.get_client_state(i:real):string; var str:string; begin frm_data_share.t_code_price.first; while not frm_data_share.t_code_price.eof do begin if (i>=frm_data_share.t_code_price.fieldbyname('利润最低').asfloat) and (i'申请转正'then begin showmessage('当前客户状态不能审核通过!!'); exit; end; try frm_crm_client_check_do:=tfrm_crm_client_check_do.Create (self); frm_crm_client_check_do.ShowModal; finally frm_crm_client_check_do.Free; frm_crm_client_check_do:=nil; end; end; procedure Tfrm_crm_client_check.Panel2Resize(Sender: TObject); var i:integer; begin i:=round(Panel2.width/11); bsSkinButton9.width:=i; bsSkinButton12.width:=i; bsSkinButton10.width:=i; bsSkinButton8.width:=i; bsSkinButton1.width:=i; bsSkinButton2.width:=i; bsSkinButton3.width:=i; bsSkinButton4.width:=i; bsSkinButton6.width:=i; bsSkinButton7.width:=i; end; procedure Tfrm_crm_client_check.bsSkinButton1Click(Sender: TObject); var i,j:integer; str:widestring; begin try i:=strtoint(get_parameters_value(9,'3')); j:=strtoint(get_parameters_value(10,'3')); p_client_state.Parameters.ParamByName('d1').value:=date-j*30; p_client_state.Open; if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(self); frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=(p_client_state.RecordCount+3); frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; frm_data_share.t_code_price.Requery(); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; p_client_liushi.Parameters.ParamByName('d1').value:=date-i*30; p_client_liushi.ExecProc; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; p_client_state.first; while not p_client_state.eof do begin str:=frm_crm_client_check.get_client_state(p_client_state.fieldbyname('毛利润').asfloat/j); str:='update t_crm_client set 客户价值='+''''+str+''''+' where 客户简称=' +''''+p_client_state.fieldbyname('客户简称').asstring+''''; p_update.Parameters.ParamByName('SQLStr').value:=str; p_update.ExecProc; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; p_client_state.next; end; finally frm_data_share.t_crm_client.requery; t_crm_client.requery; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.MaxValue; frm_sys_progress.free; frm_sys_progress:=nil; showmessage('客户状态分析成功!!'); end; end; procedure Tfrm_crm_client_check.dxDBGrid1ColumnSorting(Sender: TObject; Column: TdxDBTreeListColumn; var Allow: Boolean); begin Column_sort(Column,t_crm_client,'客户简称'); end; procedure Tfrm_crm_client_check.bsSkinButton2Click(Sender: TObject); begin t_crm_client.CLOSE; t_crm_client.SQL.clear; t_crm_client.sql.add('select * from t_crm_client where 客户性质 in ('+quotedstr('其他')+','+quotedstr('目标')+')'); t_crm_client.SQL.Add(' and 客户状态 in ('+quotedstr('申请转正')+','+quotedstr('审核通过')+')' +' order by 客户状态,客户价值,客户简称'); t_crm_client.open; end; procedure Tfrm_crm_client_check.bsSkinButton3Click(Sender: TObject); begin if t_crm_client.IsEmpty then exit; if (t_crm_client.FieldByName('客户状态').asstring='申请转正')or (t_crm_client.FieldByName('客户状态').asstring='目标客户')then begin showmessage('当前客户状态不能封存客户!!'); exit; end; t_crm_client.edit; t_crm_client['客户状态']:='封存客户'; t_crm_client.post; SendMsg_gonggao('54',''); showmessage('封存客户成功!!'); end; procedure Tfrm_crm_client_check.bsSkinButton4Click(Sender: TObject); begin if t_crm_client.IsEmpty then exit; if (t_crm_client.FieldByName('客户状态').asstring<>'封存客户')then begin showmessage('当前客户状态不能恢复客户!!'); exit; end; t_crm_client.edit; t_crm_client['客户状态']:='合作客户'; t_crm_client.post; SendMsg_gonggao('54',''); showmessage('恢复客户成功!!'); end; procedure Tfrm_crm_client_check.bsSkinButton6Click(Sender: TObject); begin if t_crm_client.IsEmpty then exit; if t_crm_client.FieldByName('客户状态').asstring<>'审核通过'then begin showmessage('当前客户状态不能复核通过!!'); exit; end; try t_crm_client.edit; t_crm_client['客户状态']:='合作客户'; t_crm_client['客户性质']:='系统'; t_crm_client.post; Send_invocie_check_check('客户转正通过,客户名称:'+t_crm_client.FieldByName('客户简称').asstring, t_crm_client.FieldByName('揽货人').asstring,'46'); Send_invocie_check_check('客户转正通过,客户名称:'+t_crm_client.FieldByName('客户简称').asstring, t_crm_client.FieldByName('录入人').asstring,'46'); SendMsg_gonggao('53','新客户:'+t_crm_client['代码']+','+t_crm_client['客户简称']); except showmessage('审核通过失败!!'); exit; end; showmessage('审核通过成功!!'); end; procedure Tfrm_crm_client_check.bsSkinButton7Click(Sender: TObject); begin if t_crm_client.IsEmpty then exit; if (t_crm_client.FieldByName('客户状态').asstring<>'申请转正') and (t_crm_client.FieldByName('客户状态').asstring<>'审核通过')then begin showmessage('当前客户已经成为合作客户,不能驳回!!'); exit; end; try t_crm_client.edit; t_crm_client['客户状态']:='驳回申请'; t_crm_client.post; Send_invocie_check_check('驳回客户转正,客户名称:'+t_crm_client.FieldByName('客户简称').asstring, t_crm_client.FieldByName('揽货人').asstring,'47'); Send_invocie_check_check('驳回客户转正,客户名称:'+t_crm_client.FieldByName('客户简称').asstring, t_crm_client.FieldByName('录入人').asstring,'47'); except showmessage('驳回申请失败!!'); exit; end; showmessage('驳回申请成功!!'); end; procedure Tfrm_crm_client_check.bsSkinButton11Click(Sender: TObject); begin if t_crm_client.IsEmpty then exit; if t_crm_client_sales.IsEmpty then exit; t_crm_client_sales.Edit; t_crm_client_sales.FieldByName('状态').AsString:='审核'; t_crm_client_sales.Post; end; procedure Tfrm_crm_client_check.bsSkinButton13Click(Sender: TObject); begin if t_crm_client.IsEmpty then exit; if t_crm_client_sales.IsEmpty then exit; t_crm_client_sales.Edit; t_crm_client_sales.FieldByName('状态').AsString:='新建'; t_crm_client_sales.Post; end; procedure Tfrm_crm_client_check.dxDBGrid1Click(Sender: TObject); begin GetDetail; end; procedure Tfrm_crm_client_check.t_crm_clientAfterScroll(DataSet: TDataSet); begin GetDetail; end; end.