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);
|
}
|
|
}
|
}
|