All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
WAP与PHP程序设计之基础篇_[PHP教程]
PHP技术:回帖脱衣服的图片实现_php资料_编程技术
SQL Server2000安全管理机制详解_[SQL Server教程]
PHP和AJAX打造高级RSS聚合器_[PHP教程]
ASP.NET实例:在GridView使用HyperLinkField,属性的链接_[Asp.Net教程]
使用PHP程序来保护你的flash作品_php资料_编程技术
PHP开发中关于文件操作的疑难问答_php资料_编程技术
Weblogic,Portal中实现AJAX编程之架构_[Asp.Net教程]
在C#中取得指定长度的字符串_[Asp.Net教程]
浅析CMS内容管理系统的两种方案_[Asp.Net教程]
Reading number is top 10 pictures
The world's top ten most beautiful railway station1
India's national beauty of the college students
Soong ching ling's former residence2
奇趣的世界记录1
So beauty, will let you spray blood2
好身材能把衣服穿出3D效果
我国房地产真相
玩手机对身体不好
From China fortress sora aoi2
牛奶和人奶哪个好?
Download software ranking
电脑知识及技巧大合集
Boxer vs Yellow1
WebService在.NET中的实战应用教学视频 → 第5集
功夫熊猫2(上集)
Unix video tutorial9
Adobe Flash Player(IE) 10.0.32.18 浏览器专用的FLASH插件
网络管理员第三版
传奇私服架设教程
C#高级编程(第4版)
linux初级教程
归海一刀 published in(发表于) 2014/1/30 0:53:38 Edit(编辑)
ASP.NET&Spring.NET&NHibernate最佳实践(五)——第3章人事子系统(2)_[Asp.Net教程]

ASP.NET&Spring.NET&NHibernate最佳实践(五)——第3章人事子系统(2)_[Asp.Net教程]

ASP.NET&Spring.NET&NHibernate最佳实践(五)——第3章人事子系统(2)_[Asp.Net教程]

3.4. 人事子系统服务层(Service)
部门服务接口(IDeptService.cs)
using System;
using Guushuuse.SalaryPrj.HR.DomainModel;
using Guushuuse.SalaryPrj.HR.Dao;
using System.Collections;


namespace Guushuuse.SalaryPrj.HR.Service
{
/**////


/// 部门服务接口
///

public interface IDeptService
{
void CreateDept(Dept dept);
void DeleteDept(Dept dept);
IDeptDao DeptDao { get; set; }
IList GetAllDepts();
Dept GetDept(int deptID);
void UpdateDept(Dept dept);
}
}


部门服务类(DeptService.cs)
using System;
using System.Collections.Generic;
using System.Text;
using Guushuuse.SalaryPrj.HR.Dao;
using Guushuuse.SalaryPrj.HR.DomainModel;
using System.Collections;
using Spring.Transaction.Interceptor;


namespace Guushuuse.SalaryPrj.HR.Service
{
/**////


/// 部门服务类
///

public class DeptService : IDeptService
{
private IDeptDao _deptDao;


public IDeptDao DeptDao
{
get { return _deptDao; }
set { _deptDao = value; }
}


public DeptService()
{


}


[Transaction(ReadOnly = false)]
public void CreateDept(Dept dept)
{
_deptDao.CreateDept(dept);
}


[Transaction(ReadOnly = false)]
public void UpdateDept(Dept dept)
{
_deptDao.UpdateDept(dept);
}


[Transaction(ReadOnly = false)]
public void DeleteDept(Dept dept)
{
_deptDao.DeleteDept(dept);
}


public IList GetAllDepts()
{
return _deptDao.GetAllDepts();
}


public Dept GetDept(int deptID)
{
return _deptDao.GetDept(deptID);
}
}
}


员工服务接口(IEmployeeService.cs)
using System;
using Guushuuse.SalaryPrj.HR.DomainModel;
using Guushuuse.SalaryPrj.HR.Dao;
using System.Collections;


namespace Guushuuse.SalaryPrj.HR.Service
{
/**////


/// 员工服务接口
///

public interface IEmployeeService
{
void CreateEmployee(Employee employee);
void DeleteEmployee(Employee employee);
IEmployeeDao EmployeeDao { get; set; }
IList GetAllEmployees();
Employee GetEmployee(int employeeID);
void UpdateEmployee(Employee employee);
}
}


员工服务类(EmployeeService.cs)
using System;
using System.Collections.Generic;
using System.Text;
using Guushuuse.SalaryPrj.HR.Dao;
using Guushuuse.SalaryPrj.HR.DomainModel;
using System.Collections;
using Spring.Transaction.Interceptor;


namespace Guushuuse.SalaryPrj.HR.Service
{
/**////


/// 员工服务类
///

public class EmployeeService : IEmployeeService
{
private IEmployeeDao _employeeDao;


public IEmployeeDao EmployeeDao
{
get { return _employeeDao; }
set { _employeeDao = value; }
}


public EmployeeService()
{


}


[Transaction(ReadOnly = false)]
public void CreateEmployee(Employee employee)
{
_employeeDao.CreateEmployee(employee);
}


[Transaction(ReadOnly = false)]
public void UpdateEmployee(Employee employee)
{
_employeeDao.UpdateEmployee(employee);
}


[Transaction(ReadOnly = false)]
public void DeleteEmployee(Employee employee)
{
_employeeDao.DeleteEmployee(employee);
}


public IList GetAllEmployees()
{
return _employeeDao.GetAllEmployees();
}


public Employee GetEmployee(int employeeID)
{
return _employeeDao.GetEmployee(employeeID);
}
}
}


服务定位类(ServiceLocator.cs)
using System;
using System.Collections.Generic;
using System.Text;
using Spring.Context;
using Spring.Context.Support;


namespace Guushuuse.SalaryPrj.HR.Service
{
/**////


/// 服务定位类
///

public class ServiceLocator
{
private static IApplicationContext _ctx;


static ServiceLocator()
{
_ctx = ContextRegistry.GetContext();
}


public static IDeptService DeptService
{
get
{
IDeptService deptService = _ctx["deptService"] as IDeptService;


return deptService;
}
}


public static IEmployeeService EmployeeService
{
get
{
IEmployeeService employeeService = _ctx["employeeService"] as IEmployeeService;


return employeeService;
}
}
}
}


修改Config/Guushuuse.SalaryPrj.HR.config文件,新增object






3.5. 人事子系统帮助类(Helper)
帮助类(HRHelper.cs)
using System;
using System.Collections.Generic;
using System.Text;
using Guushuuse.SalaryPrj.HR.DomainModel;
using Guushuuse.SalaryPrj.HR.Service;
using System.Collections;


namespace Guushuuse.SalaryPrj.HR.Helper
{
/**////


/// 帮助类
///

public class HRHelper
{
/**////
/// 新增部门
///

///
///
public static void CreateDept(string code, string name)
{
try
{
Dept dept = new Dept();
dept.Code = code;
dept.Name = name;


ServiceLocator.DeptService.CreateDept(dept);
}
catch (Exception ex)
{
throw ex;
}
}


/**////


/// 更新部门
///

///
///
///
public static void UpdateDept(int id, string code, string name)
{
try
{
Dept dept = ServiceLocator.DeptService.GetDept(id);
dept.Code = code;
dept.Name = name;


ServiceLocator.DeptService.CreateDept(dept);
}
catch (Exception ex)
{
throw ex;
}
}


/**////


/// 删除部门
///

///
///
///
public static void DeleteDept(int id, string code, string name)
{
try
{
Dept dept = ServiceLocator.DeptService.GetDept(id);

ServiceLocator.DeptService.DeleteDept(dept);
}
catch (Exception ex)
{
throw ex;
}
}


/**////


/// 取出所有部门
///

///
public static IList GetAllDepts()
{
IList depts;


try
{
depts = ServiceLocator.DeptService.GetAllDepts();
}
catch (Exception ex)
{
throw ex;
}


return depts;
}


/**////


/// 新增员工
///

///
///
///
public static void CreateEmployee(string code, string name, int deptID)
{
try
{
Employee employee = new Employee();
employee.Code = code;
employee.Name = name;
employee.Dept = ServiceLocator.DeptService.GetDept(deptID);


ServiceLocator.EmployeeService.CreateEmployee(employee);
}
catch (Exception ex)
{
throw ex;
}
}


/**////


/// 更新员工
///

///
///
///
///
public static void UpdateEmployee(int id, string code, string name, int deptID)
{
try
{
Employee employee = ServiceLocator.EmployeeService.GetEmployee(id);
employee.Code = code;
employee.Name = name;
employee.Dept = ServiceLocator.DeptService.GetDept(deptID);


ServiceLocator.EmployeeService.CreateEmployee(employee);
}
catch (Exception ex)
{
throw ex;
}
}


/**////


/// 删除员工
///

///
///
///
public static void DeleteEmployee(int id, string code, string name)
{
try
{
Employee employee = ServiceLocator.EmployeeService.GetEmployee(id);


ServiceLocator.EmployeeService.DeleteEmployee(employee);
}
catch (Exception ex)
{
throw ex;
}
}


/**////


/// 取出所有员工
///

///
public static IList GetAllEmployees()
{
IList employees;


try
{
employees = ServiceLocator.EmployeeService.GetAllEmployees();
}
catch (Exception ex)
{
throw ex;
}


return employees;
}
}
}







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.