DailyFeePaymentService.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Models;
  6. using System.Data.SqlClient;
  7. using System.Data;
  8. namespace DAL
  9. {
  10. /// <summary>
  11. /// 日常费用付款申请数据访问类
  12. /// </summary>
  13. public class DailyFeePaymentService
  14. {
  15. /// <summary>
  16. /// 查询所有
  17. /// </summary>
  18. /// <param name="sql">sql语句</param>
  19. /// <param name="param">可变参数数组</param>
  20. /// <returns>返回集合</returns>
  21. List<DailyFeePayment> excuteSql(string sql, params SqlParameter[] param)
  22. {
  23. return ServiceBase<DailyFeePayment>.excuteSql(new DailyFeePayment(), "DailyFeePayment", sql, CommandType.Text, param);
  24. }
  25. /// <summary>
  26. /// 查询所有Desc
  27. /// </summary>
  28. /// <param name="sql">sql语句</param>
  29. /// <param name="param">可变参数数组</param>
  30. /// <returns>返回集合</returns>
  31. List<DailyFeePaymentDesc> excuteSqlDesc(string sql, params SqlParameter[] param)
  32. {
  33. return ServiceBase<DailyFeePaymentDesc>.excuteSql(new DailyFeePaymentDesc(), "DailyFeePaymentDesc", sql, CommandType.Text, param);
  34. }
  35. /// <summary>
  36. /// 查询所有Count
  37. /// </summary>
  38. /// <param name="sql">sql语句</param>
  39. /// <param name="param">可变参数数组</param>
  40. /// <returns>返回集合</returns>
  41. List<CountData> excuteSqlCount(string sql, params SqlParameter[] param)
  42. {
  43. return ServiceBase<CountData>.excuteSql(new CountData(), "CountData", sql, CommandType.Text, param);
  44. }
  45. /// <summary>
  46. /// 获取单个对象
  47. /// </summary>
  48. /// <param name="sql">sql语句</param>
  49. /// <param name="param">可变参数数组</param>
  50. /// <returns>返回空或者单个对象</returns>
  51. DailyFeePayment excuteType(string sql, params SqlParameter[] param)
  52. {
  53. //查询结果放入对象集合
  54. List<DailyFeePayment> cdList = excuteSql(sql, param);
  55. //判断集合是否为空
  56. if (cdList == null || cdList.Count == 0)
  57. //返回null
  58. return null;
  59. //返回单个对象
  60. return cdList[0];
  61. }
  62. /// <summary>
  63. /// 根据编号查询对象信息
  64. /// </summary>
  65. /// <param name="id">对象编号</param>
  66. /// <returns>返回空或者单个对象信息</returns>
  67. public DailyFeePayment GetDailyFeePaymentByID(int id)
  68. {
  69. //调用获取单个对象的方法
  70. return excuteType("select * from DailyFeePayment where Id = @id and IsDel = 0", new SqlParameter("@id", id));
  71. }
  72. /// <summary>
  73. /// 获取全部 - 分页
  74. /// </summary>
  75. /// <returns></returns>
  76. public List<DailyFeePayment> GetDailyFeePayment(int pageIndex, out int sumPage, out int totalRecord, int audit, int auditGM, int auditRM, string instructions, string UniversiadePriceType, int operators, string idCard)
  77. {
  78. string sqlwhere = "IsDel = 0 and Instructions like '%" + instructions + "%'";
  79. if (operators != 0)
  80. {
  81. sqlwhere += " and Operator = " + operators;
  82. }
  83. if (idCard == "2")
  84. sqlwhere += " and FAudit = 1 and MAudit = " + auditGM;
  85. if (idCard == "3" || idCard == "")
  86. sqlwhere += " and FAudit = " + audit + " and MAudit = " + auditGM;
  87. if (idCard == "4")
  88. sqlwhere += " and (PriceType=288 or PriceType = 301 or operator=" + operators + ") and RAudit=" + auditRM;
  89. if ((idCard == "2" || idCard == "3") && UniversiadePriceType == "741")
  90. sqlwhere = sqlwhere + "and PriceType IN (select Id from setdata where STID = 55)";
  91. else if ((idCard == "2" || idCard == "3") && UniversiadePriceType != "--未选择--" && !string.IsNullOrEmpty(UniversiadePriceType.ToString()))
  92. sqlwhere = sqlwhere + "and PriceType IN (" + Convert.ToInt32(UniversiadePriceType) + ")";
  93. return PageBase<DailyFeePayment>.excutePageSql(new DailyFeePayment(), "DailyFeePayment", "DailyFeePayment", "*", "OperatorDate desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  94. }
  95. /// <summary>
  96. /// 获取全部 - 分页
  97. /// </summary>
  98. /// <returns></returns>
  99. public List<DailyFeePaymentDesc> GetDailyFeePaymentDesc(int pageIndex, out int sumPage, out int totalRecord, int audit, int auditGM, int auditRM, string instructions, string UniversiadePriceType, int operators, string idCard)
  100. {
  101. string sqlwhere = "where IsDel = 0 and Instructions like '%" + instructions + "%'";
  102. if (operators != 0)
  103. {
  104. sqlwhere += " and Operator = " + operators;
  105. }
  106. if (idCard == "2")
  107. sqlwhere += " and FAudit = 1 and MAudit = " + auditGM;
  108. if (idCard == "3" || idCard == "")
  109. sqlwhere += " and FAudit = " + audit + " and MAudit = " + auditGM;
  110. if (idCard == "4")
  111. sqlwhere += " and (PriceType=288 or PriceType = 301 or operator=" + operators + ") and RAudit=" + auditRM;
  112. if ((idCard == "2" || idCard == "3") && UniversiadePriceType == "741")
  113. sqlwhere = sqlwhere + "and PriceType IN (select Id from setdata where STID = 55)";
  114. else if ((idCard == "2" || idCard == "3") && UniversiadePriceType != "--未选择--" && !string.IsNullOrEmpty(UniversiadePriceType.ToString()))
  115. sqlwhere = sqlwhere + "and PriceType IN (" + Convert.ToInt32(UniversiadePriceType) + ")";
  116. int startIndex = (pageIndex - 1) * 10 + 1;
  117. int endIndex = startIndex + 10 - 1;
  118. string sql = string.Format(@"Select * From (Select row_number() over (order by OperatorDate desc) as RowNumber,* From DailyFeePayment {0})
  119. temp Where RowNumber Between {1} and {2}", sqlwhere, startIndex, endIndex);
  120. string CountSql = string.Format(@"Select COUNT(1) as Count From (Select * From DailyFeePayment {0}) temp", sqlwhere);
  121. List<CountData> CountList= excuteSqlCount(CountSql);
  122. float totalPage = (float)CountList[0].Count / 10;//总页数
  123. if (totalPage == 0) totalPage = 1;
  124. else totalPage = (int)Math.Ceiling((double)totalPage);
  125. sumPage = Convert.ToInt32(totalPage);
  126. totalRecord = CountList[0].Count;
  127. return excuteSqlDesc(sql);
  128. }
  129. /// <summary>
  130. /// 获取全部 - 不分页
  131. /// </summary>
  132. /// <returns></returns>
  133. public List<DailyFeePayment> GetDailyFeePaymentNoPage(int pageIndex, int sumPage, int totalRecord, int audit, int auditGM, int auditRM, string instructions, int operators, string idCard)
  134. {
  135. string sqlwhere = "select * from DailyFeePayment where IsDel = 0 and Instructions like '%" + instructions + "%'";
  136. if (operators != 0 && operators != 41 && operators != 82)
  137. sqlwhere += " and Operator = " + operators;
  138. if (idCard == "2")
  139. sqlwhere += " and FAudit = 1 and MAudit = " + auditGM;
  140. else
  141. sqlwhere += " and FAudit = " + audit + " and MAudit = " + auditGM;
  142. if (idCard == "4")
  143. sqlwhere += " and (PriceType=288 or PriceType = 301 or operator=" + operators + ") and RAudit=" + auditRM;
  144. return excuteSql(sqlwhere);
  145. //return PageBase<DailyFeePayment>.excutePageSql(new DailyFeePayment(), "DailyFeePayment", "DailyFeePayment", "*", "OperatorDate desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  146. }
  147. /// <summary>
  148. /// 获取全部 - 分页
  149. /// </summary>
  150. /// <returns></returns>
  151. public List<DailyFeePayment> GetDailyFeePayment(int pageIndex, out int sumPage, out int totalRecord, int audit, int auditGM, string instructions, int operators, string idCard, string w)
  152. {
  153. string sqlwhere = "IsDel = 0 and Instructions like '%" + instructions + "%'";
  154. if (operators != 0)
  155. sqlwhere += " and Operator = " + operators;
  156. if (idCard == "2")
  157. sqlwhere += " and FAudit = 1 and MAudit = " + auditGM;
  158. else
  159. sqlwhere += " and FAudit = " + audit + " and MAudit = " + auditGM;
  160. sqlwhere += w;
  161. return PageBase<DailyFeePayment>.excutePageSql(new DailyFeePayment(), "DailyFeePayment", "DailyFeePayment", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  162. }
  163. /// <summary>
  164. /// 获取全部
  165. /// </summary>
  166. /// <returns></returns>
  167. public List<DailyFeePayment> GetAllDailyFeePayment(int FAudit, int MAudit, string instructions, int LoginUserId, string SelectUserId)
  168. {
  169. string sqlwhere = "select * from DailyFeePayment where IsDel = 0 and FAudit = " + FAudit + " and MAudit = " + MAudit;
  170. if (!string.IsNullOrEmpty(instructions))
  171. {
  172. sqlwhere += " and Instructions like '%" + instructions + "%' ";
  173. }
  174. if (LoginUserId == 21 || LoginUserId == 22)
  175. {
  176. if (SelectUserId != "-1")
  177. {
  178. sqlwhere += " and Operator = " + LoginUserId;
  179. }
  180. }
  181. else
  182. {
  183. sqlwhere += " and Operator = " + LoginUserId;
  184. }
  185. return excuteSql(sqlwhere);
  186. }
  187. public List<DailyFeePayment> GetAll(string OperType)
  188. {
  189. string sql = "select * from DailyFeePayment where IsDel = 0 and Operators > 0 and Operators is not null ";
  190. if (OperType == "finance")
  191. {
  192. sql += " and FAudit = 0 and MAudit = 0 ";
  193. }
  194. else if (OperType == "GM")
  195. {
  196. sql += " and FAudit = 1 and MAudit = 0 ";
  197. }
  198. return excuteSql(sql);
  199. }
  200. public List<DailyFeePayment> GetAll(int page,int size,out int total,string OperType,string QueryName,string PriceRemake)
  201. {
  202. string sqlWhere = string.Empty;
  203. if (!string.IsNullOrWhiteSpace(QueryName))
  204. {
  205. UsersService usersService = new UsersService();
  206. var queryUserId = usersService.GetAll().FindAll(x => x.CnName.Contains(QueryName)).Select(x => x.Id);
  207. if (queryUserId.Count() > 0)
  208. {
  209. sqlWhere += $" and Operator in ({string.Join(",", queryUserId).TrimEnd(',')}) ";
  210. }
  211. else
  212. {
  213. sqlWhere += $" and Operator in (0) ";
  214. }
  215. }
  216. if (!string.IsNullOrWhiteSpace(PriceRemake))
  217. {
  218. sqlWhere += $" and Instructions like '%{PriceRemake}%' ";
  219. }
  220. string sql = $@" select top {size} * from DailyFeePayment where isdel = 0 and Operator > 0 and Operator is not null " + sqlWhere;
  221. total = 0;
  222. if (OperType == "finance")
  223. {
  224. sql += $@" and FAudit = 0 and MAudit = 0 and Id not in (
  225. select top {(page - 1) * size} Id from DailyFeePayment where isdel = 0 and Operator > 0 and Operator is not null
  226. and FAudit = 0 and MAudit = 0 {sqlWhere}
  227. order by id desc
  228. )";
  229. total = (int)SqlHelper.ExecuteScalar($@"select count(*) from DailyFeePayment where isdel = 0 and Operator > 0
  230. and Operator is not null and FAudit = 0 and MAudit = 0 " + sqlWhere, CommandType.Text);
  231. }
  232. else if (OperType == "GM")
  233. {
  234. sql += $@" and FAudit = 1 and MAudit = 0 and Id not in (
  235. select top {(page - 1) * size} Id from DailyFeePayment where isdel = 0 and Operator > 0 and Operator is not null
  236. and FAudit = 1 and MAudit = 0 {sqlWhere}
  237. order by id desc
  238. )";
  239. total = (int)SqlHelper.ExecuteScalar($@"select count(*) from DailyFeePayment where isdel = 0 and Operator > 0
  240. and Operator is not null and FAudit = 1 and MAudit = 0 " + sqlWhere, CommandType.Text);
  241. }
  242. sql += "order by id desc ";
  243. return excuteSql(sql);
  244. }
  245. /// <summary>
  246. /// 增加
  247. /// </summary>
  248. /// <param name="dfp"></param>
  249. /// <returns></returns>
  250. public bool AddDailyFeePayment(DailyFeePayment dfp, out int id)
  251. {
  252. string sql = "insert into DailyFeePayment values(@Instructions,@SumPrice,@Operator,@OperatorDate,@FAudit,@FAuditDate,@MAudit,@MAuditDate,@Reason,@IsDel,@IsPay,@OrbitalPrivateTransfer,@PriceType,@CId,@CName,@RAudit,@RAuditDate,@AuditOperator);SELECT @@IDENTITY";
  253. SqlParameter[] parameter = new SqlParameter[]{
  254. new SqlParameter("@Instructions",dfp.Instructions),
  255. new SqlParameter("@SumPrice",dfp.SumPrice),
  256. new SqlParameter("@Operator",dfp.Operators),
  257. new SqlParameter("@OperatorDate",dfp.OperatorsDate),
  258. new SqlParameter("@FAudit",dfp.FAudit),
  259. new SqlParameter("@FAuditDate",dfp.FAuditDate),
  260. new SqlParameter("@MAudit",dfp.MAudit),
  261. new SqlParameter("@MAuditDate",dfp.MAuditDate),
  262. new SqlParameter("@Reason",dfp.Reason),
  263. new SqlParameter("@IsDel",dfp.IsDel),
  264. new SqlParameter("@IsPay",dfp.IsPay),
  265. new SqlParameter("@OrbitalPrivateTransfer",dfp.OrbitalPrivateTransfer),
  266. new SqlParameter("@PriceType",dfp.PriceType),
  267. new SqlParameter("@CId",dfp.CId),
  268. new SqlParameter("@CName",dfp.CName),
  269. new SqlParameter("@RAudit",dfp.RAudit),
  270. new SqlParameter("@RAuditDate",dfp.RAuditDate),
  271. new SqlParameter("@AuditOperator",dfp.AuditOperator)
  272. };
  273. int obj = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
  274. if (obj > 0)
  275. {
  276. id = obj;
  277. return true;
  278. }
  279. id = 0;
  280. return false;
  281. }
  282. /// <summary>
  283. /// 编辑
  284. /// </summary>
  285. /// <param name="sdt"></param>
  286. /// <returns></returns>
  287. public bool EditDailyFeePayment(DailyFeePayment dfp)
  288. {
  289. string sql = "update DailyFeePayment set Instructions = @Instructions,SumPrice = @SumPrice,OrbitalPrivateTransfer = @OrbitalPrivateTransfer,PriceType = @PriceType,Operator = @Operator,OperatorDate = @OperatorDate where Id = @Id";
  290. SqlParameter[] parameter = new SqlParameter[] {
  291. new SqlParameter("@Instructions",dfp.Instructions),
  292. new SqlParameter("@SumPrice",dfp.SumPrice),
  293. new SqlParameter("@OrbitalPrivateTransfer",dfp.OrbitalPrivateTransfer),
  294. new SqlParameter("@PriceType",dfp.PriceType),
  295. new SqlParameter("@Operator",dfp.Operators),
  296. new SqlParameter("@OperatorDate",dfp.OperatorsDate),
  297. new SqlParameter("@Id",dfp.Id)
  298. };
  299. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  300. return true;
  301. return false;
  302. }
  303. /// <summary>
  304. /// 编辑
  305. /// </summary>
  306. /// <param name="sdt"></param>
  307. /// <returns></returns>
  308. public bool EditDailyFeePaymentSumPrice(float sumPrice, int id)
  309. {
  310. string sql = "update DailyFeePayment set SumPrice = @SumPrice where Id = @Id";
  311. SqlParameter[] parameter = new SqlParameter[] {
  312. new SqlParameter("@SumPrice",sumPrice),
  313. new SqlParameter("@Id",id)
  314. };
  315. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  316. return true;
  317. return false;
  318. }
  319. /// <summary>
  320. /// 删除
  321. /// </summary>
  322. /// <param name="id"></param>
  323. /// <returns></returns>
  324. public bool DelDailyFeePayment(int id)
  325. {
  326. if (SqlHelper.ExecuteNonQuery("update DailyFeePayment set IsDel = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  327. return true;
  328. return false;
  329. }
  330. /// <summary>
  331. /// 删除
  332. /// </summary>
  333. /// <param name="id"></param>
  334. /// <returns></returns>
  335. public bool DelDailyFeePaymentById(int id)
  336. {
  337. if (SqlHelper.ExecuteNonQuery("delete DailyFeePayment where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  338. return true;
  339. return false;
  340. }
  341. /// <summary>
  342. /// 财务审核
  343. /// </summary>
  344. /// <param name="id"></param>
  345. /// <returns></returns>
  346. public bool UpdateDailyFeePaymentByFAudit(int FAudit, string FAuditDate, string Reason, int id)
  347. {
  348. string sql = "update DailyFeePayment set FAudit = @FAudit,FAuditDate=@FAuditDate,Reason = @Reason where Id = @Id";
  349. SqlParameter[] parameter = new SqlParameter[] {
  350. new SqlParameter("@FAudit",FAudit),
  351. new SqlParameter("@FAuditDate",FAuditDate),
  352. new SqlParameter("@Reason",Reason),
  353. new SqlParameter("@Id",id)
  354. };
  355. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  356. return true;
  357. return false;
  358. }
  359. /// <summary>
  360. /// 人事审核
  361. /// </summary>
  362. /// <param name="id"></param>
  363. /// <returns></returns>
  364. public bool UpdateDailyFeePaymentByRAudit(int FAudit, int MAudit, int RAudit, string Date, string Reason, int id)
  365. {
  366. string sql = "update DailyFeePayment set FAudit = @FAudit,FAuditDate=@FAuditDate,MAudit = @MAudit,MAuditDate=@MAuditDate,RAudit = @RAudit,RAuditDate=@RAuditDate,Reason = @Reason where Id = @Id";
  367. SqlParameter[] parameter = new SqlParameter[] {
  368. new SqlParameter("@FAudit",FAudit),
  369. new SqlParameter("@FAuditDate",Date),
  370. new SqlParameter("@MAudit",MAudit),
  371. new SqlParameter("@MAuditDate",Date),
  372. new SqlParameter("@RAudit",RAudit),
  373. new SqlParameter("@RAuditDate",Date),
  374. new SqlParameter("@Reason",Reason),
  375. new SqlParameter("@Id",id)
  376. };
  377. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  378. return true;
  379. return false;
  380. }
  381. /// <summary>
  382. /// 总经理审核
  383. /// </summary>
  384. /// <param name="id"></param>
  385. /// <returns></returns>
  386. public bool UpdateDailyFeePaymentByMAudit(int FAudit, int MAudit, string MAuditDate, string Reason, int id, int AuditOperator)
  387. {
  388. string sql = "update DailyFeePayment set FAudit = @FAudit,MAudit = @MAudit,MAuditDate=@MAuditDate,Reason = @Reason,AuditOperator=@AuditOperator where Id = @Id";
  389. SqlParameter[] parameter = new SqlParameter[] {
  390. new SqlParameter("@FAudit",FAudit),
  391. new SqlParameter("@MAudit",MAudit),
  392. new SqlParameter("@MAuditDate",MAuditDate),
  393. new SqlParameter("@Reason",Reason),
  394. new SqlParameter("@AuditOperator",AuditOperator),
  395. new SqlParameter("@Id",id)
  396. };
  397. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  398. return true;
  399. return false;
  400. }
  401. /// <summary>
  402. /// 付款确认
  403. /// </summary>
  404. /// <param name="id"></param>
  405. /// <returns></returns>
  406. public bool UpdateDailyFeePaymentByPay(int id)
  407. {
  408. if (SqlHelper.ExecuteNonQuery("update DailyFeePayment set IsPay = 1 where Id = " + id + "", CommandType.Text) > 0)
  409. return true;
  410. return false;
  411. }
  412. /// <summary>
  413. /// 获取全部未付款数据 - 分页
  414. /// MAudit=1
  415. /// </summary>
  416. /// <returns></returns>
  417. public List<DailyFeePayment> GetDailyFeePaymentByIsPay(int pageIndex, out int sumPage, out int totalRecord, int isPay, string instructions)
  418. {
  419. string sqlwhere = "IsDel = 0 and IsPay =" + isPay + " and MAudit = 1 and Instructions like '%" + instructions + "%'";
  420. return PageBase<DailyFeePayment>.excutePageSql(new DailyFeePayment(), "DailyFeePayment", "DailyFeePayment", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  421. }
  422. /// <summary>
  423. /// 获取全部未付款数据 - 分页
  424. /// MAudit=0
  425. /// </summary>
  426. /// <returns></returns>
  427. public List<DailyFeePayment> GetDailyFeePaymentMaByIsPay(int pageIndex, out int sumPage, out int totalRecord, int isPay, string priceType, string startTime, string endTime)
  428. {
  429. string sqlwhere = "IsDel = 0 and IsPay =" + isPay + " and PriceType = " + priceType;
  430. if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime))
  431. sqlwhere += " OperatorDate between '" + startTime + "' and '" + endTime + "'";
  432. return PageBase<DailyFeePayment>.excutePageSql(new DailyFeePayment(), "DailyFeePayment", "DailyFeePayment", "*", " OperatorDate asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  433. }
  434. /// <summary>
  435. /// 报表
  436. /// </summary>
  437. /// <param name="startTime"></param>
  438. /// <param name="endTime"></param>
  439. /// <returns></returns>
  440. public List<DailyFeePayment> GetStatements(string startTime, string endTime)
  441. {
  442. return excuteSql("select * from DailyFeePayment where (MAuditDate >= '" + startTime + "' and MAuditDate <= '" + endTime + "') and IsPay = 1 and IsDel = 0 and PriceType not in( 686 ,687 , 688 , 689)");
  443. }
  444. public List<DailyFeePayment> GetById(string idlist)
  445. {
  446. return excuteSql("select * from DailyFeePayment where IsDel = 0 and Id in (" + idlist + ")");
  447. }
  448. public List<DailyFeePayment> GetByPaymentApplicationReport(string startTime, string endTime)
  449. {
  450. return excuteSql("select * from DailyFeePayment where IsDel = 0 and IsPay = 0 and MAudit = 1 and (MAuditDate between '" + startTime + "' and '" + endTime + "') and PriceType <> 306"); //and PriceType <> 307
  451. //return excuteSql("select * from DailyFeePayment where IsDel = 0 and IsPay = 0 and (MAuditDate between '" + startTime + "' and '" + endTime + "')");
  452. }
  453. public double GetSum(string startTime, string endTime, int CId)
  454. {
  455. try
  456. {
  457. return (double)SqlHelper.ExecuteScalar("select sum(itemSumprice) from dailyFeePaymentContent dfpc join dailyFeePayment dfp on dfp.id = dfpc.DFPID where dfp.isdel = 0 and dfp.maudit = 1 and (dfp.operatordate between '" + startTime + "' and '" + endTime + "') and dfp.CId=" + CId, CommandType.Text);
  458. }
  459. catch
  460. {
  461. return 0;
  462. }
  463. }
  464. /// <summary>
  465. /// 日常费用 不含 信用卡还款(686) 张总私人费用(687) 代报销社保生育补贴(688) 团组签证保险(689)
  466. /// </summary>
  467. /// <param name="startTime"></param>
  468. /// <param name="endTime"></param>
  469. /// <param name="CId"></param>
  470. /// <returns></returns>
  471. public double GetSum1(string startTime, string endTime, int CId)
  472. {
  473. try
  474. {
  475. return (double)SqlHelper.ExecuteScalar("select sum(SumPrice) from dailyFeePayment where isdel = 0 and IsPay = 1 and(MAuditDate between '" + startTime + "' and '" + endTime + "') and Cid = " + CId + " and PriceType not in(686, 687, 688, 689)", CommandType.Text);
  476. }
  477. catch
  478. {
  479. return 0;
  480. }
  481. }
  482. /// <summary>
  483. /// 日常费用
  484. /// </summary>
  485. /// <param name="startTime">开始时间</param>
  486. /// <param name="endTime">结束时间</param>
  487. /// <param name="CId">公司编号id</param>
  488. /// <returns></returns>
  489. public double GetCorrosion(string startTime, string endTime, string[] CIds)
  490. {
  491. try
  492. {
  493. string strIds = "";
  494. for (int i = 0; i < CIds.Length; i++)
  495. {
  496. if (i == CIds.Length - 1)
  497. strIds += i;
  498. else
  499. strIds += i + ",";
  500. }
  501. return (double)SqlHelper.ExecuteScalar("select sum(itemSumprice) from dailyFeePaymentContent dfpc join dailyFeePayment dfp on dfp.id = dfpc.DFPID where dfp.isdel = 0 and dfp.maudit = 1 and (dfp.operatordate between '" + startTime + "' and '" + endTime + "') and dfp.CId in (" + strIds + ") ", CommandType.Text);
  502. }
  503. catch { return 0; }
  504. }
  505. /// <summary>
  506. /// 日常费用
  507. /// </summary>
  508. /// <param name="startTime">开始时间</param>
  509. /// <param name="endTime">结束时间</param>
  510. /// <param name="PriceId">费用发类型id</param>
  511. /// <param name="CId">公司编号id</param>
  512. /// <returns></returns>
  513. public double GetCorrosion(string startTime, string endTime, int PriceId, string[] CIds)
  514. {
  515. try
  516. {
  517. string strIds = "";
  518. for (int i = 0; i < CIds.Length; i++)
  519. {
  520. if (i == CIds.Length - 1)
  521. strIds += i;
  522. else
  523. strIds += i + ",";
  524. }
  525. return (double)SqlHelper.ExecuteScalar("select sum(itemSumprice) from dailyFeePaymentContent dfpc join dailyFeePayment dfp on dfp.id = dfpc.DFPID where dfp.isdel = 0 and dfp.maudit = 1 and (dfp.operatordate between '" + startTime + "' and '" + endTime + "') and dfp.CId IN (" + strIds + ") and dfp.PriceType =" + PriceId, CommandType.Text);
  526. }
  527. catch { return 0; }
  528. }
  529. /// <summary>
  530. /// 日常费用(setdata 人员费用,办公费用 )
  531. /// </summary>
  532. /// <param name="startTime"></param>
  533. /// <param name="endTime"></param>
  534. /// <param name="CIds"></param>
  535. /// <returns></returns>
  536. public decimal GetNewOverhead(string startTime, string endTime, string[] CIds)
  537. {
  538. string cidsStr = string.Empty;
  539. foreach (var item in CIds)
  540. {
  541. cidsStr += item + ",";
  542. }
  543. cidsStr = cidsStr.TrimEnd(',');
  544. string sql = $@" select sum(itemSumprice) from dailyFeePaymentContent
  545. dfpc join dailyFeePayment dfp on dfp.id = dfpc.DFPID
  546. where dfp.isdel = 0 and dfp.maudit = 1 and dfp.CId in ({cidsStr})
  547. and (dfp.operatordate between '{startTime}' and '{endTime}') and dfp.PriceType in(
  548. select Id from SetData where IsDel = 0 And STid = 49 or STid = 48 and Name <> '其他款项'
  549. ) ";
  550. return Convert.ToDecimal((SqlHelper.ExecuteScalar(sql, CommandType.Text).ToString()));
  551. }
  552. /// <summary>
  553. /// 日常费用详细数据
  554. /// </summary>
  555. /// <param name="startTime">开始时间</param>
  556. /// <param name="endTime">结束时间</param>
  557. /// <param name="PriceId">费用发类型id</param>
  558. /// <param name="CId">公司编号id</param>
  559. /// <returns></returns>
  560. public List<DailyFeePayment> GetCostData(string startTime, string endTime, int PriceId, string[] CIds)
  561. {
  562. string strIds = "";
  563. for (int i = 0; i < CIds.Length; i++)
  564. {
  565. if (i == CIds.Length - 1)
  566. strIds += i;
  567. else
  568. strIds += i + ",";
  569. }
  570. return excuteSql("select * from DailyFeePayment where IsDel = 0 and IsPay = 1 and MAudit = 1 and (MAuditDate between '" + startTime + "' and '" + endTime + "') and PriceType = " + PriceId + " and CId IN (" + strIds + ")"); //and PriceType <> 307
  571. //return excuteSql("select * from DailyFeePayment where IsDel = 0 and IsPay = 0 and (MAuditDate between '" + startTime + "' and '" + endTime + "')");
  572. }
  573. /// <summary>
  574. /// 20220323 1107 贾文滔
  575. /// 大运会专属查询函数
  576. /// </summary>
  577. /// <returns></returns>
  578. public List<DailyFeePayment> GetForUniversiade(string PriceType)
  579. {
  580. string sql = "select * from DailyFeePayment d where d.IsDel=0 ";
  581. if (PriceType == "741")
  582. sql = sql + "and d.PriceType IN (select Id from setdata where STID = 55) order by PriceType";
  583. else
  584. sql = sql + "and d.PriceType IN (" + PriceType + ") order by PriceType";
  585. return excuteSql(sql);
  586. }
  587. }
  588. }