XTZHDBService.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. using QWPlatform.IService;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using PMS.EntityModels.SysManager;
  7. using System.Data;
  8. using QWPlatform.SystemLibrary;
  9. using QWPlatform.SystemLibrary.LogManager;
  10. namespace PMS.DBService.SysManager
  11. {
  12. public class XTZHDBService : DataServiceBase
  13. {
  14. //实例化数据库
  15. public DataServiceBase dataservice = new DataServiceBase();
  16. public string XtZHEdit(XTZHModel xtzhModel, int editType)
  17. {
  18. var dt = this.ProcedureBuilder.Procedure("B_基础管理_系统账户.P_系统账户_Edit")
  19. .Paramter("id_in", xtzhModel.ID)
  20. .Paramter("编辑类型_in", editType)
  21. .Paramter("账户_in", xtzhModel.ZH)
  22. .Paramter("密码_in", QWPlatform.SystemLibrary.Utils.Strings.MD5(xtzhModel.MM))
  23. .Paramter("姓名_in", xtzhModel.XM)
  24. .Paramter("邮箱_in", xtzhModel.YX)
  25. .Paramter("状态_in", xtzhModel.QY)
  26. .Paramter("类型_in", xtzhModel.LX)
  27. .Paramter("公司_in", xtzhModel.GSID)
  28. .Paramter("人员ID_in", xtzhModel.RYID)
  29. .ParamterOut("Result_out", DbType.String, 400);
  30. dt.Execute();
  31. return dt.ParameterValue<string>("Result_out");
  32. }
  33. /// <summary>
  34. /// 人员信息的查询
  35. /// </summary>
  36. /// <param name="zh"></param>
  37. /// <returns></returns>
  38. public DataTable SelectPersonInfo(string zh)
  39. {
  40. return this.SelectBuilder.From("人员信息")
  41. .Columns("*")
  42. .Where("联系电话", zh)
  43. .Select();
  44. }
  45. /// <summary>
  46. /// 获取公司信息
  47. /// </summary>
  48. /// <returns></returns>
  49. public DataTable XtZHGs()
  50. {
  51. string sql = "select 'ID' as ID,'全部' as 公司ID from dual union select ID,名称 from 渠道信息";
  52. return this.SqlBuilder.SqlText(sql)
  53. .Select();
  54. }
  55. /// <summary>
  56. /// 根据id查找账户信息
  57. /// </summary>
  58. /// <param name="iD"></param>
  59. /// <returns></returns>
  60. public DataTable GetSystemUserInfo(int ID)
  61. {
  62. return this.SelectBuilder.From("系统账户")
  63. .Columns("*")
  64. .Where("ID", ID).Select();
  65. }
  66. /// <summary>
  67. /// 获取系统账户类型
  68. /// </summary>
  69. /// <returns></returns>
  70. public DataTable XtZHLx()
  71. {
  72. string sql = "select '' AS ID,'全部' AS 类型 From dual Union select '|' || 类型, replace(replace(类型, 1, '超级管理员'), 0, '普通用户') from 系统账户";
  73. var dt = this.SqlBuilder.SqlText(sql).Select();
  74. return dt;
  75. }
  76. /// <summary>
  77. /// 获取公司下的人员
  78. /// </summary>
  79. /// <param name="gSID"></param>
  80. /// <returns></returns>
  81. public DataTable XtZHRY(string gSID)
  82. {
  83. string sql = "select ID, 姓名 人员名称 from 人员信息 where 渠道ID =:渠道ID";
  84. var dt = this.SqlBuilder.SqlText(sql).Parameters("渠道ID", gSID).Select();
  85. return dt;
  86. }
  87. /// <summary>
  88. /// 系统账户重置密码
  89. /// </summary>
  90. /// <param name="id"></param>
  91. /// <param name="pwd"></param>
  92. public void XGMm(int id, string pwd)
  93. {
  94. this.UpdateBuilder.Update("系统账户")
  95. .Column("密码", QWPlatform.SystemLibrary.Utils.Strings.MD5(pwd))
  96. .Where("id", id)
  97. .Execute();
  98. }
  99. /// <summary>
  100. /// 删除系统账户
  101. /// </summary>
  102. /// <param name="id">id</param>
  103. public void XtZHDel(int id)
  104. {
  105. using (var tran = this.DBTransaction.BeginTrans())
  106. {
  107. try
  108. {
  109. this.DeleteBulider.Delete("系统账户权限").Where("账户ID", id).Execute(tran);
  110. this.DeleteBulider.Delete("系统角色关系").Where("账户ID", id).Execute(tran);
  111. this.DeleteBulider.Delete("系统账户").Where("ID", id).Execute(tran);
  112. tran.CommitTrans();
  113. }
  114. catch (Exception ex)
  115. {
  116. tran.Rollback();
  117. Logger.Instance.Error("删除账户失败,原因:" + ex);
  118. }
  119. }
  120. }
  121. /// <summary>
  122. /// 更新用户访问渠道项目权限
  123. /// </summary>
  124. /// <param name="id"></param>
  125. /// <param name="authorize">1是,0否</param>
  126. public bool UpdataAuthorize(int id,int authorize)
  127. {
  128. var state = false;
  129. try
  130. {
  131. state =this.UpdateBuilder.Update("系统账户").Where("id", id).Column("渠道所有项目", authorize).Execute() > 0;
  132. }
  133. catch (Exception ex)
  134. {
  135. Logger.Instance.Error("更新账户访问渠道下所有项目失败,原因:" + ex);
  136. }
  137. return state;
  138. }
  139. public string XtZHSelect(string search, int start_number, int end_number)
  140. {
  141. var dt = this.ProcedureBuilder
  142. .Procedure("B_基础管理_系统账户.p_系统账户_Select")
  143. .Paramter("查询条件_In", search)
  144. .Paramter("开始行_In", start_number)
  145. .Paramter("结束行_In", end_number)
  146. .ParamterOut("总行数_Out", DbType.Double, 5)
  147. .ParamterOut("Resultlist", true);
  148. dt.Execute();
  149. var dts = dt.ParameterValue<DataTable>("Resultlist");
  150. var total = dt.ParameterValue<decimal>("总行数_Out");
  151. return dts.ToEasyUIGridJson(Convert.ToInt32(total));
  152. }
  153. /// <summary>
  154. /// 查询系统账户得名称
  155. /// </summary>
  156. /// <param name="XM"></param>
  157. /// <returns></returns>
  158. public string UserNameCheck(string XM)
  159. {
  160. // Procedure p_系统账户姓名_Select
  161. //(
  162. //姓名_In In 系统账户.姓名 % type,
  163. //Result_Out Out varchar2
  164. // )
  165. var dt = this.ProcedureBuilder
  166. .Procedure("B_基础管理_系统账户.p_系统账户姓名_Select")
  167. .Paramter("姓名_In", XM)
  168. .ParamterOut("Result_Out", DbType.String, 400);
  169. dt.Execute();
  170. return dt.ParameterValue<string>("Result_Out");
  171. }
  172. }
  173. }