AnalyzedScenerys.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace LYFZ.Software.MainBusiness.DecisionAssistant
  6. {
  7. class AnalyzedScenerys: LYFZ.Software.UI.DecisionAssistant.AnalyzedScenerys
  8. {
  9. #region 变量
  10. public string strSelectYear = "";
  11. #endregion
  12. #region 系统函数;
  13. public AnalyzedScenerys()
  14. {
  15. // 查询函数;
  16. this.btnQuery.Click += BtnQuery_Click;
  17. // 加载窗口;
  18. this.Load += AnalyzedScenerys_Load;
  19. // 显示窗口;
  20. this.Shown += AnalyzedScenerys_Shown;
  21. }
  22. private void AnalyzedScenerys_Shown(object sender, EventArgs e)
  23. {
  24. //throw new NotImplementedException();
  25. }
  26. private void AnalyzedScenerys_Load(object sender, EventArgs e)
  27. {
  28. this.dt_end.Value = DateTime.Now;
  29. this.dt_start.Value = DateTime.Now.AddMonths(-1);
  30. }
  31. private void BtnQuery_Click(object sender, EventArgs e)
  32. {
  33. System.Data.DataSet dt = GetScenerysData(this.dt_start.Value, this.dt_end.Value);
  34. if ( dt != null && dt.Tables.Count > 0 )
  35. {
  36. dgv.DataSource = dt.Tables[0];
  37. }
  38. }
  39. #endregion
  40. #region 自定义函数;
  41. public System.Data.DataSet GetScenerysData(System.DateTime startDate, System.DateTime endDate)
  42. {
  43. /* 调用存储过程;
  44. System.Data.SqlClient.SqlParameter[] parameters = {
  45. new System.Data.SqlClient.SqlParameter("@startDate", System.Data.SqlDbType.DateTime),
  46. new System.Data.SqlClient.SqlParameter("@endDate", System.Data.SqlDbType.DateTime)
  47. };
  48. parameters[0].Value = startDate;
  49. parameters[1].Value = endDate;
  50. return LYFZ.Helper.SQLHelper.RunProcedure("proc_getSceneryUsage", parameters, "sceneryUsage");
  51. */
  52. string strQuery = "with t as(" +
  53. "select top 100 percent " +
  54. "Ordpg_Sights" +
  55. ",count(*) as 使用总数" +
  56. ",count(case Ordpg_PhotographyStatus when 1 then '已拍照'end) 已拍照" +
  57. ",count(case Ordpg_PhotographyStatus when 2 then '拍照中'end) 拍照中" +
  58. ",count(case Ordpg_PhotographyStatus when 0 then '未拍照'end) 未拍照" +
  59. " from tb_ErpOrdersPhotography Left Join tb_ErpOrder On tb_ErpOrdersPhotography.Ordpg_Number = tb_ErpOrder.Ord_Number" +
  60. " where tb_ErpOrder.Ord_CreateDateTime >= '"+ startDate.ToString("yyyy-MM-dd 00:00:00") +"' and tb_ErpOrder.Ord_CreateDateTime <= '" + endDate.ToString("yyyy-MM-dd 23:59:59") + "'" +
  61. " group by Ordpg_Sights order by Ordpg_Sights " +
  62. ")" +
  63. "select Tsc_Name as 景点名, isnull(t.使用总数, 0) as 使用总数, isnull(t.已拍照, 0) as 已拍照, isnull(t.拍照中, 0) as 拍照中, isnull(t.未拍照, 0) as 未拍照" +
  64. " from t right join tb_ErpTheScenery on t.Ordpg_Sights = tb_ErpTheScenery.Tsc_Name";
  65. return LYFZ.Helper.SQLHelper.Query(strQuery);
  66. }
  67. #endregion
  68. }
  69. }