123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- 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;
- using LYFZ.Model;
- namespace LYFZ.ComponentLibrary
- {
- public partial class DataViewColumnSet : LYFZ.ComponentLibrary.BaseContentsFormMain
- {
- public DataViewColumnSet()
- {
- 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;
- }
- string dgvUserEmployeeID = "";
- string dgvGuidName = "";
- private List<string> dataCoumnList = new List<string>();
- private List<string> enabledList = new List<string>();
- List<Model.TitleColumnDisplay> _TitleColumnDisplayList = new List<Model.TitleColumnDisplay>();
- /// <summary>
- /// 完全字段集合
- /// </summary>
- public List<string> DataCoumnList { get => dataCoumnList; set => dataCoumnList = value; }
- /// <summary>
- /// 不可操作字段
- /// </summary>
- public List<string> EnabledList { get => enabledList; set => enabledList = value; }
- public List<TitleColumnDisplay> TitleColumnDisplayList { get => _TitleColumnDisplayList; set => _TitleColumnDisplayList = value; }
- public string DgvUserEmployeeID { get => dgvUserEmployeeID; set => dgvUserEmployeeID = value; }
- public string DgvGuidName { get => dgvGuidName; set => dgvGuidName = value; }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void DataGridViewSetColumn_Load(object sender, EventArgs e)
- {
- for (int i = 0; i < this.dataCoumnList.Count; i++)
- {
- string columnText = this.dataCoumnList[i].Trim();
- if (!string.IsNullOrWhiteSpace(columnText))
- {
- TitleColumnDisplay titleColumn = this._TitleColumnDisplayList.Find(t=>t.ColumnText.ToLower() == columnText.ToLower());
- if (titleColumn == null)
- {
- titleColumn = new TitleColumnDisplay
- {
- ColumnText = columnText
- ,
- Index = i
- ,
- Display = 1
- };
- }
- else {
- if (titleColumn.Index <= -99999)
- {
- titleColumn.Index = i;
- }
- }
- LYFZ.ComponentLibrary.CheckBoxEx chk = chk = new CheckBoxEx();
- chk.Tag = titleColumn;
- chk.Text = columnText;
- chk.Name = columnText;
- chk.Width = 200;
- chk.Checked = !this._TitleColumnDisplayList.Any(t=>t.ColumnText.ToLower()== columnText.ToLower()&&t.Display==0);
- if (this.enabledList.Any(n => n.ToLower() == columnText.ToLower()))
- {
- chk.Enabled = false;
- chk.Checked = true;
- }
-
- this.flowLayoutPanel1.Controls.Add(chk);
- }
- }
-
-
- }
- /// <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;
- }
- /* List<TitleColumnDisplay> TempTitleColumnDisplayList = new List<TitleColumnDisplay>();
- foreach (Control control in this.flowLayoutPanel1.Controls)
- {
- if (control is CheckBoxEx)
- {
- CheckBoxEx tmp = (CheckBoxEx)control;
- tmp.Checked = true;
- TitleColumnDisplay titleColumn = (TitleColumnDisplay)tmp.Tag;
- titleColumn.Display = 1;
- TempTitleColumnDisplayList.Add(titleColumn);
- }
- }*/
- //if (!LYFZ.DAL.DAL_GridViewDisplayIndex.UpdateGridViewDisplayIndexModel(this.dgvUserEmployeeID, this.dgvGuidName, TitleColumnDisplay.ToTitleColumnDisplayJsonData(TempTitleColumnDisplayList), LYFZ.DAL.DAL_GridViewDisplayIndex.StrVersionNumber))
- if(!LYFZ.DAL.DAL_GridViewDisplayIndex.DeleteGridViewDisplayIndexModel(this.dgvUserEmployeeID, this.dgvGuidName))
- {
- MessageBoxCustom.Show("重置失败!");
- return;
- }
-
- MessageBoxCustom.Show("重置成功!");
- this.DialogResult = DialogResult.OK;
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSaveed_Click(object sender, EventArgs e)
- {
- List<TitleColumnDisplay> TempTitleColumnDisplayList = new List<TitleColumnDisplay>();
- foreach (Control control in this.flowLayoutPanel1.Controls)
- {
- if (control is CheckBoxEx)
- {
- CheckBoxEx tmp = (CheckBoxEx)control;
- TitleColumnDisplay titleColumn = (TitleColumnDisplay)tmp.Tag;
- if (tmp.Checked)
- {
- titleColumn.Display = 1;
- }
- else {
- titleColumn.Display = 0;
- }
- TempTitleColumnDisplayList.Add(titleColumn);
- }
- }
- if (!LYFZ.DAL.DAL_GridViewDisplayIndex.UpdateGridViewDisplayIndexModel(this.dgvUserEmployeeID, this.dgvGuidName, TitleColumnDisplay.ToTitleColumnDisplayJsonData(TempTitleColumnDisplayList), LYFZ.DAL.DAL_GridViewDisplayIndex.StrVersionNumber))
- {
- MessageBoxCustom.Show("保存失败!");
- return;
- }
-
-
- MessageBoxCustom.Show("保存成功!");
- this.DialogResult = DialogResult.OK;
- }
- /// <summary>
- /// 取消
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnCancel_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- }
- }
- }
|