Unit BLLUserInfo;

interface
Uses SysUtils,Classes,ADODB,DB,BaseModel,DZModelUserInfo;
Const Tablename='UserInfo';
Type
TBLLUserInfo=Class 
Private
 FadoConnection:TadoConnection;
 Fadoqry:TadoQuery;
 FautoClose:Boolean;
Public
  Constructor Create(constr:string);Overload;
  Constructor Create(con:TadoConnection);Overload;
  Destructor Destroy;
  Function Add(Value:TModelUserInfo):boolean;
  Function Exists(UserID:Integer):boolean;Overload;
  Function GetModel(UserID:Integer):TModelUserInfo;Overload;
  Function DeleteModel(UserID:Integer):boolean;Overload;
  Function Update(UserID:Integer;Value:TModelUserInfo):boolean;Overload;
  Function Exists(UserName:String):boolean;Overload;
  Function GetModel(UserName:String):TModelUserInfo;Overload;
  Function DeleteModel(UserName:String):boolean;Overload;
  Function Update(UserName:String;Value:TModelUserInfo):boolean;Overload;
  Procedure GetDataSet(StrWhere:string;Qry:Tadoquery);Overload;
  Procedure GetDataSet(Top:integer;StrWhere,orderby:string;Qry:Tadoquery);Overload;
  Function DeleteList(Model:TmodelUserInfo):Boolean;//删除记录条件为and方式
  Function DeleteListOr(Model:TmodelUserInfo):Boolean;//删除记录条件为or方式
  Function DeleteByWhere(StrWhere:string):Boolean;//删除记录条件为or方式
End;

implementation

Constructor TBLLUserInfo.Create(constr:string);
Begin
 self.FadoConnection:=TadoConnection.Create(nil);
 self.FadoConnection.LoginPrompt:=False;
 self.FadoConnection.KeepConnection:=True;
 self.FadoConnection.ConnectionString:=Constr;
 self.Fadoqry:=TadoQuery.Create(nil);
 self.Fadoqry.Connection:=FadoConnection;
 FautoClose:=true;
end;
Constructor TBLLUserInfo.Create(con:TadoConnection);
Begin
 self.FadoConnection:=con;
 self.Fadoqry:=TadoQuery.Create(nil);
 self.Fadoqry.Connection:=FadoConnection;
end;
Destructor TBLLUserInfo.Destroy;
Begin
  self.Fadoqry.free;
  if Self.FautoClose then FadoConnection.free;
  Inherited;
End;
Function TBLLUserInfo.Add(Value:TModelUserInfo):boolean;
Var Sqlstr,values:string;Valued:Boolean;
Begin
  Sqlstr:='Insert into UserInfo(';
  values:='values(';
  Valued:=False;
  Result:=False;
  with value do begin
    If (Not UserID.IsNull) and (UserID.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'UserID,';
    Valued:=True;
    values:=values+UserID.ValueToString+',';  end;
    If (Not UserName.IsNull) and (UserName.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'UserName,';
    Valued:=True;
    values:=values+UserName.ValueToString+',';  end;
    If (Not Password.IsNull) and (Password.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'Password,';
    Valued:=True;
    values:=values+Password.ValueToString+',';  end;
    If (Not RegisterTime.IsNull) and (RegisterTime.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'RegisterTime,';
    Valued:=True;
    values:=values+RegisterTime.ValueToString+',';  end;
    If (Not LastLoginTime.IsNull) and (LastLoginTime.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'LastLoginTime,';
    Valued:=True;
    values:=values+LastLoginTime.ValueToString+',';  end;
    If (Not FailCount.IsNull) and (FailCount.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'FailCount,';
    Valued:=True;
    values:=values+FailCount.ValueToString+',';  end;
    If (Not Nickname.IsNull) and (Nickname.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'Nickname,';
    Valued:=True;
    values:=values+Nickname.ValueToString+',';  end;
    If (Not HeadImg.IsNull) and (HeadImg.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'HeadImg,';
    Valued:=True;
    values:=values+HeadImg.ValueToString+',';  end;
    If (Not Sex.IsNull) and (Sex.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'Sex,';
    Valued:=True;
    values:=values+Sex.ValueToString+',';  end;
    If (Not Birthday.IsNull) and (Birthday.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'Birthday,';
    Valued:=True;
    values:=values+Birthday.ValueToString+',';  end;
    If (Not DepartMent.IsNull) and (DepartMent.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'DepartMent,';
    Valued:=True;
    values:=values+DepartMent.ValueToString+',';  end;
    If (Not JobType.IsNull) and (JobType.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'JobType,';
    Valued:=True;
    values:=values+JobType.ValueToString+',';  end;
    If (Not Edu.IsNull) and (Edu.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'Edu,';
    Valued:=True;
    values:=values+Edu.ValueToString+',';  end;
    If (Not Personality.IsNull) and (Personality.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'Personality,';
    Valued:=True;
    values:=values+Personality.ValueToString+',';  end;
    If (Not PersonHobbie.IsNull) and (PersonHobbie.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'PersonHobbie,';
    Valued:=True;
    values:=values+PersonHobbie.ValueToString+',';  end;
    If (Not PersonSign.IsNull) and (PersonSign.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'PersonSign,';
    Valued:=True;
    values:=values+PersonSign.ValueToString+',';  end;
    If (Not Remark.IsNull) and (Remark.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'Remark,';
    Valued:=True;
    values:=values+Remark.ValueToString+',';  end;
    If (Not CityID.IsNull) and (CityID.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'CityID,';
    Valued:=True;
    values:=values+CityID.ValueToString+',';  end;
    If (Not Email.IsNull) and (Email.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'Email,';
    Valued:=True;
    values:=values+Email.ValueToString+',';  end;
    If (Not PersonPhone.IsNull) and (PersonPhone.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'PersonPhone,';
    Valued:=True;
    values:=values+PersonPhone.ValueToString+',';  end;
    If (Not Ask.IsNull) and (Ask.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'Ask,';
    Valued:=True;
    values:=values+Ask.ValueToString+',';  end;
    If (Not Answer.IsNull) and (Answer.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'Answer,';
    Valued:=True;
    values:=values+Answer.ValueToString+',';  end;
    If (Not UserState.IsNull) and (UserState.DType<>ftAutoInc) Then Begin
    Sqlstr:=Sqlstr+'UserState,';
    Valued:=True;
    values:=values+UserState.ValueToString+',';  end;
    If Not Valued then Exit;
    Delete(Sqlstr,Length(Sqlstr),1);
    Sqlstr:=Sqlstr+')';
    Delete(values,Length(values),1);
    values:=values+')';
  End;
  If FadoConnection.Connected=False then 
  FadoConnection.Connected:=True;
  Fadoqry.Close;
  Fadoqry.Sql.text:=Sqlstr+values;
  try
  Result:=Fadoqry.ExecSQL>0;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
Function TBLLUserInfo.Exists(UserID:Integer):Boolean;
Var Sqlstr:string;
Begin
Sqlstr:='Select UserID From UserInfo Where UserID='+InttoStr(UserID);
  try
  If FadoConnection.Connected=False then 
  FadoConnection.Connected:=True;
  Fadoqry.Close;
  Fadoqry.Sql.text:=Sqlstr;
  Fadoqry.Open;
  Result:=Fadoqry.recordCount>0;
  Fadoqry.Close;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
Function TBLLUserInfo.GetModel(UserID:Integer):TModelUserInfo;
Var Sqlstr:string;
Begin
  Result:=nil;
  Sqlstr:='Select UserID,UserName,Password,RegisterTime,LastLoginTime,'+
  'FailCount,Nickname,HeadImg,Sex,Birthday,'+
  'DepartMent,JobType,Edu,Personality,PersonHobbie,'+
  'PersonSign,Remark,CityID,Email,PersonPhone,'+
  'Ask,Answer,UserState From UserInfo Where UserID='+InttoStr(UserID);
  try
  If FadoConnection.Connected=False then 
  FadoConnection.Connected:=True;
  Fadoqry.Close;
  Fadoqry.Sql.text:=Sqlstr;
  Fadoqry.Open;
  if Fadoqry.recordCount>0 then begin
     Result:=TModelUserInfo.Create;
     Result.UserID.Value:=Fadoqry.Fieldbyname('UserID').Value;
     Result.UserName.Value:=Fadoqry.Fieldbyname('UserName').Value;
     Result.Password.Value:=Fadoqry.Fieldbyname('Password').Value;
     Result.RegisterTime.Value:=Fadoqry.Fieldbyname('RegisterTime').Value;
     Result.LastLoginTime.Value:=Fadoqry.Fieldbyname('LastLoginTime').Value;
     Result.FailCount.Value:=Fadoqry.Fieldbyname('FailCount').Value;
     Result.Nickname.Value:=Fadoqry.Fieldbyname('Nickname').Value;
     Result.HeadImg.Value:=Fadoqry.Fieldbyname('HeadImg').Value;
     Result.Sex.Value:=Fadoqry.Fieldbyname('Sex').Value;
     Result.Birthday.Value:=Fadoqry.Fieldbyname('Birthday').Value;
     Result.DepartMent.Value:=Fadoqry.Fieldbyname('DepartMent').Value;
     Result.JobType.Value:=Fadoqry.Fieldbyname('JobType').Value;
     Result.Edu.Value:=Fadoqry.Fieldbyname('Edu').Value;
     Result.Personality.Value:=Fadoqry.Fieldbyname('Personality').Value;
     Result.PersonHobbie.Value:=Fadoqry.Fieldbyname('PersonHobbie').Value;
     Result.PersonSign.Value:=Fadoqry.Fieldbyname('PersonSign').Value;
     Result.Remark.Value:=Fadoqry.Fieldbyname('Remark').Value;
     Result.CityID.Value:=Fadoqry.Fieldbyname('CityID').Value;
     Result.Email.Value:=Fadoqry.Fieldbyname('Email').Value;
     Result.PersonPhone.Value:=Fadoqry.Fieldbyname('PersonPhone').Value;
     Result.Ask.Value:=Fadoqry.Fieldbyname('Ask').Value;
     Result.Answer.Value:=Fadoqry.Fieldbyname('Answer').Value;
     Result.UserState.Value:=Fadoqry.Fieldbyname('UserState').Value;
  end;
  Fadoqry.Close;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
Function TBLLUserInfo.DeleteModel(UserID:Integer):Boolean;
Var Sqlstr:string;
Begin
Sqlstr:='Delete  From UserInfo Where UserID='+InttoStr(UserID);
  try
  If FadoConnection.Connected=False then 
  FadoConnection.Connected:=True;
  Fadoqry.Close;
  Fadoqry.Sql.text:=Sqlstr;
  Result:=Fadoqry.ExecSql>0;
  Fadoqry.Close;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
Function TBLLUserInfo.Update(UserID:Integer;Value:TModelUserInfo):Boolean;
Var Sqlstr:string;
Begin
  Sqlstr:='Update UserInfo Set ';
  Sqlstr:=Sqlstr+  'UserName='+Value.UserName.ValueToString+','+
  'Password='+Value.Password.ValueToString+','+
  'RegisterTime='+Value.RegisterTime.ValueToString+','+
  'LastLoginTime='+Value.LastLoginTime.ValueToString+','+
  'FailCount='+Value.FailCount.ValueToString+','+
  'Nickname='+Value.Nickname.ValueToString+','+
  'HeadImg='+Value.HeadImg.ValueToString+','+
  'Sex='+Value.Sex.ValueToString+','+
  'Birthday='+Value.Birthday.ValueToString+','+
  'DepartMent='+Value.DepartMent.ValueToString+','+
  'JobType='+Value.JobType.ValueToString+','+
  'Edu='+Value.Edu.ValueToString+','+
  'Personality='+Value.Personality.ValueToString+','+
  'PersonHobbie='+Value.PersonHobbie.ValueToString+','+
  'PersonSign='+Value.PersonSign.ValueToString+','+
  'Remark='+Value.Remark.ValueToString+','+
  'CityID='+Value.CityID.ValueToString+','+
  'Email='+Value.Email.ValueToString+','+
  'PersonPhone='+Value.PersonPhone.ValueToString+','+
  'Ask='+Value.Ask.ValueToString+','+
  'Answer='+Value.Answer.ValueToString+','+
  'UserState='+Value.UserState.ValueToString+' Where UserID='+InttoStr(UserID);
  try
  If FadoConnection.Connected=False then 
  FadoConnection.Connected:=True;
  Fadoqry.Close;
  Fadoqry.Sql.text:=Sqlstr;
  Result:=Fadoqry.ExecSql>0;
  Fadoqry.Close;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
Function TBLLUserInfo.Exists(UserName:String):Boolean;
Var Sqlstr:string;
Begin
Sqlstr:='Select UserName From UserInfo Where UserName='+''''+UserName+'''';
  try
  If FadoConnection.Connected=False then 
  FadoConnection.Connected:=True;
  Fadoqry.Close;
  Fadoqry.Sql.text:=Sqlstr;
  Fadoqry.Open;
  Result:=Fadoqry.recordCount>0;
  Fadoqry.Close;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
Function TBLLUserInfo.GetModel(UserName:String):TModelUserInfo;
Var Sqlstr:string;
Begin
  Result:=nil;
  Sqlstr:='Select UserID,UserName,Password,RegisterTime,LastLoginTime,'+
  'FailCount,Nickname,HeadImg,Sex,Birthday,'+
  'DepartMent,JobType,Edu,Personality,PersonHobbie,'+
  'PersonSign,Remark,CityID,Email,PersonPhone,'+
  'Ask,Answer,UserState From UserInfo Where UserName='+''''+UserName+'''';
  try
  If FadoConnection.Connected=False then 
  FadoConnection.Connected:=True;
  Fadoqry.Close;
  Fadoqry.Sql.text:=Sqlstr;
  Fadoqry.Open;
  if Fadoqry.recordCount>0 then begin
     Result:=TModelUserInfo.Create;
     Result.UserID.Value:=Fadoqry.Fieldbyname('UserID').Value;
     Result.UserName.Value:=Fadoqry.Fieldbyname('UserName').Value;
     Result.Password.Value:=Fadoqry.Fieldbyname('Password').Value;
     Result.RegisterTime.Value:=Fadoqry.Fieldbyname('RegisterTime').Value;
     Result.LastLoginTime.Value:=Fadoqry.Fieldbyname('LastLoginTime').Value;
     Result.FailCount.Value:=Fadoqry.Fieldbyname('FailCount').Value;
     Result.Nickname.Value:=Fadoqry.Fieldbyname('Nickname').Value;
     Result.HeadImg.Value:=Fadoqry.Fieldbyname('HeadImg').Value;
     Result.Sex.Value:=Fadoqry.Fieldbyname('Sex').Value;
     Result.Birthday.Value:=Fadoqry.Fieldbyname('Birthday').Value;
     Result.DepartMent.Value:=Fadoqry.Fieldbyname('DepartMent').Value;
     Result.JobType.Value:=Fadoqry.Fieldbyname('JobType').Value;
     Result.Edu.Value:=Fadoqry.Fieldbyname('Edu').Value;
     Result.Personality.Value:=Fadoqry.Fieldbyname('Personality').Value;
     Result.PersonHobbie.Value:=Fadoqry.Fieldbyname('PersonHobbie').Value;
     Result.PersonSign.Value:=Fadoqry.Fieldbyname('PersonSign').Value;
     Result.Remark.Value:=Fadoqry.Fieldbyname('Remark').Value;
     Result.CityID.Value:=Fadoqry.Fieldbyname('CityID').Value;
     Result.Email.Value:=Fadoqry.Fieldbyname('Email').Value;
     Result.PersonPhone.Value:=Fadoqry.Fieldbyname('PersonPhone').Value;
     Result.Ask.Value:=Fadoqry.Fieldbyname('Ask').Value;
     Result.Answer.Value:=Fadoqry.Fieldbyname('Answer').Value;
     Result.UserState.Value:=Fadoqry.Fieldbyname('UserState').Value;
  end;
  Fadoqry.Close;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
Function TBLLUserInfo.DeleteModel(UserName:String):Boolean;
Var Sqlstr:string;
Begin
Sqlstr:='Delete  From UserInfo Where UserName='+''''+UserName+'''';
  try
  If FadoConnection.Connected=False then 
  FadoConnection.Connected:=True;
  Fadoqry.Close;
  Fadoqry.Sql.text:=Sqlstr;
  Result:=Fadoqry.ExecSql>0;
  Fadoqry.Close;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
Function TBLLUserInfo.Update(UserName:String;Value:TModelUserInfo):Boolean;
Var Sqlstr:string;
Begin
  Sqlstr:='Update UserInfo Set ';
  Sqlstr:=Sqlstr+  'UserName='+Value.UserName.ValueToString+','+
  'Password='+Value.Password.ValueToString+','+
  'RegisterTime='+Value.RegisterTime.ValueToString+','+
  'LastLoginTime='+Value.LastLoginTime.ValueToString+','+
  'FailCount='+Value.FailCount.ValueToString+','+
  'Nickname='+Value.Nickname.ValueToString+','+
  'HeadImg='+Value.HeadImg.ValueToString+','+
  'Sex='+Value.Sex.ValueToString+','+
  'Birthday='+Value.Birthday.ValueToString+','+
  'DepartMent='+Value.DepartMent.ValueToString+','+
  'JobType='+Value.JobType.ValueToString+','+
  'Edu='+Value.Edu.ValueToString+','+
  'Personality='+Value.Personality.ValueToString+','+
  'PersonHobbie='+Value.PersonHobbie.ValueToString+','+
  'PersonSign='+Value.PersonSign.ValueToString+','+
  'Remark='+Value.Remark.ValueToString+','+
  'CityID='+Value.CityID.ValueToString+','+
  'Email='+Value.Email.ValueToString+','+
  'PersonPhone='+Value.PersonPhone.ValueToString+','+
  'Ask='+Value.Ask.ValueToString+','+
  'Answer='+Value.Answer.ValueToString+','+
  'UserState='+Value.UserState.ValueToString+' Where UserName='+''''+UserName+'''';
  try
  If FadoConnection.Connected=False then 
  FadoConnection.Connected:=True;
  Fadoqry.Close;
  Fadoqry.Sql.text:=Sqlstr;
  Result:=Fadoqry.ExecSql>0;
  Fadoqry.Close;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
Procedure TBLLUserInfo.GetDataSet(strWhere:string;Qry:Tadoquery);
Var Sqlstr:string;
Begin
  Sqlstr:='Select UserID,UserName,Password,RegisterTime,LastLoginTime,'+
  'FailCount,Nickname,HeadImg,Sex,Birthday,'+
  'DepartMent,JobType,Edu,Personality,PersonHobbie,'+
  'PersonSign,Remark,CityID,Email,PersonPhone,'+
  'Ask,Answer,UserState From UserInfo';
  If Trim(strWhere)<>'' then 
  Sqlstr:=Sqlstr+' where '+sTrWhere;
  Qry.Close;
  if not assigned(Qry.Connection) then
  begin
    qry.Connection:=self.FadoConnection ;
    If FadoConnection.Connected=False then
    FadoConnection.Connected:=True;
  end;
  Qry.Sql.text:=Sqlstr;
  try
  Qry.Open;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
Procedure TBLLUserInfo.GetDataSet(Top:integer;StrWhere,orderby:string;Qry:Tadoquery);
Var Sqlstr:string;
Begin
  Sqlstr:='Select ';
  If Top>0 then Sqlstr:=Sqlstr+'Top '+inttostr(Top);
  Sqlstr:=Sqlstr+' UserID,UserName,Password,RegisterTime,LastLoginTime,'+
  'FailCount,Nickname,HeadImg,Sex,Birthday,'+
  'DepartMent,JobType,Edu,Personality,PersonHobbie,'+
  'PersonSign,Remark,CityID,Email,PersonPhone,'+
  'Ask,Answer,UserState From UserInfo';
  If Trim(strWhere)<>'' then 
  Sqlstr:=Sqlstr+' where '+sTrWhere;
  If Trim(orderby)<>'' then 
  Sqlstr:=Sqlstr+' Order by '+orderby;
  Qry.Close;
  if not assigned(Qry.Connection) then
  begin
    qry.Connection:=self.FadoConnection ;
    If FadoConnection.Connected=False then
    FadoConnection.Connected:=True;
  end;
  Qry.Sql.text:=Sqlstr;
  try
  Qry.Open;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
Function TBLLUserInfo.DeleteList(Model:TmodelUserInfo):Boolean;
Var Sqlstr,strwhere:string;
Begin
Sqlstr:='Delete From UserInfo';
StrWhere:='';
  with Model do begin
    If (Not UserID.IsNull) Then 
    StrWhere:=StrWhere+'(UserID='+UserID.ValueToString+')and';
    If (Not UserName.IsNull) Then 
    StrWhere:=StrWhere+'(UserName='+UserName.ValueToString+')and';
    If (Not Password.IsNull) Then 
    StrWhere:=StrWhere+'(Password='+Password.ValueToString+')and';
    If (Not RegisterTime.IsNull) Then 
    StrWhere:=StrWhere+'(RegisterTime='+RegisterTime.ValueToString+')and';
    If (Not LastLoginTime.IsNull) Then 
    StrWhere:=StrWhere+'(LastLoginTime='+LastLoginTime.ValueToString+')and';
    If (Not FailCount.IsNull) Then 
    StrWhere:=StrWhere+'(FailCount='+FailCount.ValueToString+')and';
    If (Not Nickname.IsNull) Then 
    StrWhere:=StrWhere+'(Nickname='+Nickname.ValueToString+')and';
    If (Not HeadImg.IsNull) Then 
    StrWhere:=StrWhere+'(HeadImg='+HeadImg.ValueToString+')and';
    If (Not Sex.IsNull) Then 
    StrWhere:=StrWhere+'(Sex='+Sex.ValueToString+')and';
    If (Not Birthday.IsNull) Then 
    StrWhere:=StrWhere+'(Birthday='+Birthday.ValueToString+')and';
    If (Not DepartMent.IsNull) Then 
    StrWhere:=StrWhere+'(DepartMent='+DepartMent.ValueToString+')and';
    If (Not JobType.IsNull) Then 
    StrWhere:=StrWhere+'(JobType='+JobType.ValueToString+')and';
    If (Not Edu.IsNull) Then 
    StrWhere:=StrWhere+'(Edu='+Edu.ValueToString+')and';
    If (Not Personality.IsNull) Then 
    StrWhere:=StrWhere+'(Personality='+Personality.ValueToString+')and';
    If (Not PersonHobbie.IsNull) Then 
    StrWhere:=StrWhere+'(PersonHobbie='+PersonHobbie.ValueToString+')and';
    If (Not PersonSign.IsNull) Then 
    StrWhere:=StrWhere+'(PersonSign='+PersonSign.ValueToString+')and';
    If (Not Remark.IsNull) Then 
    StrWhere:=StrWhere+'(Remark='+Remark.ValueToString+')and';
    If (Not CityID.IsNull) Then 
    StrWhere:=StrWhere+'(CityID='+CityID.ValueToString+')and';
    If (Not Email.IsNull) Then 
    StrWhere:=StrWhere+'(Email='+Email.ValueToString+')and';
    If (Not PersonPhone.IsNull) Then 
    StrWhere:=StrWhere+'(PersonPhone='+PersonPhone.ValueToString+')and';
    If (Not Ask.IsNull) Then 
    StrWhere:=StrWhere+'(Ask='+Ask.ValueToString+')and';
    If (Not Answer.IsNull) Then 
    StrWhere:=StrWhere+'(Answer='+Answer.ValueToString+')and';
    If (Not UserState.IsNull) Then 
    StrWhere:=StrWhere+'(UserState='+UserState.ValueToString+')and';
  End;
  if trim(StrWhere)<>'' then begin delete(StrWhere,length(Strwhere)-2,3);
  StrWhere:=' where'+StrWhere;
  End;
  try
  If FadoConnection.Connected=False then 
  FadoConnection.Connected:=True;
  Fadoqry.Close;
  Fadoqry.Sql.text:=Sqlstr+StrWhere;
  Result:=Fadoqry.ExecSql>0;
  Fadoqry.Close;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
Function TBLLUserInfo.DeleteListOr(Model:TmodelUserInfo):Boolean;
Var Sqlstr,strwhere:string;
Begin
Sqlstr:='Delete From UserInfo';
StrWhere:='';
  with Model do begin
    If (Not UserID.IsNull) Then 
    StrWhere:=StrWhere+'(UserID='+UserID.ValueToString+')Or';
    If (Not UserName.IsNull) Then 
    StrWhere:=StrWhere+'(UserName='+UserName.ValueToString+')Or';
    If (Not Password.IsNull) Then 
    StrWhere:=StrWhere+'(Password='+Password.ValueToString+')Or';
    If (Not RegisterTime.IsNull) Then 
    StrWhere:=StrWhere+'(RegisterTime='+RegisterTime.ValueToString+')Or';
    If (Not LastLoginTime.IsNull) Then 
    StrWhere:=StrWhere+'(LastLoginTime='+LastLoginTime.ValueToString+')Or';
    If (Not FailCount.IsNull) Then 
    StrWhere:=StrWhere+'(FailCount='+FailCount.ValueToString+')Or';
    If (Not Nickname.IsNull) Then 
    StrWhere:=StrWhere+'(Nickname='+Nickname.ValueToString+')Or';
    If (Not HeadImg.IsNull) Then 
    StrWhere:=StrWhere+'(HeadImg='+HeadImg.ValueToString+')Or';
    If (Not Sex.IsNull) Then 
    StrWhere:=StrWhere+'(Sex='+Sex.ValueToString+')Or';
    If (Not Birthday.IsNull) Then 
    StrWhere:=StrWhere+'(Birthday='+Birthday.ValueToString+')Or';
    If (Not DepartMent.IsNull) Then 
    StrWhere:=StrWhere+'(DepartMent='+DepartMent.ValueToString+')Or';
    If (Not JobType.IsNull) Then 
    StrWhere:=StrWhere+'(JobType='+JobType.ValueToString+')Or';
    If (Not Edu.IsNull) Then 
    StrWhere:=StrWhere+'(Edu='+Edu.ValueToString+')Or';
    If (Not Personality.IsNull) Then 
    StrWhere:=StrWhere+'(Personality='+Personality.ValueToString+')Or';
    If (Not PersonHobbie.IsNull) Then 
    StrWhere:=StrWhere+'(PersonHobbie='+PersonHobbie.ValueToString+')Or';
    If (Not PersonSign.IsNull) Then 
    StrWhere:=StrWhere+'(PersonSign='+PersonSign.ValueToString+')Or';
    If (Not Remark.IsNull) Then 
    StrWhere:=StrWhere+'(Remark='+Remark.ValueToString+')Or';
    If (Not CityID.IsNull) Then 
    StrWhere:=StrWhere+'(CityID='+CityID.ValueToString+')Or';
    If (Not Email.IsNull) Then 
    StrWhere:=StrWhere+'(Email='+Email.ValueToString+')Or';
    If (Not PersonPhone.IsNull) Then 
    StrWhere:=StrWhere+'(PersonPhone='+PersonPhone.ValueToString+')Or';
    If (Not Ask.IsNull) Then 
    StrWhere:=StrWhere+'(Ask='+Ask.ValueToString+')Or';
    If (Not Answer.IsNull) Then 
    StrWhere:=StrWhere+'(Answer='+Answer.ValueToString+')Or';
    If (Not UserState.IsNull) Then 
    StrWhere:=StrWhere+'(UserState='+UserState.ValueToString+')Or';
  End;
  if trim(StrWhere)<>'' then begin delete(StrWhere,length(Strwhere)-1,2);
  StrWhere:=' where'+StrWhere;
  End;
  try
  If FadoConnection.Connected=False then 
  FadoConnection.Connected:=True;
  Fadoqry.Close;
  Fadoqry.Sql.text:=Sqlstr+StrWhere;
  Result:=Fadoqry.ExecSql>0;
  Fadoqry.Close;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
Function TBLLUserInfo.DeleteByWhere(StrWhere:string):Boolean;
Var Sqlstr:string;
Begin
  If Trim(StrWhere)='' then raise exception.Create('条件不能为空');
  Sqlstr:='Delete  From UserInfo Where '+StrWhere;
  try
  If FadoConnection.Connected=False then 
  FadoConnection.Connected:=True;
  Fadoqry.Close;
  Fadoqry.Sql.text:=Sqlstr;
  Result:=Fadoqry.ExecSql>0;
  Fadoqry.Close;
  except
  On e:exception do raise exception.Create(e.message);
  end;
End;
End.
