为什么我的子线程无法访问主线程中的东西,编译通过但运行后出现Access Avoilation之类的错误(100分)

  • 主题发起人 主题发起人 ddgboy
  • 开始时间 开始时间
D

ddgboy

Unregistered / Unconfirmed
GUEST, unregistred user!
如题。发生错误的代码:
{TDonloadThread}
procedure TDownloadThread.Execute;
begin
Upload;
end;

procedure TDownloadThread.Upload;
var
Name:String;
begin
if not frmOAManager.IdFTP1.Connected then
exit;//从这里开始报错,好像是不能访问到frmOAManager
Name := 'itlweb20060426.rar';
try
frmOAManager.SaveDialog1.FileName := Name;
if frmOAManager.SaveDialog1.Execute then
begin
frmOAManager.IdFTP1.TransferType := ftBinary;
frmOAManager.BytesToTransfer := frmOAManager.IdFTP1.Size(Name);
frmOAManager.IdFTP1.Get(Name, frmOAManager.SaveDialog1.FileName, true);
end;
finally
//
end;
end;
 
那个form没有create吧。
 
To chenge:
我的线程类建和那个窗体在一起。
 
是否能把你的project发给我,帮你看看。
chenge2k@gmail.com
 
线程调用窗体的可示控件时,要使用sychronize调用,保持同步,其次就是uses窗体单元
 
在你的线程中动态建立TIdFTP。
永远不要在主进程中使用Indy的文件传输控件,应为它们工作于阻塞方式下。
 
关键问题是我现在连子线程外很普通的label都调用不到。
lxw5214:使用sychronize调用也不行,而且很多人说使用sychronize就不叫线程了。
chenge:我的project太大, 不好发给你。我现在把这个单元全部贴出来,麻烦您看看,非常感谢您的支持。
unit OAManager;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, StdCtrls, IdBaseComponent, IdComponent,IdFTPCommon,
IdTCPConnection, IdTCPClient, IdHTTP, Gauges,Include,DateUtils,DB,DBTables,main,
IdFTP, IdIntercept, IdLogBase, IdLogDebug;
type
PStatUnit = ^TStatUnit;
TStatUnit = record
Date:Integer;
MarketType: Char;
Game: array[0..30] of char;
SellVolume: Integer;
SellBal:do
uble;
SellPrice:do
uble;
BuyBal:do
uble;
BuyVolume: Integer;
BuyPrice:do
uble;
NeedSendVolume: Integer;
NeedSendBal:do
uble;
StockVolume: Integer;
StockBal:do
uble;
StockPrice:do
uble;
SendVolume: Integer;
SendBal:do
uble;
CBVolume: Integer;
CBBal:do
uble;
LostVolume: Integer;
LostBal:do
uble;
Income:do
uble;
end;

TStatList = Class(TList)
private
function FindBy(FDate:Integer;FMarketType:Char;FGame:String):PStatUnit;
protected
procedure Notify(Ptr: Pointer;
Action: TListNotification);
override;
public
function Add(FDate:Integer;FMarketType:Char;FGame:String;FSellVolume:Integer;FSellBal:Double;FSellPrice:Double;
FBuyBal:Double;FBuyVolume:Integer;FBuyPrice:Double;FNeedSendVolume:Integer;FNeedSendBal:Double;
FStockVolume:Integer;FStockBal:Double;FstockPrice:Double;FSendVolume:Integer;FSendBal:Double;
FCBVolume:Integer;FCBBal:Double;FLostVolume:Integer;FLostBal:Double;FIncome:Double):Integer;overload;
function Add(FDate:Integer;FMarketType:Char;FGame:String;FType:Char;FVolume:Integer;FBal:Double):Integer;overload;
function CalIntoDB(FDate:Integer):Boolean;
function CalIncome(FMarketType:char = #0;FGame:String = ''):TStringList;
end;

type
TfrmOAManager = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
TabSheet4: TTabSheet;
Button2: TButton;
mmShow: TMemo;
Label1: TLabel;
edDate: TEdit;
IdHTTP1: TIdHTTP;
Label2: TLabel;
Label3: TLabel;
Gauge1: TGauge;
edFrom: TEdit;
edSubject: TEdit;
mmContent: TMemo;
Button1: TButton;
lbCount: TLabel;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Memo1: TMemo;
Label4: TLabel;
Label5: TLabel;
cbMarketType: TComboBox;
cbGame: TComboBox;
Button6: TButton;
Memo2: TMemo;
Button7: TButton;
TabSheet5: TTabSheet;
Button8: TButton;
Button9: TButton;
TabSheet6: TTabSheet;
cbDict: TCheckBox;
cbParam: TCheckBox;
cbGameList: TCheckBox;
cbItem: TCheckBox;
cbServer: TCheckBox;
cbStorage: TCheckBox;
cbItemSell: TCheckBox;
cbPowerLevel: TCheckBox;
cbGameJour: TCheckBox;
cbLevelProcess: TCheckBox;
Button10: TButton;
Gauge2: TGauge;
Gauge3: TGauge;
Button11: TButton;
Button12: TButton;
Button13: TButton;
Button14: TButton;
Button15: TButton;
Button16: TButton;
Button17: TButton;
Button18: TButton;
Button19: TButton;
Button20: TButton;
Button21: TButton;
Button22: TButton;
Button23: TButton;
Button24: TButton;
Button25: TButton;
Button26: TButton;
Button27: TButton;
Button28: TButton;
Button29: TButton;
Button30: TButton;
Button31: TButton;
Button32: TButton;
Button33: TButton;
Button34: TButton;
Button35: TButton;
Button36: TButton;
Button37: TButton;
Button38: TButton;
Button39: TButton;
Button40: TButton;
Button41: TButton;
Edit1: TEdit;
Button42: TButton;
Button43: TButton;
Button44: TButton;
Button45: TButton;
Button46: TButton;
Button47: TButton;
Button48: TButton;
Button49: TButton;
Button50: TButton;
Button51: TButton;
Button52: TButton;
Button53: TButton;
Button54: TButton;
Button55: TButton;
Button56: TButton;
Button57: TButton;
Button58: TButton;
Button59: TButton;
Button60: TButton;
IdFTP1: TIdFTP;
Button61: TButton;
SaveDialog1: TSaveDialog;
OpenDialog1: TOpenDialog;
ProgressBar1: TProgressBar;
Button62: TButton;
Button63: TButton;
Button65: TButton;
lbSpeed: TLabel;
Gauge4: TGauge;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure cbMarketTypeChange(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button13Click(Sender: TObject);
procedure Button14Click(Sender: TObject);
procedure Button15Click(Sender: TObject);
procedure Button16Click(Sender: TObject);
procedure Button17Click(Sender: TObject);
procedure Button18Click(Sender: TObject);
procedure Button19Click(Sender: TObject);
procedure Button20Click(Sender: TObject);
procedure Button21Click(Sender: TObject);
procedure Button22Click(Sender: TObject);
procedure Button23Click(Sender: TObject);
procedure Button24Click(Sender: TObject);
procedure Button25Click(Sender: TObject);
procedure Button26Click(Sender: TObject);
procedure Button28Click(Sender: TObject);
procedure Button29Click(Sender: TObject);
procedure Button30Click(Sender: TObject);
procedure Button31Click(Sender: TObject);
procedure Button32Click(Sender: TObject);
procedure Button33Click(Sender: TObject);
procedure Button35Click(Sender: TObject);
procedure Button36Click(Sender: TObject);
procedure Button37Click(Sender: TObject);
procedure Button39Click(Sender: TObject);
procedure Button38Click(Sender: TObject);
procedure Button40Click(Sender: TObject);
procedure Button42Click(Sender: TObject);
procedure Button43Click(Sender: TObject);
procedure Button44Click(Sender: TObject);
procedure Button45Click(Sender: TObject);
procedure Button46Click(Sender: TObject);
procedure Button47Click(Sender: TObject);
procedure Button48Click(Sender: TObject);
procedure Button49Click(Sender: TObject);
procedure Button50Click(Sender: TObject);
procedure Button51Click(Sender: TObject);
procedure Button53Click(Sender: TObject);
procedure Button54Click(Sender: TObject);
procedure Button55Click(Sender: TObject);
procedure Button56Click(Sender: TObject);
procedure Button59Click(Sender: TObject);
procedure Button60Click(Sender: TObject);
procedure Button61Click(Sender: TObject);
procedure Button62Click(Sender: TObject);
procedure Button63Click(Sender: TObject);
procedure Button65Click(Sender: TObject);
procedure IdFTP1Work(Sender: TObject;
AWorkMode: TWorkMode;
const AWorkCount: Integer);
procedure IdFTP1Workbegin
(Sender: TObject;
AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure IdFTP1WorkEnd(Sender: TObject;
AWorkMode: TWorkMode);
private
{ Private declarations }
FSqLList: TStringList;
FBackupname:string;
AbortTransfer: Boolean;
//是否终止传输
TransferrignData: Boolean;
BytesToTransfer: LongWord;//传输的字节数
STime: TDateTime;
AverageSpeed:do
uble;
//平均速度
procedure ChageDir(DirName: String);

proceduredo
GameJour(FDate:String);
proceduredo
StorageJour(FDate:String);
proceduredo
FinanceJour(FDate:String);
proceduredo
GameRealBuy(FDate:String);
proceduredo
WgSell(FDate:String);
proceduredo
GameStorage(FDate:String);
proceduredo
Stat(FDate:String);
proceduredo
General(FDate:String);
public
{ Public declarations }
end;

TDownloadThread = class(TThread)
private
{ Private declarations }
procedure Upload;
public
{ Public declarations }
procedure Execute;Override;
end;

var
frmOAManager: TfrmOAManager;
FEmailList: TStringList;
implementation
uses ShowList;

{$R *.dfm}
procedure TfrmOAManager.FormShow(Sender: TObject);
begin
Left := 0;
Top := 0;
Width := 754;
Height := 529;
end;

procedure TfrmOAManager.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
FClientInfo.FFormList.DeleteByName(Caption);
Action := Cafree;
frmMain.RefreshMenu;
end;

procedure TfrmOAManager.DoFinanceJour(FDate:String);
begin
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert thfinancejour select ' + FDate + ',* from tbfinancejour ' +
'where Date <= ' + FDate + ' and (status = ' +
'''' + '6' + '''' + ' or status = ' + '''' + '7' + '''' +')');
FMyQuery.ExecSQL;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('delete from tbfinancejour where Date <= ' + FDate +
' and (status = ' + '''' + '6' + '''' + ' or status = ' + '''' + '7' + '''' +')');
FMyQuery.ExecSQL;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert thfinance select ' + FDate + ',* from tbfinance');
FMyQuery.ExecSQL;

mmShow.Lines.Add('财务流水表处理完毕!');
end;

procedure TfrmOAManager.DoGameJour(FDate:String);
begin
try
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert thgamejour select ' + FDate + ',* from tbgamejour ' +
'where execdate <= ' + FDate + ' and (status = ' +
'''' + '6' + '''' + ' or status = ' + '''' + '7' + '''' +
' or status = ' + '''' + 'A' + '''' + ')');
FMyQuery.ExecSQL;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('delete from tbgamejour where execDate <= ' + FDate +
' and (status = ' + '''' + '6' + '''' + ' or status = ' + '''' + '7' + '''' +
' or status = ' + '''' + 'A' + '''' + ')');
FMyQuery.ExecSQL;
mmShow.Lines.Add('交易流水表处理完毕!');
except
begin
mmShow.Lines.Add('交易流水表处理失败!');
end;
end;
end;

procedure TfrmOAManager.DoGameRealBuy(FDate:String);
begin
try
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert thgamerealbuy select ' + Fdate + ',* from tbgamerealbuy ' +
'where buydate <= ' + Fdate + ' and OutBal <> 0');
FMyQuery.ExecSQL;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('delete from tbgamerealbuy where buydate <= ' + FDate + ' and OutBal <> 0 ');
FMyQuery.ExecSQL;
mmShow.Lines.Add('实时采购表处理成功!');
except
begin
mmShow.Lines.Add('实时采购表处理失败!');
end;
end;
end;

procedure TfrmOAManager.DoGameStorage(FDate:String);
begin
try
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert thgamestorage select ' + FDate + ',* from tbgamestorage');
FMyQuery.ExecSQL;
mmShow.Lines.Add('库存表处理完毕!');
except
begin
mmShow.Lines.Add('库存表处理失败!');
end;
end;
end;

procedure TfrmOAManager.DoGeneral(FDate:String);
var
i:Integer;
Exectype,game:String;
RegMembers,NewBuyCount,NewBuyVolume,RegCount,RegVolume,TotalCount,TotalVolume:String;
FDataList:TStringList;
PropertyID:String;
FLastDate:String;
FBuysite: String;
begin
try
FDataList := TStringList.Create;
FLastDate := IntToStr(DateToInt(IncDay(IntToDate(StrtoInt(FDate)),-1)));
FMyquery.SQL.Clear;
FMyQuery.sql.Add('delete from tbGeneralStat where statdate = ' + FDate);
FMyQuery.ExecSQL;
FMyQuery.SQL.Clear;
FMyQuery.sql.Add('select exectype,markettype,game,count(*),sum(volume) from tbgamejour ' +
' where execdate = ' + FDate + ' and canceltype = ' +
'''' + '0' + '''' + ' group by exectype,markettype,game');
FMyQuery.Open;
while Not FMyQuery.eofdo
begin
FDataList.Add(FMyquery.Fields.Fields[0].AsString + '|' +
FMyQuery.Fields.Fields[1].AsString + '|' +
FMyQuery.Fields.Fields[2].AsString + '|' +
FMyQuery.Fields.Fields[3].AsString + '|' +
FMyQuery.Fields.Fields[4].AsString + '|');
FMyQuery.Next;
end;
begin
Trans(FDataList.Count);
if Not MYSQLDB.Connected then
MySQLconnect;
for i := 0 to FDataList.Count - 1do
begin
ExecType := GetPart(FDataList.Strings,'|',1);
game := GetPart(FDataList.Strings,'|',3);
FMyQuery.sql.clear;
FMyQuery.SQL.add('select count(*),sum(volume) from tbgamejour a, ' +
' tbcustomer b where a.customerid = b.customerid and b.registerdate = ' +
FDate + ' and exectype = ' + '''' + ExecType + '''' +
' and game = ' + '''' + Game + '''' + ' and canceltype = ' + '''' + '0' + '''');
FMyQuery.Open;
while Not FMyQuery.Eofdo
begin
if FMyQuery.Fields.Fields[1].AsString = '' then
FDataList.Strings := FDataList.Strings + FMyquery.Fields.Fields[0].AsString + '|' + '0' + '|'
else
FDataList.Strings := FDataList.Strings + FMyquery.Fields.Fields[0].AsString + '|' +
FMyQuery.Fields.Fields[1].AsString + '|' ;
FMyquery.Next;
end;
//网站成交
if exectype = '0' then
begin
if game = 'WOW' then
PropertyID := '1'
else
if game = 'EUWOW' then
PropertyID := '2'
else
if Game = 'Guild Wars' then
PropertyID := '3'
else
if game = 'Lineage2' then
PropertyID := '4'
else
PropertyID := '1';
MYSQLQuery.SQL.Clear;
MYSQLQuery.SQL.Add('select count(*),sum(volume) from blizzard_order_jour where ' +
' execdate = ' + FDate + ' and game = ' + '''' + game + '''');
MYSQLQuery.Open;
while Not MYSQLQuery.Eofdo
begin
if MYSQLQuery.Fields.Fields[1].AsString = '' then
FDataList.Strings := FDataList.Strings + MYSQLQuery.Fields.Fields[0].AsString + '|' + '0' + '|'
else
FDataList.Strings := FDataList.Strings + MYSQLQuery.Fields.Fields[0].AsString + '|' +
MYSQLQuery.Fields.Fields[1].AsString + '|' ;
MySQLQuery.Next;
end;
if Game = 'WOW' then
begin
MYSQLQuery.SQL.Clear;
MYSQLQuery.SQL.Add('select count(*) from blizzard_member_register where registerdate = ' + FLastDate);
MYSQLQuery.Open;
while Not MYSQLQuery.Eofdo
begin
FDataList.Strings := FDataList.Strings + MYSQLQuery.Fields.Fields[0].AsString + '|' ;
MySQLQuery.Next;
end;
end;
end;

if exectype = 'H' then
begin
if Not Game4PowerDB.Connected then
Game4PowerConnect;
Game4PowerQuery.SQL.Clear;
Game4PowerQuery.SQL.Add('select count(*),sum(volume) from twgamejour where ' +
' execdate = ' + FDate + ' and game = ' + '''' + game + '''');
Game4PowerQuery.Open;
while Not Game4PowerQuery.Eofdo
begin
if Game4PowerQuery.Fields.Fields[1].AsString = '' then
FDataList.Strings := FDataList.Strings + Game4PowerQuery.Fields.Fields[0].AsString + '|' + '0' + '|'
else
FDataList.Strings := FDataList.Strings + Game4PowerQuery.Fields.Fields[0].AsString + '|' +
Game4PowerQuery.Fields.Fields[1].AsString + '|' ;
Game4PowerQuery.Next;
end;
if Game = 'WOW' then
begin
Game4PowerQuery.SQL.Clear;
Game4PowerQuery.SQL.Add('select count(*) from twcustomer where registerdate = ' + FLastDate);
Game4PowerQuery.Open;
while Not Game4PowerQuery.Eofdo
begin
FDataList.Strings := FDataList.Strings + Game4PowerQuery.Fields.Fields[0].AsString + '|' ;
Game4PowerQuery.Next;
end;
end;
end;

FBuysite := FClientInfo.FDictionary.GetChildTypeName(1026,exectype[1]);
RegMembers := '0';
NewBuyCount := GetPart(FDataList.Strings,'|',6);
NewBuyVolume := GetPart(FDataList.Strings,'|',7);
RegCount := '0';
RegVolume := '0';
TotalCount := GetPart(FDataList.Strings,'|',4);
TotalVolume := GetPart(FDataList.Strings,'|',5);
if GetPartcount(FDataList.Strings,'|') > 7 then
begin
RegCount := GetPart(FDataList.Strings,'|',8);
RegVolume := GetPart(FDataList.Strings,'|',9);
end;
if GetPartcount(FDataList.Strings,'|') > 9 then
RegMembers := GetPart(FDataList.Strings,'|',10);
FMyQuery.sql.Clear;
FMyQuery.sql.Add('insert into tbGeneralStat values(' + Fdate + ',' +
'''' + FBuysite + '''' + ',' +
'''' + GetPart(FDataList.Strings,'|',2) + '''' + ',' +
'''' + GetPart(FDataList.Strings,'|',3) + '''' + ',' +
Regmembers + ',' +
NewBuyCount + ',' +
NewBuyVolume + ',' +
RegCount + ',' +
RegVolume + ',' +
TotalCount + ',' +
TotalVolume + ')');
FMyQuery.ExecSQL;

ProcessTrans(i + 1);
end;
endTrans;
FDataList.Free;
MmShow.Lines.Add('综合统计完毕!');
except
begin
MmShow.Lines.Add('综合统计失败!');
end;
end;
end;

procedure TfrmOAManager.DoStat(FDate:String);
var
FStatList: TStatList;
begin
try
FStatList := TStatlist.Create;
FStatList.CalIntoDB(StrToInt(Fdate));
FStatList.Free;
MmShow.Lines.Add('统计数据插入完毕!');
except
begin
MmShow.Lines.Add('统计数据插入失败!');
end;
end;
end;

procedure TfrmOAManager.DoStorageJour;
begin
try
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert thstoragejour select ' + FDate + ',* from tbstoragejour ' +
' where tradedate <= ' + FDate + ' and ' +
'((OutBal <> 0) or (SetVolume < 0 and Volume < 0 and OutBal = 0) or (SetPrice <0) or (Price < 0))');
FMyQuery.ExecSQL;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('delete from tbstoragejour ' +
' where tradedate <= ' + FDate + ' and ' +
'((OutBal <> 0) or (SetVolume < 0 and Volume < 0 and OutBal = 0) or (SetPrice <0) or (Price < 0)) ');
FMyQuery.ExecSQL;
mmShow.Lines.Add('库存流水表处理完毕!');
except
begin
mmShow.Lines.Add('库存流水表处理失败!');
end;
end;
end;

procedure TfrmOAManager.DoWgSell;
begin
try
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert thwgsell select ' + Fdate + ',* from tbwgsell ' +
'where Selldate <= ' + Fdate + ' and (status = ' +
'''' + '2' + '''' + ' or status = ' + '''' + '6' + '''' + ' or status = ' +
'''' + '7' + '''' + ' or status = ' +
'''' + '0' + '''' + ' or status = ' + '''' + '1' + '''' +')' );
FMyQuery.ExecSQL;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('delete tbwgsell ' +
'where Selldate <= ' + Fdate + ' and (status = ' +
'''' + '2' + '''' + ' or status = ' + '''' + '6' + '''' + ' or status = ' +
'''' + '7' + '''' + ' or status = ' +
'''' + '0' + '''' + ' or status = ' + '''' + '1' + '''' +')' );
FMyQuery.ExecSQL;;
mmShow.Lines.Add('网站采购表处理完毕!');
except
begin
mmShow.Lines.Add('网站采购表处理失败!');
end;
end;
end;

{ TStatList }
function TStatList.Add(FDate: Integer;
FMarketType: Char;
FGame: String;
FSellVolume: Integer;
FSellBal, FSellPrice, FBuyBal:do
uble;
FBuyVolume: Integer;
FBuyPrice:do
uble;
FNeedSendVolume: Integer;
FNeedSendBal:do
uble;
FStockVolume: Integer;
FStockBal,
FstockPrice:do
uble;
FSendVolume: Integer;
FSendBal:do
uble;
FCBVolume:Integer;
FCBBal:Double;
FLostVolume: Integer;
FLostBal, FIncome:do
uble): Integer;
var
Ptr:PStatUnit;
begin
New(Ptr);
Ptr.Date := FDate;
Ptr.MarketType := FMarketType;
StrPLCopy(Ptr.Game,FGame,SizeOf(Ptr.Game));
Ptr.SellVolume := FSellVolume;
Ptr.SellBal := FSellBal;
Ptr.SellPrice := FSellPrice;
Ptr.BuyBal := FBuyBal;
Ptr.BuyVolume := FBuyVolume;
Ptr.BuyPrice := FBuyPrice;
Ptr.NeedSendVolume := FNeedSendVolume;
Ptr.NeedSendBal := FNeedSendBal;
Ptr.StockVolume := FStockVolume;
Ptr.StockBal := FStockBal;
Ptr.StockPrice := FStockPrice;
Ptr.SendVolume := FSendVolume;
Ptr.SendBal := FSendBal;
Ptr.CBVolume := FCBVolume;
Ptr.CBBal := FCBBal;
Ptr.LostVolume := FLostVolume;
Ptr.LostBal := FLostBal;
Ptr.Income := FIncome;
result := Add(Ptr);
end;

function TStatList.Add(FDate: Integer;
FMarketType: Char;
FGame: String;
FType: Char;
FVolume: Integer;
FBal:do
uble): Integer;
var
Ptr:PStatUnit;
begin
Ptr := FindBy(FDate,FmarketType,FGame);
if Not Assigned(Ptr) then
begin
New(Ptr);
Ptr.Date := FDate;
Ptr.MarketType := FMarketType;
StrPLCopy(Ptr.Game,FGame,SizeOf(Ptr.Game));
Ptr.SellVolume := 0;
ptr.SellBal := 0;
ptr.SellPrice := 0;
Ptr.BuyBal := 0;
Ptr.BuyVolume := 0;
Ptr.BuyPrice := 0;
ptr.NeedSendVolume := 0;
ptr.NeedSendBal := 0;
ptr.StockVolume := 0;
ptr.StockPrice := 0;
Ptr.StockBal := 0;
Ptr.SendVolume := 0;
Ptr.SendBal := 0;
Ptr.CBVolume := 0;
Ptr.CBBal := 0;
ptr.LostVolume := 0;
Ptr.LostBal := 0;
ptr.Income := 0;
Add(Ptr);
end;
if FType = '0' then
begin
Ptr.SellVolume := FVolume;
Ptr.SellBal := FBal;
if Ptr.SellVolume = 0 then
Ptr.SellPrice := 0
else
Ptr.SellPrice := Ptr.SellBal / Ptr.SellVolume;
end
else
if Ftype = '1' then
begin
Ptr.BuyBal := Ptr.BuyBal + FBal;
Ptr.BuyVolume := Ptr.BuyVolume + Fvolume;
if Ptr.BuyVolume = 0 then
Ptr.BuyPrice := 0
else
Ptr.BuyPrice := Ptr.BuyBal / Ptr.BuyVolume;
end
else
if FType = '2' then
begin
Ptr.NeedSendVolume := FVolume;
Ptr.NeedSendBal := FBal;
end
else
if FType = '3' then
begin
Ptr.StockVolume := FVolume;
Ptr.StockBal := FBal;
if Ptr.StockVolume = 0 then
Ptr.StockPrice := 0
else
Ptr.StockPrice := Ptr.StockBal / Ptr.StockVolume;
end
else
if FType = '4' then
begin
Ptr.SendVolume := Fvolume;
Ptr.SendBal := FBal;
end
else
if Ftype = '5' then
begin
Ptr.LostVolume := Ptr.LostVolume + Fvolume;
Ptr.LostBal := Ptr.LostBal + FBal;
end
else
if FType = '6' then
begin
Ptr.CBVolume := Ptr.CBVolume + FVolume;
Ptr.CBBal := Ptr.CBBal + FBal;
end;
result := 0;
end;

function TStatList.CalIncome(FMarketType:char = #0;FGame:String = ''): TStringList;
var
i:integer;
FLastDate:Integer;
tmpStr:String;
ptr:PGameUnit;
Ptr1,Ptr2:PStatUnit;
InCome:Double;
totalIncome:Double;
begin
result := TStringList.Create;
if (FGame <> '') or (CalIntoDB(DateToInt(now))) then
begin
FLastDate := DatetoInt(incDay(Now,-1));
FMyQuery.SQL.Clear;
if FGame = '' then
FMyQuery.SQL.add('select * from thstat where date = ' + Inttostr(FlastDate))
else
FMyQuery.SQL.add('select * from thstat where date = ' + Inttostr(FlastDate) + ' and markettype = ' + '''' + FmarketType + '''' +
'and game = ' + '''' + FGame + '''');
FMyQuery.Open;
while Not FMyQuery.Eofdo
begin
Add(FMyQuery.fields.fields[0].AsInteger,FMyQuery.fields.fields[1].AsString[1],
FMyQuery.Fields.Fields[2].AsString,
FMyQuery.fields.fields[3].AsInteger,FMyQuery.fields.fields[4].AsFloat,
FMyQuery.fields.fields[5].AsFloat,FMyQuery.fields.fields[6].AsFloat,
FMyQuery.fields.fields[7].AsInteger,FMyQuery.fields.fields[8].AsFloat,
FMyQuery.fields.fields[9].AsInteger,FMyQuery.fields.fields[10].AsFloat,
FMyQuery.fields.fields[11].AsInteger,FMyQuery.fields.fields[12].AsFloat,
FMyQuery.fields.fields[13].AsFloat,FMyQuery.fields.fields[14].AsInteger,
FMyQuery.fields.fields[15].AsFloat,FMyQuery.fields.fields[16].AsInteger,
FMyQuery.fields.fields[17].AsFloat,FMyQuery.fields.fields[18].AsInteger,
FMyQuery.fields.fields[19].AsFloat,FMyQuery.fields.fields[20].AsFloat);
FMyQuery.Next;
end;

FMyQuery.SQL.Clear;
if FGame = '' then
FMyQuery.SQL.add('select * from thstat where date = ' + Inttostr(DatetoInt(Now)))
else
FMyQuery.SQL.add('select * from thstat where date = ' + Inttostr(DatetoInt(Now)) + ' and markettype = ' + '''' + FmarketType + '''' +
' and game = ' + '''' + FGame + '''');
FMyQuery.Open;
while Not FMyQuery.Eofdo
begin
Add(FMyQuery.fields.fields[0].AsInteger,FMyQuery.fields.fields[1].AsString[1],
FMyQuery.Fields.Fields[2].AsString,
FMyQuery.fields.fields[3].AsInteger,FMyQuery.fields.fields[4].AsFloat,
FMyQuery.fields.fields[5].AsFloat,FMyQuery.fields.fields[6].AsFloat,
FMyQuery.fields.fields[7].AsInteger,FMyQuery.fields.fields[8].AsFloat,
FMyQuery.fields.fields[9].AsInteger,FMyQuery.fields.fields[10].AsFloat,
FMyQuery.fields.fields[11].AsInteger,FMyQuery.fields.fields[12].AsFloat,
FMyQuery.fields.fields[13].AsFloat,FMyQuery.fields.fields[14].AsInteger,
FMyQuery.fields.fields[15].AsFloat,FMyQuery.fields.fields[16].AsInteger,
FMyQuery.fields.fields[17].AsFloat,FMyQuery.fields.fields[18].AsInteger,
FMyQuery.fields.fields[19].AsFloat,FMyQuery.fields.fields[20].AsFloat);
FMyQuery.Next;
end;
totalIncome := 0;
if FGame = '' then
begin
tmpStr := InttoStr(DateToInt(now)) + '日' + '各游戏销售成本利润分析';
result.Add(tmpStr);
tmpstr := tailfill('游戏',' ',20) + tailFill('销售量',' ',15) + tailFill('销售额',' ',15) + tailFill('销售价格',' ',15) +
tailFill('收购量',' ',15) + tailFill('收购额',' ',15) + tailFill('收购价格',' ',15) + tailFill('估计利润',' ',15);
result.Add(tmpStr);
//该游戏利润 = 销售收入 - 收购支出 + 市值差
//销售额 = 总销售额 - 退款额 - CB额
//收购支出 = 实时收购支出+仓库收购支出
//当日市值 = 库存市值 - 未发送市值
//昨日市值 = 昨日库存市值 - 昨日未发送市值
//for
end;
for i := 0 to FClientInfo.FGameList.Count - 1do
begin
Ptr := PGameUnit(FClientInfo.FGameList.Items);
if (FGame <> '') and (trim(Ptr.Game) <> FGame) then
Continue;
Ptr1 := FindBy(DatetoInt(Now),Ptr.MarketType,Ptr.Game);
ptr2 := FindBy(FLastDate,Ptr.MarketType,Ptr.Game);
if Assigned(Ptr1) and Assigned(Ptr2) then
begin
if FGame = '' then
begin
Income := (Ptr1.SellBal - Ptr1.CBBal - Ptr1.LostBal) - (Ptr1.BuyBal) + (Ptr1.StockBal - Ptr1.NeedSendBal) - (Ptr2.StockBal - Ptr2.NeedSendBal);
Income := StrToFloat(formatfloat('0.00',Income));
totalIncome := TotalIncome + Income;
tmpstr := tailfill(Ptr1.game,' ',20) + tailFill(IntToStr(Ptr1.SellVolume - Ptr1.CBVolume - Ptr1.LostVolume),' ',15) +
tailFill(floatToStr(Ptr1.SellBal),' ',15) + tailFill(formatfloat('0.00',Ptr1.SellPrice),' ',15) +
tailFill(IntToStr(Ptr1.BuyVolume),' ',15) + tailFill(floatToStr(Ptr1.BuyBal),' ',15) +
tailFill(formatfloat('0.00',Ptr1.BuyPrice),' ',15) + tailFill(floattoStr(Income),' ',15);
result.Add(tmpStr);
FMyQuery.SQL.Clear;
FMyQuery.SQL.add('update thstat set income = ' + floatToStr(Income) + ' where date = ' + Inttostr(DatetoInt(Now)) +
' and markettype = ' + '''' + Ptr.MarketType + '''' + ' and game = ' + '''' + Ptr.Game + '''' );
FMyQuery.ExecSQL;
end
else
begin
tmpStr := tailfill('销售总额:' + floatToStr(Ptr1.SellBal),' ',20) +
tailfill('退款总额:' + floatToStr(Ptr1.CBBal),' ',20) +
tailfill('损失总额:' + floatToStr(Ptr1.LostBal),' ',20) +
tailfill('收购总额:' + floatToStr(Ptr1.BuyBal),' ',20);
result.Add(tmpStr);
tmpStr := tailfill('今日库存总额:' + floatToStr(Ptr1.StockBal),' ',40) +
tailfill('今日未发总额:' + floatToStr(Ptr1.NeedSendBal),' ',40);
result.Add(tmpStr);
tmpStr := tailfill('昨日库存总额:' + floatToStr(Ptr2.StockBal),' ',40) +
tailfill('昨日未发总额:' + floatToStr(Ptr2.NeedSendBal),' ',40);
result.Add(tmpStr);
tmpStr := '利润 = (' + floatToStr(Ptr1.SellBal) + ' - ' + floatToStr(Ptr1.CBBal) + ' - ' + floatToStr(Ptr1.LostBal) +
') - ' + floatToStr(Ptr1.BuyBal) + ' + (' + floatToStr(Ptr1.StockBal) + ' - ' + floatToStr(Ptr1.NeedSendBal) + ')' +
' - (' + floattoStr(Ptr2.StockBal) + ' - ' + floatToStr(ptr2.NeedSendBal) + ')';
result.Add(tmpStr);

end;
end;
end;
if FGame = '' then
begin
tmpStr := tailfill('总计',' ',20) + tailFill('',' ',15) + tailFill('',' ',15) + tailFill('',' ',15) +
tailFill('',' ',15) + tailFill('',' ',15) + tailFill('',' ',15) + tailFill(floatToStr(TotalIncome),' ',15);
result.Add(tmpStr);
end;
end;
//result := 0;
end;

function TStatList.CalIntoDB(Fdate:Integer): Boolean;
var
i:Integer;
Ptr:PStatUnit;
begin
Clear;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('delete from thstat where date = ' + IntToStr(Fdate) );
FMyQuery.ExecSQL;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select markettype,game,sum(bal),sum(volume) from tbgamejour ' +
' where execdate = ' + IntToStr(Fdate) +
' group by MarketType,game');
FMyQuery.Open;
while Not FMyquery.Eofdo
begin
Add(DatetoInt(Now),
FMyQuery.Fields.Fields[0].AsString[1],
FMyQuery.fields.Fields[1].AsString,
'0',
FMyQuery.Fields.Fields[3].AsInteger,
FMyQuery.Fields.Fields[2].asfloat);
FMyQuery.Next;
end;

FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select markettype,game,sum(BuyVolume * BuyPrice),sum(BuyVolume) from tbGameRealBuy ' +
' where BuyDate = ' + IntToStr(Fdate) + ' and outbal <> 0 ' +
' group by MarketType,game');
FMyQuery.Open;
while Not FMyquery.Eofdo
begin
Add(DatetoInt(Now),
FMyQuery.Fields.Fields[0].AsString[1],
FMyQuery.fields.Fields[1].AsString,
'1',
FMyQuery.Fields.Fields[3].AsInteger,
FMyQuery.Fields.Fields[2].asfloat);
FMyQuery.Next;
end;

FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select markettype,game,sum(Volume * Price),sum(volume) from tbstoragejour ' +
' where TradeDate = ' + IntToStr(Fdate) + ' and CheckOpID <> 0 and volume >0' +
' group by MarketType,game');
FMyQuery.Open;
while Not FMyquery.Eofdo
begin
Add(DatetoInt(Now),
FMyQuery.Fields.Fields[0].AsString[1],
FMyQuery.fields.Fields[1].AsString,
'1',
FMyQuery.Fields.Fields[3].AsInteger,
FMyQuery.Fields.Fields[2].asfloat);
FMyQuery.Next;
end;

FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select markettype,game,sum(bal),sum(volume) from tbgamejour ' +
' where canceltype = ' + '''' + '0' + '''' +
' and senddate = 0 ' +
' group by MarketType,game');
FMyQuery.Open;
while Not FMyquery.Eofdo
begin
Add(DatetoInt(Now),
FMyQuery.Fields.Fields[0].AsString[1],
FMyQuery.fields.Fields[1].AsString,
'2',
FMyQuery.Fields.Fields[3].AsInteger,
FMyQuery.Fields.Fields[2].asfloat);
FMyQuery.Next;
end;

FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select markettype,game,sum(volume),sum(volume * Price) from tbgameStorage ' +
' group by MarketType,game');
FMyQuery.Open;
while Not FMyquery.Eofdo
begin
Add(DatetoInt(Now),
FMyQuery.Fields.Fields[0].AsString[1],
FMyQuery.fields.Fields[1].AsString,
'3',
FMyQuery.Fields.Fields[2].AsInteger,
FMyQuery.Fields.Fields[3].asfloat);
FMyQuery.Next;
end;

FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select markettype,game,sum(bal),sum(volume) from tbgamejour ' +
' where execdate = ' + IntToStr(Fdate) + ' and canceltype = ' + '''' + '0' + '''' +
' and senddate <> 0 ' +
' group by MarketType,game');
FMyQuery.Open;
while Not FMyquery.Eofdo
begin
Add(DatetoInt(Now),
FMyQuery.Fields.Fields[0].AsString[1],
FMyQuery.fields.Fields[1].AsString,
'4',
FMyQuery.Fields.Fields[3].AsInteger,
FMyQuery.Fields.Fields[2].asfloat);
FMyQuery.Next;
end;

FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select markettype,game,sum(bal),sum(volume) from tbgamejour ' +
' where canceltype <> ' + '''' + '0' + '''' +
' and senddate = 0 ' +
' group by MarketType,game');
FMyQuery.Open;
while Not FMyquery.Eofdo
begin
Add(DatetoInt(Now),
FMyQuery.Fields.Fields[0].AsString[1],
FMyQuery.fields.Fields[1].AsString,
'6',
FMyQuery.Fields.Fields[3].AsInteger,
FMyQuery.Fields.Fields[2].asfloat);
FMyQuery.Next;
end;

FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select markettype,game,sum(bal),sum(volume) from tbgamejour ' +
' where canceltype <> ' + '''' + '0' + '''' +
' and senddate <> 0 ' +
' group by MarketType,game');
FMyQuery.Open;
while Not FMyquery.Eofdo
begin
Add(DatetoInt(Now),
FMyQuery.Fields.Fields[0].AsString[1],
FMyQuery.fields.Fields[1].AsString,
'5',
FMyQuery.Fields.Fields[3].AsInteger,
FMyQuery.Fields.Fields[2].asfloat);
FMyQuery.Next;
end;

FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select markettype,game,sum(bal),sum(volume) from thgamejour ' +
' where execdate = ' + IntToStr(Fdate) + ' and canceltype <> ' + '''' + '0' + '''' +
' and senddate <> 0 ' +
' group by MarketType,game');
FMyQuery.Open;
while Not FMyquery.Eofdo
begin
Add(DatetoInt(Now),
FMyQuery.Fields.Fields[0].AsString[1],
FMyQuery.fields.Fields[1].AsString,
'5',
FMyQuery.Fields.Fields[3].AsInteger,
FMyQuery.Fields.Fields[2].asfloat);
FMyQuery.Next;
end;

for i := 0 to Count - 1do
begin
Ptr := Items;
FMyQuery.sql.Clear;
FMyQuery.SQL.Add('insert into thstat values(' + IntToStr(Fdate) + ',' +
'''' + Ptr.MarketType + '''' + ',' +
'''' + Ptr.Game + '''' + ',' +
IntTostr(Ptr.SellVolume) + ',' +
FloatToStr(Ptr.SellBal) + ',' +
floatToStr(Ptr.SellPrice) + ',' +
floatToStr(Ptr.BuyBal) + ',' +
IntToStr(Ptr.BuyVolume) + ',' +
floatToStr(Ptr.BuyPrice) + ',' +
IntToStr(Ptr.NeedSendVolume) + ',' +
floatToStr(Ptr.NeedSendBal) + ',' +
IntToStr(Ptr.StockVolume) + ',' +
floatToStr(Ptr.StockBal) + ',' +
floatToStr(Ptr.StockPrice) + ',' +
IntToStr(Ptr.SendVolume) + ',' +
floatToStr(Ptr.SendBal) + ',' +
IntToStr(Ptr.CBVolume) + ',' +
floatToStr(Ptr.CBBal) + ',' +
IntToStr(Ptr.LostVolume) + ',' +
FloattoStr(Ptr.LostBal) + ',' +
'0)');
FMyQuery.ExecSQL;
end;
result := true;
end;

function TStatList.FindBy(FDate: Integer;
FMarketType: Char;
FGame: String): PStatUnit;
var
i:Integer;
begin
result := nil;
for i := 0 to Count - 1do
begin
if (PStatUnit(Items)^.Date = FDate) and
(PStatUnit(Items)^.MarketType = FMarketType) and
(PStatUnit(Items)^.Game = FGame) then
begin
result := PStatUnit(items);
Break;
end;
end;
end;

procedure TStatList.Notify(Ptr: Pointer;
Action: TListNotification);
begin
if Action = lnDeleted then
begin
Dispose(Ptr);
end;
inherited;
end;

procedure TfrmOAManager.Button2Click(Sender: TObject);
begin
do
General(edDate.Text);
do
GameJour(edDate.Text);
do
StorageJour(edDate.Text);
do
FinanceJour(edDate.Text);
do
GameRealBuy(edDate.Text);
do
WgSell(edDate.Text);
do
GameStorage(edDate.Text);
do
Stat(edDate.Text);
FmyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tsserialno set date = ' + IntToStr(DateToInt(Now)) + ',serialno = 0' );
FMyQuery.ExecSQL;
end;

{
var
FStatList: TStatList;
begin
FStatList := TSTatList.Create;
FStatList.CalIntoDB(20051004);
MmShow.Lines := FStatList.CalIncome;
FStatList.free;
end;
}
procedure TfrmOAManager.FormCreate(Sender: TObject);
begin
edDate.Text := IntToStr(DatetoInt(Now));
FEmailList := TStringList.Create;
edFrom.Text := 'gold4power@gmail.com';
FClientInfo.FDictionary.SetCombList(1003,cbMarkettype);
PageControl1.ActivePageIndex := 0;
FSqLList := TStringList.Create;
end;

procedure TfrmOAManager.Button1Click(Sender: TObject);
var
i,j:Integer;
FEmail:String;
aStream: TStringStream;
Params: TStrings;
tmpStr:String;
FHaveSend:String;
begin
aStream := TStringStream.Create('');
params := TStringList.Create;
Gauge1.Visible := true;
Gauge1.MaxValue := FEmailList.Count;
Gauge1.Progress := 0;
tmpStr := '';
for j := 0 to MMContent.Lines.Count - 1do
begin
if j = 0 then
tmpStr := tmpStr + MMContent.Lines.Strings[j] + #13#10
else
tmpStr := tmpStr + #13#10 + MMContent.Lines.Strings[j];
end;
if (edFrom.Text <> '') and (edSubject.Text <> '') and (Mmcontent.Lines.Count <> 0) then
begin
FHaveSend := '';
for i := 0 to FEmailList.Count - 1do
begin
FEmail := Trim(FEmailList.Strings);
{
if Femail <> 'amandalcrawford@hotmail.com' then
begin
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tbcustomer set loginpassword = ' + '''' + '2' + '''' + ' where email = ' + '''' + FEmail + '''');
FMyQuery.ExecSQL;
end
else
begin
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tbcustomer set loginpassword = ' + '''' + '2' + '''' + ' where email = ' + '''' + FEmail + '''');
FMyQuery.ExecSQL;
exit;
end;
}
try
Params.Clear;
Params.Add('from=' + edfrom.Text );
//&to=sanple_wsc12312312@hotmail.com&subject=test&body=hi');
//Params.Add('to=' + FEmail);
Params.Add('to=' + FEmail);
//Params.Add('to=' + 'sanple_wsc@hotmail.com');
Params.Add('subject=' + edSubject.Text);
Params.Add('body=' + tmpStr);
IdHTTP1.Post('http://www.gold4power.com/web/mailapi.php',Params,aStream);
Gauge1.Progress := Gauge1.Progress + 1;
if FHaveSend = '' then
FhaveSend := ' where email = ' + '''' + FEmail + ''''
else
FHaveSend := FHaveSend + ' or email = ' + '''' + Femail + '''';
//if Length(FhaveSend) > 500 then
begin
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tbcustomer set loginpassword = ' + '''' + '2' + '''' + FHaveSend);
FMyQuery.ExecSQL;
FhaveSend := '';
end;
Application.ProcessMessages;
except
on e:Exceptiondo
begin

end;
end;
end;
end;
Gauge1.Visible := false;
aStream.Destroy;
Params.Free;
end;

procedure TfrmOAManager.FormDestroy(Sender: TObject);
begin
FEmailList.Free;
FSqLList.Free;
//TH1.Terminate;//销毁线程
// TH1.Destroy;
end;

procedure TfrmOAManager.Button3Click(Sender: TObject);
begin
FEmailList.Clear;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select distinct(email) from tbcustomer where loginpassword <> ' +
'''' + '2' + '''' + ' and email <> ' + '''' + '' + '''' + ' and email like ' + '''' + '%@%' + '''');
FMyQuery.Open;
while Not FMyQuery.Eofdo
begin
FEmailList.Add(FMyQuery.Fields.Fields[0].AsString);
FMyQuery.Next;
end;
FMyQuery.Close;
lbCount.Visible := true;
lbCount.Caption := '共' + IntToStr(FEmailList.count) + '条';
end;

procedure TfrmOAManager.Button5Click(Sender: TObject);
var
iCount:Integer;
tmpStr:String;
i:Integer;
FServer:String;
begin
FEmailList.Clear;
FServer := '';
for i := 0 to Mmcontent.Lines.Count - 1do
begin
tmpStr := filter(trim(mmcontent.lines.Strings));
if i = 0 then
FServer := ' and ( b.server = ' + '''' + tmpStr + ''''
else
if i = MmContent.Lines.Count - 1 then
Fserver := Fserver + ' or b.server = ' + '''' + tmpStr + '''' + ')'
else
begin
Fserver := Fserver + ' or b.server = ' + '''' + tmpStr + '''' ;
end;
end;

FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select distinct(a.email) from tbcustomer a,thgamejour b where a.customerid = b.customerid ' +
' and b.game = ' + '''' + 'WOW' + '''' +' and b.canceltype = ' +
'''' + '0' + '''' + ' and a.email <> ' + '''' + '' + '''' + FServer +
' and b.execdate >= 20051223');
FMyQuery.Open;
iCount := 0;
tmpStr := '';
while Not FMyQuery.Eofdo
begin
if iCount <= 200 then
tmpStr := tmpStr + '|' + FMyQuery.Fields.Fields[0].AsString
else
begin
FEmailList.Add(tmpStr);
FEmailList.Add('');
FEmailList.Add('');
FEmailList.Add('');

iCount := 0;
tmpStr := '';
end;
iCount := iCount + 1;
FMyQuery.Next;
end;
FMyQuery.Close;
lbCount.Visible := true;
lbCount.Caption := '共' + IntToStr(FEmailList.count) + '条';
FEmailList.SaveToFile('D:/work/批量邮件/batchemail' + IntToStr(DatetoInt(Now)));
end;

procedure TfrmOAManager.Button4Click(Sender: TObject);
var
iCount:integer;
tmpStr:String;
begin
FEmailList.Clear;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select distinct(email) from tbcustomer where loginpassword <> ' +
'''' + '2' + '''' + ' and email <> ' + '''' + '' + '''' + ' and email like ' + '''' + '%@%' + '''');
FMyQuery.Open;
iCount := 0;
tmpStr := '';
while Not FMyQuery.Eofdo
begin
iCount := iCount + 1;
if iCount = 1 then
FEmailList.Add(FMyQuery.Fields.Fields[0].AsString)
else
tmpStr := tmpStr + FMyQuery.Fields.Fields[0].AsString + ';';
if iCount = 20 then
begin
FEmaillist.add(tmpStr);
FEmaillist.add('');
iCount := 0;
tmpStr := '';
end;
//FEmailList.Add(FMyQuery.Fields.Fields[0].AsString);
FMyQuery.Next;
end;
FMyQuery.Close;
lbCount.Visible := true;
lbCount.Caption := '共' + IntToStr(FEmailList.count) + '条';
FEmaillist.SaveToFile('D:/BatchEmail.text');
end;

procedure TfrmOAManager.Button6Click(Sender: TObject);
const
KeyStr: array[0..3] of String = ('Normal','RPPVP','RP','PvP');
var
i,j,iPos:Integer;
FServerList:TStringList;
tmpStr:String;
isServer,isFind:Boolean;
FServer:String;
begin
if (memo1.Lines.Count > 0) and
(cbmarkettype.Text <> '') and
(cbGame.Text <> '') then
begin
Memo2.Lines.Clear;
FServerList := FClientInfo.FGameServerList.GetServerList(cbMarkettype.text[1],cbGame.text);
for i := 0 to Memo1.Lines.Count - 1do
begin
tmpStr := trim(Memo1.Lines.Strings);
isServer := false;
for j := 0 to 3do
begin
iPos := Pos(uppercase(KeyStr[j]),uppercase(tmpStr));
if iPos > 0 then
begin
isServer := true;
break;
end;
end;
if isServer then
begin
FServer := trim(Copy(tmpStr,1,iPos - 2));
isfind := false;
for J := 0 to FServerList.Count - 1do
begin
if Pos(uppercase(FServer),uppercase(FServerList.Strings[j])) > 0 then
begin
isfind := true;
Break;
end;
end;
if Not isFind then
Memo2.Lines.Add(Fserver);
end;
end
end;
end;

procedure TfrmOAManager.cbMarketTypeChange(Sender: TObject);
begin
if cbMarketType.Text <> '' then
FClientInfo.FGameList.SetGameList(cbMarketType.Text[1],cbGame);
end;

procedure TfrmOAManager.Button7Click(Sender: TObject);
var
i:Integer;
Server:String;
begin
for i := 0 to Memo2.Lines.Count - 1do
begin
Server := Memo2.Lines.Strings;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert into tsgameserver values(' + '''' + cbmarkettype.text[1] + '''' +
',' + '''' + cbGame.text + '''' + ',' + '''' + Filter(Server) + '-' + 'Alliance' + '''' +
',' + '''' + '' + '''' + ',' + '''' + '' + '''' + ',' + '''' + '' + '''' + ')' );
FMyQuery.ExecSQL;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert into tsgameserver values(' + '''' + cbmarkettype.text[1] + '''' +
',' + '''' + cbGame.text + '''' + ',' + '''' + Filter(Server) + '-' + 'Horde' + '''' +
',' + '''' + '' + '''' + ',' + '''' + '' + '''' + ',' + '''' + '' + '''' + ')' );
FMyQuery.ExecSQL;
end;
end;

procedure TfrmOAManager.Button8Click(Sender: TObject);
var
i,iPos:integer;
FDataList: TStringList;
FServerList: TStringList;
Server:String;
begin
FServerList := FClientInfo.FGameServerList.GetServerList('1','WOW');
FDataList := TStringList.Create;
for i := 0 to FServerList.count - 1do
begin
iPos := Pos('-Alliance',FServerList.Strings);
if iPos > 0 then
begin
Server := Copy(FServerList.Strings,1,iPos-1);
if FDataList.Count = 0 then
FDataList.Add('<OPTION value=&quot;US server: ' + Server + '&quot;
selected>' + Server + '</OPTION>')
else
FDataList.Add('<OPTION value=&quot;US server: ' + Server + '&quot;>' + Server + '</OPTION>');
end;
end;
FDataList.SaveToFile('D:/1.text');
FDataList.free;
end;

procedure TfrmOAManager.Button9Click(Sender: TObject);
var
i:Integer;
FDataList:TStringList;
extSearchNo,Game,Server:String;
Cost:Double;
begin
FDataList := TStringList.Create;
FMyQuery.sql.Clear;
FMyQuery.sql.Add('select extsearchno,game,server from tbgamejour where exectype = ' + '''' + '8' + '''' + ' and getbal = 0');
FMyQuery.Open;
while NOt FMyQuery.Eofdo
begin
FDataList.Add(FMyQuery.Fields.Fields[0].AsString + '|' +
FMyQuery.Fields.Fields[1].AsString + '|' +
FMyQuery.Fields.Fields[2].AsString + '|' );
FMyQuery.Next;
end;
for i := 0 to FDataList.Count - 1do
begin
ExtSearchNo := GetPart(FDatalist.Strings,'|',1);
Game := GetPart(FDatalist.Strings,'|',2);
Server := GetPart(FDatalist.Strings,'|',3);
Cost := GetCostPrice('1',Game,Server);
FMyQuery.SQL.Clear;
FMyQuery.sql.Add('update tbgamejour set getbal = volume * ' + floatToStr(Cost) +' where extsearchno = ' + '''' + ExtSearchno + '''');
FMyQuery.ExecSQL;
end;
FDataList.Free;
end;

procedure TfrmOAManager.Button11Click(Sender: TObject);
begin
if Not frmmain.DBWEB.Connected then
begin
try
frmmain.DBWEB.Open;
MessageDlg('连接成功' , mtError, [mbOK], 0);
frmmain.QueryMySQL.DatabaseName := frmmain.DBWEB.DatabaseName;
except
on e:Exceptiondo
begin
MessageDlg('连接失败:请检查' + E.Message, mtError, [mbOK], 0);
end;
end;
end
end;
{
for i := 0 to FTableList.Count - 1do
begin
if i > 0 then
FDataList.Add('');
tmpStr := 'delete from ' + FTableList.Strings;
FDataList.Add(tmpStr);
FQuery.SQL.Clear;
FQuery.SQL.Add('select * from ' + FtableList.Strings);
FQuery.Open;
while Not FQuery.Eofdo
begin
tmpStr := 'insert into ' + FTableList.Strings + ' values(';
for j := 0 to FQuery.FieldCount - 1do
begin
if FQuery.FieldDefs.Items[j].DataType = ftString then
tmpStr := tmpStr + '''' + Filter(FQuery.Fields.Fields[j].AsString) + ''''
else
tmpStr := tmpStr + FQuery.Fields.Fields[j].AsString;
if j <> FQuery.FieldCount - 1 then
tmpStr := tmpStr + ','
else
tmpStr := tmpStr + ')';
end;
FDataList.Add(tmpStr);
FQuery.Next;
end;
end;
}
procedure TfrmOAManager.Button10Click(Sender: TObject);
function GetTableCount:Integer;
begin
result := 0;
if cbDict.Checked then
result := result + 1;
if cbParam.Checked then
result := result + 1;
if cbGameList.Checked then
result := result + 1;
if cbItem.Checked then
result := result + 1;
if cbStorage.Checked then
result := result + 1;
if cbItemSell.Checked then
result := result + 1;
if cbPowerLevel.Checked then
result := result + 1;
if cbGameJour.Checked then
result := result + 1;
if cbLevelProcess.Checked then
result := result + 1;
end;
function SameLoad(SourceQuery,DestQuery:TQuery;SourceTableName,DestTableName:String;Prosess:TGauge):Boolean;
var
i:Integer;
tmpStr:String;
begin
try
result := true;
//DestQuery.SQL.Clear;
FSqlList.Add('delete from ' + DestTableName + ';');
//DestQuery.SQL.Add('delete from ' + DestTableName);
//DestQuery.ExecSQL;
SourceQuery.SQL.Clear;
Sourcequery.SQL.Add('select * from ' + SourceTableName);
Sourcequery.Open;
Prosess.MaxValue := SourceQuery.RecordCount;
Prosess.Progress := 0;
while Not SourceQuery.Eofdo
begin
Prosess.Progress := Prosess.Progress + 1;
tmpStr := 'insert into ' + DesttableName + ' values(';
for i := 0 to SourceQuery.FieldCount - 1do
begin
if SourceQuery.FieldDefs.Items.DataType = ftString then
tmpStr := tmpStr + '''' + NoBlankFilter(SourceQuery.Fields.Fields.AsString) + ''''
else
tmpStr := tmpStr + SourceQuery.Fields.Fields.AsString;
if i <> SourceQuery.FieldCount - 1 then
tmpStr := tmpStr + ','
else
tmpStr := tmpStr + ')';
end;
//DestQuery.SQL.Clear;
//DestQuery.SQL.Add(tmpStr);
//DestQuery.ExecSQL;
FSqlList.Add(tmpStr+ ';');
Sourcequery.Next;
end;
except
on e:exceptiondo
begin
result := false;
end;
end;
end;
begin
{
if Not frmmain.DBWEB.Connected then
begin
try
frmmain.DBWEB.Open;
//MessageDlg('连接成功' , mtError, [mbOK], 0);
frmmain.QueryMySQL.DatabaseName := frmmain.DBWEB.DatabaseName;
except
on e:Exceptiondo
begin
MessageDlg('连接失败:请检查' + E.Message, mtError, [mbOK], 0);
end;
end;
end
else
frmmain.QueryMySQL.DatabaseName := frmmain.DBWEB.DatabaseName;
}
Gauge2.MaxValue := GetTableCount;
Gauge2.Progress := 0;
if cbDict.Checked then
begin
SameLoad(FMyQuery,frmMain.QueryMySQL,'tsDict','twDict',Gauge3);
Gauge2.Progress := gauge2.Progress + 1;
end;
if cbParam.Checked then
begin
SameLoad(FMyQuery,frmMain.QueryMySQL,'tsParam','twParam',Gauge3);
Gauge2.Progress := gauge2.Progress + 1;
end;
if cbGameList.Checked then
begin
SameLoad(FMyQuery,frmMain.QueryMySQL,'tsGame','twGame',Gauge3);
Gauge2.Progress := gauge2.Progress + 1;
end;
if cbItem.Checked then
begin
SameLoad(FMyQuery,frmMain.QueryMySQL,'tsGameItem','twGameItem',Gauge3);
Gauge2.Progress := gauge2.Progress + 1;
end;
if cbStorage.Checked then
begin
SameLoad(FMyQuery,frmMain.QueryMySQL,'tbGameStorage','twGameStorage',Gauge3);
Gauge2.Progress := gauge2.Progress + 1;
end;
if cbItemSell.Checked then
begin
SameLoad(FMyQuery,frmMain.QueryMySQL,'tbItemSell','twGoldSell',Gauge3);
Gauge2.Progress := gauge2.Progress + 1;
end;
if cbPowerLevel.Checked then
begin
SameLoad(FMyQuery,frmMain.QueryMySQL,'tbPowerLevel','twPowerLevel',Gauge3);
Gauge2.Progress := gauge2.Progress + 1;
end;
//
if cbGameJour.Checked then
begin
SameLoad(FMyQuery,frmMain.QueryMySQL,'tsDict','twDict',Gauge3);
Gauge2.Progress := gauge2.Progress + 1;
end;
if cbLevelProcess.Checked then
begin
SameLoad(FMyQuery,frmMain.QueryMySQL,'tsDict','twDict',Gauge3);
Gauge2.Progress := gauge2.Progress + 1;
end;
FSqlList.SaveToFile('c:/mysqltable.sql');
end;

procedure TfrmOAManager.Button12Click(Sender: TObject);
var
FDataList:TStringList;
begin
FDataList := TStringList.Create;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select distinct(server) from tbgamestorage where game= ' + '''' + 'WOW' + '''' +
' and Server like ' + '''' + '%-Alliance' + '''');
FMyQuery.Open;
while Not FMyQuery.Eofdo
begin
FDataList.Add(FMyQuery.fieldbyName('server').AsString);
FMyQuery.Next;
end;

FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select distinct(server) from tbgamestorage where game= ' + '''' + 'WOW' + '''' +
' and Server like ' + '''' + '%-Horde' + '''');
FMyQuery.Open;
while Not FMyQuery.Eofdo
begin
FDataList.Add(FMyQuery.fieldbyName('server').AsString);
FMyQuery.Next;
end;
FDataList.SaveToFile('d:/wowserver.text');
end;

procedure TfrmOAManager.Button13Click(Sender: TObject);
var
i,iLen,iPos:Integer;
tmpStr,RestStr:String;
FSerialNo: String;
Server,StockAccount,Stockaccount1,ActorName:String;
begin
for i := 0 to Memo1.Lines.Count - 1do
begin
tmpStr := Memo1.Lines.Strings;
iPos := Pos('-Alliance',tmpStr);
if iPos <= 0 then
begin
iPos := Pos('-Horde',tmpStr);
iLen := Length('-Horde');
end
else
iLen := Length('-Alliance');
if iPos > 0 then
begin
Server := trim(copy(tmpStr,1,iPos + iLen - 1));
restStr := Copy(tmpStr,iPos + iLen,Length(tmpStr) - iPos - iLen + 1);
restSTr := TrimTrans(DirtyTrans(restSTr));
StockAccount1 := GetPart(restSTr,' ',1);
StockAccount := GetPart(restSTr,' ',2);
ActorName := Getpart(restSTr,' ',3);
try
FMyQuery.sql.Clear;
FMyQuery.SQL.Add('update tbgamestorage set actorname = ' + '''' + ActorName + '''' +
', stockaccount = ' + '''' + stockaccount + '''' +
' where game = ' + '''' + 'WOW' + '''' + ' and stockaccount = ' +
'''' + Stockaccount1 + '''' + ' and server = ' + '''' + filter(server) + '''');
FMyQuery.ExecSQL;
FSerialNo := GetSerialNo;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert into tsOpPoint values(' + '''' + FSerialNo + '''' +
',' + '''' + IntToStr(FClientInfo.FOPID) + ''''+
',' + IntToStr(DateToInt(Now)) +
',' + IntToStr(timeToShortInt(Now)) +
',' + '''' + '1' + '''' +
',' + '''' + '新建角色' + '''' +
',' + IntToStr(FClientInfo.FOPID) +
',' + '1' + ')');
FMyQuery.ExecSQL;
{
FMyQuery.SQL.Add('insert into tbgamestorage values(' + '''' + '1' + '''' + ',' +
'''' + 'WOW' + '''' + ',' + '''' + Filter(Server) + '''' + ',' +
'''' + '' + '''' + ',' + '''' + StockAccount + '''' + ',' +
'''' + ActorName + '''' + ',0,0,0)');
}
//FMyQuery.ExecSQL;
except
On E:Exceptiondo
begin
Showmessage(e.Message);
end;
end;
end;
end;
end;

procedure TfrmOAManager.Button14Click(Sender: TObject);
var
i,iLen,iPos:Integer;
tmpStr,RestStr:String;
Server,StockAccount,StockAccount1,ActorName:String;
begin
for i := 0 to Memo1.Lines.Count - 1do
begin
tmpStr := Memo1.Lines.Strings;
iPos := Pos('-Alliance',tmpStr);
if iPos <= 0 then
begin
iPos := Pos('-Horde',tmpStr);
iLen := Length('-Horde');
end
else
iLen := Length('-Alliance');
if iPos > 0 then
begin
Server := trim(copy(tmpStr,1,iPos + iLen - 1));
restStr := Copy(tmpStr,iPos + iLen,Length(tmpStr) - iPos - iLen + 1);
restSTr := TrimTrans(DirtyTrans(restSTr));
StockAccount1 := GetPart(restSTr,' ',1);
StockAccount := GetPart(restSTr,' ',2);
ActorName := Getpart(restSTr,' ',3);
try
FMyQuery.sql.Clear;
FMyQuery.SQL.Add('update tspurchaseactor set stockaccount = ' + '''' + stockaccount + '''' +
',actorname = ' + '''' + actorname + '''' +
' where game = ' + '''' + 'WOW' + '''' +
' and server = ' + '''' + filter(Server) + '''' +
' and stockaccount = ' + '''' + StockAccount1 + '''');
FMyQuery.ExecSQL;
except
On E:Exceptiondo
begin
Showmessage(e.Message);
end;
end;
end;
end;
end;

procedure TfrmOAManager.Button15Click(Sender: TObject);
var
i,iPos:integer;
FDataList: TStringList;
FServerList: TStringList;
Server:String;
begin
FServerList := TStringList.Create;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select server,sum(volume) from tbgamestorage where game = ' +
'''' + 'WOW' + '''' + ' and volume <> 0 group by server ');
FMyQuery.Open;
while Not FMyQuery.Eofdo
begin
iPos := Pos('-Alliance',FMyQuery.Fields.Fields[0].AsString);
if iPos <= 0 then
begin
iPos := Pos('-Horde',FMyQuery.Fields.Fields[0].AsString);
end;
Server := Copy(FMyQuery.Fields.Fields[0].AsString,1,iPos - 1);
if FServerList.IndexOf(Server) < 0 then
FServerList.Add(Server);
FMyQuery.Next;
end;
FDataList := TStringList.Create;
for i := 0 to FServerList.Count - 1do
begin
FDataList.add('<OPTION value=&quot;US server: ' + FServerlist.Strings + '&quot;
selected>' +
FServerList.Strings + '</OPTION> ');
end;
FDataList.SaveToFile('D:/1.text');
FDataList.free;
end;

procedure TfrmOAManager.Button16Click(Sender: TObject);
var
i:Integer;
FDataList: TStringList;
begin
FDataList := TStringList.Create;
FdataList.LoadFromFile('D:/1.txt');
for i := 0 to FDataList.Count - 1do
begin
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tbworkgroup set creditlevel = ' + '''' + '7' + '''' +
' where workgroupid = ' + '''' + FDataList.Strings + '''');
FMyQuery.ExecSQL;
end;
FDataList.Free;
end;

procedure TfrmOAManager.Button17Click(Sender: TObject);
var
i,iPos:integer;
FDataList: TStringList;
FServerList: TStringList;
Server:String;
begin
FServerList := FClientInfo.FGameServerList.GetServerList('1','EUWOW');
FDataList := TStringList.Create;
for i := 0 to FServerList.count - 1do
begin
iPos := Pos('-Alliance',FServerList.Strings);
if iPos > 0 then
begin
Server := Copy(FServerList.Strings,1,iPos-1);
if FDataList.Count = 0 then
FDataList.Add('<OPTION value=&quot;EU server: ' + Server + '&quot;
selected>' + Server + '</OPTION>')
else
FDataList.Add('<OPTION value=&quot;EU server: ' + Server + '&quot;>' + Server + '</OPTION>');
end;
end;
FDataList.SaveToFile('D:/1.text');
FDataList.free;
end;

procedure TfrmOAManager.Button18Click(Sender: TObject);
var
i,iLen,iPos:Integer;
tmpStr,RestStr:String;
FSerialNo: String;
Server,StockAccount,Stockaccount1,ActorName:String;
begin
if (cbmarkettype.Text <> '') and (cbgame.Text <> '') then
begin
if button18.Caption <> '新服替换' then
begin
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select server,stockaccount from tbgamestorage where markettype = ' +
'''' + cbmarkettype.Text[1] + '''' + ' and game = ' + '''' + cbgame.Text + '''' +
' and actorname = ' + '''' + '' + '''' + ' order by stockaccount');
FMyQuery.Open;
while Not FMyQuery.Eofdo
begin
memo1.Lines.Add(FMyQuery.Fields.Fields[0].AsString + ' ' + FMyquery.Fields.Fields[1].AsString + ' ' +
FClientInfo.FAccountList.GetPassword('WOW',FMyquery.Fields.Fields[1].AsString) + ' ' );
FMyQuery.Next;
end;
button18.Caption := '新服替换';
end
else
begin
for i := 0 to Memo1.Lines.Count - 1do
begin
tmpStr := Memo1.Lines.Strings;
iPos := Pos('-Alliance',tmpStr);
if iPos <= 0 then
begin
iPos := Pos('-Horde',tmpStr);
iLen := Length('-Horde');
end
else
iLen := Length('-Alliance');
if iPos > 0 then
begin
Server := trim(copy(tmpStr,1,iPos + iLen - 1));
restStr := Copy(tmpStr,iPos + iLen,Length(tmpStr) - iPos - iLen + 1);
restSTr := TrimTrans(DirtyTrans(restSTr));
StockAccount1 := GetPart(restSTr,' ',1);
StockAccount := GetPart(restSTr,' ',1);
ActorName := Getpart(restSTr,' ',3);
try
FMyQuery.sql.Clear;
FMyQuery.SQL.Add('update tbgamestorage set actorname = ' + '''' + ActorName + '''' +
', stockaccount = ' + '''' + stockaccount + '''' +
' where game = ' + '''' + 'WOW' + '''' + ' and stockaccount = ' +
'''' + Stockaccount1 + '''' + ' and server = ' + '''' + filter(server) + '''');
FMyQuery.ExecSQL;
FSerialNo := GetSerialNo;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert into tsOpPoint values(' + '''' + FSerialNo + '''' +
',' + '''' + IntToStr(FClientInfo.FOPID) + ''''+
',' + IntToStr(DateToInt(Now)) +
',' + IntToStr(timeToShortInt(Now)) +
',' + '''' + '1' + '''' +
',' + '''' + '新建角色' + '''' +
',' + IntToStr(FClientInfo.FOPID) +
',' + '1' + ')');
FMyQuery.ExecSQL;
{
FMyQuery.SQL.Add('insert into tbgamestorage values(' + '''' + '1' + '''' + ',' +
'''' + 'WOW' + '''' + ',' + '''' + Filter(Server) + '''' + ',' +
'''' + '' + '''' + ',' + '''' + StockAccount + '''' + ',' +
'''' + ActorName + '''' + ',0,0,0)');
}
//FMyQuery.ExecSQL;
except
On E:Exceptiondo
begin
Showmessage(e.Message);
end;
end;
end;
end;
end;
end;
end;

procedure TfrmOAManager.Button19Click(Sender: TObject);
function EnumChildWindowsProc(hwnd: Integer): Boolean;
stdcall;
var
buffer: array[0..255] of Char;
begin
Result := True;
GetClassName(hwnd,buffer,256);
//得到类名
WritetoLog('D:/跟踪.txt',buffer);
end;
var
hwnd,hwnd1: Integer;
buffer: array[0..255] of Char;
begin
//Memo1.Clear;
hwnd := findWindow(nil,'World of Warcraft');
GetClassName(hwnd, buffer, 254);
hwnd1 := FindWindowEx(hwnd,0,'edit',nil);
WritetoLog('D:/跟踪.txt',buffer);
if (hwnd<>0 ) and (hwnd1 <> 0) then
EnumChildWindows(hwnd,@EnumChildWindowsProc,Integer(@hwnd));
end;

procedure TfrmOAManager.Button20Click(Sender: TObject);
var
i,iLen,iPos:Integer;
tmpStr,RestStr:String;
Server,StockAccount,ActorName,volume:String;
begin
for i := 0 to Memo1.Lines.Count - 1do
begin
tmpStr := Memo1.Lines.Strings;
iPos := Pos('-Alliance',tmpStr);
if iPos <= 0 then
begin
iPos := Pos('-Horde',tmpStr);
iLen := Length('-Horde');
end
else
iLen := Length('-Alliance');
if iPos > 0 then
begin
Server := trim(copy(tmpStr,1,iPos + iLen - 1));
restStr := Copy(tmpStr,iPos + iLen,Length(tmpStr) - iPos - iLen + 1);
restSTr := TrimTrans(DirtyTrans(restSTr));
StockAccount := GetPart(restSTr,' ',1);
ActorName := Getpart(restSTr,' ',2);
volume := Getpart(restSTr,' ',3);
try
FMyQuery.sql.Clear;
FMyQuery.SQL.Add('insert into tbgamestorage values(' + '''' + '1' + '''' + ',' +
'''' + 'EUWOW' + '''' + ',' +
'''' + Filter(server) + '''' + ',' +
'''' + '' + '''' + ',' +
'''' + Stockaccount + '''' + ',' +
'''' + ActorName + '''' + ',' +
volume + ',' +
'0.3' + ',0)');
FMyquery.ExecSQL;
{
FMyQuery.SQL.Add('update tbgamestorage set actorname = ' + '''' + ActorName + '''' +
', stockaccount = ' + '''' + stockaccount + '''' +
', volume = ' + volume +
', price = 0.3' +
' where game = ' + '''' + 'WOW' + '''' + ' and stockaccount = ' +
'''' + Stockaccount1 + '''' + ' and server = ' + '''' + filter(server) + '''');
FMyQuery.ExecSQL;
FSerialNo := GetSerialNo;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert into tsOpPoint values(' + '''' + FSerialNo + '''' +
',' + '''' + IntToStr(FClientInfo.FOPID) + ''''+
',' + IntToStr(DateToInt(Now)) +
',' + IntToStr(timeToShortInt(Now)) +
',' + '''' + '1' + '''' +
',' + '''' + '新建角色' + '''' +
',' + IntToStr(FClientInfo.FOPID) + ')');
FMyQuery.ExecSQL;

FMyQuery.SQL.Add('insert into tbgamestorage values(' + '''' + '1' + '''' + ',' +
'''' + 'WOW' + '''' + ',' + '''' + Filter(Server) + '''' + ',' +
'''' + '' + '''' + ',' + '''' + StockAccount + '''' + ',' +
'''' + ActorName + '''' + ',0,0,0)');
}
//FMyQuery.ExecSQL;
except
On E:Exceptiondo
begin
Showmessage(e.Message);
end;
end;
end;
end;
end;

procedure TfrmOAManager.Button21Click(Sender: TObject);
var
i,iLen,iPos:Integer;
tmpStr,RestStr:String;
Server,StockAccount,ActorName,volume:String;
begin
for i := 0 to Memo1.Lines.Count - 1do
begin
tmpStr := Memo1.Lines.Strings;
iPos := Pos('-Alliance',tmpStr);
if iPos <= 0 then
begin
iPos := Pos('-Horde',tmpStr);
iLen := Length('-Horde');
end
else
iLen := Length('-Alliance');
if iPos > 0 then
begin
Server := trim(copy(tmpStr,1,iPos + iLen - 1));
restStr := Copy(tmpStr,iPos + iLen,Length(tmpStr) - iPos - iLen + 1);
restSTr := TrimTrans(DirtyTrans(restSTr));
StockAccount := GetPart(restSTr,' ',1);
ActorName := Getpart(restSTr,' ',2);
volume := Getpart(restSTr,' ',3);
try
FMyQuery.sql.Clear;
FMyQuery.SQL.Add('insert into tspurchaseactor values(' + '''' + '1' + '''' + ',' +
'''' + 'EUWOW' + '''' + ',' +
'''' + Filter(server) + '''' + ',' +
'''' + Stockaccount + '''' + ',' +
'''' + ActorName + '''' + ',' +
'''' + 'B' + '''' + ')');
FMyquery.ExecSQL;
{
FMyQuery.SQL.Add('update tbgamestorage set actorname = ' + '''' + ActorName + '''' +
', stockaccount = ' + '''' + stockaccount + '''' +
', volume = ' + volume +
', price = 0.3' +
' where game = ' + '''' + 'WOW' + '''' + ' and stockaccount = ' +
'''' + Stockaccount1 + '''' + ' and server = ' + '''' + filter(server) + '''');
FMyQuery.ExecSQL;
FSerialNo := GetSerialNo;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert into tsOpPoint values(' + '''' + FSerialNo + '''' +
',' + '''' + IntToStr(FClientInfo.FOPID) + ''''+
',' + IntToStr(DateToInt(Now)) +
',' + IntToStr(timeToShortInt(Now)) +
',' + '''' + '1' + '''' +
',' + '''' + '新建角色' + '''' +
',' + IntToStr(FClientInfo.FOPID) + ')');
FMyQuery.ExecSQL;

FMyQuery.SQL.Add('insert into tbgamestorage values(' + '''' + '1' + '''' + ',' +
'''' + 'WOW' + '''' + ',' + '''' + Filter(Server) + '''' + ',' +
'''' + '' + '''' + ',' + '''' + StockAccount + '''' + ',' +
'''' + ActorName + '''' + ',0,0,0)');
}
//FMyQuery.ExecSQL;
except
On E:Exceptiondo
begin
Showmessage(e.Message);
end;
end;
end;
end;
end;

procedure TfrmOAManager.Button22Click(Sender: TObject);
var
i,iLen,iPos:Integer;
tmpStr,RestStr:String;
Server,StockAccount,ActorName:String;
begin
for i := 0 to Memo1.Lines.Count - 1do
begin
tmpStr := Memo1.Lines.Strings;
iPos := Pos('-Alliance',tmpStr);
if iPos <= 0 then
begin
iPos := Pos('-Horde',tmpStr);
iLen := Length('-Horde');
end
else
iLen := Length('-Alliance');
if iPos > 0 then
begin
Server := trim(copy(tmpStr,1,iPos + iLen - 1));
restStr := Copy(tmpStr,iPos + iLen,Length(tmpStr) - iPos - iLen + 1);
restSTr := TrimTrans(DirtyTrans(restSTr));
StockAccount := GetPart(restSTr,' ',1);
ActorName := Getpart(restSTr,' ',2);
try
FMyQuery.sql.Clear;
FMyQuery.SQL.Add('insert into tbgamestorage values(' + '''' + '1' + '''' + ',' +
'''' + 'WOW' + '''' + ',' +
'''' + Filter(server) + '''' + ',' +
'''' + '' + '''' + ',' +
'''' + Stockaccount + '''' + ',' +
'''' + ActorName + '''' + ',' +
'0' + ',' +
'0.0' + ',4)');
FMyquery.ExecSQL;
{
FMyQuery.SQL.Add('update tbgamestorage set actorname = ' + '''' + ActorName + '''' +
', stockaccount = ' + '''' + stockaccount + '''' +
', volume = ' + volume +
', price = 0.3' +
' where game = ' + '''' + 'WOW' + '''' + ' and stockaccount = ' +
'''' + Stockaccount1 + '''' + ' and server = ' + '''' + filter(server) + '''');
FMyQuery.ExecSQL;
FSerialNo := GetSerialNo;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert into tsOpPoint values(' + '''' + FSerialNo + '''' +
',' + '''' + IntToStr(FClientInfo.FOPID) + ''''+
',' + IntToStr(DateToInt(Now)) +
',' + IntToStr(timeToShortInt(Now)) +
',' + '''' + '1' + '''' +
',' + '''' + '新建角色' + '''' +
',' + IntToStr(FClientInfo.FOPID) + ')');
FMyQuery.ExecSQL;

FMyQuery.SQL.Add('insert into tbgamestorage values(' + '''' + '1' + '''' + ',' +
'''' + 'WOW' + '''' + ',' + '''' + Filter(Server) + '''' + ',' +
'''' + '' + '''' + ',' + '''' + StockAccount + '''' + ',' +
'''' + ActorName + '''' + ',0,0,0)');
}
//FMyQuery.ExecSQL;
except
On E:Exceptiondo
begin
Showmessage(e.Message);
end;
end;
end;
end;
end;

procedure TfrmOAManager.Button23Click(Sender: TObject);
var
i,iLen,iPos:Integer;
tmpStr,RestStr:String;
Server,StockAccount,ActorName:String;
begin
for i := 0 to Memo1.Lines.Count - 1do
begin
tmpStr := Memo1.Lines.Strings;
iPos := Pos('-Alliance',tmpStr);
if iPos <= 0 then
begin
iPos := Pos('-Horde',tmpStr);
iLen := Length('-Horde');
end
else
iLen := Length('-Alliance');
if iPos > 0 then
begin
Server := trim(copy(tmpStr,1,iPos + iLen - 1));
restStr := Copy(tmpStr,iPos + iLen,Length(tmpStr) - iPos - iLen + 1);
restSTr := TrimTrans(DirtyTrans(restSTr));
StockAccount := GetPart(restSTr,' ',1);
ActorName := Getpart(restSTr,' ',2);
try
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tspurchaseactor set stockaccount = ' + '''' + stockaccount + '''' + ',' +
'Actorname = ' + '''' + ActorName + '''' + ' where markettype = ' + '''' + '1' + '''' +
' and game = ' + '''' + 'WOW' + '''' +
' and server = ' + '''' + Filter(Server) + '''' +
' and creditlevel = ' + '''' + '8' + '''');
FMyquery.ExecSQL;
FMyQuery.sql.Clear;
FMyQuery.SQL.Add('insert into tbgamestorage values(' + '''' + '1' + '''' + ',' +
'''' + 'WOW' + '''' + ',' +
'''' + Filter(server) + '''' + ',' +
'''' + '' + '''' + ',' +
'''' + Stockaccount + '''' + ',' +
'''' + ActorName + '''' + ',' +
'0' + ',' +
'0.0' + ',5)');
FMyquery.ExecSQL;
except
On E:Exceptiondo
begin
Showmessage(e.Message);
end;
end;
end;
end;
end;

procedure TfrmOAManager.Button24Click(Sender: TObject);
var
i:integer;
tmpStr:String;
FDataList:TStringList;
FileName:String;
Account:String;
Password:String;
Server:String;
AMStaffer:String;
PMStaffer:String;
ActorClass:String;
iPos1,iPos2:Integer;
begin
FDataList := TStringList.Create;
FDataList.LoadFromFile('C:/排班');
for i := 0 to FDataList.count - 1do
begin
FileName := '';
tmpStr := FDataList.Strings;
if tmpStr = '' then
Continue;
FileName := GetPart(tmpStr,#9,1) + GetPart(tmpStr,#9,2) + GetPart(tmpStr,#9,3);
AMStaffer := GetPart(tmpStr,#9,4);
PMStaffer := GetPart(tmpStr,#9,5);
Account := GetPart(tmpStr,#9,6);
Password := GetPart(tmpStr,#9,7);
iPos1 := Pos(Password,tmpstr);
iPos2 := Pos('猎人',tmpStr);
ActorClass := '';
if iPos2 <= 0 then
begin
iPos2 := Pos('盗贼',tmpStr);
if iPos2 <= 0 then
iPos2 := Pos('术士',tmpStr)
else
ActorClass := '盗贼';
end
else
ActorClass := '猎人';
if iPos2 <= 0 then
Continue;
if ActorClass = '' then
ActorClass := '术士';
Server := trim(Copy(tmpStr,iPos1 + Length(password),iPos2 - iPos1 - Length(Password)));
fileName := 'D:/排班排班排班排班排班排班排班/' + FileName + '.txt';
WriteToLog(FileName,tailfill('帐号',' ',10) + Account);
WriteToLog(FileName,tailfill('密码',' ',10) + Password);
WriteToLog(FileName,tailfill('服务器',' ',10) + Server);
WriteToLog(FileName,tailfill('职业',' ',10) + ActorClass);
WriteToLog(FileName,tailfill('早班',' ',10) + AMStaffer);
WriteToLog(FileName,tailfill('晚班',' ',10) + PMStaffer);
end;
ShowMessage('生成成功!');
FDataList.Free;
end;

procedure TfrmOAManager.Button25Click(Sender: TObject);
var
i:Integer;
begin

for i := 1 to 90do
begin
//try
FMyQuery.sql.Clear;
FMyQuery.sql.Add('select * from tsopmenu where opid = ' + '8' + headfill(IntToStr(i),'0',3) +
' and menuid = 9009');
FMyQuery.Open;
if FMyQuery.RecordCount = 0 then
begin
FMyQuery.SQL.clear;
FMyQuery.SQL.add('insert into tsopmenu values(' + '8' + headfill(IntToStr(i),'0',3) + ',' + '9009)');
FMyQuery.ExecSQL;
end;
FMyQuery.sql.Clear;
FMyQuery.sql.Add('select * from tsopmenu where opid = ' + '8' + headfill(IntToStr(i),'0',3) +
' and menuid = 9005');
FMyQuery.Open;
if FMyQuery.RecordCount = 0 then
begin
FMyQuery.SQL.clear;
FMyQuery.SQL.add('insert into tsopmenu values(' + '8' + headfill(IntToStr(i),'0',3) + ',' + '9005)');
FMyQuery.ExecSQL;
end;
//except
end;
end;

procedure TfrmOAManager.Button26Click(Sender: TObject);
var
i:Integer;
iPos:Integer;
tmpStr:string;
Server:String;
begin
for i := 0 to memo1.Lines.Count - 1do
begin
tmpStr := trim(memo1.Lines.Strings);
if tmpStr = '' then
continue;
iPos := Pos('PV',tmpstr);
Server := '';
if iPos > 0 then
Server := trim(Copy(tmpStr,1,iPos -1))
else
Continue;

FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert into tsgameserver values( ' + '''' + '1' + '''' + ',' +
'''' + 'TFWOW' + '''' + ',' + '''' + Server + '-Alliance' + '''' + ',' +
'''' + '' + '''' + ',' + '''' + '' + '''' + ',' + '''' + '0' + '''' + ')');
FMyQuery.ExecSQL;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert into tsgameserver values( ' + '''' + '1' + '''' + ',' +
'''' + 'TFWOW' + '''' + ',' + '''' + Server + '-Horde' + '''' + ',' +
'''' + '' + '''' + ',' + '''' + '' + '''' + ',' + '''' + '0' + '''' + ')');
FMyQuery.ExecSQL;

end;
end;

procedure TfrmOAManager.Button28Click(Sender: TObject);
var
i:Integer;
FStringList: TStringList;
Level:String;
EXP:String;
tmpStr:String;
begin
FStringList := TStringList.Create;
FStringList.LoadFromFile('c:/exp');
for i := 0 to FStringList.Count - 1do
begin
tmpStr := trimTrans(FStringList.Strings);
Level := GetPart(tmpStr,#9,1);
Exp := GetPart(tmpStr,#9,2);
FMyQuery.SQL.clear;
FMyQuery.SQL.add('insert into tbgameexp values(' + '''' + '1' + '''' +
',' + '''' + 'WOW' + '''' + ',' + Level + ',' + EXP + ')');
FMyQuery.ExecSQL;
end;
FStringList.free;
end;

procedure TfrmOAManager.Button29Click(Sender: TObject);
var
i:integer;
tmpStr:String;
FDataList: TStringList;
FSerialNoList:TStringList;
begin
FDataList := TStringList.Create;
FSerialNoList := TStringList.Create;
FDataList.LoadFromFile('D:/工作室管理系统/硬盘序列号文件.txt');
for i := 0 to FDataList.Count - 1do
begin
tmpStr := trimTrans(FDataList.Strings);
if (tmpStr = '') or (GetpartCount(tmpStr,' ') = 1) then
continue;
if FSerialNoList.IndexOf(getPart(tmpStr,' ',2)) = -1 then
FSerialNoList.Add(getPart(tmpStr,' ',2));
end;
FSerialNoList.SaveToFile('D:/工作室管理系统/硬盘唯一序列号文件.txt');
FSerialNoList.Free;
FDataList.Free;
end;

procedure TfrmOAManager.Button31Click(Sender: TObject);
var
i:Integer;
FStringList: TStringList;
tmpStr:String;
server,stockaccount,actorname,creditlevel:String;
begin
FStringList := TStringList.Create;
FStringList.LoadFromFile('d:/恢复.text');
for i := 0 to FStringList.Count - 1do
begin
tmpStr := FStringList.Strings;
tmpStr := trimTrans(tmpStr) + #9;
Server := GetPart(tmpStr,#9,3);
stockaccount := GetPart(tmpStr,#9,4);
actorname := GetPart(tmpStr,#9,5);
creditlevel := trim(GetPart(tmpStr,#9,6));
FmyQuery.SQL.Clear;
FMyQuery.sql.Add('update tspurchaseactor set stockaccount = ' + '''' + StockAccount + '''' +
',actorname = ' + '''' + ActorName + '''' + ' where game = ' + '''' + 'WOW' + '''' +
' and server = ' + '''' + Filter(Server) + '''' +
' and creditlevel = ' + '''' + creditlevel + '''');
FMyQuery.ExecSQL;
end;
FStringList.Free;
end;

procedure TfrmOAManager.Button32Click(Sender: TObject);
var
i,iPos,iLen:Integer;
FStrList:TStringList;
tmpStr,restStr:String;
Server,StockAccount,Actorname,Frozenvolume:String;
begin
FStrList := TStringList.Create;
FStrList.LoadFromFile('c:/cangku.txt');
for i := 0 to FStrList.Count - 1do
begin
tmpStr := trimTrans(DirtyTrans(FStrList.Strings)) ;
iPos := Pos('-Alliance',tmpStr);
if iPos <= 0 then
begin
iPos := Pos('-Horde',tmpStr);
iLen := Length('-Horde');
end
else
iLen := Length('-Alliance');
if iPos > 0 then
begin
Server := trim(copy(tmpStr,1,iPos + iLen - 1));
restStr := trim(Copy(tmpStr,iPos + iLen,Length(tmpStr) - iPos - iLen + 1)) + ' ';
if tmpStr = '' then
continue;
StockAccount := GetPart(restStr,' ',1);
Actorname := GetPart(restStr,' ',2);
Frozenvolume := GetPart(restStr,' ',3);
FMyQuery.SQL.clear;
FMyQuery.SQL.Add('update tbgamestorage set stockaccount = ' + '''' + StockAccount + '''' +
',Actorname = ' + '''' + ActorName + '''' +
' where server = ' + '''' + filter(Server) + '''' +
' and game = ' + '''' + 'WOW' + '''' +
' and frozenvolume = ' + Frozenvolume);
FMyquery.ExecSQL;
end;
end;
FStrList.free;
end;

procedure TfrmOAManager.Button33Click(Sender: TObject);
var
i:Integer;
FDataList:TStringList;
FGame,FAccount,RegisterDate:String;
begin
FDataList := TStringList.Create;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select * from tsaccountsupply ');
FMyQuery.Open;
while Not FMyQuery.Eofdo
begin
if FMyquery.FieldByName('limitdate').AsString = '' then
begin
FDataList.Add(FMyQuery.fieldByName('game').AsString + '|' + FMyQuery.fieldByName('account').AsString + '|'
+ FMyQuery.fieldByname('inputDate').AsString + '|');
end;
FMyQuery.Next;
end;
for i := 0 to FDataList.Count - 1do
begin
FGame := GetPart(FDataList.Strings,'|',1);
FAccount := GetPart(FDataList.Strings,'|',2);
RegisterDate := GetPart(FDataList.Strings,'|',3);
RegisterDate := IntToStr(DatetoInt(incmonth(InttoDate(StrToInt(RegisterDate)),3)));
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tsaccountsupply set limitdate = ' + registerDate +
',limittime = ' + '121212' + ' where game = ' + '''' + FGame + '''' +
' and account = ' + '''' + FAccount + '''');
FMyQuery.ExecSQL;
end;
FDataList.Free;
end;

procedure TfrmOAManager.Button35Click(Sender: TObject);
var
i:integer;
tmpStr:String;
begin
FMyQuery.SQL.Clear;
FMyQuery.SQL.add('update tsgameserver set mark = ' + '''' + '0' + '''' +
' where markettype= ' + '''' + cbmarketType.Text[1] + '''' +
' and game = ' + '''' + cbGame.Text + '''' );
FMyQuery.ExecSQL;
for i := 0 to Memo1.Lines.Count - 1do
begin
tmpStr := memo1.Lines.Strings;
FMyQuery.SQL.Clear;
FMyQuery.SQL.add('update tsgameserver set mark = ' + '''' + '1' + '''' +
' where markettype= ' + '''' + cbmarketType.Text[1] + '''' +
' and game = ' + '''' + cbGame.Text + '''' +
' and server = ' + '''' + filter(tmpStr + '-Alliance') + '''' );
FMyQuery.ExecSQL;
FMyQuery.SQL.Clear;
FMyQuery.SQL.add('update tsgameserver set mark = ' + '''' + '1' + '''' +
' where markettype= ' + '''' + cbmarketType.Text[1] + '''' +
' and game = ' + '''' + cbGame.Text + '''' +
' and server = ' + '''' + filter(tmpStr + '-Horde') + '''' );
FMyQuery.ExecSQL;
end;
ShowMessage('导入成功');
end;

procedure TfrmOAManager.Button36Click(Sender: TObject);
var
i,j:integer;
bfind:Boolean;
FServerList:TStringlist;
FServer:String;
begin
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select * from tsgameserver where markettype= ' + '''' + cbmarketType.Text[1] + '''' +
' and game = ' + '''' + cbGame.Text + '''' +
' and mark = ' + '''' + '1' + '''');
FMyQuery.open;
FServerList := TStringList.Create;
while Not FMyQuery.Eofdo
begin
FServer := FMyQuery.FieldByName('server').AsString;
if Pos('-Alliance',FServer) > 0 then
FServer := Copy(FServer,1,Length(FServer) - Length('-Alliance'))
else
FServer := Copy(FServer,1,Length(FServer) - Length('-Horde'));
if FServerList.IndexOf(Fserver) <0 then
FServerList.Add(FServer);
FMyQuery.Next;
end;
for i := 0 to memo1.Lines.Count - 1do
begin
bfind := false;
for j := 0 to FServerList.Count - 1do
begin
if trim(uppercase(FServerList.Strings[j])) = trim(uppercase( memo1.Lines.Strings)) then
begin
bfind := true;
Break;
end;
end;
if Not bfind then
memo2.Lines.Add(memo1.Lines.Strings);
end;
FServerList.Free;
end;

procedure TfrmOAManager.Button37Click(Sender: TObject);
var
i,j,iCount:Integer;
FCustList: TStringList;
Source,BuySite,ExecType:String;
RefundCount:Integer;
RefundBal:Double;
CustType:Char;
BuyGame:String;
totalBuyBal:Double;

LastBuyDate,LastBuyVolume:Integer;
LastBuyBal:Double;
LastBuyServer:String;
LastDeliveryTime:String;

PreBuyDate,PreBuyVolume:Integer;
PreBuyBal:Double;
PreBuyServer:String;
PreDeliveryTime:String;
CustLevel:Char;
ActiveType:char;
Count:Integer;
FDataList:TStringList;
FWebID:String;
FDiscount:String;
FCustomer:String;
Femail:String;
begin
FCustList := TStringList.Create;
FDataList := TStringList.Create;
FDataList.LoadfromFile('d:/webregister.txt');
if FileExists('D:/Cust5.text' ) then
FCustList.LoadFromFile('D:/Cust5.text' )
else
begin
FMyquery.SQL.Clear;
FMyquery.SQL.Add('select customerid,email from tbcustomer where markettype = ' + '''' + '1' + '''' + ' and registerdate <> ' + IntToStr(DateToInt(Now)) +
' and email = ' + '''' + 'vegeta351c@hotmail.com' + '''');
//FMyquery.SQL.Add('select customerid,email from tbcustomer where markettype = ' + '''' + '1' + '''' + ' and registerdate <> ' + IntToStr(DateToInt(Now)) );
FMyQuery.Open;
while Not FMyQuery.Eofdo
begin
if Pos('@',FMyQuery.Fields.Fields[1].AsString) > 0 then
FCustList.Add(FMyQuery.Fields.Fields[0].AsString + '|' + FMyQuery.Fields.Fields[1].AsString + '|');
FMyquery.Next;
end;
FCustList.SaveToFile('d:/cust5.text');
end;
gauge2.MaxValue := FCustList.Count;
gauge2.Progress := 0;
for i := 0 to FCustList.Count - 1do
begin
try
FCustomer := GetPart(FCustList.Strings,'|',1);
Femail := GetPart(FCustList.Strings,'|',2);
if FCustomer = '' then
continue;
FMyQuery.SQL.Clear;
FMyQuery.sql.Add('select * from thgamejour where customerid = ' + '''' + Filter(FCustomer) + '''' + ' order by execdate,exectime');
FMyquery.Open;
iCount := 0;
RefundCount := 0;
RefundBal := 0;
LastBuyDate := 0;
LastBuyVolume := 0;
LastBuyBal := 0;
LastBuyServer := '';
LastDeliveryTime := '';
PreBuyDate := 0;
PreBuyVolume := 0;
PreBuyBal := 0;
PreBuyServer := '';
PreDeliveryTime := '';
totalBuyBal := 0;
CustLevel := '1';
FDiscount := '';
FWebID := '';
Count := FMyQuery.RecordCount;
while Not FMyQuery.Eofdo
begin
if iCount = 0 then
begin
Source := FClientInfo.FDictionary.GetChildTypeName(1026,FMyQuery.FieldByName('exectype').AsString[1]);
end;
if FMyQuery.FieldByName('canceltype').AsString[1] = '5' then
CustLevel := '7'
else
if FMyQuery.FieldByName('canceltype').AsString[1] = '0' then
begin
if iCount = Count - 1 then
begin
LastBuyDate := FMyQuery.FieldByName('execDate').AsInteger;
LastBuyVolume := FMyQuery.FieldByName('volume').AsInteger;
LastBuyBal := FMyQuery.FieldByName('bal').AsFloat;
LastBuyServer := FMyQuery.FieldByName('server').AsString;
if (FMyQuery.FieldByName('senddate').AsInteger <> 0) and (FMyQuery.FieldByName('sendtime').AsInteger <> 0) then
LastDeliveryTime := GetWheel(FMyQuery.FieldByName('execdate').AsInteger,FMyQuery.FieldByName('exectime').AsInteger,
FMyQuery.FieldByName('senddate').AsInteger,FMyQuery.FieldByName('sendtime').AsInteger)
else
LastDeliveryTime := '无法统计';
end
else
begin
PreBuyDate := FMyQuery.FieldByName('execDate').AsInteger;
PreBuyVolume := FMyQuery.FieldByName('volume').AsInteger;
PreBuyBal := FMyQuery.FieldByName('bal').AsFloat;
PreBuyServer := FMyQuery.FieldByName('server').AsString;
if (FMyQuery.FieldByName('senddate').AsInteger <> 0) and (FMyQuery.FieldByName('sendtime').AsInteger <> 0) then
PreDeliveryTime := GetWheel(FMyQuery.FieldByName('execdate').AsInteger,FMyQuery.FieldByName('exectime').AsInteger,
FMyQuery.FieldByName('senddate').AsInteger,FMyQuery.FieldByName('sendtime').AsInteger)
else
PreDeliveryTime := '无法统计';
end;
totalBuyBal := totalBuyBal + FMyQuery.FieldByName('bal').AsFloat;
end
else
if FMyQuery.FieldByName('canceltype').AsString[1] <> '0' then
begin
LastBuyDate := FMyQuery.FieldByName('execDate').AsInteger;
RefundCount := RefundCount + 1;
RefundBal := RefundBal + FMyQuery.FieldByName('bal').AsFloat;
end;
ExecType := FMyQuery.FieldByName('exectype').AsString;
BuyGame := FMyQuery.FieldByName('game').AsString;
iCount := iCount + 1;
FMyQuery.Next;
end;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tbcustomer set buycount = ' + IntToStr(iCount) +
' ,BuyBal = ' + floatToStr(totalBuyBal) +
' where customerid = ' + '''' + Filter(FCustomer) + '''');
FMyQuery.ExecSQL;
FWebID := '0';
for j := 0 to FDataList.count - 1do
begin
if GetPartCount( FDataList.Strings[j],'|') > 3 then
begin
if Femail = GetPart(FDataList.Strings[j],'|',3) then
begin
FWebID := GetPart(FDataList.Strings[j],'|',1);
FDiscount := GetPart(FDataList.Strings[j],'|',4);
end;
end;
end;
if FDiscount ='' then
FDiscount := '0';
if Count = 1 then
CustLevel := '1';
if (Count >= 2) and (totalBuyBal > 0) then
CustLevel := '2';
if totalBuyBal / 8 > 200 then
CustLevel := '3';
if totalBuyBal / 8 > 500 then
CustLevel := '4';
if totalBuyBal / 8 > 1000 then
CustLevel := '5';
if totalBuyBal / 8 > 2000 then
CustLevel := '6';
if Count > 200 then
CustType := '4'
else
CustType := '0';
ActiveType := '1';
if LastBuyDate <> 0 then
begin
if daysbetween(IntToDate(LastBuyDate),Now) > 90 then
ActiveType := '3'
else
if daysbetween(IntToDate(LastBuyDate),Now) > 60 then
ActiveType := '2'
else
if (daysbetween(IntToDate(LastBuyDate),Now) < 30) then
begin
if (daysbetween(IntToDate(LastBuyDate),Now) < 15) and (iCount > 2) then
Activetype := '0'
else
ActiveType := '1';
end;
end;
BuySite := FClientInfo.FDictionary.GetChildTypeName(1026,ExecType[1]);
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('insert into tbCustomerDescribe values(' + '''' + Filter(FCustomer) + '''' + ',' +
'''' + Source + '''' + ',' +
'''' + CustLevel + '''' + ',' +
'''' + BuySite + '''' + ',' +
FWebID + ',' + FDiscount + ',0,' +
'''' + BuyGame + '''' + ',' +
'''' + CustType + '''' + ',' +
'''' + ActiveType + '''' + ',' +
IntTostr(RefundCount) + ',' +
floatToStr(RefundBal) + ',' +
IntToStr(LastBuyDate) + ',' +
floatToStr(LastBuyBal) + ',' +
IntToStr(LastBuyVolume) + ',' +
'''' + Filter(LastBuyServer) + '''' + ',' +
'''' + LastDeliveryTime + '''' + ',' +
IntToStr(PreBuyDate) + ',' +
floatToStr(PreBuyBal) + ',' +
IntToStr(PreBuyVolume) + ',' +
'''' + Filter(PreBuyServer) + '''' + ',' +
'''' + PreDeliveryTime + '''' + ',' +
'0,0,0,0,0,0,0,0,' + '''' + '0' + '''' + ')');
FMyQuery.ExecSQL;
except
on e:exceptiondo
begin
WriteToLog('D:/2.txt',FCustomer + ' '+ E.message);
end;
end;
gauge2.Progress := gauge2.Progress + 1;
Application.ProcessMessages;
end;
FDataList.free;
end;

procedure TfrmOAManager.Button39Click(Sender: TObject);
var
i,j:Integer;
FDataList:TStringList;
FEmail:String;
FWebID:String;
tmpStr:String;
iPos: Integer;
FCustomerID:String;
begin
FDataList := TStringList.Create;
FDataList.LoadFromFile('d:/1.txt');
begin
trans(FDataList.count);
for i := 0 to FDataList.Count - 1do
begin
try
tmpStr := FDataList.Strings;
tmpStr := trimTrans(DirtyTrans(tmpStr));
if trim(tmpStr) = '' then
continue;
Femail := getPart(tmpStr,' ',1);
if Pos('Inbox',tmpStr) > 0 then
begin
FWebid := '';
iPos := Pos('[Register:',tmpStr);
for j := iPos + Length('[Register:') to Length(tmpStr)do
begin
if tmpStr[j] = ']' then
break
else
FWebID := FwebID + tmpStr[j];
end;
end
else
FWebID := getPart(tmpStr,' ',2);
FMyQuery.SQL.Clear;
FMyquery.SQL.Add('select * from tbcustomer where email = ' + '''' + FEmail + '''');
FMyQuery.Open;
while Not FMyQuery.Eofdo
begin
FCustomerID := FMyQuery.FieldByName('customerid').AsString;
FMyQuery.Next;
end;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tbcustomerdescribe set webid = ' + Fwebid +
' where customerid = ' + '''' + Filter(FCustomerID) + '''');
FMyQuery.ExecSQL;
processTrans(i + 1);
except
begin

end;
end;
end;
endTrans;
FDataList.Free;
end;

procedure TfrmOAManager.Button38Click(Sender: TObject);
var
i:Integer;
BuySite,ExecType:String;
RefundCount:Integer;
RefundBal:Double;
BuyGame:String;
Buycount:Integer;
totalBuyBal:Double;

LastBuyServer:String;
LastDeliveryTime:String;

PreBuyDate,PreBuyVolume:Integer;
PreBuyBal:Double;
PreBuyServer:String;
PreDeliveryTime:String;
CustLevel:Char;

FDataList:TStringList;

FCustomer:String;

server:String;
volume:String;
bal:String;
execdate:String;
exectime:String;
senddate:String;
sendtime:String;
canceltype:String;
tmpStr:String;
begin

FDataList := TStringList.Create;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select * from tbgamejour where exectype <>' + '''' + '8' + '''');
FMyQuery.Open;
while Not FMyQuery.Eofdo
begin
FDataList.Add(FMyQuery.fieldByName('customerid').AsString + '|' +
FMyQuery.fieldByName('server').AsString + '|' +
FMyQuery.fieldByName('volume').AsString + '|' +
FMyQuery.fieldByName('bal').AsString + '|' +
FMyQuery.fieldByName('execdate').AsString + '|' +
FMyQuery.fieldByName('exectime').AsString + '|' +
FMyQuery.fieldByName('senddate').AsString + '|' +
FMyQuery.fieldByName('sendtime').AsString + '|' +
FMyQuery.fieldByName('canceltype').AsString + '|' +
FMyQuery.fieldByName('exectype').AsString + '|' +
FMyQuery.fieldByName('game').AsString + '|' +
FMyQuery.fieldByName('server').AsString);
FMyQuery.Next;
end;
gauge2.MaxValue := FDataList.Count;
gauge2.Progress := 0;
for i := 0 to FDataList.Count - 1do
begin
try
tmpStr := FDataList.Strings;
FCustomer := GetPart(tmpStr,'|',1);
server := GetPart(tmpStr,'|',2);
volume := GetPart(tmpStr,'|',3);
bal := GetPart(tmpStr,'|',4);
execdate := GetPart(tmpStr,'|',5);
exectime := GetPart(tmpStr,'|',6);
senddate := GetPart(tmpStr,'|',7);
sendtime := GetPart(tmpStr,'|',8);
canceltype := GetPart(tmpStr,'|',9);
ExecType := GetPart(tmpStr,'|',10);
BuyGame := GetPart(tmpStr,'|',11);
LastBuyServer := GetPart(tmpStr,'|',12);
BuySite := FClientInfo.FDictionary.GetChildTypeName(1026,ExecType[1]);
//先判断是否在customerdescribe

LastBuyServer := '';
LastDeliveryTime := '';
PreBuyDate := 0;
PreBuyVolume := 0;
PreBuyBal := 0;
PreBuyServer := '';
PreDeliveryTime := '';
RefundCount := 0;
refundBal := 0;
totalBuyBal := 0;
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select b.buycount,b.buybal,a.* from tbcustomerdescribe a,tbcustomer b ' +
' where a.customerid = b.customerid and a.customerid = ' + '''' + Filter(FCustomer) + '''');
FMyQuery.Open;
Buycount := 0;
while Not FMyQuery.Eofdo
begin
PreBuyDate := FMyQuery.fieldByName('lastbuydate').AsInteger;
PreBuyVolume := FMyQuery.fieldByName('LastBuyVolume').AsInteger;
PreBuyBal := FMyQuery.fieldByName('LastBuyBal').AsFloat;
PreBuyServer := FMyQuery.fieldByName('LastDeliveryTime').AsString;
PreDeliveryTime := FMyQuery.fieldByName('LastDeliveryTime').AsString;
RefundCount := FMyQuery.fieldByName('RefundCount').AsInteger;
RefundBal := FMyQuery.fieldByName('RefundBal').AsFloat;
totalBuyBal := FMyQuery.fieldByName('BuyBal').AsFloat;
Buycount := FMyQuery.fieldByName('Buycount').AsInteger;
FMyQuery.Next;
end;

CustLevel := '1';
if canceltype = '0' then
begin
//Buycount := Buycount + 1;
//totalBuyBal := totalBuyBal + bal;
if Buycount = 1 then
CustLevel := '1';
if (Buycount >= 2) and (totalBuyBal > 0) then
CustLevel := '2';
if totalBuyBal / 8 > 200 then
CustLevel := '3';
if totalBuyBal / 8 > 500 then
CustLevel := '4';
if totalBuyBal / 8 > 1000 then

CustLevel := '5';
if totalBuyBal / 8 > 2000 then
CustLevel := '6';
end
else
if CancelType = '5' then
CustLevel := '7';
//已发货
if (senddate <> '0') and (sendtime <> '0') then
begin
//非当日成交
if execdate <> senddate then
begin
LastDeliveryTime := GetWheel(StrToInt(execdate),StrToInt(exectime),StrToInt(senddate),StrToInt(sendtime));
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tbcustomerdescribe set CustomerLevel= ' + '''' + CustLevel + '''' +
',BuySite = ' + '''' + BuySite + '''' +
',BuyGame = ' + '''' + buyGame + '''' +
',LastDeliveryTime = ' + '''' + LastDeliveryTime + '''' +
' where customerid = ' + '''' + Filter(FCustomer) + '''');
FMyQuery.ExecSQL;
end
//当日成交
else
if execdate = senddate then
begin
LastDeliveryTime := GetWheel(StrToInt(execdate),StrToInt(exectime),StrToInt(senddate),StrToInt(sendtime));
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tbcustomerdescribe set CustomerLevel= ' + '''' + CustLevel + '''' +
',BuySite = ' + '''' + BuySite + '''' +
',BuyGame = ' + '''' + buyGame + '''' +
',ActiveType =' + '''' + '0' + '''' +
',LastBuyDate = ' + execdate +
',LastBuyBal = ' + bal +
',LastBuyVolume = ' + Volume +
',LastBuyServer = ' + '''' + filter(LastBuyServer) + '''' +
',LastDeliveryTime = ' + '''' + LastDeliveryTime + '''' +
',PreBuyDate = ' + IntToStr(PreBuyDate) +
',PreBuyBal = ' + floatToStr(PreBuyBal) +
',PreBuyVolume = ' + IntToStr(PreBuyVolume) +
',PreBuyServer = ' + '''' + filter(PreBuyServer) + '''' +
',PreDeliveryTime = ' + '''' + PreDeliveryTime + '''' +
' where customerid = ' + '''' + Filter(FCustomer) + '''');
FMyQuery.ExecSQL;
end;
end
//退款
else
if CancelType <> '0' then
begin
RefundCount := RefundCount + 1;
RefundBal := RefundBal + StrTofloat(Bal);
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tbcustomerdescribe set CustomerLevel= ' + '''' + CustLevel + '''' +
',BuySite = ' + '''' + BuySite + '''' +
',BuyGame = ' + '''' + buyGame + '''' +
',refundCount = ' + InttoStr(RefundCount) +
',refundbal = ' + floatToStr(RefundBal) +
' where customerid = ' + '''' + Filter(FCustomer) + '''');
FMyQuery.ExecSQL;
end
//要当日成交未发松
else
if execdate = IntToStr(DateToInt(now)) then
begin
//LastDeliveryTime := GetWheel(StrToInt(execdate),StrToInt(exectime),StrToInt(senddate),StrToInt(sendtime));
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tbcustomerdescribe set CustomerLevel= ' + '''' + CustLevel + '''' +
',BuySite = ' + '''' + BuySite + '''' +
',BuyGame = ' + '''' + buyGame + '''' +
',ActiveType =' + '''' + '0' + '''' +
',LastBuyDate = ' + execdate +
',LastBuyBal = ' + bal +
',LastBuyVolume = ' + Volume +
',LastBuyServer = ' + '''' + filter(LastBuyServer) + '''' +
',LastDeliveryTime = ' + '''' + '未发送' + '''' +
',PreBuyDate = ' + IntToStr(PreBuyDate) +
',PreBuyBal = ' + floatToStr(PreBuyBal) +
',PreBuyVolume = ' + IntToStr(PreBuyVolume) +
',PreBuyServer = ' + '''' + filter(preBuyServer) + '''' +
',PreDeliveryTime = ' + '''' + preDeliveryTime + '''' +
' where customerID = ' + '''' + Filter(FCustomer) + '''');
FMyQuery.ExecSQL;
end;
except
begin

end;
end;
//如果不在 customerdescribe 找 customer
//如果还不在记日志
gauge2.Progress := gauge2.Progress + 1;
Application.ProcessMessages;
end;
FDataList.free;
end;

procedure TfrmOAManager.Button40Click(Sender: TObject);
var
i:Integer;
FDataList:TStringList;
Femail,FDiscount,FCustomerID:String;
begin
FDataList := TStringList.Create;
FDataList.LoadfromFile('d:/webregister.txt');
begin
Trans(FDataList.Count);
for i := 0 to FDataList.Count - 1do
begin
try
Femail := GetPart(FDataList.Strings,'|',3);
FDiscount := GetPart(FDataList.Strings,'|',4);
FMyQuery.SQL.Clear;
FMyQuery.sql.Add('select customerid from tbcustomer where email = ' + '''' + FEmail + '''');
FMyQuery.Open;
FCustomerID := '0';
while Not FMyQuery.Eofdo
begin
FCustomerID := FMyQuery.Fields.Fields[0].AsString;
FMyQuery.Next;
end;
if (FCustomerID <> '0') and (FDiscount <> '') then
begin
FMyQuery.sql.Clear;
FMyQuery.sql.Add('update tbcustomerdescribe set buydiscount = ' + FDiscount +
' where customerid = ' + '''' + FCustomerID + '''' );
FMyQuery.ExecSQL;
end;
except
begin

end;
end;
processTrans(i + 1);
end;
endTrans;
FDataList.Free;
end;

procedure TfrmOAManager.Button42Click(Sender: TObject);
var
i:Integer;
Exectype,game:String;
RegMembers,NewBuyCount,NewBuyVolume,RegCount,RegVolume,TotalCount,TotalVolume:String;
FDataList:TStringList;
PropertyID:String;
FLastDate:String;
FBuysite: String;
FDate:String;
begin
try
FDataList := TStringList.Create;
FDate := edit1.Text;
FLastDate := IntToStr(DateToInt(IncDay(IntToDate(StrtoInt(FDate)),-1)));
FMyquery.SQL.Clear;
FMyQuery.sql.Add('delete from tbGeneralStat where statdate = ' + FDate);
FMyQuery.ExecSQL;
FMyQuery.SQL.Clear;
FMyQuery.sql.Add('select exectype,markettype,game,count(*),sum(volume) from thgamejour ' +
' where execdate = ' + FDate + ' and canceltype = ' +
'''' + '0' + '''' +
' group by exectype,markettype,game');
FMyQuery.Open;
while Not FMyQuery.eofdo
begin
FDataList.Add(FMyquery.Fields.Fields[0].AsString + '|' +
FMyQuery.Fields.Fields[1].AsString + '|' +
FMyQuery.Fields.Fields[2].AsString + '|' +
FMyQuery.Fields.Fields[3].AsString + '|' +
FMyQuery.Fields.Fields[4].AsString + '|');
FMyQuery.Next;
end;

FMyQuery.SQL.Clear;
FMyQuery.sql.Add('select exectype,markettype,game,count(*),sum(volume) from tbgamejour ' +
' where execdate = ' + FDate + ' and canceltype = ' +
'''' + '0' + '''' +
' group by exectype,markettype,game');
FMyQuery.Open;
while Not FMyQuery.eofdo
begin
for i := 0 to FDataList.Count - 1do
begin
if (FMyquery.Fields.Fields[0].AsString = GetPart(FDataList.Strings,'|',1)) and
(FMyquery.Fields.Fields[1].AsString = GetPart(FDataList.Strings,'|',2)) and
(FMyquery.Fields.Fields[2].AsString = GetPart(FDataList.Strings,'|',3)) then
begin
FDataList.Strings := UpdatePart(FDataList.Strings,'|',4,IntToStr(FMyquery.Fields.Fields[3].AsInteger + StrToInt(GetPart(FDataList.Strings,'|',4))));
FDataList.Strings := UpdatePart(FDataList.Strings,'|',5,IntToStr(FMyquery.Fields.Fields[4].AsInteger + StrToInt(GetPart(FDataList.Strings,'|',5))));
Break;
end;
end;
FMyQuery.Next;
end;

begin
Trans(FDataList.Count);
if Not MYSQLDB.Connected then
MySQLconnect;
for i := 0 to FDataList.Count - 1do
begin
ExecType := GetPart(FDataList.Strings,'|',1);
game := GetPart(FDataList.Strings,'|',3);
FMyQuery.sql.clear;
FMyQuery.SQL.add('select count(*),sum(volume) from thgamejour a, ' +
' tbcustomer b where a.customerid = b.customerid and b.registerdate = ' +
FDate + ' and exectype = ' + '''' + ExecType + '''' +
' and game = ' + '''' + Game + '''' + ' and canceltype = ' + '''' + '0' + '''');
FMyQuery.Open;
while Not FMyQuery.Eofdo
begin
if FMyQuery.Fields.Fields[1].AsString = '' then
FDataList.Strings := FDataList.Strings + FMyquery.Fields.Fields[0].AsString + '|' + '0' + '|'
else
FDataList.Strings := FDataList.Strings + FMyquery.Fields.Fields[0].AsString + '|' +
FMyQuery.Fields.Fields[1].AsString + '|' ;
FMyquery.Next;
end;
//网站成交
if exectype = '0' then
begin
if game = 'WOW' then
PropertyID := '1'
else
if game = 'EUWOW' then
PropertyID := '2'
else
if Game = 'Guild Wars' then
PropertyID := '3'
else
if game = 'Lineage2' then
PropertyID := '4'
else
PropertyID := '1';
MYSQLQuery.SQL.Clear;
MYSQLQuery.SQL.Add('select count(*),sum(volume) from blizzard_order_jour where ' +
' execdate = ' + FDate + ' and game = ' + '''' + game + '''');
MYSQLQuery.Open;
while Not MYSQLQuery.Eofdo
begin
if MYSQLQuery.Fields.Fields[1].AsString = '' then
FDataList.Strings := FDataList.Strings + MYSQLQuery.Fields.Fields[0].AsString + '|' + '0' + '|'
else
FDataList.Strings := FDataList.Strings + MYSQLQuery.Fields.Fields[0].AsString + '|' +
MYSQLQuery.Fields.Fields[1].AsString + '|' ;
MySQLQuery.Next;
end;
if Game = 'WOW' then
begin
MYSQLQuery.SQL.Clear;
MYSQLQuery.SQL.Add('select count(*) from blizzard_member_register where registerdate = ' + FLastDate);
MYSQLQuery.Open;
while Not MYSQLQuery.Eofdo
begin
FDataList.Strings := FDataList.Strings + MYSQLQuery.Fields.Fields[0].AsString + '|' ;
MySQLQuery.Next;
end;
end;
end;
if exectype = 'H' then
begin
if Not Game4PowerDB.Connected then
Game4PowerConnect;
Game4PowerQuery.SQL.Clear;
Game4PowerQuery.SQL.Add('select count(*),sum(volume) from twgamejour where ' +
' execdate = ' + FDate + ' and game = ' + '''' + game + '''');
Game4PowerQuery.Open;
while Not Game4PowerQuery.Eofdo
begin
if Game4PowerQuery.Fields.Fields[1].AsString = '' then
FDataList.Strings := FDataList.Strings + Game4PowerQuery.Fields.Fields[0].AsString + '|' + '0' + '|'
else
FDataList.Strings := FDataList.Strings + Game4PowerQuery.Fields.Fields[0].AsString + '|' +
Game4PowerQuery.Fields.Fields[1].AsString + '|' ;
Game4PowerQuery.Next;
end;
if Game = 'WOW' then
begin
Game4PowerQuery.SQL.Clear;
Game4PowerQuery.SQL.Add('select count(*) from twcustomer where registerdate = ' + FLastDate);
Game4PowerQuery.Open;
while Not Game4PowerQuery.Eofdo
begin
FDataList.Strings := FDataList.Strings + Game4PowerQuery.Fields.Fields[0].AsString + '|' ;
Game4PowerQuery.Next;
end;
end;
end;

FBuysite := FClientInfo.FDictionary.GetChildTypeName(1026,exectype[1]);
RegMembers := '0';
NewBuyCount := GetPart(FDataList.Strings,'|',6);
NewBuyVolume := GetPart(FDataList.Strings,'|',7);
RegCount := '0';
RegVolume := '0';
TotalCount := GetPart(FDataList.Strings,'|',4);
TotalVolume := GetPart(FDataList.Strings,'|',5);
if GetPartcount(FDataList.Strings,'|') > 7 then
begin
RegCount := GetPart(FDataList.Strings,'|',8);
RegVolume := GetPart(FDataList.Strings,'|',9);
end;
if GetPartcount(FDataList.Strings,'|') > 9 then
RegMembers := GetPart(FDataList.Strings,'|',10);
FMyQuery.sql.Clear;
FMyQuery.sql.Add('insert into tbGeneralStat values(' + Fdate + ',' +
'''' + FBuysite + '''' + ',' +
'''' + GetPart(FDataList.Strings,'|',2) + '''' + ',' +
'''' + GetPart(FDataList.Strings,'|',3) + '''' + ',' +
Regmembers + ',' +
NewBuyCount + ',' +
NewBuyVolume + ',' +
RegCount + ',' +
RegVolume + ',' +
TotalCount + ',' +
TotalVolume + ')');
FMyQuery.ExecSQL;

ProcessTrans(i + 1);
end;
endTrans;
FDataList.Free;
MmShow.Lines.Add('综合统计完毕!');
except
begin
MmShow.Lines.Add('综合统计失败!');
end;
end;
end;

procedure TfrmOAManager.Button43Click(Sender: TObject);
begin
do
General(edDate.Text);
end;

procedure TfrmOAManager.Button44Click(Sender: TObject);
begin

do
GameJour(edDate.Text);
end;

procedure TfrmOAManager.Button45Click(Sender: TObject);
begin

do
StorageJour(edDate.Text);
end;

procedure TfrmOAManager.Button46Click(Sender: TObject);
begin

do
FinanceJour(edDate.Text);
end;

procedure TfrmOAManager.Button47Click(Sender: TObject);
begin

do
GameRealBuy(edDate.Text);
end;

procedure TfrmOAManager.Button48Click(Sender: TObject);
begin

do
WgSell(edDate.Text);
end;

procedure TfrmOAManager.Button49Click(Sender: TObject);
begin

do
GameStorage(edDate.Text);
end;

procedure TfrmOAManager.Button50Click(Sender: TObject);
begin

do
Stat(edDate.Text);
end;

procedure TfrmOAManager.Button51Click(Sender: TObject);
begin
FmyQuery.SQL.Clear;
FMyQuery.SQL.Add('update tsserialno set date = ' + IntToStr(DateToInt(Now)) + ',serialno = 0' );
FMyQuery.ExecSQL;
MmShow.Lines.Add('流水处理完毕!');
end;

procedure TfrmOAManager.Button53Click(Sender: TObject);
function TransServer(FServer:String;Game:String):String;
begin
if Pos('''',FServer) > 0 then
begin
result := '''' + FClientInfo.FGameServerList.GetServer1('1',game,fserver) + '''';
end
else
result := '''' + FServer + '''';
end;
var
iCount:Integer;
Fserver:String;
GameID:String;
ServerID:Integer;
begin
if Not Game4PowerDB.Connected then
Game4PowerConnect;
FMyQuery.sql.Clear;
FMyQuery.sql.Add('select * from tsgameserver where game = ' + '''' + 'WOW' + '''' +
' or game = ' + '''' + 'EUWOW' + '''' + ' order by markettype,game,server');
FMyQuery.Open;
begin
trans(FMyQuery.RecordCount);
iCount := 0;
while Not FMyQuery.Eofdo
begin
iCount := iCount + 1;
ProcessTrans(iCount);
if FMyQuery.fieldByName('game').AsString = 'WOW' then
GameID := '1'
else
GameID := '2';
FServer := TransServer(FMyQuery.fieldByName('server').AsString,FMyQuery.fieldByName('game').AsString);
Game4PowerQuery.SQL.Clear;
Game4PowerQuery.SQL.Add('select serverID from twgoldsell where markettype = ' + '''' + '1' + '''' +
' and game = ' + '''' + FMyQuery.fieldByName('game').AsString + '''' +
' and server = ' + FServer +
' and unit = 100');
Game4PowerQuery.open;
ServerID := 0;
while Not Game4PowerQuery.Eofdo
begin
ServerID := Game4PowerQuery.Fields.Fields[0].AsInteger;
Game4PowerQuery.Next;
end;

Game4PowerQuery.SQL.Clear;
Game4PowerQuery.SQL.Add('insert into twgoldsell values(' + '0' + ',' +
'''' + FMyQuery.fieldByName('markettype').AsString[1] + '''' + ',' +
GameID + ',' +
'''' + FMyQuery.fieldByName('game').AsString + '''' + ',' +
IntToStr(ServerID) + ',' +
FServer + ',' +
'''' + 'Gold 3,000' + '''' + ',' + '500' + ',' + '3000' + ',' + '200)');
Game4PowerQuery.ExecSQL;
Game4PowerQuery.SQL.Clear;
Game4PowerQuery.SQL.Add('insert into twgoldsell values(' + '0' + ',' +
'''' + FMyQuery.fieldByName('markettype').AsString[1] + '''' + ',' +
GameID + ',' +
'''' + FMyQuery.fieldByName('game').AsString + '''' + ',' +
IntToStr(ServerID) + ',' +
FServer + ',' +
'''' + 'Gold 4,000' + '''' + ',' + '500' + ',' + '4000' + ',' + '200)');
Game4PowerQuery.ExecSQL;
Game4PowerQuery.SQL.Clear;
Game4PowerQuery.SQL.Add('insert into twgoldsell values(' + '0' + ',' +
'''' + FMyQuery.fieldByName('markettype').AsString[1] + '''' + ',' +
GameID + ',' +
'''' + FMyQuery.fieldByName('game').AsString + '''' + ',' +
IntToStr(ServerID) + ',' +
FServer + ',' +
'''' + 'Gold 5,000' + '''' + ',' + '500' + ',' + '5000' + ',' + '200)');
Game4PowerQuery.ExecSQL;

FMyQuery.Next;
end;
endTrans;
end;

procedure TfrmOAManager.Button54Click(Sender: TObject);
var
i:Integer;
FSerialNo:String;
FDataList:TstringList;
begin
FMyQuery.sql.Clear;
FMyquery.sql.Add('select * from tbsitesort order by SiteAddress,sortdate,sorttime');
FMyQuery.open;
FDataList := tStringList.Create;
while Not FMyQuery.Eofdo
begin
FDataList.Add(FMyQuery.fieldByName('siteaddress').AsString + '|' +
FMyQuery.fieldByName('sortdate').AsString + '|' +
FMyQuery.fieldByName('sorttime').AsString + '|');
FMyQuery.next;
end;
for i := 0 to FDataList.Count - 1do
begin
FMyQuery.SQL.Clear;
FSerialNo := GetSerialNo;
FMyQuery.SQL.Add('update tbsitesort set serialno = ' + '''' + FSerialNo + '''' +
' where siteaddress = ' + '''' + GetPart(FDataList.strings,'|',1) + '''' +
' and sortdate = ' + getPart(FDataList.strings,'|',2) +
' and sorttime = ' + GetPart(FdataList.Strings,'|',3));
FMyQuery.ExecSQL;
end;
FDataList.Free;
end;

procedure TfrmOAManager.Button55Click(Sender: TObject);
var
i:Integer;
FClassifyID:String;
FServerList: TStringList;
FWeaponID:Integer;
begin
if Not MYSQLDB.Connected then
MySQLconnect;
FServerList := TStringList.Create;
MySQLQuery.SQL.Clear;
MYSQLQuery.SQL.Add('select * from blizzard_weapon_classify where propertyid = 10');
MySQLQuery.Open;
while Not MySQLQuery.Eofdo
begin
FServerList.Add(MySQLQuery.fieldByName('classifyid').AsString);
MySQLQuery.Next;
end;
FWeaponID := 0;
MySQLQuery.SQL.Clear;
MYSQLQuery.SQL.Add('select max(WeaponID) from blizzard_weapon_detail');
MYSQLquery.Open;
while Not MYSQLQuery.Eofdo
begin
FWeaponID := MYSQLQuery.Fields.Fields[0].AsInteger;
MySQLQuery.Next;
end;
for i := 0 to FServerList.count - 1do
begin
FClassifyID := FServerList.Strings;
FWeaponID := FWeaponID + 1;
MySQLQuery.SQL.Clear;
MYSQLQuery.SQL.Add('insert into blizzard_weapon_detail values(' + IntToStr(FWeaponID) +
',' + FClassifyID + ',' +
'''' + 'Platinum 1,000' + '''' + ',' +
'''' + '' + '''' + ',' +
'''' + '/Upfiles/weapon/' + '''' + ',' +
'0,0,4.98,20,0,0,0,' + '''' + '1' + '''' + ',' +
'''' + '1' + '''' + ')');
MySQLQuery.ExecSQL;
FWeaponID := FWeaponID + 1;
MySQLQuery.SQL.Clear;
MYSQLQuery.SQL.Add('insert into blizzard_weapon_detail values(' + IntToStr(FWeaponID) +
',' + FClassifyID + ',' +
'''' + 'Platinum 2,000' + '''' + ',' +
'''' + '' + '''' + ',' +
'''' + '/Upfiles/weapon/' + '''' + ',' +
'0,0,9.98,20,0,0,1,' + '''' + '1' + '''' + ',' +
'''' + '1' + '''' + ')');
MySQLQuery.ExecSQL;
FWeaponID := FWeaponID + 1;
MySQLQuery.SQL.Clear;
MYSQLQuery.SQL.Add('insert into blizzard_weapon_detail values(' + IntToStr(FWeaponID) +
',' + FClassifyID + ',' +
'''' + 'Platinum 3,000' + '''' + ',' +
'''' + '' + '''' + ',' +
'''' + '/Upfiles/weapon/' + '''' + ',' +
'0,0,14.98,20,0,0,2,' + '''' + '1' + '''' + ',' +
'''' + '1' + '''' + ')');
MySQLQuery.ExecSQL;
FWeaponID := FWeaponID + 1;
MySQLQuery.SQL.Clear;
MYSQLQuery.SQL.Add('insert into blizzard_weapon_detail values(' + IntToStr(FWeaponID) +
',' + FClassifyID + ',' +
'''' + 'Platinum 4,000' + '''' + ',' +
'''' + '' + '''' + ',' +
'''' + '/Upfiles/weapon/' + '''' + ',' +
'0,0,18.98,20,0,0,3,' + '''' + '1' + '''' + ',' +
'''' + '1' + '''' + ')');
MySQLQuery.ExecSQL;
FWeaponID := FWeaponID + 1;
MySQLQuery.SQL.Clear;
MYSQLQuery.SQL.Add('insert into blizzard_weapon_detail values(' + IntToStr(FWeaponID) +
',' + FClassifyID + ',' +
'''' + 'Platinum 5,000' + '''' + ',' +
'''' + '' + '''' + ',' +
'''' + '/Upfiles/weapon/' + '''' + ',' +
'0,0,22.98,20,0,0,4,' + '''' + '1' + '''' + ',' +
'''' + '1' + '''' + ')');
MySQLQuery.ExecSQL;
FWeaponID := FWeaponID + 1;
MySQLQuery.SQL.Clear;
MYSQLQuery.SQL.Add('insert into blizzard_weapon_detail values(' + IntToStr(FWeaponID) +
',' + FClassifyID + ',' +
'''' + 'Platinum 10,000' + '''' + ',' +
'''' + '' + '''' + ',' +
'''' + '/Upfiles/weapon/' + '''' + ',' +
'0,0,44.98,20,0,0,5,' + '''' + '1' + '''' + ',' +
'''' + '1' + '''' + ')');
MySQLQuery.ExecSQL;
FWeaponID := FWeaponID + 1;
MySQLQuery.SQL.Clear;
MYSQLQuery.SQL.Add('insert into blizzard_weapon_detail values(' + IntToStr(FWeaponID) +
',' + FClassifyID + ',' +
'''' + 'Platinum 20,000' + '''' + ',' +
'''' + '' + '''' + ',' +
'''' + '/Upfiles/weapon/' + '''' + ',' +
'0,0,87.98,20,0,0,6,' + '''' + '1' + '''' + ',' +
'''' + '1' + '''' + ')');
MySQLQuery.ExecSQL;
end;
FServerList.Free;
end;

procedure TfrmOAManager.Button56Click(Sender: TObject);
var
FDataList: TStringList;
begin
FDataList := TStringList.Create;
if Not MYSQLDB.Connected then
MySQLconnect;
MySQLQuery.SQL.Clear;
MySQLQuery.SQL.Add('select id,email from blizzard_member_register where email <> ' + '''' + '' + '''');
MySQLQuery.Open;
while Not MySQLQuery.Eofdo
begin
FDataList.Add(MySQLQuery.Fields.Fields[0].AsString + '|' + MySQLQuery.Fields.Fields[1].AsString +'|');
MySQLQuery.Next;
end;
FDataList.SaveToFile('D:/reg.txt');
FDataList.Free;
end;

procedure TfrmOAManager.Button59Click(Sender: TObject);
var
FDataList:Tstringlist;
FShowList:Tstringlist;
Count,i,TotalVolume:integer;
TotalBal :Double;
lisshour:string;
Ftemp:string;
begin
Ftemp:=Inputbox('输入','请输入开始计算的时间(6位数)','');
//Ftemp := '20060401';
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('select exectime,volume,bal,serialno,game,server from thgamejour where execdate >= '''+Ftemp+'''' +
' and game = ' + '''' + 'WOW' + '''' + ' and canceltype = ' + '''' + '0' + '''' +
' and exectype <> ' + '''' + '8' + '''' + ' and bal >0 and exectype = ' + '''' + '0' + '''' + ' order by exectime');
FMyQuery.Open;
FDataList:=Tstringlist.Create;
FShowList:=Tstringlist.Create;
while Not FMyQuery.Eof do
begin
FDataList.Add(headfill(FMyQuery.fieldbyname('exectime').AsString,'0',6) + '/' +
FMyQuery.fieldbyname('Volume').AsString + '/' +
FMyQuery.fieldbyname('bal').AsString + '/');
FMyQuery.Next;
end;

lisshour := '';
TotalVolume := 0;
TotalBal := 0;
Count := 0;
FShowList.Add(tailfill('时段',' ',10) + tailfill('笔数',' ',10) + tailfill('数量',' ',10) + tailfill('金额',' ',10));
for i:=0 to FDatalist.Count - 1do
begin
if lisshour <> copy(getpart(FdataList.Strings,'/',1),1,2) then
begin
if lisshour <> '' then
FShowList.Add(tailfill(lissHour,' ',10) + tailfill(IntToStr(Count),' ',10) +
tailfill(IntToStr(TotalVolume),' ',10) + tailfill(formatfloat('0.00',TotalBal),' ',10));
lisshour:=Copy(Getpart(FDataList.Strings,'/',1),1,2);
TotalVolume := 0;
TotalBal := 0;
count := 0;
end;
Count := Count + 1;
TotalVolume := TotalVolume + strtoInt(Getpart(FDataList.Strings,'/',2));
TotalBal := totalBal + strtofloat(Getpart(FDataList.Strings,'/',3));
end;
FShowList.Add(tailfill(lisshour,' ',10) + tailfill(IntToStr(Count),' ',10) +
tailfill(IntToStr(TotalVolume),' ',10) + tailfill(formatfloat('0.00',TotalBal),' ',10));
if FShowList.Count > 0 then
PopShow(FShowList);
FShowList.Free;
FDataList.free;
end;

procedure TfrmOAManager.Button60Click(Sender: TObject);
var
Fbuycount:integer;
Fbuybal:Double;
FMYQuery1:TQuery;
i,j:integer;
begin
FMYQuery1 := TQuery.Create(nil);
FMYQuery1.DatabaseName := FMyQuery.DatabaseName;
begin
trans;
FMYQuery.Close;
FMYQuery.SQL.Text:='select a.serialno,a.extsearchno,a.customerID,a.volume,a.bal,a.status,b.buycount,b.buybal from tbgamejour a,tbcustomer b where ExtsearchNO like ' + '''' + 'bulu' + '%' + ''' and a.status not in (6,7) and a.customerID=b.customerID';
FMYQuery.Open;
i := 1;
j := 1;
While Not FMYQuery.Eofdo
begin
FMYQuery1.Close;
FMYQuery1.SQL.Text:='update tbgamejour set SendID= ' +
'''' + 'sanpe' + '''' + ' ,sendDate= ' +
'''' + inttostr(DateToInt(now)) + '''' + ' ,sendTime= ' +
'''' + inttostr(TimeToShortInt(Now)) + '''' + ' ,status= ' +
'''' + '7' + '''' + ' ,sendopID= ' +
'''' + '8888' + '''' +
'where SerialNO = '+FMYQuery.fieldbyname('SerialNO').AsString+'';
FMYQuery1.ExecSQL;
//其实可以在第一个select中联合查询出来就可以了
//FMYQuery1.Close;
//FMYQuery1.SQL.Text:='select * from tbcustomer where customerID='''+FMYQuery.fieldbyname('customerID').AsString+'''';
//FMYQuery1.Open;
if FMYQuery.fieldbyname('buycount').AsInteger>1 then
begin
Fbuycount := FMYQuery.fieldbyname('buycount').AsInteger-1;
Fbuybal := FMYQuery.fieldbyname('buybal').AsFloat-FMYQuery.fieldbyname('bal').AsFloat;
FMYQuery1.Close;
FMYQuery1.SQL.Text:='update tbcustomer set buycount= ' +
'''' + inttostr(Fbuycount) + '''' + ',buybal= ' +
'''' + Floattostr(Fbuybal) +''''+
'where customerID='''+FMYQuery.fieldbyname('customerID').AsString+'''';
FMYQuery1.ExecSQL;
j := j + 1;
end;
FMYQuery.Next;
i := i + 1;
end;
endtrans;
ShowMessage('Tbcustomer表共更新' + inttostr(j) + '条记录'+ #13#10 +
'Tbgamejour表共更新' + inttostr(i) + '条记录 .' );
FMYQuery1.Free;
end;

procedure TfrmOAManager.Button30Click(Sender: TObject);
begin
FBackupname :=IntToStr(DateToInt(Now)) + IntToStr(TimeToShortInt(Now));
FMyQuery.SQL.Clear;
FMyQuery.SQL.Add('dump database itlweb20060425 to disk = ' + '''' + 'd:/backup/itlweb' + FBackupname + '.dmp' + '''');
FMyQuery.ExecSQL;
ShowMessage('备份成功!');
end;

procedure TfrmOAManager.ChageDir(DirName: String);
begin
try
IdFTP1.ChangeDir(DirName);
//设置文件传输类型为ASCII文件传输
IdFTP1.TransferType := ftASCII;
finally
//
end;
end;

//连接FTP服务器
procedure TfrmOAManager.Button62Click(Sender: TObject);
begin
AverageSpeed:=0;
Button62.Enabled := false;
if IdFTP1.Connected then
try
if TransferrignData then
IdFTP1.Abort;
IdFTP1.Quit;
finally
Button62.Caption := '连接';
Button62.Enabled := true;
Button62.Default := true;
end
else
with IdFTP1do
try
//建立到FTP服务器的连接
Username := 'backup';
//FTP用户
Password := '17yoo123';//FTP密码
Host := FParam.DBName;//取服务器的IP
Connect;
Self.ChageDir('');//修改当前路径
finally
Button62.Enabled := true;
if Connected then
//断开与FTP服务器的连接
begin
Button62.Caption := '断开连接';
Button62.Default := false;
end;
end;
end;

//从FTP服务器中下载文件
procedure TfrmOAManager.Button61Click(Sender: TObject);
begin
{Var
Name: String;
begin
if not IdFTP1.Connected then
exit;
// Name := FBackupName + '.dmp';
Name := 'itlweb20060426.rar';
try
SaveDialog1.FileName := Name;
if SaveDialog1.Execute then
begin
IdFTP1.TransferType := ftBinary;
BytesToTransfer := IdFTP1.Size(Name);
IdFTP1.Get(Name, SaveDialog1.FileName, true);
end;
finally
//
end;
}
//TDownloadThread.Create(frmOAManager.IdFTP1;frmOAManager.SaveDialog1);
TDownloadThread.Create(false);
end;

{Constructor TDownloadThread.Create(DownFTP:TIdFTP;DownSaveDialog:TSaveDialog);
begin
FDownFTP :=do
wnFTP;
FDownSaveDialog :=do
wnSaveDialog;
FreeOnTerminate:=True;
inherited Create(False);
end;
}
{TDonloadThread}
procedure TDownloadThread.Execute;
begin
Upload;
end;

procedure TDownloadThread.Upload;
var
Name:String;
begin
if not frmOAManager.IdFTP1.Connected then
exit;
Name := 'itlweb20060426.rar';
try
frmOAManager.SaveDialog1.FileName := Name;
if frmOAManager.SaveDialog1.Execute then
begin
frmOAManager.IdFTP1.TransferType := ftBinary;
frmOAManager.BytesToTransfer := frmOAManager.IdFTP1.Size(Name);
frmOAManager.IdFTP1.Get(Name, frmOAManager.SaveDialog1.FileName, true);
end;
finally
//
end;
end;
 
建议你把错误信息发上来,是编译还是运行错,尽量详细。
 
编译没有问题,是在delphi7下编译后运行时马上出错。(如果离开编译环境直接运行看不到错误)出错信息如下:
Project Client.exe raised exception class EAccessViolation with message 'Access violation at address 0057B1DE in module 'Client.exe'. Read of address 0000047C'. Process stopped.Use Step or Run to continue.
 
这种错误经常是没有初始化某个object变量,成了野指针, 变量地址是0057B1DE,不一定是线程的问题。以前书上见过根据地址找到对应的源码行,忘记了,找找这方面的资料。
程序太大,估计帮不了你了。
 
接受答案了.
 
后退
顶部