Position.cs
上传用户:jdb8708888
上传日期:2013-05-29
资源大小:19971k
文件大小:6k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

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 Position
  10. {
  11. public Position()
  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 ParentPositionID,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 = "@Position_ParentID";
  30. prams[0].Value = ParentPositionID;
  31. prams[1].SqlDbType = SqlDbType.VarChar;
  32. prams[1].Size = 255;
  33. prams[1].ParameterName = "@Position_Name";
  34. prams[1].Value = name.Trim();
  35. prams[2].SqlDbType = SqlDbType.Text;
  36. prams[2].ParameterName = "@Position_Remark";
  37. prams[2].Value = description.Trim();
  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_AddPosition",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 PositionID,DateTime ondutytime,DateTime offdutytime)
  52. {
  53. Database db = new Database();
  54. SqlParameter[] prams = {
  55.    db.MakeInParam("@positionid",SqlDbType.Int,4,PositionID),
  56.    db.MakeInParam("@ondutytime",SqlDbType.DateTime,8,ondutytime),
  57.    db.MakeInParam("@offdutytime",SqlDbType.DateTime,8,offdutytime)
  58.    };
  59. return (db.RunProc("sp_WA_AddPositionDutyTime",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 PositionID,DateTime ondutytime,DateTime offdutytime)
  69. {
  70. Database db = new Database();
  71. SqlParameter[] prams = {
  72.    db.MakeInParam("@positionid",SqlDbType.Int,4,PositionID),
  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_UpdatePositionDutyTime",prams));
  77. }
  78. public static int DeleteDutyTime(long PositionID)
  79. {
  80. Database db = new Database();
  81. SqlParameter[] prams = {
  82.    db.MakeInParam("@positionid",SqlDbType.Int,4,PositionID)
  83.    };
  84. return (db.RunProc("sp_WA_DeletePositionDutyTime",prams));
  85. }
  86. public static int Delete(long PositionID)
  87. {
  88. Database db = new Database();
  89. SqlParameter[] prams = {
  90. db.MakeInParam("@Position_id",SqlDbType.Int,4,PositionID)
  91.    };
  92. return(db.RunProc("sp_DeletePosition",prams));
  93. }
  94. public static int Modify(long PositionID,string dep_name,string dep_description)
  95. {
  96. Database db = new Database();
  97. SqlParameter[] prams = {
  98. db.MakeInParam("@position_id",SqlDbType.Int,4,PositionID),
  99. db.MakeInParam("@position_name",SqlDbType.VarChar,300,dep_name.Trim()),
  100. db.MakeInParam("@position_description",SqlDbType.VarChar,300,dep_description.Trim())
  101.    };
  102. return (db.RunProc("sp_UpdatePositionInfo",prams));
  103. }
  104. public SqlDataReader GetPositionInfo(long PositionID)
  105. {
  106. Database db = new Database();
  107. SqlDataReader dr;
  108. SqlParameter[] prams = {
  109.    db.MakeInParam("@position_id",SqlDbType.Int,4,PositionID)
  110.    };
  111. db.RunProc("sp_GetPositionInfo",prams,out dr);
  112. return dr;
  113. }
  114. public SqlDataReader GetPositionDutyTime(long PositionID)
  115. {
  116. Database db = new Database();
  117. SqlDataReader dr;
  118. SqlParameter[] prams = {
  119.    db.MakeInParam("@PositionID",SqlDbType.Int,4,PositionID)
  120.    };
  121. db.RunProc("sp_GetPositionDutyTime",prams,out dr);
  122. return dr;
  123. }
  124. public int MoveDeparement(long FromPositionID,long ToPositionID)
  125. {
  126. Database db = new Database();
  127. SqlParameter[] prams = {
  128.    db.MakeInParam("@FromPositionID",SqlDbType.Int,4,FromPositionID),
  129.    db.MakeInParam("@ToPositionID",SqlDbType.Int,4,ToPositionID),
  130.    };
  131. return (db.RunProc("sp_MovePosition",prams));
  132. }
  133. #region 人员职位级别更新
  134. /// <summary>
  135. /// 人员职位级别更新
  136. /// </summary>
  137. /// <param name="PositionID">职位ID</param>
  138. /// <param name="NewCaste">新职级</param>
  139. /// <returns>返回是否成功</returns>
  140. public static int UpdateCaste(long PositionID,int NewCaste) 
  141. {
  142. UDS.Components.Database db = new UDS.Components.Database();
  143. SqlParameter[] prams = {
  144.    db.MakeInParam("@PositionID",SqlDbType.Int,4,PositionID),
  145.    db.MakeInParam("@NewCaste",SqlDbType.Int,4,NewCaste)
  146.    };
  147. return db.RunProc("sp_UpdatePositionCaste",prams);
  148. }
  149. #endregion
  150. #region 获得职位名称
  151. /// <summary>
  152. /// 获得职位名称
  153. /// </summary>
  154. /// <param name="PositionID">职位ID</param>
  155. /// <returns>职位名称</returns>
  156. public static string GetPositionName(long PositionID) 
  157. {
  158. string PositionName = "";
  159. Database db = new Database();
  160. SqlDataReader dr;
  161. SqlParameter[] prams = {
  162.    db.MakeInParam("@position_id",SqlDbType.Int,4,PositionID)
  163.    };
  164. db.RunProc("sp_GetPositionInfo",prams,out dr);
  165. if(dr.Read())
  166. {
  167. PositionName = dr["Position_Name"].ToString();
  168. }
  169. dr.Close();
  170. return PositionName;
  171. }
  172. #endregion
  173. }
  174. }