150 lines
5.8 KiB
C#
150 lines
5.8 KiB
C#
using AIMSBLL;
|
|
using AIMSExtension;
|
|
using AIMSModel;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
|
|
namespace AIMS.OperationAfter.UI
|
|
{
|
|
public partial class frmExportConfig2 : Form
|
|
{
|
|
public SysConfig exportConfig;
|
|
public DataGridView _dgv;
|
|
public string DataGridViewPath;
|
|
public string SysName;
|
|
|
|
private frmExportConfig2()
|
|
{
|
|
InitializeComponent();
|
|
this.FormBorderStyle = FormBorderStyle.FixedSingle;
|
|
}
|
|
|
|
public frmExportConfig2(DataGridView dgv, SysConfig _exportConfig, string dataGridViewPath, string name)
|
|
{
|
|
InitializeComponent();
|
|
this._dgv = dgv;
|
|
this.exportConfig = _exportConfig;
|
|
DataGridViewPath = dataGridViewPath;
|
|
SysName = name;
|
|
}
|
|
|
|
private void frmSelGridColusView_Load(object sender, EventArgs e)
|
|
{
|
|
if (_dgv == null) return;
|
|
LoadSettingSource(_dgv);
|
|
if (exportConfig != null)
|
|
{
|
|
if (exportConfig.Value != null)
|
|
{
|
|
ExportConfig dataGridViewSetting = JsonConvert.DeserializeObject<ExportConfig>(exportConfig.Value);
|
|
txtName.Text = dataGridViewSetting.Title;
|
|
txtFontSize.Value = dataGridViewSetting.FontSize;
|
|
|
|
foreach (DataGridViewRow column in dataGridView2.Rows)
|
|
{
|
|
foreach (var item in dataGridViewSetting.Exports)
|
|
{
|
|
if (column.Cells[0].Value.ToString() == item.Name)
|
|
{
|
|
column.Cells["widthDataGridViewTextBoxColumn"].Value = item.Width;
|
|
column.Cells["visibleDataGridViewCheckBoxColumn"].Value = item.IsVisible;
|
|
column.Cells["columnorder"].Value = item.ColumnOrder;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
exportConfig = new SysConfig();
|
|
txtName.Text = Name;
|
|
txtFontSize.Value = 6;
|
|
}
|
|
}
|
|
|
|
private void LoadSettingSource(DataGridView dgv)
|
|
{
|
|
int _lineNumber = 0;
|
|
foreach (DataGridViewColumn dataGridViewColumn in dgv.Columns)
|
|
{
|
|
DataGridViewRow drc = new DataGridViewRow();
|
|
drc.CreateCells(dataGridView2);
|
|
drc.Cells[0].Value = dataGridViewColumn.Name;
|
|
drc.Cells[1].Value = dataGridViewColumn.HeaderText;
|
|
drc.Cells[2].Value = dataGridViewColumn.MinimumWidth;
|
|
drc.Cells[3].Value = dataGridViewColumn.ReadOnly;
|
|
drc.Cells[4].Value = dataGridViewColumn.Visible;
|
|
drc.Cells[5].Value = dataGridViewColumn.Width;
|
|
drc.Cells[6].Value = dataGridViewColumn.Index;
|
|
dataGridView2.Rows.Insert(_lineNumber, drc);
|
|
_lineNumber++;
|
|
}
|
|
}
|
|
|
|
private void tsbCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void tsbSave_Click(object sender, EventArgs e)
|
|
{
|
|
EndEdit();
|
|
exportConfig.Name = txtName.Text;
|
|
exportConfig.Note = DataGridViewPath;
|
|
ExportConfig dgvSetting = CreateDataGridViewSetting(dataGridView2);
|
|
dgvSetting.FontSize =int.Parse( txtFontSize.Value.ToString());
|
|
string ss = JsonConvert.SerializeObject(dgvSetting);
|
|
exportConfig.Value = ss;
|
|
exportConfig.IsValid = 1;
|
|
exportConfig.OperatorNo = PublicMethod.OperatorNo;
|
|
exportConfig.OperatorName = PublicMethod.OperatorName;
|
|
exportConfig.OperateDate = DateTime.Now;
|
|
exportConfig.Extend1 = PublicMethod.RoleId.ToString();
|
|
|
|
if (exportConfig.Id != null && exportConfig.Id.Value > 0)
|
|
{
|
|
BSysConfig.Update(exportConfig);
|
|
}
|
|
else
|
|
{
|
|
exportConfig.Id = BSysConfig.Insert(exportConfig);
|
|
}
|
|
DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
private ExportConfig CreateDataGridViewSetting(DataGridView dataGridView)
|
|
{
|
|
ExportConfig dataGridViewSetting = new ExportConfig();
|
|
dataGridViewSetting.Title = txtName.Text;
|
|
dataGridViewSetting.Path = DataGridViewPath;
|
|
dataGridViewSetting.FontSize = int.Parse(txtFontSize.Value.ToString());
|
|
dataGridViewSetting.Landscape = false;
|
|
dataGridViewSetting.Exports = new List<ExportItem>();
|
|
foreach (DataGridViewRow column in dataGridView.Rows)
|
|
{
|
|
ExportItem export = new ExportItem();
|
|
export.Name = column.Cells["dataPropertyNameDataGridViewTextBoxColumn"].Value.ToString();
|
|
export.Text = column.Cells["headerTextDataGridViewTextBoxColumn"].Value.ToString();
|
|
export.PrintName = column.Cells["headerTextDataGridViewTextBoxColumn"].Value.ToString();
|
|
export.Width = int.Parse(column.Cells["widthDataGridViewTextBoxColumn"].Value.ToString());
|
|
export.IsVisible = bool.Parse(column.Cells["visibleDataGridViewCheckBoxColumn"].Value.ToString());
|
|
export.IsPrint = true;
|
|
export.PrintWidth = 8;
|
|
export.PrintSize = 8;
|
|
export.ColumnOrder = int.Parse(column.Cells["columnorder"].Value.ToString());
|
|
|
|
dataGridViewSetting.Exports.Add(export);
|
|
}
|
|
return dataGridViewSetting;
|
|
}
|
|
|
|
private void EndEdit()
|
|
{
|
|
this.Validate();
|
|
}
|
|
|
|
}
|
|
}
|