2017-09-17 15:08:34 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Windows.Forms;
|
2017-09-24 12:42:45 +08:00
|
|
|
|
using HslCommunication;
|
2017-10-08 09:41:29 +08:00
|
|
|
|
using CommonLibrary;
|
2017-09-17 15:08:34 +08:00
|
|
|
|
|
2017-09-24 12:42:45 +08:00
|
|
|
|
namespace ClientsLibrary.Configuration
|
2017-09-17 15:08:34 +08:00
|
|
|
|
{
|
2017-09-24 12:42:45 +08:00
|
|
|
|
public partial class ArrayConfiguration : UserControl
|
2017-09-17 15:08:34 +08:00
|
|
|
|
{
|
2017-09-24 12:42:45 +08:00
|
|
|
|
#region Constructor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ArrayConfiguration(int download, int upload, string headText)
|
2017-09-17 15:08:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
2017-09-24 12:42:45 +08:00
|
|
|
|
SetInfomation(download, upload, headText);
|
|
|
|
|
|
|
2017-09-17 15:08:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-24 12:42:45 +08:00
|
|
|
|
public ArrayConfiguration()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2017-09-17 15:08:34 +08:00
|
|
|
|
#region Private Member
|
|
|
|
|
|
|
|
|
|
|
|
private int Download = 0;
|
|
|
|
|
|
private int Upload = 0;
|
|
|
|
|
|
private string HeadText = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2017-10-08 09:41:29 +08:00
|
|
|
|
#region Public Method
|
2017-10-06 13:30:28 +08:00
|
|
|
|
|
|
|
|
|
|
|
2017-09-24 12:42:45 +08:00
|
|
|
|
public void SetInfomation(int download, int upload, string headText)
|
|
|
|
|
|
{
|
|
|
|
|
|
Download = download;
|
|
|
|
|
|
Upload = upload;
|
|
|
|
|
|
HeadText = headText;
|
|
|
|
|
|
}
|
2017-09-17 15:08:34 +08:00
|
|
|
|
|
2017-10-08 09:41:29 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Control Load
|
|
|
|
|
|
|
2017-09-17 15:08:34 +08:00
|
|
|
|
|
|
|
|
|
|
private void FactoryConfiguration_Load(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataGridView1.Columns[0].HeaderText = HeadText;
|
|
|
|
|
|
|
2017-10-08 09:41:29 +08:00
|
|
|
|
// 向服务器请求数据初始化
|
2017-09-24 12:42:45 +08:00
|
|
|
|
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(Download, "");
|
2017-09-17 15:08:34 +08:00
|
|
|
|
|
|
|
|
|
|
if (result.IsSuccess)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> ListData = Newtonsoft.Json.Linq.JArray.Parse(result.Content).ToObject<List<string>>();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ListData.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
int rowIndex = dataGridView1.Rows.Add();
|
|
|
|
|
|
dataGridView1.Rows[rowIndex].Cells[0].Value = ListData[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show(result.Message);
|
2017-10-08 09:41:29 +08:00
|
|
|
|
userButton_save.Enabled = false;
|
2017-09-17 15:08:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-08 09:41:29 +08:00
|
|
|
|
// 本地化支持
|
|
|
|
|
|
UILocalization();
|
2017-09-17 15:08:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-08 09:41:29 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region List Add
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void userButton_Add_Click(object sender, EventArgs e)
|
2017-09-17 15:08:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
dataGridView1.Rows.Add();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-08 09:41:29 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region List Delete
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-09-17 15:08:34 +08:00
|
|
|
|
private void userButton1_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dataGridView1.SelectedRows != null)
|
|
|
|
|
|
{
|
2017-09-24 12:42:45 +08:00
|
|
|
|
if (dataGridView1.Rows.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]);
|
|
|
|
|
|
}
|
2017-09-17 15:08:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-08 09:41:29 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Submit
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-09-17 15:08:34 +08:00
|
|
|
|
private void userButton2_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> data = new List<string>();
|
2017-09-24 12:42:45 +08:00
|
|
|
|
for (int i = 0; i < dataGridView1.Rows.Count; i++)
|
2017-09-17 15:08:34 +08:00
|
|
|
|
{
|
2017-09-24 12:42:45 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(dataGridView1.Rows[i].Cells[0].Value.ToString()))
|
2017-09-17 15:08:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
data.Add(dataGridView1.Rows[i].Cells[0].Value.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-24 12:42:45 +08:00
|
|
|
|
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(Upload,
|
|
|
|
|
|
Newtonsoft.Json.Linq.JArray.FromObject(data).ToString());
|
2017-09-17 15:08:34 +08:00
|
|
|
|
|
2017-09-24 12:42:45 +08:00
|
|
|
|
if (result.IsSuccess)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("修改成功!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("修改失败!原因:" + result.Message);
|
|
|
|
|
|
}
|
2017-09-17 15:08:34 +08:00
|
|
|
|
}
|
2017-10-08 09:41:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Localization Support
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 本地化显示的操作,还未完成
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void UILocalization()
|
|
|
|
|
|
{
|
|
|
|
|
|
userButton_add.UIText = UserLocalization.Localization.ButtonAdd;
|
|
|
|
|
|
userButton_delete.UIText = UserLocalization.Localization.ButtonDelete;
|
|
|
|
|
|
userButton_save.UIText = UserLocalization.Localization.ButtonSave;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2017-09-17 15:08:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|