?? unit_analyzeappeal.pas
字號:
unit Unit_AnalyzeAppeal;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Unit_AnalyzeTemplet, Db, DBTables, XLGrids, Buttons, StdCtrls,
TFlatComboBoxUnit, TFlatButtonUnit, ExtCtrls, Grids, ComCtrls,
TFlatCheckBoxUnit,Unit_Public;
type
TFrm_AnalyzeAppeal = class(TFrm_AnalyzeTemplet)
DateTimePicker1: TDateTimePicker;
Label8: TLabel;
DateTimePicker2: TDateTimePicker;
Label9: TLabel;
Label7: TLabel;
StringGrid_Appeal: TStringGrid;
Query_PUB: TQuery;
procedure FlatButton1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FlatButton2Click(Sender: TObject);
private
{ Private declarations }
WhereString : string;
procedure GetWhereSql;
procedure FillStringGrid;
procedure PL_InitString;
public
{ Public declarations }
end;
var
Frm_AnalyzeAppeal: TFrm_AnalyzeAppeal;
implementation
Function Fun_ExportData(pFileName:String;pReportTitle:String;pObjectSource:TObject):Boolean;stdcall;external'winfun.dll';
{$R *.DFM}
procedure TFrm_AnalyzeAppeal.FormShow(Sender: TObject);
begin
inherited;
PL_InitString;
Query_PUB.Open;
end;
procedure TFrm_AnalyzeAppeal.FlatButton1Click(Sender: TObject);
begin
inherited;
GetWhereSql;
with QueryRow do
begin
Close;
Sql.Clear;
Sql.Add('select * from t_a_appeal');
Sql.Add(WhereString);
Open;
end;
PL_InitString;
FillStringGrid;
end;
procedure TFrm_AnalyzeAppeal.PL_InitString;
var
i : integer;
begin
StringGrid_Appeal.Cells[0,0] := '星級';
StringGrid_Appeal.Cells[1,0] := '投訴客戶數';
StringGrid_Appeal.Cells[2,0] := '投訴次數';
StringGrid_Appeal.Cells[3,0] := '已處理';
StringGrid_Appeal.Cells[4,0] := '占投訴客戶數比例';
StringGrid_Appeal.Cells[5,0] := '未處理';
StringGrid_Appeal.Cells[6,0] := '占投訴客戶數比例';
for i := 1 to 7 do
StringGrid_Appeal.Cells[0,i] := '';
end;
procedure TFrm_AnalyzeAppeal.GetWhereSql;
var
ValueString : string;
begin
//初始化WhereString變量
WhereString:='where (1=1)';
//讀取地市代碼
ValueString:=Fun_GetCity(FlatCombobox_City,'',1);
If ValueString<>'' Then
WhereString:=WhereString+' And CityNo='''+ValueString+'''';
//讀取局向代碼
ValueString:=Fun_GetCounty(FlatCombobox_County,'','',1);
If ValueString<>'' Then
WhereString:=WhereString+' And OFF_NO_HOME='+ValueString;
//讀取工號代碼
If FlatComboBox_ManagerNo.ItemIndex>0 Then
WhereString:=WhereString+' And WK_NO='''+Copy(FlatComboBox_ManagerNo.Text,1,Pos(':',FlatComboBox_ManagerNo.Text)-1)+'''';
//讀取等級代碼
ValueString:=Fun_GetCodeName(FlatCombobox_Grade);
If ValueString<>'' Then
WhereString:=WhereString+' And GradeNo='''+ValueString+'''';
//讀取品牌代碼
ValueString:=Fun_GetCodeName(FlatCombobox_Brand);
If ValueString<>'' Then
WhereString:=WhereString+' And ProductNo='''+ValueString+'''';
//讀取客戶屬性代碼
ValueString:=Fun_GetCodeName(FlatCombobox_Att);
If ValueString<>'' Then
WhereString:=WhereString+' And CustAtt='+ValueString;
//讀取時間
if DateTimePicker1.Checked then
WhereString:=WhereString+' And CALCMONTH>='''+FormatDateTime('YYYYMMDD',DateTimePicker1.DateTime)+'''';
if DateTimePicker2.Checked then
WhereString:=WhereString+' And CALCMONTH<='''+FormatDateTime('YYYYMMDD',DateTimePicker2.DateTime)+'''';
end;
procedure TFrm_AnalyzeAppeal.FillStringGrid;
var
i, j, h : integer;
begin
//init h
h := 0;
//fill first's col and row
j := 1;
if FlatComboBox_Grade.ItemIndex = 0 then
begin
StringGrid_Appeal.RowCount := Query_PUB.RecordCount + 1;
with Query_PUB do
begin
while not Eof do
begin
StringGrid_Appeal.Cells[0,j] := FieldByName('DESCRIPTION').AsString;
inc(j);
Next;
end;
First;
end;
end
else
begin
StringGrid_Appeal.RowCount := 2;
StringGrid_Appeal.Cells[0,1] := FlatComboBox_Grade.Text;
end;
//fill other's row and col
for i := 1 to StringGrid_Appeal.RowCount - 1 do
begin
if QueryRow.Locate('DESCRIPTION', Trim(StringGrid_Appeal.Cells[0,i]), []) = True then
begin
StringGrid_Appeal.Cells[i, 1] := QueryRow.FieldByName('AMOUNT').AsString;
StringGrid_Appeal.Cells[i, 2] := QueryRow.FieldByName('APPEALAMOUNT').AsString;
StringGrid_Appeal.Cells[i, 3] := QueryRow.FieldByName('AREADYDEAL').AsString;
StringGrid_Appeal.Cells[i, 4] := QueryRow.FieldByName('AREADYPERCENT').AsString;
StringGrid_Appeal.Cells[i, 5] := QueryRow.FieldByName('STILLDEAL').AsString;
StringGrid_Appeal.Cells[i, 6] := QueryRow.FieldByName('STILLPERCENT').AsString;
h := 1;
end;
end;
//record is null
if h = 0 then
for j := 1 to 7 do
begin
StringGrid_Appeal.Cells[1, j] := '0';
StringGrid_Appeal.Cells[2, j] := '0';
StringGrid_Appeal.Cells[3, j] := '0';
StringGrid_Appeal.Cells[4, j] := ' -';
StringGrid_Appeal.Cells[5, j] := '0';
StringGrid_Appeal.Cells[6, j] := ' -';
end;
end;
procedure TFrm_AnalyzeAppeal.FlatButton2Click(Sender: TObject);
begin
inherited;
Fun_ExportData('大客戶投訴統計','大客戶投訴統計',StringGrid_Appeal);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -