123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- 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.Windows.Forms;
- namespace LYFZ.ComponentLibrary
- {
- public partial class DataGridViewSetColumn : LYFZ.ComponentLibrary.BaseContentsFormMain
- {
- public DataGridViewSetColumn()
- {
- InitializeComponent();
- this.panelEx1.BackColor = UIBlueThemeResources.AreaBackgroundColor;
- this.panelEx1.BorderColor = UIBlueThemeResources.BorderAreaColor;
- this.panelEx1.BorderStyle = BorderStyle.FixedSingle;
- this.Load += DataGridViewSetColumn_Load;
- this.btnRevert.Click += btnRevert_Click;
- this.btnSaveed.Click += btnSaveed_Click;
- this.btnCancel.Click += btnCancel_Click;
- }
- /// <summary>
- /// DataGridView列表参数
- /// </summary>
- public LYFZ.ComponentLibrary.DataGridViewEc dgvNewData = new DataGridViewEc();
- /// <summary>
- /// 是否保存
- /// </summary>
- public bool IsSaveed = false;
- /// <summary>
- /// 不可操作字段
- /// </summary>
- public List<string> listEnabled = new List<string>();
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void DataGridViewSetColumn_Load(object sender, EventArgs e)
- {
- this.listEnabled.Add("订单类型");
- this.listEnabled.Add("拍摄名称");
- List<string> listOriginalColumn = new List<string>(this.dgvNewData.dgvCurrentColumnOriginalSet.Trim().Split(','));
- List<string> listHideColumn = new List<string>(this.dgvNewData.dgvFixedHideColumn.Trim().Split(','));
- LYFZ.ComponentLibrary.CheckBoxEx chk = null;
- for (int i = 0; i < listOriginalColumn.Count; i++)
- {
- if (!string.IsNullOrEmpty(listOriginalColumn[i].Trim()))
- {
- chk = new CheckBoxEx();
- chk.Text = listOriginalColumn[i].Trim();
- chk.Name = listOriginalColumn[i].Trim();
- chk.Width = 200;
- chk.Checked = this.dgvNewData.dictShowColumName.Keys.Contains(listOriginalColumn[i].Trim());
- if (chk.Checked)
- {
- chk.Tag = this.dgvNewData.dictShowColumName[listOriginalColumn[i].Trim()].ToString().Trim();
- }
- else
- {
- chk.Tag = "100";
- }
- if (listHideColumn.Contains(listOriginalColumn[i].Trim()))
- {
- chk.Visible = false;
- }
- this.flowLayoutPanel1.Controls.Add(chk);
- }
- }
- for (int i = 0; i < this.dgvNewData.Columns.Count; i++)
- {
- if (this.dgvNewData.Columns[i].Frozen)
- { this.listEnabled.Add(this.dgvNewData.Columns[i].Name.Trim()); }
- }
- //设置不可点的
- foreach (Control control in this.flowLayoutPanel1.Controls)
- {
- if (control is CheckBoxEx)
- {
- CheckBoxEx tmp = (CheckBoxEx)control;
- if (this.listEnabled.Contains(tmp.Text.Trim()))
- { tmp.Enabled = false; }
- }
- }
- //for (int i = 0; i < this.dgvNewData.Columns.Count; i++)
- //{
- // if (this.dgvNewData.Columns[i].Frozen)
- // {
- // foreach (Control control in this.flowLayoutPanel1.Controls)
- // {
- // if (control is CheckBoxEx)
- // {
- // CheckBoxEx tmp = (CheckBoxEx)control;
- // if (tmp.Text.Trim().Equals(this.dgvNewData.Columns[i].Name.Trim()))
- // { tmp.Enabled = false; }
- // }
- // }
- // }
- //}
- }
- /// <summary>
- /// 还原初始设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnRevert_Click(object sender, EventArgs e)
- {
- if (MessageBoxCustom.Show("您确定要重置为初始设置吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
- { return; }
- /* string StrValue = "";
- foreach (Control control in this.flowLayoutPanel1.Controls)
- {
- if (control is CheckBoxEx)
- {
- CheckBoxEx tmp = (CheckBoxEx)control;
- StrValue += tmp.Text.Trim() + ":" + tmp.Tag.ToString().Trim() + "|";
- }
- }
- if (!LYFZ.DAL.DAL_GridViewDisplayIndex.UpdateGridViewDisplayIndexModel(this.dgvNewData.dgvUserEmployeeID, this.dgvNewData.dgvGuidName, StrValue, LYFZ.DAL.DAL_GridViewDisplayIndex.StrVersionNumber))
- */
- if (!LYFZ.DAL.DAL_GridViewDisplayIndex.DeleteGridViewDisplayIndexModel(this.dgvNewData.dgvUserEmployeeID, this.dgvNewData.dgvGuidName))
- { MessageBoxCustom.Show("重置失败!"); return; }
- this.IsSaveed = true;
- MessageBoxCustom.Show("重置成功!");
- this.Close();
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSaveed_Click(object sender, EventArgs e)
- {
- string StrValue = "";
- foreach (Control control in this.flowLayoutPanel1.Controls)
- {
- if (control is CheckBoxEx)
- {
- CheckBoxEx tmp = (CheckBoxEx)control;
- if (tmp.Checked || !tmp.Visible)
- { StrValue += tmp.Text.Trim() + ":" + tmp.Tag.ToString().Trim() + "|"; }
- }
- }
- if (!LYFZ.DAL.DAL_GridViewDisplayIndex.UpdateGridViewDisplayIndexModel(this.dgvNewData.dgvUserEmployeeID, this.dgvNewData.dgvGuidName, StrValue, LYFZ.DAL.DAL_GridViewDisplayIndex.StrVersionNumber))
- { MessageBoxCustom.Show("保存失败!"); return; }
- this.btnCancel.Text = " 关 闭";
- this.IsSaveed = true;
- MessageBoxCustom.Show("保存成功!");
- }
- /// <summary>
- /// 取消
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnCancel_Click(object sender, EventArgs e)
- { this.Close(); }
- }
- }
|