lk
2022-11-06 ce8e2226eead53745a12d138d6246fee706ddd8b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using CommonHelper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System.Collections;
 
namespace Sunny.UI.Demo.Controls
{
    public partial class DomesticPolicyData : UIPage
    {
        private Hashtable ht = new Hashtable();
 
        /// <summary>
        /// 表格标题重命名
        /// </summary>
        /// <param name="ColName"></param>
        /// <returns></returns>
        private string GetDgvColumName(string ColName)
        {
            if (ht.Contains(ColName)) return ht[ColName].ToString();
            else return ColName;
        }
 
        public DomesticPolicyData()
        {
            InitializeComponent();
 
            string url = "http://1.117.218.88:8090/api/IndustryPolicyApp/GetPages?PageIndex=1&PageSize=1";
            JObject item = (JObject)GetChinaStockList(url, 1);
            var items = item["data"]["totalItems"];
            uiPagination1.TotalCount = items.Value<int>();
            uiPagination1.PageSize = 5;
        }
 
        public static String GetData(String url, Encoding encode)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "GET";
            request.ContentType = "text/html, application/xhtml+xml, */*";
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream rs = response.GetResponseStream();
            StreamReader sr = new StreamReader(rs, encode);
            var result = sr.ReadToEnd();
            sr.Close();
            rs.Close();
            return result;
        }
 
 
        public object GetChinaStockList(string SearchInfo, int ReportType)
        {
            //string URL = Configs.GetValue("HYSiteUrl");
            //string GetSarchUrl = $"{URL}/ChinaStock/GetChinaStockList";
            string Result = GetData(SearchInfo, Encoding.UTF8);
            //JavaMsgData javaMsgData = JsonHelper.ToObject<JavaMsgData>(Result);
            return (JObject)JsonConvert.DeserializeObject(Result);
        }
 
 
        public void GetdgViewIndustryIndex(int PageIndex, int PageSize)
        {
            string url = "http://1.117.218.88:8090/api/IndustryPolicyApp/GetPages?PageIndex=" + PageIndex + "&PageSize=" + PageSize;
            JObject item = (JObject)GetChinaStockList(url, 1);
            if (item["data"]["items"] != null)
            {
                var items = item["data"]["items"];
                dgViewIndustryIndex.DataSource = items;
                for (int i = 0; i < dgViewIndustryIndex.Columns.Count; i++)
                {
                    string colName = dgViewIndustryIndex.Columns[i].Name;
                    if (colName == "id")
                    {
                        dgViewIndustryIndex.Columns[i].Visible = false;
                    }
                    dgViewIndustryIndex.Columns[i].HeaderText = GetDgvColumName(colName);
                }
            }
        }
 
        private void DomesticPolicyData_Load(object sender, EventArgs e)
        {
            ht.Add("title","政策名称");
            ht.Add("publishDate", "日期");
            ht.Add("organization", "发布单位");
            ht.Add("content", "主要内容");
            ht.Add("country", "国家");
            ht.Add("area", "区域");
            ht.Add("type", "政策性质");
            ht.Add("url", "来源");
            GetdgViewIndustryIndex(1, uiPagination1.PageSize);
        }
 
        private void dgViewIndustryIndex_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 7 && e.RowIndex > 0)
            {
                System.Diagnostics.Process.Start(dgViewIndustryIndex.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
                //this.dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
            }
        }
 
        private void uiPagination1_PageChanged(object sender, object pagingSource, int pageIndex, int count)
        {
            GetdgViewIndustryIndex(pageIndex, uiPagination1.PageSize);
        }
 
    }
}