📄 dataunit.pas
字号:
unit DataUnit;
interface
uses
SysUtils, Classes, DB, ADODB;
type
TDataModule1 = class(TDataModule)
ADOConnection1: TADOConnection;
ADOConnection2: TADOConnection;
ADOTable1: TADOTable;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
ADOQuery3: TADOQuery;
private
{ Private declarations }
public
procedure CheckIDHasUPdate;
procedure RepairItmeMakeIndex;
procedure CombineID(Addstr:String;npos,index:Integer);
procedure CombineHum(Addstr:String;npos,index:Integer);
procedure CombineGuild(Addstr:String;npos,index:Integer);
procedure CombineITEM(index:Integer);
procedure CombineMagic(index:Integer);
procedure CombineVal(index:Integer);
procedure CombineGuildMember(index:Integer);
procedure CombineGuildCOMMUNITY(index:Integer);
procedure UnCombine(Index:Integer);
procedure DeleteServer(Index:Integer);
end;
var
DataModule1: TDataModule1;
implementation
uses DataCombine;
{$R *.dfm}
{ TDataModule1 }
procedure TDataModule1.CheckIDHasUPdate;
begin
if ADOConnection1.Connected then
begin
if not ADOTable1.Active then
ADOTable1.Active:=True;
if ADOTable1.FindField('ServerIndex')=nil then
begin
ADOQuery1.Active:=False;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('alter table D_ACCOUNT add ServerIndex int not NULL Default 0');
ADOQuery1.ExecSQL;
ADOQuery1.Active:=False;
end;
//人物数据表
if ADOTable1.Active then
ADOTable1.Active:=False;
ADOTable1.TableName:='D_HUM_INFO';
if not ADOTable1.Active then
ADOTable1.Active:=True;
if ADOTable1.FindField('ServerIndex')=nil then
begin
ADOQuery1.Active:=False;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('alter table D_HUM_INFO add ServerIndex int not NULL Default 0');
ADOQuery1.ExecSQL;
ADOQuery1.Active:=False;
end;
//物品数据表
if ADOTable1.Active then
ADOTable1.Active:=False;
ADOTable1.TableName:='D_HUM_ITEM';
if not ADOTable1.Active then
ADOTable1.Active:=True;
if ADOTable1.FindField('ServerIndex')=nil then
begin
ADOQuery1.Active:=False;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('alter table D_HUM_ITEM add ServerIndex int not NULL Default 0');
ADOQuery1.ExecSQL;
ADOQuery1.Active:=False;
end;
//魔法数据表
if ADOTable1.Active then
ADOTable1.Active:=False;
ADOTable1.TableName:='D_HUM_MAGIC';
if not ADOTable1.Active then
ADOTable1.Active:=True;
if ADOTable1.FindField('ServerIndex')=nil then
begin
ADOQuery1.Active:=False;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('alter table D_HUM_MAGIC add ServerIndex int not NULL Default 0');
ADOQuery1.ExecSQL;
ADOQuery1.Active:=False;
end;
//行会数据表
if ADOTable1.Active then
ADOTable1.Active:=False;
ADOTable1.TableName:='D_Guild';
if not ADOTable1.Active then
ADOTable1.Active:=True;
if ADOTable1.FindField('ServerIndex')=nil then
begin
ADOQuery1.Active:=False;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('alter table D_Guild add ServerIndex int not NULL Default 0');
ADOQuery1.ExecSQL;
ADOQuery1.Active:=False;
end;
//行会成员数据表
if ADOTable1.Active then
ADOTable1.Active:=False;
ADOTable1.TableName:='D_GuildMember';
if not ADOTable1.Active then
ADOTable1.Active:=True;
if ADOTable1.FindField('ServerIndex')=nil then
begin
ADOQuery1.Active:=False;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('alter table D_GuildMember add ServerIndex int not NULL Default 0');
ADOQuery1.ExecSQL;
ADOQuery1.Active:=False;
end;
//行会关系数据表
if ADOTable1.Active then
ADOTable1.Active:=False;
ADOTable1.TableName:='D_Guild_COMMUNITY';
if not ADOTable1.Active then
ADOTable1.Active:=True;
if ADOTable1.FindField('ServerIndex')=nil then
begin
ADOQuery1.Active:=False;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('alter table D_Guild_COMMUNITY add ServerIndex int not NULL Default 0');
ADOQuery1.ExecSQL;
ADOQuery1.Active:=False;
end;
//变量
if ADOTable1.Active then
ADOTable1.Active:=False;
ADOTable1.TableName:='D_VAL';
if not ADOTable1.Active then
ADOTable1.Active:=True;
if ADOTable1.FindField('ServerIndex')=nil then
begin
ADOQuery1.Active:=False;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('alter table D_VAL add ServerIndex int not NULL Default 0');
ADOQuery1.ExecSQL;
ADOQuery1.Active:=False;
end;
End;
end;
procedure TDataModule1.CombineGuild(Addstr: String; npos, index: Integer);
var
i,j : Integer;
Account : String;
ar : array of variant;
Find : Boolean;
begin
if not ADOConnection1.Connected then Exit;
if not ADOConnection2.Connected then Exit;
ADOQuery2.Active:=FAlse;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('Select * from D_Guild');
ADOQuery2.Active:=True;
ADOQuery1.Active:=FAlse;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Select * from D_Guild where GuildName=:Name');
ADOQuery3.Active:=FAlse;
ADOQuery3.SQL.Clear;
ADOQuery3.SQL.Add('update D_Guild_COMMUNITY set GuildName=:CharID where GuildName=:Name');
ADOQuery3.SQL.Add('update D_Guild_COMMUNITY set GuildNameof=:CharID1 where GuildNameof=:Name1');
ADOQuery3.SQL.Add('update D_GuildMember set GuildName=:CharID2 where GuildName=:Name2');
if ADOQuery2.RecordCount=0 then Exit;
FormMain.bsSkinGauge1.MaxValue:=ADOQuery2.RecordCount-1;
FormMain.bsSkinGauge1.Value:=0;
FormMain.bsSkinGauge1.Visible:=True;
FormMain.OutLog('正在合并行会数据表......');
try
for i:=0 to ADOQuery2.RecordCount-1 do
begin
Account:=ADOQuery2.FieldValues['GuildName'];
ADOQuery1.Parameters[0].Value:=Account;
ADOQuery1.Active:=True;
if ADOQuery1.RecordCount>0 then
begin
Find:=True;
FormMain.OutLog(Format('发现行会:%s重复',[Account]));
End
else
Find:=FAlse;
if npos=0 then
Account:= Addstr+Account
else
Account:=ACcount+Addstr;
ADOQuery1.Append;
for j:=1 to ADOQuery2.FieldCount-1 do
Begin
if not ADOQuery2.Fields[j].IsNull then
ADOQuery1.Fields[j].Value:=ADOQuery2.Fields[j].Value;
end;
if Find then
Begin
ADOQuery1.FieldByName('GuildName').Value:=Account;
ADOQuery3.Parameters.ParamByName('Name').Value:=ADOQuery2.FieldValues['GuildName'];
ADOQuery3.Parameters.ParamByName('CharID').Value:=Account;
ADOQuery3.Parameters.ParamByName('Name1').Value:=ADOQuery2.FieldValues['GuildName'];
ADOQuery3.Parameters.ParamByName('CharID1').Value:=Account;
ADOQuery3.Parameters.ParamByName('Name2').Value:=ADOQuery2.FieldValues['GuildName'];
ADOQuery3.Parameters.ParamByName('CharID2').Value:=Account;
ADOQuery3.ExecSQL;
end;
ADOQuery1.FieldValues['serverindex']:=index;
ADOQuery1.Post;
ADOQuery1.Active:=False;
ADOQuery2.Next;
FormMain.bsSkinGauge1.Value:=i;
End;
finally
FormMain.bsSkinGauge1.Visible:=False;
FormMain.OutLog('HUM数据表合并完成......');
End;
end;
procedure TDataModule1.CombineGuildCOMMUNITY(index:Integer);
var
i,j : Integer;
Account : String;
ar : array of variant;
Find : Boolean;
begin
if not ADOConnection1.Connected then Exit;
if not ADOConnection2.Connected then Exit;
ADOQuery2.Active:=FAlse;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('Select * from D_Guild_COMMUNITY');
ADOQuery2.Active:=True;
ADOQuery1.Active:=FAlse;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Select * from D_Guild_COMMUNITY');
if ADOQuery2.RecordCount=0 then Exit;
FormMain.bsSkinGauge1.MaxValue:=ADOQuery2.RecordCount-1;
FormMain.bsSkinGauge1.Value:=0;
FormMain.bsSkinGauge1.Visible:=True;
FormMain.OutLog('正在合并行会关系数据表......');
try
for i:=0 to ADOQuery2.RecordCount-1 do
begin
ADOQuery1.Active:=True;
ADOQuery1.Append;
for j:=0 to ADOQuery2.FieldCount-1 do
Begin
if not ADOQuery2.Fields[j].IsNull then
ADOQuery1.Fields[j].Value:=ADOQuery2.Fields[j].Value;
end;
ADOQuery1.FieldValues['serverindex']:=index;
ADOQuery1.Post;
ADOQuery1.Active:=False;
ADOQuery2.Next;
FormMain.bsSkinGauge1.Value:=i;
End;
finally
FormMain.bsSkinGauge1.Visible:=False;
FormMain.OutLog('行会关系数据表合并完成......');
End;
end;
procedure TDataModule1.CombineGuildMember(index:Integer);
var
i,j : Integer;
Account : String;
ar : array of variant;
Find : Boolean;
begin
if not ADOConnection1.Connected then Exit;
if not ADOConnection2.Connected then Exit;
ADOQuery2.Active:=FAlse;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('Select * from D_GuildMember');
ADOQuery2.Active:=True;
ADOQuery1.Active:=FAlse;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Select * from D_GuildMember');
if ADOQuery2.RecordCount=0 then Exit;
FormMain.bsSkinGauge1.MaxValue:=ADOQuery2.RecordCount-1;
FormMain.bsSkinGauge1.Value:=0;
FormMain.bsSkinGauge1.Visible:=True;
FormMain.OutLog('正在合并行会成员数据表......');
try
for i:=0 to ADOQuery2.RecordCount-1 do
begin
ADOQuery1.Active:=True;
ADOQuery1.Append;
for j:=1 to ADOQuery2.FieldCount-1 do
Begin
if not ADOQuery2.Fields[j].IsNull then
ADOQuery1.Fields[j].Value:=ADOQuery2.Fields[j].Value;
end;
ADOQuery1.FieldValues['serverindex']:=index;
ADOQuery1.Post;
ADOQuery1.Active:=False;
ADOQuery2.Next;
FormMain.bsSkinGauge1.Value:=i;
End;
finally
FormMain.bsSkinGauge1.Visible:=False;
FormMain.OutLog('行会成员数据表合并完成......');
End;
end;
procedure TDataModule1.CombineHum(Addstr: String; npos, index: Integer);
var
i,j : Integer;
Account : String;
ar : array of variant;
Find : Boolean;
begin
if not ADOConnection1.Connected then Exit;
if not ADOConnection2.Connected then Exit;
ADOQuery2.Active:=FAlse;
ADOQuery2.SQL.Clear;
ADOQuery2.SQL.Add('Select * from D_HUM_INFO');
ADOQuery2.Active:=True;
ADOQuery1.Active:=FAlse;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Select * from D_HUM_INFO where name=:Name');
ADOQuery3.Active:=FAlse;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -