如何开发一个学生成绩管理糸统(6)

通过前面两个逻辑类的编写,应该基本可以明白逻辑类的编写了,还有如何调用DAL层的数据集调用 。

现在要编写的是CourseInfoBLL的类,基本的添删改就不再多说了,帖上代码就行了。

 

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
   
/// <summary>
/// ClassBLL 的摘要说明
/// </summary>
[System.ComponentModel.DataObject]
public class CourseInfoBLL
{
private s_courseinfoTableAdapter _productsAdapter = null ;

protected s_courseinfoTableAdapter Adapter
{
get
{
if (_productsAdapter == null )
_productsAdapter
= new s_courseinfoTableAdapter();

return _productsAdapter;
}
}

[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Select,
true )]
public GYsms.s_courseinfoDataTable GetCourseInfo()
{
return Adapter.GetCourseInfo();
}



[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Select,
false )]
public GYsms.s_courseinfoDataTable GetCourseInfoById( int id)
{
return Adapter.GetCinfoById(id);
}


[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Insert,
true )]
public bool AddCourseInfo( int id, int pid, int thours, int lhours, int phours)
{
GYsms.s_courseinfoDataTable table
= new GYsms.s_courseinfoDataTable();
GYsms.s_courseinfoRow row
= table.News_courseinfoRow();

row.id
= id;
row.pid
= pid == 0 ? 0 : pid;
row.thours
= thours == 0 ? 0 :thours;
row.lhours
= lhours == 0 ? 0 :lhours;
row.phours
= phours == 0 ? 0 : phours;

table.Adds_courseinfoRow(row);
int rowsAffacted = Adapter.Update(table);
return rowsAffacted == 1 ;
}

[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Update,
true )]
public bool UpdateCourseInfo( int id , int pid, int thours, int lhours, int phours)
{
GYsms.s_courseinfoDataTable table
= Adapter.GetCinfoById(id);
if (table.Count == 0 )
return false ;

GYsms.s_courseinfoRow row
= table[ 0 ];
row.pid
= pid == 0 ? 0 : pid;
row.thours
= thours == 0 ? 0 : thours;
row.lhours
= lhours == 0 ? 0 : lhours;
row.phours
= phours == 0 ? 0 : phours;
int rowsAffacted = Adapter.Update(table);
return rowsAffacted == 1 ;
}



[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Delete,
true )]
public bool DeleteCourseInfo( int id)
{
int rowsAffacted = Adapter.Delete(id);
return rowsAffacted == 1 ;
}

 

这里有一个方法,就是为了可以将两个表s_course和s_courseinfo表进行关联使用的方法

通过查询Pid,返回与s_course表相关联的多个数据集合,再通过Id来调用各个数据,

在构思的时候,我想的是一门课程只有一个s_course表和s_courseinfo表中的一列数据。

 

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
   

/// <summary>
/// 返回Ids的集合,查询专业号
/// </summary>
/// <param name="pid"> 专业号 </param>
/// <returns> Ids集合 </returns>
[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Select,
false )]
public GYsms.s_courseinfoDataTable GetCourseInfoByPId( int pid)
{
// System.Collections.Generic.List<int>
return Adapter.GetIdsByPid(pid);
}

 

 

我在这里放一下DAL层,数据集的代码,还有逻辑层的全部代码,有兴趣的可以自己下载来看看。代码编写主要用来参考,

因为在设计数据表时没有使用关糸,我觉得有点不妥,以后会再重写文章,写一个使用关糸的数据层设计。作为第二板。

http://files.cnblogs.com/ScriptZhang/DAL.rar

http://files.cnblogs.com/ScriptZhang/BLL.rar

还是请大家多给点意见.

 

 

转载于:https://www.cnblogs.com/ScriptZhang/archive/2010/05/17/1737049.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值