123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- using NPOI.Util;
- using SourceGrid;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace OTSIncAReportApp._1_UI.OTSReportExport
- {
- public partial class Category : Form
- {
- List<string> CheckTheOptions = new List<string>();
- DataTable ElementList = new DataTable();
- public List<string> OutElementList = new List<string>();
- /// <summary>
- /// 窗体是否修改
- /// </summary>
- public bool IsModify = false;
- public List<string> vs = new List<string>();
- private bool isRemove = false;
- Hashtable table;
-
- public Category(List<string> a_ElementList,DataTable AllList,bool a_Remove)
- {
- InitializeComponent();
- ElementList = AllList.Copy();
- CheckTheOptions = a_ElementList.Copy();
- OutElementList = a_ElementList.Copy();
- isRemove = a_Remove;
- #region 国际化语言
- OTSCommon.Language lan = new OTSCommon.Language(this);
- table = lan.GetNameTable(this.Name);
- #endregion
- }
- //public Category(List<string> a_ElementList,DataTable AllList, bool a_Remove)
- //{
- // ElementList = AllList;
- // isRemove = a_Remove;
- // InitializeComponent();
- //}
- private void Category_Load(object sender, EventArgs e)
- {
- if (ElementList != null)
- {
- if (ElementList.Rows.Count > 0)
- {
- FlowLayoutPanel flowLayoutPanel = new FlowLayoutPanel();
- flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
- flowLayoutPanel.WrapContents = true;
- flowLayoutPanel.Dock = DockStyle.Fill;
- flowLayoutPanel.AutoScroll = true;
- flowLayoutPanel.Padding = new Padding(20, 10, 20, 25);
- panel2.Controls.Add(flowLayoutPanel);
- for (int i = 0; i < ElementList.Rows.Count; i++)
- {
- // 添加控件到 FlowLayoutPanel 中
- CheckBox box1 = new CheckBox();
- box1.Text = ElementList.Rows[i]["StrName"].ToString();
- box1.Width = flowLayoutPanel.Width - 40;
- box1.Height = 25;
- Font font = new Font("宋体", 15, FontStyle.Regular);
- box1.Font = font;
- if (CheckTheOptions.Count == 0)
- {
- if (!isRemove)
- box1.Checked = true;
- else
- box1.Checked = false;
- }
- else
- {
- for (int a = 0; a < CheckTheOptions.Count; a++)
- {
- if (ElementList.Rows[i]["STDId"].ToString() == CheckTheOptions[a].ToString())
- box1.Checked = true;
- }
- }
- flowLayoutPanel.Controls.Add(box1);
- }
- Panel panel = new Panel();
- panel.Size = new Size(10, 10);
- panel.BackColor = Color.Transparent;
- flowLayoutPanel.Controls.Add(panel);
- this.checkBox_selall.CheckedChanged -= new System.EventHandler(this.checkBox_selall_CheckedChanged);
- checkBox_selall.Checked = true;
- this.checkBox_selall.CheckedChanged += new System.EventHandler(this.checkBox_selall_CheckedChanged);
- }
- }
- }
- private void checkBox_selall_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBox_selall.Checked)
- {
- foreach (Control control in panel2.Controls)
- {
- if (control.GetType() == typeof(FlowLayoutPanel))
- {
- foreach (Control control1 in control.Controls)
- {
- if (control1.GetType() == typeof(System.Windows.Forms.CheckBox))
- {
- ((CheckBox)control1).Checked = true;
- }
- }
- }
- }
- }
- else
- {
- foreach (Control control in panel2.Controls)
- {
- if (control.GetType() == typeof(FlowLayoutPanel))
- {
- foreach (Control control1 in control.Controls)
- {
- if (control1.GetType() == typeof(System.Windows.Forms.CheckBox))
- {
- ((CheckBox)control1).Checked = false;
- }
- }
- }
- }
- }
- }
- /// <summary>
- /// 确定按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- OutElementList.Clear();
- vs.Clear();
- List<bool> blList = new List<bool>();
- foreach (Control control in panel2.Controls)
- {
- if (control.GetType() == typeof(FlowLayoutPanel))
- {
- foreach (Control control1 in control.Controls)
- {
- if (control1.GetType() == typeof(System.Windows.Forms.CheckBox))
- {
- if (((CheckBox)control1).Checked)
- {
- blList.Add(true);
- OutElementList.Add(control1.Text);
- }
- else
- {
- blList.Add(false);
- }
- }
- }
- }
- }
- for (int i=0;i < ElementList.Rows.Count; i++)
- {
- if(blList[i])
- {
- vs.Add(ElementList.Rows[i]["STDId"].ToString());
- }
- }
- IsModify = true;
- this.Close();
- }
- /// <summary>
- /// 取消按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- vs.Clear();
- vs= CheckTheOptions.Copy();
- OutElementList.Clear();
- for (int i = 0; i < ElementList.Rows.Count; i++)
- {
- for (int a = 0; a < CheckTheOptions.Count; a++)
- {
- if (CheckTheOptions[a] == ElementList.Rows[i]["STDId"].ToString())
- {
- OutElementList.Add(ElementList.Rows[i]["StrName"].ToString());
- }
- }
- }
- this.Close();
- }
- }
- }
|