⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit_manageradmination.pas

📁 delphi开发的中国移动大客户管理系统,后台数据库为oracle
💻 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 + -