Files
lserp_cs_6.0/其他程序/AFKAbutment - 副本/ConfigurationTool.cs
cyf ab56a9bcf7 基线 SVN r240
SVN-Revision: r240
2025-02-06 06:46:06 +00:00

229 lines
7.9 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Lskj.Control;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace AFKAbutment
{
public partial class ConfigurationTool : Form
{
public DataTable dataTable = new DataTable();
public string PrimarySeparator;//主要分隔符
public string SecondarySeparator;//次要分隔符
public string SegmentedContent;//分割的内容
public string DirectionTag;//方向 0AFK》LS 1 //LS》AFK
// 反写事件
public event ReturnContent returnContent;
public delegate void ReturnContent(string value);
public ConfigurationTool()
{
InitializeComponent();
}
private void ConfigurationTool_Load(object sender, EventArgs e)
{
//this.gridView.BorderStyle
this.button1.Click += button1_Click;
this.determine.Click += determine_Click;
this.addBtn.Click += AddBtn_Click;
this.setBtn.Click += setBtn_Click;
this.deleteBtn.Click += deleteBtn_Click;
if (string.IsNullOrWhiteSpace(SegmentedContent))
{
splitContent.Text = "请输入要进行分割的内容";
}
else
{
splitContent.Text = SegmentedContent;
}
if ("0".Equals(DirectionTag))
{
dataTable.Columns.Add("朗速");
dataTable.Columns.Add("AFK");
}
else if ("1".Equals(DirectionTag))
{
dataTable.Columns.Add("AFK");
dataTable.Columns.Add("朗速");
}
else
{
dataTable.Columns.Add("tableColumns1");
dataTable.Columns.Add("tableColumns2");
}
this.gridControl.DataSource = dataTable;
this.queryBox.TextChanged += new EventHandler(queryBox_TextChanged);
if (!string.IsNullOrWhiteSpace(DirectionTag))
{
this.determine_Click(null, null);
}
}
//搜索框值改变事件
private void queryBox_TextChanged(object sender, EventArgs e)
{
try
{
//【TextEdit】判断是否为空
if (queryBox.Text.ToString() != "")
{
string txtid = queryBox.Text.Trim().ToString();
//grv是gridview的名字,【开始模糊查询】
this.gridView.ActiveFilter.Add(null, new DevExpress.XtraGrid.Columns.ColumnFilterInfo(string.Format("朗速 like '%{0}%' or AFK like '%{0}%'", txtid)));
}
else
{
//表示清除模糊查询
this.gridView.ActiveFilter.Clear();
}
}
catch (Exception ex)
{
}
}
//点击确定
private void determine_Click(object sender, EventArgs e)
{
try
{
if (!string.IsNullOrEmpty(splitContent.Text))
{
PrimarySeparator = separator1.Text.Trim();
SecondarySeparator = separator2.Text.Trim();
string content = splitContent.Text;
string[] contents1 = content.Split(new string[] { PrimarySeparator }, StringSplitOptions.None);
if (contents1.Length > 2)
{
if (contents1.Length == 3)
{
this.tableNameBox.Text = contents1[0];
this.FirstBox.Text = contents1[1];
this.SecondBox.Text = contents1[2];
}
else if (contents1.Length == 4)
{
this.tableNameBox.Text = contents1[0];
this.FirstBox.Text = contents1[1];
this.SecondBox.Text = contents1[2];
this.EndBox.Text = contents1[3];
}
string[] tableColumns1 = contents1[1].Split(new string[] { SecondarySeparator }, StringSplitOptions.None);
string[] tableColumns2 = contents1[2].Split(new string[] { SecondarySeparator }, StringSplitOptions.None);
dataTable.Rows.Clear();
for (int i = 0; i < tableColumns1.Length; i++)
{
dataTable.Rows.Add(tableColumns1[i], tableColumns2[i]);
}
this.gridControl.DataSource = dataTable;
}
else
{
MessageBox.Show("字符串不符合规则");
this.splitContent.Text = "";
this.splitContent.Focus();
}
}
else
{
MessageBox.Show("字符串不能为空");
this.splitContent.Text = "";
this.splitContent.Focus();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
this.FirstBox.Text = "";
this.SecondBox.Text = "";
}
}
private void button1_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.tableNameBox.Text))
{
MessageBox.Show("表名不能为空");
return;
}
string content = splitContent.Text;
string[] contents1 = content.Split(new string[] { PrimarySeparator }, StringSplitOptions.None);
DataTable dataTable = this.gridControl.DataSource as DataTable;
string tableColumns1 = string.Empty;
string tableColumns2 = string.Empty;
for (int i = 0; i < dataTable.Rows.Count; i++)
{
tableColumns1 = tableColumns1 + dataTable.Rows[i][0] + "" + ",";
tableColumns2 = tableColumns2 + dataTable.Rows[i][1] + "" + ",";
}
tableColumns1 = tableColumns1.Trim(',');
tableColumns2 = tableColumns2.Trim(',');
if (string.IsNullOrEmpty(tableColumns1) || string.IsNullOrEmpty(tableColumns2))
{
MessageBox.Show("列字段不能为空");
return;
}
string jg = string.Empty;
if (!string.IsNullOrEmpty(this.EndBox.Text))
{
this.FirstBox.Text = tableColumns1;
this.SecondBox.Text = tableColumns2;
jg = this.tableNameBox.Text + "^" + this.FirstBox.Text + "^" + this.SecondBox.Text + "^" + this.EndBox.Text;
}
else
{
this.FirstBox.Text = tableColumns1;
this.SecondBox.Text = tableColumns2;
jg = this.tableNameBox.Text + "^" + this.FirstBox.Text + "^" + this.SecondBox.Text;
}
splitContent.Text = jg;
}
//新增
private void AddBtn_Click(object sender, EventArgs e)
{
this.gridView.AddNewRow();
}
//删除
private void deleteBtn_Click(object sender, EventArgs e)
{
DialogResult dialogResult = MessageUtil.Show("是否删除当前列?", MessageBoxButtons.OKCancel);
if (dialogResult == DialogResult.OK)
{
this.gridView.DeleteSelectedRows();
}
}
//反写
private void setBtn_Click(object sender, EventArgs e)
{
this.button1_Click(null, null);
returnContent(splitContent.Text);
this.Close();
}
}
}