📄 datasql_db.pas
字号:
unit DataSQL_DB;
interface
uses
SysUtils, Classes, DB, ADODB, Grobal2, shellapi, Math,Windows, DBAccess,
MSAccess, MemDS;
type
TDataModule_DB = class(TDataModule)
ADOConnectionDB: TMSConnection;
ADOQueryGet: TMSQuery;
ADOQuery: TMSQuery;
ADOStoredProcADD: TMSStoredProc;
ADOStoredProc_Get: TMSStoredProc;
ADOStoredProc_Del: TMSStoredProc;
private
{ Private declarations }
public
//DBIndex : Word;
function GetChrName(Name: string; var Count: Integer): string;
function AddChar(Account, Name: string; sex, job, hair: Byte): Integer;
// function GetHumRecord(ChrName: string; var HumanRCD: THumData): Integer;
function UpdateBy(Name,ACCOUNT:String;boSelect,boDelete:Byte):Boolean;
{ function SaveHumItem(HumData:THumData): Boolean;
function SaveItem(Item:TUserItem;Name:String;pos:integer):Boolean;
function UpdateHumData(HumData: THumData): Boolean;
function UpdataMagic(Magic:TMagic1;Name:String):BOOLean;
}
function LoadVar(charname,VarName:String;var Value:string;var ValueInt:Integer):Boolean;
function SaveVar(charname,VarName:String; Value:string;var ValueInt:Integer):Boolean;
end;
var
DataModule_DB : TDataModule_DB;
const
ConnectStr = 'Provider=SQLOLEDB.1;Password=%s;Persist Security Info=True;User ID=%s;Initial '
+'Catalog=%s;Data Source=%s';
QueryChrSqlStr =
'SELECT ACCOUNT, NAME, Hair, Sex,Job,nLevel FROM D_HUM_INFO where ACCOUNT=:ACCOUNT';
implementation
uses DBSMain, DBShare;
{$R *.dfm}
{ TDataModule_DB }
function TDataModule_DB.AddChar(Account, Name: string; sex, job, hair: Byte):
Integer;
begin
Result := 4;
try
if ADOConnectionDB.Connected then
begin
ADOStoredProcADD.Close;
ADOStoredProcADD.Params.ParamByName('@ACCOUNT').Value := Account;
ADOStoredProcADD.Params.ParamByName('@Name').Value := Name;
ADOStoredProcADD.Params.ParamByName('@sex').Value := sex;
ADOStoredProcADD.Params.ParamByName('@Job').Value := job;
ADOStoredProcADD.Params.ParamByName('@hair').Value := hair;
// ADOStoredProcADD.Params.ParamByName('@Dbindex').Value := Dbindex;
ADOStoredProcADD.Prepared := True;
ADOStoredProcADD.ExecProc;
Result := ADOStoredProcADD.Params.ParamByName('@RETURN_VALUE').Value;
ADOStoredProcADD.Close;
end;
finally
End;
end;
function TDataModule_DB.GetChrName(Name: string; var Count: Integer): string;
var
i : Integer;
btSex : Byte;
sChrName : string;
sJob : string;
sHair : string;
sLevel : string;
s40 : string;
btSelect : Byte;
begin
Count := 0;
Result := '';
try
if ADOConnectionDB.Connected then
begin
ADOQueryGet.Active := False;
ADOQueryGet.SQL.Text:='SELECT ACCOUNT, NAME, Hair, Sex,Job,nLevel,boSelect FROM D_HUM_INFO where (ACCOUNT=:ACCOUNT)and(boDelete = 0)';
ADOQueryGet.Params.ParamByName('ACCOUNT').Value := Name;
ADOQueryGet.Prepared := True;
ADOQueryGet.Active := True;
s40 := '';
for i := 0 to ADOQueryGet.RecordCount - 1 do
begin
btSex := ADOQueryGet.FieldValues['Sex'];
sChrName := ADOQueryGet.FieldValues['Name'];
sJob := IntToStr(ADOQueryGet.FieldValues['Job']);
sHair := IntToStr(ADOQueryGet.FieldValues['Hair']);
sLevel := IntToStr(ADOQueryGet.FieldValues['nLevel']);
btSelect := ADOQueryGet.FieldValues['BoSelect'];
if btSelect = 1 then
s40 := s40 + '*';
s40 := s40 + sChrName + '/' + sJob + '/' + sHair + '/' + sLevel
+ '/' + IntToStr(btSex) + '/';
ADOQueryGet.Next;
end;
Result := s40;
Count := ADOQueryGet.RecordCount;
ADOQueryGet.Active:=False;
end;
finally
End;
end;
{
function TDataModule_DB.GetHumRecord(ChrName: string; var HumanRCD:
THumData): Integer;
var
i, Index,count : Integer;
IndexOfItem : array[0..2] of Integer;
b : array of Byte;
// m:Tmemorystream;
begin
Result := -4;
FillChar(HumanRCD, SizeOf(THumData), 0);
if ADOConnectionDB.Connected then
begin
try
ADOStoredProc_Get.Active:=False;
ADOStoredProc_Get.Params.ParamByName('@ChrName').Value := ChrName;
ADOStoredProc_Get.Prepared := True;
ADOStoredProc_Get.Active := True;
if ADOStoredProc_Get.RecordCount = 0 then
Begin
Result:=5;
exit;
End;
// HumanRCD.DBIndex:=DBIndex ;//数据库索引
HumanRcd.HumID:=ADOStoredProc_Get.FieldByName('id').AsInteger;
HumanRCD.sChrName1 := ADOStoredProc_Get.FieldByName('name').AsString;
HumanRcd.sChrName := ADOStoredProc_Get.FieldByName('name').AsString;
HumanRcd.sCurMap := ADOStoredProc_Get.FieldByName('CurMap').AsString;
HumanRcd.wCurX := ADOStoredProc_Get.FieldByName('wCurx').AsInteger;
HumanRcd.wCurY := ADOStoredProc_Get.FieldByName('wCury').AsInteger;
HumanRcd.btDir := ADOStoredProc_Get.FieldByName('Dir').AsInteger;
HumanRcd.btHair := ADOStoredProc_Get.FieldByName('Hair').AsInteger;
HumanRcd.btSex := ADOStoredProc_Get.FieldByName('Sex').AsInteger;
HumanRcd.btJob := ADOStoredProc_Get.FieldByName('Job').AsInteger;
HumanRcd.nGold := ADOStoredProc_Get.FieldByName('Gold').AsInteger;
HumanRcd.Abil.Level :=ADOStoredProc_Get.FieldByName('nLevel').AsInteger;
HumanRcd.Abil.AC := ADOStoredProc_Get.FieldByName('AC').AsInteger;
HumanRcd.Abil.MAC := ADOStoredProc_Get.FieldByName('MAC').AsInteger;
HumanRcd.Abil.DC := ADOStoredProc_Get.FieldByName('DC').AsInteger;
HumanRcd.Abil.MC := ADOStoredProc_Get.FieldByName('MC').AsInteger;
HumanRcd.Abil.SC := ADOStoredProc_Get.FieldByName('SC').AsInteger;
HumanRcd.Abil.HP := ADOStoredProc_Get.FieldByName('HP').AsInteger;
HumanRcd.Abil.MP := ADOStoredProc_Get.FieldByName('MP').AsInteger;
HumanRcd.Abil.MaxHP := ADOStoredProc_Get.FieldByName('MAXHP').AsInteger;
HumanRcd.Abil.MaxMP := ADOStoredProc_Get.FieldByName('MAXMP').AsInteger;
HumanRcd.Abil.Exp := ADOStoredProc_Get.FieldByName('EXP').AsInteger;
HumanRcd.Abil.MaxExp := ADOStoredProc_Get.FieldByName('MAXExp').AsInteger;
HumanRcd.Abil.Weight := ADOStoredProc_Get.FieldByName('Weight').AsInteger;
HumanRcd.Abil.MaxWeight :=ADOStoredProc_Get.FieldByName('MaxWeight').AsInteger;
HumanRcd.Abil.WearWeight := ADOStoredProc_Get.FieldByName('WearWeight').AsInteger;
HumanRcd.Abil.MaxWearWeight := ADOStoredProc_Get.FieldByName('MaxWearWeight').AsInteger;
HumanRcd.Abil.HandWeight := ADOStoredProc_Get.FieldByName('HANDWEIGHT').AsInteger;
HumanRcd.Abil.MaxHandWeight := ADOStoredProc_Get.FieldByName('MaxHandWeight').AsInteger;
HumanRcd.sHomeMap := ADOStoredProc_Get.FieldByName('HomeMap').AsString;
HumanRcd.wHomeX := ADOStoredProc_Get.FieldByName('HomeX').AsInteger;
HumanRcd.wHomeY := ADOStoredProc_Get.FieldByName('HomeY').AsInteger;
HumanRcd.sDearName := ADOStoredProc_Get.FieldByName('DearName').AsString;
HumanRcd.sMasterName := ADOStoredProc_Get.FieldByName('MasterName').AsString;
HumanRcd.boMaster := ADOStoredProc_Get.FieldByName('boMaster').AsInteger;
HumanRcd.btCreditPoint := ADOStoredProc_Get.FieldByName('creditpoint').AsInteger;
HumanRcd.sStoragePwd := ADOStoredProc_Get.FieldByName('StroragePwd').AsString;
HumanRcd.btReLevel := ADOStoredProc_Get.FieldByName('ReLevel').AsInteger;
HumanRcd.boLockLogon := ADOStoredProc_Get.FieldByName('LOckLogon').AsInteger;
HumanRcd.nBonusPoint := AdoStoredProc_Get.fieldByName('BonusPoint').AsInteger;
HumanRcd.BonusAbil.DC := ADOStoredProc_Get.FieldByName('Naked_DC').AsInteger;
HumanRcd.BonusAbil.MC := ADOStoredProc_Get.FieldByName('Naked_MC').AsInteger;
HumanRcd.BonusAbil.SC := ADOStoredProc_Get.FieldByName('Naked_SC').AsInteger;
HumanRCD.NewStorageCount:= ADOStoredProc_Get.fieldbyName('StorageCount').AsInteger;
HumanRCD.NewStorageSize:= ADOStoredProc_Get.fieldbyName('StorageCount').AsInteger;
HumanRcd.BonusAbil.AC :=
ADOStoredProc_Get.FieldByName('Naked_AC').AsInteger;
HumanRcd.BonusAbil.MAC :=
ADOStoredProc_Get.FieldByName('Naked_MAC').AsInteger;
HumanRcd.BonusAbil.HP :=
ADOStoredProc_Get.FieldByName('Naked_HP').AsInteger;
HumanRcd.BonusAbil.MP :=
ADOStoredProc_Get.FieldByName('Naked_MP').AsInteger;
HumanRcd.BonusAbil.Hit :=
ADOStoredProc_Get.FieldByName('Naked_Hit').AsInteger;
HumanRcd.BonusAbil.Speed :=
ADOStoredProc_Get.FieldByName('Naked_Speed').AsInteger;
HumanRcd.BonusAbil.X2 :=
ADOStoredProc_Get.FieldByName('Naked_X2').AsInteger;
HumanRcd.nGameGold :=
ADOStoredProc_Get.FieldByName('GameGold').AsInteger;
HumanRcd.nGamePoint :=
ADOStoredProc_Get.FieldByName('GamePoint').AsInteger;
HumanRcd.nPayMentPoint :=
ADOStoredProc_Get.FieldByName('PayMentPoint').AsInteger;
HumanRcd.wContribution :=
ADOStoredProc_Get.FieldByName('Contribution').AsInteger;
HumanRcd.btIncHealth :=
ADOStoredProc_Get.FieldByName('IncHealth').AsInteger;
HumanRcd.nPKPOINT :=
ADOStoredProc_Get.FieldByName('PKPoint').AsInteger;
HumanRcd.btAllowGroup :=
ADOStoredProc_Get.FieldByName('AllowGroup').AsInteger;
HumanRcd.btAttatckMode :=
ADOStoredProc_Get.FieldByName('AttatckMode').AsInteger;
HumanRcd.btIncHealing :=
ADOStoredProc_Get.FieldByName('IncHealing').AsInteger;
HumanRcd.btIncSpell :=
ADOStoredProc_Get.FieldByName('IncSpell').AsInteger;
HumanRcd.btFightZoneDieCount :=
ADOStoredProc_Get.FieldByName('FightZoneDieCount').AsInteger;
HumanRcd.sAccount := ADOStoredProc_Get.FieldByName('ACCOUNT').AsString;
if not ADOStoredProc_Get.FieldByName('memo1').IsNull then
Begin
b := ADOStoredProc_Get.FieldByName('memo1').AsVariant;
Move(b[0], HumanRcd.memo1[0], 213);
End;
if not ADOStoredProc_Get.FieldByName('newvar').IsNull then
Begin
b := ADOStoredProc_Get.FieldByName('newvar').AsVariant;
Move(b[0], HumanRcd.newvar.NewVar[0], 20);
End;
if not ADOStoredProc_Get.FieldByName('newvardate').IsNull then
Begin
b := ADOStoredProc_Get.FieldByName('newvardate').AsVariant;
Move(b[0], HumanRcd.newvar.VarDate[0], 320);
End;
ADOStoredProc_Get.Active:=False;
IndexOfItem[0] := 0;
IndexOfItem[1] := 0;
IndexOfItem[2] := 0;
ADOStoredProc_Item_Get.Active:=False;
ADOStoredProc_Item_Get.Params.ParamByName('@CharID').Value := ChrName;
ADOStoredProc_Item_Get.Prepared := True;
ADOStoredProc_Item_Get.Active := True;
//SetLength(HumanRCD.NewStorageItmes,ADOStoredProc_Item_Get.RecordCount);
Count:=0;
// FrmDBSrv.MemoLog.Lines.Add(format('加载包裹%d',[ADOStoredProc_Item_Get.RecordCount]));
for i := 0 to ADOStoredProc_Item_Get.RecordCount - 1 do
begin
Index:=ADOStoredProc_Item_Get.FieldByName('pos').AsInteger;
if Index in [0..204] then
Begin
HumanRcd.UserItems[Index].MakeIndex :=
ADOStoredProc_Item_Get.FieldByName('makeindex').AsInteger;
HumanRcd.UserItems[Index].wIndex :=
ADOStoredProc_Item_Get.FieldByName('windex').AsInteger;
HumanRcd.UserItems[Index].Dura :=
ADOStoredProc_Item_Get.FieldByName('dura').AsInteger;
HumanRcd.UserItems[Index].DuraMax :=
ADOStoredProc_Item_Get.FieldByName('duramax').AsInteger;
b:=ADOStoredProc_Item_Get.FieldByName('btValue').AsVariant;
Move(b[0], HumanRcd.UserItems[Index].btvalue, 78);
End;
ADOStoredProc_Item_Get.Next;
end;
// SetLength(HumanRCD.NewStorageItmes,count);
ADOStoredProc_Item_Get.Active:=False;
ADOStoredProc_Magic_Get.Active:=False;
ADOStoredProc_Magic_Get.Params.ParamByName('@CharID').Value := ChrName;
ADOStoredProc_Magic_Get.Prepared := True;
ADOStoredProc_Magic_Get.Active := True;
Index := ADOStoredProc_Magic_Get.RecordCount;
if index>20 then index:=20;
for i := 0 to index-1 do
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -