Department.cs
上传用户:cha0314
上传日期:2014-03-02
资源大小:12522k
文件大小:5k
源码类别:

C#编程

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. namespace UDS.Components
  5. {
  6. /// <summary>
  7. /// 部门处理类
  8. /// </summary>
  9. public class Department
  10. {
  11. public Department()
  12. {
  13. }
  14. /// <summary>
  15. /// 添加部门
  16. /// </summary>
  17. /// <param name="pid">本部门的父部门id</param>
  18. /// <param name="name">本部门的名称</param>
  19. /// <param name="description">本部门的描述</param>
  20. /// <returns>本部门分配到的id</returns>
  21. public static long Add(long ParentDepartmentID,string name,string description)
  22. {
  23. Database db = new Database();
  24. SqlParameter[] prams = new SqlParameter[3];
  25. prams[0] = new SqlParameter();
  26. prams[1] = new SqlParameter();
  27. prams[2] = new SqlParameter();
  28. prams[0].SqlDbType = SqlDbType.Int;
  29. prams[0].ParameterName = "@Dept_ParentID";
  30. prams[0].Value = ParentDepartmentID;
  31. prams[1].SqlDbType = SqlDbType.VarChar;
  32. prams[1].Size = 255;
  33. prams[1].ParameterName = "@Dept_Name";
  34. prams[1].Value = name;
  35. prams[2].SqlDbType = SqlDbType.Text;
  36. prams[2].ParameterName = "@Dept_Remark";
  37. prams[2].Value = description;
  38. //prams[3] = new SqlParameter();
  39. //prams[3].SqlDbType = SqlDbType.Int;
  40. //prams[3].ParameterName = "@ID";
  41. //prams[3].Direction = ParameterDirection.ReturnValue;
  42. return (db.RunProc("sp_AddDepartment",prams));
  43. }
  44. /// <summary>
  45. /// 添加考勤时间
  46. /// </summary>
  47. /// <param name="id">部门id</param>
  48. /// <param name="ondutytime">上班时间</param>
  49. /// <param name="offdutytime">下班时间</param>
  50. /// <returns></returns>
  51. public static int AddDutyTime(long DepartmentID,DateTime ondutytime,DateTime offdutytime)
  52. {
  53. Database db = new Database();
  54. SqlParameter[] prams = {
  55.    db.MakeInParam("@departmentid",SqlDbType.Int,4,DepartmentID),
  56.    db.MakeInParam("@ondutytime",SqlDbType.DateTime,8,ondutytime),
  57.    db.MakeInParam("@offdutytime",SqlDbType.DateTime,8,offdutytime)
  58.    };
  59. return (db.RunProc("sp_WA_AddDepartmentDutyTime",prams));
  60. }
  61. /// <summary>
  62. /// 更改部门考勤时间
  63. /// </summary>
  64. /// <param name="id">部门id</param>
  65. /// <param name="ondutytime">上班时间</param>
  66. /// <param name="offdutytime">下班时间</param>
  67. /// <returns></returns>
  68. public static int UpdateDutyTime(long DepartmentID,DateTime ondutytime,DateTime offdutytime)
  69. {
  70. Database db = new Database();
  71. SqlParameter[] prams = {
  72.    db.MakeInParam("@departmentid",SqlDbType.Int,4,DepartmentID),
  73.    db.MakeInParam("@ondutytime",SqlDbType.VarChar,20,ondutytime.ToShortTimeString()),
  74.    db.MakeInParam("@offdutytime",SqlDbType.VarChar,20,offdutytime.ToShortTimeString())
  75.    };
  76. return (db.RunProc("sp_WA_UpdateDepartmentDutyTime",prams));
  77. }
  78. public static int DeleteDutyTime(long DepartmentID)
  79. {
  80. Database db = new Database();
  81. SqlParameter[] prams = {
  82.    db.MakeInParam("@departmentid",SqlDbType.Int,4,DepartmentID)
  83.    };
  84. return (db.RunProc("sp_WA_DeleteDepartmentDutyTime",prams));
  85. }
  86. public static int Delete(long DepartmentID)
  87. {
  88. Database db = new Database();
  89. SqlParameter[] prams = {
  90. db.MakeInParam("@Dept_id",SqlDbType.Int,4,DepartmentID)
  91.    };
  92. return(db.RunProc("sp_DeleteDepartment",prams));
  93. }
  94. public static int Modify(long DepartmentID,string dep_name,string dep_description)
  95. {
  96. Database db = new Database();
  97. SqlParameter[] prams = {
  98. db.MakeInParam("@dept_id",SqlDbType.Int,4,DepartmentID),
  99. db.MakeInParam("@dept_name",SqlDbType.VarChar,300,dep_name),
  100. db.MakeInParam("@dept_description",SqlDbType.VarChar,300,dep_description)
  101.    };
  102. return (db.RunProc("sp_UpdateDepartmentInfo",prams));
  103. }
  104. public SqlDataReader GetDepartmentInfo(long DepartmentID)
  105. {
  106. Database db = new Database();
  107. SqlDataReader dr;
  108. SqlParameter[] prams = {
  109.    db.MakeInParam("@dept_id",SqlDbType.Int,4,DepartmentID)
  110.    };
  111. db.RunProc("sp_GetDepartmentInfo",prams,out dr);
  112. return dr;
  113. }
  114. public SqlDataReader GetDepartmentDutyTime(long DepartmentID)
  115. {
  116. Database db = new Database();
  117. SqlDataReader dr;
  118. SqlParameter[] prams = {
  119.    db.MakeInParam("@DeptID",SqlDbType.Int,4,DepartmentID)
  120.    };
  121. db.RunProc("sp_GetDepartmentDutyTime",prams,out dr);
  122. return dr;
  123. }
  124. public int MoveDeparement(long FromDepartmentID,long ToDepartmentID)
  125. {
  126. Database db = new Database();
  127. SqlParameter[] prams = {
  128.    db.MakeInParam("@FromDepartmentID",SqlDbType.Int,4,FromDepartmentID),
  129.    db.MakeInParam("@ToDepartmentID",SqlDbType.Int,4,ToDepartmentID),
  130.    };
  131. return (db.RunProc("sp_MoveDepartment",prams));
  132. }
  133. }
  134. }