Control_statusU学籍变动单元代码
uses DAHelper,ClassesU,ADODB,SysUtils;
//添加学籍变动信息
function AddStatus(Status:TStatus):boolean;
//修改学籍变动信息
function EditStatus(Status:TStatus):boolean;
//删除学籍变动信息
function DelStatus(id:integer):boolean;
//得到学籍变动信息
function GetStatusArray:TADOQuery;
//根据学生号查找学籍变动信息
function GetStatusByStdNo(StatusNo:string):TStatus;
//根据学生号查找学籍变动信息,返回TADOQuery类型
function GetStatusQueryByStdNo(StdNo:string):TADOQuery;
implementation
function GetStatusQueryByStdNo(StdNo:string):TADOQuery;
var
sql:string;
begin
sql:='select id,学生证号,变动类型,变动日期,原班级编号,'+
'isnull(转入学校名称,'''') 转入学校名称,'+
'isnull(转入班级编号,'''') 转入班级编号,'+
'isnull(学籍变动原因,'''') 学籍变动原因,'+
'isnull(备注,'''') 备注 from 学籍变动'+
' where 学生证号='+''''+StdNo+'''';
result:=DAHelper.ExeSqlQuery(sql);
end;
function GetStatusByStdNo(StatusNo:string):TStatus;
var
sql:string;
Status:TStatus;
ADOQuery:TADOQuery;
begin
ADOQuery:=TADOQuery.Create(nil);
sql:='select id,学生证号,变动类型,变动日期,原班级编号,'+
'isnull(转入学校名称,'''') 转入学校名称,'+
'isnull(转入班级编号,'''') 转入班级编号,'+
'isnull(学籍变动原因,'''') 学籍变动原因,'+
'isnull(备注,'''') 备注 from 学籍变动'+
' where 学生证号='+''''+StatusNo+'''';
ADOQuery:=DAHelper.ExeSqlQuery(sql);
if(ADOQuery.RecordCount<1) then
begin
result:=nil;
end
else
begin
Status:=TStatus.Create;
Status.id:=ADOQuery.Fields[0].Value;
Status.studentNo:=ADOQuery.Fields[1].Value;
Status.changeType:=ADOQuery.Fields[2].Value;
Status.changeDate:=DateToStr(ADOQuery.Fields[3].Value);
Status.oldClass:=ADOQuery.Fields[4].Value;
Status.newSchool:=ADOQuery.Fields[5].Value;
Status.newClass:=ADOQuery.Fields[6].Value;
Status.reason:=ADOQuery.Fields[7].Value;
Status.remark:=ADOQuery.Fields[8].Value;
result:=Status;
end;
ADOQuery:=nil;
end;
function GetStatusArray:TADOQuery;
var
sql:string;
begin
sql:='select id,学生证号,变动类型,变动日期,原班级编号,'+
'isnull(转入学校名称,'''') 转入学校名称,'+
'isnull(转入班级编号,'''') 转入班级编号,'+
'isnull(学籍变动原因,'''') 学籍变动原因,'+
'isnull(备注,'''') 备注 from 学籍变动';
result:=DAHelper.ExeSqlQuery(sql);
end;
function DelStatus(id:integer):boolean;
var
sql:string;
begin
sql:='delete from 学籍变动 where id='+inttostr(id);
result:=DAHelper.ExeSqlNoQuery(sql);
end;
function EditStatus(Status:TStatus):boolean;
var
sql:string;
begin
sql:='update 学籍变动 set 学生证号='+''''+Status.studentNo+''''+
',变动类型='+''''+Status.changeType +''''+
',原班级编号='+''''+Status.oldClass +''''+
',转入学校名称='+''''+Status.newSchool+''''+
',转入班级编号='+''''+Status.newClass+''''+
',学籍变动原因='+''''+Status.reason+''''+
',备注='+''''+Status.remark+''''+
' where id='+inttostr(Status.id);
result:=DAHelper.ExeSqlNoQuery(sql);
end;
function AddStatus(Status:TStatus):boolean;
var
sql:string;
begin
sql:='insert into 学籍变动(学生证号,变动类型,变动日期,原班级编号,'+
'转入学校名称,转入班级编号,学籍变动原因,'+
'备注)'+' values('+''''+Status.studentNo+''''+','+''''+Status.changeType+''''+
','+''''+Status.changeDate+''''+','+''''+Status.oldClass+''''+','+
''''+Status.newSchool+''''+','+
''''+Status.newClass+''''+','+''''+Status.reason+''''+
','+''''+Status.remark+''''+ ')';
result:=DAHelper.ExeSqlNoQuery(sql);
end;
Control_StudentU学生信息单元代码
uses DAHelper,ClassesU,ADODB,SysUtils;
//添加学生信息
function AddStudent(Student:TStudent):boolean;
//修改学生信息
function EditStudent(Student:TStudent;stdNo:string):boolean;
//删除学生信息
function DelStudent(stdNo:string):boolean;
//得到学生信息
function GetStudentArray:TADOQuery;
//根据学生号查找学生信息
function GetStudentByStudentNo(StudentNo:string):TStudent;
//根据学生号查找学生信息,返回TADOQuery类型
function GetStudentQueryByStudentNo(StudentNo:string):TADOQuery;
//根据学生姓名查找学生信息
function GetStudentByName(studentName:string):TADOQuery;
implementation
function GetStudentQueryByStudentNo(StudentNo:string):TADOQuery;
var
sql:string;
begin
sql:='select 学生证号,姓名,照片,性别,民族,生日,籍贯,身份证号,isnull(家庭电话,'''') 家庭电话,'+
'居住地址,邮政编码,入校日期,所在院系'+
',isnull(职务,'''') 职务,isnull(备注,'''') 备注 from 学生信息 '+
' where 学生证号='+''''+studentNo+'''';
result:=DAHelper.ExeSqlQuery(sql);
end;
function GetStudentByName(studentName:string):TADOQuery;
var
sql:string;
begin
sql:='select 学生证号,姓名,照片,性别,民族,生日,籍贯,身份证号,isnull(家庭电话,'''') 家庭电话,'+
'居住地址,邮政编码,入校日期,所在院系'+
',isnull(职务,'''') 职务,isnull(备注,'''') 备注 from 学生信息 '+
' where 姓名='+''''+studentName+'''';
result:=DAHelper.ExeSqlQuery(sql);
end;
function GetStudentByStudentNo(StudentNo:string):TStudent;
var
sql:string;
Student:TStudent;
ADOQuery:TADOQuery;
begin
ADOQuery:=TADOQuery.Create(nil);
sql:='select 学生证号,姓名,照片,性别,民族,生日,籍贯,身份证号,isnull(家庭电话,'''') 家庭电话,'+
'居住地址,邮政编码,入校日期,所在院系'+
',isnull(职务,'''') 职务,isnull(备注,'''') 备注 from 学生信息 '+
' where 学生证号='+''''+StudentNo+'''';
ADOQuery:=DAHelper.ExeSqlQuery(sql);
if(ADOQuery.RecordCount<1) then
begin
result:=nil;
end
else
begin
Student:=TStudent.Create;
Student.stdNo:=ADOQuery.Fields[0].Value;
Student.stdName:=ADOQuery.Fields[1].Value;
Student.picPath:=ADOQuery.Fields[2].Value;
Student.sex:=ADOQuery.Fields[3].Value;
Student.nation:=ADOQuery.Fields[4].Value;
Student.birthday:=DateToStr(ADOQuery.Fields[5].Value);
Student.native:=ADOQuery.Fields[6].Value;
Student.IDCard:=ADOQuery.Fields[7].Value;
Student.homeTel:=ADOQuery.Fields[8].Value;
Student.address:=ADOQuery.Fields[9].Value;
Student.postalcode:=ADOQuery.Fields[10].Value;
Student.inDate:=DateToStr(ADOQuery.Fields[11].Value);
Student.ClassName:=ADOQuery.Fields[12].Value;
Student.duty:=ADOQuery.Fields[13].Value;
Student.remark:=ADOQuery.Fields[14].Value;
result:=Student;
end;
ADOQuery:=nil;
end;
function GetStudentArray:TADOQuery;
var
sql:string;
begin
sql:='select 学生证号,姓名,照片,性别,民族,生日,籍贯,身份证号,isnull(家庭电话,'''') 家庭电话,'+
'居住地址,邮政编码,入校日期,所在院系'+
',isnull(职务,'''') 职务,isnull(备注,'''') 备注 from 学生信息 ';
result:=DAHelper.ExeSqlQuery(sql);
end;
function DelStudent(stdNo:string):boolean;
var
sql:string;
begin
sql:='delete from 学生信息 where 学生证号='+''''+stdNo+'''';
result:=DAHelper.ExeSqlNoQuery(sql);
end;
function EditStudent(Student:TStudent;stdNo:string):boolean;
var
sql:string;
begin
sql:='update 学生信息 set 学生证号='+''''+Student.stdNo+''''+
',姓名='+''''+Student.stdName +''''+
',照片='+''''+Student.picPath+''''+
',性别='+''''+Student.sex +''''+
',民族='+''''+Student.nation+''''+
',生日='+''''+Student.birthday+''''+
',籍贯='+''''+Student.native+''''+
',身份证号='+''''+Student.IDCard+''''+
',家庭电话='+''''+Student.homeTel+''''+
',居住地址='+''''+Student.address+''''+
',邮政编码='+''''+Student.postalcode+''''+
',入校日期='+''''+Student.inDate+''''+
',所在院系='+''''+Student.ClassName+''''+
',职务='+''''+Student.duty+''''+
',备注='+''''+Student.remark+''''+
' where 学生证号='+''''+stdNo+'''';
result:=DAHelper.ExeSqlNoQuery(sql);
end;
function AddStudent(Student:TStudent):boolean;
var
sql:string;
begin
sql:='insert into 学生信息(学生证号,姓名,照片,性别,民族,生日,籍贯,身份证号,家庭电话,'+
'居住地址,邮政编码,入校日期,所在院系,职务,'+
'备注)'+' values('+''''+Student.stdNo+''''+','+''''+Student.stdName+''''+
','+''''+Student.picPath+''''+','+''''+Student.sex+''''+','+
''''+Student.nation+''''+','+
''''+Student.birthday+''''+','+''''+Student.native+''''+
','+''''+Student.IDCard+''''+','+''''+Student.homeTel+''''+
','+''''+Student.address+''''+
','+''''+Student.postalcode+''''+','+''''+Student.inDate+''''+
','+''''+Student.ClassName+''''+','+''''+Student.duty+''''+
','+''''+Student.remark+''''+ ')';
result:=DAHelper.ExeSqlNoQuery(sql);
end;DataConfig数据库单元文件
uses
SysUtils,Classes,DB,ADODB;
const
//连接字符串
connectionStr='Provider=SQLOLEDB.1;'+
'Password=123456;Persist Security Info=True;'+
'User ID=sa;Initial Catalog=xjgl;'+
'Data Source=(local)';
var
ADOCon:TADOConnection;
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] 下一页