157 lines
6.1 KiB
C#
157 lines
6.1 KiB
C#
using AIMS;
|
|
using AIMSBLL;
|
|
using AIMSExtension;
|
|
using AIMSModel;
|
|
using DCSoftDotfuscate;
|
|
using DevComponents.DotNetBar.Controls;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
|
|
namespace KHD_OREMR.UserControls
|
|
{
|
|
public partial class frmExportConfig : Form
|
|
{
|
|
public SysConfig exportConfig;
|
|
public DataGridView _dgv;
|
|
public string DataGridViewPath;
|
|
public string SysName;
|
|
|
|
private frmExportConfig()
|
|
{
|
|
InitializeComponent();
|
|
this.FormBorderStyle = FormBorderStyle.FixedSingle;
|
|
}
|
|
|
|
public frmExportConfig(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)
|
|
{
|
|
ExportConfig dataGridViewSetting = JsonConvert.DeserializeObject<ExportConfig>(exportConfig.Value);
|
|
txtName.Text = dataGridViewSetting.Title;
|
|
txtFontSize.Value = dataGridViewSetting.FontSize;
|
|
cmbIsHD.Checked = dataGridViewSetting.Landscape;
|
|
|
|
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["printShow"].Value = item.IsPrint;
|
|
column.Cells["printWidth"].Value = item.PrintWidth;
|
|
column.Cells["PrintSize"].Value = item.PrintSize;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
exportConfig = new SysConfig();
|
|
txtName.Text = Name;
|
|
txtFontSize.Value = 9;
|
|
cmbIsHD.Checked = true;
|
|
foreach (DataGridViewRow column in dataGridView2.Rows)
|
|
{
|
|
column.Cells["printShow"].Value = true;
|
|
column.Cells["printWidth"].Value = 8;
|
|
column.Cells["PrintSize"].Value = 8;
|
|
}
|
|
}
|
|
}
|
|
|
|
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;
|
|
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 dataGridViewSetting = CreateDataGridViewSetting(dataGridView2);
|
|
exportConfig.Value = JsonConvert.SerializeObject(dataGridViewSetting);
|
|
exportConfig.IsValid = 1;
|
|
exportConfig.OperatorNo = PublicMethod.OperatorNo;
|
|
exportConfig.OperatorName = PublicMethod.OperatorName;
|
|
exportConfig.OperateDate = DateTime.Now;
|
|
|
|
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 = cmbIsHD.Checked;
|
|
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 = bool.Parse(column.Cells["printShow"].Value.ToString());
|
|
export.PrintWidth = int.Parse(column.Cells["printWidth"].Value.ToString());
|
|
export.PrintSize = int.Parse(column.Cells["PrintSize"].Value.ToString());
|
|
|
|
dataGridViewSetting.exports.Add(export);
|
|
}
|
|
return dataGridViewSetting;
|
|
}
|
|
|
|
private void EndEdit()
|
|
{
|
|
this.Validate();
|
|
}
|
|
|
|
}
|
|
}
|