diff --git a/插件库/Lskj.Control/ModuleGridEx.cs b/插件库/Lskj.Control/ModuleGridEx.cs index 41796d0..0b663ac 100644 --- a/插件库/Lskj.Control/ModuleGridEx.cs +++ b/插件库/Lskj.Control/ModuleGridEx.cs @@ -213,7 +213,7 @@ namespace Lskj.Control { get { return this.TipsPanel; } } - + /// /// 搜索界面 /// @@ -855,9 +855,25 @@ namespace Lskj.Control Dictionary dataCaches = Model != null ? Model.DataCaches : null; //显示筛选行 if (this.SysModel.LoadFilter) this.gcMain.GridView.OptionsView.ShowAutoFilterRow = true; - // 创建多表头,默认标准表格 - if (this.Model.GridEnumObj == GridEnum.BandedGridView || SysModel.AutoMultiHeader == 1) + if (SysModel.AutoMultiHeader == 1 && SysModel.TreeAutoMultiHeader == 1) { + // 创建 多表头,树表格 + this.panelControl1.Controls.Clear(); + this.gcMain = new TreeBandedGridControlEx() { Expansion = SysModel.TreeTableExpand }; + this.gcMain.Model = this.Model; + this.gcMain.Dock = DockStyle.Fill; + if (this._gridColumns.Rows.Count == 0&&!string.IsNullOrWhiteSpace(SysModel.TreeKeyFieldName) && !string.IsNullOrWhiteSpace(SysModel.TreeParentFieldName)) + { + //节点编号 + (this.gcMain as TreeBandedGridControlEx).TreeListObj.KeyFieldName = SysModel.TreeKeyFieldName; + //父节点编号 + (this.gcMain as TreeBandedGridControlEx).TreeListObj.ParentFieldName = SysModel.TreeParentFieldName; + } + this.panelControl1.Controls.Add(this.gcMain); + } + else if (this.Model.GridEnumObj == GridEnum.BandedGridView || SysModel.AutoMultiHeader == 1) + { + // 创建多表头,默认标准表格 PanelControl panel = null; if (this.gcMain.gridControl.Tag is PanelControl) panel = this.gcMain.gridControl.Tag as PanelControl; @@ -870,14 +886,23 @@ namespace Lskj.Control if (this.SysModel.LoadFilter) (this.gcMain as BandedGridControlEx).GridView.OptionsView.ShowAutoFilterRow = true; (this.gcMain as BandedGridControlEx).gridControl.Tag = panel; } - if (this.Model.GridEnumObj == GridEnum.TreeListGridView || SysModel.TreeAutoMultiHeader == 1) + else if (this.Model.GridEnumObj == GridEnum.TreeListGridView || SysModel.TreeAutoMultiHeader == 1) { + // 创建树表格 this.panelControl1.Controls.Clear(); this.gcMain = new TreeGridControlEx() { Expansion = SysModel.TreeTableExpand }; this.gcMain.Model = this.Model; this.gcMain.Dock = DockStyle.Fill; + if (this._gridColumns.Rows.Count == 0 && !string.IsNullOrWhiteSpace(SysModel.TreeKeyFieldName) && !string.IsNullOrWhiteSpace(SysModel.TreeParentFieldName)) + { + //节点编号 + (this.gcMain as TreeGridControlEx).TreeListObj.KeyFieldName = SysModel.TreeKeyFieldName; + //父节点编号 + (this.gcMain as TreeGridControlEx).TreeListObj.ParentFieldName = SysModel.TreeParentFieldName; + } this.panelControl1.Controls.Add(this.gcMain); } + //如果配置了聚合模式则构建多表头覆盖当前表格 if (SysModel.IsCustomGroup == 1) { @@ -3315,10 +3340,10 @@ namespace Lskj.Control private void GetPrintOtherParam(string ModeCond) { //取得打印完成后的参数 - - if (!string.IsNullOrEmpty(ModeCond) ) + + if (!string.IsNullOrEmpty(ModeCond)) { - + DataRow item = AttachImpl.GetSystemModule(ModeCond); string tableName = item["TableName"] + ""; string modetype = item["modType"] + ""; @@ -3974,7 +3999,7 @@ namespace Lskj.Control string printType = printRowItem["printType"] + ""; string sourceType = printRowItem["sourceType"] + ""; string printPath = PubUtil.PrintFileAbsolutelyPath70; - string modid= printRowItem["modid"] + ""; + string modid = printRowItem["modid"] + ""; if (!File.Exists(printPath)) { MessageUtil.Show(ResourceKeys.NotFoundPrintFile); @@ -4033,7 +4058,7 @@ namespace Lskj.Control tmpSqls.AddRange(tmpSql2.Split(';').ToList()); if (_printSaveParams != null && _printSaveParams.Count > 0) { - _printSaveParams[5] = tmpSql+ tmpSql1+ tmpSql2; + _printSaveParams[5] = tmpSql + tmpSql1 + tmpSql2; _printSaveParams[3] = dataRow[_printSaveParams[2]] + ""; } @@ -4087,7 +4112,35 @@ namespace Lskj.Control /// The instance containing the event data. protected void OnGridViewRightCallBack(object sender, EventArgs e) { - + try + { + int oldRowHandle = gcMain.GridView.FocusedRowHandle; + if (!(gcMain is TreeGridControlEx) && oldRowHandle < 0) return; + DataTable dt = this.gcMain.GridView.GetGridViewFilteredAndSortedDataToDataTable(); + if (gcMain is TreeGridControlEx) dt = (gcMain as TreeGridControlEx).GetGridViewDataSource(); + if (dt == null || dt.Rows.Count == 0) return; + DataRow SelectTheLine = gcMain is TreeGridControlEx ? (gcMain as TreeGridControlEx).GetViewFocusedDataRow() : dt.Rows[oldRowHandle]; + this.SearchObj.RememberRow = (this.SysModel.AccordingNameSelected == 0); + this.SearchObj.SearchLastGrid(); + if (this.SysModel.AccordingNameSelected != 0)//根据主键刷新目标选中行 + { + DataRow items = dt.Rows.Cast().FirstOrDefault(x => x[ParmaryKey].Equals(SelectTheLine[ParmaryKey])); + dt = this.gcMain.GridView.GetGridViewFilteredAndSortedDataToDataTable(); + BindingSource bindingSource = new BindingSource(); + bindingSource.DataSource = dt; + int numberOfRows = bindingSource.Find(ParmaryKey, SelectTheLine[ParmaryKey].ToString()); + this.gcMain.GridView.ClearSelection(); + this.gcMain.GridView.FocusedRowHandle = numberOfRows; + this.gcMain.GridView.SelectRow(numberOfRows); + } + if (this.RightGridCallBack != null) this.RightGridCallBack(sender, e); + if (DetailRightGridCallBack != null) this.DetailRightGridCallBack(sender, e); + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } } /// /// 说明:双击修改界面 @@ -4285,29 +4338,45 @@ namespace Lskj.Control TreeGridControlEx treeList = gcMain as TreeGridControlEx; if (this.GridControlObj != null && this.GridControlObj.AdapterObj != null) { - int result = this.GridControlObj.AdapterObj.Update(treeList.TreeListObj.DataSource as DataTable); - if (result > 0) + if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.AfterModuleDataChange, this.Model.ModuleCode, 0)) { - isExec = false; - MessageUtil.Show(ResourceKeys.SaveSuccess); - if (OnSaveGridCallBack != null) + goto IsApi; + } + if (this.SysModel.DefaultStoredProcedureSaves) + { + goto IsApi; + } + else + { + int result = this.GridControlObj.AdapterObj.Update(treeList.TreeListObj.DataSource as DataTable); + if (result > 0) { - this.OnSaveGridCallBack(sender, e); + isExec = false; + MessageUtil.Show(ResourceKeys.SaveSuccess); + if (OnSaveGridCallBack != null) + { + this.OnSaveGridCallBack(sender, e); + } } } + } } catch (Exception) { } - if (isExec) + IsApi: if (isExec) { this.SaveTreeRecord(); if (OnSaveGridCallBack != null) { this.OnSaveGridCallBack(sender, e); } + if (this.SysModel.ModifyClose && this.OnCloseCallback != null) + { + this.OnCloseCallback(null, null); + } } } else @@ -4729,6 +4798,19 @@ namespace Lskj.Control /// The e. protected void OnReportPrintAfter(object sender, EventArgs e) { + try + { + if (_printSaveParams != null && _printSaveParams.Count > 0) + { + //打印完成后添加数据库 + int result = BaseModuleImpl.SavePrintRecord(_printSaveParams[0], _printSaveParams[1], _printSaveParams[2], _printSaveParams[3], _printSaveParams[4]); + } + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } } /// @@ -4796,7 +4878,15 @@ namespace Lskj.Control /// protected void OnTsmExportClick(object sender, EventArgs e) { - + try + { + this.ExportGridRecord(); + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } } /// /// 说明:添加空行 @@ -5342,7 +5432,7 @@ namespace Lskj.Control /// public void SetDisplayColumns(string text) { - if (!this.SysModel.SearchEnable) + if (!this.SysModel.SearchEnable) { PromptBox.EditText = text; // 获取文档对象 @@ -5418,7 +5508,8 @@ namespace Lskj.Control { this.scc_container.SplitterPosition = Convert.ToInt32(htight); } - else { + else + { this.scc_container.SplitterPosition = 250; } } diff --git a/插件库/Lskj.Control/TreeBandedGridControlEx.cs b/插件库/Lskj.Control/TreeBandedGridControlEx.cs index eeccf10..23bfed3 100644 --- a/插件库/Lskj.Control/TreeBandedGridControlEx.cs +++ b/插件库/Lskj.Control/TreeBandedGridControlEx.cs @@ -93,6 +93,7 @@ namespace Lskj.Control //this.gcMain.OptionsFind.AlwaysVisible = true; } + private void TreeListObj_CustomDrawNodeIndicator(object sender, CustomDrawNodeIndicatorEventArgs e) { try @@ -1915,9 +1916,15 @@ namespace Lskj.Control /// if set to true [select row handler]. public override void SetGridViewDataSource(DataTable table, bool selectRowHandler = true) { + if (this.ColumnList == null || this.ColumnList.Count == 0) + { + this.gcMain.Bands.Clear(); + this.gcMain.Columns.Clear(); + } TreeListNode lastNode = this.TreeListObj.FocusedNode; GetTreeExpanded(); this.gcMain.DataSource = table; + this.SetAutoColumns(); //根据记录展开对应节点 foreach (TreeListNode treeListNode in treeListNodes) { @@ -1932,16 +1939,20 @@ namespace Lskj.Control public override int SetGridViewDataSource(SqlDataAdapter adapter, bool selectRowHandler = true) { if (adapter == null) return 0; + if (this.ColumnList == null || this.ColumnList.Count == 0) + { + this.gcMain.Bands.Clear(); + this.gcMain.Columns.Clear(); + } TreeListNode lastNode = this.TreeListObj.FocusedNode; this.AdapterObj = adapter; DataSet dataSet = new DataSet(); adapter.Fill(dataSet, "SetGridViewDataSource"); - SqlCommandBuilder cb = new SqlCommandBuilder(this.AdapterObj); GetTreeExpanded(); this.gcMain.DataSource = dataSet.Tables[0]; - + this.SetAutoColumns(); //根据记录展开对应节点 foreach (TreeListNode treeListNode in treeListNodes) { @@ -1957,6 +1968,10 @@ namespace Lskj.Control { this.gcMain.ExpandToLevel(0); } + else if ((Expansion + "").Equals("3")) + { + this.gcMain.CollapseAll(); + } if (selectRowHandler) { this.TreeListObj.FocusedNode = lastNode; @@ -1966,6 +1981,175 @@ namespace Lskj.Control + /// + /// 说明:设置动态列 + /// 创建人:龚宇超 + /// 创建日期:2019-06-03 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + protected virtual void SetAutoColumns() + { + try + { + bool isShowFooter = false; + if (this.ColumnList == null || this.ColumnList.Count == 0) + { + this.SuspendLayout(); + this.ResumeLayout(); + List bandEmptyRows = new List(); + List bandFields = new List(); + DataRow dr = MainImpl.GetSystemdllTab(this.Model.ModuleCode); + bool isEdit = false;//是否可操作 + if (dr != null && !(this.Model is DynamicReportModel)) + { + ModuleModel SysModel = new ModuleModel(dr); + isEdit = SysModel.CanEdit; + } + if (this is TreeBandedGridControlEx) + { + + TreeListBand gridBandEmpty = new TreeListBand(); + foreach (TreeListColumn item in gcMain.Columns) + { + //if (item.FieldName.StartsWith("|")) item.FieldName = item.FieldName.Replace("|",""); + if (item.FieldName.Contains("|")) + { + int index = item.FieldName.LastIndexOf("|"); + string bandField = item.FieldName.Substring(0, index); + if (!bandFields.Contains(bandField)) bandFields.Add(bandField); + } + else + { + bandEmptyRows.Add(item.FieldName); + } + } + foreach (string bandName in bandFields) + { + TreeListBand gridBand = new TreeListBand(); + gridBand.Caption = bandName; + gridBand.AppearanceHeader.Options.UseFont = true; + gridBand.AppearanceHeader.Font = new Font("宋体", 9, FontStyle.Bold); + gridBand.AppearanceHeader.Options.UseTextOptions = true; + gridBand.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center; + gcMain.Bands.AddRange(new TreeListBand[] { gridBand }); + //bandFields += "|" + item.BandFields; + } + if (bandEmptyRows != null && bandEmptyRows.Count() > 0) + { + // 空白列 + gridBandEmpty.Caption = ""; + gridBandEmpty.AppearanceHeader.Options.UseFont = true; + gridBandEmpty.AppearanceHeader.Font = new Font("宋体", 9, FontStyle.Bold); + gridBandEmpty.AppearanceHeader.Options.UseTextOptions = true; + gridBandEmpty.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center; + gcMain.Bands.Insert(0, gridBandEmpty); + } + gcMain.BeginUpdate(); + // 创建列 + for (int i = 0; i < gcMain.Columns.Count; i++) + { + TreeListColumn col = gcMain.Columns[i]; + int vsNum = 0; bool isNum = false; string FieldName = col.FieldName; string bandTitle = string.Empty; + col.VisibleIndex = i; + if (col.FieldName.Contains("|")) + { + string[] colSplit = col.FieldName.Split('|'); + if (colSplit.Length >= 2) + { + FieldName = colSplit[1]; + bandTitle = colSplit[0]; + } + } + if (col.VisibleIndex == 0) + { + isShowFooter = true; + + gcMain.OptionsView.ShowSummaryFooter = true; + col.AllNodesSummary = true; + col.SummaryFooter = SummaryItemType.Count; + col.SummaryFooterStrFormat = "合计:{0:#,###}行"; + + } + if (FieldName.Contains("_")) + { + string[] colparame = FieldName.Split('_'); + if (colparame.Length >= 2) + { + FieldName = colparame[0]; + isNum = Int32.TryParse(colparame[1], out vsNum); + if (vsNum == 0) + col.Visible = false; + if (colparame.Length > 2) + { + bool visible = "1".Equals(colparame[2]); + // 设置底部合计 + if (visible) + { + isShowFooter = true; + + gcMain.OptionsView.ShowSummaryFooter = true; + col.AllNodesSummary = true; + col.SummaryFooter = DevExpress.XtraTreeList.SummaryItemType.Sum; + col.SummaryFooterStrFormat = "{0:}"; + } + if (colparame.Length > 3) + { + string dataFormat = colparame[3]; + if (!string.IsNullOrWhiteSpace(dataFormat)) + { + col.Format.FormatType = FormatType.Custom; + col.Format.FormatString = dataFormat; + } + } + } + } + } + if (!string.IsNullOrEmpty(bandTitle)) + { + // 绑定了多表头显示 + TreeListBand gridBand = gcMain.Bands.Cast().FirstOrDefault(x => x.Caption == bandTitle); + if (gridBand != null) + { + gridBand.Columns.Add(col);// + TreeListBandColumnCollection gcc = gridBand.Columns; + } + gcMain.Columns.Add(col); + } + else + { + // 未绑定多表头则直接显示 + if (bandEmptyRows != null && bandEmptyRows.Contains(col.FieldName)) + { + gridBandEmpty.Columns.Add(col); + } + gcMain.Columns.Add(col); + } + if (isNum) col.Width = vsNum; + + col.OptionsColumn.AllowEdit = isEdit; + //col.FieldName = FieldName; + //col.Name = FieldName; + col.Caption = FieldName; + col.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Contains; + col.OptionsFilter.FilterPopupMode = FilterPopupMode.CheckedList; + col.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; + //gcMain.OptionsView.ShowFooter = isShowFooter; + } + gcMain.EndUpdate(); + //this.bandedGridView.DataSource = bandedGridView.DataSource as DataTable; + } + } + } + catch (Exception ex) + { + + } + + } + /// /// 记录展开的节点 @@ -2523,8 +2707,16 @@ namespace Lskj.Control /// The instance containing the event data. private void OnCustomDrawNodeCell(object sender, CustomDrawNodeCellEventArgs e) { - if (e.Node == this.gcMain.FocusedNode) - e.Appearance.BackColor = ColorTranslator.FromHtml("#9feb6a"); + try + { + if (e.Node == this.gcMain.FocusedNode) + e.Appearance.BackColor = ColorTranslator.FromHtml("#9feb6a"); + } + catch (Exception ex) + { + + } + } /// /// 粘贴功能 diff --git a/插件库/Lskj.Control/TreeGridControlEx.cs b/插件库/Lskj.Control/TreeGridControlEx.cs index 4f33658..fc564ed 100644 --- a/插件库/Lskj.Control/TreeGridControlEx.cs +++ b/插件库/Lskj.Control/TreeGridControlEx.cs @@ -2229,16 +2229,16 @@ namespace Lskj.Control public override int SetGridViewDataSource(SqlDataAdapter adapter, bool selectRowHandler = true) { if (adapter == null) return 0; + if (this.ColumnList == null || this.ColumnList.Count == 0) + { + this.gcMain.Columns.Clear(); + } lastNodeIndex = 0; if (selectRowHandler) lastNodeIndex = this.TreeListObj.GetVisibleIndexByNode(this.TreeListObj.FocusedNode); this.AdapterObj = adapter; DataSet dataSet = new DataSet(); adapter.Fill(dataSet, "SetGridViewDataSource"); - if (this.ColumnList == null || this.ColumnList.Count == 0) - { - this.gcMain.Columns.Clear(); - } SqlCommandBuilder cb = new SqlCommandBuilder(this.AdapterObj); @@ -2971,6 +2971,9 @@ namespace Lskj.Control { if (e.Node == this.gcMain.FocusedNode) e.Appearance.BackColor = ColorTranslator.FromHtml("#9feb6a"); + + + } /// /// 粘贴功能