ab56a9bcf7
SVN-Revision: r240
766 lines
36 KiB
C#
766 lines
36 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Lskj.Control;
|
|
using Lskj.Business;
|
|
using Lskj.Data;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using Lskj.Util;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Business.Impl;
|
|
using DevExpress.XtraTab;
|
|
using Lskj.Model;
|
|
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
|
|
namespace Lskj.SweepCodeExe
|
|
{
|
|
public partial class TabIntoControl : TabControlEx
|
|
{
|
|
/// <summary>
|
|
/// 是否加载明细刷新
|
|
/// </summary>
|
|
/// <value><c>true</c> if [_ un refresh]; otherwise, <c>false</c>.</value>
|
|
private bool _UnRefresh
|
|
{
|
|
get
|
|
{
|
|
return Model is DynamicModuleDetailModel || Model is DynamicModuleModel || Model is DynamicProductionModel;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 拖拽模式
|
|
/// </summary>
|
|
public bool IsDragDetail;
|
|
/// <summary>
|
|
/// 拖拽目标主键字段
|
|
/// </summary>
|
|
public string DrgaParentPrimaryKey;
|
|
/// <summary>
|
|
/// 添加数据sql赋值
|
|
/// </summary>
|
|
public string ControlSql;
|
|
/// <summary>
|
|
/// tab标签
|
|
/// </summary>
|
|
private List<GridDetailModel> _gridDetail;
|
|
/// <summary>
|
|
/// tab标签里明细数据
|
|
/// </summary>
|
|
private List<GridDetailModel> _gridIntoDetail;
|
|
/// <summary>
|
|
/// The system model
|
|
/// </summary>
|
|
public DynamicModel Model;
|
|
/// <summary>
|
|
/// 父表格
|
|
/// </summary>
|
|
public GridControlEx ParentGridEx;
|
|
/// <summary>
|
|
/// 父容器
|
|
/// </summary>
|
|
public MyControl ParentControlEx;
|
|
/// <summary>
|
|
/// 明细数据里的主表格
|
|
/// </summary>
|
|
public ModuleGridEx ModuleGridObj;
|
|
/// <summary>
|
|
/// 选项卡
|
|
/// </summary>
|
|
public XtraTabControl TabIntoControlObj
|
|
{
|
|
get { return this.xtc_container; }
|
|
}
|
|
/// <summary>
|
|
/// 右键菜单执行后调用
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
public event EventHandler OnRightCallback;
|
|
/// <summary>
|
|
/// 表格保存执行后调用
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
public event EventHandler OnAllGridCallback;
|
|
public TabIntoControl()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:绑定选项卡</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-09</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public void InitTabPages(List<GridDetailModel> gridDetail, int _fontSize = 0)
|
|
{
|
|
double result = (Screen.PrimaryScreen.Bounds.Height * Screen.PrimaryScreen.Bounds.Width) / (double)(1080 * 1920);
|
|
result = result == 1 ? result : result * 1.5;
|
|
this._gridDetail = gridDetail;
|
|
this.xtc_container.TabPages.Clear();
|
|
if (_fontSize == 0)
|
|
{
|
|
_fontSize = 10;
|
|
|
|
}
|
|
//decimal result = Math.Round((decimal)_fontSize / (decimal)12, 2);//缩放比
|
|
foreach (GridDetailModel model in this._gridDetail)
|
|
{
|
|
XtraTabPage page = new XtraTabPage();
|
|
page.Text = model.DetailName;
|
|
page.Appearance.Header.Font = new System.Drawing.Font("Microsoft YaHei UI", Convert.ToInt32(11 * result), System.Drawing.FontStyle.Bold);
|
|
page.Appearance.Header.FontStyleDelta = System.Drawing.FontStyle.Bold;
|
|
page.TabPageWidth = Convert.ToInt32(181 * result);
|
|
page.Appearance.Header.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
|
|
if (model.IsChart)
|
|
{
|
|
ChartControlEx chartEx = new ChartControlEx();
|
|
chartEx.Dock = DockStyle.Fill;
|
|
chartEx.SetCharts(BaseModuleImpl.GetChartParams(model.FormKey));
|
|
chartEx.SetChartRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.Model, OnGridViewRightCallBack);
|
|
chartEx.Tag = model;
|
|
|
|
page.Tag = chartEx;
|
|
page.Controls.Add(chartEx);
|
|
}
|
|
else if (model.IsExcel)
|
|
{
|
|
ExcelControlEx excelEx = new ExcelControlEx();
|
|
excelEx.Dock = DockStyle.Fill;
|
|
excelEx.Tag = model;
|
|
|
|
page.Tag = excelEx;
|
|
page.Controls.Add(excelEx);
|
|
}
|
|
else if (model.IsWebView)
|
|
{
|
|
// 加载网页
|
|
string url = model.DetailSql.StartsWith("http") ? model.DetailSql : SystemInfo.Instance.OAUrl + model.DetailSql;
|
|
|
|
ModuleWebView webView = new ModuleWebView();
|
|
webView.Dock = DockStyle.Fill;
|
|
webView.Tag = model;
|
|
webView.Navigate(ReplaceHelper.ReplaceUserInfo(url));
|
|
|
|
page.Tag = webView;
|
|
page.Controls.Add(webView);
|
|
}
|
|
else
|
|
{
|
|
if (model.IsReadOnly)
|
|
{
|
|
PanelControl plBottom = new PanelControl();
|
|
plBottom.Visible = false;
|
|
plBottom.Dock = DockStyle.Bottom;
|
|
PanelControl plMain = new PanelControl();
|
|
plMain.Dock = DockStyle.None;
|
|
GridControlEx gridEx = new GridControlEx();
|
|
gridEx.GridControl.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
|
|
gridEx.GridControl.LookAndFeel.UseDefaultLookAndFeel = false;
|
|
gridEx.GridView.Appearance.HeaderPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
|
|
gridEx.GridView.Appearance.HeaderPanel.Font = new System.Drawing.Font("Microsoft YaHei UI", Convert.ToInt32(11 * result), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
|
gridEx.GridView.Appearance.HeaderPanel.ForeColor = System.Drawing.Color.Black;
|
|
gridEx.GridView.ColumnPanelRowHeight = Convert.ToInt32(30 * result);
|
|
gridEx.GridView.RowHeight = Convert.ToInt32(32 * result);
|
|
gridEx.GridView.Appearance.Row.Font = new System.Drawing.Font("Microsoft YaHei UI", Convert.ToInt32(10 * result));
|
|
gridEx.GridView.Appearance.Row.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(136)))), ((int)(((byte)(136)))), ((int)(((byte)(136)))));
|
|
gridEx.Dock = DockStyle.Fill;
|
|
gridEx.Tag = model;
|
|
gridEx.Parent = plMain;
|
|
gridEx.Model = this.Model;
|
|
gridEx.SetReadOnlyColumns(model.GridColumns, model.GridCustomColumnKey);
|
|
gridEx.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.Model, OnGridViewRightCallBack);
|
|
gridEx.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(model.FormKey));
|
|
plMain.Height = this.xtc_container.Height - Convert.ToInt32((40 + page.Appearance.Header.FontHeight) * result);
|
|
plMain.Width = Convert.ToInt32(this.xtc_container.Width - 40);
|
|
plMain.Top = Convert.ToInt32(20 * result); plMain.Left = Convert.ToInt32(20 * result);
|
|
//plMain.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
//plMain.Parent = xtc_container;
|
|
if (IsDragDetail && this.ParentGridEx != null && model.IsDrag)
|
|
{
|
|
// 拖拽模式,绑定拖拽对象
|
|
GridDragGrid dragGrid = new GridDragGrid(gridEx.GridView, this.ParentGridEx.GridView);
|
|
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragGridCompleted);
|
|
}
|
|
|
|
// 加载配置查询条件
|
|
//if (model.IsSearch)
|
|
//{
|
|
// plBottom.Visible = true;
|
|
// MyControl searchObj = new MyControl(model.DetailSql, gridEx);
|
|
// plBottom.Height = searchObj.InitSearchControl(BaseModuleImpl.GetCustomQueryFields(model.SystemModel.CondKey), plBottom);
|
|
//}
|
|
page.Tag = gridEx;
|
|
page.Controls.AddRange(new PanelControl[] { plBottom, plMain });
|
|
|
|
}
|
|
else
|
|
{
|
|
DynamicModel dyncModel = new DynamicModuleModel(new string[] { model.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, "1", model.UnionModule, "0" });
|
|
model.SystemModel = new ModuleModel(MainImpl.GetSystemdllTab(model.UnionModule));
|
|
if (Model != null)
|
|
model.SystemModel.ParmaryKey = BaseImpl.GetBasePrimaryKey(Model.ModuleCode);
|
|
ModuleGridEx gridEx = new ModuleGridEx();
|
|
gridEx.Name = "gridEx";
|
|
gridEx.IsDetail = true;
|
|
gridEx.Dock = DockStyle.None;
|
|
gridEx.GridControlObj.gridControl.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
|
|
gridEx.GridControlObj.gridControl.LookAndFeel.UseDefaultLookAndFeel = false;
|
|
gridEx.GridControlObj.GridView.Appearance.HeaderPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
|
|
gridEx.GridControlObj.GridView.Appearance.HeaderPanel.Font = new System.Drawing.Font("Microsoft YaHei UI", Convert.ToInt32(11 * result), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
|
gridEx.GridControlObj.GridView.Appearance.HeaderPanel.ForeColor = System.Drawing.Color.Black;
|
|
gridEx.GridControlObj.GridView.ColumnPanelRowHeight = Convert.ToInt32(30 * result); ;
|
|
gridEx.GridControlObj.GridView.RowHeight = Convert.ToInt32(32 * result); ;
|
|
gridEx.GridControlObj.GridView.Appearance.Row.Font = new System.Drawing.Font("Microsoft YaHei UI", Convert.ToInt32(10 * result));
|
|
gridEx.GridControlObj.GridView.Appearance.Row.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(136)))), ((int)(((byte)(136)))), ((int)(((byte)(136)))));
|
|
gridEx.OperShortMode = false; // 不显示简短模式
|
|
gridEx.VisibleSearchPanel = Model.IsDetailSearch;
|
|
gridEx.VisibleOperPanel = !model.IsReadOnly;
|
|
gridEx.InitializeControl(model.SystemModel, dyncModel);
|
|
gridEx.GridControlObj.Tag = model;
|
|
gridEx.ParentControlEx = this.ParentControlEx;
|
|
gridEx.ParentGridEx = this.ParentGridEx;
|
|
gridEx.ParentKeyField = string.IsNullOrEmpty(model.UnionParentField) ? model.SystemModel.ParmaryKey : model.UnionParentField;
|
|
gridEx.DetailKeyField = model.UnionValue;
|
|
gridEx.OnSaveGridCallBack += new EventHandler(OnGridViewAllCallBack);
|
|
gridEx.Height = this.xtc_container.Height - Convert.ToInt32(40 * result + page.Appearance.Header.FontHeight);
|
|
gridEx.Width = Convert.ToInt32(this.xtc_container.Width - 40);
|
|
gridEx.Top = Convert.ToInt32(20 * result); gridEx.Left = Convert.ToInt32(20 * result);
|
|
if (IsDragDetail && this.ParentGridEx != null && model.IsDrag)
|
|
{
|
|
// 拖拽模式,绑定拖拽对象
|
|
GridDragGrid dragGrid = new GridDragGrid(gridEx.GridControlObj.GridView, this.ParentGridEx.GridView);
|
|
dragGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragGridCompleted);
|
|
}
|
|
|
|
if (model.AutoRefresh && !_UnRefresh)
|
|
gridEx.SearchObj.SearchGrid();
|
|
this._gridIntoDetail = GetDetails(model.UnionModule);
|
|
if (_gridIntoDetail.Count > 0)
|
|
{
|
|
page.Tag = gridEx.GridControlObj;
|
|
|
|
SplitContainer splitLeftControl = new SplitContainer();
|
|
splitLeftControl.Dock = DockStyle.Fill;
|
|
|
|
TabAddControl tabAdd = new TabAddControl();
|
|
tabAdd.InitTabPages(_gridIntoDetail);
|
|
tabAdd.Dock = DockStyle.Fill;
|
|
splitLeftControl.Panel1.Controls.Add(gridEx);
|
|
splitLeftControl.Panel2.Controls.Add(tabAdd);
|
|
splitLeftControl.Panel1.Tag = gridEx;
|
|
splitLeftControl.Panel2.Tag = tabAdd;
|
|
page.Controls.AddRange(new SplitContainer[] { splitLeftControl });
|
|
gridEx.GridControlObj.GridView.RowCellClick += new DevExpress.XtraGrid.Views.Grid.RowCellClickEventHandler(GridView_RowCellClick);
|
|
}
|
|
else
|
|
{
|
|
page.Tag = gridEx.GridControlObj;
|
|
page.Controls.Add(gridEx);
|
|
}
|
|
}
|
|
}
|
|
|
|
this.xtc_container.TabPages.Add(page);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:特殊情况绑定选项卡</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-04-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="gridDetail">The grid detail.</param>
|
|
/// <param name="parentValue">The parent value.</param>
|
|
public void InitTabPages(List<GridDetailModel> gridDetail, string parentValue)
|
|
{
|
|
this._gridDetail = gridDetail;
|
|
this.xtc_container.TabPages.Clear();
|
|
|
|
foreach (GridDetailModel model in this._gridDetail)
|
|
{
|
|
XtraTabPage page = new XtraTabPage();
|
|
page.Text = model.DetailName;
|
|
|
|
if (model.IsChart)
|
|
{
|
|
ChartControlEx chartEx = new ChartControlEx();
|
|
chartEx.Dock = DockStyle.Fill;
|
|
chartEx.SetCharts(BaseModuleImpl.GetChartParams(model.FormKey));
|
|
chartEx.SetChartRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.Model, OnGridViewRightCallBack);
|
|
chartEx.Tag = model;
|
|
|
|
page.Tag = chartEx;
|
|
page.Controls.Add(chartEx);
|
|
}
|
|
else if (model.IsExcel)
|
|
{
|
|
ExcelControlEx excelEx = new ExcelControlEx();
|
|
excelEx.Dock = DockStyle.Fill;
|
|
excelEx.Tag = model;
|
|
|
|
page.Tag = excelEx;
|
|
page.Controls.Add(excelEx);
|
|
}
|
|
else
|
|
{
|
|
if (model.IsReadOnly)
|
|
{
|
|
PanelControl plTop = new PanelControl();
|
|
plTop.Dock = DockStyle.Top;
|
|
|
|
PanelControl plMain = new PanelControl();
|
|
plMain.Dock = DockStyle.Fill;
|
|
|
|
GridControlEx gridEx = new GridControlEx();
|
|
gridEx.Dock = DockStyle.Fill;
|
|
gridEx.Tag = model;
|
|
gridEx.Parent = plMain;
|
|
|
|
gridEx.Model = this.Model;
|
|
gridEx.SetReadOnlyColumns(model.GridColumns, model.GridCustomColumnKey);
|
|
gridEx.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(model.FormKey), this.Model, OnGridViewRightCallBack);
|
|
gridEx.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(model.FormKey));
|
|
|
|
// 加载配置查询条件
|
|
if (model.IsSearch)
|
|
{
|
|
MyControl searchObj = new MyControl(model.DetailSql, gridEx);
|
|
if (!string.IsNullOrEmpty(model.UnionValue) && !string.IsNullOrEmpty(parentValue))
|
|
searchObj.WhereCond = string.Format(" and {0}='{1}'", model.UnionValue, parentValue);
|
|
plTop.Height = searchObj.InitSearchControl(BaseModuleImpl.GetCustomQueryFields(model.SystemModel.CondKey), plTop);
|
|
}
|
|
|
|
page.Tag = gridEx;
|
|
page.Controls.AddRange(new PanelControl[] { plTop, plMain });
|
|
}
|
|
else
|
|
{
|
|
DynamicModel dyncModel = new DynamicModel(new string[] { model.DetailName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, "1", model.UnionModule, "0" });
|
|
model.SystemModel = new ModuleModel(MainImpl.GetSystemdllTab(model.UnionModule));
|
|
|
|
ModuleGridEx gridEx = new ModuleGridEx();
|
|
gridEx.Name = "gridEx";
|
|
gridEx.Dock = DockStyle.Fill;
|
|
gridEx.OperShortMode = false; // 不显示简短模式
|
|
gridEx.VisibleSearchPanel = model.IsSearch;
|
|
gridEx.VisibleOperPanel = true;
|
|
gridEx.ParentGridEx = this.ParentGridEx;
|
|
gridEx.ParentControlEx = this.ParentControlEx;
|
|
gridEx.ParentKeyField = string.IsNullOrEmpty(model.UnionParentField) ? model.UnionValue : model.UnionParentField;
|
|
gridEx.ParentKeyValue = parentValue;
|
|
gridEx.DetailKeyField = model.UnionValue;
|
|
gridEx.UnionKey = model.UnionValue;
|
|
gridEx.UnionValue = parentValue; //Model.ObjectId;
|
|
gridEx.InitializeControl(model.SystemModel, dyncModel);
|
|
gridEx.GridControlObj.Tag = model;
|
|
gridEx.ControlSql = ControlSql;
|
|
|
|
if (model.AutoRefresh)
|
|
gridEx.SearchObj.SearchGrid();
|
|
|
|
page.Tag = gridEx.GridControlObj;
|
|
page.Controls.Add(gridEx);
|
|
|
|
}
|
|
}
|
|
this.xtc_container.TabPages.Add(page);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:加载tab标签里得明细数据</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2018-09-28 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="RowCellClickEventArgs"/> instance containing the event data.</param>
|
|
protected void GridView_RowCellClick(object sender, RowCellClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WaitForm.ShowForm();
|
|
|
|
XtraTabPage tabPage = this.xtc_container.SelectedTabPage;
|
|
foreach (System.Windows.Forms.Control control in tabPage.Controls)
|
|
{
|
|
if (control is SplitContainer)
|
|
{
|
|
SplitContainer splitContainer = control as SplitContainer;
|
|
ModuleGridEx gcMain = splitContainer.Panel1.Tag as ModuleGridEx;
|
|
TabAddControl tabadd = splitContainer.Panel2.Tag as TabAddControl;
|
|
GridDetailModel model = tabadd.gridEx.Tag as GridDetailModel;
|
|
GridDetailModel model2 = tabadd.gridEx2.GridControlObj.Tag as GridDetailModel;
|
|
DataRow rowItem = gcMain.GridControlObj.GridView.GetFocusedDataRow();
|
|
this.ModuleGridObj = gcMain;
|
|
tabadd.PrimaryKey = this.ModuleGridObj.ParmaryKey;
|
|
if (rowItem != null && model != null)
|
|
{
|
|
string searchSql = this.GetSearchSql(model, rowItem);
|
|
tabadd.gridEx.LastSearchSql = searchSql;
|
|
tabadd.gridEx.SetGridViewDataSource(MainImpl.GetDataTableResult(tabadd.gridEx.LastSearchSql));
|
|
string searchSql2 = this.GetSearchSql(model2, rowItem);
|
|
tabadd.gridEx2.GridControlObj.LastSearchSql = searchSql2;
|
|
tabadd.gridEx2.SearchObj.SearchLastGrid();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
MessageUtil.Show("加载明细数据失败!" + ex);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取查询条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="model">The model.</param>
|
|
/// <param name="rowItem">The row item.</param>
|
|
/// <returns>System.String.</returns>
|
|
protected string GetSearchSql(GridDetailModel model, DataRow rowItem)
|
|
{
|
|
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) && rowItem.Table.Columns.Contains(model.UnionParentField) ? model.UnionParentField : ModuleGridObj.ParmaryKey;
|
|
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
|
|
|
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
|
|
|
if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue))
|
|
{
|
|
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, rowItem[fieldName] + "");
|
|
}
|
|
return sqlValue;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:判断多标签里是否有明细表</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2019-12-19 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>List<GridDetailModel>.</returns>
|
|
private List<GridDetailModel> GetDetails(string ModuleCode)
|
|
{
|
|
List<GridDetailModel> details = new List<GridDetailModel>();
|
|
|
|
DataTable table = BaseModuleImpl.GetBaseDetailPages(ModuleCode);
|
|
foreach (DataRow item in table.Rows)
|
|
{
|
|
DataTable gridColumns = ReportImpl.GetReportDetailColumns(ModuleCode, item["id"] + "");
|
|
details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
|
}
|
|
|
|
return details;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取TabPage绑定的实体对象</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tabPage">The tab page.</param>
|
|
/// <returns>GridDetailModel.</returns>
|
|
public GridDetailModel GetGridDetailModel(XtraTabPage tabPage)
|
|
{
|
|
if (tabPage == null) return null;
|
|
|
|
if (tabPage.Tag is GridControlEx)
|
|
return (tabPage.Tag as GridControlEx).Tag as GridDetailModel;
|
|
if (tabPage.Tag is ChartControlEx)
|
|
return (tabPage.Tag as ChartControlEx).Tag as GridDetailModel;
|
|
|
|
return null;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取选中TabPage绑定的实体对象</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>GridDetailModel.</returns>
|
|
public GridDetailModel GetFocusTabPageGridDetailModel()
|
|
{
|
|
return this.GetGridDetailModel(this.xtc_container.SelectedTabPage);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置指定TabPage数据源</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-15 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tabPage">The tab page.</param>
|
|
/// <param name="rowItem">The row item.</param>
|
|
public void SetGridDataSource(XtraTabPage tabPage, DataTable table)
|
|
{
|
|
try
|
|
{
|
|
if (tabPage == null) return;
|
|
|
|
if (tabPage.Tag is GridControlEx)
|
|
{
|
|
this.SetGridViewTabPage(tabPage, table);
|
|
}
|
|
else if (tabPage.Tag is ChartControlEx)
|
|
{
|
|
this.SetChartViewTabPage(tabPage, table);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.WriteError("TabPage配置错误-->" + tabPage.Text, ex);
|
|
LogHelper.Instance.WriteError(ex);
|
|
MessageUtil.Show(ex);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置选中TabPage数据源</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="table">The table.</param>
|
|
public void SetGridDataSource(DataTable table)
|
|
{
|
|
this.SetGridDataSource(this.xtc_container.SelectedTabPage, table);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置表格数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tabPage">The tab page.</param>
|
|
/// <param name="gridControl">The grid control.</param>
|
|
protected void SetGridViewTabPage(XtraTabPage tabPage, DataTable table)
|
|
{
|
|
GridControlEx gridControl = tabPage.Tag as GridControlEx;
|
|
GridDetailModel model = gridControl.Tag as GridDetailModel;
|
|
gridControl.SetGridViewDataSource(table);
|
|
gridControl.GridView.DoubleClick -= new EventHandler(OnGridCompleted);
|
|
int dataRowCount = gridControl.GridView.DataRowCount;
|
|
if (IsDragDetail && this.ParentGridEx != null && model.IsDrag)
|
|
{
|
|
gridControl.GridView.DoubleClick += new EventHandler(OnGridCompleted);
|
|
}
|
|
tabPage.Text = model.DetailName + "(" + dataRowCount + ")";
|
|
tabPage.Appearance.Header.ForeColor = gridControl.GridView.DataRowCount > 0 ? Color.Red : Color.FromArgb(0, 0, 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置图表数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="tabPage">The tab page.</param>
|
|
/// <param name="chartControl">The chart control.</param>
|
|
protected void SetChartViewTabPage(XtraTabPage tabPage, DataTable table)
|
|
{
|
|
ChartControlEx chartEx = tabPage.Tag as ChartControlEx;
|
|
GridDetailModel model = chartEx.Tag as GridDetailModel;
|
|
|
|
chartEx.CreateChart(table);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewRightCallBack(object sender, EventArgs e)
|
|
{
|
|
if (this.OnRightCallback != null)
|
|
this.OnRightCallback(sender, e);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-24 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnGridViewAllCallBack(object sender, EventArgs e)
|
|
{
|
|
if (this.OnAllGridCallback != null)
|
|
this.OnAllGridCallback(sender, e);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:表格双击完成</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2019-08-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
protected void OnGridCompleted(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
XtraTabPage tabPage = this.xtc_container.SelectedTabPage;
|
|
GridControlEx ge = tabPage.Tag as GridControlEx;
|
|
DataRow[] rowItems = new DataRow[] { ge.GridView.GetFocusedDataRow() };
|
|
GridColumnCollection gridColumns = this.ParentGridEx.GridView.Columns;
|
|
DataTable table = this.ParentGridEx.gridControl.DataSource as DataTable;
|
|
foreach (DataRow rowItem in rowItems)
|
|
{
|
|
DataRow newRow = table.NewRow();
|
|
foreach (GridColumn col in gridColumns)
|
|
{
|
|
if ("id".Equals(col.FieldName) || col.FieldName.Equals(this.DrgaParentPrimaryKey)) continue;
|
|
|
|
if (rowItem.Table.Columns.Contains(col.FieldName))
|
|
{
|
|
// 列中是否包含对应字段,包含则使用值
|
|
newRow[col.FieldName] = rowItem[col.FieldName];
|
|
}
|
|
else
|
|
{
|
|
// 未包含字段,则使用控件默认值.
|
|
GridColumnModel model = col.Tag as GridColumnModel;
|
|
string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue);
|
|
|
|
if (!string.IsNullOrEmpty(model.DefaultValue))
|
|
{
|
|
newRow[col.FieldName] = fieldValue;
|
|
}
|
|
}
|
|
}
|
|
table.Rows.Add(newRow);
|
|
}
|
|
|
|
this.ParentGridEx.GridView.ClearSelection();
|
|
this.ParentGridEx.GridView.SelectRowHandler(table.Rows.Count - 1);
|
|
this.ParentGridEx.GridView.UpdateCurrentRow();
|
|
this.ParentGridEx.GridView.ShowEditor();
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.WriteError("表格双击移动错误", ex);
|
|
LogHelper.Instance.WriteError(ex);
|
|
MessageUtil.Show(ResourceKeys.OperFault);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:表格拖拽完成</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-14 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
protected void OnDragGridCompleted(object sender, GridDragGridArgs e)
|
|
{
|
|
if (e.GridViewSelectRows == null || e.GridViewSelectRows.Length == 0 || this.ParentGridEx == null) return;
|
|
|
|
try
|
|
{
|
|
if (MessageUtil.Show(ResourceKeys.DragSelectRow, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
GridColumnCollection gridColumns = this.ParentGridEx.GridView.Columns;
|
|
DataTable table = this.ParentGridEx.gridControl.DataSource as DataTable;
|
|
foreach (DataRow rowItem in e.GridViewSelectRows)
|
|
{
|
|
DataRow newRow = table.NewRow();
|
|
foreach (GridColumn col in gridColumns)
|
|
{
|
|
if ("id".Equals(col.FieldName) || col.FieldName.Equals(this.DrgaParentPrimaryKey)) continue;
|
|
|
|
if (rowItem.Table.Columns.Contains(col.FieldName))
|
|
{
|
|
// 列中是否包含对应字段,包含则使用值
|
|
newRow[col.FieldName] = rowItem[col.FieldName];
|
|
}
|
|
else
|
|
{
|
|
// 未包含字段,则使用控件默认值.
|
|
GridColumnModel model = col.Tag as GridColumnModel;
|
|
string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue);
|
|
|
|
if (!string.IsNullOrEmpty(model.DefaultValue))
|
|
{
|
|
newRow[col.FieldName] = fieldValue;
|
|
}
|
|
}
|
|
}
|
|
table.Rows.Add(newRow);
|
|
}
|
|
|
|
this.ParentGridEx.GridView.ClearSelection();
|
|
this.ParentGridEx.GridView.SelectRowHandler(table.Rows.Count - 1);
|
|
this.ParentGridEx.GridView.UpdateCurrentRow();
|
|
this.ParentGridEx.GridView.ShowEditor();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.WriteError("表格拖拽错误", ex);
|
|
LogHelper.Instance.WriteError(ex);
|
|
MessageUtil.Show(ResourceKeys.OperFault);
|
|
}
|
|
}
|
|
}
|
|
}
|