?? unit_manageradmination.pas
字號:
unit Unit_ManagerAdmination;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Buttons, Grids, TeeProcs, TeEngine, Chart, DBChart,
Series, Db, DBTables, Menus, ImgList, CheckLst,ProcedureP,FunctionP,
DBGrids, TFlatComboBoxUnit, TFlatButtonUnit;
type
TFrm_ManagerAdmination = class(TForm)
Panel1: TPanel;
PopupMenu1: TPopupMenu;
ImageList1: TImageList;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
DataSourceTJ: TDataSource;
N4: TMenuItem;
Panel2: TPanel;
StringGrid1: TStringGrid;
Panel4: TPanel;
Panel3: TPanel;
Label3: TLabel;
FlatComboBoxCity: TFlatComboBox;
Label4: TLabel;
FlatComboBoxCounty: TFlatComboBox;
Label5: TLabel;
FlatComboBoxNo: TFlatComboBox;
FlatButton1: TFlatButton;
FlatButton2: TFlatButton;
FlatButton3: TFlatButton;
QueryRy: TQuery;
QueryAnalyze: TQuery;
PnlPrint: TPanel;
Label146: TLabel;
Label147: TLabel;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FlatComboBoxCityChange(Sender: TObject);
procedure FlatComboBoxCountyChange(Sender: TObject);
procedure FlatButton1Click(Sender: TObject);
procedure FlatButton3Click(Sender: TObject);
private
JX_Temp, XJ_Temp : string;
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_ManagerAdmination: TFrm_ManagerAdmination;
implementation
uses
Unit_Public,Main;
{$R *.DFM}
procedure TFrm_ManagerAdmination.FormShow(Sender: TObject);
var
i : integer;
begin
PnlPrint.Visible :=false;
StringGrid1.Cells[0,0] := '工號';
StringGrid1.Cells[1,0] := '個人客戶數';
StringGrid1.Cells[2,0] := '集團客戶數';
StringGrid1.Cells[3,0] := '集團成員數';
Fun_GetCity(FlatComboboxCity,'所有',0,PS_CityName);
FlatComboBoxCityChange(Nil);
FlatComboBoxCountyChange(Nil);
end;
procedure TFrm_ManagerAdmination.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := Cafree;
end;
procedure TFrm_ManagerAdmination.FlatComboBoxCityChange(Sender: TObject);
begin
Fun_GetCounty(FlatComboboxCounty,'所有',FlatComboboxCity.Text,0,PS_HomeName);
end;
procedure TFrm_ManagerAdmination.FlatComboBoxCountyChange(Sender: TObject);
begin
Fun_GetManager(FlatComboboxNo,'所有',FlatComboboxCity.Text,FlatComboboxCounty.Text,GH);
end;
procedure TFrm_ManagerAdmination.FlatButton1Click(Sender: TObject);
var
i : integer;
CityNo:String;
CountyNo:String;
GradeNo:String;
ManagerNo:String;
LSQL,LSqlStr:String;
begin
PnlPrint.Visible :=true;
PnlPrint.Refresh;
// 清空
stringgrid1.RowCount :=2;
stringgrid1.ColCount :=4;
stringgrid1.Refresh ;
CityNo:=Fun_GetCity(FlatComboboxCity,'',1);
CountyNo:=Fun_GetCounty(FlatComboboxCounty,'','',1);
GradeNo:=Fun_GetCodeName(FlatComboboxNo,'');
If FlatComboboxNo.ItemIndex>0 Then
ManagerNo:=Copy(FlatComboboxNo.Text,1,Pos(':',FlatComboboxNo.Text)-1)
Else
ManagerNo:='';
//思路是按查詢出來的客戶經理數,一行一行寫,每行寫時直接去統計
QueryRY.Close;
LSqlStr :='Select count(*) From T_V_Manager Where GH is not null ' ;
If FlatComboboxCity.ItemIndex>0 Then
LSqlStr :=LSqlStr+' And CITYNAME='''+FlatComboboxCity.Text+'''' ;
If FlatComboboxCounty.ItemIndex>0 Then
LSqlStr :=LSqlStr+' And HOME_NAME='''+FlatComboboxCounty.Text+'''' ;
If FlatComboboxNo.ItemIndex>0 Then
LSqlStr :=LSqlStr+' And GH='''+ManagerNo+'''' ;
QueryRy.sql.text :=LSqlStr;
QueryRy.Open;
StringGrid1.RowCount:=QueryRy.fields[0].asinteger+2;
QueryRy.close;
LSqlStr :='select GH '+copy(LSqlStr,pos('From',LSqlStr),length(LSqlStr)-pos('From',LSqlStr)+1);
LSqlStr :=LSqlStr+' order by GH' ;
QueryRy.sql.text :=LSqlStr;
QueryRy.Open;
QueryRy.first;
I:=1;
while not QueryRy.Eof do
begin
//新增了一行
ManagerNo :=QueryRy.fieldbyname('GH').asstring;
//加上客戶經理工號
StringGrid1.Cells[0,I]:=ManagerNo;
//同一行填上個人客戶數,集團客戶數,集團成員數
//先得到同一的查詢條件
LSQL:=' (1=1)';
If CityNo<>'' Then
LSQL :=LSQL+' And CityNo='''+CityNo+'''';
If CountyNo<>'' Then
LSQL :=LSQL+' And Off_No_home='+CountyNo;
If ManagerNo<>'' Then
LSQL :=LSQL+' And GH='''+ManagerNo+'''';
//個人客戶
LSQLStr:='Select count(VIPH) from T_F_CustInfo Where '+LSQL;
QueryAnalyze.Close;
QueryAnalyze.SQL.text :=LSQLStr;
QueryAnalyze.Open;
StringGrid1.Cells[1,I]:=QueryAnalyze.fields[0].asstring;
//集團客戶數
LSQLStr:='Select count(JTYHDM) from T_F_GroupInfo Where '+LSQL;
QueryAnalyze.Close;
QueryAnalyze.SQL.text :=LSQLStr;
QueryAnalyze.Open;
StringGrid1.Cells[2,I]:=QueryAnalyze.fields[0].asstring;
//集團成員數
LSQLStr:='select count(VIPH) from t_f_custinfo where fybz=1 '
+' and JTYHDM is not null and JTYHDM in '
+' (Select JTYHDM from T_F_GroupInfo Where '+LSQL+')';
QueryAnalyze.Close;
QueryAnalyze.SQL.text :=LSQLStr;
QueryAnalyze.Open;
StringGrid1.Cells[3,I]:=QueryAnalyze.fields[0].asstring;
QueryRY.Next;
I:=I+1;
//StringGrid1.RowCount :=StringGrid1.RowCount + 1;
end;
//加上未分配
StringGrid1.Cells[0,i]:='未分配';
//加上未分配的數值
LSQLStr:='Select count(VIPH) from T_F_CustInfo Where GH is null';
QueryAnalyze.Close;
QueryAnalyze.SQL.text :=LSQLStr;
QueryAnalyze.Open;
StringGrid1.Cells[1,I]:=QueryAnalyze.fields[0].asstring;
PnlPrint.Visible :=false;
StringGrid1.Refresh;
end;
procedure TFrm_ManagerAdmination.FlatButton3Click(Sender: TObject);
begin
Close;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -