Aucune description

T_Sys_ModuleFunctions.cs 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data.SqlClient;
  6. using System.Data;
  7. using XYFDRQ.DBUtility;
  8. namespace XYFDRQ.DAL
  9. {
  10. /// <summary>
  11. /// 数据访问类:T_Sys_ModuleFunctions
  12. /// </summary>
  13. public partial class T_Sys_ModuleFunctions
  14. {
  15. public T_Sys_ModuleFunctions()
  16. { }
  17. #region Method
  18. /// <summary>
  19. /// 是否存在该记录
  20. /// </summary>
  21. public bool Exists(int F_FunctionId)
  22. {
  23. StringBuilder strSql = new StringBuilder();
  24. strSql.Append("select count(1) from T_Sys_ModuleFunctions");
  25. strSql.Append(" where F_FunctionId=@F_FunctionId");
  26. SqlParameter[] parameters = {
  27. new SqlParameter("@F_FunctionId", SqlDbType.Int,4)
  28. };
  29. parameters[0].Value = F_FunctionId;
  30. return DbHelperSQL.Exists(strSql.ToString(), parameters);
  31. }
  32. /// <summary>
  33. /// 增加一条数据
  34. /// </summary>
  35. public int Add(XYFDRQ.Model.T_Sys_ModuleFunctions model)
  36. {
  37. StringBuilder strSql = new StringBuilder();
  38. strSql.Append("insert into T_Sys_ModuleFunctions(");
  39. strSql.Append("F_FunctionCode,F_ParentId,F_ParentCode,F_Name,F_Sort,F_Layer,F_StateFlag,F_Type,F_OptUrl,F_Remark,F_SysFlag,F_ImgUrl,F_ModuleId,F_ModuleCode)");
  40. strSql.Append(" values (");
  41. strSql.Append("@F_FunctionCode,@F_ParentId,@F_ParentCode,@F_Name,@F_Sort,@F_Layer,@F_StateFlag,@F_Type,@F_OptUrl,@F_Remark,@F_SysFlag,@F_ImgUrl,@F_ModuleId,@F_ModuleCode)");
  42. strSql.Append(";select @@IDENTITY");
  43. SqlParameter[] parameters = {
  44. new SqlParameter("@F_FunctionCode", SqlDbType.NVarChar,50),
  45. new SqlParameter("@F_ParentId", SqlDbType.Int,4),
  46. new SqlParameter("@F_ParentCode", SqlDbType.NVarChar,50),
  47. new SqlParameter("@F_Name", SqlDbType.VarChar,50),
  48. new SqlParameter("@F_Sort", SqlDbType.Int,4),
  49. new SqlParameter("@F_Layer", SqlDbType.Int,4),
  50. new SqlParameter("@F_StateFlag", SqlDbType.Int,4),
  51. new SqlParameter("@F_Type", SqlDbType.Int,4),
  52. new SqlParameter("@F_OptUrl", SqlDbType.VarChar,200),
  53. new SqlParameter("@F_Remark", SqlDbType.VarChar,200),
  54. new SqlParameter("@F_SysFlag", SqlDbType.Bit,1),
  55. new SqlParameter("@F_ImgUrl", SqlDbType.VarChar,200),
  56. new SqlParameter("@F_ModuleId", SqlDbType.Int,4),
  57. new SqlParameter("@F_ModuleCode", SqlDbType.VarChar,50)};
  58. parameters[0].Value = model.F_FunctionCode;
  59. parameters[1].Value = model.F_ParentId;
  60. parameters[2].Value = model.F_ParentCode;
  61. parameters[3].Value = model.F_Name;
  62. parameters[4].Value = model.F_Sort;
  63. parameters[5].Value = model.F_Layer;
  64. parameters[6].Value = model.F_StateFlag;
  65. parameters[7].Value = model.F_Type;
  66. parameters[8].Value = model.F_OptUrl;
  67. parameters[9].Value = model.F_Remark;
  68. parameters[10].Value = model.F_SysFlag;
  69. parameters[11].Value = model.F_ImgUrl;
  70. parameters[12].Value = model.F_ModuleId;
  71. parameters[13].Value = model.F_ModuleCode;
  72. object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
  73. if (obj == null)
  74. {
  75. return 0;
  76. }
  77. else
  78. {
  79. return Convert.ToInt32(obj);
  80. }
  81. }
  82. /// <summary>
  83. /// 更新一条数据
  84. /// </summary>
  85. public bool Update(XYFDRQ.Model.T_Sys_ModuleFunctions model)
  86. {
  87. StringBuilder strSql = new StringBuilder();
  88. strSql.Append("update T_Sys_ModuleFunctions set ");
  89. strSql.Append("F_FunctionCode=@F_FunctionCode,");
  90. strSql.Append("F_ParentId=@F_ParentId,");
  91. strSql.Append("F_ParentCode=@F_ParentCode,");
  92. strSql.Append("F_Name=@F_Name,");
  93. strSql.Append("F_Sort=@F_Sort,");
  94. strSql.Append("F_Layer=@F_Layer,");
  95. strSql.Append("F_StateFlag=@F_StateFlag,");
  96. strSql.Append("F_Type=@F_Type,");
  97. strSql.Append("F_OptUrl=@F_OptUrl,");
  98. strSql.Append("F_Remark=@F_Remark,");
  99. strSql.Append("F_SysFlag=@F_SysFlag,");
  100. strSql.Append("F_ImgUrl=@F_ImgUrl,");
  101. strSql.Append("F_ModuleId=@F_ModuleId,");
  102. strSql.Append("F_ModuleCode=@F_ModuleCode");
  103. strSql.Append(" where F_FunctionId=@F_FunctionId");
  104. SqlParameter[] parameters = {
  105. new SqlParameter("@F_FunctionCode", SqlDbType.NVarChar,50),
  106. new SqlParameter("@F_ParentId", SqlDbType.Int,4),
  107. new SqlParameter("@F_ParentCode", SqlDbType.NVarChar,50),
  108. new SqlParameter("@F_Name", SqlDbType.VarChar,50),
  109. new SqlParameter("@F_Sort", SqlDbType.Int,4),
  110. new SqlParameter("@F_Layer", SqlDbType.Int,4),
  111. new SqlParameter("@F_StateFlag", SqlDbType.Int,4),
  112. new SqlParameter("@F_Type", SqlDbType.Int,4),
  113. new SqlParameter("@F_OptUrl", SqlDbType.VarChar,200),
  114. new SqlParameter("@F_Remark", SqlDbType.VarChar,200),
  115. new SqlParameter("@F_SysFlag", SqlDbType.Bit,1),
  116. new SqlParameter("@F_ImgUrl", SqlDbType.VarChar,200),
  117. new SqlParameter("@F_ModuleId", SqlDbType.Int,4),
  118. new SqlParameter("@F_ModuleCode", SqlDbType.VarChar,50),
  119. new SqlParameter("@F_FunctionId", SqlDbType.Int,4)};
  120. parameters[0].Value = model.F_FunctionCode;
  121. parameters[1].Value = model.F_ParentId;
  122. parameters[2].Value = model.F_ParentCode;
  123. parameters[3].Value = model.F_Name;
  124. parameters[4].Value = model.F_Sort;
  125. parameters[5].Value = model.F_Layer;
  126. parameters[6].Value = model.F_StateFlag;
  127. parameters[7].Value = model.F_Type;
  128. parameters[8].Value = model.F_OptUrl;
  129. parameters[9].Value = model.F_Remark;
  130. parameters[10].Value = model.F_SysFlag;
  131. parameters[11].Value = model.F_ImgUrl;
  132. parameters[12].Value = model.F_ModuleId;
  133. parameters[13].Value = model.F_ModuleCode;
  134. parameters[14].Value = model.F_FunctionId;
  135. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  136. if (rows > 0)
  137. {
  138. return true;
  139. }
  140. else
  141. {
  142. return false;
  143. }
  144. }
  145. /// <summary>
  146. /// 删除一条数据
  147. /// </summary>
  148. public bool Delete(int F_FunctionId)
  149. {
  150. StringBuilder strSql = new StringBuilder();
  151. strSql.Append("delete from T_Sys_ModuleFunctions ");
  152. strSql.Append(" where F_FunctionId=@F_FunctionId");
  153. SqlParameter[] parameters = {
  154. new SqlParameter("@F_FunctionId", SqlDbType.Int,4)
  155. };
  156. parameters[0].Value = F_FunctionId;
  157. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  158. if (rows > 0)
  159. {
  160. return true;
  161. }
  162. else
  163. {
  164. return false;
  165. }
  166. }
  167. /// <summary>
  168. /// 删除一条数据
  169. /// </summary>
  170. public bool DeleteList(string F_FunctionIdlist)
  171. {
  172. StringBuilder strSql = new StringBuilder();
  173. strSql.Append("delete from T_Sys_ModuleFunctions ");
  174. strSql.Append(" where F_FunctionId in (" + F_FunctionIdlist + ") ");
  175. int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
  176. if (rows > 0)
  177. {
  178. return true;
  179. }
  180. else
  181. {
  182. return false;
  183. }
  184. }
  185. /// <summary>
  186. /// 得到一个对象实体
  187. /// </summary>
  188. public XYFDRQ.Model.T_Sys_ModuleFunctions GetModel(int F_FunctionId)
  189. {
  190. StringBuilder strSql = new StringBuilder();
  191. strSql.Append("select top 1 * from T_Sys_ModuleFunctions ");
  192. strSql.Append(" where F_FunctionId=@F_FunctionId");
  193. SqlParameter[] parameters = {
  194. new SqlParameter("@F_FunctionId", SqlDbType.Int,4)
  195. };
  196. parameters[0].Value = F_FunctionId;
  197. XYFDRQ.Model.T_Sys_ModuleFunctions model = new XYFDRQ.Model.T_Sys_ModuleFunctions();
  198. DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
  199. if (ds.Tables[0].Rows.Count > 0)
  200. {
  201. if (ds.Tables[0].Rows[0]["F_FunctionId"] != null && ds.Tables[0].Rows[0]["F_FunctionId"].ToString() != "")
  202. {
  203. model.F_FunctionId = int.Parse(ds.Tables[0].Rows[0]["F_FunctionId"].ToString());
  204. }
  205. if (ds.Tables[0].Rows[0]["F_FunctionCode"] != null && ds.Tables[0].Rows[0]["F_FunctionCode"].ToString() != "")
  206. {
  207. model.F_FunctionCode = ds.Tables[0].Rows[0]["F_FunctionCode"].ToString();
  208. }
  209. if (ds.Tables[0].Rows[0]["F_ParentId"] != null && ds.Tables[0].Rows[0]["F_ParentId"].ToString() != "")
  210. {
  211. model.F_ParentId = int.Parse(ds.Tables[0].Rows[0]["F_ParentId"].ToString());
  212. }
  213. if (ds.Tables[0].Rows[0]["F_ParentCode"] != null && ds.Tables[0].Rows[0]["F_ParentCode"].ToString() != "")
  214. {
  215. model.F_ParentCode = ds.Tables[0].Rows[0]["F_ParentCode"].ToString();
  216. }
  217. if (ds.Tables[0].Rows[0]["F_Name"] != null && ds.Tables[0].Rows[0]["F_Name"].ToString() != "")
  218. {
  219. model.F_Name = ds.Tables[0].Rows[0]["F_Name"].ToString();
  220. }
  221. if (ds.Tables[0].Rows[0]["F_Sort"] != null && ds.Tables[0].Rows[0]["F_Sort"].ToString() != "")
  222. {
  223. model.F_Sort = int.Parse(ds.Tables[0].Rows[0]["F_Sort"].ToString());
  224. }
  225. if (ds.Tables[0].Rows[0]["F_Layer"] != null && ds.Tables[0].Rows[0]["F_Layer"].ToString() != "")
  226. {
  227. model.F_Layer = int.Parse(ds.Tables[0].Rows[0]["F_Layer"].ToString());
  228. }
  229. if (ds.Tables[0].Rows[0]["F_StateFlag"] != null && ds.Tables[0].Rows[0]["F_StateFlag"].ToString() != "")
  230. {
  231. model.F_StateFlag = int.Parse(ds.Tables[0].Rows[0]["F_StateFlag"].ToString());
  232. }
  233. if (ds.Tables[0].Rows[0]["F_Type"] != null && ds.Tables[0].Rows[0]["F_Type"].ToString() != "")
  234. {
  235. model.F_Type = int.Parse(ds.Tables[0].Rows[0]["F_Type"].ToString());
  236. }
  237. if (ds.Tables[0].Rows[0]["F_OptUrl"] != null && ds.Tables[0].Rows[0]["F_OptUrl"].ToString() != "")
  238. {
  239. model.F_OptUrl = ds.Tables[0].Rows[0]["F_OptUrl"].ToString();
  240. }
  241. if (ds.Tables[0].Rows[0]["F_Remark"] != null && ds.Tables[0].Rows[0]["F_Remark"].ToString() != "")
  242. {
  243. model.F_Remark = ds.Tables[0].Rows[0]["F_Remark"].ToString();
  244. }
  245. if (ds.Tables[0].Rows[0]["F_SysFlag"] != null && ds.Tables[0].Rows[0]["F_SysFlag"].ToString() != "")
  246. {
  247. if ((ds.Tables[0].Rows[0]["F_SysFlag"].ToString() == "1") || (ds.Tables[0].Rows[0]["F_SysFlag"].ToString().ToLower() == "true"))
  248. {
  249. model.F_SysFlag = true;
  250. }
  251. else
  252. {
  253. model.F_SysFlag = false;
  254. }
  255. }
  256. if (ds.Tables[0].Rows[0]["F_ImgUrl"] != null && ds.Tables[0].Rows[0]["F_ImgUrl"].ToString() != "")
  257. {
  258. model.F_ImgUrl = ds.Tables[0].Rows[0]["F_ImgUrl"].ToString();
  259. }
  260. if (ds.Tables[0].Rows[0]["F_ModuleId"] != null && ds.Tables[0].Rows[0]["F_ModuleId"].ToString() != "")
  261. {
  262. model.F_ModuleId = int.Parse(ds.Tables[0].Rows[0]["F_ModuleId"].ToString());
  263. }
  264. if (ds.Tables[0].Rows[0]["F_ModuleCode"] != null && ds.Tables[0].Rows[0]["F_ModuleCode"].ToString() != "")
  265. {
  266. model.F_ModuleCode = ds.Tables[0].Rows[0]["F_ModuleCode"].ToString();
  267. }
  268. return model;
  269. }
  270. else
  271. {
  272. return null;
  273. }
  274. }
  275. /// <summary>
  276. /// 获得数据列表
  277. /// </summary>
  278. public DataSet GetList(string strWhere)
  279. {
  280. StringBuilder strSql = new StringBuilder();
  281. strSql.Append("select * ");
  282. strSql.Append(" FROM T_Sys_ModuleFunctions ");
  283. if (strWhere.Trim() != "")
  284. {
  285. strSql.Append(" where " + strWhere);
  286. }
  287. return DbHelperSQL.Query(strSql.ToString());
  288. }
  289. /// <summary>
  290. /// 获得前几行数据
  291. /// </summary>
  292. public DataSet GetList(int Top, string strWhere, string filedOrder)
  293. {
  294. StringBuilder strSql = new StringBuilder();
  295. strSql.Append("select ");
  296. if (Top > 0)
  297. {
  298. strSql.Append(" top " + Top.ToString());
  299. }
  300. strSql.Append(" * ");
  301. strSql.Append(" FROM T_Sys_ModuleFunctions ");
  302. if (strWhere.Trim() != "")
  303. {
  304. strSql.Append(" where " + strWhere);
  305. }
  306. strSql.Append(" order by " + filedOrder);
  307. return DbHelperSQL.Query(strSql.ToString());
  308. }
  309. #endregion Method
  310. /// <summary>
  311. /// 根据ModeuleId更新moduleCode
  312. /// </summary>
  313. public bool UpdateModuleCodeByModuleId(int p_ModuleId, string p_ModuleCode)
  314. {
  315. StringBuilder strSql = new StringBuilder();
  316. strSql.Append("update T_Sys_ModuleFunctions set ");
  317. strSql.Append("F_ModuleCode=@F_ModuleCode");
  318. strSql.Append(" where F_ModuleId=@F_ModuleId");
  319. SqlParameter[] parameters = {
  320. new SqlParameter("@F_ModuleId", SqlDbType.Int,4),
  321. new SqlParameter("@F_ModuleCode", SqlDbType.VarChar,50)};
  322. parameters[0].Value = p_ModuleId;
  323. parameters[1].Value= p_ModuleCode;
  324. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  325. if (rows > 0)
  326. {
  327. return true;
  328. }
  329. else
  330. {
  331. return false;
  332. }
  333. }
  334. /// <summary>
  335. /// 根据ParentId更新ParentCode
  336. /// </summary>
  337. public bool UpdateParentCodeCodeByParentId(int p_FunctionId, string p_FunctionCode)
  338. {
  339. StringBuilder strSql = new StringBuilder();
  340. strSql.Append("update T_Sys_ModuleFunctions set ");
  341. strSql.Append("F_ParentCode=@F_ParentCode");
  342. strSql.Append(" where F_ParentId=@F_ParentId");
  343. SqlParameter[] parameters = {
  344. new SqlParameter("@F_ParentId",SqlDbType.Int,4),
  345. new SqlParameter("@F_ParentCode", SqlDbType.NVarChar,50)
  346. };
  347. parameters[0].Value = p_FunctionId;
  348. parameters[1].Value = p_FunctionCode;
  349. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  350. if (rows > 0)
  351. {
  352. return true;
  353. }
  354. else
  355. {
  356. return false;
  357. }
  358. }
  359. }
  360. }