using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//添加导入命名空间语句
using System.Data.Linq;
using DataLinq;
namespace HrDAL
{
public class DALPostInfo
{
//创建DataContext对象
private HrDataLinqDataContext objDataContext = new HrDataLinqDataContext();
//添加方法返回表PostInfo的全部记录,DataContext对象负责数据库操作
public Table<PostInfo> SelectRecordAll()
{
try
{
return objDataContext.PostInfo;
}
catch (Exception ex)
{
throw ex;
}
}
//
public IList<PostInfo> listSelectRecordAll()
{
try
{
return objDataContext.PostInfo.ToList();
}
catch (Exception ex)
{
throw ex;
}
}
////////////////////////////
////////////////////////
public int SelectPIDBySName(string sname)
{//通过职位名查询对象编号
try
{
return ((from post in objDataContext.PostInfo where post.postName == sname select post.Pid).Single());
}
catch (Exception ex)
{
throw ex;
}
}
public string SelectPNameByPID(int pid)
{//通过对象编号查询职位名
try
{
return ((from post in objDataContext.PostInfo where post.Pid == pid select post.postName).Single());
}
catch (Exception ex)
{
throw ex;
}
}
}
//对表Employmee操作
public class DALEmployInfo
{
//创建DataContext对象
private HrDataLinqDataContext objDataContext = new HrDataLinqDataContext();
//添加方法返回表PostInfo的全部记录,DataContext对象负责数据库操作
//对表Employmee操作
public Table<EmployInfo> SelectRecordAll()
{
try
{
return objDataContext.EmployInfo;
}
catch (Exception ex)
{
throw ex;
}
}
public string SelectMaxRecordNo()
{
try
{
return ((from maxEID in objDataContext.EmployInfo select maxEID.Eid).Max()) ;
}
catch (Exception ex)
{
throw ex;
}
}
public EmployInfo SelectRecordByID(string eid)
{//通过员工编号查询记录
try
{
return (from emp in objDataContext.EmployInfo where emp.Eid ==eid
select emp).Single();
}
catch (Exception ex)
{
throw ex;
}
}
public bool InsertRecord(EmployInfo obj)
{
try
{
//EmployInfo objEmployee = new EmployInfo();
//objDataContext.EmployInfo.InsertOnSubmit(localTable);
objDataContext.EmployInfo.InsertOnSubmit(obj);
objDataContext.SubmitChanges();
return true ;
}
catch (Exception ex)
{
//throw ex;
return false;
}
}
////////
public bool UpdateRecord(EmployInfo localTable)
{
try
{
objDataContext.EmployInfo.Attach(localTable);
objDataContext.Refresh(RefreshMode.KeepCurrentValues, localTable);
objDataContext.SubmitChanges(ConflictMode.ContinueOnConflict);
return true;
}
catch (Exception ex)
{
//throw ex;
return false;
}
}
///读照片
///
public byte[] selectimg(string eid)
{
try
{
return(from emp in objDataContext.EmployInfo
where emp.Eid == eid
select emp.Ephoto ).Single().ToArray ();
}
catch (Exception ex)
{
throw ex;
}
}
}
//Section表
public class DALSectionInfo
{
//创建DataContext对象
private HrDataLinqDataContext objDataContext = new HrDataLinqDataContext();
//添加方法返回表PostInfo的全部记录,DataContext对象负责数据库操作
public Table<Section> SelectRecordAll()
{
try
{
return objDataContext.Section ;
}
catch (Exception ex)
{
throw ex;
}
}
////////////////////////
public int SelectSIDBySName(string sname)
{
try
{
return ((from sid in objDataContext.Section where sid.SectionName==sname select sid.Sid).Single ());
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// sid------sname
/// </summary>
/// <returns></returns>
///
public string SelectSNameBySID(int sid)
{//通过对象编号查询职位名
try
{
return ((from sect in objDataContext.Section where sect.Sid == sid select sect.SectionName ).Single());
}
catch (Exception ex)
{
throw ex;
}
}
public IList<Section> listSelectRecordAll()
{
try
{
return objDataContext.Section.ToList();
}
catch (Exception ex)
{
throw ex;
}
}
}
///对TrainInfo表的操作
///
public class DALTrainInfo
{
//创建DataContext对象
private HrDataLinqDataContext objDataContext = new HrDataLinqDataContext();
//添加方法返回表TrainInfo的全部记录,DataContext对象负责数据库操作
public Table<TrainEmployeeView> SelectRecordAll()
{//返回表TrainInfo的全部记录
try
{
return objDataContext.TrainEmployeeView ;
//目前linq不支持将多表联合查询的结果返回,
//对于这个情况,你只能在数据库里面建立一个视图,
//视图里面包含你所需要的所有数据列,然后在视图里面查询。
}
catch (Exception ex)
{
throw ex;
}
}
////////////////////////
public IList<TrainInfo > listSelectRecordAll()
{//返回表TrainInfo的全部记录并存到IList之中
try
{
return objDataContext.TrainInfo.ToList();
}
catch (Exception ex)
{
throw ex;
}
}
public bool UpdateRecord(TrainInfo localTable)
{ //更新TrainInfo表中的数据
try
{
objDataContext.TrainInfo.Attach(localTable);
objDataContext.Refresh(RefreshMode.KeepCurrentValues, localTable);
ob
勾之月
- 粉丝: 693
- 资源: 6728
最新资源
- 聋哑人手语词汇图像分类数据集【已标注,约1,100张数据】
- 基于Pygame库实现新年烟花效果的Python代码
- 必应图片壁纸Python爬虫代码bing-img.zip
- 购物返利源码/代购网站源码/每日分打包完整版源码下载
- Java外卖项目(瑞吉外卖项目的扩展)
- 使用Python和matplotlib库绘制爱心图形的技术教程
- 国际象棋检测11-YOLO(v7至v9)、COCO、Darknet、Paligemma、VOC数据集合集.rar
- Python与Pygame实现带特效的圣诞节场景模拟程序
- R语言实战机器学习实战教程
- 常用算法介绍与学习资源汇总
- ssd5课件图片记录保存
- 国际象棋检测2-YOLO(v5至v11)、COCO、CreateML、Paligemma、TFRecord、VOC数据集合集.rar
- Offer资讯交流Web系统(编号:0889870).zip
- 高考志愿智能推荐系统_2a1qfv22.zip
- 个性化推荐影院(编号:03132141).zip
- 高校学生求职就业平台(编号:24440246).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈