diff --git a/.gitignore b/.gitignore index b02974c..f2f274c 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ *.zip *.rar *.7z +*.r[0-9]* # Confirmed unnecessary large files. /其他程序/工作部署记录/Smart X1 SDK V1.0.zip diff --git a/引用DLL/Lskj.Data.ADO.dll b/引用DLL/Lskj.Data.ADO.dll index 5d8c72b..08f2ab0 100644 Binary files a/引用DLL/Lskj.Data.ADO.dll and b/引用DLL/Lskj.Data.ADO.dll differ diff --git a/引用DLL/Lskj.Data.Api.dll b/引用DLL/Lskj.Data.Api.dll index 60bf317..e4a252a 100644 Binary files a/引用DLL/Lskj.Data.Api.dll and b/引用DLL/Lskj.Data.Api.dll differ diff --git a/引用DLL/Lskj.Web.Core.dll b/引用DLL/Lskj.Web.Core.dll index 410b678..eac31d7 100644 Binary files a/引用DLL/Lskj.Web.Core.dll and b/引用DLL/Lskj.Web.Core.dll differ diff --git a/引用DLL/Lskj.WebErp.Core.dll b/引用DLL/Lskj.WebErp.Core.dll index 7561c0c..e03e67a 100644 Binary files a/引用DLL/Lskj.WebErp.Core.dll and b/引用DLL/Lskj.WebErp.Core.dll differ diff --git a/插件库/Lskj.Business/Impl/MainImpl.cs b/插件库/Lskj.Business/Impl/MainImpl.cs index 05e8454..f57f2c6 100644 --- a/插件库/Lskj.Business/Impl/MainImpl.cs +++ b/插件库/Lskj.Business/Impl/MainImpl.cs @@ -293,6 +293,27 @@ namespace Lskj.Business.Impl { return false; } + } + + /// + /// 记录修改后的密码 + /// + /// + /// + /// + public static bool RecordPassword(string afterPass,string text) + { + try + { + //加密密码 + afterPass = AESUtil.Encrypt(afterPass); + LogUtil.WriteDebug("", text, afterPass, ""); + return true; + } + catch (Exception ex) + { + return false; + } } diff --git a/插件库/Lskj.Business/Impl/PowerImpl.cs b/插件库/Lskj.Business/Impl/PowerImpl.cs index 79c873d..3fa01be 100644 --- a/插件库/Lskj.Business/Impl/PowerImpl.cs +++ b/插件库/Lskj.Business/Impl/PowerImpl.cs @@ -6,6 +6,7 @@ using System.Text; using System.Data.SqlClient; using Lskj.Util; using Lskj.Model; +using Lskj.Core; namespace Lskj.Business.Impl { @@ -202,6 +203,26 @@ namespace Lskj.Business.Impl public static bool SaveRoleOperDate(string OperId, string OperName, string departemnt, string readdate, string editdate) { string sqlValue = string.Format(" if exists (select * from p_systemRoleOperSetTab s where s.operatorid='{0}' and roleId='0' ) update p_systemRoleOperSetTab set ReadPurview='{4}',EditPurview='{5}' where operatorid = '{0}' and roleId='0' ELSE insert into p_systemRoleOperSetTab (roleId,roleOperatorId,operatorid,operatorname,operatedate,department,ReadPurview,EditPurview) values ('0','{0}','{0}','{1}','{2}','{3}','{4}','{5}')", OperId, OperName, DateTime.Now, departemnt, readdate, editdate); + + if (SqlHelper.ConnectionType == ConnectionType.DmServer) + { + string dmOperId = (OperId ?? string.Empty).Replace("'", "''"); + string dmOperName = (OperName ?? string.Empty).Replace("'", "''"); + string dmDepartment = (departemnt ?? string.Empty).Replace("'", "''"); + string dmReadDate = (readdate ?? string.Empty).Replace("'", "''"); + string dmEditDate = (editdate ?? string.Empty).Replace("'", "''"); + + sqlValue = string.Format(@" + MERGE INTO p_systemRoleOperSetTab t + USING (SELECT '{0}' operatorid, '0' roleId FROM DUAL) s + ON (t.operatorid = s.operatorid AND t.roleId = s.roleId) + WHEN MATCHED THEN + UPDATE SET ReadPurview = '{3}', EditPurview = '{4}' + WHEN NOT MATCHED THEN + INSERT (roleId, roleOperatorId, operatorid, operatorname, operatedate, department, ReadPurview, EditPurview) + VALUES ('0', '{0}', '{0}', '{1}', SYSDATE, '{2}', '{3}', '{4}')", + dmOperId, dmOperName, dmDepartment, dmReadDate, dmEditDate); + } return ExecSqlValue(sqlValue) > 0; } diff --git a/插件库/Lskj.Business/Impl/SystemInfo.cs b/插件库/Lskj.Business/Impl/SystemInfo.cs index fd6bbb1..46b5594 100644 --- a/插件库/Lskj.Business/Impl/SystemInfo.cs +++ b/插件库/Lskj.Business/Impl/SystemInfo.cs @@ -16,6 +16,7 @@ using System.Xml; using Lskj.Business.Impl; using Lskj.Core; using Lskj.Model; +using Lskj.Data; namespace Lskj.Business { @@ -330,6 +331,11 @@ namespace Lskj.Business Instance.LoginUsername = item.Table.Columns.Contains("LoginUsername") && !string.IsNullOrEmpty(item["LoginUsername"] + "") ? item["LoginUsername"] + "" : ""; Instance.MainLeftShowMode = item.Table.Columns.Contains("MainLeftShowMode") && !string.IsNullOrEmpty(item["MainLeftShowMode"] + "") ? item["MainLeftShowMode"] + "" : ""; Instance.DeadlockPrompt = item.Table.Columns.Contains("DeadlockPrompt") && !string.IsNullOrEmpty(item["DeadlockPrompt"] + "") ? item["DeadlockPrompt"] + "" : ""; + Instance.SpecialAttachmentBrowser = item.Table.Columns.Contains("SpecialAttachmentBrowser") && !string.IsNullOrEmpty(item["SpecialAttachmentBrowser"] + "") ? "1".Equals(item["SpecialAttachmentBrowser"] + "") : false; + if (Instance.SpecialAttachmentBrowser) + { + ResourceDynamic.PubBrower = System.Environment.OSVersion.Version.Major == 5 && (System.Environment.OSVersion.Version.Minor == 1 || System.Environment.OSVersion.Version.Minor == 2) ? "Lskj.PubBrowerXp.dll" : "Lskj.PubBrower2.dll"; + } } /// /// 高拍仪AccessKey @@ -1154,6 +1160,10 @@ namespace Lskj.Business /// 死锁提示 /// public string DeadlockPrompt; + /// + /// 附件浏览器自带逻辑 + /// + public bool SpecialAttachmentBrowser; } } diff --git a/插件库/Lskj.Control/AuditPanelEx.Designer.cs b/插件库/Lskj.Control/AuditPanelEx.Designer.cs index 1cf15cb..231854f 100644 --- a/插件库/Lskj.Control/AuditPanelEx.Designer.cs +++ b/插件库/Lskj.Control/AuditPanelEx.Designer.cs @@ -28,7 +28,6 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); this.tabMain = new DevExpress.XtraTab.XtraTabControl(); this.tabpage_finish = new DevExpress.XtraTab.XtraTabPage(); this.gridFinish = new Lskj.Control.GridControlEx(); @@ -51,8 +50,8 @@ this.btnReverseSelection = new DevExpress.XtraEditors.SimpleButton(); this.btnSelectAll = new DevExpress.XtraEditors.SimpleButton(); this.dpb_Tools = new DevExpress.XtraEditors.DropDownButton(); - this.p_menu = new DevExpress.XtraBars.PopupMenu(this.components); - this.barManager1 = new DevExpress.XtraBars.BarManager(this.components); + this.p_menu = new DevExpress.XtraBars.PopupMenu(); + this.barManager1 = new DevExpress.XtraBars.BarManager(); this.barDockControlTop = new DevExpress.XtraBars.BarDockControl(); this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl(); this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl(); @@ -85,7 +84,7 @@ this.tabMain.Location = new System.Drawing.Point(0, 0); this.tabMain.Name = "tabMain"; this.tabMain.SelectedTabPage = this.tabpage_finish; - this.tabMain.Size = new System.Drawing.Size(1051, 683); + this.tabMain.Size = new System.Drawing.Size(1051, 701); this.tabMain.TabIndex = 20; this.tabMain.TabPages.AddRange(new DevExpress.XtraTab.XtraTabPage[] { this.tabpage_finish}); @@ -96,7 +95,7 @@ this.tabpage_finish.Controls.Add(this.splitBelow); this.tabpage_finish.Controls.Add(this.pl_top); this.tabpage_finish.Name = "tabpage_finish"; - this.tabpage_finish.Size = new System.Drawing.Size(1045, 654); + this.tabpage_finish.Size = new System.Drawing.Size(1045, 672); this.tabpage_finish.Text = "已完成单据"; // // gridFinish @@ -108,13 +107,14 @@ this.gridFinish.Margin = new System.Windows.Forms.Padding(4); this.gridFinish.Name = "gridFinish"; this.gridFinish.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; - this.gridFinish.Size = new System.Drawing.Size(1045, 322); + this.gridFinish.Size = new System.Drawing.Size(1045, 340); + this.gridFinish.SysModel = null; this.gridFinish.TabIndex = 29; // // splitBelow // this.splitBelow.Dock = System.Windows.Forms.DockStyle.Bottom; - this.splitBelow.Location = new System.Drawing.Point(0, 361); + this.splitBelow.Location = new System.Drawing.Point(0, 379); this.splitBelow.Name = "splitBelow"; this.splitBelow.Panel1.Controls.Add(this.gridFlow); this.splitBelow.Panel1.Text = "Panel1"; @@ -134,6 +134,7 @@ this.gridFlow.Name = "gridFlow"; this.gridFlow.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; this.gridFlow.Size = new System.Drawing.Size(453, 293); + this.gridFlow.SysModel = null; this.gridFlow.TabIndex = 19; // // gridDetail @@ -145,6 +146,7 @@ this.gridDetail.Name = "gridDetail"; this.gridDetail.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; this.gridDetail.Size = new System.Drawing.Size(587, 293); + this.gridDetail.SysModel = null; this.gridDetail.TabIndex = 20; // // pl_top @@ -174,6 +176,8 @@ // labeldate_start // this.labeldate_start.BackColor = System.Drawing.Color.Transparent; + this.labeldate_start.BackgroundColor = System.Drawing.Color.Empty; + this.labeldate_start.ContentBold = false; this.labeldate_start.EditText = null; this.labeldate_start.FontSize = 0F; this.labeldate_start.LabelText = "终审时间起"; @@ -190,6 +194,8 @@ // labelcheck_finalAuditor // this.labelcheck_finalAuditor.BackColor = System.Drawing.Color.Transparent; + this.labelcheck_finalAuditor.BackgroundColor = System.Drawing.Color.Empty; + this.labelcheck_finalAuditor.ContentBold = false; this.labelcheck_finalAuditor.EditText = null; this.labelcheck_finalAuditor.FontSize = 0F; this.labelcheck_finalAuditor.LabelText = "终审人"; @@ -206,6 +212,8 @@ // labeltxt_dataFlag // this.labeltxt_dataFlag.BackColor = System.Drawing.Color.Transparent; + this.labeltxt_dataFlag.BackgroundColor = System.Drawing.Color.Empty; + this.labeltxt_dataFlag.ContentBold = false; this.labeltxt_dataFlag.EditText = ""; this.labeltxt_dataFlag.FontSize = 0F; this.labeltxt_dataFlag.LabelText = "数据标识号"; @@ -233,6 +241,8 @@ // labeldate_end // this.labeldate_end.BackColor = System.Drawing.Color.Transparent; + this.labeldate_end.BackgroundColor = System.Drawing.Color.Empty; + this.labeldate_end.ContentBold = false; this.labeldate_end.EditText = null; this.labeldate_end.FontSize = 0F; this.labeldate_end.LabelText = "终审时间止"; @@ -313,9 +323,9 @@ this.pl_bottom.Controls.Add(this.label_tips); this.pl_bottom.Controls.Add(this.label_date); this.pl_bottom.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pl_bottom.Location = new System.Drawing.Point(0, 683); + this.pl_bottom.Location = new System.Drawing.Point(0, 693); this.pl_bottom.Name = "pl_bottom"; - this.pl_bottom.Size = new System.Drawing.Size(1051, 32); + this.pl_bottom.Size = new System.Drawing.Size(1051, 21); this.pl_bottom.TabIndex = 21; // // btnReverseSelection @@ -323,7 +333,7 @@ this.btnReverseSelection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnReverseSelection.Appearance.Font = new System.Drawing.Font("宋体", 9F); this.btnReverseSelection.Appearance.Options.UseFont = true; - this.btnReverseSelection.Location = new System.Drawing.Point(586, 3); + this.btnReverseSelection.Location = new System.Drawing.Point(586, -8); this.btnReverseSelection.Name = "btnReverseSelection"; this.btnReverseSelection.Size = new System.Drawing.Size(55, 26); this.btnReverseSelection.TabIndex = 13; @@ -336,7 +346,7 @@ this.btnSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnSelectAll.Appearance.Font = new System.Drawing.Font("宋体", 9F); this.btnSelectAll.Appearance.Options.UseFont = true; - this.btnSelectAll.Location = new System.Drawing.Point(647, 3); + this.btnSelectAll.Location = new System.Drawing.Point(647, -8); this.btnSelectAll.Name = "btnSelectAll"; this.btnSelectAll.Size = new System.Drawing.Size(55, 26); this.btnSelectAll.TabIndex = 12; @@ -351,7 +361,7 @@ this.dpb_Tools.Appearance.Options.UseFont = true; this.dpb_Tools.DropDownArrowStyle = DevExpress.XtraEditors.DropDownArrowStyle.Show; this.dpb_Tools.DropDownControl = this.p_menu; - this.dpb_Tools.Location = new System.Drawing.Point(888, 3); + this.dpb_Tools.Location = new System.Drawing.Point(888, -8); this.dpb_Tools.Name = "dpb_Tools"; this.dpb_Tools.Size = new System.Drawing.Size(80, 26); this.dpb_Tools.TabIndex = 11; @@ -405,7 +415,7 @@ this.btnOkAudit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnOkAudit.Appearance.Font = new System.Drawing.Font("宋体", 9F); this.btnOkAudit.Appearance.Options.UseFont = true; - this.btnOkAudit.Location = new System.Drawing.Point(708, 3); + this.btnOkAudit.Location = new System.Drawing.Point(708, -8); this.btnOkAudit.Name = "btnOkAudit"; this.btnOkAudit.Size = new System.Drawing.Size(82, 26); this.btnOkAudit.TabIndex = 7; @@ -418,7 +428,7 @@ this.btnBackAudit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnBackAudit.Appearance.Font = new System.Drawing.Font("宋体", 9F); this.btnBackAudit.Appearance.Options.UseFont = true; - this.btnBackAudit.Location = new System.Drawing.Point(796, 3); + this.btnBackAudit.Location = new System.Drawing.Point(796, -8); this.btnBackAudit.Name = "btnBackAudit"; this.btnBackAudit.Size = new System.Drawing.Size(86, 26); this.btnBackAudit.TabIndex = 6; @@ -431,7 +441,7 @@ this.btnRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnRefresh.Appearance.Font = new System.Drawing.Font("宋体", 9F); this.btnRefresh.Appearance.Options.UseFont = true; - this.btnRefresh.Location = new System.Drawing.Point(974, 3); + this.btnRefresh.Location = new System.Drawing.Point(974, -8); this.btnRefresh.Name = "btnRefresh"; this.btnRefresh.Size = new System.Drawing.Size(72, 26); this.btnRefresh.TabIndex = 5; @@ -448,7 +458,7 @@ this.Controls.Add(this.barDockControlBottom); this.Controls.Add(this.barDockControlTop); this.Name = "AuditPanelEx"; - this.Size = new System.Drawing.Size(1051, 715); + this.Size = new System.Drawing.Size(1576, 1072); ((System.ComponentModel.ISupportInitialize)(this.tabMain)).EndInit(); this.tabMain.ResumeLayout(false); this.tabpage_finish.ResumeLayout(false); diff --git a/插件库/Lskj.Control/FrmExport.cs b/插件库/Lskj.Control/FrmExport.cs index b670fd2..fae2a18 100644 --- a/插件库/Lskj.Control/FrmExport.cs +++ b/插件库/Lskj.Control/FrmExport.cs @@ -25,6 +25,7 @@ using System; using System.Collections.Generic; using System.Data; using System.Drawing; +using System.Globalization; using System.IO; using System.Linq; using System.Windows.Forms; @@ -36,6 +37,11 @@ namespace Lskj.Control /// public partial class FrmExport : Form { + /// + /// 临时导出表无法执行原表的自定义汇总逻辑,保存原表已经计算完成的总计值。 + /// + private readonly Dictionary _exportCustomSummaryValues = new Dictionary(StringComparer.OrdinalIgnoreCase); + public FrmExport() { InitializeComponent(); @@ -45,8 +51,57 @@ namespace Lskj.Control gridView1.Appearance.Row.Font = new Font("宋体", 9); gridView1.OptionsView.RowAutoHeight = true; gridView1.RowCellStyle += new RowCellStyleEventHandler(OnGridViewRowCellStyle); + gridView1.CustomSummaryCalculate += OnExportCustomSummaryCalculate; Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this); } + + /// + /// 将原表已经计算完成的自定义总计回填到临时导出表。 + /// + private void OnExportCustomSummaryCalculate(object sender, DevExpress.Data.CustomSummaryEventArgs e) + { + if (!e.IsTotalSummary || e.SummaryProcess != DevExpress.Data.CustomSummaryProcess.Finalize) + { + return; + } + + GridSummaryItem summaryItem = e.Item as GridSummaryItem; + object summaryValue; + if (summaryItem != null && !string.IsNullOrEmpty(summaryItem.FieldName) && + _exportCustomSummaryValues.TryGetValue(summaryItem.FieldName, out summaryValue)) + { + e.TotalValue = summaryValue; + e.TotalValueReady = true; + } + } + + /// + /// 百分率自定义汇总在原表中可能已经格式化为字符串,导出前还原为数值。 + /// + private static object GetExportSummaryValue(GridColumn column, GridSummaryItem summaryItem) + { + object summaryValue = summaryItem.SummaryValue; + string valueText = summaryValue as string; + string summaryFormat = summaryItem.DisplayFormat ?? string.Empty; + string columnFormat = column == null ? string.Empty : column.DisplayFormat.FormatString; + + if (string.IsNullOrWhiteSpace(valueText) || + (!summaryFormat.Contains("%") && !columnFormat.Contains("%"))) + { + return summaryValue; + } + + string percentSymbol = CultureInfo.CurrentCulture.NumberFormat.PercentSymbol; + string numericText = valueText.Replace(percentSymbol, string.Empty).Replace("%", string.Empty).Trim(); + decimal percentageValue; + if (decimal.TryParse(numericText, NumberStyles.Any, CultureInfo.CurrentCulture, out percentageValue) || + decimal.TryParse(numericText, NumberStyles.Any, CultureInfo.InvariantCulture, out percentageValue)) + { + return percentageValue / 100m; + } + + return summaryValue; + } /// /// DataTable转换成Excel文档流(导出数据量超出65535条,分sheet) /// @@ -105,10 +160,12 @@ namespace Lskj.Control /// GridControl. public BandedGridControlEx ReplaceBitColumn(BandedGridControlEx bandGridControlEx, bool IsCustomColumn = false) { + _exportCustomSummaryValues.Clear(); bool hasBoolean = false; BandedGridView gridView = bandGridControlEx.GridView as BandedGridView; BandedGridControlEx NewBandedGridControlEx = new BandedGridControlEx(); BandedGridView gridView2 = NewBandedGridControlEx.GridView as BandedGridView; + gridView2.CustomSummaryCalculate += OnExportCustomSummaryCalculate; gridView2.Columns.Clear();//默认有2个列 List boolList = new List(); List datetimeList = new List(); @@ -164,6 +221,8 @@ namespace Lskj.Control newCol.Width = col.Width; newCol.OptionsColumn.AllowEdit = col.OptionsColumn.AllowEdit; newCol.ColumnEdit = boolList.Contains(col.FieldName) || datetimeList.Contains(col.FieldName) ? null : col.ColumnEdit; + newCol.DisplayFormat.FormatType = col.DisplayFormat.FormatType; + newCol.DisplayFormat.FormatString = col.DisplayFormat.FormatString; //多表头默认都有1级标题(默认有空白表头) if (col.OwnerBand != null) @@ -377,6 +436,7 @@ namespace Lskj.Control //底部汇总是否导出 if (SystemInfo.Instance.ExportSummary) { + gridView.UpdateTotalSummary(); for (int i = 1; i < gridView2.Columns.Count; i++) { string columnName = gridView2.Columns[i].FieldName; @@ -384,6 +444,11 @@ namespace Lskj.Control GridSummaryItem gsi = gridView.Columns[columnName].SummaryItem; if (gsi.SummaryType != DevExpress.Data.SummaryItemType.None) //gsi.SummaryValue!=null&& !string.IsNullOrEmpty(gsi.SummaryValue.ToString()) { + if (gsi.SummaryType == DevExpress.Data.SummaryItemType.Custom) + { + _exportCustomSummaryValues[columnName] = GetExportSummaryValue(gridView.Columns[columnName], gsi); + } + gridView2.Columns[i].Summary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] { new DevExpress.XtraGrid.GridColumnSummaryItem(gsi.SummaryType, gridView2.Columns[i].FieldName.ToString(), gsi.DisplayFormat) }); if (SystemInfo.Instance.GroupSpecialMode) @@ -422,6 +487,7 @@ namespace Lskj.Control public GridControl ReplaceBitColumn(GridControl control, bool IsCustomColumn = false) { GridView gridView = control.FocusedView as GridView; + _exportCustomSummaryValues.Clear(); bool hasBoolean = false; List boolList = new List(); List datetimeList = new List(); @@ -481,6 +547,8 @@ namespace Lskj.Control newCol.Width = 100; newCol.OptionsColumn.AllowEdit = col.OptionsColumn.AllowEdit; newCol.ColumnEdit = boolList.Contains(col.FieldName) || datetimeList.Contains(col.FieldName) ? null : col.ColumnEdit; + newCol.DisplayFormat.FormatType = col.DisplayFormat.FormatType; + newCol.DisplayFormat.FormatString = col.DisplayFormat.FormatString; this.gridView1.Columns.Add(newCol); visibleList.Add(col.FieldName); if (gridModel != null && !dictionary.ContainsKey(col.FieldName)) @@ -733,7 +801,9 @@ namespace Lskj.Control if (firstColumn != null) { this.gridView1.OptionsView.ShowFooter = true; - firstColumn.Summary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] { new DevExpress.XtraGrid.GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Count, firstColumn.FieldName.ToString(), "合计: {0:#,###}行") }); + string firstFieldName = firstColumn.FieldName.ToString(); + _exportCustomSummaryValues[firstFieldName] = string.Format("合计: {0}行", dtTable.Rows.Count); + firstColumn.Summary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] { new DevExpress.XtraGrid.GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Custom, firstFieldName, "{0}") }); if (SystemInfo.Instance.GroupSpecialMode) { @@ -748,6 +818,7 @@ namespace Lskj.Control //底部汇总是否导出 if (SystemInfo.Instance.ExportSummary) { + gridView.UpdateTotalSummary(); for (int i = 1; i < this.gridView1.Columns.Count; i++) { string columnName = this.gridView1.Columns[i].FieldName; @@ -755,6 +826,11 @@ namespace Lskj.Control if (gsi.SummaryType != DevExpress.Data.SummaryItemType.None) //gsi.SummaryValue!=null&& !string.IsNullOrEmpty(gsi.SummaryValue.ToString()) { + if (gsi.SummaryType == DevExpress.Data.SummaryItemType.Custom) + { + _exportCustomSummaryValues[columnName] = GetExportSummaryValue(gridView.Columns[columnName], gsi); + } + string originalFormat = gsi.DisplayFormat; // 匹配 {0:#.##}、{0:0.##} 等格式 避免出现没有小数但是还有小数点的情况,如 0. try @@ -763,7 +839,7 @@ namespace Lskj.Control if (match.Success) { string innerFormat = match.Groups[1].Value; - if (innerFormat.Contains(".")) + if (innerFormat.Contains(".") && innerFormat.Split(';').Length == 1) { // 生成条件格式:正数;负数;零(整数无小数点) string newInnerFormat = $"{innerFormat};{innerFormat};{innerFormat.Split('.')[0]}"; diff --git a/插件库/Lskj.Control/GridControlEx.cs b/插件库/Lskj.Control/GridControlEx.cs index 3ec2b93..8d7db63 100644 --- a/插件库/Lskj.Control/GridControlEx.cs +++ b/插件库/Lskj.Control/GridControlEx.cs @@ -1880,6 +1880,71 @@ namespace Lskj.Control } } } + + /// + /// 行转列多表头列合计。动态列创建在独立的BandedGridView里,不能直接复用主表格的SetColumnSumming。 + /// + private void SetDynamicBandedColumnSumming(BandedGridView view, BandedGridColumn gridColumn, GridColumnModel model, ref bool isFirstVisibleColumn, bool useSimpleSum) + { + if (view == null || gridColumn == null || model == null || !gridColumn.Visible) return; + + if (isFirstVisibleColumn) + { + view.OptionsView.ShowFooter = true; + gridColumn.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Count, gridColumn.FieldName, TotalFormat) }); + if (SystemInfo.Instance.GroupSpecialMode) + { + view.OptionsView.GroupFooterShowMode = GroupFooterShowMode.VisibleAlways; + } + else + { + view.GroupSummary.AddRange(new GridSummaryItem[] { new GridGroupSummaryItem(DevExpress.Data.SummaryItemType.Count, gridColumn.FieldName, null, TotalFormat) }); + } + isFirstVisibleColumn = false; + return; + } + + if (!model.CanSum) return; + + SummaryItemType summaryType = useSimpleSum ? SummaryItemType.Sum : ((!string.IsNullOrEmpty(model.sumCalc) || !string.IsNullOrEmpty(model.SumCond) || model.isSumMerge) ? SummaryItemType.Custom : SummaryItemType.Sum); + string format = model.SumText + "{0:" + model.DataFormat + "}"; + view.OptionsView.ShowFooter = true; + gridColumn.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(summaryType, gridColumn.FieldName, format) }); + if (SystemInfo.Instance.GroupSpecialMode) + { + view.GroupSummary.Add(new GridGroupSummaryItem(summaryType, gridColumn.FieldName, gridColumn, format)); + view.OptionsView.GroupFooterShowMode = GroupFooterShowMode.VisibleAlways; + } + else + { + view.GroupSummary.AddRange(new GridSummaryItem[] { new GridGroupSummaryItem(summaryType, gridColumn.FieldName, null, format) }); + } + } + + /// + /// 行转列树形多表头列合计。TreeList使用SummaryFooter,需单独设置。 + /// + private void SetDynamicTreeColumnSumming(DevExpress.XtraTreeList.TreeList treeList, DevExpress.XtraTreeList.Columns.TreeListColumn gridColumn, GridColumnModel model, ref bool isFirstVisibleColumn) + { + if (treeList == null || gridColumn == null || model == null || !gridColumn.Visible) return; + + if (isFirstVisibleColumn) + { + treeList.OptionsView.ShowSummaryFooter = true; + gridColumn.AllNodesSummary = true; + gridColumn.SummaryFooter = DevExpress.XtraTreeList.SummaryItemType.Count; + gridColumn.RowFooterSummaryStrFormat = TotalFormat; + isFirstVisibleColumn = false; + return; + } + + if (!model.CanSum) return; + + treeList.OptionsView.ShowSummaryFooter = true; + gridColumn.AllNodesSummary = true; + gridColumn.SummaryFooter = DevExpress.XtraTreeList.SummaryItemType.Sum; + gridColumn.RowFooterSummaryStrFormat = model.SumText + "{0:" + model.DataFormat + "}"; + } /// /// 说明:创建只读列 /// 创建人:龚宇超 @@ -8738,9 +8803,12 @@ namespace Lskj.Control /* ========= 1. 清空现有列 ========= */ bandedGridControlEx.BandedView.Bands.Clear(); bandedGridControlEx.BandedView.Columns.Clear(); + bandedGridControlEx.BandedView.GroupSummary.Clear(); + bandedGridControlEx.BandedView.OptionsView.ShowFooter = false; /* ========= 2. 创建“基本信息”Band ========= */ List normalColumns = ColumnList.Where(o => o.IsCustomGroupField == 0 || o.IsCustomGroupField == 3).ToList(); + bool bandedFirstVisibleColumn = true; GridBand normalBand = new GridBand { Caption = "基本信息" }; @@ -8775,6 +8843,7 @@ namespace Lskj.Control col.AppearanceHeader.ForeColor = RequiredForceColor; } bandedGridControlEx.SetColumnFormat(col, normalCol); + SetDynamicBandedColumnSumming(bandedGridControlEx.BandedView, col, normalCol, ref bandedFirstVisibleColumn, false); normalBand.Columns.Add(col); bandedGridControlEx.BandedView.Columns.Add(col); } @@ -8835,6 +8904,7 @@ namespace Lskj.Control subColumn.AppearanceHeader.ForeColor = RequiredForceColor; } bandedGridControlEx.SetColumnFormat(subColumn, subField); + SetDynamicBandedColumnSumming(bandedGridControlEx.BandedView, subColumn, subField, ref bandedFirstVisibleColumn, true); dynamicBand.Columns.Add(subColumn); bandedGridControlEx.BandedView.Columns.Add(subColumn); } @@ -8880,9 +8950,11 @@ namespace Lskj.Control /* ========= 1. 清空现有列 ========= */ TreeBandedGridControlEx.TreeListObj.Bands.Clear(); TreeBandedGridControlEx.TreeListObj.Columns.Clear(); + TreeBandedGridControlEx.TreeListObj.OptionsView.ShowSummaryFooter = false; /* ========= 2. 创建“基本信息”Band ========= */ List normalColumns = ColumnList.Where(o => o.IsCustomGroupField == 0 || o.IsCustomGroupField == 3).ToList(); + bool treeFirstVisibleColumn = true; DevExpress.XtraTreeList.Columns.TreeListBand normalBand = new DevExpress.XtraTreeList.Columns.TreeListBand { Caption = "基本信息" }; if (this.AggregationFreeze) normalBand.Fixed = DevExpress.XtraTreeList.Columns.FixedStyle.Left; @@ -8920,6 +8992,7 @@ namespace Lskj.Control col.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; col.AppearanceHeader.Options.UseTextOptions = true; TreeBandedGridControlEx.SetColumnFormat(col, normalCol); + SetDynamicTreeColumnSumming(TreeBandedGridControlEx.TreeListObj, col, normalCol, ref treeFirstVisibleColumn); normalBand.Columns.Add(col); TreeBandedGridControlEx.TreeListObj.Columns.Add(col); } @@ -8984,6 +9057,7 @@ namespace Lskj.Control subColumn.AppearanceHeader.Options.UseTextOptions = true; TreeBandedGridControlEx.SetColumnFormat(subColumn, subField); + SetDynamicTreeColumnSumming(TreeBandedGridControlEx.TreeListObj, subColumn, subField, ref treeFirstVisibleColumn); dynamicBand.Columns.Add(subColumn); TreeBandedGridControlEx.TreeListObj.Columns.Add(subColumn); } diff --git a/插件库/Lskj.Control/LabelMultiAutoTextEdit.cs b/插件库/Lskj.Control/LabelMultiAutoTextEdit.cs index 9c85a24..cbf0a7b 100644 --- a/插件库/Lskj.Control/LabelMultiAutoTextEdit.cs +++ b/插件库/Lskj.Control/LabelMultiAutoTextEdit.cs @@ -75,6 +75,11 @@ namespace Lskj.Control /// 初始赋值 /// public string ControlValue = string.Empty; + /// + /// 保存表格属性用到的key + /// + public string CurrentOperColumnKey = string.Empty; + public LabelMultiAutoTextEdit() @@ -380,6 +385,7 @@ namespace Lskj.Control _lookUpForm.TextField = TextField; _lookUpForm.SourceSQL = SourceSQL; _lookUpForm.DataSource = dataSource; + _lookUpForm.CurrentOperColumnKey = CurrentOperColumnKey; } /// /// 说明:清空选中的值 @@ -419,6 +425,7 @@ namespace Lskj.Control _lookUpForm.EditValue = this.EditValue; _lookUpForm.IsType = Model.FieldType; _lookUpForm.EditText = this.TextEdit.Text; + _lookUpForm.CurrentOperColumnKey = CurrentOperColumnKey; string sqlValue = string.Empty; if (this.ControlObj != null) { diff --git a/插件库/Lskj.Control/Model/ControlModel.cs b/插件库/Lskj.Control/Model/ControlModel.cs index a903434..89ebf3d 100644 --- a/插件库/Lskj.Control/Model/ControlModel.cs +++ b/插件库/Lskj.Control/Model/ControlModel.cs @@ -204,7 +204,7 @@ namespace Lskj.Control.Model /// The enable cond. public string RequiredCond { get; set; } /// - /// 可以方式 + /// 禁用方式(默认禁编,设置为1就禁显) /// /// The type of the enable. public string DisableType { get; set; } diff --git a/插件库/Lskj.Control/Model/GridExtend.cs b/插件库/Lskj.Control/Model/GridExtend.cs index 40fbfdb..b98c394 100644 --- a/插件库/Lskj.Control/Model/GridExtend.cs +++ b/插件库/Lskj.Control/Model/GridExtend.cs @@ -2801,7 +2801,9 @@ namespace Lskj.Control.Model GridColumnModel model = col.Tag as GridColumnModel; if (cell != null) { - if (cell.CellType == CellType.Blank) + // DevExpress导出的xlsx空值可能是内容为空的String单元格,也应按空单元格处理。 + if (cell.CellType == CellType.Blank || + (cell.CellType == CellType.String && string.IsNullOrEmpty(cell.StringCellValue))) { //isImportRows = false; continue; @@ -3564,7 +3566,8 @@ namespace Lskj.Control.Model { string field = fields[i]; string value = rowResult.Table.Columns.Contains(field) ? rowResult[field] + "" : null; - rowItem[field] = value; + + if(rowItem.Table.Columns.Contains(field)) rowItem[field] = value; } } else @@ -3573,7 +3576,7 @@ namespace Lskj.Control.Model for (int i = 0; i < fields.Length; i++) { string field = fields[i]; - rowItem[field] = DBNull.Value; + if (rowItem.Table.Columns.Contains(field)) rowItem[field] = DBNull.Value; } } } diff --git a/插件库/Lskj.Control/Model/MenuStrip/BaseMenuStrip.cs b/插件库/Lskj.Control/Model/MenuStrip/BaseMenuStrip.cs index fc94c3d..bf3d039 100644 --- a/插件库/Lskj.Control/Model/MenuStrip/BaseMenuStrip.cs +++ b/插件库/Lskj.Control/Model/MenuStrip/BaseMenuStrip.cs @@ -173,6 +173,11 @@ namespace Lskj.Control.Model cmsMenu.Items.Add(menuItem); RightMenuItems.Add(menuItem); } + if (menuModel.FontSize != 0) + { + menuItem.Font = new Font(menuItem.Font.FontFamily, menuModel.FontSize); + } + } if (!string.IsNullOrWhiteSpace(menuModel.ExecuteFirstCode)) { @@ -304,7 +309,7 @@ namespace Lskj.Control.Model return; } - if (model.VerifyUpdate && BaseGridView!=null) + if (model.VerifyUpdate && BaseGridView != null) { for (int i = 0; i < BaseGridView.DataRowCount; i++) { @@ -502,7 +507,7 @@ namespace Lskj.Control.Model { tipOnlyOne = false; string prompt = ReplaceHelper.ReplaceRowParam(rowData, model.BeforeMsg); - if (model.Mergeexec) + if (model.Mergeexec) { //替换[],替换的是多选行中的数据 prompt = ReplaceHelper.ReplaceRowParam(rows, prompt.Replace("[", "{").Replace("]", "}"), "", ""); @@ -977,7 +982,7 @@ namespace Lskj.Control.Model case -1: if (rValue == -1) { - if (SqlHelper.ConnectionType == ConnectionType.SqlServer) + if (SqlHelper.ConnectionType == ConnectionType.SqlServer) { SqlStoredProcedurepPrompt.GenerateProcedureExecutionScript(procName, paramList, isFirstFlag, comfirmFlag); } @@ -1811,7 +1816,7 @@ namespace Lskj.Control.Model paramList[2] = ReplaceHelper.ReplaceRowParam(rows, url) + ""; } } - if (model.DllName.ToLower().Contains("p_PubPrint.lsp".ToLower())&& !model.CancelDefaultReplace) + if (model.DllName.ToLower().Contains("p_PubPrint.lsp".ToLower()) && !model.CancelDefaultReplace) { string paramsql1 = paramList[2]; paramList[2] = ReplaceHelper.ReplaceRowParam(rows, paramsql1, "'", "'"); diff --git a/插件库/Lskj.Control/Model/MenuStrip/RightMenuModel.cs b/插件库/Lskj.Control/Model/MenuStrip/RightMenuModel.cs index 65edb81..89b43d1 100644 --- a/插件库/Lskj.Control/Model/MenuStrip/RightMenuModel.cs +++ b/插件库/Lskj.Control/Model/MenuStrip/RightMenuModel.cs @@ -346,6 +346,10 @@ namespace Lskj.Control.Model /// 右键多选合并不走默认替换(p_PubPrint.lsp) /// public bool CancelDefaultReplace; + /// + /// 右键字体大小 + /// + public int FontSize; /// @@ -485,6 +489,8 @@ namespace Lskj.Control.Model this.VerifyUpdate = string.IsNullOrWhiteSpace(item["VerifyUpdate"] + "") ? false : "1".Equals(item["VerifyUpdate"] + ""); if (item.Table.Columns.Contains("CancelDefaultReplace")) this.CancelDefaultReplace = string.IsNullOrWhiteSpace(item["CancelDefaultReplace"] + "") ? false : "1".Equals(item["CancelDefaultReplace"] + ""); + + this.FontSize = item.Table.Columns.Contains("FontSize") && !string.IsNullOrEmpty(item["FontSize"] + "") ? Convert.ToInt32(item["FontSize"] + "") : 0; } /// diff --git a/插件库/Lskj.Control/Model/MessageUtil.cs b/插件库/Lskj.Control/Model/MessageUtil.cs index 37ba281..fe6fbcb 100644 --- a/插件库/Lskj.Control/Model/MessageUtil.cs +++ b/插件库/Lskj.Control/Model/MessageUtil.cs @@ -27,7 +27,43 @@ namespace Lskj.Control public sealed class MessageUtil { - public static string Prompt = string.IsNullOrWhiteSpace(SystemInfo.Instance.DeadlockPrompt) ? "网络连接超时,请稍候再试!" : SystemInfo.Instance.DeadlockPrompt; + public static string Prompt = "网络连接超时,请稍候再试!"; + + /// + /// 系统配置尚未初始化时不主动访问数据库,读取失败则使用默认死锁提示。 + /// + private static bool TryGetDeadlockPrompt(string message, out string deadlockPrompt) + { + deadlockPrompt = message; + if (string.IsNullOrEmpty(message) || !message.Contains("与另一个进程被死锁在")) + { + return false; + } + + bool promptDeadlock = false; + string configuredPrompt = string.Empty; + try + { + SystemInfo systemInfo = SystemInfo.Instance; + if (systemInfo != null) + { + promptDeadlock = systemInfo.PromptDeadlock; + configuredPrompt = systemInfo.DeadlockPrompt; + } + } + catch + { + // 数据库连接失败或系统参数尚未初始化时,提示框仍使用安全默认值。 + } + + if (promptDeadlock) + { + return false; + } + + deadlockPrompt = string.IsNullOrWhiteSpace(configuredPrompt) ? Prompt : configuredPrompt; + return true; + } /// @@ -54,8 +90,9 @@ namespace Lskj.Control } } - if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在")&& !SystemInfo.Instance.PromptDeadlock) - msg = Prompt; + string deadlockPrompt; + if (TryGetDeadlockPrompt(msg, out deadlockPrompt)) + msg = deadlockPrompt; if (Business.Impl.LanguageTranslation.Translatable) { msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg); @@ -89,9 +126,10 @@ namespace Lskj.Control } } - if (!string.IsNullOrEmpty(errorMessage) && errorMessage.Contains("与另一个进程被死锁在") && !SystemInfo.Instance.PromptDeadlock) + string deadlockPrompt; + if (TryGetDeadlockPrompt(errorMessage, out deadlockPrompt)) { - errorMessage = Prompt; + errorMessage = deadlockPrompt; if (Business.Impl.LanguageTranslation.Translatable) { errorMessage = Business.Impl.LanguageTranslation.GetTranslatedText(errorMessage); @@ -165,8 +203,9 @@ namespace Lskj.Control if (Debugger.IsAttached) { string msg = ex == null ? ResourceKeys.UnKownErrorTip : ex.StackTrace; - if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在") && !SystemInfo.Instance.PromptDeadlock) - msg = Prompt; + string deadlockPrompt; + if (TryGetDeadlockPrompt(msg, out deadlockPrompt)) + msg = deadlockPrompt; if (Business.Impl.LanguageTranslation.Translatable) { msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg); @@ -176,8 +215,9 @@ namespace Lskj.Control else { string msg = ex == null ? ResourceKeys.UnKownErrorTip : ex.Message; //ResourceKeys.SystemErrorTip + "\r\n" + ex.Message + "\r\n" + ex.StackTrace; - if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在") && !SystemInfo.Instance.PromptDeadlock) - msg = Prompt; + string deadlockPrompt; + if (TryGetDeadlockPrompt(msg, out deadlockPrompt)) + msg = deadlockPrompt; if (Business.Impl.LanguageTranslation.Translatable) { msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg); diff --git a/插件库/Lskj.Control/Model/MyControl.cs b/插件库/Lskj.Control/Model/MyControl.cs index 2558f5d..2f1d084 100644 --- a/插件库/Lskj.Control/Model/MyControl.cs +++ b/插件库/Lskj.Control/Model/MyControl.cs @@ -4615,6 +4615,7 @@ namespace Lskj.Control.Model multiAutoEdit.ValueField = model.ValueMember; multiAutoEdit.TextField = model.TextMember; multiAutoEdit.ControlObj = this; + multiAutoEdit.CurrentOperColumnKey= Model.ModuleCode + "_" + model.FieldName; //multiAutoEdit.SetDataSource(dataSource); multiAutoEdit.TextBoxProhibition = model.TextBoxProhibition; multiAutoEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown); diff --git a/插件库/Lskj.Control/ModuleEx.cs b/插件库/Lskj.Control/ModuleEx.cs index 67aa022..4dc7ac1 100644 --- a/插件库/Lskj.Control/ModuleEx.cs +++ b/插件库/Lskj.Control/ModuleEx.cs @@ -31,7 +31,6 @@ using FastReport; using DevExpress.XtraGrid.Views.BandedGrid; using System.Diagnostics; using Lskj.Core; -using System.Text.RegularExpressions; using Lskj.Business; using DevExpress.XtraTreeList.Nodes; using DevExpress.XtraTreeList; @@ -680,8 +679,35 @@ namespace Lskj.Control // this.ModuleGridObj.InitlizeSpiltLocation(); //} this.ModuleGridObj.SearchObj.SearchGrid(sqlValue); - if (!this.IsDragDetail) - this.ModuleGridDetailObj.SetDetailGridDataSource(); + if (!this.IsDragDetail) + { + bool enter = false; + + try + { + if (this.ModuleGridObj != null) + { + DataRow rowItem = this.ModuleGridObj.GridControlObj.GetViewFocusedDataRow(); + if (this.ModuleGridObj.GridControlObj.CustomGroupSelectedRow != null) + { + rowItem = this.ModuleGridObj.GridControlObj.CustomGroupSelectedRow; + } + if (rowItem != null&& !this.SysModel.DoubleClickDetail) enter = true; + } + } + catch (Exception ex) + { + + } + //enter判断 2026-7-24 添加 因为主表有行改版后事件,主表赋值后会刷新一次,这里是重复刷新(方法里有判断,主表有值执行的逻辑是相同的) + //如果是主表有数据,并且绑定了行改变事件,就执行了(重复执行) + //如果主表没有数据,就执行(清空明细) 或者绑定的是双击加载明细事件也执行(节点改变后刷新主表,顺便刷新明细) + if (!enter) + { + this.ModuleGridDetailObj.SetDetailGridDataSource(); + } + } + if (this.treeGridLeft.Visible && ModuleGridDetailObj.GridDetailList != null && ModuleGridDetailObj.GridDetailList.Count > 0) { this.ModuleGridDetailObj.scc_container.PanelVisibility = this.ModuleGridObj.GridControlObj.DataRowCount() == 0 ? SplitPanelVisibility.Panel1 : SplitPanelVisibility.Both; @@ -1851,16 +1877,81 @@ namespace Lskj.Control } /// - /// 判断是否是selete开头(可以处理sql前方有注释和空格的情况) + /// 判断有效SQL是否以select开头(忽略前方空格、BOM和注释) /// /// /// public static bool IsSelectAtStart(string sqlText) { - // Remove comments and whitespace at the start of the text - string cleanedText = Regex.Replace(sqlText, @"^(\s*--.*?(\r\n|\n)|\s*)*", ""); - // Check if the remaining text starts with 'select' - return cleanedText.StartsWith("select", StringComparison.OrdinalIgnoreCase); + if (string.IsNullOrEmpty(sqlText)) + { + return false; + } + + int index = 0; + while (index < sqlText.Length) + { + while (index < sqlText.Length && + (char.IsWhiteSpace(sqlText[index]) || sqlText[index] == '\uFEFF')) + { + index++; + } + + // 跳过SQL开头连续出现的单行注释。 + if (index + 1 < sqlText.Length && sqlText[index] == '-' && sqlText[index + 1] == '-') + { + index += 2; + while (index < sqlText.Length && sqlText[index] != '\r' && sqlText[index] != '\n') + { + index++; + } + continue; + } + + // 跳过块注释,同时兼容SQL Server支持的嵌套块注释。 + if (index + 1 < sqlText.Length && sqlText[index] == '/' && sqlText[index + 1] == '*') + { + index += 2; + int commentDepth = 1; + while (index < sqlText.Length && commentDepth > 0) + { + if (index + 1 < sqlText.Length && sqlText[index] == '/' && sqlText[index + 1] == '*') + { + commentDepth++; + index += 2; + } + else if (index + 1 < sqlText.Length && sqlText[index] == '*' && sqlText[index + 1] == '/') + { + commentDepth--; + index += 2; + } + else + { + index++; + } + } + + if (commentDepth > 0) + { + return false; + } + continue; + } + + break; + } + + const string selectKeyword = "select"; + if (index + selectKeyword.Length > sqlText.Length || + string.Compare(sqlText, index, selectKeyword, 0, selectKeyword.Length, + StringComparison.OrdinalIgnoreCase) != 0) + { + return false; + } + + int nextIndex = index + selectKeyword.Length; + return nextIndex == sqlText.Length || + (!char.IsLetterOrDigit(sqlText[nextIndex]) && sqlText[nextIndex] != '_'); } @@ -2000,4 +2091,4 @@ namespace Lskj.Control } } -} \ No newline at end of file +} diff --git a/插件库/Lskj.Control/MultiGridLookUp/FrmLookUp.cs b/插件库/Lskj.Control/MultiGridLookUp/FrmLookUp.cs index feb9b96..d407e34 100644 --- a/插件库/Lskj.Control/MultiGridLookUp/FrmLookUp.cs +++ b/插件库/Lskj.Control/MultiGridLookUp/FrmLookUp.cs @@ -186,6 +186,8 @@ namespace Lskj.Control.MultiGridLookUp this.Location = new Point((SystemInformation.PrimaryMonitorSize.Width - this.Width) / 2, (SystemInformation.PrimaryMonitorSize.Height - this.Height) / 2); } + // 自动列宽和弹窗尺寸计算完成后,最后应用个性化列配置,避免配置被覆盖。 + this.SetCustomColumns(); } /// /// 说明:计算控件Size,只计算一次 @@ -374,7 +376,6 @@ namespace Lskj.Control.MultiGridLookUp } } } - SetCustomColumns(); this.gcDetail.GridControl.DataSource = this.gridControl1.DataSourceTable().Clone(); this.gcMain.BestFitColumns(); //this.gcDetail.SelectAll(); @@ -397,28 +398,53 @@ namespace Lskj.Control.MultiGridLookUp DataTable customTable = this.gcMain.GetCustomColumnByDatabase(this.CurrentOperColumnKey); if (customTable != null && customTable.Rows.Count > 0) { - foreach (DataRow rowItem in customTable.Rows) + this.gcMain.BeginUpdate(); + this.gcDetail.BeginUpdate(); + try { - string fieldName = rowItem["fieldName"] + ""; - int fieldWidth = Convert.ToInt32(rowItem["fieldWidth"]); - int index = Convert.ToInt32(rowItem["orderid"]); - bool visible = "1".Equals(rowItem["isVisible"] + "") && fieldWidth > 0; - bool isFix = "True".Equals(rowItem["IfFixColumn"] + "", StringComparison.OrdinalIgnoreCase); - - GridColumn gridColumn = this.gcMain.Columns.ColumnByName(fieldName); - if (gridColumn != null && gridColumn.Visible && gridColumn.Width > 0) + foreach (DataRow rowItem in customTable.Rows) { - GridColumn colObj = this.gcMain.Columns[fieldName]; - colObj.VisibleIndex = index; - colObj.Width = fieldWidth; - colObj.Visible = visible; - colObj.Fixed = isFix ? FixedStyle.Left : FixedStyle.None; - colObj.OptionsFilter.FilterPopupMode = FilterPopupMode.CheckedList; + string fieldName = rowItem["fieldName"] + ""; + int fieldWidth = Convert.ToInt32(rowItem["fieldWidth"]); + int index = Convert.ToInt32(rowItem["orderid"]); + bool visible = "1".Equals(rowItem["isVisible"] + "") && fieldWidth > 0; + bool isFix = "True".Equals(rowItem["IfFixColumn"] + "", StringComparison.OrdinalIgnoreCase); + + SetCustomColumn(this.gcMain.Columns.ColumnByName(fieldName), fieldWidth, index, visible, isFix); + SetCustomColumn(this.gcDetail.Columns.ColumnByName(fieldName), fieldWidth, index, visible, isFix); } } + finally + { + this.gcDetail.EndUpdate(); + this.gcMain.EndUpdate(); + } } } + /// + /// 应用单列的个性化布局。 + /// + private static void SetCustomColumn(GridColumn column, int width, int visibleIndex, bool visible, bool isFix) + { + if (column == null) + { + return; + } + + column.Visible = visible; + if (visible) + { + column.VisibleIndex = visibleIndex; + } + if (width > 0) + { + column.Width = width; + } + column.Fixed = isFix ? FixedStyle.Left : FixedStyle.None; + column.OptionsFilter.FilterPopupMode = FilterPopupMode.CheckedList; + } + /// /// 说明:设置默认选中 /// 创建人:龚宇超 diff --git a/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp.cs b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp.cs index d5943f7..21417c3 100644 --- a/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp.cs +++ b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp.cs @@ -1028,7 +1028,11 @@ namespace Lskj.Control.MultiModelLookUp this.SysModel = new ModuleModel(modelRow);// 系统模块实体对象 if (this.SysModel != null) { - + if (this.SysModel.ModuleFrameHeight > 0 && this.SysModel.ModuleFrameWidth > 0) + { + this.Height = this.SysModel.ModuleFrameHeight; + this.Width = this.SysModel.ModuleFrameWidth; + } switch (this.SysModel.MenuType) { diff --git a/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp2.cs b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp2.cs index 4b98950..1c7019b 100644 --- a/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp2.cs +++ b/插件库/Lskj.Control/MultiModelLookUp/FrmModelLookUp2.cs @@ -1121,6 +1121,12 @@ namespace Lskj.Control.MultiModelLookUp this.SysModel = new ModuleModel(modelRow);// 系统模块实体对象 if (this.SysModel != null) { + if (this.SysModel.ModuleFrameHeight > 0 && this.SysModel.ModuleFrameWidth > 0) + { + this.Height = this.SysModel.ModuleFrameHeight; + this.Width = this.SysModel.ModuleFrameWidth; + } + switch (this.SysModel.MenuType) diff --git a/插件库/Lskj.Control/TreeGridControlEx.cs b/插件库/Lskj.Control/TreeGridControlEx.cs index 569348c..2b73bf2 100644 --- a/插件库/Lskj.Control/TreeGridControlEx.cs +++ b/插件库/Lskj.Control/TreeGridControlEx.cs @@ -79,6 +79,29 @@ namespace Lskj.Control /// public string SortField; + /// + /// 是否使用按层级分段的新版节点编号;默认false,保持老版整数节点号规则。 + /// + public bool UseSegmentedNodeId { get; set; } + + /// + /// 是否启用单据树表格粘贴;启用后粘贴内容作为新节点添加,不覆盖已有行。 + /// + public bool BillPaste { get; set; } + + // 记录单据粘贴是否应从一级节点开始,避免通过清空TreeList选择状态来表达粘贴位置。 + private bool _billPasteAsRoot; + + private int _treeNumberNodes = 2; + /// + /// 每级节点编号占用的位数,最小为2位。 + /// + public int TreeNumberNodes + { + get { return _treeNumberNodes; } + set { _treeNumberNodes = value < 2 ? 2 : value; } + } + /// /// 上次选中行 /// @@ -156,10 +179,36 @@ namespace Lskj.Control private void GcMain_MouseDown(object sender, MouseEventArgs e) { + TreeList treeList = sender as TreeList; + if (treeList == null) + { + return; + } + + if (e.Button == MouseButtons.Left) + { + TreeListHitInfo mouseHitInfo = treeList.CalcHitInfo(e.Location); + + if (BillPaste) + { + // 点击空白区域时后续粘贴为一级节点,不改动TreeList内部的选中集合。 + _billPasteAsRoot = mouseHitInfo.HitInfoType == HitInfoType.Empty; + } + + if (treeList.OptionsSelection.MultiSelect && + treeList.OptionsSelection.MultiSelectMode == TreeListMultiSelectMode.CellSelect && + (mouseHitInfo.HitInfoType == HitInfoType.RowIndicator || mouseHitInfo.HitInfoType == HitInfoType.RowIndicatorEdge) && + treeList.FocusedColumn == null && treeList.VisibleColumns.Count > 0) + { + // DevExpress 15.2在单元格多选模式下重复点击行序号时会清空FocusedColumn, + // 后续点击会将null列传给IsCellSelected并触发“参数名:key”异常。 + treeList.FocusedColumn = treeList.VisibleColumns[0]; + } + } + if (isEditing) return; // 编辑中不处理折叠 - TreeList treeList = sender as TreeList; - if (treeList == null || e.Clicks != 2 || e.Button != MouseButtons.Left) + if (e.Clicks != 2 || e.Button != MouseButtons.Left) return; TreeListHitInfo hitInfo = treeList.CalcHitInfo(e.Location); @@ -2312,6 +2361,24 @@ namespace Lskj.Control } else if (e.Modifiers.CompareTo(Keys.Control) == 0 && e.KeyCode == Keys.V) { + if (this.BillPaste) + { + // 单据树表格粘贴始终新增节点,不进入下方按可见行覆盖数据的通用粘贴逻辑。 + if (!SystemInfo.Instance.CancelPasteClearSort) + { + this.TreeListObj.ClearSorting(); + } + + object billPasteData = null; + IDataObject billDataObj = Clipboard.GetDataObject(); + if (billDataObj != null && billDataObj.GetDataPresent(DataFormats.Text)) + { + billPasteData = billDataObj.GetData(DataFormats.Text); + } + BillPasteMethod(e, billPasteData); + return; + } + //if (this.gridView.IsFindPanelVisible) //{ // MessageUtil.Show("搜索模式下无法粘贴行."); @@ -3258,6 +3325,314 @@ namespace Lskj.Control } + /// + /// 单据树表格粘贴。先将剪贴板内容转换为临时表,再统一设置父节点和节点号并追加到数据源。 + /// + /// 键盘事件,用于阻止系统继续处理本次粘贴。 + /// 剪贴板中的制表符分隔文本。 + private void BillPasteMethod(KeyEventArgs e, object clipboardData) + { + if (clipboardData == null) + { + return; + } + + DataTable sourceTable = this.GetGridViewDataSource(); + if (sourceTable == null || this.TreeListObj.VisibleColumns.Count == 0 || + !sourceTable.Columns.Contains(this.TreeListObj.KeyFieldName) || + !sourceTable.Columns.Contains(this.TreeListObj.ParentFieldName)) + { + return; + } + + TreeListColumn focusedColumn = this.TreeListObj.FocusedColumn; + if (focusedColumn == null || focusedColumn.VisibleIndex < 0) + { + focusedColumn = this.TreeListObj.VisibleColumns[0]; + } + + string pasteText = clipboardData.ToString(); + pasteText = Regex.Replace(pasteText, "\"[^\"]*(?:\"\"[^\"]*)*\"", m => m.Value.Replace("\r\n", "{lskj}").Replace("\"", "")); + string[] pasteRows = pasteText.Split(new string[] { "\r\n" }, StringSplitOptions.None); + DataTable pasteTable = sourceTable.Clone(); + int startColumnIndex = sourceTable.Rows.Count == 0 ? 0 : focusedColumn.VisibleIndex; + + for (int i = 0; i < pasteRows.Length; i++) + { + if (i == pasteRows.Length - 1 && pasteRows[i].Trim().Length == 0) + { + continue; + } + + string[] pasteCells = IgnoreTab ? new string[] { pasteRows[i] } : pasteRows[i].Split('\t'); + DataRow pasteRow = pasteTable.NewRow(); + SetBillPasteDefaultValues(pasteRow); + + int columnIndex = startColumnIndex; + for (int j = 0; j < pasteCells.Length && columnIndex < this.TreeListObj.VisibleColumns.Count; j++, columnIndex++) + { + TreeListColumn column = this.TreeListObj.VisibleColumns[columnIndex]; + GridColumnModel model = column.Tag as GridColumnModel; + if (model == null || model.ProhibitPaste || + (!model.CanCopy && (!this.TreeListObj.OptionsBehavior.Editable || !column.OptionsColumn.AllowEdit))) + { + continue; + } + + if (!string.IsNullOrWhiteSpace(model.DisableCond)) + { + string updateCond = model.DisableCond; + if (this.ParentControl != null) + { + updateCond = this.ParentControl.ReplaceParentControlValue(updateCond); + } + updateCond = ReplaceHelper.ReplaceRowParam(pasteRow, updateCond); + if (!ReplaceHelper.EvalCond(updateCond)) + { + continue; + } + } + + SetBillPasteCellValue(pasteRow, column, model, pasteCells[j]); + } + + SetBillPasteLengthErrors(pasteRow); + pasteTable.Rows.Add(pasteRow); + } + + if (pasteTable.Rows.Count == 0) + { + e.Handled = true; + return; + } + + TreeListNode parentNode = _billPasteAsRoot ? null : this.TreeListObj.FocusedNode; + DataRow parentRow = this.GetViewSpecifyDataRow(parentNode); + string parentNodeId = parentRow == null ? "0" : parentRow[this.TreeListObj.KeyFieldName] + ""; + if (string.IsNullOrWhiteSpace(parentNodeId)) + { + parentNodeId = "0"; + } + + if (UseSegmentedNodeId) + { + // 保留剪贴板中的节点号和父节点号,按原父子关系整体映射到当前选中节点下。 + pasteTable = PrepareNodeIdsForInsert(pasteTable, parentNodeId); + } + else + { + PrepareOldNodeIdsForInsert(pasteTable, parentNodeId); + } + + object lastNodeId = null; + foreach (DataRow pasteRow in pasteTable.Rows) + { + DataRow newRow = sourceTable.NewRow(); + foreach (DataColumn column in sourceTable.Columns) + { + if (column.AutoIncrement || column.ReadOnly || !string.IsNullOrEmpty(column.Expression)) + { + continue; + } + newRow[column.ColumnName] = pasteRow[column.ColumnName]; + } + sourceTable.Rows.Add(newRow); + lastNodeId = newRow[this.TreeListObj.KeyFieldName]; + } + + this.TreeListObj.RefreshDataSource(); + if (parentNode != null) + { + parentNode.Expanded = true; + } + DataSourceSorting(); + if (UseSegmentedNodeId) + { + // 新版节点号必须与最终界面顺序一致,追加完成后再统一整理一次。 + RenumberNodeIds(); + } + + if (lastNodeId != null) + { + TreeListNode lastNode = this.TreeListObj.FindNodeByKeyID(lastNodeId); + if (lastNode != null) + { + this.TreeListObj.FocusedNode = lastNode; + } + } + this.TreeListObj.ShowEditor(); + e.Handled = true; + } + + /// + /// 按普通表格粘贴规则,为新增粘贴行设置列默认值和父控件参数默认值。 + /// + /// 待填充的临时粘贴行。 + private void SetBillPasteDefaultValues(DataRow row) + { + foreach (TreeListColumn column in this.TreeListObj.Columns) + { + GridColumnModel model = column.Tag as GridColumnModel; + if (model == null || !row.Table.Columns.Contains(column.FieldName)) + { + continue; + } + + string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue); + if (!string.IsNullOrEmpty(model.DefaultValue) && model.DefaultValue.Contains("{#") && this.ParentControl != null) + { + fieldValue = this.ParentControl.ReplaceParentControlValue(model.DefaultValue); + if (!string.IsNullOrEmpty(fieldValue)) + { + row[column.FieldName] = fieldValue; + } + } + else if (!string.IsNullOrEmpty(model.DefaultValue) && !model.DefaultValue.Contains("{ROW_")) + { + row[column.FieldName] = fieldValue; + } + } + } + + /// + /// 将单个剪贴板文本转换为列的实际保存值,并处理下拉框、模块返回框、日期和数值类型校验。 + /// + /// 待赋值的临时粘贴行。 + /// 目标树表格列。 + /// 目标列配置。 + /// 剪贴板中的显示文本。 + private void SetBillPasteCellValue(DataRow row, TreeListColumn column, GridColumnModel model, string pasteValue) + { + string cellValue = string.IsNullOrEmpty(pasteValue) ? pasteValue : pasteValue.Replace("{lskj}", "\n"); + bool isTextEqualValue = false; + object value = ControlType.IsValue(model.FieldType) ? GetValueByCaption(model, column.ColumnEdit, cellValue, out isTextEqualValue) : cellValue; + value = model.FieldType == 14 ? ReplaceMultiSpace(value) : value; + + if (model.FieldType == 17) + { + value = value.Equals("非校验") ? 0 : value.Equals("校验") ? 1 : value; + if (value.Equals("不确定")) + { + return; + } + } + + if (model.FieldType == 116 || model.FieldType == 117 || model.FieldType == 160 || model.FieldType == 161) + { + value = ModuleReturnVerify(model, column.ColumnEdit, cellValue, out isTextEqualValue); + if (!isTextEqualValue && cellValue == value + "") + { + return; + } + } + + DateTime dateValue; + if (!isTextEqualValue && ((ControlType.IsValue(model.FieldType) && cellValue == value + "") || + (ControlType.LabTextInt == model.FieldType && (value + "").IsChinese()) || + (ControlType.IsDate(model.FieldType) && !DateTime.TryParse(value + "", out dateValue)))) + { + return; + } + + if (string.IsNullOrEmpty(value + "")) + { + if (!string.IsNullOrWhiteSpace(row[column.FieldName] + "")) + { + return; + } + + string columnType = column.ColumnType.Name.ToLower(); + if (columnType == "string" || columnType.IndexOf("char") >= 0) + row[column.FieldName] = ""; + else if (columnType.IndexOf("int") >= 0 || columnType == "decimal") + row[column.FieldName] = 0; + } + else + { + row[column.FieldName] = value; + } + } + + /// + /// 检查粘贴行的文本字节长度,超出列配置限制时在DataRow上记录列错误。 + /// + /// 已完成字段转换的临时粘贴行。 + private void SetBillPasteLengthErrors(DataRow row) + { + foreach (TreeListColumn column in this.TreeListObj.Columns) + { + GridColumnModel model = column.Tag as GridColumnModel; + if (model == null || model.LimitLength <= 0 || !row.Table.Columns.Contains(column.FieldName)) + { + continue; + } + + int inputLength = Encoding.Default.GetBytes(row[column.FieldName] + "").Length; + if (inputLength > model.LimitLength) + { + row.SetColumnError(row.Table.Columns[column.FieldName], "当前输入文本超过设定长度!"); + } + } + } + + /// + /// 按老版整数节点号规则迁移一批粘贴数据,同时保留这批数据内部的父子关系。 + /// 数值型来源节点号沿用原来的整体偏移方式;非数值或空节点号从当前最大节点号继续生成。 + /// + /// 已从剪贴板转换完成、尚未加入主数据源的临时表。 + /// 整批粘贴数据要插入到的目标父节点号。 + private void PrepareOldNodeIdsForInsert(DataTable pasteTable, string targetParentNodeId) + { + string keyFieldName = this.TreeListObj.KeyFieldName; + string parentFieldName = this.TreeListObj.ParentFieldName; + int nextNodeId = int.Parse(GetNewNodesId()); + int nodeOffset = nextNodeId - 1; + Dictionary nodeIdMap = new Dictionary(StringComparer.Ordinal); + HashSet usedNodeIds = new HashSet(); + + // 第一遍只生成新节点号,并记录来源节点号到新节点号的映射,父节点在第二遍统一处理。 + foreach (DataRow row in pasteTable.Rows) + { + string sourceNodeId = (row[keyFieldName] + "").Trim(); + + int sourceNumber; + int mappedNodeId; + if (!string.IsNullOrEmpty(sourceNodeId) && !nodeIdMap.ContainsKey(sourceNodeId) && + int.TryParse(sourceNodeId, out sourceNumber) && sourceNumber > 0) + { + mappedNodeId = sourceNumber + nodeOffset; + } + else + { + mappedNodeId = nextNodeId; + } + + while (usedNodeIds.Contains(mappedNodeId)) + { + mappedNodeId++; + } + + usedNodeIds.Add(mappedNodeId); + nextNodeId = Math.Max(nextNodeId, mappedNodeId + 1); + row[keyFieldName] = mappedNodeId; + if (!string.IsNullOrEmpty(sourceNodeId) && !nodeIdMap.ContainsKey(sourceNodeId)) + { + nodeIdMap.Add(sourceNodeId, mappedNodeId); + } + } + + // 只有父节点也包含在本次粘贴数据中时才保留层级,否则该行直接挂到目标父节点下。 + foreach (DataRow row in pasteTable.Rows) + { + string sourceParentNodeId = (row[parentFieldName] + "").Trim(); + int mappedParentNodeId; + row[parentFieldName] = !string.IsNullOrEmpty(sourceParentNodeId) && sourceParentNodeId != "0" && + nodeIdMap.TryGetValue(sourceParentNodeId, out mappedParentNodeId) + ? mappedParentNodeId + "" + : targetParentNodeId; + } + } + /// /// 粘贴功能 /// @@ -3450,31 +3825,50 @@ namespace Lskj.Control /// 传入的数据源 public void SetGridViewDataSourceGenerateID(DataTable table) { - DataRow[] dataRows = table.Rows.Cast().Where(x => string.IsNullOrWhiteSpace(x[TreeListObj.KeyFieldName] + "")).ToArray(); - - //传入的表格全部没有节点id,生成id后设置为数据源 - if (table.Rows.Count == dataRows.Length) + if (UseSegmentedNodeId) { - int i = 1; - foreach (DataRow item in table.Rows) - { - item[TreeListObj.KeyFieldName] = i; - i++; - } + table = EnsureSegmentedNodeColumnTypes(table); + AssignMissingSegmentedNodeIds(table); this.SetGridViewDataSource(table); + RenumberNodeIds(); } else { - DataRow[] AlreadyExistsRow = table.Rows.Cast().Where(x => !string.IsNullOrWhiteSpace(x[TreeListObj.KeyFieldName] + "")).ToArray(); - int maxid = int.Parse(AlreadyExistsRow.Cast().Max(n => n[TreeListObj.KeyFieldName]) + "") + 1; - //没有节点id的行赋值当前最大id - foreach (DataRow item in dataRows) + DataRow[] dataRows = table.Rows.Cast().Where(x => string.IsNullOrWhiteSpace(x[TreeListObj.KeyFieldName] + "")).ToArray(); + + //传入的表格全部没有节点id,生成id后设置为数据源 + if (table.Rows.Count == dataRows.Length) { - item[TreeListObj.KeyFieldName] = maxid + ""; - maxid++; + int i = 1; + foreach (DataRow item in table.Rows) + { + item[TreeListObj.KeyFieldName] = i; + i++; + } + this.SetGridViewDataSource(table); + } + else + { + DataRow[] AlreadyExistsRow = table.Rows.Cast().Where(x => !string.IsNullOrWhiteSpace(x[TreeListObj.KeyFieldName] + "")).ToArray(); + int maxid = int.Parse(AlreadyExistsRow.Cast().Max(n => n[TreeListObj.KeyFieldName]) + "") + 1; + //没有节点id的行赋值当前最大id + foreach (DataRow item in dataRows) + { + item[TreeListObj.KeyFieldName] = maxid + ""; + maxid++; + } + this.SetGridViewDataSource(table); } - this.SetGridViewDataSource(table); } + + SetTreeExpansion(); + } + + /// + /// 数据源重新绑定后,根据Expansion配置恢复树节点的展开状态。 + /// + private void SetTreeExpansion() + { if ((Expansion + "").Equals("1")) { this.TreeListObj.ExpandAll(); @@ -3490,13 +3884,79 @@ namespace Lskj.Control } /// - /// 获取新增节点id + /// 获取新增一级节点号;新版从一级节点分段继续编号,老版取最大整数节点号加一。 /// - /// + /// 可用于新增一级节点的节点号。 public string GetNewNodesId() + { + if (UseSegmentedNodeId) + { + return GetNewNodesId("0"); + } + + return GetOldNewNodesId(); + } + + /// + /// 根据父节点获取新增节点号;老版模式忽略父节点并继续使用最大整数节点号。 + /// + /// 目标父节点号,0或空字符串表示一级节点。 + /// 目标层级中下一个可用节点号。 + public string GetNewNodesId(string parentNodeId) + { + if (!UseSegmentedNodeId) + { + return GetOldNewNodesId(); + } + + DataTable gridTable = this.TreeListObj.DataSource as DataTable; + return GetNewNodesId(parentNodeId, gridTable); + } + + /// + /// 根据指定数据源和父节点获取新增节点号,用于尚未绑定到TreeList的批量新增数据。 + /// + /// 目标父节点号,0或空字符串表示一级节点。 + /// 参与计算现有节点号的数据源。 + /// 目标层级中下一个可用节点号。 + public string GetNewNodesId(string parentNodeId, DataTable dataTable) + { + if (!UseSegmentedNodeId) + { + return GetOldNewNodesId(); + } + + int sequence = GetNextNodeSequence(dataTable, parentNodeId); + return BuildSegmentedNodeId(parentNodeId, sequence); + } + + /// + /// 获取指定父节点下最后一个节点号,供新增主节点后继续追加关联子数据使用。 + /// + /// 目标父节点号。 + /// 最后一个同级节点号;该层级没有节点时返回空字符串。 + public string GetLastNodesId(string parentNodeId) + { + if (!UseSegmentedNodeId) + { + int nodeId; + return int.TryParse(GetOldNewNodesId(), out nodeId) ? (nodeId - 1) + "" : ""; + } + + DataTable gridTable = this.TreeListObj.DataSource as DataTable; + int sequence = GetNextNodeSequence(gridTable, parentNodeId) - 1; + return sequence > 0 ? BuildSegmentedNodeId(parentNodeId, sequence) : ""; + } + + /// + /// 按老版规则获取全表最大整数节点号加一。 + /// + /// 下一个可用的老版整数节点号。 + private string GetOldNewNodesId() { int id = 1; - DataTable gridTable = (this.TreeListObj.DataSource as DataTable).TrimDeleteRows(); + DataTable dataSource = this.TreeListObj.DataSource as DataTable; + DataTable gridTable = dataSource == null ? null : dataSource.TrimDeleteRows(); //获取表里最大的节点id if (gridTable != null && gridTable.Rows.Count > 0) { @@ -3510,6 +3970,393 @@ namespace Lskj.Control return id + ""; } + /// + /// 获取指定父节点下的下一个分段序号,只统计符合当前分段位数的直接子节点。 + /// + /// 节点数据源。 + /// 目标父节点号。 + /// 从1开始的下一个同级序号。 + private int GetNextNodeSequence(DataTable dataTable, string parentNodeId) + { + if (dataTable == null || !dataTable.Columns.Contains(TreeListObj.KeyFieldName) || !dataTable.Columns.Contains(TreeListObj.ParentFieldName)) + { + return 1; + } + + string parentId = NormalizeParentNodeId(parentNodeId); + int maxSequence = 0; + foreach (DataRow row in dataTable.Rows) + { + if (row.RowState == DataRowState.Deleted || !IsSameParentNode(row[TreeListObj.ParentFieldName] + "", parentId)) + { + continue; + } + + string nodeId = row[TreeListObj.KeyFieldName] + ""; + if (!nodeId.StartsWith(parentId, StringComparison.Ordinal) || nodeId.Length != parentId.Length + TreeNumberNodes) + { + continue; + } + + int sequence; + if (int.TryParse(nodeId.Substring(parentId.Length, TreeNumberNodes), out sequence) && sequence > maxSequence) + { + maxSequence = sequence; + } + } + + return maxSequence + 1; + } + + /// + /// 将父节点号和同级序号组合成新版分段节点号,例如01 + 02生成0102。 + /// + /// 父节点号。 + /// 当前父节点下的同级序号。 + /// 按TreeNumberNodes补零后的完整节点号。 + private string BuildSegmentedNodeId(string parentNodeId, int sequence) + { + string segment = sequence.ToString(); + if (segment.Length > TreeNumberNodes) + { + throw new InvalidOperationException("当前层级的节点数量已超过" + new string('9', TreeNumberNodes) + "个,无法继续新增节点。"); + } + + return NormalizeParentNodeId(parentNodeId) + segment.PadLeft(TreeNumberNodes, '0'); + } + + /// + /// 统一根节点表示方式,空字符串和0都转换为空前缀。 + /// + /// 待规范化的父节点号。 + /// 用于拼接新版节点号的父节点前缀。 + private string NormalizeParentNodeId(string parentNodeId) + { + string value = (parentNodeId + "").Trim(); + return string.IsNullOrEmpty(value) || value == "0" ? "" : value; + } + + /// + /// 比较两个父节点号,根节点的空字符串和0视为相同。 + /// + /// 数据行中的父节点号。 + /// 目标父节点号。 + /// 规范化后是否为同一个父节点。 + private bool IsSameParentNode(string rowParentNodeId, string parentNodeId) + { + return string.Equals(NormalizeParentNodeId(rowParentNodeId), NormalizeParentNodeId(parentNodeId), StringComparison.Ordinal); + } + + /// + /// 导入数据的临时树节点,保留来源节点关系以便整体重映射节点号。 + /// + private class ImportedTreeNode + { + public DataRow Row; + public string SourceNodeId; + public string SourceParentNodeId; + public List Children = new List(); + } + + /// + /// 将待插入树数据的来源父子关系整体映射到目标父节点下,并生成不重复的新版分段节点号。 + /// + /// 待插入的数据,KeyFieldName和ParentFieldName保存来源节点关系。 + /// 整批数据要插入到的目标父节点号。 + /// 已重新生成节点号和父节点号的数据源。 + public DataTable PrepareNodeIdsForInsert(DataTable dataTable, string parentNodeId) + { + if (!UseSegmentedNodeId || dataTable == null || dataTable.Rows.Count == 0 || + !dataTable.Columns.Contains(TreeListObj.KeyFieldName) || !dataTable.Columns.Contains(TreeListObj.ParentFieldName)) + { + return dataTable; + } + + dataTable = EnsureSegmentedNodeColumnTypes(dataTable); + + List importNodes = new List(); + Dictionary nodeMap = new Dictionary(StringComparer.Ordinal); + foreach (DataRow row in dataTable.Rows) + { + ImportedTreeNode node = new ImportedTreeNode + { + Row = row, + SourceNodeId = (row[TreeListObj.KeyFieldName] + "").Trim(), + SourceParentNodeId = (row[TreeListObj.ParentFieldName] + "").Trim() + }; + importNodes.Add(node); + if (!string.IsNullOrEmpty(node.SourceNodeId) && !nodeMap.ContainsKey(node.SourceNodeId)) + { + nodeMap.Add(node.SourceNodeId, node); + } + } + + List rootNodes = new List(); + foreach (ImportedTreeNode node in importNodes) + { + ImportedTreeNode parentNode; + if (!string.IsNullOrEmpty(node.SourceParentNodeId) && node.SourceParentNodeId != "0" && + nodeMap.TryGetValue(node.SourceParentNodeId, out parentNode) && parentNode != node) + { + parentNode.Children.Add(node); + } + else + { + rootNodes.Add(node); + } + } + + HashSet handledNodes = new HashSet(); + int sequence = GetNextNodeSequence(this.TreeListObj.DataSource as DataTable, parentNodeId); + foreach (ImportedTreeNode node in rootNodes) + { + AssignImportedNodeId(node, parentNodeId, ref sequence, handledNodes); + } + + // 异常的循环父子关系没有根节点,将未处理行按根节点继续添加,避免导入死循环。 + foreach (ImportedTreeNode node in importNodes) + { + if (!handledNodes.Contains(node)) + { + AssignImportedNodeId(node, parentNodeId, ref sequence, handledNodes); + } + } + + return dataTable; + } + + /// + /// 递归为导入节点及其子节点生成目标树中的分段节点号。 + /// + /// 当前待编号的导入节点。 + /// 当前节点在目标树中的父节点号。 + /// 当前层级下一个可用序号,处理后自动递增。 + /// 已处理节点集合,用于避免异常循环父子关系导致无限递归。 + private void AssignImportedNodeId(ImportedTreeNode node, string parentNodeId, ref int sequence, HashSet handledNodes) + { + if (!handledNodes.Add(node)) + { + return; + } + + string nodeId = BuildSegmentedNodeId(parentNodeId, sequence); + sequence++; + node.Row[TreeListObj.KeyFieldName] = nodeId; + node.Row[TreeListObj.ParentFieldName] = string.IsNullOrEmpty(NormalizeParentNodeId(parentNodeId)) ? "0" : parentNodeId; + + int childSequence = 1; + foreach (ImportedTreeNode childNode in node.Children) + { + AssignImportedNodeId(childNode, nodeId, ref childSequence, handledNodes); + } + } + + /// + /// 记录界面节点顺序对应的新节点号,避免遍历过程中直接修改KeyFieldName破坏父子关系。 + /// + private class NodeNumberAssignment + { + public DataRow Row; + public string NodeId; + public string ParentNodeId; + } + + private bool _renumberingNodeIds; + + /// + /// 按当前树节点显示顺序重新生成全部分段节点号和父节点号,然后一次性重新绑定数据源。 + /// + public void RenumberNodeIds() + { + if (!UseSegmentedNodeId || this.TreeListObj.DataSource == null || _renumberingNodeIds) + { + return; + } + + _renumberingNodeIds = true; + try + { + List assignments = new List(); + CollectNodeNumberAssignments(this.TreeListObj.Nodes, "", assignments); + if (assignments.Count == 0) + { + return; + } + + DataTable sourceTable = this.TreeListObj.DataSource as DataTable; + if (sourceTable == null) + { + return; + } + + DataTable numberedTable = sourceTable.Copy(); + foreach (NodeNumberAssignment assignment in assignments) + { + int rowIndex = sourceTable.Rows.IndexOf(assignment.Row); + if (rowIndex >= 0 && rowIndex < numberedTable.Rows.Count) + { + DataRow numberedRow = numberedTable.Rows[rowIndex]; + numberedRow[TreeListObj.ParentFieldName] = string.IsNullOrEmpty(assignment.ParentNodeId) ? "0" : assignment.ParentNodeId; + numberedRow[TreeListObj.KeyFieldName] = assignment.NodeId; + } + } + + this.SetGridViewDataSource(numberedTable); + } + finally + { + _renumberingNodeIds = false; + } + } + + /// + /// 按TreeList当前同级顺序递归收集节点号分配结果,不在遍历过程中修改原数据。 + /// + /// 当前层级的节点集合。 + /// 当前层级对应的父节点号。 + /// 用于汇总全部节点分配结果的集合。 + private void CollectNodeNumberAssignments(TreeListNodes nodes, string parentNodeId, List assignments) + { + for (int i = 0; i < nodes.Count; i++) + { + TreeListNode node = nodes[i]; + DataRowView rowView = this.TreeListObj.GetDataRecordByNode(node) as DataRowView; + if (rowView == null) + { + continue; + } + + string nodeId = BuildSegmentedNodeId(parentNodeId, i + 1); + assignments.Add(new NodeNumberAssignment + { + Row = rowView.Row, + NodeId = nodeId, + ParentNodeId = parentNodeId + }); + CollectNodeNumberAssignments(node.Nodes, nodeId, assignments); + } + } + + /// + /// 为数据源中节点号为空的行补充分段节点号,已有节点号保持不变。 + /// + /// 需要补充节点号的数据源。 + private void AssignMissingSegmentedNodeIds(DataTable dataTable) + { + if (dataTable == null || !dataTable.Columns.Contains(TreeListObj.KeyFieldName) || !dataTable.Columns.Contains(TreeListObj.ParentFieldName)) + { + return; + } + + foreach (DataRow row in dataTable.Rows) + { + if (row.RowState == DataRowState.Deleted || !string.IsNullOrWhiteSpace(row[TreeListObj.KeyFieldName] + "")) + { + continue; + } + + string parentNodeId = row[TreeListObj.ParentFieldName] + ""; + row[TreeListObj.KeyFieldName] = GetNewNodesId(parentNodeId, dataTable); + if (string.IsNullOrEmpty(NormalizeParentNodeId(parentNodeId))) + { + row[TreeListObj.ParentFieldName] = "0"; + } + } + } + + /// + /// 确保新版节点号和父节点号使用可写字符串列,避免01等前导零被数值列丢失。 + /// + /// 待检查或转换的数据源。 + /// 列类型已满足新版编号要求的数据源;无需转换时返回原表。 + private DataTable EnsureSegmentedNodeColumnTypes(DataTable dataTable) + { + if (dataTable == null || !dataTable.Columns.Contains(TreeListObj.KeyFieldName) || !dataTable.Columns.Contains(TreeListObj.ParentFieldName)) + { + return dataTable; + } + + DataColumn keyColumn = dataTable.Columns[TreeListObj.KeyFieldName]; + DataColumn parentColumn = dataTable.Columns[TreeListObj.ParentFieldName]; + bool keyIsString = (keyColumn.DataType == typeof(string) || keyColumn.DataType == typeof(object)) && !keyColumn.ReadOnly; + bool parentIsString = (parentColumn.DataType == typeof(string) || parentColumn.DataType == typeof(object)) && !parentColumn.ReadOnly; + if (keyIsString && parentIsString) + { + return dataTable; + } + + DataTable stringTable = new DataTable(dataTable.TableName); + foreach (DataColumn column in dataTable.Columns) + { + bool isNodeColumn = column.ColumnName.Equals(TreeListObj.KeyFieldName, StringComparison.OrdinalIgnoreCase) || + column.ColumnName.Equals(TreeListObj.ParentFieldName, StringComparison.OrdinalIgnoreCase); + DataColumn newColumn = new DataColumn(column.ColumnName, isNodeColumn ? typeof(string) : column.DataType) + { + Caption = column.Caption, + AllowDBNull = column.AllowDBNull, + DefaultValue = isNodeColumn ? "" : column.DefaultValue, + ColumnMapping = column.ColumnMapping + }; + if (!isNodeColumn && column.DataType == typeof(string)) + { + newColumn.MaxLength = column.MaxLength; + } + foreach (object key in column.ExtendedProperties.Keys) + { + newColumn.ExtendedProperties[key] = column.ExtendedProperties[key]; + } + stringTable.Columns.Add(newColumn); + } + + foreach (DataRow sourceRow in dataTable.Rows) + { + if (sourceRow.RowState == DataRowState.Deleted) + { + continue; + } + + DataRow newRow = stringTable.NewRow(); + foreach (DataColumn column in dataTable.Columns) + { + object value = sourceRow[column]; + if (column.ColumnName.Equals(TreeListObj.KeyFieldName, StringComparison.OrdinalIgnoreCase) || + column.ColumnName.Equals(TreeListObj.ParentFieldName, StringComparison.OrdinalIgnoreCase)) + { + newRow[column.ColumnName] = value == DBNull.Value ? "" : value + ""; + } + else + { + newRow[column.ColumnName] = value; + } + } + stringTable.Rows.Add(newRow); + + if (sourceRow.RowState == DataRowState.Unchanged) + { + newRow.AcceptChanges(); + } + else if (sourceRow.RowState == DataRowState.Modified) + { + newRow.AcceptChanges(); + newRow.SetModified(); + } + } + + foreach (DataColumn sourceColumn in dataTable.Columns) + { + DataColumn targetColumn = stringTable.Columns[sourceColumn.ColumnName]; + bool isNodeColumn = sourceColumn.ColumnName.Equals(TreeListObj.KeyFieldName, StringComparison.OrdinalIgnoreCase) || + sourceColumn.ColumnName.Equals(TreeListObj.ParentFieldName, StringComparison.OrdinalIgnoreCase); + if (!isNodeColumn && !string.IsNullOrEmpty(sourceColumn.Expression)) + { + targetColumn.Expression = sourceColumn.Expression; + } + targetColumn.ReadOnly = isNodeColumn ? false : sourceColumn.ReadOnly; + } + + return stringTable; + } + /// /// 说明:数据源重新生成节点id /// 创建人:曹屹峰 @@ -3521,6 +4368,12 @@ namespace Lskj.Control /// public void GenerateNodeID() { + if (UseSegmentedNodeId) + { + RenumberNodeIds(); + return; + } + //树表格当前数据源重新生成id DataTable dt = this.TreeListObj.DataSource as DataTable; int i = 1; @@ -3592,6 +4445,11 @@ namespace Lskj.Control MessageUtil.Show("删除成功!"); } } + + if (UseSegmentedNodeId) + { + RenumberNodeIds(); + } } } @@ -3674,7 +4532,11 @@ namespace Lskj.Control } } } - tmpRow[this.TreeListObj.KeyFieldName] = GetNewNodesId();//节点id + tmpRow[this.TreeListObj.KeyFieldName] = GetNewNodesId("0");//节点id + if (UseSegmentedNodeId && gridTable.Columns.Contains(this.TreeListObj.ParentFieldName)) + { + tmpRow[this.TreeListObj.ParentFieldName] = "0"; + } gridTable.Rows.Add(tmpRow); this.TreeListObj.ShowEditor(); @@ -3756,10 +4618,10 @@ namespace Lskj.Control /// - /// 拖拽完成时特殊处理 + /// 拖拽释放时处理限制条件和Alt同层排序。新版模式会先移动界面节点,再同步排序字段和分段节点号。 /// - /// - /// + /// 触发拖拽的TreeList。 + /// 拖拽目标位置和按键状态。 private void TreeListObj_DragDrop(object sender, DragEventArgs e) { if (!string.IsNullOrWhiteSpace(TreeTableDragCondition)) @@ -3788,13 +4650,22 @@ namespace Lskj.Control if (!string.IsNullOrWhiteSpace(this.SortField) && dataTable.Columns.Contains(this.SortField)) { //目标节点 + DXDragEventArgs dragEventArgs = DXDragEventArgs.GetEventArgs(TreeListObj, e); TreeListHitInfo hitInfo = TreeListObj.CalcHitInfo(TreeListObj.PointToClient(new System.Drawing.Point(e.X, e.Y))); - TreeListNode TreeListNode = hitInfo.Node;//当前目标节点 + TreeListNode TreeListNode = dragEventArgs == null || dragEventArgs.TargetNode == null ? hitInfo.Node : dragEventArgs.TargetNode;//当前目标节点 + if (TreeListNode == null) + { + return; + } TreeListNode parentNode = TreeListNode.ParentNode; // 获取目标节点的父节点 int nodeIndex = parentNode == null ? TreeListObj.Nodes.IndexOf(TreeListNode) : parentNode.Nodes.IndexOf(TreeListNode);//当前目标节点的索引 //拖拽节点 - TreeListNode SelectedNode = this.TreeListObj.FocusedNode; - TreeListNode SelectedParentNode = TreeListNode.ParentNode; // 获取拖拽节点的父节点 + TreeListNode SelectedNode = dragEventArgs == null || dragEventArgs.Node == null ? this.TreeListObj.FocusedNode : dragEventArgs.Node; + if (SelectedNode == null || SelectedNode == TreeListNode) + { + return; + } + TreeListNode SelectedParentNode = SelectedNode.ParentNode; // 获取拖拽节点的父节点 int SelectedNodeIndex = SelectedParentNode == null ? TreeListObj.Nodes.IndexOf(SelectedNode) : SelectedParentNode.Nodes.IndexOf(SelectedNode);//拖拽节点的索引 //如果目标节点和拖拽节点的父节点不一样,就证明不在同一层级,直接结束 if (SelectedNode.ParentNode != parentNode) @@ -3803,6 +4674,17 @@ namespace Lskj.Control return; } + if (UseSegmentedNodeId) + { + // 新版编号必须以界面中的同层节点顺序为准,先移动节点,再重写排序字段和节点号。 + int newNodeIndex = SelectedNodeIndex < nodeIndex ? nodeIndex : nodeIndex + 1; + this.TreeListObj.SetNodeIndex(SelectedNode, newNodeIndex); + int focusedNodeIndex = this.TreeListObj.GetVisibleIndexByNode(SelectedNode); + DataSourceSorting(); + RebindSegmentedNodesBySortField(focusedNodeIndex); + return; + } + DataRow DragRow = (this.TreeListObj.GetDataRecordByNode(SelectedNode) as DataRowView).Row;//拖拽行 DataRow TargetRow = (this.TreeListObj.GetDataRecordByNode(TreeListNode) as DataRowView).Row; //目标行 int SerialNumber = int.Parse(TargetRow[this.SortField] + "") + 1;//目标行序号+1 @@ -3833,17 +4715,48 @@ namespace Lskj.Control /// - /// 拖拽后执行 + /// TreeList完成普通节点拖拽后,同步数据源排序;新版模式再按最终界面顺序重新生成节点号。 /// - /// - /// + /// 完成拖拽的TreeList。 + /// 拖拽完成后的节点信息。 private void TreeListObj_AfterDragNode(object sender, AfterDragNodeEventArgs e) { DataSourceSorting(); + if (UseSegmentedNodeId) + { + int focusedNodeIndex = this.TreeListObj.GetVisibleIndexByNode(e.Node ?? this.TreeListObj.FocusedNode); + RebindSegmentedNodesBySortField(focusedNodeIndex); + } //强制重新加载数据 // this.TreeListObj.RefreshDataSource(); } + + /// + /// 按排序字段重新绑定新版树节点,再按绑定后的界面顺序生成节点号并恢复焦点位置。 + /// + /// 重新绑定前焦点节点的可见索引。 + private void RebindSegmentedNodesBySortField(int focusedNodeIndex) + { + DataTable dataTable = GetGridViewDataSource(); + if (dataTable == null) + { + return; + } + + if (!string.IsNullOrWhiteSpace(this.SortField) && dataTable.Columns.Contains(this.SortField)) + { + DataView dataView = dataTable.AsDataView(); + dataView.Sort = "[" + this.SortField.Replace("]", "]]") + "] ASC"; + dataTable = dataView.ToTable(); + } + + this.SetGridViewDataSourceGenerateID(dataTable); + if (focusedNodeIndex >= 0) + { + this.TreeListObj.FocusedNode = this.TreeListObj.GetNodeByVisibleIndex(focusedNodeIndex); + } + } #endregion diff --git a/插件库/Lskj.Core/ApiHelper.cs b/插件库/Lskj.Core/ApiHelper.cs index da0ac70..23a2124 100644 --- a/插件库/Lskj.Core/ApiHelper.cs +++ b/插件库/Lskj.Core/ApiHelper.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; - +using System.Windows.Forms; namespace Lskj.Core { @@ -148,15 +148,18 @@ namespace Lskj.Core apiHandlerModels = new List(); apiHandler._dataImpl = new Data.Api.DataImpl(); - apiHandler._dataImpl.dbOperator = new Lskj.Data.ADO.Template.DbTemplate(SqlHelper._connection.ConnectionString, "system.data.sqlclient"); + apiHandler._dataImpl = new Lskj.Data.Api.DataImpl()//新建数据库连接 + { + dbOperator = new Lskj.Data.ADO.Template.DbTemplate(SqlHelper._connection.ConnectionString, "system.data.sqlclient") + }; if (isSend)//是否发送数据 { - apiHandler.GetEventApiSendData(mep, apiHandlerModels); - apiHandler.SendEventApiData(apiHandlerModels); + apiHandler.GetEventApiSendData(mep, apiHandlerModels, apiHandler._dataImpl); + apiHandler.SendEventApiData(apiHandlerModels, apiHandler._dataImpl); } else { - apiHandler.GetEventApiSendData(mep, apiHandlerModels); + apiHandler.GetEventApiSendData(mep, apiHandlerModels, apiHandler._dataImpl); } this.apiResutMsg = apiHandler.GetApiReturnMsg(apiHandlerModels); } diff --git a/插件库/Lskj.LserpAll/Lskj.LserpAll.sln b/插件库/Lskj.LserpAll/Lskj.LserpAll.sln index e3eb339..764c7e7 100644 --- a/插件库/Lskj.LserpAll/Lskj.LserpAll.sln +++ b/插件库/Lskj.LserpAll/Lskj.LserpAll.sln @@ -271,6 +271,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lskj.PubCodeDesign", "..\Ls EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lskj.PubBillManagement", "..\Lskj.PubBillManagement\Lskj.PubBillManagement.csproj", "{6CE319BA-1253-41F2-8B59-8173FD7BE3F3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lskj.PubUpdatePwd", "..\Lskj.PubUpdatePwd\Lskj.PubUpdatePwd.csproj", "{91470E21-B8FB-4A16-967A-912F9E4807E1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1741,6 +1743,18 @@ Global {6CE319BA-1253-41F2-8B59-8173FD7BE3F3}.Release|Mixed Platforms.Build.0 = Release|Any CPU {6CE319BA-1253-41F2-8B59-8173FD7BE3F3}.Release|x86.ActiveCfg = Release|Any CPU {6CE319BA-1253-41F2-8B59-8173FD7BE3F3}.Release|x86.Build.0 = Release|Any CPU + {91470E21-B8FB-4A16-967A-912F9E4807E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {91470E21-B8FB-4A16-967A-912F9E4807E1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {91470E21-B8FB-4A16-967A-912F9E4807E1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {91470E21-B8FB-4A16-967A-912F9E4807E1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {91470E21-B8FB-4A16-967A-912F9E4807E1}.Debug|x86.ActiveCfg = Debug|Any CPU + {91470E21-B8FB-4A16-967A-912F9E4807E1}.Debug|x86.Build.0 = Debug|Any CPU + {91470E21-B8FB-4A16-967A-912F9E4807E1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {91470E21-B8FB-4A16-967A-912F9E4807E1}.Release|Any CPU.Build.0 = Release|Any CPU + {91470E21-B8FB-4A16-967A-912F9E4807E1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {91470E21-B8FB-4A16-967A-912F9E4807E1}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {91470E21-B8FB-4A16-967A-912F9E4807E1}.Release|x86.ActiveCfg = Release|Any CPU + {91470E21-B8FB-4A16-967A-912F9E4807E1}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/插件库/Lskj.Model/BillModel.cs b/插件库/Lskj.Model/BillModel.cs index 1b95f1e..d3b2d1f 100644 --- a/插件库/Lskj.Model/BillModel.cs +++ b/插件库/Lskj.Model/BillModel.cs @@ -468,9 +468,9 @@ namespace Lskj.Model /// public bool HorizontalMode; /// - /// 树表格老版节点号模式 + /// 树表格新版节点号模式 /// - public bool OldNodeRules; + public bool NewNodeRules; /// /// 新版树节点位数(默认2位,最小2位) /// @@ -583,8 +583,8 @@ namespace Lskj.Model this.SourceMainPushPullHide = rowItem.Table.Columns.Contains("SourceMainPushPullHide") ? "1".Equals(rowItem["SourceMainPushPullHide"] + "") : false; this.SelectSourceColor = rowItem.Table.Columns.Contains("SelectSourceColor") ? rowItem["SelectSourceColor"] + "" : ""; this.HorizontalMode = rowItem.Table.Columns.Contains("HorizontalMode") ? "1".Equals(rowItem["HorizontalMode"] + "") : false; - this.OldNodeRules = rowItem.Table.Columns.Contains("OldNodeRules") ? "1".Equals(rowItem["OldNodeRules"] + "") : false; - this.TreeNumberNodes = rowItem.Table.Columns.Contains("MessageRefreshTime") && !string.IsNullOrEmpty(rowItem["MessageRefreshTime"] + "") ? Convert.ToInt32(rowItem["MessageRefreshTime"] + "")>2? Convert.ToInt32(rowItem["MessageRefreshTime"] + ""):2 : 2; + this.NewNodeRules = rowItem.Table.Columns.Contains("NewNodeRules") ? "1".Equals(rowItem["NewNodeRules"] + "") : false; + this.TreeNumberNodes = rowItem.Table.Columns.Contains("TreeNumberNodes") && !string.IsNullOrEmpty(rowItem["TreeNumberNodes"] + "") ? Convert.ToInt32(rowItem["TreeNumberNodes"] + "")>2? Convert.ToInt32(rowItem["TreeNumberNodes"] + ""):2 : 2; } } -} \ No newline at end of file +} diff --git a/插件库/Lskj.Model/ModuleModel.cs b/插件库/Lskj.Model/ModuleModel.cs index 974a1e3..b05701d 100644 --- a/插件库/Lskj.Model/ModuleModel.cs +++ b/插件库/Lskj.Model/ModuleModel.cs @@ -585,7 +585,7 @@ namespace Lskj.Model /// public int AccordingNameSelected; /// - /// 基础档案关闭时候触发存储过程 + /// 基础档案关闭时候触发存储过程(扫码模块关闭时) /// public string FrmCloseStored; /// @@ -1050,6 +1050,14 @@ namespace Lskj.Model ///隐藏审核按钮(lskj.pubadd.dll) /// public bool HideReviewBut; + /// + /// 模块弹出框高度 + /// + public int ModuleFrameHeight; + /// + /// 模块弹出框宽度 + /// + public int ModuleFrameWidth; #endregion @@ -1243,6 +1251,9 @@ namespace Lskj.Model this.TotalQuantity = rowItem.Table.Columns.Contains("TotalQuantity") ? "1".Equals(rowItem["TotalQuantity"] + "") : false; this.HeaderSortCriteria = rowItem.Table.Columns.Contains("HeaderSortCriteria") ? rowItem["HeaderSortCriteria"] + "" : ""; this.HideReviewBut = rowItem.Table.Columns.Contains("HideReviewBut") ? "1".Equals(rowItem["HideReviewBut"] + "") : false; + + this.ModuleFrameHeight = rowItem.Table.Columns.Contains("ModuleFrameHeight") && !string.IsNullOrEmpty(rowItem["ModuleFrameHeight"] + "") ? Convert.ToInt32(rowItem["ModuleFrameHeight"] + "") : 0; + this.ModuleFrameWidth = rowItem.Table.Columns.Contains("ModuleFrameWidth") && !string.IsNullOrEmpty(rowItem["ModuleFrameWidth"] + "") ? Convert.ToInt32(rowItem["ModuleFrameWidth"] + "") : 0; } } } diff --git a/插件库/Lskj.PubApiSetModule/FrmMain.cs b/插件库/Lskj.PubApiSetModule/FrmMain.cs index c6fe370..db52c4c 100644 --- a/插件库/Lskj.PubApiSetModule/FrmMain.cs +++ b/插件库/Lskj.PubApiSetModule/FrmMain.cs @@ -439,7 +439,10 @@ namespace Lskj.PubApiSetModule valueEncryptTypeComboBox.Items.Add(new ComBoxModel() { Value = 3, Text = "URL地址加密" }); valueEncryptTypeComboBox.Items.Add(new ComBoxModel() { Value = 4, Text = "URL文件Base64" }); valueEncryptTypeComboBox.Items.Add(new ComBoxModel() { Value = 5, Text = "RSA" }); - valueEncryptTypeComboBox.Items.Add(new ComBoxModel() { Value = 103, Text = "道宏发票接口特殊加密" });//道宏发票接口特殊加密 + valueEncryptTypeComboBox.Items.Add(new ComBoxModel() { Value = 101, Text = "航天凯特特殊加密" }); + valueEncryptTypeComboBox.Items.Add(new ComBoxModel() { Value = 102, Text = "SHA256ToBase64" }); + valueEncryptTypeComboBox.Items.Add(new ComBoxModel() { Value = 103, Text = "道宏发票接口特殊加密" }); + valueEncryptTypeComboBox.Items.Add(new ComBoxModel() { Value = 104, Text = "SHA256ToBit" }); #endregion #region 朗速接口主表 getIdColumn.OptionsColumn.AllowEdit = false; @@ -607,7 +610,7 @@ namespace Lskj.PubApiSetModule colDic.Add("valueDataType", "int"); colDic.Add("unionPmsId", "int"); colDic.Add("valueEncryptType", "int"); - colDic.Add("encryptKey", "int"); + colDic.Add("encryptKey", "varchar(100)"); colDic.Add("allowNull", "int"); string isExitApiTab = "select top 1 * from sysObjects where Id=OBJECT_ID(N'P_systemEventApiPmsTab') and xtype='U'"; DataTable apiTab = SqlHelper.ExecuteDataTable(isExitApiTab); diff --git a/插件库/Lskj.PubBill/BillModule.cs b/插件库/Lskj.PubBill/BillModule.cs index 11939d9..48b61e5 100644 --- a/插件库/Lskj.PubBill/BillModule.cs +++ b/插件库/Lskj.PubBill/BillModule.cs @@ -611,58 +611,67 @@ namespace Lskj.PubBill #endregion #region 加载来源明细 GridControlEx gridDetail = new GridControlEx(); - if (model.sourceDetailType.Equals("1")) + if (!string.IsNullOrWhiteSpace(model.DetailModeCode)) { - //明细为树表格 - gridDetail = new TreeGridControlEx(); - billModuleModel.SourceDetailControl = gridDetail; - //创建表格列 - cachesDic.AddTask(gridDetail, "DynamicModel", dynamicModelTask); - gridDetail.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey); - Task detailGridRowColorsTask = cachesDic.AddTask(gridDetail, "BaseGridRowColors", new Task(() => - { - return BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey); - })); - Task detailGridRightMenusTask = cachesDic.AddTask(gridDetail, "BaseGridRightMenus", new Task(() => - { - return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey); - })); } - else + else { - gridDetail = new GridControlEx(); - billModuleModel.SourceDetailControl = gridDetail; - //创建表格列 - cachesDic.AddTask(gridDetail, "DynamicModel", dynamicModelTask); - gridDetail.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey); - Task detailGridRowColorsTask = cachesDic.AddTask(gridDetail, "BaseGridRowColors", new Task(() => + if (model.sourceDetailType.Equals("1")) { - return BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey); - })); - Task detailGridRightMenusTask = cachesDic.AddTask(gridDetail, "BaseGridRightMenus", new Task(() => - { - return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey); - })); - //明细的明细(明细分成左右2个) - if (!string.IsNullOrEmpty(model.SourceDetailsDetailsSql)) - { - GridControlEx gridDetail_Details = new GridControlEx(); - billModuleModel.SourceDetailDetailControl = gridDetail_Details; - //创建只读列 - Task detailDetailsTask = cachesDic.AddTask(gridDetail_Details, "DetailDetails", new Task(() => - { - return BaseModuleImpl.getDetail_Details(model.FormKey); - })); + //明细为树表格 + gridDetail = new TreeGridControlEx(); + billModuleModel.SourceDetailControl = gridDetail; //创建表格列 - cachesDic.AddTask(gridDetail_Details, "DynamicModel", dynamicModelTask); - gridDetail_Details.GetDataCaches(cachesDic); - Task detailDetailsGridRightMenusTask = cachesDic.AddTask(gridDetail_Details, "BaseGridRightMenus", new Task(() => + cachesDic.AddTask(gridDetail, "DynamicModel", dynamicModelTask); + gridDetail.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey); + Task detailGridRowColorsTask = cachesDic.AddTask(gridDetail, "BaseGridRowColors", new Task(() => { - return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDTX_" + model.FormKey); + return BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey); })); + Task detailGridRightMenusTask = cachesDic.AddTask(gridDetail, "BaseGridRightMenus", new Task(() => + { + return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey); + })); + } - } + else + { + gridDetail = new GridControlEx(); + billModuleModel.SourceDetailControl = gridDetail; + //创建表格列 + cachesDic.AddTask(gridDetail, "DynamicModel", dynamicModelTask); + gridDetail.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey); + Task detailGridRowColorsTask = cachesDic.AddTask(gridDetail, "BaseGridRowColors", new Task(() => + { + return BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey); + })); + Task detailGridRightMenusTask = cachesDic.AddTask(gridDetail, "BaseGridRightMenus", new Task(() => + { + return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey); + })); + //明细的明细(明细分成左右2个) + if (!string.IsNullOrEmpty(model.SourceDetailsDetailsSql)) + { + GridControlEx gridDetail_Details = new GridControlEx(); + billModuleModel.SourceDetailDetailControl = gridDetail_Details; + //创建只读列 + Task detailDetailsTask = cachesDic.AddTask(gridDetail_Details, "DetailDetails", new Task(() => + { + return BaseModuleImpl.getDetail_Details(model.FormKey); + })); + //创建表格列 + cachesDic.AddTask(gridDetail_Details, "DynamicModel", dynamicModelTask); + gridDetail_Details.GetDataCaches(cachesDic); + Task detailDetailsGridRightMenusTask = cachesDic.AddTask(gridDetail_Details, "BaseGridRightMenus", new Task(() => + { + return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDTX_" + model.FormKey); + })); + } + } + } + + #endregion BillModuleModelDic.Add(sourceModelRow, billModuleModel); #region 加载来源条件 @@ -825,6 +834,9 @@ namespace Lskj.PubBill this.gcMain.Dock = DockStyle.Fill; this.pl_main_center_detail.Controls.Add(this.gcMain); (this.gcMain as TreeGridControlEx).Expansion = this.BillModel.DetailTreeTableExpansion; + (this.gcMain as TreeGridControlEx).UseSegmentedNodeId = this.BillModel.NewNodeRules; + (this.gcMain as TreeGridControlEx).TreeNumberNodes = this.BillModel.TreeNumberNodes; + (this.gcMain as TreeGridControlEx).BillPaste = true; (this.gcMain as TreeGridControlEx).AddRightButton(); //节点编号 (this.gcMain as TreeGridControlEx).TreeListObj.KeyFieldName = "tap_id"; @@ -1881,25 +1893,6 @@ namespace Lskj.PubBill controls = BaseModuleImpl.GetCustomQueryFields(model.FormKey); } - if (false) - { - string menuCode = string.Empty; - DataRow modelRow = MainImpl.GetSystemdllTab(menuCode);//获取模块信息 - ModuleModel sysModel = new ModuleModel(modelRow); - //设置主表sql - //model.SourceSql = sysModel.MenuSql; - //获取主表列 - DataTable dtSourceColumns = BaseModuleImpl.GetBaseGridColumns(sysModel.ModeCode); - //获取明细消息 - - //明细sql - //model.DetailSql - - } - - - - XtraTabPage tabPage = new XtraTabPage(); tabPage.Text = model.UserName; @@ -1924,42 +1917,21 @@ namespace Lskj.PubBill GridControlEx gridControl = null; TreeViewEx treeView = null; - if (model.SourceType == 1) + DataTable SourceMainColumns = new DataTable(); + if (!string.IsNullOrWhiteSpace(model.SourceModeCode)) { - // 来源为树类型 - treeView = sourceControl != null ? (TreeViewEx)sourceControl : new TreeViewEx(); - treeView.BorderStyle = BorderStyle.None; - treeView.Dock = DockStyle.Fill; - treeView.TreeNodeKeyField = model.SourceKeyField; - treeView.TreeNodeTextField = model.SourceResult; - if (!dataCaches.GetValue(treeView, "BindTreeTable", out DataTable bindTreeTable)) - { - bindTreeTable = BaseImpl.GetDataTableResult(model.SourceSql); - } - treeView.TreeInhibitSort = model.TreeInhibitSort; - treeView.BindTreeView(bindTreeTable); - treeView.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeNodeSelectAfter); + string menuCode = model.SourceModeCode; + DataRow modelRow = MainImpl.GetSystemdllTab(menuCode);//获取模块信息 + ModuleModel sysModel = new ModuleModel(modelRow); + //设置主表sql + model.ChangeSourceSql(sysModel.MenuSql); + //主表主键 + string parmaryKey = BaseImpl.GetBasePrimaryKey(sysModel.ModeCode);//获取主键 + unionModel.ParmaryKey = parmaryKey; - tabPage.Controls.Add(treeView); - } - else if (model.SourceType == 5) - { - model.ChangeSourceType(2);//单据来源显示条数 - this.IsBillShowCount = true; - } - else if (model.SourceType == 3 || model.SourceType == 4) - { - //类型为3,是树表格类型的单据管理。 - //类型为4,是树表格类型的数据来源 - gridControl = sourceControl != null ? (TreeGridControlEx)sourceControl : new TreeGridControlEx(); - gridControl.Dock = DockStyle.Fill; - gridControl.BorderStyle = System.Windows.Forms.BorderStyle.None; - gridControl.Model = this.SysModel; - if (!dataCaches.GetValue(gridControl, "SourceColumns", out DataTable dtSourceColumns)) - { - dtSourceColumns = BillImpl.GetSourceColumns(model.Id); - } + //获取主表列 + SourceMainColumns = BaseModuleImpl.GetBaseGridColumns(sysModel.ModeCode); if (!dataCaches.GetValue(gridControl, "BaseGridRowColors", out DataTable dtBaseGridRowColors)) { dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey); @@ -1968,27 +1940,48 @@ namespace Lskj.PubBill { dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey); } + if (model.SourceType == 3 || model.SourceType == 4) + { + gridControl = sourceControl != null ? (TreeGridControlEx)sourceControl : new TreeGridControlEx(); + gridControl.Dock = DockStyle.Fill; + gridControl.BorderStyle = System.Windows.Forms.BorderStyle.None; + gridControl.Model = this.SysModel; + } + else + { + // 来源为表格类型 + gridControl = sourceControl != null ? (GridControlEx)sourceControl : new GridControlEx(); + gridControl.BorderStyle = BorderStyle.None; + gridControl.Model = this.SysModel; + gridControl.Dock = DockStyle.Fill; + gridControl.ExportPermission = this.BillModel.ExportPermission; + } - //节点编号 - if (!string.IsNullOrWhiteSpace(model.SourceKeyFieldName)) (gridControl as TreeGridControlEx).TreeListObj.KeyFieldName = model.SourceKeyFieldName; - //父节点编号 - if (!string.IsNullOrWhiteSpace(model.SourceParentFieldName)) (gridControl as TreeGridControlEx).TreeListObj.ParentFieldName = model.SourceParentFieldName; - - gridControl.SetReadOnlyColumns(dtSourceColumns, GridCustomColumnStruct.BillSourceGridView + model.FormKey); + gridControl.SetReadOnlyColumns(SourceMainColumns, GridCustomColumnStruct.BillSourceGridView + model.FormKey); gridControl.SetGridRowColors(dtBaseGridRowColors); - //gridControl.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback); - (gridControl as TreeGridControlEx).SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback); - unionModel.TreeGridControlObj = gridControl as TreeGridControlEx; - unionModel.TreeGridControlObj.TreeListObj.FocusedNodeChanged += new DevExpress.XtraTreeList.FocusedNodeChangedEventHandler(OnTreeListObjFocusedNodeChanged); + gridControl.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback); + + //基础ModuleGridEx + // DynamicModuleModel dyncModel = new DynamicModuleModel(new[] + //{ sysModel.MenuName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, + // this.SysModel.Privilege, sysModel.ModeCode, "0" }); + // ModuleGridEx MainGridEx = new ModuleGridEx(); + // MainGridEx.Dock = DockStyle.Fill; + // MainGridEx.VisibleSearchPanel = false;//禁止上方搜索 + // MainGridEx.InitializeControl(sysModel, dyncModel); + // gridControl = MainGridEx.GridControlObj; if (BillModel.IsBillSourceCheck == 1) { - GridDragGrid.TreeListAddCheckBox((gridControl as TreeGridControlEx).TreeListObj); + GridDragGrid.GridAddCheckBox(gridControl.GridView); } - - if (model.SourceType == 4) + if (sysModel.TreeAutoMultiHeader == 1) { + //模块为树表格 + model.ChangeSourceType(4); + unionModel.TreeGridControlObj = gridControl as TreeGridControlEx; + unionModel.TreeGridControlObj.TreeListObj.FocusedNodeChanged += new DevExpress.XtraTreeList.FocusedNodeChangedEventHandler(OnTreeListObjFocusedNodeChanged); //来源拖拽到主表 if (this.BillModel.DetailTreeTable) { @@ -2003,55 +1996,9 @@ namespace Lskj.PubBill treeGridDragGrid.OnDragComplete += TreeGridDragGrid_OnDragComplete; } } - - - tabPage.Controls.Add(gridControl); - } - else - { - // 来源为表格类型 - gridControl = sourceControl != null ? (GridControlEx)sourceControl : new GridControlEx(); - gridControl.BorderStyle = BorderStyle.None; - gridControl.Model = this.SysModel; - gridControl.Dock = DockStyle.Fill; - gridControl.ExportPermission = this.BillModel.ExportPermission; - - if (model.LoadFilter) - { - gridControl.GridView.OptionsView.ShowAutoFilterRow = true; - } - if (!dataCaches.GetValue(gridControl, "SourceColumns", out DataTable dtSourceColumns)) - { - dtSourceColumns = BillImpl.GetSourceColumns(model.Id); - } - if (!dataCaches.GetValue(gridControl, "BaseGridRowColors", out DataTable dtBaseGridRowColors)) - { - dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey); - } - if (!dataCaches.GetValue(gridControl, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus)) - { - dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey); - } - gridControl.SetReadOnlyColumns(dtSourceColumns, GridCustomColumnStruct.BillSourceGridView + model.FormKey); - gridControl.SetGridRowColors(dtBaseGridRowColors); - gridControl.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback); - //gridControl.GridView.SelectionChanged += new SelectionChangedEventHandler(OnGridControlSelectionChanged); - //gridControl.GridView.FocusedRowObjectChanged += OnFocusedRowObjectChanged; - if (model.DetailsDoubleClick) - { - gridControl.GridView.DoubleClick += OnSourceGridViewDoubleClick; // 2023-3-11 增加双击配置 - } - else - { - gridControl.GridView.RowCellClick += OnGridViewRowCellClick; // 2019-11-12 cmd提出改为行点击事件,否则会出现保存提交后,单据管理无法查询出数据 - } - - if (BillModel.IsBillSourceCheck == 1) - { - GridDragGrid.GridAddCheckBox(gridControl.GridView); - } - if (model.SourceType == 0) + else { + gridControl.GridView.RowCellClick += OnGridViewRowCellClick; //来源拖拽到主表 if (this.BillModel.DetailTreeTable) { @@ -2067,8 +2014,177 @@ namespace Lskj.PubBill } } + + tabPage.Controls.Add(gridControl); + //获取明细信息,第一个为对应的来源明细 + DataTable table = BaseModuleImpl.GetBaseDetailPages(sysModel.ModeCode);// + if (table != null && table.Rows.Count > 0) + { + DataRow detailsRow = table.Rows[0]; + GridDetailModel gridDetailModel = new GridDetailModel(detailsRow, new DataTable(), GridCustomColumnStruct.BaseDetailGridView); + //第一个页签的模块号 赋值给 来源明细模块号。后续来源明细会根据模块号加载 + model.DetailModeCode = gridDetailModel.UnionModule; + DataRow Detail = MainImpl.GetSystemdllTab(gridDetailModel.UnionModule);//获取模块信息 + ModuleModel DetailModel = new ModuleModel(Detail); + //明细sql gridDetailModel.IsReadOnly || gridDetailModel.IsChart ? gridDetailModel.DetailSql : DetailModel.MenuSql + model.ChangeSourceDetailSql(DetailModel.MenuSql); + unionModel.GridDetailModel = gridDetailModel; + } + } + else + { + if (model.SourceType == 1) + { + // 来源为树类型 + treeView = sourceControl != null ? (TreeViewEx)sourceControl : new TreeViewEx(); + treeView.BorderStyle = BorderStyle.None; + treeView.Dock = DockStyle.Fill; + treeView.TreeNodeKeyField = model.SourceKeyField; + treeView.TreeNodeTextField = model.SourceResult; + if (!dataCaches.GetValue(treeView, "BindTreeTable", out DataTable bindTreeTable)) + { + bindTreeTable = BaseImpl.GetDataTableResult(model.SourceSql); + } + treeView.TreeInhibitSort = model.TreeInhibitSort; + treeView.BindTreeView(bindTreeTable); + treeView.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeNodeSelectAfter); + + tabPage.Controls.Add(treeView); + } + else if (model.SourceType == 5) + { + model.ChangeSourceType(2);//单据来源显示条数 + this.IsBillShowCount = true; + } + else if (model.SourceType == 3 || model.SourceType == 4) + { + //类型为3,是树表格类型的单据管理。 + //类型为4,是树表格类型的数据来源 + gridControl = sourceControl != null ? (TreeGridControlEx)sourceControl : new TreeGridControlEx(); + gridControl.Dock = DockStyle.Fill; + gridControl.BorderStyle = System.Windows.Forms.BorderStyle.None; + gridControl.Model = this.SysModel; + + if (!dataCaches.GetValue(gridControl, "SourceColumns", out DataTable dtSourceColumns)) + { + dtSourceColumns = BillImpl.GetSourceColumns(model.Id); + } + if (!dataCaches.GetValue(gridControl, "BaseGridRowColors", out DataTable dtBaseGridRowColors)) + { + dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey); + } + if (!dataCaches.GetValue(gridControl, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus)) + { + dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey); + } + + //节点编号 + if (!string.IsNullOrWhiteSpace(model.SourceKeyFieldName)) (gridControl as TreeGridControlEx).TreeListObj.KeyFieldName = model.SourceKeyFieldName; + //父节点编号 + if (!string.IsNullOrWhiteSpace(model.SourceParentFieldName)) (gridControl as TreeGridControlEx).TreeListObj.ParentFieldName = model.SourceParentFieldName; + + gridControl.SetReadOnlyColumns(dtSourceColumns, GridCustomColumnStruct.BillSourceGridView + model.FormKey); + gridControl.SetGridRowColors(dtBaseGridRowColors); + //gridControl.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback); + (gridControl as TreeGridControlEx).SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback); + unionModel.TreeGridControlObj = gridControl as TreeGridControlEx; + unionModel.TreeGridControlObj.TreeListObj.FocusedNodeChanged += new DevExpress.XtraTreeList.FocusedNodeChangedEventHandler(OnTreeListObjFocusedNodeChanged); + + + if (BillModel.IsBillSourceCheck == 1) + { + GridDragGrid.TreeListAddCheckBox((gridControl as TreeGridControlEx).TreeListObj); + } + + if (model.SourceType == 4) + { + //来源拖拽到主表 + if (this.BillModel.DetailTreeTable) + { + TreeGridDragTree treeGridDragTree = new TreeGridDragTree((gridControl as TreeGridControlEx).TreeListObj, (this.gcMain as TreeGridControlEx).TreeListObj); + treeGridDragTree.CanDragParentNode = true; + treeGridDragTree.NeglectingNodes = true; + treeGridDragTree.OnDragComplete += TreeGridDragTree_OnDragComplete; + } + else + { + TreeGridDragGrid treeGridDragGrid = new TreeGridDragGrid((gridControl as TreeGridControlEx).TreeListObj, this.gcMain.GridView); + treeGridDragGrid.OnDragComplete += TreeGridDragGrid_OnDragComplete; + } + } + + + tabPage.Controls.Add(gridControl); + } + else + { + // 来源为表格类型 + gridControl = sourceControl != null ? (GridControlEx)sourceControl : new GridControlEx(); + gridControl.BorderStyle = BorderStyle.None; + gridControl.Model = this.SysModel; + gridControl.Dock = DockStyle.Fill; + gridControl.ExportPermission = this.BillModel.ExportPermission; + + if (model.LoadFilter) + { + gridControl.GridView.OptionsView.ShowAutoFilterRow = true; + } + if (!dataCaches.GetValue(gridControl, "SourceColumns", out DataTable dtSourceColumns)) + { + dtSourceColumns = BillImpl.GetSourceColumns(model.Id); + } + if (!dataCaches.GetValue(gridControl, "BaseGridRowColors", out DataTable dtBaseGridRowColors)) + { + dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey); + } + if (!dataCaches.GetValue(gridControl, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus)) + { + dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey); + } + gridControl.SetReadOnlyColumns(dtSourceColumns, GridCustomColumnStruct.BillSourceGridView + model.FormKey); + gridControl.SetGridRowColors(dtBaseGridRowColors); + gridControl.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback); + //gridControl.GridView.SelectionChanged += new SelectionChangedEventHandler(OnGridControlSelectionChanged); + //gridControl.GridView.FocusedRowObjectChanged += OnFocusedRowObjectChanged; + if (model.DetailsDoubleClick) + { + gridControl.GridView.DoubleClick += OnSourceGridViewDoubleClick; // 2023-3-11 增加双击配置 + } + else + { + gridControl.GridView.RowCellClick += OnGridViewRowCellClick; // 2019-11-12 cmd提出改为行点击事件,否则会出现保存提交后,单据管理无法查询出数据 + } + + if (BillModel.IsBillSourceCheck == 1) + { + GridDragGrid.GridAddCheckBox(gridControl.GridView); + } + if (model.SourceType == 0) + { + //来源拖拽到主表 + if (this.BillModel.DetailTreeTable) + { + GridDragTreeGrid dragDetailGrid = new GridDragTreeGrid(gridControl.GridView, (this.gcMain as TreeGridControlEx).TreeListObj); + dragDetailGrid.CanDragParentNode = true; + dragDetailGrid.NeglectingNodes = true; + dragDetailGrid.OnDragComplete += DragDetailGrid_OnDragMainGridCompleted; + } + else + { + GridDragGrid dragMainGrid = new GridDragGrid(gridControl.GridView, this.gcMain.GridView); + dragMainGrid.OnDragComplete += new GridFragGridCompleteEventHandler(OnDragMainGridCompleted); + } + } + + tabPage.Controls.Add(gridControl); + } + } + + + + #endregion #region 加载来源明细 @@ -2089,22 +2205,19 @@ namespace Lskj.PubBill - if (!string.IsNullOrWhiteSpace(model.DetailMenuCode)) + if (!string.IsNullOrWhiteSpace(model.DetailModeCode)) { //来源明细配置了模块号,根据模块号创建对应的ModuleGridEx //ModuleGridEx主要是用保存的功能,数据源sql还是根据配置的为准 - DataRow modelRow = MainImpl.GetSystemdllTab(model.DetailMenuCode);//获取模块信息 + DataRow modelRow = MainImpl.GetSystemdllTab(model.DetailModeCode);//获取模块信息 if (modelRow == null) { - MessageUtil.Show($"没有找到编号为 {model.DetailMenuCode} 的模块信息"); + MessageUtil.Show($"没有找到编号为 {model.DetailModeCode} 的模块信息"); gridDetail.Parent = gridDetail; continue; } ModuleModel sysModel = new ModuleModel(modelRow); - //设置主表sql - //model.SourceSql = sysModel.MenuSql; - DynamicModuleModel dyncModel = new DynamicModuleModel(new[] { sysModel.MenuName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, this.SysModel.Privilege, sysModel.ModeCode, "0" }); @@ -3942,6 +4055,14 @@ namespace Lskj.PubBill } else { + if (unionModel.GridDetailModel != null && !string.IsNullOrWhiteSpace(unionModel.ParmaryKey)&& rowItem!=null) + { + //来源主表配置的模块,来源明细sql要拼接条件 + string fieldName = !string.IsNullOrEmpty(unionModel.GridDetailModel.UnionParentField) && rowItem.Table.Columns.Contains(unionModel.GridDetailModel.UnionParentField) ? unionModel.GridDetailModel.UnionParentField : unionModel.ParmaryKey; + DetailSql = ReplaceHelper.ReplaceWhereCond(DetailSql) + string.Format(" and {0}='{1}'", unionModel.GridDetailModel.UnionValue, rowItem[fieldName]+""); + + } + //有复选框的页签在刷新前清空选中行,否则合计在刷新数据源后不会自带改变 @@ -6927,7 +7048,7 @@ namespace Lskj.PubBill { string addSql = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(unionModel.AddDataSql)); DataTable dataTable = MainImpl.GetDataTableResult(addSql); - DragAddTable(dataTable, (int.Parse((this.gcMain as TreeGridControlEx).GetNewNodesId()) - 1) + "");////上方的新增行的id默认是最大的 + DragAddTable(dataTable, (this.gcMain as TreeGridControlEx).GetLastNodesId(Pid));////上方的新增行的id默认是最大的 } } } @@ -8795,7 +8916,7 @@ namespace Lskj.PubBill //添加拖拽行对应的数据源 string addSql = ReplaceHelper.ReplaceRowParam(e.GridViewSelectRows, ReplaceHelper.ReplaceUserInfo(unionModel.AddDataSql)); DataTable dataTable = MainImpl.GetDataTableResult(addSql); - DragAddTable(dataTable, (int.Parse((this.gcMain as TreeGridControlEx).GetNewNodesId()) - 1) + "");//上方的新增行的id默认是最大的 + DragAddTable(dataTable, (this.gcMain as TreeGridControlEx).GetLastNodesId(Pid));//上方的新增行的id默认是最大的 } } this.gcMain.GridView.SelectRowHandler(oldRowHandle); @@ -8833,36 +8954,46 @@ namespace Lskj.PubBill //数据源的id和pid全部加上目标节点(加上后当前数据源就是目标节点的子节点数据源) if (dataTable.Columns.Contains(ParentFieldName) && dataTable.Columns.Contains(KeyFieldName)) { - //当前树表格中最大的id号 - int NodeId = int.Parse((this.gcMain as TreeGridControlEx).GetNewNodesId()) - 1; - //当前树表格中如果id为null,要赋值的id值(节点id不能为null) - int NewNodeId = int.Parse((this.gcMain as TreeGridControlEx).GetNewNodesId()); + if (this.BillModel.NewNodeRules) + { + dataTable = (this.gcMain as TreeGridControlEx).PrepareNodeIdsForInsert(dataTable, Pid); + } + else + { + //当前树表格中最大的id号 + int NodeId = int.Parse((this.gcMain as TreeGridControlEx).GetNewNodesId()) - 1; + //当前树表格中如果id为null,要赋值的id值(节点id不能为null) + int NewNodeId = int.Parse((this.gcMain as TreeGridControlEx).GetNewNodesId()); + + //根据当前的节点号,改变新增数据源中的节点号 + foreach (DataRow rowItem in dataTable.Rows) + { + // 新增表格中的数据id全部加上最大id号,如果是空就默认去赋最大id+1的值 + if (!string.IsNullOrWhiteSpace(rowItem[KeyFieldName] + "")) + { + rowItem[KeyFieldName] = int.Parse(rowItem[KeyFieldName] + "") + NodeId; + } + else + { + rowItem[KeyFieldName] = NewNodeId; + NewNodeId++; + } + + //pid为0或者null的改成目标节点的节点号,有值的默认加上最大id值 + if (string.IsNullOrWhiteSpace(rowItem[ParentFieldName] + "") || int.Parse(rowItem[ParentFieldName] + "") == 0) + { + rowItem[ParentFieldName] = Pid; + + } + else if (int.Parse(rowItem[ParentFieldName] + "") > 0) + { + rowItem[ParentFieldName] = int.Parse(rowItem[ParentFieldName] + "") + NodeId; + } + } + } - //根据当前的节点号,改变新增数据源中的节点号 foreach (DataRow rowItem in dataTable.Rows) { - // 新增表格中的数据id全部加上最大id号,如果是空就默认去赋最大id+1的值 - if (!string.IsNullOrWhiteSpace(rowItem[KeyFieldName] + "")) - { - rowItem[KeyFieldName] = int.Parse(rowItem[KeyFieldName] + "") + NodeId; - } - else - { - rowItem[KeyFieldName] = NewNodeId; - NewNodeId++; - } - - //pid为0或者null的改成目标节点的节点号,有值的默认加上最大id值 - if (string.IsNullOrWhiteSpace(rowItem[ParentFieldName] + "") || int.Parse(rowItem[ParentFieldName] + "") == 0) - { - rowItem[ParentFieldName] = Pid; - - } - else if (int.Parse(rowItem[ParentFieldName] + "") > 0) - { - rowItem[ParentFieldName] = int.Parse(rowItem[ParentFieldName] + "") + NodeId; - } - DataRow newRow = TreeTable.NewRow(); newRow.BeginEdit(); // 赋值明细字段 @@ -9171,9 +9302,9 @@ namespace Lskj.PubBill } } (this.gcMain as TreeGridControlEx).TreeListObj.EndUpdate(); - if (string.IsNullOrWhiteSpace(newRow[(this.gcMain as TreeGridControlEx).TreeListObj.KeyFieldName] + "")) + if (this.BillModel.NewNodeRules || string.IsNullOrWhiteSpace(newRow[(this.gcMain as TreeGridControlEx).TreeListObj.KeyFieldName] + "")) { - newRow[(this.gcMain as TreeGridControlEx).TreeListObj.KeyFieldName] = (this.gcMain as TreeGridControlEx).GetNewNodesId();//节点id为空,就默认给当前数据源最大id+1 + newRow[(this.gcMain as TreeGridControlEx).TreeListObj.KeyFieldName] = (this.gcMain as TreeGridControlEx).GetNewNodesId(Pid);//节点id为空,就默认生成节点id } if (!string.IsNullOrWhiteSpace(Pid)) @@ -9338,7 +9469,13 @@ namespace Lskj.PubBill LogHelper.Instance.WriteError(ex); } } - // newRow[(this.gcMain as TreeGridControlEx).TreeListObj.KeyFieldName] = (this.gcMain as TreeGridControlEx).GetNewNodesId();//节点id + if (this.BillModel.NewNodeRules) + { + string keyFieldName = (this.gcMain as TreeGridControlEx).TreeListObj.KeyFieldName; + string parentFieldName = (this.gcMain as TreeGridControlEx).TreeListObj.ParentFieldName; + newRow[keyFieldName] = (this.gcMain as TreeGridControlEx).GetNewNodesId("0", gridTable); + newRow[parentFieldName] = "0"; + } newRow.EndEdit(); gridTable.Rows.Add(newRow); @@ -10336,4 +10473,4 @@ namespace Lskj.PubBill } -} \ No newline at end of file +} diff --git a/插件库/Lskj.PubBill/Model/BillSourceModel.cs b/插件库/Lskj.PubBill/Model/BillSourceModel.cs index 88da356..26fe668 100644 --- a/插件库/Lskj.PubBill/Model/BillSourceModel.cs +++ b/插件库/Lskj.PubBill/Model/BillSourceModel.cs @@ -61,9 +61,11 @@ namespace Lskj.PubBill.Model public string Orderid;// 来源页签序号 - public string DetailMenuCode;// 来源模块号 + public string SourceModeCode;// 来源模块号 + public string DetailModeCode;// 来源明细模块号 + public BillSourceModel(DataRow item) { @@ -110,7 +112,8 @@ namespace Lskj.PubBill.Model this.DragAndSave = item.Table.Columns.Contains("DragAndSave") && "1".Equals(item["DragAndSave"] + "") ? true : false; this.TreeInhibitSort = item.Table.Columns.Contains("TreeInhibitSort") && "1".Equals(item["TreeInhibitSort"] + "") ? true : false; this.Orderid = item.Table.Columns.Contains("Orderid") ? item["Orderid"] + "" : ""; - this.DetailMenuCode = item.Table.Columns.Contains("DetailMenuCode") ? item["DetailMenuCode"] + "" : ""; + this.SourceModeCode = item.Table.Columns.Contains("SourceModeCode") ? item["SourceModeCode"] + "" : ""; + this.DetailModeCode = item.Table.Columns.Contains("DetailModeCode") ? item["DetailModeCode"] + "" : ""; } /// /// 改变来源类型 @@ -129,5 +132,24 @@ namespace Lskj.PubBill.Model { this.sourceDetailType = sourceDetailType; } + + /// + /// 改变来源主表sql + /// + /// + public void ChangeSourceSql(string Sql) + { + this.SourceSql = Sql; + } + + /// + /// 改变来源明细sql + /// + /// + public void ChangeSourceDetailSql(string Sql) + { + this.DetailSql = Sql; + } + } } diff --git a/插件库/Lskj.PubBill/Model/BillSourceUnionModel.cs b/插件库/Lskj.PubBill/Model/BillSourceUnionModel.cs index bc20bea..4ecdeae 100644 --- a/插件库/Lskj.PubBill/Model/BillSourceUnionModel.cs +++ b/插件库/Lskj.PubBill/Model/BillSourceUnionModel.cs @@ -54,10 +54,7 @@ namespace Lskj.PubBill.Model /// 单据来源明细表格的明细 /// public GridControlEx GridDetailDetailControlObj; - /// - /// 单据来源明细模块 - /// - public ModuleGridEx GridDetailModuleGridEx; + public bool IsChange = false; @@ -72,5 +69,18 @@ namespace Lskj.PubBill.Model public string AddDataCondition; + /// + /// 单据来源明细模块 + /// + public ModuleGridEx GridDetailModuleGridEx; + /// + /// 主表配置模块号的情况下,对应的明细选项 + /// + public GridDetailModel GridDetailModel; + /// + /// 来源主表主键 + /// + public string ParmaryKey; + } } diff --git a/插件库/Lskj.PubBillManagement/BillModule.Designer.cs b/插件库/Lskj.PubBillManagement/BillModule.Designer.cs new file mode 100644 index 0000000..e93b354 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/BillModule.Designer.cs @@ -0,0 +1,215 @@ +namespace Lskj.PubBillManagement +{ + partial class BillModule + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.barManager1 = new DevExpress.XtraBars.BarManager(); + this.barDockControl1 = new DevExpress.XtraBars.BarDockControl(); + this.barDockControl2 = new DevExpress.XtraBars.BarDockControl(); + this.barDockControl3 = new DevExpress.XtraBars.BarDockControl(); + this.barDockControl5 = new DevExpress.XtraBars.BarDockControl(); + this.pmFP = new DevExpress.XtraBars.PopupMenu(); + this.pmBillExp = new DevExpress.XtraBars.PopupMenu(); + this.pmBill = new DevExpress.XtraBars.PopupMenu(); + this.pMprint = new DevExpress.XtraBars.PopupMenu(); + this.pMenu = new DevExpress.XtraBars.PopupMenu(); + this.tb_buttom = new Lskj.Control.TabControlEx(); + this.pl_Main = new DevExpress.XtraEditors.PanelControl(); + this.xtc_main_container = new DevExpress.XtraTab.XtraTabControl(); + this.ssc_main = new DevExpress.XtraEditors.SplitContainerControl(); + ((System.ComponentModel.ISupportInitialize)(this.barManager1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pmFP)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pmBillExp)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pmBill)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pMprint)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pMenu)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_Main)).BeginInit(); + this.pl_Main.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.xtc_main_container)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.ssc_main)).BeginInit(); + this.ssc_main.SuspendLayout(); + this.SuspendLayout(); + // + // barManager1 + // + this.barManager1.DockControls.Add(this.barDockControl1); + this.barManager1.DockControls.Add(this.barDockControl2); + this.barManager1.DockControls.Add(this.barDockControl3); + this.barManager1.DockControls.Add(this.barDockControl5); + this.barManager1.Form = this; + this.barManager1.MaxItemId = 0; + // + // barDockControl1 + // + this.barDockControl1.CausesValidation = false; + this.barDockControl1.Dock = System.Windows.Forms.DockStyle.Top; + this.barDockControl1.Location = new System.Drawing.Point(0, 0); + this.barDockControl1.Size = new System.Drawing.Size(1511, 0); + // + // barDockControl2 + // + this.barDockControl2.CausesValidation = false; + this.barDockControl2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.barDockControl2.Location = new System.Drawing.Point(0, 730); + this.barDockControl2.Size = new System.Drawing.Size(1511, 0); + // + // barDockControl3 + // + this.barDockControl3.CausesValidation = false; + this.barDockControl3.Dock = System.Windows.Forms.DockStyle.Left; + this.barDockControl3.Location = new System.Drawing.Point(0, 0); + this.barDockControl3.Size = new System.Drawing.Size(0, 730); + // + // barDockControl5 + // + this.barDockControl5.CausesValidation = false; + this.barDockControl5.Dock = System.Windows.Forms.DockStyle.Right; + this.barDockControl5.Location = new System.Drawing.Point(1511, 0); + this.barDockControl5.Size = new System.Drawing.Size(0, 730); + // + // pmFP + // + this.pmFP.Manager = this.barManager1; + this.pmFP.Name = "pmFP"; + // + // pmBillExp + // + this.pmBillExp.Manager = this.barManager1; + this.pmBillExp.Name = "pmBillExp"; + // + // pmBill + // + this.pmBill.Manager = this.barManager1; + this.pmBill.Name = "pmBill"; + // + // pMprint + // + this.pMprint.Manager = this.barManager1; + this.pMprint.Name = "pMprint"; + // + // pMenu + // + this.pMenu.Manager = this.barManager1; + this.pMenu.Name = "pMenu"; + // + // tb_buttom + // + this.tb_buttom.Dock = System.Windows.Forms.DockStyle.Fill; + this.tb_buttom.Location = new System.Drawing.Point(0, 0); + this.tb_buttom.Name = "tb_buttom"; + this.tb_buttom.Size = new System.Drawing.Size(1511, 280); + this.tb_buttom.TabIndex = 25; + this.tb_buttom.Load += new System.EventHandler(this.tb_buttom_Load); + // + // pl_Main + // + this.pl_Main.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_Main.Appearance.Options.UseBackColor = true; + this.pl_Main.Controls.Add(this.xtc_main_container); + this.pl_Main.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_Main.Location = new System.Drawing.Point(0, 0); + this.pl_Main.Name = "pl_Main"; + this.pl_Main.Size = new System.Drawing.Size(1511, 445); + this.pl_Main.TabIndex = 5; + // + // xtc_main_container + // + this.xtc_main_container.Appearance.BackColor = System.Drawing.Color.Transparent; + this.xtc_main_container.Appearance.Options.UseBackColor = true; + this.xtc_main_container.Dock = System.Windows.Forms.DockStyle.Fill; + this.xtc_main_container.HeaderLocation = DevExpress.XtraTab.TabHeaderLocation.Bottom; + this.xtc_main_container.Location = new System.Drawing.Point(2, 2); + this.xtc_main_container.Name = "xtc_main_container"; + this.xtc_main_container.Size = new System.Drawing.Size(1507, 441); + this.xtc_main_container.TabIndex = 0; + this.xtc_main_container.SelectedPageChanged += new DevExpress.XtraTab.TabPageChangedEventHandler(this.OnTabSelectedPageChanged); + // + // ssc_main + // + this.ssc_main.Appearance.BackColor = System.Drawing.Color.Transparent; + this.ssc_main.Appearance.Options.UseBackColor = true; + this.ssc_main.CollapsePanel = DevExpress.XtraEditors.SplitCollapsePanel.Panel2; + this.ssc_main.Dock = System.Windows.Forms.DockStyle.Fill; + this.ssc_main.Horizontal = false; + this.ssc_main.Location = new System.Drawing.Point(0, 0); + this.ssc_main.Name = "ssc_main"; + this.ssc_main.Panel1.Controls.Add(this.pl_Main); + this.ssc_main.Panel1.Text = "Panel1"; + this.ssc_main.Panel2.Controls.Add(this.tb_buttom); + this.ssc_main.Panel2.Text = "Panel2"; + this.ssc_main.Size = new System.Drawing.Size(1511, 730); + this.ssc_main.SplitterPosition = 445; + this.ssc_main.TabIndex = 0; + this.ssc_main.Text = "splitContainerControl1"; + this.ssc_main.SplitterMoved += new System.EventHandler(this.OnMainSplitterMoved); + // + // BillModule + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.Controls.Add(this.ssc_main); + this.Controls.Add(this.barDockControl3); + this.Controls.Add(this.barDockControl5); + this.Controls.Add(this.barDockControl2); + this.Controls.Add(this.barDockControl1); + this.Name = "BillModule"; + this.Size = new System.Drawing.Size(1511, 730); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OnFrmMainKeyDown); + ((System.ComponentModel.ISupportInitialize)(this.barManager1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pmFP)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pmBillExp)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pmBill)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pMprint)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pMenu)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_Main)).EndInit(); + this.pl_Main.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.xtc_main_container)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.ssc_main)).EndInit(); + this.ssc_main.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + + #endregion + private DevExpress.XtraBars.PopupMenu pMenu; + private DevExpress.XtraBars.BarManager barManager1; + private DevExpress.XtraBars.BarDockControl barDockControl1; + private DevExpress.XtraBars.BarDockControl barDockControl2; + private DevExpress.XtraBars.BarDockControl barDockControl3; + private DevExpress.XtraBars.BarDockControl barDockControl5; + private DevExpress.XtraBars.PopupMenu pmBillExp; + private DevExpress.XtraBars.PopupMenu pmBill; + private DevExpress.XtraBars.PopupMenu pMprint; + private DevExpress.XtraBars.PopupMenu pmFP; + private DevExpress.XtraEditors.SplitContainerControl ssc_main; + private DevExpress.XtraEditors.PanelControl pl_Main; + private DevExpress.XtraTab.XtraTabControl xtc_main_container; + private Control.TabControlEx tb_buttom; + } +} diff --git a/插件库/Lskj.PubBillManagement/BillModule.cs b/插件库/Lskj.PubBillManagement/BillModule.cs new file mode 100644 index 0000000..bb2b6de --- /dev/null +++ b/插件库/Lskj.PubBillManagement/BillModule.cs @@ -0,0 +1,2474 @@ +using DevExpress.Data; +using DevExpress.Utils; +using DevExpress.XtraBars; +using DevExpress.XtraEditors; +using DevExpress.XtraGrid.Columns; +using DevExpress.XtraGrid.Views.Base; +using DevExpress.XtraGrid.Views.Grid; +using DevExpress.XtraTab; +using DevExpress.XtraTreeList.Columns; +using DevExpress.XtraTreeList.Nodes; +using Lskj.Business; +using Lskj.Business.Impl; +using Lskj.Control; +using Lskj.Control.BrowserSetting; +using Lskj.Control.Model; +using Lskj.Core; +using Lskj.Data; +using Lskj.Model; +using Lskj.PubBillManagement.Model; +using Lskj.Util; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Data.SqlClient; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Net; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Lskj.PubBillManagement +{ + public partial class BillModule : UserControl + { + /// + /// 是否为初始化创建 + /// + private bool _isInitFinish; + /// + /// 是否加载右侧控件数据 + /// + private bool _isLoadRightControlValue = true; + /// + /// 是否手动选择了模版 + /// + private bool _isSelectedTemplete; + /// + /// 是否直接打印 + /// + private bool _isExcPrint; + /// + /// 是否选择关联下发 + /// + private bool _isCheck; + /// + /// 主打印Sql + /// + private string _mainPrintSql; + private string guidField = "xxxxx_guid"; + /// + /// 主键字段 + /// + private string mRecordPrimaryField; + /// + /// 单据水印 + /// + private WaterMark _waterMark; + /// + /// 导入单据明细数据、导入单据明细并更新 + /// + private BarButtonItem _itemImport, _itemImportUpdate; + /// + /// 打印主sql中关联打印次数返回条件 + /// + private string _printModeCond; + /// + /// 打印完成后添加数据用到的参数: 表名,列前缀,主键字段,主键值,模块编号,主打印Sql + /// + private List _printSaveParams; + /// + /// 单据明细列 + /// + private DataTable _detailColumns; + private bool IsCopying = false; + + + protected DataRow BillRowItem; + /// + /// 主表控件 + /// + public MyControl ControlObj; + /// + /// 入口参数 + /// + protected DynamicBillModel SysModel; + /// + /// 是否为Brp模版 + /// + /// true if this instance is BRP templete; otherwise, false. + protected bool IsBrpTemplete { get { return SysModel is DynamicBillBrpModel; } } + /// + /// + /// + public BillModel BillModel; + /// + /// 数量名称 + /// + public string NumberMc; + /// + /// 红字单据的分配管理模块 + /// + public string rdRedUnionCode; + /// + /// 蓝字单据的分配管理模块 + /// + public string rdBlueUnionCode; + /// + /// 蓝字单据的分配管理模块 + /// + Dictionary pageNumKey = new Dictionary(); + /// + /// 是否拖拽换行展示 + /// + public bool isDragWrap = true; + /// + /// 触发主表改变刷新来源限制 + /// + private bool IsBillMaster = true; + /// + /// 是否执行了加载储存过程 + /// + //public bool ProcessExists = false; + /// + /// 保存或修改时报错信息 + /// + public string SaveErrorMessage = string.Empty; + /// + /// 单据明细删除的行 + /// + // private Dictionary ToWithdrawRows = new Dictionary(); + private List> ToWithdrawRows = new List>(); + /// + ///改变颜色行 + /// + private List ChangeColorRow = new List(); + /// + /// + /// + public string AssociatedField = string.Empty; + /// + /// 注册设置公共事件私有类 + /// + private static PubEvenImpl _eventHandler; + /// + /// 注册设置公共事件类 + /// + private static PubEvenImpl eventHandler; + /// + /// 当前人员是否有导出权限 + /// + public bool ExportPermission; + /// + /// 是否显示单据管理条数 + /// + public bool IsBillShowCount = false; + /// + /// 来源明细的页面名字后缀(设置成全局变量,更好的处理语言翻译的情况) + /// + public string DetailedSuffix = Business.Impl.LanguageTranslation.Translatable ? "-" + Business.Impl.LanguageTranslation.GetTranslatedText("明细") : "-明细"; + /// + /// 数量后缀 + /// + public string QuantitySuffix = Business.Impl.LanguageTranslation.Translatable ? Business.Impl.LanguageTranslation.GetTranslatedText("条") + ")" : "条)"; + /// + /// 新增 + /// + public string addText = Business.Impl.LanguageTranslation.Translatable ? "(" + Business.Impl.LanguageTranslation.GetTranslatedText("新增") + ")" : "(新增)"; + /// + /// 修改 + /// + public string updateText = Business.Impl.LanguageTranslation.Translatable ? "(" + Business.Impl.LanguageTranslation.GetTranslatedText("修改") + ")" : "(修改)"; + + + /// + /// 单据来源控件集合 + /// + public Dictionary BillModuleModelDic = new Dictionary(); + /// + /// 主表动态生成的日期列 + /// + public List DateColumnList = new List(); + /// + /// 主表动态生成的合计列 + /// + public GridColumn SumGridColumn = new GridColumn(); + /// + /// 附加右键菜单集合 + /// + public List itemCommonList = new List(); + /// + /// 是否已经添加了多行汇总 + /// + public bool MultiLineSummary; + /// + /// 扫码框 + /// + public TextEdit ScanCodeTextEdit = null; + /// + /// 初始化时选中的页签 + /// + public XtraTabPage InitialSelectionTab = null; + /// + /// 当前操作的ImageEdit + /// + private LabelImageEdit _imageEdit; + /// + /// 当前来源明细中变色行 + /// + private HashSet ColorHandles = new HashSet(); + /// + /// 保存验证条件表 + /// + public DataTable SaveCondTab = new DataTable(); + + + + public BillModule() + { + InitializeComponent(); + } + + #region 初始化操作 + /// + /// 说明:窗口加载 + /// 创建人:龚宇超 + /// 创建日期:2017-11-23 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The instance containing the event data. + public void OnLoad(DynamicBillModel Model) + { + try + { + this.SysModel = Model;// 单据动态链接库参数,入口参数 + this._isInitFinish = false;// 是否为初始化创建 + this.ssc_main.Visible = false; //获取或设置一个值,该值指示是否显示该控件及其所有子控件。 + //this.ProcessExists = (Lskj.Data.Caches.CacheSYSConfig.Instance().JudgeProcessExists() && SystemInfo.Instance.isExecload); + + + + Dictionary dataCaches = Model != null ? Model.DataCaches : null; + dataCaches.GetValue(this, "DataCaches", out bool _);//等待缓存数据加载完成 + this.InitializeSetting();//初始化系统配置 + this.InitializeControl();//初始化控件 + this.InitlizeSpiltLocation(); + + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("单据初始化窗体失败!", ex); + MessageUtil.Show(ex.StackTrace); + } + finally + { + this._isInitFinish = true; + this.ssc_main.Visible = true; + } + } + + + /// + /// 获取数据源缓存 + /// + /// + public void GetDataCaches(Dictionary cachesDic) + { + //获取通用数据 + Task sysModelTask = cachesDic.GetTask(this, "SysModel"); + Task systemDllRowTask = cachesDic.GetTask(this, "SystemDllRow"); + Task dynamicModelTask = cachesDic.GetTask(this, "DynamicModel"); + Task getDataCachesTask = cachesDic.AddTask(this, "DataCaches", new Task(() => + { + DynamicBillModel dynamicModel = (DynamicBillModel)dynamicModelTask.Result; + #region InitializeSetting初始化系统配置 + Task billInfoRowTask = cachesDic.AddTask(this, "BillInfo", new Task(() => + { + return BillImpl.GetBillInfo(dynamicModel.ModuleCode);//获取单个模块信息 + })); + Task billModelTask = cachesDic.AddTask(this, "BillModel", new Task(() => + { + BillModel model = null; + if (billInfoRowTask.Result != null) + { + model = new BillModel(billInfoRowTask.Result); + } + return model; + })); + BillModel billModel = billModelTask.Result; + if (billModel != null) + { + Task masterPreFixTask = cachesDic.AddTask(this, "MasterPreFix", new Task(() => + { + return BaseImpl.GetColumnPrefix(billModel.MasterTable);// 主表列前缀 + })); + Task detailPreFixTask = cachesDic.AddTask(this, "DetailPreFix", new Task(() => + { + return BaseImpl.GetColumnPrefix(billModel.DetailTable);// 明细表列前缀 + })); + } + Task menuConfigTabTask = cachesDic.AddTask(this, "MenuConfigTab", new Task(() => + { + DataRow dataRow = BaseImpl.GetMenuConfigTab(dynamicModel.ModuleId); + if (dataRow != null) + { + billModel.BillSourceIds = dataRow.Table.Columns.Contains("BillSourceIds") ? (dataRow["BillSourceIds"] + "").Trim(',') : string.Empty; + billModel.BillFlag = dataRow.Table.Columns.Contains("BillFlag") && !string.IsNullOrEmpty(dataRow["BillFlag"] + "") ? Convert.ToInt32(dataRow["BillFlag"] + "") : -1; + //billModel + } + return dataRow;//获取菜单其他配置 + })); + #region GetPrintOtherParam获取打印其他参数 + if (string.IsNullOrEmpty(billModel.PrintSql) && billModel.PrintSql.Contains("<<")) + { + string[] strs = billModel.PrintSql.Split(new[] { ">>" }, 2, StringSplitOptions.None); + _mainPrintSql = strs[1]; + _printModeCond = strs[0].Replace("<<", ""); + } + if (!string.IsNullOrEmpty(_printModeCond) && _printModeCond.IndexOf(';') > 0) + { + string[] str = _printModeCond.Split(';'); + Task printOtherSystemRowTask = cachesDic.AddTask(this, "PrintOtherSystemRow", new Task(() => + { + return AttachImpl.GetSystemModule(str[0]); + })); + Task printOtherColumnPrefixTask = cachesDic.AddTask(this, "PrintOtherColumnPrefix", new Task(() => + { + string tableName = printOtherSystemRowTask.Result["TableName"] + ""; + return BaseImpl.GetColumnPrefix(tableName); + })); + Task printOtherPrimaryKeyTask = cachesDic.AddTask(this, "PrintOtherPrimaryKey", new Task(() => + { + string modetype = printOtherSystemRowTask.Result["modType"] + ""; + return modetype == "1" ? BaseImpl.GetBasePrimaryKey(str[0]) : printOtherColumnPrefixTask.Result + "billdocument_id"; + })); + Task printOtherIsExcPrintTask = cachesDic.AddTask(this, "PrintOtherIsExcPrint", new Task(() => + { + string modetype = printOtherSystemRowTask.Result["modType"] + ""; + switch (modetype) + { + case "1": + ModuleModel mode = new ModuleModel(MainImpl.GetSystemdllTab(str[0])); + if (mode != null) + { + return mode.PrintType == 3; + } + break; + case "2": + BaseAccraditationModel model = new BaseAccraditationModel(BillAuditImpl.GetPubAuditProperty(str[0])); + if (model != null) + { + return model.BillPrintType == 3; + } + break; + } + return false; + })); + } + #endregion + Task billSettingTask = cachesDic.AddTask(this, "BillSetting", new Task(() => + { + BillImpl.InitBillSetting(billModel); + return true; + })); + #endregion + + + if (billModel.PanelWidth > 0) + { + #region InitializeBillSource初始化单据来源 + Task> detailTask = cachesDic.AddTask(this, "Details", new Task>(() => + { + List details = new List(); + DataTable table = BaseAuditImpl.GetAttachTabs(dynamicModel.ModuleCode, "100", " and orderid < 0 "); + foreach (DataRow item in table.Rows) + { + GridDetailModel gridDetailModel = new GridDetailModel(item, null, GridCustomColumnStruct.BillSourceDetailAttachGridView); + details.Add(gridDetailModel); + Task addGridColumnsTask = cachesDic.AddTask(gridDetailModel, "GridColumns", new Task(() => + { + DataTable gridColumns = BaseAuditImpl.GetBottomBasicInformation(item["formKey"] + ""); + gridDetailModel.GridColumns = gridColumns; + return gridColumns; + })); + } + return details; + })); + Task sourcesTask = cachesDic.AddTask(this, "Sources", new Task(() => + { + DataRow menuConfigRow = menuConfigTabTask.Result; + string SourceIds = (billModel.BillSourceIds + "").Trim(','); + if (!string.IsNullOrWhiteSpace(dynamicModel.SourceDetailsID)) + { + SourceIds = (SourceIds + "," + dynamicModel.SourceDetailsID).Trim(','); + } + return BillImpl.GetSources(dynamicModel.ModuleCode, SourceIds);//获取单据来源 + })); + cachesDic.AddTask(tb_buttom, "DynamicModel", dynamicModelTask); + cachesDic.AddTask(tb_buttom, "Details", detailTask); + tb_buttom.GetDataCaches(cachesDic); + Task initSourcesTask = cachesDic.AddTask(this, "InitSourcesTask", new Task(() => + { + Hashtable htTable = sourcesTask.Result; + DataTable masterTable = htTable["master"] as DataTable; + DataTable detailTable = htTable["detail"] as DataTable; + for (int i = 0; i < masterTable.Rows.Count; i++) + { + DataRow sourceModelRow = masterTable.Rows[i]; + BillModuleModel billModuleModel = new BillModuleModel(); + BillSourceModel model = new BillSourceModel(sourceModelRow); + billModuleModel.SourceModel = model; + Task customQueryFieldsTask = cachesDic.AddTask(model, "CustomQueryFields", new Task(() => + { + return BaseModuleImpl.GetCustomQueryFields(model.FormKey); + })); + #region 加载来源表头 + GridControlEx gridControl = null; + TreeViewEx treeView = null; + if (model.SourceType == 1) + { + // 来源为树类型 + treeView = new TreeViewEx(); + billModuleModel.SourceControl = treeView; + Task bindTreeTableTask = cachesDic.AddTask(treeView, "BindTreeTable", new Task(() => + { + return BaseImpl.GetDataTableResult(model.SourceSql); + })); + } + else if (model.SourceType == 5) + { + model.ChangeSourceType(2);//单据来源显示条数 + } + else if (model.SourceType == 3 || model.SourceType == 4) + { + gridControl = new TreeGridControlEx(); + billModuleModel.SourceControl = gridControl; + Task sourceColumnsTask = cachesDic.AddTask(gridControl, "SourceColumns", new Task(() => + { + return BillImpl.GetSourceColumns(model.Id); + })); + Task sourceGridRowColorsTask = cachesDic.AddTask(gridControl, "BaseGridRowColors", new Task(() => + { + return BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey); + })); + Task sourceGridRightMenusTask = cachesDic.AddTask(gridControl, "BaseGridRightMenus", new Task(() => + { + return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey); + })); + } + else + { + // 来源为表格类型 + gridControl = new GridControlEx(); + billModuleModel.SourceControl = gridControl; + Task sourceColumnsTask = cachesDic.AddTask(gridControl, "SourceColumns", new Task(() => + { + return BillImpl.GetSourceColumns(model.Id); + })); + //创建表格列 + cachesDic.AddTask(gridControl, "DynamicModel", dynamicModelTask); + gridControl.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceGridView + model.FormKey); + Task sourceGridRowColorsTask = cachesDic.AddTask(gridControl, "BaseGridRowColors", new Task(() => + { + return BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey); + })); + Task sourceGridRightMenusTask = cachesDic.AddTask(gridControl, "BaseGridRightMenus", new Task(() => + { + return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey); + })); + } + #endregion + #region 加载来源明细 + GridControlEx gridDetail = new GridControlEx(); + if (model.sourceDetailType.Equals("1")) + { + //明细为树表格 + gridDetail = new TreeGridControlEx(); + billModuleModel.SourceDetailControl = gridDetail; + //创建表格列 + cachesDic.AddTask(gridDetail, "DynamicModel", dynamicModelTask); + gridDetail.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey); + Task detailGridRowColorsTask = cachesDic.AddTask(gridDetail, "BaseGridRowColors", new Task(() => + { + return BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey); + })); + Task detailGridRightMenusTask = cachesDic.AddTask(gridDetail, "BaseGridRightMenus", new Task(() => + { + return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey); + })); + + } + else + { + gridDetail = new GridControlEx(); + billModuleModel.SourceDetailControl = gridDetail; + //创建表格列 + cachesDic.AddTask(gridDetail, "DynamicModel", dynamicModelTask); + gridDetail.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey); + Task detailGridRowColorsTask = cachesDic.AddTask(gridDetail, "BaseGridRowColors", new Task(() => + { + return BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey); + })); + Task detailGridRightMenusTask = cachesDic.AddTask(gridDetail, "BaseGridRightMenus", new Task(() => + { + return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey); + })); + //明细的明细(明细分成左右2个) + if (!string.IsNullOrEmpty(model.SourceDetailsDetailsSql)) + { + GridControlEx gridDetail_Details = new GridControlEx(); + billModuleModel.SourceDetailDetailControl = gridDetail_Details; + //创建只读列 + Task detailDetailsTask = cachesDic.AddTask(gridDetail_Details, "DetailDetails", new Task(() => + { + return BaseModuleImpl.getDetail_Details(model.FormKey); + })); + //创建表格列 + cachesDic.AddTask(gridDetail_Details, "DynamicModel", dynamicModelTask); + gridDetail_Details.GetDataCaches(cachesDic); + Task detailDetailsGridRightMenusTask = cachesDic.AddTask(gridDetail_Details, "BaseGridRightMenus", new Task(() => + { + return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDTX_" + model.FormKey); + })); + } + } + #endregion + BillModuleModelDic.Add(sourceModelRow, billModuleModel); + #region 加载来源条件 + Task searchControlTask = cachesDic.AddTask(sourceModelRow, "SearchControl", new Task(() => + { + DataTable controls = customQueryFieldsTask.Result; + MyControl searchControl = null; + if (model.SourceType != 1 || (controls != null && controls.Rows.Count > 0)) + { + // 创建自定义条件 + string searchSql = model.SourceType == 1 ? Regex.Replace(model.DetailSql, "{speciesno}", "", RegexOptions.IgnoreCase) : model.SourceSql; + searchControl = new MyControl(searchSql, gridControl == null ? gridDetail : gridControl, treeView); + searchControl.Model = dynamicModel; + searchControl.OtherParams = dynamicModel.OtherParams(); + cachesDic.AddTask(searchControl, "DynamicModel", dynamicModelTask); + cachesDic.AddTask(searchControl, "ControlsTable", customQueryFieldsTask); + searchControl.GetSearchDataCaches(cachesDic); + } + return searchControl; + })); + #endregion + } + return true; + })); + #endregion + } + return true; + })); + #endregion + } + + + /// + /// 说明:初始化分割条位置 + /// 创建人:龚宇超 + /// 创建日期:2018-03-06 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitlizeSpiltLocation() + { + try + { + // 设置单据来源底部高度 + if (this.BillModel.PanelHeight == 0) + { + // 隐藏来源明细 + this.ssc_main.PanelVisibility = SplitPanelVisibility.Panel1; + } + else + { + string height = IniHelper.Read(string.Format("bill_height_{0}", this.SysModel.ModuleCode)); + if (!string.IsNullOrEmpty(height)) + this.ssc_main.SplitterPosition = Convert.ToInt32(height); + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + } + + } + /// + /// 说明:初始化系统配置 + /// 创建人:龚宇超 + /// 创建日期:2017-11-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeSetting() + { + Dictionary dataCaches = SysModel != null ? SysModel.DataCaches : null; + if (!dataCaches.GetValue(this, "BillInfo", out DataRow modelRow)) + { + modelRow = BillImpl.GetBillInfo(this.SysModel.ModuleCode);//获取单个模块信息 + } + if (modelRow == null) + { + throw new Exception("模块编号[" + this.SysModel.ModuleCode + "],配置错误!\r\n该模块信息未找到!"); + } + if (!dataCaches.GetValue(this, "BillModel", out BillModel)) + { + this.BillModel = new BillModel(modelRow);//初始化类的新实例。 + } + + if (this.BillModel != null) + { + this.BillModel.TypeName = string.IsNullOrEmpty(SysModel.BillMasterSql) ? this.SysModel.FormText : this.BillModel.TypeName;// 模块名称 + if (!string.IsNullOrWhiteSpace(this.SysModel.DocumentName)) this.BillModel.TypeName = this.SysModel.DocumentName; + + if (!dataCaches.GetValue(this, "MasterPreFix", out string masterPreFix)) + { + masterPreFix = BaseImpl.GetColumnPrefix(this.BillModel.MasterTable);// 主表列前缀 + } + this.BillModel.MasterPreFix = masterPreFix; + if (!dataCaches.GetValue(this, "DetailPreFix", out string detailPreFix)) + { + detailPreFix = BaseImpl.GetColumnPrefix(this.BillModel.DetailTable);// 明细表列前缀 + } + this.BillModel.DetailPreFix = detailPreFix; + this.BillModel.DetailOrderField = this.BillModel.DetailPreFix + "lsidx_id";// 单据来源id + if (SystemInfo.Instance.IsNotBillDetailOrder)//禁用排序 + this.BillModel.DetailOrderField = string.Empty; + } + if (!dataCaches.GetValue(this, "MenuConfigTab", out DataRow menuRow)) + { + menuRow = BaseImpl.GetMenuConfigTab(this.SysModel.ModuleId);//获取菜单其他配置 + } + if (menuRow != null) + { + this.BillModel.BillSourceIds = menuRow.Table.Columns.Contains("BillSourceIds") ? (menuRow["BillSourceIds"] + "").Trim(',') : string.Empty; + this.BillModel.BillFlag = menuRow.Table.Columns.Contains("BillFlag") && !string.IsNullOrEmpty(menuRow["BillFlag"] + "") ? Convert.ToInt32(menuRow["BillFlag"] + "") : -1; + } + if (this.SysModel.HideSource) + { + this.BillModel.PanelWidth = 0; + this.BillModel.PanelHeight = 0; + } + + if (!dataCaches.GetValue(this, "BillSetting", out bool _)) + { + BillImpl.InitBillSetting(this.BillModel); + } + } + + /// + /// 说明:初始化控件 + /// 创建人:龚宇超 + /// 创建日期:2017-11-23 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeControl() + { + this.InitializeBillSource();//初始化单据来源 + } + + + /// + /// 点击第一个默认新增行新增默认数据 + /// + /// + /// + private void GridView_MouseDown(object sender, MouseEventArgs e) + { + + } + + + /// + /// 说明:初始化单据来源 + /// 创建人:龚宇超 + /// 创建日期:2017-11-28 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeBillSource() + { + this.xtc_main_container.TabPages.Clear(); + + Dictionary dataCaches = SysModel != null ? SysModel.DataCaches : null; + if (!dataCaches.GetValue(this, "Details", out List attachModels)) + { + attachModels = GetAttachTabs(); + } + if (!dataCaches.GetValue(this, "Sources", out Hashtable htTable)) + { + string SourceIds = (this.BillModel.BillSourceIds + "").Trim(','); + if (!string.IsNullOrWhiteSpace(this.SysModel.SourceDetailsID)) + { + SourceIds = (SourceIds + "," + this.SysModel.SourceDetailsID).Trim(','); + } + htTable = BillImpl.GetSources(this.SysModel.ModuleCode, SourceIds);//获取单据来源 + } + DataTable masterTable = htTable["master"] as DataTable; + DataTable detailTable = htTable["detail"] as DataTable; + + + + + /* 构造原理 + * 1. 假如存在附加信息,则底部显示来源明细(来源明细摆放在标签第一个位置)+多标签,假如标签只有一个则隐藏标签头. + * 2. 假如不存在附加信息,则底部只显示来源明细. + **/ + if (attachModels.Count > 0) + { + this.tb_buttom.Model = this.SysModel; + this.tb_buttom.ParentControlEx = this.ControlObj; + //this.tb_buttom.ParentGridEx = this.gcMain; + if (this.BillModel.RefreshSelectedDetail) + { + //配置了只刷新当前页签后,切换页签时刷新 + this.tb_buttom.TabControlObj.SelectedPageChanged += TabControlObj_SelectedPageChanged; + } + this.tb_buttom.InitTabPages(attachModels); + + } + else + { + this.tb_buttom.TabControlObj.ShowTabHeader = DevExpress.Utils.DefaultBoolean.False; + } + dataCaches.GetValue(this, "InitSourcesTask", out bool _); + + int SerialNumber = 0; + for (int i = 0; i < masterTable.Rows.Count; i++) + { + DataRow sourceModelRow = masterTable.Rows[i]; + BillModuleModel billModuleModel = BillModuleModelDic.ContainsKey(sourceModelRow) ? BillModuleModelDic[sourceModelRow] : new BillModuleModel(); + BillSourceModel model = billModuleModel.SourceModel != null ? billModuleModel.SourceModel : new BillSourceModel(sourceModelRow); + object sourceControl = billModuleModel.SourceControl != null ? billModuleModel.SourceControl : null; + object sourceDetailControl = billModuleModel.SourceDetailControl != null ? billModuleModel.SourceDetailControl : null; + object sourceDetailDetailControl = billModuleModel.SourceDetailDetailControl != null ? billModuleModel.SourceDetailDetailControl : null; + BillSourceUnionModel unionModel = new BillSourceUnionModel(); + if (!dataCaches.GetValue(model, "CustomQueryFields", out DataTable controls)) + { + controls = BaseModuleImpl.GetCustomQueryFields(model.FormKey); + } + + + XtraTabPage tabPage = new XtraTabPage(); + tabPage.Text = model.UserName; + + //只加载单据管理类型 + if (!(model.SourceType == 2 || model.SourceType == 4)) continue; + + + #region 加载来源表头 + GridControlEx gridControl = null; + TreeViewEx treeView = null; + + if (model.SourceType == 1) + { + // 来源为树类型 + treeView = sourceControl != null ? (TreeViewEx)sourceControl : new TreeViewEx(); + treeView.BorderStyle = BorderStyle.None; + treeView.Dock = DockStyle.Fill; + treeView.TreeNodeKeyField = model.SourceKeyField; + treeView.TreeNodeTextField = model.SourceResult; + if (!dataCaches.GetValue(treeView, "BindTreeTable", out DataTable bindTreeTable)) + { + bindTreeTable = BaseImpl.GetDataTableResult(model.SourceSql); + } + treeView.TreeInhibitSort = model.TreeInhibitSort; + treeView.BindTreeView(bindTreeTable); + treeView.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeNodeSelectAfter); + + tabPage.Controls.Add(treeView); + } + else if (model.SourceType == 5) + { + model.ChangeSourceType(2);//单据来源显示条数 + this.IsBillShowCount = true; + } + else if (model.SourceType == 3 || model.SourceType == 4) + { + //类型为3,是树表格类型的单据管理。 + //类型为4,是树表格类型的数据来源 + gridControl = sourceControl != null ? (TreeGridControlEx)sourceControl : new TreeGridControlEx(); + gridControl.Dock = DockStyle.Fill; + gridControl.BorderStyle = System.Windows.Forms.BorderStyle.None; + gridControl.Model = this.SysModel; + + if (!dataCaches.GetValue(gridControl, "SourceColumns", out DataTable dtSourceColumns)) + { + dtSourceColumns = BillImpl.GetSourceColumns(model.Id); + } + if (!dataCaches.GetValue(gridControl, "BaseGridRowColors", out DataTable dtBaseGridRowColors)) + { + dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey); + } + if (!dataCaches.GetValue(gridControl, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus)) + { + dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey); + } + + //节点编号 + if (!string.IsNullOrWhiteSpace(model.SourceKeyFieldName)) (gridControl as TreeGridControlEx).TreeListObj.KeyFieldName = model.SourceKeyFieldName; + //父节点编号 + if (!string.IsNullOrWhiteSpace(model.SourceParentFieldName)) (gridControl as TreeGridControlEx).TreeListObj.ParentFieldName = model.SourceParentFieldName; + + gridControl.SetReadOnlyColumns(dtSourceColumns, GridCustomColumnStruct.BillSourceGridView + model.FormKey); + gridControl.SetGridRowColors(dtBaseGridRowColors); + //gridControl.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback); + (gridControl as TreeGridControlEx).SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback); + unionModel.TreeGridControlObj = gridControl as TreeGridControlEx; + unionModel.TreeGridControlObj.TreeListObj.FocusedNodeChanged += new DevExpress.XtraTreeList.FocusedNodeChangedEventHandler(OnTreeListObjFocusedNodeChanged); + + + if (BillModel.IsBillSourceCheck == 1) + { + GridDragGrid.TreeListAddCheckBox((gridControl as TreeGridControlEx).TreeListObj); + } + tabPage.Controls.Add(gridControl); + } + else + { + // 来源为表格类型 + gridControl = sourceControl != null ? (GridControlEx)sourceControl : new GridControlEx(); + gridControl.BorderStyle = BorderStyle.None; + gridControl.Model = this.SysModel; + gridControl.Dock = DockStyle.Fill; + gridControl.ExportPermission = this.BillModel.ExportPermission; + + if (model.LoadFilter) + { + gridControl.GridView.OptionsView.ShowAutoFilterRow = true; + } + if (!dataCaches.GetValue(gridControl, "SourceColumns", out DataTable dtSourceColumns)) + { + dtSourceColumns = BillImpl.GetSourceColumns(model.Id); + } + if (!dataCaches.GetValue(gridControl, "BaseGridRowColors", out DataTable dtBaseGridRowColors)) + { + dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey); + } + if (!dataCaches.GetValue(gridControl, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus)) + { + dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey); + } + gridControl.SetReadOnlyColumns(dtSourceColumns, GridCustomColumnStruct.BillSourceGridView + model.FormKey); + gridControl.SetGridRowColors(dtBaseGridRowColors); + gridControl.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback); + //gridControl.GridView.SelectionChanged += new SelectionChangedEventHandler(OnGridControlSelectionChanged); + //gridControl.GridView.FocusedRowObjectChanged += OnFocusedRowObjectChanged; + //if (model.DetailsDoubleClick) + //{ + // gridControl.GridView.DoubleClick += OnSourceGridViewDoubleClick; // 2023-3-11 增加双击配置 + //} + //else + //{ + // gridControl.GridView.RowCellClick += OnGridViewRowCellClick; // 2019-11-12 cmd提出改为行点击事件,否则会出现保存提交后,单据管理无法查询出数据 + //} + + gridControl.GridView.RowCellClick += OnGridViewRowCellClick; // 2019-11-12 cmd提出改为行点击事件,否则会出现保存提交后,单据管理无法查询出数据 + + gridControl.GridView.DoubleClick += OnSourceGridViewDoubleClick;//双击事件改成打开单据主消息控件 + + + if (BillModel.IsBillSourceCheck == 1) + { + GridDragGrid.GridAddCheckBox(gridControl.GridView); + } + tabPage.Controls.Add(gridControl); + } + #endregion + + #region 加载来源明细 + XtraTabPage tabDetail = new XtraTabPage(); + + if (SystemInfo.Instance.GridRowFontSize > 0) + { + //页签大小 + FontFamily fontFamily = tabDetail.Appearance.Header.Font.FontFamily; + tabDetail.Appearance.Header.Font = new System.Drawing.Font(fontFamily, SystemInfo.Instance.GridRowFontSize); + } + + DataRow[] detailColumns = detailTable.Select("sourceId=" + model.Id); + + + //明细为表格 + GridControlEx gridDetail = new GridControlEx(); + + + + if (!string.IsNullOrWhiteSpace(model.DetailMenuCode)) + { + //来源明细配置了模块号,根据模块号创建对应的ModuleGridEx + //ModuleGridEx主要是用保存的功能,数据源sql还是根据配置的为准 + DataRow modelRow = MainImpl.GetSystemdllTab(model.DetailMenuCode);//获取模块信息 + if (modelRow == null) + { + MessageUtil.Show($"没有找到编号为 {model.DetailMenuCode} 的模块信息"); + gridDetail.Parent = gridDetail; + continue; + } + + ModuleModel sysModel = new ModuleModel(modelRow); + //设置主表sql + //model.SourceSql = sysModel.MenuSql; + + DynamicModuleModel dyncModel = new DynamicModuleModel(new[] + { sysModel.MenuName, ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, + this.SysModel.Privilege, sysModel.ModeCode, "0" }); + + ModuleGridEx gridEx = new ModuleGridEx(); + gridEx.Dock = DockStyle.Fill; + if (model.SourceType == 1) + { + gridEx.LeftTreeViewEx = treeView; + } + else + { + gridEx.LeftGridEx = gridControl; + gridEx.ParentGridEx = gridControl; + } + gridEx.ParentKeyField = model.SourceKeyField; + gridEx.ParentUnionField = model.SourceKeyField; + + gridEx.VisibleSearchPanel = false;//禁止上方搜索 + gridEx.InitializeControl(sysModel, dyncModel); + + + gridDetail = gridEx.GridControlObj; + gridEx.Parent = tabDetail; + unionModel.GridDetailModuleGridEx = gridEx; + + if (sysModel.TreeAutoMultiHeader == 1) model.ChangeSourceDetailType("1"); + + + + if (SerialNumber == 0) + { + this.tb_buttom.TabControlObj.TabPages.Insert(0, tabDetail); + this.tb_buttom.TabControlObj.SelectedTabPageIndex = 0; + if (attachModels.Count > 0) + this.tb_buttom.TabControlObj.TabPages[0].Text = model.UserName + DetailedSuffix; + } + + } + else + { + if (model.sourceDetailType.Equals("1")) + { + //明细为树表格 + gridDetail = sourceDetailControl != null ? (TreeGridControlEx)sourceDetailControl : new TreeGridControlEx(); + gridDetail.Model = this.SysModel; + gridDetail.Dock = DockStyle.Fill; + gridDetail.SetReadOnlyColumns(detailColumns == null || detailColumns.Length == 0 ? new DataTable() : detailColumns.CopyToDataTable(), GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey); + if (!dataCaches.GetValue(gridDetail, "BaseGridRowColors", out DataTable dtBaseGridRowColors)) + { + dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey); + } + if (!dataCaches.GetValue(gridDetail, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus)) + { + dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey); + } + gridDetail.SetGridRowColors(dtBaseGridRowColors); + gridDetail.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridDetailRightMenuCallback); + gridDetail.Parent = tabDetail; + gridDetail.BorderStyle = System.Windows.Forms.BorderStyle.None; + + if (SerialNumber == 0) + { + this.tb_buttom.TabControlObj.TabPages.Insert(0, tabDetail); + this.tb_buttom.TabControlObj.SelectedTabPageIndex = 0; + if (attachModels.Count > 0) + this.tb_buttom.TabControlObj.TabPages[0].Text = model.UserName + DetailedSuffix; + } + + if (BillModel.IsBillDetailCheck == 1)//加载复选框 + { + GridDragGrid.TreeListAddCheckBox((gridDetail as TreeGridControlEx).TreeListObj); + } + } + else + { + + gridDetail = sourceDetailControl != null ? (GridControlEx)sourceDetailControl : new GridControlEx(); + gridDetail.Model = this.SysModel; + gridDetail.Dock = DockStyle.Fill; + gridDetail.SetReadOnlyColumns(detailColumns == null || detailColumns.Length == 0 ? new DataTable() : detailColumns.CopyToDataTable(), GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey); + + if (model.DetailedLoadFilter) + { + gridDetail.GridView.OptionsView.ShowAutoFilterRow = true; + } + if (!dataCaches.GetValue(gridDetail, "BaseGridRowColors", out DataTable dtBaseGridRowColors)) + { + dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey); + } + if (!dataCaches.GetValue(gridDetail, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus)) + { + dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey); + } + gridDetail.SetGridRowColors(dtBaseGridRowColors); + gridDetail.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridDetailRightMenuCallback); + + //明细的明细(明细分成左右2个) + if (!string.IsNullOrEmpty(model.SourceDetailsDetailsSql)) + { + GridControlEx gridDetail_Details = sourceDetailDetailControl != null ? (GridControlEx)sourceDetailDetailControl : new GridControlEx(); + gridDetail_Details.Model = this.SysModel; + gridDetail_Details.Dock = DockStyle.Fill; + //创建只读列 + if (!dataCaches.GetValue(gridDetail_Details, "Detail_Details", out DataTable dataTable)) + { + dataTable = BaseModuleImpl.getDetail_Details(model.FormKey); + } + gridDetail_Details.SetReadOnlyColumns(dataTable); + //设置右键 + if (!dataCaches.GetValue(gridDetail_Details, "BaseGridRightMenus", out DataTable dttBaseGridRightMenus)) + { + dttBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDTX_" + model.FormKey); + } + gridDetail_Details.SetGridRightMenus(dttBaseGridRightMenus, this.SysModel, OnGridDetailRightMenuCallback); + //明细点击 更新 明细的明细 + gridDetail.GridView.FocusedRowObjectChanged += GridView_FocusedRowObjectChanged; + gridDetail.GridView.Tag = model.SourceDetailsDetailsSql; + //创建SplitContainerControl控件,让下方可以左右拖动 + SplitContainerControl splitContainerControl = new DevExpress.XtraEditors.SplitContainerControl(); + splitContainerControl.Dock = DockStyle.Fill; + splitContainerControl.Panel1.Controls.Add(gridDetail); + gridDetail.BorderStyle = System.Windows.Forms.BorderStyle.None; + splitContainerControl.Panel2.Controls.Add(gridDetail_Details); + gridDetail_Details.BorderStyle = System.Windows.Forms.BorderStyle.None; + + splitContainerControl.SplitterMoved += new System.EventHandler(this.OnDetailsSplitterMoved); + string newwidth = IniHelper.Read(string.Format("bill_Details_Width_{0}", this.SysModel.ModuleCode));//通过Key获取Value值 + if (!string.IsNullOrEmpty(newwidth)) + { + splitContainerControl.SplitterPosition = Convert.ToInt32(newwidth); + } + else + { + int width = this.tb_buttom.Width;//获取控件宽度 + splitContainerControl.SplitterPosition = width / 2;//然后将分割位置设置在宽度一半位置 + } + + + splitContainerControl.Parent = tabDetail; + unionModel.GridDetailDetailControlObj = gridDetail_Details; + } + else + { + gridDetail.Parent = tabDetail; + gridDetail.BorderStyle = System.Windows.Forms.BorderStyle.None; + + } + + if (SerialNumber == 0) + { + this.tb_buttom.TabControlObj.TabPages.Insert(0, tabDetail); + this.tb_buttom.TabControlObj.SelectedTabPageIndex = 0; + if (attachModels.Count > 0) + this.tb_buttom.TabControlObj.TabPages[0].Text = model.UserName + DetailedSuffix; + } + if (BillModel.IsBillDetailCheck == 1)//加载复选框 + { + GridDragGrid.GridAddCheckBox(gridDetail.GridView); + } + } + } + + + + + + + + #endregion + + #region 加载来源条件 + if (model.SourceType == 1 && (controls == null || controls.Rows.Count == 0)) + { + //// 设置默认下拉列表框 + //DataTable columnTable = detailTable.Select("sourceId=" + model.Id + " and isnull(isVisible,0)=0").CopyToDataTable(); + //this.lceCombobox.ValueMember = this.lceCombobox.ValueField = "fieldName"; + //this.lceCombobox.TextField = "userName"; + //this.lceCombobox.SetDataSource(columnTable); + //this.lceCombobox.TextEdit.SelectedIndex = 0; + + //this.pl_treeview_detault_search.Dock = DockStyle.Bottom; + //this.pl_treeview_detault_search.Visible = true; + + //tabPage.Controls.Add(pl_treeview_detault_search); + } + else + { + // 创建自定义条件 + string searchSql = model.SourceType == 1 ? Regex.Replace(model.DetailSql, "{speciesno}", "", RegexOptions.IgnoreCase) : model.SourceSql; + PanelControl searchPanel = new PanelControl(); + if (!dataCaches.GetValue(sourceModelRow, "SearchControl", out MyControl searchControl)) + { + searchControl = new MyControl(searchSql, gridControl == null ? gridDetail : gridControl, treeView); + } + searchControl.OnSearchBeforeCallBack += new SearchEventHandler(OnSearchBefore); + searchControl.OnSearchAfterCallBack += new EventHandler(OnSearchAfterd); + if (SerialNumber == 0 && !SystemInfo.Instance.IsBillSourceRefushTag.Equals("1") && string.IsNullOrWhiteSpace(this.BillModel.InitialRefreshId)) + { + // 第一个页面要刷新数据,所以绑定事件用于初始化完成后在查询数据 + searchControl.OnDataSourceBindCallBack += new EventHandler(OnFirstPageDataSourceBindCallBack); + } + if (!string.IsNullOrWhiteSpace(this.BillModel.InitialRefreshId) && this.BillModel.InitialRefreshId.Equals(model.Id + "")) + { + searchControl.OnDataSourceBindCallBack += SearchControl_OnDataSourceBindCallBack; + InitialSelectionTab = tabPage; + } + + searchControl.ParentUnionField = model.SourceKeyField; + + searchPanel.Dock = DockStyle.Top; + searchPanel.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + searchPanel.BackColor = Color.Transparent; + searchPanel.Parent = tabPage; + searchControl.OtherParams = this.SysModel.OtherParams(); + searchPanel.Height = searchControl.InitSearchControl(controls, searchPanel); + unionModel.SearchObj = searchControl; + } + #endregion + + unionModel.GridControlObj = gridControl; + + if (model.sourceDetailType.Equals("1")) + { + unionModel.TreeGridDetailControlObj = (gridDetail as TreeGridControlEx); + } + else + { + unionModel.GridDetailControlObj = gridDetail; + } + + + + + unionModel.ModelObj = model; + unionModel.TreeViewObj = treeView; + if (SerialNumber == 0) + unionModel.IsChange = true; + tabPage.Tag = unionModel; + if (model.SourceType == 0 && !model.DisableShowSourceCount) + { + // 模块要查看具体条数 + unionModel.SearchObj.OnDataSourceBindCallBack += new EventHandler(OnPageDataSourceBindCallBack); + pageNumKey.Add(unionModel.SearchObj, tabPage); + } + this.xtc_main_container.TabPages.Add(tabPage); + SerialNumber++; + } + + + } + + + + + + + + + /// + /// 点击来源明细,加载明细的明细 + /// + /// + /// + private void GridView_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e) + { + try + { + + GridView gridView = sender as GridView; + DataRow rowItem = gridView.GetFocusedDataRow(); + string sql = gridView.Tag + ""; + BillSourceUnionModel unionModel = this.xtc_main_container.SelectedTabPage.Tag as BillSourceUnionModel; + if (unionModel.GridDetailDetailControlObj != null) + { + unionModel.GridDetailDetailControlObj.gridControl.DataSource = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, sql)); + } + } + catch (Exception ex) + { + MessageUtil.Show(ex); + } + + + } + + + + + + + + + + + + + + #region 单据来源相关 + /// + /// 说明:刷新当前选中的TabPage + /// 创建人:龚宇超 + /// 创建日期:2018-06-29 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// + private void RefreshSelectedSource() + { + if (this.xtc_main_container.SelectedTabPage == null) return;//来源选择为null(不显示左侧来源)。不执行下方刷新 + + XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage; + BillSourceUnionModel model = tabPage.Tag as BillSourceUnionModel; + if (model.GridControlObj != null) this.RefreshSource(model); + if (BillModel.drgFinishHide == "1") + { + if (model.ModelObj.SourceType == 1) + { + string sqlValue = ReplaceHelper.ReplaceUserInfo(ReplaceHelper.ReplaceWhereCond(model.ModelObj.DetailSql)); + sqlValue = sqlValue.Replace("#", ""); + sqlValue = this.ControlObj.ReplaceControlValue(sqlValue); + sqlValue = ReplaceHelper.ReplaceParamToValue(sqlValue, model.TreeViewObj.GetSelectValue()); + model.GridDetailControlObj.GridControl.DataSource = BillImpl.GetDataTableResult(sqlValue); + } + else + { + this.RefreshSourceDetail(model); + } + } + if (model.ModelObj.SourceType == 0 && model.SearchObj.GridRowCount > 0) tabPage.Text = model.ModelObj.UserName + "(" + model.SearchObj.GridRowCount + QuantitySuffix; + } + /// + /// 说明:刷新单据来源主表,未传递时,默认刷新 + /// 创建人:龚宇超 + /// 创建日期:2017-12-13 + /// 修改人: + /// 修改日期: + /// 修改备注:gcMain + /// 版本:1.0 + /// + /// The union model. + /// XtraTabPage. + private void RefreshSource(BillSourceUnionModel unionModel = null) + { + if (unionModel == null || unionModel.SearchObj == null) return; + unionModel.SearchObj.SearchLastGrid(); + + + } + + + + /// + /// 说明:刷新单据来源明细 + /// 创建人:龚宇超 + /// 创建日期:2017-11-30 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The union model. + private void RefreshSourceDetail(BillSourceUnionModel unionModel) + { + if (unionModel == null) return; + XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage; + + if (unionModel.ModelObj.SourceType == 1) + { + // 树加载明细 + //string fieldName = this.lceCombobox.EditValue; + //string fieldValue = this.textEdit1.Text.Trim(); + string fieldName = string.Empty; + string fieldValue = string.Empty; + string checkStrs = unionModel.TreeViewObj.GetCheckValues(); + string sqlValue = ReplaceHelper.ReplaceParamToValue(ReplaceHelper.ReplaceUserInfo(unionModel.ModelObj.DetailSql), unionModel.TreeViewObj.GetSelectNodeValue()); + + if (!string.IsNullOrEmpty(checkStrs)) + checkStrs = " and SpeciesNo in (" + checkStrs.TrimEnd(',') + ")"; + sqlValue = string.Format("select * from ({0}) temp where 1=1 ", ReplaceHelper.ReplaceWhereCond(sqlValue) + checkStrs) + string.Format(" and ({0} like '%{1}%' or dbo.P_getpy({0}) like '%{1}%')", fieldName, fieldValue); + + try + { + WaitForm.ShowForm(); + unionModel.GridDetailControlObj.GridControl.DataSource = BillImpl.GetDataTableResult(sqlValue); + } + catch (Exception ex) + { + MessageUtil.Show(ex); + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError(BillModel.TypeName + "模块刷新树加载明细出错!", ex); + } + finally + { + WaitForm.HideForm(); + } + } + else + { + // 加载明细 + try + { + WaitForm.ShowForm(); + + + DataRow rowItem = unionModel.GridControlObj.GridView.GetFocusedDataRow(); + //unionModel.GridDetailControlObj.GridControl.DataSource = rowItem == null + // ? new DataTable() : BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, unionModel.ModelObj.DetailSql)); + if (unionModel.ModelObj.SourceType == 3 || unionModel.ModelObj.SourceType == 4) + { + rowItem = unionModel.TreeGridControlObj.GetViewFocusedDataRow(); + } + + + string DetailSql = unionModel.ModelObj.DetailSql; + DetailSql = ReplaceHelper.ReplaceUserInfo(DetailSql); + DetailSql = ReplaceHelper.ReplaceWhereCond(DetailSql); + DetailSql = ReplaceHelper.ReplaceRowParam(rowItem, DetailSql); + if (unionModel.SearchObj != null) + DetailSql = unionModel.SearchObj.ReplaceParentControlValue(DetailSql); + + if (unionModel.ModelObj.sourceDetailType == "1") + { + unionModel.TreeGridDetailControlObj.SetGridViewDataSource(rowItem == null + ? new DataTable() : BillImpl.GetDataTableResult(DetailSql)); + } + else + { + + + //有复选框的页签在刷新前清空选中行,否则合计在刷新数据源后不会自带改变 + if (unionModel.GridDetailControlObj.GridView.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CheckBoxRowSelect && unionModel.GridDetailControlObj.GridView.OptionsSelection.MultiSelect == true) + { + //int[] selectIndexs = unionModel.GridDetailControlObj.GridView.GetSelectedRows(); + unionModel.GridDetailControlObj.GridView.ClearSelection(); + } + + unionModel.GridDetailControlObj.GridControl.DataSource = rowItem == null + ? new DataTable() : BillImpl.GetDataTableResult(DetailSql); + } + + if (unionModel.GridDetailModuleGridEx != null) + { + unionModel.GridDetailModuleGridEx.GridControlObj.LastSearchSql = DetailSql; + } + + + DataTable table = null; + if (unionModel.ModelObj.sourceDetailType == "1") + { + table = unionModel.TreeGridDetailControlObj.TreeListObj.DataSource as DataTable; + } + else + { + table = unionModel.GridDetailControlObj.GridControl.DataSource as DataTable; + } + + if (table != null && !table.Columns.Contains("_check")) + { + table.Columns.Add("_check", typeof(bool)); + foreach (DataRow row in table.Rows) + { + row["_check"] = 0; + } + } + + + + if (tb_buttom.TabControlObj.TabPages.Count > 0) + { + for (int i = 0; i < this.tb_buttom.TabControlObj.TabPages.Count; i++) + { + XtraTabPage page = this.tb_buttom.TabControlObj.TabPages[i]; + if (i == 0) continue; + if (rowItem != null && page != null) + { + this.SetTabPageDataSource(page, rowItem); + } + } + //foreach (XtraTabPage AttachPage in this.tb_buttom.TabControlObj.TabPages) + //{ + // GridDetailModel model = tb_buttom.GetGridDetailModel(AttachPage); + // if (model == null) continue; + // string sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, model.DetailSql); + // this.tb_buttom.SetGridDataSource(AttachPage, sqlValue); + //} + } + } + catch (Exception ex) + { + MessageUtil.Show(ex); + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError(BillModel.TypeName + "模块加载明细出错!", ex); + } + finally + { + WaitForm.HideForm(); + } + } + } + /// + /// 说明:刷新单据来源 + /// 创建人:龚宇超 + /// 创建日期:2019-12-16 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void SaveRefreshSource() + { + foreach (XtraTabPage tabPage in this.xtc_main_container.TabPages) + { + BillSourceUnionModel model = tabPage.Tag as BillSourceUnionModel; + if (model != null && model.GridControlObj != null && model.ModelObj.SaveRefreshFlag) + { + this.RefreshSource(model); + this.RefreshSourceDetail(model); + } + } + } + + + + + + /// + /// 说明: + /// 创建人:龚宇超 + /// 创建日期:2017-11-30 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// true if XXXX, false otherwise. + private bool ValidateDetailCond(DataRow rowItem, BillSourceUnionModel unionModel) + { + bool validate = false; + + try + { + string detailCond = ReplaceHelper.ReplaceRowParam(rowItem, unionModel.ModelObj.DetailEnableCond); + detailCond = detailCond.ToLower();//2025-09-08 赵坤表示条件全部转成小写判断。 来源明细中不能配置单元格类型(不能配置 复选框条件 {xxx}=0 ),只能写{xxx}='Ture'。这种bit类型容易忘记大小的情况 + if (detailCond.Contains("#")) + { + List condition = ReplaceHelper.GetParamFields(detailCond); + foreach (string item in condition) + { + string fieldValue = this.ControlObj.GetControlValue(item.Replace("{#", "").Replace("}", "")); + detailCond = detailCond.Replace(item, fieldValue); + } + } + if (detailCond.StartsWith("@") || detailCond.StartsWith("!")) + { + validate = "1".Equals(BaseImpl.GetDefaultValue(detailCond)); + } + else + { + + validate = ReplaceHelper.EvalCond(detailCond); + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteLog(ex.StackTrace); + LogUtil.WriteError("验证多条添加条件出错!", ex); + //MessageUtil.Show(ResourceKeys.CondtionError + "\r\n" + unionModel.ModelObj.DetailEnableCond); + } + return validate; + } + /// + /// 说明:单据来源右键菜单执行完后刷新 + /// 创建人:龚宇超 + /// 创建日期:2017-12-11 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnGridControlRightCallback(object sender, EventArgs e) + { + this.RefreshSelectedSource(); + + // 执行右键菜单后刷新单据状态2020-03-23 + XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage; + BillSourceUnionModel model = tabPage.Tag as BillSourceUnionModel; + } + /// + /// 说明:获取单据管理的单据来源标签 + /// 创建人:龚宇超 + /// 创建日期:2017-12-13 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private BillSourceUnionModel GetBillSourceManager() + { + foreach (XtraTabPage item in this.xtc_main_container.TabPages) + { + BillSourceUnionModel model = item.Tag as BillSourceUnionModel; + if (model.ModelObj.SourceType == 2) + return model; + } + return null; + } + /// + /// 说明:初始化附加信息 + /// 创建人:龚宇超 + /// 创建日期:2018-04-26 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private List GetAttachTabs() + { + List details = new List(); + + DataTable table = BaseAuditImpl.GetAttachTabs(this.SysModel.ModuleCode, "100", " and orderid < 0 "); + foreach (DataRow item in table.Rows) + { + DataTable gridColumns = BaseAuditImpl.GetBottomBasicInformation(item["formKey"] + ""); + details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BillSourceDetailAttachGridView)); + } + + return details; + } + #endregion + + + + #region 事件相关 + /// + /// 说明:打印完成后回调 + /// 创建人:龚宇超 + /// 创建日期:2018-07-05 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The e. + private void OnReportPrintAfter(object sender, EventArgs e) + { + //打印完成后添加数据库 + if (_printSaveParams != null && _printSaveParams.Count > 0) + { + int result = BaseModuleImpl.SavePrintRecord(_printSaveParams[0], _printSaveParams[1], _printSaveParams[2], _printSaveParams[3], _printSaveParams[4]); + } + + } + /// + /// 说明: + /// 创建人:龚宇超 + /// 创建日期:2017-11-28 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnFrmMainKeyDown(object sender, KeyEventArgs e) + { + // 窗口获取按键则表格按键中断.有时间处理 + if (e.Modifiers.CompareTo(Keys.Control) == 0) + { + if (e.KeyCode == Keys.Down) + this.ssc_main.Collapsed = true; + if (e.KeyCode == Keys.Up) + this.ssc_main.Collapsed = false; + } + } + /// + /// 说明:树节点选中刷新明细 + /// 创建人:龚宇超 + /// 创建日期:2017-12-01 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnTreeNodeSelectAfter(object sender, TreeViewEventArgs e) + { + TreeView tree = (TreeView)sender; + XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage; + BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel; + if (unionModel != null) + { + WaitForm.ShowForm(); + try + { + + + string sqlValue = ReplaceHelper.ReplaceUserInfo(ReplaceHelper.ReplaceWhereCond(unionModel.ModelObj.DetailSql)); + sqlValue = sqlValue.Replace("#", ""); + sqlValue = this.ControlObj.ReplaceControlValue(sqlValue); + if (unionModel.SearchObj != null) sqlValue = unionModel.SearchObj.ReplaceControlValue(sqlValue); + sqlValue = ReplaceHelper.ReplaceParamToValue(sqlValue, e.Node.Name); + + if (unionModel.GridDetailModuleGridEx != null) + { + unionModel.GridDetailModuleGridEx.GridControlObj.LastSearchSql = sqlValue; + } + + if (unionModel.ModelObj.sourceDetailType == "1" && unionModel.TreeGridDetailControlObj.TreeListObj != null) + { + unionModel.TreeGridDetailControlObj.TreeListObj.DataSource = BillImpl.GetDataTableResult(sqlValue); + } + else + { + unionModel.GridDetailControlObj.GridControl.DataSource = BillImpl.GetDataTableResult(sqlValue); + } + + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError(BillModel.TypeName + "模块选中树节点" + tree.SelectedNode.Text + "刷新明细失败!", ex); + } + finally + { + WaitForm.HideForm(); + } + } + } + /// + /// 说明:单据来源切换Tab标签 + /// 创建人:龚宇超 + /// 创建日期:2017-11-28 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnTabSelectedPageChanged(object sender, TabPageChangedEventArgs e) + { + try + { + if (_isInitFinish && !SystemInfo.Instance.IsBillSourceRefushTag.Equals("1")) + { + BillSourceUnionModel unionModel = e.Page.Tag as BillSourceUnionModel; + if (unionModel != null) + { + this.RefreshSelectedSource(); + this.tb_buttom.TabControlObj.TabPages[0].Controls.Clear(); + if (unionModel.GridDetailModuleGridEx != null) + { + this.tb_buttom.TabControlObj.TabPages[0].Controls.Add(unionModel.GridDetailModuleGridEx); + } + else if (unionModel.GridDetailDetailControlObj == null) + { + this.tb_buttom.TabControlObj.TabPages[0].Controls.Add(unionModel.GridDetailControlObj != null ? unionModel.GridDetailControlObj : unionModel.TreeGridDetailControlObj); + } + else + { + //this.tb_buttom.TabControlObj.TabPages[0].Controls.Add(unionModel.GridDetailDetailControlObj); + //创建SplitContainerControl控件,让下方可以左右拖动 + SplitContainerControl splitContainerControl = new DevExpress.XtraEditors.SplitContainerControl(); + splitContainerControl.Dock = DockStyle.Fill; + splitContainerControl.Panel1.Controls.Add(unionModel.GridDetailControlObj); + splitContainerControl.Panel2.Controls.Add(unionModel.GridDetailDetailControlObj); + int width = this.tb_buttom.Width;//获取控件宽度 + splitContainerControl.SplitterPosition = width / 2;//然后将分割位置设置在宽度一半位置 + this.tb_buttom.TabControlObj.TabPages[0].Controls.Add(splitContainerControl); + } + this.tb_buttom.TabControlObj.TabPages[0].Text = unionModel.ModelObj.UserName + DetailedSuffix; + if (unionModel.IsChange == false) + { + AutoSizeChange.ControllInitializeSize(this.tb_buttom.TabControlObj.TabPages[0]); + unionModel.IsChange = true; + } + } + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("单据切换标签失败!", ex); + } + } + /// + /// 说明:单据来源树结构默认查询条件 + /// 创建人:龚宇超 + /// 创建日期:2017-11-28 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnTreeSearchClick(object sender, EventArgs e) + { + XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage; + + this.RefreshSourceDetail(tabPage.Tag as BillSourceUnionModel); + } + + /// + /// 单据来源树 条件框回车查询 + /// + /// + /// + private void OnTreeConditionKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + this.OnTreeSearchClick(null, null); + } + + } + + + /// + /// 说明:第一个页签初始化完成刷新数据 + /// 创建人:龚宇超 + /// 创建日期: + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + private void OnFirstPageDataSourceBindCallBack(object sender, EventArgs e) + { + try + { + if (IsBillMaster) + { + this.RefreshSelectedSource(); + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("单据切换标查询失败!", ex); + } + } + /// + /// 说明:第一个页签初始化完成刷新数据 + /// 创建人:龚宇超 + /// 创建日期: + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + private void OnPageDataSourceBindCallBack(object sender, EventArgs e) + { + try + { + MyControl searchControl = sender as MyControl; + XtraTabPage tabPage = pageNumKey[searchControl]; + if (tabPage.TabIndex == 0) return; + BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel; + string searchSql = unionModel.ModelObj.SourceSql; + searchSql = ReplaceHelper.ReplaceUserInfo(searchSql); + searchSql = ReplaceHelper.ReplaceWhereCond(searchSql); + searchSql = unionModel.SearchObj.SetSearchSqlValue(searchSql, true, true); + // 查找FROM子句的位置 + int fromIndex = searchSql.IndexOf("FROM", StringComparison.OrdinalIgnoreCase); + if (fromIndex != -1) + { + // 生成优化后的SQL查询 + string optimizedSql = "SELECT COUNT(*) " + searchSql.Substring(fromIndex); + searchSql = optimizedSql; + } + DataTable dt = MainImpl.GetDataTableResult(searchSql); + if (dt.Rows.Count > 0) tabPage.Text += "(" + dt.Rows[0][0] + QuantitySuffix; + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("单据条件绑定失败失败!", ex); + } + } + + /// + /// 跳转到指定页签,并执行配置条件的搜索 + /// + /// + /// + private void SearchControl_OnDataSourceBindCallBack(object sender, EventArgs e) + { + if (InitialSelectionTab != null) + { + this.xtc_main_container.SelectedTabPage = InitialSelectionTab; + BillSourceUnionModel model = InitialSelectionTab.Tag as BillSourceUnionModel; + if (model.SearchObj != null) model.SearchObj.SearchGrid(); + } + } + + /// + /// 说明:单据来源选中行,加载明细 + /// 创建人:龚宇超 + /// 创建日期:2017-11-30 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnGridControlSelectionChanged(object sender, SelectionChangedEventArgs e) + { + XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage; + + this.RefreshSourceDetail(tabPage.Tag as BillSourceUnionModel); + } + /// + /// 说明:单据来源选中行,加载明细 + /// 创建人:龚宇超 + /// 创建日期:2017-11-30 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnGridViewRowCellClick(object sender, RowCellClickEventArgs e) + { + + XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage; + BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel; + this.RefreshSourceDetail(unionModel); + } + + + + + private void OnSourceGridViewDoubleClick(object sender, EventArgs e) + { + + XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage; + BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel; + //this.RefreshSourceDetail(unionModel); + DataRow rowItem = unionModel.GridControlObj.GridView.GetFocusedDataRow(); + if (rowItem == null) + return; + //单据号 + string billno = rowItem[BillModel.PrimaryKey] + ""; + + DynamicBillModel model = CloneDynamicBillModel(this.SysModel); + model.BillOrderNo = billno; + FrmBill frmBill = new FrmBill(model); + frmBill.Text = string.Format("{0}-详情[单据编号:{1}]", this.BillModel.TypeName, billno); + frmBill.ShowDialog(); + //刷新界面 + unionModel.SearchObj.SearchLastGrid(); + + } + + + // + /// 复制单据动态参数,保留原对象的运行时配置和缓存。 + /// + private static DynamicBillModel CloneDynamicBillModel(DynamicBillModel source) + { + if (source == null) + return null; + + MethodInfo method = typeof(object).GetMethod( + "MemberwiseClone", + BindingFlags.Instance | BindingFlags.NonPublic); + + return method.Invoke(source, null) as DynamicBillModel; + } + + + + /// + /// 说明:单据明细选中刷新附件明细 + /// 创建人:王一帆 + /// 创建日期:2021-06-30 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OngcMainRowCellClick(object sender, RowCellClickEventArgs e) + { + if (this.tb_buttom.TabControlObj.TabPages.Count > 1) + { + SetDetailGridDataSource(); + } + } + + + + /// + /// 切换下方附加模块页签时,刷新当前页签 + /// + /// + /// + private void TabControlObj_SelectedPageChanged(object sender, TabPageChangedEventArgs e) + { + if (this.tb_buttom.TabControlObj.TabPages.Count > 1) + { + SetDetailGridDataSource(); + } + } + + /// + /// 说明:获取底部多标签数据 + /// 创建人:龚宇超 + /// 创建日期:2017-12-19 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + public void SetDetailGridDataSource() + { + DataRow rowItem = null; + //DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow(); + //if (this.BillModel.DetailTreeTable) + //{ + // rowItem = (this.gcMain as TreeGridControlEx).GetViewFocusedDataRow(); + //} + int i = 0; + foreach (XtraTabPage page in this.tb_buttom.TabControlObj.TabPages) + { + if (i == 0) + { + i++; + continue; + } + if (this.BillModel.RefreshSelectedDetail && page != tb_buttom.TabControlObj.SelectedTabPage) + { + continue; + } + if (rowItem != null && page != null) + { + this.SetTabPageDataSource(page, rowItem); + } + } + } + + + + + /// + /// 说明:设置表格数据 + /// 创建人:龚宇超 + /// 创建日期:2018-01-29 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The tab page. + /// The grid control. + public void SetTabPageDataSource(XtraTabPage tabPage, DataRow rowItem) + { + + GridDetailModel model = this.tb_buttom.GetGridDetailModel(tabPage); + if (rowItem != null && model != null) + { + if (tabPage.Tag is ModuleWebView) + { + // 加载网页 + string url = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(model.DetailSql)); + url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url; + ModuleWebView webView = tabPage.Tag as ModuleWebView; + webView.Dock = DockStyle.Fill; + webView.Tag = model; + webView.Navigate(url); + } + else if (tabPage.Tag is FrmWebBrowser) + { + // 加载网页 + string url = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(model.DetailSql)); + url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url; + FrmWebBrowser webView = tabPage.Tag as FrmWebBrowser; + webView.Dock = DockStyle.Fill; + webView.Tag = model; + webView.LoadUrl(url); + } + else if (tabPage.Tag is FrmMiniBlink) + { + // 加载网页 + string url = ReplaceHelper.ReplaceRowParam(rowItem, ReplaceHelper.ReplaceUserInfo(model.DetailSql)); + url = url.StartsWith("http") ? url : SystemInfo.Instance.OAUrl + url; + FrmMiniBlink webView = tabPage.Tag as FrmMiniBlink; + webView.Dock = DockStyle.Fill; + webView.Tag = model; + webView.LoadUrl(url); + } + else if (tabPage.Tag is TabMultipledetails) + { + TabMultipledetails tabMultipledetails = tabPage.Tag as TabMultipledetails; + tabMultipledetails.SetConditionValues(rowItem); + + GridControlEx grdExMain = (tabMultipledetails.SplitMain.Panel1.Tag as GridControlEx); + GridDetailModel MainModel = grdExMain.Tag as GridDetailModel; + string searchMainSql = this.GetSearchSql(MainModel, rowItem); + DataTable firstTable = MainImpl.GetDataTableResult(searchMainSql); + grdExMain.LastSearchSql = searchMainSql; + grdExMain.SetGridViewDataSource(firstTable); + + if (tabMultipledetails.SplitMain.Panel2.Tag is GridControlEx) + { + GridControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as GridControlEx); + GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel; + string searchAddSql = this.GetSearchSql(AdditionalModel, rowItem); + if (!MainModel.IsUnioDetail) + { + grdExAdditional.LastSearchSql = searchAddSql; + grdExAdditional.SetGridViewDataSource(MainImpl.GetDataTableResult(searchAddSql)); + } + //右侧是左侧的明细,左侧没有数据时。右侧赋空值(因为无法触发左侧行改变事件) + if (MainModel.IsUnioDetail && firstTable.Rows.Count == 0) + { + grdExAdditional.LastSearchSql = ""; + grdExAdditional.SetGridViewDataSource(new DataTable()); + } + } + else if (tabMultipledetails.SplitMain.Panel2.Tag is ChartControlEx) + { + ChartControlEx grdExAdditional = (tabMultipledetails.SplitMain.Panel2.Tag as ChartControlEx); + GridDetailModel AdditionalModel = grdExAdditional.Tag as GridDetailModel; + string searchAddSql = this.GetSearchSql(AdditionalModel, rowItem); + DataTable table = MainImpl.GetDataTableResult(searchAddSql); + grdExAdditional.CreateChart(table); + } + + tabPage.Text = MainModel.DetailName + "(" + firstTable.Rows.Count + QuantitySuffix; + //tabPage.Text = MainModel.DetailName + "(" + firstTable.Rows.Count + "条)"; + //tabPage.Appearance.Header.ForeColor = firstTable.Rows.Count > 0 ? Color.Red : Color.FromArgb(0, 0, 0); + } + else + { + string searchSql = this.GetSearchSql(model, rowItem); + if (tabPage.Tag is GridControlEx) + { + (tabPage.Tag as GridControlEx).LastSearchSql = searchSql; + } + this.tb_buttom.SetGridDataSource(tabPage, MainImpl.GetDataTableResult(searchSql)); + if (tabPage.Tag is GridControlEx && (tabPage.Tag as GridControlEx).ParentControl != null) + (tabPage.Tag as GridControlEx).ParentControl.SetAllControlValue(rowItem); + //配置明细直接根据条件加载 + if (model.SystemModel != null && 1 == model.SystemModel.isFirstLoad) + { + (tabPage.Tag as GridControlEx).ParentControl.SearchGrid(); + GridControlEx gridControlEx = tabPage.Tag as GridControlEx; + + if (gridControlEx.CustomGroupBandEx != null) + { + tabPage.Text = model.DetailName + "(" + gridControlEx.CustomGroupBandEx.DataRowCount() + QuantitySuffix; + } + else if (gridControlEx.CustomGroupTreeBandEx != null) + { + tabPage.Text = model.DetailName + "(" + gridControlEx.CustomGroupTreeBandEx.DataRowCount() + QuantitySuffix; + } + else + { + tabPage.Text = model.DetailName + "(" + (tabPage.Tag as GridControlEx).ParentControl.GridRowCount + QuantitySuffix; + } + //tabPage.Text = gridControlEx.CustomGroupBandEx != null ? model.DetailName + "(" + gridControlEx.CustomGroupBandEx.DataRowCount() + "条)" : model.DetailName + "(" + (tabPage.Tag as GridControlEx).ParentControl.GridRowCount + "条)"; + //tabPage.Text = model.DetailName + "(" + (tabPage.Tag as GridControlEx).ParentControl.GridRowCount + "条)"; + } + //附加信息根据主表明细选中行,判断配置的按钮条件 + Object moduleObject = tabPage.Controls.Cast().FirstOrDefault(); + ModuleGridEx moduleGridEx = null; + if (moduleObject is ModuleGridEx) + { + moduleGridEx = moduleObject as ModuleGridEx; + moduleGridEx.ParentButtonState(rowItem); + } + + } + } + + } + /// + /// 说明:获取查询条件 + /// 创建人:龚宇超 + /// 创建日期:2017-11-22 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The model. + /// The row item. + /// System.String. + protected string GetSearchSql(GridDetailModel model, DataRow rowItem) + { + string fieldName = !string.IsNullOrEmpty(model.UnionParentField) && rowItem.Table.Columns.Contains(model.UnionParentField) ? model.UnionParentField : BillModel.PrimaryKey; + string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql; + string unioValue = string.Empty; + unioValue = rowItem.Table.Columns.Contains(fieldName) ? rowItem[fieldName] + "" : string.Empty; + if (this.ControlObj != null && string.IsNullOrEmpty(unioValue)) + { + unioValue = !string.IsNullOrEmpty(model.UnionParentField) && this.ControlObj.FindControl(model.UnionParentField) != null ? this.ControlObj.GetControlValue(model.UnionParentField) : unioValue; + } + sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue); + sqlValue = this.ControlObj.ReplaceControlValue(sqlValue);//后替换主表内容 + if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue)) + { + sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, unioValue); + } + if (!string.IsNullOrEmpty(model.UnionCond)) + { + string UnionCond = ReplaceHelper.ReplaceRowParam(rowItem, model.UnionCond); + sqlValue += UnionCond; + } + return sqlValue; + } + /// + /// 说明:单据来源选中行,加载明细 + /// 创建人:龚宇超 + /// 创建日期:2019-07-25 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + private void OnTreeListObjFocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) + { + XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage; + + this.RefreshSourceDetail(tabPage.Tag as BillSourceUnionModel); + } + /// + /// 说明:单据来源明细右键菜单执行后刷新数据 + /// 创建人:龚宇超 + /// 创建日期:2017-12-19 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnGridDetailRightMenuCallback(object sender, EventArgs e) + { + XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage; + + this.RefreshSourceDetail(tabPage.Tag as BillSourceUnionModel); + } + + + + + + /// + /// 说明:分割条移动保存位置 + /// 创建人:龚宇超 + /// 创建日期:2018-03-06 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnMainSplitterMoved(object sender, EventArgs e) + { + if (this._isInitFinish) + { + IniHelper.Write(string.Format("bill_height_{0}", this.SysModel.ModuleCode), this.ssc_main.SplitterPosition + ""); + } + } + /// + /// 说明:明细分割条移动保存位置 + /// 创建人:龚宇超 + /// 创建日期:2018-03-06 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnDetailsSplitterMoved(object sender, EventArgs e) + { + if (this._isInitFinish) + { + SplitContainerControl splitContainerControl = sender as SplitContainerControl; + IniHelper.Write(string.Format("bill_Details_Width_{0}", this.SysModel.ModuleCode), splitContainerControl.SplitterPosition + ""); + } + } + /// + /// 说明:单据来源查询之前处理 + /// 创建人:龚宇超 + /// 创建日期:2018-03-06 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The e. + private void OnSearchBefore(object sender, SearchArgs e) + { + + // 用户搜索时不加载右侧控件值,只有点击、人为选中行在加载右侧控件值. + this._isLoadRightControlValue = false; + XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage; + BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel; + if (!unionModel.SearchObj.VerifyNull()) + { + e.Continue = false; + } + } + /// + /// 说明:单据来源查询完成 + /// 创建人:龚宇超 + /// 创建日期:2018-03-06 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + /// + private void OnSearchAfterd(object sender, EventArgs e) + { + this._isLoadRightControlValue = true; + + XtraTabPage tabPage = this.xtc_main_container.SelectedTabPage; + BillSourceUnionModel unionModel = tabPage.Tag as BillSourceUnionModel; + if (unionModel.ModelObj.SourceType == 1) + { + if (unionModel.TreeViewObj != null && unionModel.SearchObj.MainGridEx != null) + { + string sql = ReplaceHelper.ReplaceUserInfo(unionModel.SearchObj.MainGridEx.LastSearchSql); + + //和上一次查询sql相同就不再次查询了 + if (!unionModel.SearchObj.MainGridEx.LastSearchSql.Equals(sql)) + { + unionModel.SearchObj.MainGridEx.SetGridViewDataSource(BaseImpl.GetDataTableResult(sql)); + } + } + } + else + { + if (unionModel.GridControlObj != null) + { + + string sql = ReplaceHelper.ReplaceUserInfo(unionModel.GridControlObj.LastSearchSql); + + if (SubstringCount(sql, "#") > 1) + { + string fixedSql = sql.Substring(sql.IndexOf('#'), sql.LastIndexOf('#') + 1 - sql.IndexOf('#')); + string billMainCode = sql.Substring(sql.IndexOf('#'), sql.LastIndexOf('#') + 1 - sql.IndexOf('#')).Replace("#", ""); + var paramList = ReplaceHelper.GetParamFields(billMainCode); + bool isCondReplace = true; + foreach (string item in paramList) + { + string field = item.Replace("{", "").Replace("}", ""); + if (ControlObj.FindControl(field) != null) + { + string value = ControlObj.GetControlValue(field); + if (string.IsNullOrEmpty(value)) isCondReplace = false; + billMainCode = billMainCode.Replace(item, value); + } + } + if (!isCondReplace) + { + sql = sql.Replace(fixedSql, "1=1"); + } + else + { + sql = sql.Replace(fixedSql, billMainCode); + + } + } + int oldRowHandle = 0; + if (unionModel.GridControlObj.GridView != null) + { + oldRowHandle = unionModel.GridControlObj.GridView.FocusedRowHandle; + } + + //和上一次查询sql相同就不再次查询了 + if (!unionModel.GridControlObj.LastSearchSql.Equals(sql)) + { + unionModel.GridControlObj.gridControl.DataSource = BaseImpl.GetDataTableResult(sql); + unionModel.GridControlObj.GridView.SelectRowHandler(oldRowHandle); + } + + //如果没有数据,显示 (0条) + //(unionModel.ModelObj.SourceType == 0 || this.IsBillShowCount) && unionModel.SearchObj.GridRowCount > 0 + if (unionModel.ModelObj.SourceType == 0 || this.IsBillShowCount) tabPage.Text = unionModel.ModelObj.UserName + "(" + unionModel.SearchObj.GridRowCount + QuantitySuffix; + + RefreshSourceDetail(unionModel); + } + + } + + } + /// + /// 说明:判断字符串出现次数 + /// 创建人:龚宇超 + /// 创建日期: + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The string. + /// The substring. + /// System.Int32. + private static int SubstringCount(string str, string substring) + { + if (str.Contains(substring)) + { + string strReplaced = str.Replace(substring, ""); + return (str.Length - strReplaced.Length) / substring.Length; + } + + return 0; + } + + + #endregion + + + + #region + + private void tb_buttom_Load(object sender, EventArgs e) + { + + } + #endregion + + + + + + + + /// + /// 说明:检查可用条件 + /// 创建人:龚宇超 + /// 创建日期:2017-11-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The cond. + /// The data row. + /// true if XXXX, false otherwise. + private bool ValidateCond(string cond, DataRow dataRow) + { + bool result = false; + string condition = cond; + try + { + if (string.IsNullOrWhiteSpace(cond)) return true;//如果值是空格或者空行,默认正确 + cond = ReplaceHelper.ReplaceRowParam(dataRow, cond); + if (cond.StartsWith("@") || cond.StartsWith("!")) + { + result = "1".Equals(BaseImpl.GetDefaultValue(cond)); + } + else if (dataRow == null) + { + result = ReplaceHelper.EvalCond(cond); + } + else + { + result = ReplaceHelper.ReplaceRowParamCond(dataRow, cond); + } + return result; + } + catch (Exception ex) + { + + } + return result; + } + + + /// + /// 设置打印按钮条件 + /// + /// + public bool SetPrintButton(DataRow rowItem) + { + try + { + bool result = false; + //判断打印按钮条件 + if (!string.IsNullOrWhiteSpace(this.BillModel.PrintingConditions)) + { + if (rowItem == null) return result; + + string cond = ReplaceHelper.ReplaceRowParam(rowItem, this.BillModel.PrintingConditions); + if (cond.StartsWith("@") || cond.StartsWith("!")) + { + result = "1".Equals(BaseImpl.GetDefaultValue(cond)); + } + else + { + result = ReplaceHelper.ReplaceRowParamCond(rowItem, cond); + } + return result; + } + else + { + return true; + } + } + catch (Exception ex) + { + return false; + } + } + + + + + + + } +} \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/BillModule.resx b/插件库/Lskj.PubBillManagement/BillModule.resx new file mode 100644 index 0000000..d11908a --- /dev/null +++ b/插件库/Lskj.PubBillManagement/BillModule.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 642, 21 + + + 59 + + + 1078, 23 + + + 873, 21 + + + 983, 21 + + + 773, 21 + + + 548, 21 + + \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/DllBaseClass.cs b/插件库/Lskj.PubBillManagement/DllBaseClass.cs new file mode 100644 index 0000000..98fd4f2 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/DllBaseClass.cs @@ -0,0 +1,64 @@ +/****************************** +* 说明:单据模版入口 +* 创建人:龚宇超 +* 创建日期:2017-11-23 +* 修改人: +* 修改日期: +* 修改备注: +* 版本:1.0.0.0 +******************************/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Lskj.Util; +using System.Windows.Forms; +using Lskj.Model; +using Lskj.Business; +using Lskj.Business.Impl; +using System.Collections; + +namespace Lskj.PubBillManagement +{ + /// + /// 单据模版入口 + /// + public class DllBaseClass : IForm + { + public DllBaseClass() + { + + } + + public DllBaseClass(string[] obj) + { + try + { + FrmMain main = new FrmMain(); + DynamicBillModel moduleModel = new DynamicBillModel(obj); + main.SysModel = moduleModel; + moduleModel.DataCaches = new Dictionary(); + if (SystemInfo.Instance.OptimizationSpeed) main.GetDataCaches(moduleModel.DataCaches); + GridEnum gridEnum = GridEnum.GridView; + if (!moduleModel.DataCaches.GetValue(main, "FormType", out int formType)) + { + formType = BaseImpl.GetBillDetailType(moduleModel.ModuleCode); + } + if (formType == 1) + { + gridEnum = GridEnum.BandedGridView; + } + main.SysModel.GridEnumObj = gridEnum; + this.SubForm = main; + + } + catch (Exception ex) + { + LogUtil.WriteError("Lskj.PubBillManagement.dll--参数错误-->" + obj.ToString(), ex); + } + + } + + public Form SubForm { get; set; } + } +} diff --git a/插件库/Lskj.PubBillManagement/FrmAdd.Designer.cs b/插件库/Lskj.PubBillManagement/FrmAdd.Designer.cs new file mode 100644 index 0000000..69a4591 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmAdd.Designer.cs @@ -0,0 +1,81 @@ + +namespace Lskj.PubBillManagement +{ + partial class FrmAdd + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.txtEdit = new DevExpress.XtraEditors.TextEdit(); + this.label1 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.txtEdit.Properties)).BeginInit(); + this.SuspendLayout(); + // + // txtEdit + // + this.txtEdit.EditValue = "1"; + this.txtEdit.Location = new System.Drawing.Point(12, 39); + this.txtEdit.Name = "txtEdit"; + this.txtEdit.Properties.Appearance.Font = new System.Drawing.Font("微软雅黑", 12F); + this.txtEdit.Properties.Appearance.Options.UseFont = true; + this.txtEdit.Size = new System.Drawing.Size(198, 28); + this.txtEdit.TabIndex = 25; + this.txtEdit.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtEdit_KeyDown); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(10, 14); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(77, 12); + this.label1.TabIndex = 22; + this.label1.Text = "请输入数量:"; + // + // FrmAddRole + // + this.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.Appearance.Options.UseBackColor = true; + this.Appearance.Options.UseFont = true; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(219, 96); + this.Controls.Add(this.txtEdit); + this.Controls.Add(this.label1); + this.Margin = new System.Windows.Forms.Padding(2); + this.Name = "FrmAddRole"; + this.Text = ""; + ((System.ComponentModel.ISupportInitialize)(this.txtEdit.Properties)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private DevExpress.XtraEditors.TextEdit txtEdit; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/FrmAdd.cs b/插件库/Lskj.PubBillManagement/FrmAdd.cs new file mode 100644 index 0000000..e1f6d26 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmAdd.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Lskj.Control; +using Lskj.Business; +using Lskj.Business.Impl; + +namespace Lskj.PubBillManagement +{ + public partial class FrmAdd : BaseForm + { + public int Quantity; + public Label LabelObj { get { return label1; } } + + public FrmAdd() + { + InitializeComponent(); + } + + /// + /// 说明:确定事件 + /// 创建人:龚宇超 + /// 创建日期:2019-06-21 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + void OnBtnOKClick(object sender, EventArgs e) + { + try + { + string text=this.txtEdit.Text; + if (string.IsNullOrWhiteSpace(text)) text = "0"; + if (!this.IsDigitsOnly(text)) + { + MessageUtil.Show("请输入数字"); + } + + this.Quantity = int.Parse(text); + this.Close(); + this.DialogResult = System.Windows.Forms.DialogResult.OK; + } + catch (Exception ex) + { + LogUtil.WriteError("确定事件出错!", ex); + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + + + } + /// + /// 说明:取消事件 + /// 创建人:龚宇超 + /// 创建日期:2019-06-21 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + void OnBtnCancelClick(object sender, EventArgs e) + { + this.Close(); + } + + + bool IsDigitsOnly(string input) + { + foreach (char c in input) + { + if (!char.IsDigit(c)) + return false; + } + return true; + } + + private void txtEdit_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + string text = this.txtEdit.Text; + + if (string.IsNullOrWhiteSpace(text)) return; + + if (!this.IsDigitsOnly(text)) + { + MessageUtil.Show("请输入数字"); + } + if (int.Parse(text) > 0) + { + this.Quantity = int.Parse(text); + this.Close(); + this.DialogResult = System.Windows.Forms.DialogResult.OK; + } + else + { + MessageUtil.Show("请检查输入数量"); + } + } + } + } +} diff --git a/插件库/Lskj.PubBillManagement/FrmAdd.resx b/插件库/Lskj.PubBillManagement/FrmAdd.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmAdd.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/FrmBill.Designer.cs b/插件库/Lskj.PubBillManagement/FrmBill.Designer.cs new file mode 100644 index 0000000..05622db --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmBill.Designer.cs @@ -0,0 +1,639 @@ + +namespace Lskj.PubBillManagement +{ + partial class FrmBill + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.pl_main = new DevExpress.XtraEditors.PanelControl(); + this.pl_main_center = new DevExpress.XtraEditors.PanelControl(); + this.pl_main_center_detail = new DevExpress.XtraEditors.PanelControl(); + this.gcMain = new Lskj.Control.GridControlEx(); + this.pl_main_center_master = new DevExpress.XtraEditors.XtraScrollableControl(); + this.pl_main_bottom = new DevExpress.XtraEditors.PanelControl(); + this.dbpFP = new DevExpress.XtraEditors.DropDownButton(); + this.btnRefresh = new DevExpress.XtraEditors.SimpleButton(); + this.btnHiding = new DevExpress.XtraEditors.SimpleButton(); + this.btnHelp = new DevExpress.XtraEditors.SimpleButton(); + this.pl_templete = new DevExpress.XtraEditors.PanelControl(); + this.cb_templete = new DevExpress.XtraEditors.ComboBoxEdit(); + this.lbl_templete = new DevExpress.XtraEditors.LabelControl(); + this.pl_input = new DevExpress.XtraEditors.PanelControl(); + this.cb_input = new DevExpress.XtraEditors.ComboBoxEdit(); + this.txt_input = new DevExpress.XtraEditors.TextEdit(); + this.labelControl2 = new DevExpress.XtraEditors.LabelControl(); + this.btn_input = new DevExpress.XtraEditors.SimpleButton(); + this.dpbImport = new DevExpress.XtraEditors.DropDownButton(); + this.btnBillAdd = new DevExpress.XtraEditors.SimpleButton(); + this.btnBillApply = new DevExpress.XtraEditors.SimpleButton(); + this.dpCopyBill = new DevExpress.XtraEditors.DropDownButton(); + this.btnPrint = new DevExpress.XtraEditors.DropDownButton(); + this.dpbTools = new DevExpress.XtraEditors.DropDownButton(); + this.btnDelete = new DevExpress.XtraEditors.SimpleButton(); + this.btnBillSave = new DevExpress.XtraEditors.SimpleButton(); + this.pl_main_top = new DevExpress.XtraEditors.PanelControl(); + this.pl_main_top_center = new DevExpress.XtraEditors.PanelControl(); + this.lbTitle = new System.Windows.Forms.Label(); + this.pl_main_top_right = new DevExpress.XtraEditors.PanelControl(); + this.lblOrderNo = new DevExpress.XtraEditors.LabelControl(); + this.labelControl1 = new DevExpress.XtraEditors.LabelControl(); + this.pl_main_top_left = new DevExpress.XtraEditors.PanelControl(); + this.pl_red = new DevExpress.XtraEditors.PanelControl(); + this.rdRed = new System.Windows.Forms.RadioButton(); + this.pl_blue = new DevExpress.XtraEditors.PanelControl(); + this.rdBlue = new System.Windows.Forms.RadioButton(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main)).BeginInit(); + this.pl_main.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_center)).BeginInit(); + this.pl_main_center.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_center_detail)).BeginInit(); + this.pl_main_center_detail.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_bottom)).BeginInit(); + this.pl_main_bottom.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_templete)).BeginInit(); + this.pl_templete.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.cb_templete.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_input)).BeginInit(); + this.pl_input.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.cb_input.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.txt_input.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top)).BeginInit(); + this.pl_main_top.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top_center)).BeginInit(); + this.pl_main_top_center.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top_right)).BeginInit(); + this.pl_main_top_right.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top_left)).BeginInit(); + this.pl_main_top_left.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_red)).BeginInit(); + this.pl_red.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_blue)).BeginInit(); + this.pl_blue.SuspendLayout(); + this.SuspendLayout(); + // + // pl_main + // + this.pl_main.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main.Appearance.Options.UseBackColor = true; + this.pl_main.Controls.Add(this.pl_main_center); + this.pl_main.Controls.Add(this.pl_main_bottom); + this.pl_main.Controls.Add(this.pl_main_top); + this.pl_main.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_main.Location = new System.Drawing.Point(0, 0); + this.pl_main.Name = "pl_main"; + this.pl_main.Size = new System.Drawing.Size(1260, 613); + this.pl_main.TabIndex = 2; + // + // pl_main_center + // + this.pl_main_center.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main_center.Appearance.Options.UseBackColor = true; + this.pl_main_center.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_center.Controls.Add(this.pl_main_center_detail); + this.pl_main_center.Controls.Add(this.pl_main_center_master); + this.pl_main_center.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_main_center.Location = new System.Drawing.Point(2, 40); + this.pl_main_center.Name = "pl_main_center"; + this.pl_main_center.Size = new System.Drawing.Size(1256, 534); + this.pl_main_center.TabIndex = 2; + // + // pl_main_center_detail + // + this.pl_main_center_detail.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main_center_detail.Appearance.Options.UseBackColor = true; + this.pl_main_center_detail.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_center_detail.Controls.Add(this.gcMain); + this.pl_main_center_detail.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_main_center_detail.Location = new System.Drawing.Point(0, 164); + this.pl_main_center_detail.Name = "pl_main_center_detail"; + this.pl_main_center_detail.Size = new System.Drawing.Size(1256, 370); + this.pl_main_center_detail.TabIndex = 5; + // + // gcMain + // + this.gcMain.AdapterObj = null; + this.gcMain.BackColor = System.Drawing.Color.Transparent; + this.gcMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.gcMain.Location = new System.Drawing.Point(0, 0); + this.gcMain.Margin = new System.Windows.Forms.Padding(5); + this.gcMain.Name = "gcMain"; + this.gcMain.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gcMain.Size = new System.Drawing.Size(1256, 370); + this.gcMain.SysModel = null; + this.gcMain.TabIndex = 0; + // + // pl_main_center_master + // + this.pl_main_center_master.AutoScroll = false; + this.pl_main_center_master.Dock = System.Windows.Forms.DockStyle.Top; + this.pl_main_center_master.Location = new System.Drawing.Point(0, 0); + this.pl_main_center_master.Name = "pl_main_center_master"; + this.pl_main_center_master.Size = new System.Drawing.Size(1256, 164); + this.pl_main_center_master.TabIndex = 6; + // + // pl_main_bottom + // + this.pl_main_bottom.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main_bottom.Appearance.Options.UseBackColor = true; + this.pl_main_bottom.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_bottom.Controls.Add(this.dbpFP); + this.pl_main_bottom.Controls.Add(this.btnRefresh); + this.pl_main_bottom.Controls.Add(this.btnHiding); + this.pl_main_bottom.Controls.Add(this.btnHelp); + this.pl_main_bottom.Controls.Add(this.pl_templete); + this.pl_main_bottom.Controls.Add(this.pl_input); + this.pl_main_bottom.Controls.Add(this.dpbImport); + this.pl_main_bottom.Controls.Add(this.btnBillAdd); + this.pl_main_bottom.Controls.Add(this.btnBillApply); + this.pl_main_bottom.Controls.Add(this.dpCopyBill); + this.pl_main_bottom.Controls.Add(this.btnPrint); + this.pl_main_bottom.Controls.Add(this.dpbTools); + this.pl_main_bottom.Controls.Add(this.btnDelete); + this.pl_main_bottom.Controls.Add(this.btnBillSave); + this.pl_main_bottom.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pl_main_bottom.Location = new System.Drawing.Point(2, 574); + this.pl_main_bottom.Name = "pl_main_bottom"; + this.pl_main_bottom.Size = new System.Drawing.Size(1256, 37); + this.pl_main_bottom.TabIndex = 1; + // + // dbpFP + // + this.dbpFP.AllowFocus = false; + this.dbpFP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.dbpFP.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.dbpFP.Appearance.Options.UseFont = true; + this.dbpFP.Location = new System.Drawing.Point(395, 7); + this.dbpFP.Name = "dbpFP"; + this.dbpFP.Size = new System.Drawing.Size(58, 26); + this.dbpFP.TabIndex = 34; + this.dbpFP.Text = "分配"; + // + // btnRefresh + // + this.btnRefresh.AllowFocus = false; + this.btnRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnRefresh.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnRefresh.Appearance.Options.UseFont = true; + this.btnRefresh.Location = new System.Drawing.Point(459, 7); + this.btnRefresh.Name = "btnRefresh"; + this.btnRefresh.Size = new System.Drawing.Size(74, 26); + this.btnRefresh.TabIndex = 33; + this.btnRefresh.Text = "刷新列数据"; + // + // btnHiding + // + this.btnHiding.AllowFocus = false; + this.btnHiding.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnHiding.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnHiding.Appearance.Options.UseFont = true; + this.btnHiding.Location = new System.Drawing.Point(535, 7); + this.btnHiding.Name = "btnHiding"; + this.btnHiding.Size = new System.Drawing.Size(67, 26); + this.btnHiding.TabIndex = 32; + this.btnHiding.Text = "隐藏主表"; + this.btnHiding.Visible = false; + // + // btnHelp + // + this.btnHelp.AllowFocus = false; + this.btnHelp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnHelp.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnHelp.Appearance.Options.UseFont = true; + this.btnHelp.Location = new System.Drawing.Point(604, 7); + this.btnHelp.Name = "btnHelp"; + this.btnHelp.Size = new System.Drawing.Size(67, 26); + this.btnHelp.TabIndex = 30; + this.btnHelp.Text = "帮助文档"; + // + // pl_templete + // + this.pl_templete.Controls.Add(this.cb_templete); + this.pl_templete.Controls.Add(this.lbl_templete); + this.pl_templete.Location = new System.Drawing.Point(3, 3); + this.pl_templete.LookAndFeel.SkinName = "VS2010"; + this.pl_templete.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Style3D; + this.pl_templete.Name = "pl_templete"; + this.pl_templete.Size = new System.Drawing.Size(195, 29); + this.pl_templete.TabIndex = 29; + this.pl_templete.Visible = false; + // + // cb_templete + // + this.cb_templete.Location = new System.Drawing.Point(58, 4); + this.cb_templete.Name = "cb_templete"; + this.cb_templete.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { + new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); + this.cb_templete.Properties.DropDownRows = 8; + this.cb_templete.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; + this.cb_templete.Size = new System.Drawing.Size(133, 20); + this.cb_templete.TabIndex = 19; + // + // lbl_templete + // + this.lbl_templete.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbl_templete.Location = new System.Drawing.Point(5, 8); + this.lbl_templete.Name = "lbl_templete"; + this.lbl_templete.Size = new System.Drawing.Size(48, 12); + this.lbl_templete.TabIndex = 16; + this.lbl_templete.Text = "选择模版"; + // + // pl_input + // + this.pl_input.Controls.Add(this.cb_input); + this.pl_input.Controls.Add(this.txt_input); + this.pl_input.Controls.Add(this.labelControl2); + this.pl_input.Controls.Add(this.btn_input); + this.pl_input.Location = new System.Drawing.Point(3, 3); + this.pl_input.LookAndFeel.SkinName = "VS2010"; + this.pl_input.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Style3D; + this.pl_input.Name = "pl_input"; + this.pl_input.Size = new System.Drawing.Size(280, 29); + this.pl_input.TabIndex = 27; + this.pl_input.Visible = false; + // + // cb_input + // + this.cb_input.Location = new System.Drawing.Point(58, 4); + this.cb_input.Name = "cb_input"; + this.cb_input.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { + new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); + this.cb_input.Properties.DropDownRows = 8; + this.cb_input.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; + this.cb_input.Size = new System.Drawing.Size(79, 20); + this.cb_input.TabIndex = 19; + // + // txt_input + // + this.txt_input.Location = new System.Drawing.Point(149, 4); + this.txt_input.Name = "txt_input"; + this.txt_input.Properties.Appearance.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txt_input.Properties.Appearance.Options.UseFont = true; + this.txt_input.Size = new System.Drawing.Size(98, 20); + this.txt_input.TabIndex = 18; + // + // labelControl2 + // + this.labelControl2.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelControl2.Location = new System.Drawing.Point(5, 8); + this.labelControl2.Name = "labelControl2"; + this.labelControl2.Size = new System.Drawing.Size(48, 12); + this.labelControl2.TabIndex = 16; + this.labelControl2.Text = "快速录入"; + // + // btn_input + // + this.btn_input.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btn_input.Appearance.Options.UseFont = true; + this.btn_input.Location = new System.Drawing.Point(249, 4); + this.btn_input.Name = "btn_input"; + this.btn_input.Size = new System.Drawing.Size(27, 21); + this.btn_input.TabIndex = 13; + this.btn_input.Text = ">>"; + // + // dpbImport + // + this.dpbImport.AllowFocus = false; + this.dpbImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.dpbImport.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.dpbImport.Appearance.Options.UseFont = true; + this.dpbImport.DropDownArrowStyle = DevExpress.XtraEditors.DropDownArrowStyle.Show; + this.dpbImport.Location = new System.Drawing.Point(749, 7); + this.dpbImport.Name = "dpbImport"; + this.dpbImport.Size = new System.Drawing.Size(74, 26); + this.dpbImport.TabIndex = 26; + this.dpbImport.Text = "导入导出"; + // + // btnBillAdd + // + this.btnBillAdd.AllowFocus = false; + this.btnBillAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnBillAdd.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnBillAdd.Appearance.Options.UseFont = true; + this.btnBillAdd.Location = new System.Drawing.Point(901, 7); + this.btnBillAdd.Name = "btnBillAdd"; + this.btnBillAdd.Size = new System.Drawing.Size(67, 26); + this.btnBillAdd.TabIndex = 19; + this.btnBillAdd.Text = "新建单据"; + // + // btnBillApply + // + this.btnBillApply.AllowFocus = false; + this.btnBillApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnBillApply.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnBillApply.Appearance.Options.UseFont = true; + this.btnBillApply.Location = new System.Drawing.Point(1108, 7); + this.btnBillApply.Name = "btnBillApply"; + this.btnBillApply.Size = new System.Drawing.Size(67, 26); + this.btnBillApply.TabIndex = 25; + this.btnBillApply.Text = "保存提交"; + // + // dpCopyBill + // + this.dpCopyBill.AllowFocus = false; + this.dpCopyBill.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.dpCopyBill.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.dpCopyBill.Appearance.Options.UseFont = true; + this.dpCopyBill.DropDownArrowStyle = DevExpress.XtraEditors.DropDownArrowStyle.Show; + this.dpCopyBill.Location = new System.Drawing.Point(825, 7); + this.dpCopyBill.Name = "dpCopyBill"; + this.dpCopyBill.Size = new System.Drawing.Size(74, 26); + this.dpCopyBill.TabIndex = 24; + this.dpCopyBill.Text = "复制单据"; + // + // btnPrint + // + this.btnPrint.AllowFocus = false; + this.btnPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnPrint.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnPrint.Appearance.Options.UseFont = true; + this.btnPrint.DropDownArrowStyle = DevExpress.XtraEditors.DropDownArrowStyle.Show; + this.btnPrint.Location = new System.Drawing.Point(1177, 7); + this.btnPrint.Name = "btnPrint"; + this.btnPrint.Size = new System.Drawing.Size(74, 26); + this.btnPrint.TabIndex = 23; + this.btnPrint.Text = "打印单据"; + // + // dpbTools + // + this.dpbTools.AllowFocus = false; + this.dpbTools.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.dpbTools.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.dpbTools.Appearance.Options.UseFont = true; + this.dpbTools.DropDownArrowStyle = DevExpress.XtraEditors.DropDownArrowStyle.Show; + this.dpbTools.Location = new System.Drawing.Point(673, 7); + this.dpbTools.Name = "dpbTools"; + this.dpbTools.Size = new System.Drawing.Size(74, 26); + this.dpbTools.TabIndex = 22; + this.dpbTools.Text = "常用工具"; + // + // btnDelete + // + this.btnDelete.AllowFocus = false; + this.btnDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnDelete.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnDelete.Appearance.Options.UseFont = true; + this.btnDelete.Location = new System.Drawing.Point(970, 7); + this.btnDelete.Name = "btnDelete"; + this.btnDelete.Size = new System.Drawing.Size(67, 26); + this.btnDelete.TabIndex = 20; + this.btnDelete.Text = "删除记录"; + // + // btnBillSave + // + this.btnBillSave.AllowFocus = false; + this.btnBillSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnBillSave.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnBillSave.Appearance.Options.UseFont = true; + this.btnBillSave.Location = new System.Drawing.Point(1039, 7); + this.btnBillSave.Name = "btnBillSave"; + this.btnBillSave.Size = new System.Drawing.Size(67, 26); + this.btnBillSave.TabIndex = 21; + this.btnBillSave.Text = "保存单据"; + // + // pl_main_top + // + this.pl_main_top.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.pl_main_top.Appearance.Options.UseBackColor = true; + this.pl_main_top.Controls.Add(this.pl_main_top_center); + this.pl_main_top.Controls.Add(this.pl_main_top_right); + this.pl_main_top.Controls.Add(this.pl_main_top_left); + this.pl_main_top.Dock = System.Windows.Forms.DockStyle.Top; + this.pl_main_top.Location = new System.Drawing.Point(2, 2); + this.pl_main_top.Name = "pl_main_top"; + this.pl_main_top.Size = new System.Drawing.Size(1256, 38); + this.pl_main_top.TabIndex = 0; + // + // pl_main_top_center + // + this.pl_main_top_center.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main_top_center.Appearance.Options.UseBackColor = true; + this.pl_main_top_center.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_top_center.Controls.Add(this.lbTitle); + this.pl_main_top_center.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_main_top_center.Location = new System.Drawing.Point(162, 2); + this.pl_main_top_center.Name = "pl_main_top_center"; + this.pl_main_top_center.Size = new System.Drawing.Size(902, 34); + this.pl_main_top_center.TabIndex = 3; + // + // lbTitle + // + this.lbTitle.BackColor = System.Drawing.Color.Transparent; + this.lbTitle.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbTitle.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.lbTitle.ForeColor = System.Drawing.Color.Blue; + this.lbTitle.Location = new System.Drawing.Point(0, 0); + this.lbTitle.Name = "lbTitle"; + this.lbTitle.Size = new System.Drawing.Size(902, 34); + this.lbTitle.TabIndex = 1; + this.lbTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // pl_main_top_right + // + this.pl_main_top_right.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main_top_right.Appearance.Options.UseBackColor = true; + this.pl_main_top_right.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_top_right.Controls.Add(this.lblOrderNo); + this.pl_main_top_right.Controls.Add(this.labelControl1); + this.pl_main_top_right.Dock = System.Windows.Forms.DockStyle.Right; + this.pl_main_top_right.Location = new System.Drawing.Point(1064, 2); + this.pl_main_top_right.Name = "pl_main_top_right"; + this.pl_main_top_right.Size = new System.Drawing.Size(190, 34); + this.pl_main_top_right.TabIndex = 2; + // + // lblOrderNo + // + this.lblOrderNo.Appearance.BackColor = System.Drawing.Color.Transparent; + this.lblOrderNo.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Underline); + this.lblOrderNo.Appearance.ForeColor = System.Drawing.Color.Blue; + this.lblOrderNo.Location = new System.Drawing.Point(67, 19); + this.lblOrderNo.Name = "lblOrderNo"; + this.lblOrderNo.Size = new System.Drawing.Size(90, 12); + this.lblOrderNo.TabIndex = 1; + this.lblOrderNo.Text = "XTC170112010001"; + // + // labelControl1 + // + this.labelControl1.Appearance.BackColor = System.Drawing.Color.Transparent; + this.labelControl1.Appearance.Font = new System.Drawing.Font("宋体", 9F); + this.labelControl1.Appearance.ForeColor = System.Drawing.Color.Blue; + this.labelControl1.Location = new System.Drawing.Point(7, 19); + this.labelControl1.Name = "labelControl1"; + this.labelControl1.Size = new System.Drawing.Size(54, 12); + this.labelControl1.TabIndex = 0; + this.labelControl1.Text = "单据编号:"; + // + // pl_main_top_left + // + this.pl_main_top_left.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main_top_left.Appearance.Options.UseBackColor = true; + this.pl_main_top_left.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_top_left.Controls.Add(this.pl_red); + this.pl_main_top_left.Controls.Add(this.pl_blue); + this.pl_main_top_left.Dock = System.Windows.Forms.DockStyle.Left; + this.pl_main_top_left.Location = new System.Drawing.Point(2, 2); + this.pl_main_top_left.Name = "pl_main_top_left"; + this.pl_main_top_left.Size = new System.Drawing.Size(160, 34); + this.pl_main_top_left.TabIndex = 1; + // + // pl_red + // + this.pl_red.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_red.Appearance.Options.UseBackColor = true; + this.pl_red.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_red.Controls.Add(this.rdRed); + this.pl_red.Dock = System.Windows.Forms.DockStyle.Left; + this.pl_red.Location = new System.Drawing.Point(80, 0); + this.pl_red.Name = "pl_red"; + this.pl_red.Size = new System.Drawing.Size(80, 34); + this.pl_red.TabIndex = 3; + // + // rdRed + // + this.rdRed.AutoSize = true; + this.rdRed.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.rdRed.ForeColor = System.Drawing.Color.Red; + this.rdRed.Location = new System.Drawing.Point(6, 12); + this.rdRed.Name = "rdRed"; + this.rdRed.Size = new System.Drawing.Size(71, 16); + this.rdRed.TabIndex = 3; + this.rdRed.Text = "红字单据"; + this.rdRed.UseVisualStyleBackColor = true; + // + // pl_blue + // + this.pl_blue.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_blue.Appearance.Options.UseBackColor = true; + this.pl_blue.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_blue.Controls.Add(this.rdBlue); + this.pl_blue.Dock = System.Windows.Forms.DockStyle.Left; + this.pl_blue.Location = new System.Drawing.Point(0, 0); + this.pl_blue.Name = "pl_blue"; + this.pl_blue.Size = new System.Drawing.Size(80, 34); + this.pl_blue.TabIndex = 2; + // + // rdBlue + // + this.rdBlue.AutoSize = true; + this.rdBlue.Checked = true; + this.rdBlue.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.rdBlue.ForeColor = System.Drawing.Color.Blue; + this.rdBlue.Location = new System.Drawing.Point(7, 12); + this.rdBlue.Name = "rdBlue"; + this.rdBlue.Size = new System.Drawing.Size(71, 16); + this.rdBlue.TabIndex = 2; + this.rdBlue.TabStop = true; + this.rdBlue.Text = "蓝字单据"; + this.rdBlue.UseVisualStyleBackColor = true; + // + // FrmBill + // + this.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.Appearance.Options.UseBackColor = true; + this.Appearance.Options.UseFont = true; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1260, 613); + this.Controls.Add(this.pl_main); + this.Name = "FrmBill"; + this.Text = "FrmBill"; + ((System.ComponentModel.ISupportInitialize)(this.pl_main)).EndInit(); + this.pl_main.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_center)).EndInit(); + this.pl_main_center.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_center_detail)).EndInit(); + this.pl_main_center_detail.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_bottom)).EndInit(); + this.pl_main_bottom.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_templete)).EndInit(); + this.pl_templete.ResumeLayout(false); + this.pl_templete.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.cb_templete.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_input)).EndInit(); + this.pl_input.ResumeLayout(false); + this.pl_input.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.cb_input.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.txt_input.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top)).EndInit(); + this.pl_main_top.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top_center)).EndInit(); + this.pl_main_top_center.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top_right)).EndInit(); + this.pl_main_top_right.ResumeLayout(false); + this.pl_main_top_right.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main_top_left)).EndInit(); + this.pl_main_top_left.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_red)).EndInit(); + this.pl_red.ResumeLayout(false); + this.pl_red.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_blue)).EndInit(); + this.pl_blue.ResumeLayout(false); + this.pl_blue.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private DevExpress.XtraEditors.PanelControl pl_main; + private DevExpress.XtraEditors.PanelControl pl_main_center; + private DevExpress.XtraEditors.PanelControl pl_main_center_detail; + private Control.GridControlEx gcMain; + private DevExpress.XtraEditors.XtraScrollableControl pl_main_center_master; + public DevExpress.XtraEditors.PanelControl pl_main_bottom; + private DevExpress.XtraEditors.DropDownButton dbpFP; + private DevExpress.XtraEditors.SimpleButton btnRefresh; + private DevExpress.XtraEditors.SimpleButton btnHiding; + private DevExpress.XtraEditors.SimpleButton btnHelp; + private DevExpress.XtraEditors.PanelControl pl_templete; + private DevExpress.XtraEditors.ComboBoxEdit cb_templete; + private DevExpress.XtraEditors.LabelControl lbl_templete; + private DevExpress.XtraEditors.PanelControl pl_input; + private DevExpress.XtraEditors.ComboBoxEdit cb_input; + private DevExpress.XtraEditors.TextEdit txt_input; + private DevExpress.XtraEditors.LabelControl labelControl2; + private DevExpress.XtraEditors.SimpleButton btn_input; + private DevExpress.XtraEditors.DropDownButton dpbImport; + private DevExpress.XtraEditors.SimpleButton btnBillAdd; + private DevExpress.XtraEditors.SimpleButton btnBillApply; + private DevExpress.XtraEditors.DropDownButton dpCopyBill; + private DevExpress.XtraEditors.DropDownButton btnPrint; + private DevExpress.XtraEditors.DropDownButton dpbTools; + private DevExpress.XtraEditors.SimpleButton btnDelete; + private DevExpress.XtraEditors.SimpleButton btnBillSave; + private DevExpress.XtraEditors.PanelControl pl_main_top; + private DevExpress.XtraEditors.PanelControl pl_main_top_center; + private System.Windows.Forms.Label lbTitle; + private DevExpress.XtraEditors.PanelControl pl_main_top_right; + private DevExpress.XtraEditors.LabelControl lblOrderNo; + private DevExpress.XtraEditors.LabelControl labelControl1; + private DevExpress.XtraEditors.PanelControl pl_main_top_left; + private DevExpress.XtraEditors.PanelControl pl_red; + private System.Windows.Forms.RadioButton rdRed; + private DevExpress.XtraEditors.PanelControl pl_blue; + private System.Windows.Forms.RadioButton rdBlue; + } +} \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/FrmBill.cs b/插件库/Lskj.PubBillManagement/FrmBill.cs new file mode 100644 index 0000000..8670557 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmBill.cs @@ -0,0 +1,6638 @@ +using DevExpress.Data; +using DevExpress.Utils; +using DevExpress.XtraBars; +using DevExpress.XtraEditors; +using DevExpress.XtraGrid.Columns; +using DevExpress.XtraGrid.Views.Base; +using DevExpress.XtraGrid.Views.Grid; +using DevExpress.XtraTab; +using DevExpress.XtraTreeList.Columns; +using DevExpress.XtraTreeList.Nodes; +using Lskj.Business; +using Lskj.Business.Impl; +using Lskj.Control; +using Lskj.Control.BrowserSetting; +using Lskj.Control.Model; +using Lskj.Core; +using Lskj.Data; +using Lskj.Model; +using Lskj.PubBillManagement.Model; +using Lskj.Util; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Data.SqlClient; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Lskj.PubBillManagement +{ + public partial class FrmBill : BaseForm + { + /// + /// 是否为初始化创建 + /// + private bool _isInitFinish; + /// + /// 是否加载右侧控件数据 + /// + private bool _isLoadRightControlValue = true; + /// + /// 是否手动选择了模版 + /// + private bool _isSelectedTemplete; + /// + /// 是否直接打印 + /// + private bool _isExcPrint; + /// + /// 是否选择关联下发 + /// + private bool _isCheck; + /// + /// 主打印Sql + /// + private string _mainPrintSql; + private string guidField = "xxxxx_guid"; + /// + /// 主键字段 + /// + private string mRecordPrimaryField; + /// + /// 单据水印 + /// + private WaterMark _waterMark; + /// + /// 导入单据明细数据、导入单据明细并更新 + /// + private BarButtonItem _itemImport, _itemImportUpdate; + /// + /// 打印主sql中关联打印次数返回条件 + /// + private string _printModeCond; + /// + /// 打印完成后添加数据用到的参数: 表名,列前缀,主键字段,主键值,模块编号,主打印Sql + /// + private List _printSaveParams; + /// + /// 单据明细列 + /// + private DataTable _detailColumns; + private bool IsCopying = false; + + + protected DataRow BillRowItem; + /// + /// 主表控件 + /// + public MyControl ControlObj; + /// + /// 入口参数 + /// + protected DynamicBillModel SysModel; + /// + /// 是否为Brp模版 + /// + /// true if this instance is BRP templete; otherwise, false. + protected bool IsBrpTemplete { get { return SysModel is DynamicBillBrpModel; } } + /// + /// + /// + public BillModel BillModel; + /// + /// 快速扫码控件 + /// + /// The main bottom input object. + public PanelControl MainBottomInputObj { get { return this.pl_input; } } + /// + /// Brp模版控件 + /// + /// The main bottom templete object. + public PanelControl MainBottomTempleteObj { get { return this.pl_templete; } } + /// + /// 明细表格数据 + /// + /// The main bottom templete object. + public GridControlEx gcMainDetilObj { get { return this.gcMain; } } + + /// + /// Brp模版控件 + /// + /// 扫码框 + public TextEdit txtinputobj { get { return this.txt_input; } } + /// + /// 数量名称 + /// + public string NumberMc; + /// + /// 红字单据的分配管理模块 + /// + public string rdRedUnionCode; + /// + /// 蓝字单据的分配管理模块 + /// + public string rdBlueUnionCode; + /// + /// 是否拖拽换行展示 + /// + public bool isDragWrap = true; + /// + /// 是否执行了加载储存过程 + /// + //public bool ProcessExists = false; + /// + /// 保存或修改时报错信息 + /// + public string SaveErrorMessage = string.Empty; + /// + /// 单据明细删除的行 + /// + // private Dictionary ToWithdrawRows = new Dictionary(); + private List> ToWithdrawRows = new List>(); + /// + ///改变颜色行 + /// + private List ChangeColorRow = new List(); + /// + /// + /// + public string AssociatedField = string.Empty; + /// + /// 注册设置公共事件私有类 + /// + private static PubEvenImpl _eventHandler; + /// + /// 注册设置公共事件类 + /// + private static PubEvenImpl eventHandler; + /// + /// 当前人员是否有导出权限 + /// + public bool ExportPermission; + /// + /// 新增 + /// + public string addText = Business.Impl.LanguageTranslation.Translatable ? "(" + Business.Impl.LanguageTranslation.GetTranslatedText("新增") + ")" : "(新增)"; + /// + /// 修改 + /// + public string updateText = Business.Impl.LanguageTranslation.Translatable ? "(" + Business.Impl.LanguageTranslation.GetTranslatedText("修改") + ")" : "(修改)"; + /// + /// 主表动态生成的日期列 + /// + public List DateColumnList = new List(); + /// + /// 主表动态生成的合计列 + /// + public GridColumn SumGridColumn = new GridColumn(); + /// + /// 附加右键菜单集合 + /// + public List itemCommonList = new List(); + /// + /// 是否已经添加了多行汇总 + /// + public bool MultiLineSummary; + /// + /// 扫码框 + /// + public TextEdit ScanCodeTextEdit = null; + /// + /// 当前操作的ImageEdit + /// + private LabelImageEdit _imageEdit; + /// + /// 保存验证条件表 + /// + public DataTable SaveCondTab = new DataTable(); + private BarManager barManager1; + private PopupMenu pMenu; + private PopupMenu pmBillExp; + private PopupMenu pmBill; + private PopupMenu pMprint; + private PopupMenu pmFP; + + /// + /// 单据保存或提交成功后通知来源界面刷新。 + /// + public event EventHandler BillChanged; + + public FrmBill() + { + InitializeComponent(); + InitializeMainEvents(); + } + + public FrmBill(DynamicBillModel model) + : this() + { + OnLoad(model); + } + + private void InitializeMainEvents() + { + this.dbpFP.Click += new EventHandler(this.OnBtnFPOldClick); + this.btnRefresh.Click += new EventHandler(this.btnRefresh_Click); + this.btnHiding.Click += new EventHandler(this.OnMainTableHiding); + this.btnHelp.Click += new EventHandler(this.OnHelpClick); + this.cb_templete.QueryCloseUp += new CancelEventHandler(this.cb_templete_QueryCloseUp); + this.cb_templete.Click += new EventHandler(this.OnTempleteClick); + this.txt_input.KeyDown += new KeyEventHandler(this.OnInputKeyDown); + this.btn_input.Click += new EventHandler(this.OnInputClick); + this.btnBillAdd.Click += new EventHandler(this.OnBillAddClick); + this.btnBillApply.Click += new EventHandler(this.OnBillApplyClick); + this.dpbTools.Click += new EventHandler(this.OnToolsClick); + this.btnDelete.Click += new EventHandler(this.OnDeleteClick); + this.btnBillSave.Click += new EventHandler(this.OnBillSaveClick); + this.lbTitle.Paint += new PaintEventHandler(this.OnLabelTitlePaint); + this.rdRed.Click += new EventHandler(this.OnRedStateClick); + this.rdBlue.Click += new EventHandler(this.OnBlueStateClick); + this.pl_main_center_master.Click += new EventHandler(this.OnMainFocusAfter); + this.KeyDown += new KeyEventHandler(this.OnFrmMainKeyDown); + } + + private void InitializePopupMenus() + { + if (this.barManager1 != null) return; + if (this.components == null) + { + this.components = new Container(); + } + this.barManager1 = new BarManager(this.components); + this.barManager1.Form = this; + this.pmFP = new PopupMenu(this.components) { Manager = this.barManager1 }; + this.pmBillExp = new PopupMenu(this.components) { Manager = this.barManager1 }; + this.pmBill = new PopupMenu(this.components) { Manager = this.barManager1 }; + this.pMprint = new PopupMenu(this.components) { Manager = this.barManager1 }; + this.pMenu = new PopupMenu(this.components) { Manager = this.barManager1 }; + this.dbpFP.DropDownControl = this.pmFP; + this.dpbImport.DropDownControl = this.pmBillExp; + this.dpCopyBill.DropDownControl = this.pmBill; + this.btnPrint.DropDownControl = this.pMprint; + this.dpbTools.DropDownControl = this.pMenu; + this.txt_input.MenuManager = this.barManager1; + } + + protected virtual void OnBillChanged(EventArgs e) + { + EventHandler handler = BillChanged; + if (handler != null) handler(this, e); + } + + /// + /// 说明:窗口加载 + /// 创建人:龚宇超 + /// 创建日期:2017-11-23 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The instance containing the event data. + public void OnLoad(DynamicBillModel Model) + { + try + { + this.SysModel = Model;// 单据动态链接库参数,入口参数 + this._isInitFinish = false;// 是否为初始化创建 + this.pl_main.Visible = false; //获取或设置一个值,该值指示是否显示该控件及其所有子控件。 + //this.ProcessExists = (Lskj.Data.Caches.CacheSYSConfig.Instance().JudgeProcessExists() && SystemInfo.Instance.isExecload); + + if (true)//5.0控件样式 + { + this.pl_main_bottom.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main_bottom.BackColor = Color.FromArgb(240, 240, 240); + this.pl_main_bottom.LookAndFeel.UseDefaultLookAndFeel = false; + this.pl_main_bottom.LookAndFeel.UseWindowsXPTheme = true; + } + + Dictionary dataCaches = Model != null ? Model.DataCaches : null; + dataCaches.GetValue(this, "DataCaches", out bool _);//等待缓存数据加载完成 + this.InitializeSetting();//初始化系统配置 + this.InitializePopupMenus(); + this.InitializeControl();//初始化控件 + + this.gcMain.GridView.KeyDown += new KeyEventHandler(OnToWithdraw); + this.gcMain.GridView.GridControl.ProcessGridKey += new KeyEventHandler(OnGridControlKye); + + this.gcMain.ExportPermission = this.BillModel.ExportPermission; + + this.CalculateCoordinates(); + + //单据明细推拽 + if (this.BillModel.DraggingOrder && !string.IsNullOrWhiteSpace(this.BillModel.DetailOrderField)) + { + this.gcMain.InitializedragState(this.BillModel.DetailOrderField); + } + + //非中文替换(红蓝单据等固定信息) + if (Business.Impl.LanguageTranslation.Translatable) + { + this.rdBlue.Text = Business.Impl.LanguageTranslation.GetTranslatedText(this.rdBlue.Text); + this.rdRed.Text = Business.Impl.LanguageTranslation.GetTranslatedText(this.rdRed.Text); + this.labelControl1.Text = Business.Impl.LanguageTranslation.GetTranslatedText(this.labelControl1.Text); + } + + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("单据初始化窗体失败!", ex); + MessageUtil.Show(ex.StackTrace); + } + finally + { + this._isInitFinish = true; + this.pl_main.Visible = true; + if (this.BillModel != null && (this.BillModel.MainVerticalScroll || this.BillModel.MainHorizontalScrolling)) + { + this.pl_main_center_master.AutoScroll = true; + this.pl_main_center_master.VerticalScroll.Visible = this.BillModel.MainVerticalScroll;//隐藏纵向滚动条 + this.pl_main_center_master.HorizontalScroll.Visible = this.BillModel.MainHorizontalScrolling;//隐藏横向滚动条 + } + + } + } + /// + /// 说明:初始化系统配置 + /// 创建人:龚宇超 + /// 创建日期:2017-11-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeSetting() + { + Dictionary dataCaches = SysModel != null ? SysModel.DataCaches : null; + if (!dataCaches.GetValue(this, "BillInfo", out DataRow modelRow)) + { + modelRow = BillImpl.GetBillInfo(this.SysModel.ModuleCode);//获取单个模块信息 + } + if (modelRow == null) + { + //MessageUtil.Show("模块编号[" + this.SysModel.ModuleCode + "],配置错误!\r\n该模块信息未找到!"); + //return; + throw new Exception("模块编号[" + this.SysModel.ModuleCode + "],配置错误!\r\n该模块信息未找到!"); + } + if (!dataCaches.GetValue(this, "BillModel", out BillModel)) + { + this.BillModel = new BillModel(modelRow);//初始化类的新实例。 + } + + if (this.BillModel != null) + { + this.BillModel.TypeName = string.IsNullOrEmpty(SysModel.BillMasterSql) ? this.SysModel.FormText : this.BillModel.TypeName;// 模块名称 + if (!string.IsNullOrWhiteSpace(this.SysModel.DocumentName)) this.BillModel.TypeName = this.SysModel.DocumentName; + + if (!dataCaches.GetValue(this, "MasterPreFix", out string masterPreFix)) + { + masterPreFix = BaseImpl.GetColumnPrefix(this.BillModel.MasterTable);// 主表列前缀 + } + this.BillModel.MasterPreFix = masterPreFix; + if (!dataCaches.GetValue(this, "DetailPreFix", out string detailPreFix)) + { + detailPreFix = BaseImpl.GetColumnPrefix(this.BillModel.DetailTable);// 明细表列前缀 + } + this.BillModel.DetailPreFix = detailPreFix; + this.BillModel.DetailOrderField = this.BillModel.DetailPreFix + "lsidx_id";// 单据来源id + if (SystemInfo.Instance.IsNotBillDetailOrder)//禁用排序 + this.BillModel.DetailOrderField = string.Empty; + } + if (!dataCaches.GetValue(this, "MenuConfigTab", out DataRow menuRow)) + { + menuRow = BaseImpl.GetMenuConfigTab(this.SysModel.ModuleId);//获取菜单其他配置 + } + if (menuRow != null) + { + this.BillModel.BillSourceIds = menuRow.Table.Columns.Contains("BillSourceIds") ? (menuRow["BillSourceIds"] + "").Trim(',') : string.Empty; + this.BillModel.BillFlag = menuRow.Table.Columns.Contains("BillFlag") && !string.IsNullOrEmpty(menuRow["BillFlag"] + "") ? Convert.ToInt32(menuRow["BillFlag"] + "") : -1; + } + if (this.SysModel.HideSource) + { + this.BillModel.PanelWidth = 0; + this.BillModel.PanelHeight = 0; + } + + + //获取打印其他参数 + GetPrintOtherParam(); + if (!dataCaches.GetValue(this, "BillSetting", out bool _)) + { + BillImpl.InitBillSetting(this.BillModel); + } + + if (this.BillModel.IsBrp) + { + this.MainBottomInputObj.Visible = false; + this.MainBottomTempleteObj.Visible = true; + } + + //显示筛选行 + if (this.BillModel.LoadFilter) this.gcMain.GridView.OptionsView.ShowAutoFilterRow = true; + //树表格 + if (this.BillModel.DetailTreeTable) + { + this.pl_main_center_detail.Controls.Clear(); + this.gcMain = new TreeGridControlEx(); + this.gcMain.Dock = DockStyle.Fill; + this.pl_main_center_detail.Controls.Add(this.gcMain); + (this.gcMain as TreeGridControlEx).Expansion = this.BillModel.DetailTreeTableExpansion; + (this.gcMain as TreeGridControlEx).AddRightButton(); + //节点编号 + (this.gcMain as TreeGridControlEx).TreeListObj.KeyFieldName = "tap_id"; + //父节点编号 + (this.gcMain as TreeGridControlEx).TreeListObj.ParentFieldName = "tap_pid"; + (this.gcMain as TreeGridControlEx).SortField = this.BillModel.DetailOrderField; + //(this.gcMain as TreeGridControlEx).TreeTableDragCondition = this.BillModel.TreeTableDragCondition; + + (this.gcMain as TreeGridControlEx).InitializedragState(); + } + + + } + /// + /// 说明:初始化分配关联模块 + /// 创建人:王一帆 + /// 创建日期:2020-02-18 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeUnionCode() + { + if (this.BillModel.PopupUnionCode.Contains(",")) + { + string[] UnionCodeSplit = this.BillModel.PopupUnionCode.Split(','); + if (UnionCodeSplit.Length >= 1) + { + this.BillModel.PopupUnionCode = this.BillModel.BillFlag == 1 ? UnionCodeSplit[1] + "" : UnionCodeSplit[0] + ""; + rdBlueUnionCode = UnionCodeSplit[0] + ""; + rdRedUnionCode = UnionCodeSplit[1] + ""; + } + } + else + { + rdBlueUnionCode = rdRedUnionCode = this.BillModel.PopupUnionCode; + } + } + /// + /// 说明:初始化控件 + /// 创建人:龚宇超 + /// 创建日期:2017-11-23 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeControl() + { + if (this.IsBrpTemplete || this.BillModel.IsBrp)// 是否为Brp模版 + this.InitializeTemplete(); + + this.InitializeStatus();//初始化红蓝字单 + this.InitializeOper();//初始化常用操作等功能 + this.InitializeBillInfo();//初始化单据控件信息 + + } + + /// + /// 说明:初始化红蓝字单 + /// 创建人:龚宇超 + /// 创建日期:2017-11-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeStatus() + { + // 初始化红、蓝单 + if (this.BillModel.BillFlag == 0) + { + this.rdBlue.Checked = true; + this.rdRed.Checked = false; + this.lbTitle.ForeColor = Color.Blue; + this.pl_red.Visible = false; + } + if (this.BillModel.BillFlag == 1) + { + this.rdRed.Checked = true; + this.rdBlue.Checked = false; + this.lbTitle.ForeColor = Color.Red; + this.pl_blue.Visible = false; + } + this.dpCopyBill.Enabled = this.BillModel.CanCopy; + this.dpbImport.Enabled = this.BillModel.CanImport || this.BillModel.CanExport; + + if (this.SysModel.HasReadPrivilege()) + this.pl_main_bottom.Enabled = false; + InitializeUnionCode();//根据红蓝字段更新分配 + this.dbpFP.Visible = !string.IsNullOrWhiteSpace(this.BillModel.PopupUnionCode); + } + /// + /// 说明:初始化常用操作等功能 + /// 创建人:龚宇超 + /// 创建日期:2017-11-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeOper() + { + BarButtonItem itemCopyMaster = new BarButtonItem(); + itemCopyMaster.Caption = "复制表头信息"; + itemCopyMaster.ItemClick += new ItemClickEventHandler(OnCopyMasterItemClick); + BarButtonItem itemCopyAll = new BarButtonItem(); + itemCopyAll.Caption = "复制整单信息"; + itemCopyAll.ItemClick += new ItemClickEventHandler(OnCopyAllItemClick); + BarButtonItem itemExport = new BarButtonItem(); + itemExport.Caption = "导出Excel文件"; + itemExport.ItemClick += new ItemClickEventHandler(OnExportItemClick); + BarButtonItem itemFPBatch = new BarButtonItem(); + itemFPBatch.Caption = "批量分配"; + itemFPBatch.ItemClick += new ItemClickEventHandler(OnBtnFPNewClick); + this._itemImport = new BarButtonItem(); + this._itemImport.Caption = "导入Excel文件"; + this._itemImport.ItemClick += new ItemClickEventHandler(OnImportItemClick); + this._itemImportUpdate = new BarButtonItem(); + this._itemImportUpdate.Caption = "导入Excel文件(更新)"; + this._itemImportUpdate.ItemClick += new ItemClickEventHandler(OnImportUpdateItemClick); + + // 复制单据 + this.pmBill.AddItems(new BarItem[] { itemCopyMaster, itemCopyAll }); + // 导入导出 + if (this.BillModel.CanExport && this.BillModel.ExportPermission) + { + this.pmBillExp.AddItem(itemExport); + } + if (this.BillModel.CanImport) + { + this.pmBillExp.AddItems(new BarItem[] { _itemImport, _itemImportUpdate }); + } + //分配 + this.pmFP.AddItems(new BarItem[] { itemFPBatch }); + // 打印模版 + string[] files = this.BillModel.PrintFile.Split('|'); + for (int i = 0; i < files.Length; i++) + { + string fileName = files[i]; + if (!string.IsNullOrWhiteSpace(fileName)) + { + BarButtonItem itemPrint = new BarButtonItem(); + int index = i + 1; + itemPrint.Caption = files[i].Replace(".rmf", "").Replace(".frx", ""); + itemPrint.Tag = files[i]; + itemPrint.ItemClick += new ItemClickEventHandler(OnPrintItemClick); + pMprint.AddItem(itemPrint); + } + } + + // 常用工具 + Dictionary dataCaches = SysModel != null ? SysModel.DataCaches : null; + if (!dataCaches.GetValue(this, "OperBaseGridRightMenus", out DataTable tableCommon)) + { + tableCommon = BaseModuleImpl.GetBaseGridRightMenus(this.SysModel.ModuleCode, ModuleType.BillDetail);//获取右键菜单数据 + } + int j = 0, x = 0; + foreach (DataRow item in tableCommon.Rows) + { + if (j > 1) + { + BarButtonItem itemCommon = new BarButtonItem(); + itemCommon.Caption = item["menuname"] + ""; + itemCommon.Tag = item; + itemCommon.ItemClick += new ItemClickEventHandler(OnCommonItemClick); + if (tableCommon.Columns.Contains("menuCond")) + { + itemCommon.Enabled = ValidateCond(item["menuCond"] + "", null); + } + pMenu.AddItem(itemCommon); + } + else + { + SimpleButton itemCommon = new SimpleButton(); + //itemCommon.AutoSize = true; + itemCommon.Text = item["menuname"] + ""; + itemCommon.Tag = item; + itemCommon.Size = new System.Drawing.Size(67, 26); + itemCommon.Font = new Font("宋体", 9); + itemCommon.Click += new EventHandler(itemCommon_Click); + int inputWidth = pl_input.Visible ? pl_input.Width : 0; + itemCommon.Location = new Point(x + 6 + inputWidth, 6); + pl_main_bottom.Controls.Add(itemCommon); + x += itemCommon.Width + 6; + + if (tableCommon.Columns.Contains("menuCond")) + { + itemCommon.Enabled = ValidateCond(item["menuCond"] + "", null); + } + itemCommonList.Add(itemCommon); + j++; + } + + } + } + /// + /// 说明:常用工具点击 + /// 创建人:龚宇超 + /// 创建日期:2017-11-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void itemCommon_Click(object sender, EventArgs e) + { + try + { + SimpleButton btn = sender as SimpleButton; + DataRow rowItem = btn.Tag as DataRow; + GridRightMenuModel model = new GridRightMenuModel(rowItem); + + if (!string.IsNullOrWhiteSpace(model.ClickCond)) + { + string clickCond = this.ControlObj.ReplaceControlValue(model.ClickCond) + ""; + bool condResult = ValidateCond(clickCond, null); + if (!condResult) return; + } + + if (rowItem["dllname"].Equals("Lskj.PubBomImport.dll")) + { + if ((model.ParamList[7] + "").Equals("3")) + { + if (!this.BillSave(0, false)) + { + return; + } + } + } + StaticControl.RightMenuGridView = gcMain.GridView; + StaticControl.Comprefix = this.BillModel.DetailPreFix; + CommonMenu menu = new CommonMenu(this.SysModel, this.ControlObj, this.gcMain); + menu.ApplyBefore += new CommonToolApplyEventHandler(OnMenuApplyBefore); + menu.DynamicLinkAfter += new CommonToolAfterDynamicLinkEventHandler(OnDynamicLinkAfter); + menu.Apply(rowItem); + + if (StaticControl.ReturnRowLisy.Count > 0) + { + DataRow[] dataRows = StaticControl.ReturnRowLisy.ToArray(); + foreach (DataRow item in dataRows) + { + if (this.BillModel.DetailTreeTable) + { + this.AddRowToTreeGridControl(item, "0"); + } + else + { + this.AddRowToGridView(item); + } + } + } + + if (model != null && model.Refresh) + { + string billNo = this.lblOrderNo.Text.Trim(); + this.SetBillStatus(BillImpl.GetDataRowResult(string.Format("select * from {0} where {1}='{2}'", BillModel.MasterTable, BillModel.PrimaryKey, billNo))); + if (ControlObj != null && ControlObj.ParentPanel != null) + { + ControlObj.ParentPanel.Invalidate(); + ControlObj.ParentPanel.Update(); + } + } + + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + + } + + /// + /// 说明:初始化单据控件信息 + /// 创建人:龚宇超 + /// 创建日期:2017-11-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeBillInfo() + { + Dictionary dataCaches = SysModel != null ? SysModel.DataCaches : null; + if (!dataCaches.GetValue(this, "ControlLocation", out DataTable controls)) + { + controls = BaseModuleImpl.GetControlLocation(this.BillModel.FormKey, this.SysModel.ModuleCode); + if (!string.IsNullOrWhiteSpace(this.BillModel.BillSourceControlName)) + { + var targetRow = controls.AsEnumerable() + .FirstOrDefault(row => row.Field("fieldName").Equals(this.BillModel.BillSourceControlName, StringComparison.OrdinalIgnoreCase)); + if (targetRow != null) + { + targetRow["fieldTypeId"] = "-11"; + } + } + } + if (!dataCaches.GetValue(this, "AddGroupData", out DataTable groups)) + { + groups = BaseModuleImpl.GetAddGroupData(this.BillModel.FormKey);//获取主信息分组数据 + } + if (!dataCaches.GetValue(this, "ControlObj", out ControlObj)) + { + this.ControlObj = new MyControl() { Model = SysModel };//主表控件 + } + + //this.ControlObj = new MyControl();//// 主表控件 + this.ControlObj.OpenDocumentSource += OpenTheSourcePopup; + this.ControlObj.OtherParams = this.SysModel.OtherParams(); + this.ControlObj.InitControl(controls, this.pl_main_center_master, groups); + this.ControlObj.refGridLookUpData = this.BillModel.RefGridLookUpData;//2023-3-17,新增单据时刷新下拉框数据源 + this.ControlObj.OnDataSourceBindCallBack += new EventHandler(OnInitializeHeaderCallBack); + + this.pl_main_center_master.Height = (this.BillModel.ParentHeight - 36) > this.pl_main_center_master.Height ? this.pl_main_center_master.Height : this.BillModel.ParentHeight - 36; + + //设置图片框的上传和删除事件 + this.SetImageEvent(controls); + + // 初始化明细 + // 创建多表头,默认标准表格 + if (this.SysModel.GridEnumObj == GridEnum.BandedGridView || this.BillModel.AutoMultiHeader == 1) + { + this.pl_main_center_detail.Controls.Clear(); + this.gcMain = new BandedGridControlEx(); + this.gcMain.Model = this.SysModel; + this.gcMain.Dock = DockStyle.Fill; + this.pl_main_center_detail.Controls.Add(this.gcMain); + } + + if (!dataCaches.GetValue(this, "DetailColumns", out _detailColumns)) + { + _detailColumns = BillImpl.GetDetailColumns(this.SysModel.ModuleCode);//初始化单据明细列 + if (this.SysModel.GridEnumObj == GridEnum.BandedGridView || this.BillModel.AutoMultiHeader == 1) + { + //多表头sql要增加一个判断,否则多表头会出错 + _detailColumns = BillImpl.GetDetailColumns(this.SysModel.ModuleCode, true);//初始化单据明细列 + } + } + this.gcMain.DisableFieldSources = this.BillModel.DisableFieldSources; + this.gcMain.Model = this.SysModel; + this.gcMain.ParentControl = this.ControlObj;//把主表控件赋给 单据主表控件、基础档案查询条件控件等等 + this.gcMain.SetEditColumns(_detailColumns, GridCustomColumnStruct.BillDetailGridView + this.BillModel.FormKey);//设置可编辑列 + if (this.BillModel.IsBillMainDetailCheck == 1)//加载明细复选框 + { + if (this.BillModel.DetailTreeTable) + { + GridDragGrid.TreeListAddCheckBox((this.gcMain as TreeGridControlEx).TreeListObj); + } + else + { + GridDragGrid.GridAddCheckBox(this.gcMain.GridView); + } + } + + if (!dataCaches.GetValue(gcMain, "BaseGridRowColors", out DataTable dtBaseGridRowColors)) + { + dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLDETAIL_" + this.BillModel.FormKey); + } + this.gcMain.SetGridRowColors(dtBaseGridRowColors); + //触发右键回调 + this.gcMain.OnAfterLinkCilk += OnAfterLinkCilkCall; + if (!dataCaches.GetValue(gcMain, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus)) + { + dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLDETAIL_" + this.SysModel.ModuleCode); + } + if (this.gcMain is BandedGridControlEx)// 判断是不是多表头表格 + { + //设置表格右键菜单 + (this.gcMain as BandedGridControlEx).SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridViewRightCallBack, this.ControlObj); + (this.gcMain as BandedGridControlEx).GridView.ShowingEditor += new CancelEventHandler(OnGridViewShowingEditor); + } + else if (this.BillModel.DetailTreeTable) + { + (this.gcMain as TreeGridControlEx).SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridViewRightCallBack, this.ControlObj, (this.gcMain as TreeGridControlEx).MenuStrip); + //(this.gcMain as TreeGridControlEx).TreeListObj.DoubleClick += new EventHandler(OnGridViewDoubleClick);//和下方行单击事件功能一致(TreeListObj_MouseClick),同样的sql会重复执行。先注释 2025-06-30 + (this.gcMain as TreeGridControlEx).TreeListObj.ShowingEditor += new CancelEventHandler(OnGridViewShowingEditor); + } + else + { + this.gcMain.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridViewRightCallBack, this.ControlObj); + //this.gcMain.GridView.DoubleClick += new EventHandler(OnGridViewDoubleClick);//和下方行单击事件功能一致(OngcMainRowCellClick),同样的sql会重复执行。先注释 2025-06-30 + this.gcMain.GridView.ShowingEditor += new CancelEventHandler(OnGridViewShowingEditor); + } + + if (!dataCaches.GetValue(this, "SaveCondTab", out this.SaveCondTab)) + { + this.SaveCondTab = BaseModuleImpl.GetClientCond(this.SysModel.ModuleCode); + } + + + if (this.BillModel.DefaultAddEmptyRow) + { + this.gcMain.GridView.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom; + if (SystemInfo.Instance.IsAddEmptyRowOldTag) + { + this.gcMain.GridView.MouseDown += GridView_MouseDown; + this.gcMain.GridView.FocusedRowChanged += GridView_FocusedRowChanged; + } + else + { + this.gcMain.GridView.InitNewRow += new InitNewRowEventHandler(OnGridViewInitNewRow); + } + //this.gcMain.GridView.InitNewRow += new InitNewRowEventHandler(OnGridViewInitNewRow); + //this.gcMain.GridView.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom; + //this.gcMain.GridView.MouseDown += GridView_MouseDown; + //this.gcMain.GridView.FocusedRowChanged += GridView_FocusedRowChanged; + } + //程序若配置扫码框则回车换行 + if (this._detailColumns.Rows.Cast().FirstOrDefault(x => x["fieldsqltag"].ToString() == ControlType.LabSacn + "") != null) + { + this.gcMain.GridView.CellValueChanged += new CellValueChangedEventHandler(OnGridViewCellValueChanged); + } + + this.gcMain.GridControl.DataSourceChanged += OnGcMainDataSourceChanged; + this.gcMain.OnAllAfterParseCallBack += OnAllAfterParseCallBack; + } + + /// + /// 表格触发右键功能 + /// + /// + /// + private void OnAfterLinkCilkCall(object sender, EventArgs e) + { + string unioright = sender + ""; + DataRow rightrowitem = this.gcMain.gridViewRightMenu.MenuTable.Rows.Cast().FirstOrDefault(x => (x["orderid"] + "").Equals(unioright)); + + GridRightMenuModel model = new GridRightMenuModel(rightrowitem); + DataRow rowItem = this.gcMain.GetViewFocusedDataRow(); + if (!string.IsNullOrWhiteSpace(model.MenuCond)) + { + //判断条件 + DataRow row = this.gcMain.GridView.GetFocusedDataRow(); + string cond = ReplaceHelper.ReplaceRowParam(row, model.MenuCond); + bool condResult = ValidateCond(cond, null); + if (!condResult) return; + } + + CommonMenu menu = new CommonMenu(this.SysModel, ControlObj, this.gcMain); + menu.Apply(rightrowitem); + } + + /// + /// 说明:数据绑定后判断是否是右键打开模块赋值 + /// 创建人:王一帆 + /// 创建日期:2020-03-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnInitializeHeaderCallBack(object sender, EventArgs e) + { + // 通过右键菜单打开单据时,判断修改还是新增 + if (!string.IsNullOrEmpty(this.SysModel.BillOrderNo)) + { + // 修改 + string sqlValue = "select * from " + this.BillModel.MasterTable + " where 1=1"; + string sqlCond = string.Format(" and {0}='{1}'", this.BillModel.PrimaryKey, this.SysModel.BillOrderNo); + DataTable masterTable = BillImpl.GetDataTableResult(sqlValue + sqlCond); + + this.SetBillStatus(masterTable.Rows.Count > 0 ? masterTable.Rows[0] : null); + } + else + { + this.SetBillStatus(null); + // 新增 + if (!string.IsNullOrEmpty(this.SysModel.BillMasterSql)) + { + // 处理单据表头数据 + DataRow row = BillImpl.GetDataRowResult(this.SysModel.BillMasterSql); + if (row != null) + { + if (row.Table.Columns.Contains(this.BillModel.RtagidKey)) + { + string Rtagid = row[this.BillModel.RtagidKey] + ""; + // 初始化红、蓝单 + if (Rtagid.Equals("0")) + { + this.rdBlue.Checked = true; + this.rdRed.Checked = false; + this.lbTitle.ForeColor = Color.Blue; + this.pl_red.Visible = false; + this.pl_blue.Visible = true; + } + else if (Rtagid.Equals("1")) + { + this.rdRed.Checked = true; + this.rdBlue.Checked = false; + this.lbTitle.ForeColor = Color.Red; + this.pl_blue.Visible = false; + this.pl_red.Visible = true; + } + + } + + + this.ControlObj.SetAllControlValue(row);//去掉第二个参数true,参数8进入的sql固定不默认赋值 + // 设置Brp模版 + if (this.IsBrpTemplete || this.BillModel.IsBrp) + { + this.SetTempleteSelectedValue(row["brpId"] + ""); + } + } + } + if (!string.IsNullOrEmpty(this.SysModel.BillMasterSql)) + { + // 处理单据明细数据 + if (!this.SysModel.BillDetailSql.StartsWith("*")) this.AddMultiRowToGridView(BillImpl.GetDataTableResult(this.SysModel.BillDetailSql)); + } + } + } + + private void AddDataColumns() + { + foreach (GridColumn gridColumn in gcMain.GridView.Columns) + { + gridColumn.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left; + } + int dayCount = 0; + BaseUserControl baseUserControl = ControlObj.FindControl("bom_rdm_tianshu"); + if (baseUserControl != null) + { + int.TryParse(baseUserControl.EditText, out dayCount); + } + if (dayCount <= 0) + { + dayCount = 7; + } + if (DateColumnList.Count != dayCount) + { + foreach (GridColumn item in DateColumnList) + { + gcMain.GridView.Columns.Remove(item); + } + gcMain.GridView.Columns.Remove(SumGridColumn); + DateColumnList.Clear(); + for (int i = 0; i < dayCount; i++) + { + GridColumn gridColumn = new GridColumn(); + gridColumn.AppearanceCell.Options.UseTextOptions = true; + gridColumn.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center; + gridColumn.AppearanceHeader.Options.UseTextOptions = true; + gridColumn.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center; + gridColumn.OptionsColumn.AllowMove = false; + gridColumn.OptionsColumn.AllowSize = false; + gridColumn.OptionsFilter.AllowFilter = false; + gridColumn.OptionsColumn.AllowMerge = DefaultBoolean.False; + gridColumn.OptionsColumn.AllowSort = DefaultBoolean.False; + gridColumn.FieldName = $"DDay_{i}"; + gridColumn.Width = 70; + gridColumn.DisplayFormat.FormatType = FormatType.Numeric; + gridColumn.DisplayFormat.FormatString = "{0:#,##0.####}"; + gridColumn.Visible = true; + gridColumn.SummaryItem.SummaryType = SummaryItemType.Sum; + gridColumn.SummaryItem.DisplayFormat = "{0:#,##0.####}"; + gcMain.GridView.Columns.Add(gridColumn); + DateColumnList.Add(gridColumn); + } + GridColumn sumGridColumn = new GridColumn(); + sumGridColumn.AppearanceCell.Options.UseTextOptions = true; + sumGridColumn.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center; + sumGridColumn.AppearanceHeader.Options.UseTextOptions = true; + sumGridColumn.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center; + sumGridColumn.OptionsColumn.AllowEdit = false; + sumGridColumn.OptionsColumn.AllowMove = false; + sumGridColumn.OptionsColumn.AllowSize = false; + sumGridColumn.OptionsFilter.AllowFilter = false; + sumGridColumn.OptionsColumn.AllowMerge = DefaultBoolean.False; + sumGridColumn.OptionsColumn.AllowSort = DefaultBoolean.False; + sumGridColumn.FieldName = $"workingsum"; + sumGridColumn.Caption = $"工时合计"; + sumGridColumn.Width = 70; + sumGridColumn.DisplayFormat.FormatType = FormatType.Numeric; + sumGridColumn.DisplayFormat.FormatString = "{0:#,##0.####}"; + sumGridColumn.Visible = true; + sumGridColumn.SummaryItem.SummaryType = SummaryItemType.Sum; + sumGridColumn.SummaryItem.DisplayFormat = "{0:#,##0.####}"; + SumGridColumn = sumGridColumn; + gcMain.GridView.Columns.Add(sumGridColumn); + } + } + + /// + /// 根据日期修改列状态 + /// + /// + private void UpdateDynamicColumns() + { + DateTime currentDate = DateTime.Now; + BaseUserControl dateUserControl = ControlObj.FindControl("bom_rdm_ksdt"); + if (dateUserControl is LabelDateEdit labelDateEdit) + { + currentDate = labelDateEdit.TextEdit.DateTime; + } + + int dayCount = 0; + BaseUserControl baseUserControl = ControlObj.FindControl("bom_rdm_tianshu"); + if (baseUserControl != null) + { + int.TryParse(baseUserControl.EditText, out dayCount); + } + if (dayCount <= 0) + { + dayCount = 7; + } + + DateTime endDate = currentDate.AddDays(dayCount); // 保持你的原逻辑 + + var view = gcMain.GridView; + view.BeginUpdate(); + try + { + // 1) 更新每个日期列的显示属性,并确保“动态列不固定” + for (int i = 0; i < DateColumnList.Count; i++) + { + GridColumn gridColumn = DateColumnList[i]; + DateTime dateForColumn = currentDate.AddDays(i); + + if (dateForColumn <= endDate) + { + gridColumn.FieldName = dateForColumn.ToString("yyyy-MM-dd"); + gridColumn.Caption = dateForColumn.ToString("MM-dd"); + gridColumn.Visible = true; + gridColumn.Tag = dateForColumn; + + // 关键:动态日期列不要固定,让它参与水平滚动 + gridColumn.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.None; + } + else + { + gridColumn.Visible = false; + } + } + + // 合计列也不要固定(保持可水平滚动) + if (SumGridColumn != null) + SumGridColumn.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.None; + + // 2) 明确“从左到右”的可见顺序 + // 先找到左侧固定列的最大 VisibleIndex,动态列排在它们之后 + int baseIndex = 0; + foreach (GridColumn c in view.Columns) + { + if (c.Visible && c.Fixed == DevExpress.XtraGrid.Columns.FixedStyle.Left) + baseIndex = Math.Max(baseIndex, c.VisibleIndex + 1); + } + + // 起始日期在左,依次向右:start, start+1, ... + int run = 0; + for (int i = 0; i < DateColumnList.Count; i++) + { + var col = DateColumnList[i]; + if (!col.Visible) continue; + col.VisibleIndex = baseIndex + run; + run++; + } + + // 合计列放在日期列最后 + if (SumGridColumn != null && SumGridColumn.Visible) + SumGridColumn.VisibleIndex = baseIndex + run; + } + finally + { + view.EndUpdate(); + } + } + + /// + /// 新增汇总数据(日期修改后) + /// + private void UpdateSummaryData(DataTable table = null) + { + DataTable dataTable = new DataTable(); + if (table != null) + { + dataTable = table; + } + else + { + dataTable = this.gcMain.GridControl.DataSourceTable(); + } + if (dataTable != null && dataTable.Columns.Contains("num")) + { + MultiLineSummary = true; + gcMain.GridView.OptionsView.ShowFooter = true; + DataRow[] dataRows = dataTable.Select("num='999'"); + DataRow dataRow = dataRows != null && dataRows.Length > 0 ? dataRows[0] : null; + gcMain.AddHeadquarters(dataRow); + } + else if (MultiLineSummary) + { + MultiLineSummary = false; + //清空新加的汇总列 + gcMain.AddHeadquarters(); + } + + } + + + /// + /// 说明:表格编辑时,判断是否是否编辑 + /// 创建人:王一帆 + /// 创建日期:2020-03-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnGridViewShowingEditor(object sender, CancelEventArgs e) + { + try + { + GridColumnModel gridColumnModel = null; + DataRow rowItem = null; + if (this.BillModel.DetailTreeTable) + { + DevExpress.XtraTreeList.TreeList treeList = (DevExpress.XtraTreeList.TreeList)sender; + TreeListColumn treeListColumn = treeList.FocusedColumn; + if (treeListColumn.Tag != null) + { + gridColumnModel = (GridColumnModel)treeListColumn.Tag; + } + rowItem = (this.gcMain as TreeGridControlEx).GetViewFocusedDataRow(); + } + else + { + GridView gridView = (GridView)sender; + GridColumn gridColumn = gridView.FocusedColumn; + + if (gridColumn.Tag != null) + { + gridColumnModel = (GridColumnModel)gridColumn.Tag; + + } + rowItem = this.gcMain.GridView.GetDataRow(this.gcMain.GridView.FocusedRowHandle); + } + + + if (gridColumnModel != null && !string.IsNullOrEmpty(gridColumnModel.DisableCond)) + { + //e.Cancel = !ReplaceHelper.EvalCond(ReplaceHelper.ReplaceRowParam(focusedRow, gridColumnModel.DisableCond)); + //e.Cancel = !ValidateCond(gridColumnModel.DisableCond, focusedRow); + string UpdateCond = this.ControlObj.ReplaceParentControlValue(gridColumnModel.DisableCond); + UpdateCond = ReplaceHelper.ReplaceRowParam(rowItem, UpdateCond); + if (!ReplaceHelper.EvalCond(UpdateCond)) + { + e.Cancel = true;//该行不可编辑 + } + } + if (!string.IsNullOrWhiteSpace(BillModel.UpdateDetailCond)) + { + string UpdateCond = this.ControlObj.ReplaceParentControlValue(BillModel.UpdateDetailCond); + UpdateCond = ReplaceHelper.ReplaceRowParam(rowItem, UpdateCond); + if (!ReplaceHelper.EvalCond(UpdateCond)) + { + e.Cancel = true;//该行不可编辑 + } + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + + } + + + } + + /// + /// 虚拟行点击添加 + /// + /// + private void InitNewRowMethod(object sender) + { + GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView; + DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows(); + DataRow tmpRow = gridTable.NewRow(); + gridTable.Rows.Add(tmpRow); + int position = gridTable.Rows.Count - 1; + foreach (DataRow dr in _detailColumns.Rows) + { + GridColumnModel model = new GridColumnModel(dr); + string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue); + + + if (model.DefaultValue.Contains("{#")) + { + fieldValue = this.ControlObj.ReplaceParentControlValue(model.DefaultValue); + if (!string.IsNullOrEmpty(fieldValue)) + { + tmpRow[model.FieldName] = fieldValue; + } + } + else if (!string.IsNullOrEmpty(model.DefaultValue)) + { + if (model.DefaultValue.Contains("{ROW")) + { + if (position > 0) + { + + fieldValue = ReplaceHelper.GetParamFields(model.DefaultValue)[0]; + fieldValue = fieldValue.Replace("}", "").Replace("{", ""); + fieldValue = fieldValue.Substring(fieldValue.IndexOf('_') + 1); + string topFieldValue = gridTable.Rows[position - 1][fieldValue] + ""; + if (gridTable.Columns[model.FieldName].DataType == typeof(DateTime)) + { + if (!string.IsNullOrEmpty(topFieldValue)) tmpRow[model.FieldName] = Convert.ToDateTime(topFieldValue); + } + else + { + tmpRow[model.FieldName] = topFieldValue; + } + } + } + else + { + tmpRow[model.FieldName] = fieldValue; + } + } + } + gridTable.OrderBy(this.BillModel.DetailOrderField); + + if (tmpRow.Table.Columns.Contains(this.BillModel.DetailOrderField) && gridTable.Rows.Count == 0) + { + tmpRow[this.BillModel.DetailOrderField] = 1; + } + + this.gcMain.GridView.UpdateCurrentRow(); + this.gcMain.GridView.ShowEditor(); + } + /// + /// 切换行判断是否是虚拟行数据进行数据填充 + /// + /// + /// + private void GridView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) + { + DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows(); + int _rowNumber = this.gcMain.GridView.FocusedRowHandle; + int _prvFocused = e.PrevFocusedRowHandle; + int indexNumber = this.gcMain.GridView.RowCount; + if (_rowNumber < 0 && _prvFocused != gridTable.Rows.Count) + { + InitNewRowMethod(sender); + this.gcMain.GridView.FocusedRowHandle = indexNumber - 1; + } + } + /// + /// 说明:单据重写明细回车事件(用于扫码回车移动至下一行数据) + /// 创建人:王一帆 + /// 创建日期:2021-06-08 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + protected void OnGridViewCellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) + { + if (isDragWrap) + { + int _rowNumber = this.gcMain.GridView.FocusedRowHandle; + GridColumn focusColumn = this.gcMain.GridView.FocusedColumn; + GridColumnModel Columnmodel = focusColumn.Tag as GridColumnModel; + + if (Columnmodel.FieldType == ControlType.LabSacn) + { + this.gcMain.GridView.OptionsNavigation.EnterMoveNextColumn = false; + if (this.BillModel.DefaultAddEmptyRow && _rowNumber + 1 == this.gcMain.GridView.DataRowCount) + { + DataTable gridTable = (this.gcMain.GridView.GridControl.DataSource as DataTable).TrimDeleteRows(); + DataRow tmpRow = gridTable.NewRow(); + gridTable.Rows.Add(tmpRow); + int position = gridTable.Rows.Count - 1; + foreach (DataRow dr in _detailColumns.Rows) + { + GridColumnModel model = new GridColumnModel(dr); + string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue); + if (model.DefaultValue.Contains("{#")) + { + fieldValue = this.ControlObj.ReplaceParentControlValue(model.DefaultValue); + if (!string.IsNullOrEmpty(fieldValue)) + { + tmpRow[model.FieldName] = fieldValue; + } + } + else if (!string.IsNullOrEmpty(model.DefaultValue)) + { + if (model.DefaultValue.Contains("{ROW")) + { + if (position > 0) + { + + fieldValue = ReplaceHelper.GetParamFields(model.DefaultValue)[0]; + fieldValue = fieldValue.Replace("}", "").Replace("{", ""); + fieldValue = fieldValue.Substring(fieldValue.IndexOf('_') + 1); + string topFieldValue = gridTable.Rows[position - 1][fieldValue] + ""; + if (gridTable.Columns[model.FieldName].DataType == typeof(DateTime)) + { + if (!string.IsNullOrEmpty(topFieldValue)) tmpRow[model.FieldName] = Convert.ToDateTime(topFieldValue); + } + else + { + tmpRow[model.FieldName] = topFieldValue; + } + } + } + else + { + tmpRow[model.FieldName] = fieldValue; + } + } + } + gridTable.OrderBy(this.BillModel.DetailOrderField); + + if (tmpRow.Table.Columns.Contains(this.BillModel.DetailOrderField) && gridTable.Rows.Count == 0) + { + tmpRow[this.BillModel.DetailOrderField] = 1; + } + + this.gcMain.GridView.UpdateCurrentRow(); + this.gcMain.GridView.ShowEditor(); + } + int ColumnIndex = this.gcMain.GridView.FocusedColumn.VisibleIndex;//焦点列的坐标 + this.gcMain.GridView.FocusedRowHandle = _rowNumber + 1; + this.gcMain.GridView.FocusedColumn.VisibleIndex = ColumnIndex; + //this.gridView.OptionsNavigation.EnterMoveNextColumn = true; + } + else + { + this.gcMain.GridView.OptionsNavigation.EnterMoveNextColumn = true; + } + } + } + + + /// + /// 说明:验证单据是否修改过 + /// 创建人:龚宇超 + /// 创建日期: + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void VerfyBillUpdated() + { + bool isUpdateDetailed = false; + DataTable table = this.gcMain.gridControl.DataSource as DataTable; + if (table != null && table.Rows.Count > 0) + { + DataRow updateRow = table.Rows.Cast().FirstOrDefault(x => x.RowState != DataRowState.Unchanged); + isUpdateDetailed = updateRow != null; + } + if (this.BillRowItem != null && (this.ControlObj.VerifyUpdated() || isUpdateDetailed)) + { + bool isReadOnly2 = !string.IsNullOrEmpty(this.BillModel.ModifyCond) && !ReplaceHelper.ReplaceRowParamCond(this.BillRowItem, this.BillModel.ModifyCond); + if (!isReadOnly2) + { + if (MessageUtil.Show(ResourceKeys.DataChanged, MessageBoxButtons.YesNo) == DialogResult.Yes) + { + this.BillSave(); + } + } + } + } + + /// + /// 说明:初始化单据按钮状态 + /// 创建人:龚宇超 + /// 创建日期:2017-12-04 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// if set to true [is edit]. + private void SetBillStatus(DataRow rowItem) + { + if (this.BillModel.unableToSave.Contains(SysModel.UserName)) + { + this.btnBillSave.Hide(); + foreach (System.Windows.Forms.Control control in pl_main_bottom.Controls) + { + + if (control.Location.X < btnBillSave.Location.X && control is DevExpress.XtraEditors.SimpleButton && control.Name != "btn_input") + { + control.Location = new Point(control.Location.X + btnBillSave.Width, control.Location.Y); + } + } + } + if (rowItem != null) + { + // 单据为修改状态,无需设置赋值时不需要计算面板属性 + bool isReadOnly = !string.IsNullOrEmpty(this.BillModel.ModifyCond) && !ReplaceHelper.ReplaceRowParamCond(rowItem, this.BillModel.ModifyCond); + this.ControlObj.CanExecControl = false; // 单据为修改状态时,无需计算面板属性 + this.lbTitle.Text = this.BillModel.TypeName + updateText; + this.lblOrderNo.Text = rowItem[this.BillModel.PrimaryKey] + ""; + this.rdBlue.Checked = "0".Equals(rowItem[this.BillModel.RtagidKey] + ""); + this.rdRed.Checked = "1".Equals(rowItem[this.BillModel.RtagidKey] + ""); + this.BillModel.SaveState = true; + this.rdBlue.Enabled = this.rdRed.Enabled = false; + this._itemImport.Enabled = this._itemImportUpdate.Enabled = !isReadOnly; + this.ControlObj.SetReadOnlyAllControl(isReadOnly); + this.ControlObj.SetAllControlValue(rowItem); + this.dbpFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = !isReadOnly; + this.ControlObj.CanExecControl = true; + this.cb_input.Enabled = this.btn_input.Enabled = this.txt_input.Enabled = !isReadOnly; + foreach (SimpleButton item in itemCommonList) + { + if (item.Visible == true && item.Tag is DataRow rightRow) + { + string menuCode = rightRow["menuCond"] + ""; + if (!string.IsNullOrEmpty(menuCode)) + { + item.Enabled = ValidateCond(menuCode, rowItem); ; + } + } + } + this.BillRowItem = rowItem; + // 设置Brp模版 + if (this.IsBrpTemplete || this.BillModel.IsBrp) + { + this.SetTempleteSelectedValue(rowItem["brpId"] + ""); + this.cb_templete.Enabled = !isReadOnly; + } + this.BillModel.PopupUnionCode = rdBlue.Checked ? rdBlueUnionCode : rdRedUnionCode; + this.dbpFP.Visible = !string.IsNullOrWhiteSpace(this.BillModel.PopupUnionCode); + this.labelControl1.ForeColor = this.lblOrderNo.ForeColor = this.lbTitle.ForeColor = rdBlue.Checked ? Color.Blue : Color.Red; + this.gcMain.GridView.OptionsBehavior.Editable = !isReadOnly; + // 上一次查询 + int oldRowHandle = this.gcMain.GridView.FocusedRowHandle; + //获取数据源并排序 + DataTable dt = BillImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, this.BillModel.DetailSql)); + if (dt.Columns.Contains(this.BillModel.DetailOrderField)) + { + DataView dataView = dt.AsDataView(); + dataView.Sort = this.BillModel.DetailOrderField; + dt = dataView.ToTable(); + dt.AcceptChanges(); + } + + if (this.BillModel.DetailTreeTable) + { + //判断是否有tap_id和tap_pid + (this.gcMain as TreeGridControlEx).SetGridViewDataSourceGenerateID(dt); + this.gcMain.GridView.SelectRowHandler(oldRowHandle); + } + else + { + this.gcMain.GridControl.DataSource = dt; + this.gcMain.GridView.SelectRowHandler(oldRowHandle); + if (this.BillModel.SelectLast && dt.Rows.Count > 0) + { + this.gcMain.GridView.SelectRowHandler(dt.Rows.Count - 1); + } + } + + + RefreshPrindMenu(); + + BaseUserControl userControl = this.ControlObj.FindControl(this.BillModel.RtagidKey); + if (userControl != null) + { + userControl.EditText = this.rdRed.Checked ? "1" : "0"; + } + } + else + { + // 单据为新增状态 + this.dbpFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = true; + this.lbTitle.Text = this.BillModel.TypeName + addText; + this.lblOrderNo.Text = BillImpl.GetBillNo(this.BillModel.BillSeq); + this._itemImport.Enabled = this._itemImportUpdate.Enabled = true; + this.cb_input.Enabled = this.btn_input.Enabled = this.txt_input.Enabled = true; + this.cb_templete.Enabled = true; + this.BillModel.SaveState = false; + this.ControlObj.SetReadOnlyAllControl(false); + this.rdBlue.Enabled = this.rdRed.Enabled = true; + foreach (SimpleButton item in itemCommonList) + { + if (item.Visible == true && item.Tag is DataRow rightRow) + { + string menuCode = rightRow["menuCond"] + ""; + if (!string.IsNullOrEmpty(menuCode)) + { + item.Enabled = ValidateCond(menuCode, rowItem); ; + } + } + } + + // 通过右键菜单打开单据,假如明细有数据则在初始化时使用传入数据. + if (this.BillModel.DetailTreeTable) + { + (this.gcMain as TreeGridControlEx).TreeListObj.OptionsBehavior.Editable = true; + (this.gcMain as TreeGridControlEx).SetGridViewDataSourceGenerateID(BillImpl.GetDataTableResult(this.BillModel.DetailSql)); + } + else + { + this.gcMain.GridView.OptionsBehavior.Editable = true; + this.gcMain.GridControl.DataSource = BillImpl.GetDataTableResult(this.BillModel.DetailSql); + } + + BaseUserControl userControl = this.ControlObj.FindControl(this.BillModel.RtagidKey); + if (userControl != null) + { + userControl.EditText = this.rdRed.Checked ? "1" : "0"; + } + } + + //设置打印按钮状态 + this.btnPrint.Enabled = this.SetPrintButton(rowItem); + + this._waterMark = new WaterMark(this.BillModel.MasterPreFix, rowItem); + this.lbTitle.Invalidate(); + + } + /// + /// 说明:点击蓝字单据 + /// 创建人:龚宇超 + /// 创建日期:2017-11-23 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnBlueStateClick(object sender, EventArgs e) + { + this.rdRed.Checked = false; + this.labelControl1.ForeColor = this.lblOrderNo.ForeColor = this.lbTitle.ForeColor = Color.Blue; + this.dbpFP.Visible = !string.IsNullOrWhiteSpace(rdBlueUnionCode); + this.BillModel.PopupUnionCode = rdBlueUnionCode; + + BaseUserControl userControl = this.ControlObj.FindControl(this.BillModel.RtagidKey); + if (userControl != null) + { + userControl.EditText = "0"; + } + } + /// + /// 说明:点击红字单据 + /// 创建人:龚宇超 + /// 创建日期:2017-11-23 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnRedStateClick(object sender, EventArgs e) + { + this.rdBlue.Checked = false; + this.labelControl1.ForeColor = this.lblOrderNo.ForeColor = this.lbTitle.ForeColor = Color.Red; + this.dbpFP.Visible = !string.IsNullOrWhiteSpace(rdRedUnionCode); + this.BillModel.PopupUnionCode = rdRedUnionCode; + + BaseUserControl userControl = this.ControlObj.FindControl(this.BillModel.RtagidKey); + if (userControl != null) + { + userControl.EditText = "1"; + } + } + /// + /// 说明:复制表头数据 + /// 创建人:龚宇超 + /// 创建日期:2017-11-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnCopyMasterItemClick(object sender, ItemClickEventArgs e) + { + this.dbpFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = true; + this.lbTitle.Text = this.BillModel.TypeName + addText; + this.lbTitle.Invalidate(); + this.lblOrderNo.Text = BillImpl.GetBillNo(this.BillModel.BillSeq); + this.BillModel.SaveState = false; + this.rdBlue.Enabled = this.rdRed.Enabled = true; + this.cb_input.Enabled = this.btn_input.Enabled = this.txt_input.Enabled = true; + this._itemImport.Enabled = this._itemImportUpdate.Enabled = true; + this.cb_templete.Enabled = true; + this.ControlObj.CopyControlValue(this.BillModel.CancelCopyAssociation); + this.ControlObj.SetReadOnlyAllControl(false); + + if (this.BillModel.DetailTreeTable) + { + ((this.gcMain as TreeGridControlEx).TreeListObj.DataSource as DataTable).Clear(); + (this.gcMain as TreeGridControlEx).TreeListObj.OptionsBehavior.Editable = true; + } + else + { + this.gcMain.GridControl.DataSourceTable().Clear(); + this.gcMain.GridView.OptionsBehavior.Editable = true; + + } + + if (ScanCodeTextEdit != null) ScanCodeTextEdit.Focus(); + this._waterMark = new WaterMark(this.BillModel.MasterPreFix, null); + } + /// + /// 说明:复制整单 + /// 创建人:龚宇超 + /// 创建日期:2017-11-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnCopyAllItemClick(object sender, ItemClickEventArgs e) + { + try + { + WaitForm.ShowForm(ResourceKeys.Handing); + DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows(); + if (this.BillModel.DetailTreeTable) + { + gridTable = ((this.gcMain as TreeGridControlEx).TreeListObj.DataSource as DataTable).TrimDeleteRows(); + } + this.dbpFP.Enabled = this.btnDelete.Enabled = this.btnBillSave.Enabled = this.btnBillApply.Enabled = true; + this.lbTitle.Text = this.BillModel.TypeName + addText; + this.lbTitle.Invalidate(); + this.lblOrderNo.Text = BillImpl.GetBillNo(this.BillModel.BillSeq); + this.rdBlue.Enabled = this.rdRed.Enabled = true; + this.cb_input.Enabled = this.btn_input.Enabled = this.txt_input.Enabled = true; + this._itemImport.Enabled = this._itemImportUpdate.Enabled = true; + this.cb_templete.Enabled = true; + this.ControlObj.CopyControlValue(this.BillModel.CancelCopyAssociation); + this.ControlObj.SetReadOnlyAllControl(false); + this._waterMark = new WaterMark(this.BillModel.MasterPreFix, null); + if (!gridTable.Columns.Contains(ERPInfo.Instance.isAddRows)) + { + gridTable.Columns.Add(ERPInfo.Instance.isAddRows, typeof(String)); + } + // 处理单据明细 + DataTable detailTable = this.gcMain.GridControl.DataSourceTable(); + if (this.BillModel.DetailTreeTable) + { + detailTable = (this.gcMain as TreeGridControlEx).GetGridViewDataSource(); + } + bool canCopy = false; + string defaultValue = string.Empty; + + + if (this.BillModel.DetailTreeTable) + { + if (detailTable.Columns.Contains(this.BillModel.PrimaryDetailKey)) + { + (this.gcMain as TreeGridControlEx).TreeListObj.BeginUpdate(); + foreach (TreeListNode item in (this.gcMain as TreeGridControlEx).TreeListObj.Nodes) + { + //根据后台列配置可否复制 + if (_detailColumns.Columns.Contains("canCopy")) + { + //int index = detailTable.Rows.IndexOf(item); + foreach (DataRow dr in _detailColumns.Rows) + { + canCopy = !string.IsNullOrEmpty(dr["canCopy"] + "") ? "1".Equals(dr["canCopy"] + "") : false; + if (!canCopy) + { + TreeListColumn column = (this.gcMain as TreeGridControlEx).TreeListObj.Columns.ColumnByFieldName(dr["fieldName"] + ""); + //TreeListNode node = treeList.GetNode(rowIndex); + defaultValue = this.ControlObj.ReplaceParentControlValue(dr["defaultdate"] + ""); + defaultValue = BaseImpl.GetDefaultValue(defaultValue); + if (!string.IsNullOrEmpty(defaultValue)) + { + item.SetValue(column, defaultValue); + } + else + { + item.SetValue(column, DBNull.Value); + } + } + } + } + item[this.BillModel.PrimaryDetailKey] = this.lblOrderNo.Text; + } + (this.gcMain as TreeGridControlEx).TreeListObj.EndUpdate(); + } + (this.gcMain as TreeGridControlEx).TreeListObj.OptionsBehavior.Editable = true; + this.BillModel.SaveState = false; + } + else + { + if (detailTable.Columns.Contains(this.BillModel.PrimaryDetailKey)) + { + this.gcMain.GridView.BeginUpdate(); + foreach (DataRow item in detailTable.Rows) + { + //根据后台列配置可否复制 + if (_detailColumns.Columns.Contains("canCopy")) + { + int index = detailTable.Rows.IndexOf(item); + foreach (DataRow dr in _detailColumns.Rows) + { + canCopy = !string.IsNullOrEmpty(dr["canCopy"] + "") ? "1".Equals(dr["canCopy"] + "") : false; + if (!canCopy) + { + GridColumn column = this.gcMain.GridView.Columns.ColumnByFieldName(dr["fieldName"] + ""); + defaultValue = this.ControlObj.ReplaceParentControlValue(dr["defaultdate"] + ""); + defaultValue = BaseImpl.GetDefaultValue(defaultValue); + if (!string.IsNullOrEmpty(defaultValue)) + { + this.gcMain.GridView.SetRowCellValue(index, column, defaultValue); + } + else + { + this.gcMain.GridView.SetRowCellValue(index, column, DBNull.Value); + } + } + } + } + item[this.BillModel.PrimaryDetailKey] = this.lblOrderNo.Text; + } + this.gcMain.GridView.EndUpdate(); + } + this.gcMain.GridView.OptionsBehavior.Editable = true; + this.BillModel.SaveState = false; + } + if (ScanCodeTextEdit != null) ScanCodeTextEdit.Focus(); + + } + catch (Exception ex) + { + + } + finally + { + WaitForm.HideForm(); + } + } + /// + /// 说明:导出Excel + /// 创建人:龚宇超 + /// 创建日期:2017-11-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnExportItemClick(object sender, ItemClickEventArgs e) + { + LogUtil.WriteDebug(this.SysModel.ModuleCode, "导出数据", this.SysModel.FormText, "单据明细导出", this.SysModel.ModuleId + ""); + + + if (this.BillModel.DetailTreeTable) + { + (this.gcMain as TreeGridControlEx).TreeListObj.ToTreeExcel(this.SysModel.FormText); + } + else + { + this.gcMain.GridControl.ToExcel(this.SysModel.FormText); + } + + + } + /// + /// 说明:从Excel导入 + /// 创建人:龚宇超 + /// 创建日期:2017-11-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnImportItemClick(object sender, ItemClickEventArgs e) + { + OpenFileDialog dialog = new OpenFileDialog(); + dialog.Title = "选择导入文件"; + //dialog.Filter = "Excel文件(*.xls)|*.xls"; + dialog.Filter = SystemInfo.Instance.IsXlsxFirst ? "Excel文件(*.xlsx)|*.xlsx|Excel文件(*.xls)|*.xls" : + "Excel文件(*.xls)|*.xls|Excel文件(*.xlsx)|*.xlsx"; + + DialogResult result = dialog.ShowDialog(); + if (result == DialogResult.OK) + { + string fileName = dialog.FileName; + string colFields = this.gcMain.GridView.Columns.ToString(','); + + if (this.BillModel.DetailTreeTable) + { + DataTable DataImportTable = (this.gcMain as TreeGridControlEx).TreeListObj.ToExcelTreeDataTable(fileName, colFields, true, true); + DataTable NewTable = (this.gcMain as TreeGridControlEx).GetGridViewDataSource(); + TreeListColumnCollection gridColumns = (this.gcMain as TreeGridControlEx).TreeListObj.Columns; + //父节点名称 + string ParentFieldName = (this.gcMain as TreeGridControlEx).TreeListObj.ParentFieldName; + //节点名称 + string KeyFieldName = (this.gcMain as TreeGridControlEx).TreeListObj.KeyFieldName; + + if (!DataImportTable.Columns.Contains(ParentFieldName)) DataImportTable.Columns.Add(ParentFieldName); + if (!DataImportTable.Columns.Contains(KeyFieldName)) DataImportTable.Columns.Add(KeyFieldName); + + AddRowsToTreeGridControl(DataImportTable, null); + } + else + { + DataTable DataImportTable = this.gcMain.GridView.ToExcelDataTable(fileName, colFields, true, true); + DataTable NewTable = this.gcMain.GridControl.DataSourceTable(); + GridColumnCollection gridColumns = this.gcMain.GridView.Columns; + foreach (DataRow rowItem in DataImportTable.Rows) + { + DataRow newRow = NewTable.NewRow(); + foreach (GridColumn col in gridColumns) + { + if ("id".Equals(col.FieldName) || col.FieldName.Equals(this.BillModel.PrimaryKey)) 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 (model.DefaultValue.Contains("{#")) + { + fieldValue = this.ControlObj.ReplaceParentControlValue(model.DefaultValue); + + } + if (!string.IsNullOrEmpty(fieldValue)) + { + newRow[col.FieldName] = fieldValue; + } + } + } + NewTable.Rows.Add(newRow); + } + this.gcMain.GridControl.DataSource = NewTable; + } + + + } + } + /// + /// 说明:导入Excel文件(更新) + /// 创建人:龚宇超 + /// 创建日期:2017-11-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnImportUpdateItemClick(object sender, ItemClickEventArgs e) + { + + } + + /// + /// 说明:验证可操作条件 + /// 创建人:龚宇超 + /// 创建日期:2018-03-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnToolsClick(object sender, EventArgs e) + { + foreach (BarItemLink itemLink in pMenu.ItemLinks) + { + DataRow rowItem = itemLink.Item.Tag as DataRow; + if (rowItem != null) + { + string menuCond = rowItem["MenuCond"] + ""; + string menuCaption = itemLink.Caption; + + if (!string.IsNullOrEmpty(menuCond)) + { + try + { + bool result = true; + menuCond = ReplaceHelper.ReplaceParamToValue(menuCond, "{" + this.BillModel.PrimaryKey + "}", this.lblOrderNo.Text.Trim()); + + if (menuCond.StartsWith("@") || menuCond.StartsWith("!")) + { + result = "1".Equals(BaseImpl.GetDefaultValue(menuCond)); + } + else + { + menuCond = this.ControlObj.ReplaceControlValue(menuCond); + if (this.BillRowItem != null) + menuCond = ReplaceHelper.ReplaceRowParam(this.BillRowItem, menuCond); + menuCond = ReplaceHelper.ReplaceParamToValue(menuCond, "0"); // 未替换的参数所有替换为0 + + result = ReplaceHelper.EvalCond(menuCond); + } + itemLink.Item.Enabled = result; + } + catch (Exception ex) + { + MessageUtil.Show("[" + menuCaption + "] " + ResourceKeys.SetRightMenuCondFault); + LogHelper.Instance.WriteError(ex); + } + } + } + } + } + /// + /// 说明:常用工具点击 + /// 创建人:龚宇超 + /// 创建日期:2017-11-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnCommonItemClick(object sender, ItemClickEventArgs e) + { + DataRow rowItem = e.Item.Tag as DataRow; + + CommonMenu menu = new CommonMenu(this.SysModel, this.ControlObj, null); + menu.ApplyBefore += new CommonToolApplyEventHandler(OnMenuApplyBefore); + menu.DynamicLinkAfter += new CommonToolAfterDynamicLinkEventHandler(OnDynamicLinkAfter); + menu.Apply(rowItem); + } + /// + /// 说明:执行前单独替换BilldocumentId + /// 创建人:龚宇超 + /// 创建日期:2018-03-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The e. + protected void OnMenuApplyBefore(ApplyArgs e) + { + string[] paramList = new string[e.MemuModel.ParamList.Count]; + + for (int i = 0; i < e.MemuModel.ParamList.Count; i++) + { + string item = e.MemuModel.ParamList[i]; + List condition = ReplaceHelper.GetParamFields(item); + foreach (string cond in condition) + { + string value = this.BillModel.PrimaryKey.Equals(cond.Replace("{", "").Replace("}", "").ToLower(), StringComparison.OrdinalIgnoreCase) ? this.lblOrderNo.Text.Trim() : cond; + item = item.Replace(cond, value); ; + } + paramList[i] = item; + } + e.MemuModel.ParamList = paramList.ToList(); + } + /// + /// 动态链接库执行完成后 + /// + /// + protected void OnDynamicLinkAfter(object sender, ApplyArgs e) + { + try + { + if (!string.IsNullOrWhiteSpace(e.MemuModel.ResultSQL)) + { + string resultSql = e.MemuModel.ResultSQL; + if (e.DialogModel != null && e.DialogModel.DialogDllName.Equals("lskj.pubadd.dll", StringComparison.OrdinalIgnoreCase) && e.DialogModel.PubDialogType == DialogType.PubAddRecord) + { + if (e.DialogModel.ReturnTag != null && e.DialogModel.ReturnTag is MyControl) + { + MyControl addControlObj = e.DialogModel.ReturnTag as MyControl; + resultSql = addControlObj.ReplaceControlValue(resultSql); + } + resultSql = this.ControlObj.ReplaceControlValue(resultSql); + DataTable dataTable = MainImpl.GetDataTableResult(resultSql); + foreach (DataRow item in dataTable.Rows) + { + this.AddRowToGridView(item); + } + } + else + { + resultSql = this.ControlObj.ReplaceControlValue(resultSql); + DataTable dataTable = MainImpl.GetDataTableResult(resultSql); + foreach (DataRow item in dataTable.Rows) + { + this.AddRowToGridView(item, false); + } + } + } + if (e.DialogModel != null && e.DialogModel.DialogDllName.Equals("Lskj.PubBomImport.dll", StringComparison.OrdinalIgnoreCase)) + { + if (e.DialogModel.ReturnTag != null && e.DialogModel.ReturnTag is BomImpRtnModel impRtnModel) + { + if (impRtnModel.ShowType.Equals("1") || impRtnModel.ShowType.Equals("2") || impRtnModel.ShowType.Equals("3") || impRtnModel.ShowType.Equals("5") || impRtnModel.ShowType.Equals("6") || impRtnModel.ShowType.Equals("7") || impRtnModel.ShowType.Equals("8") || impRtnModel.ShowType.Equals("9"))//执行保存 + { + CommonMenu menu = (CommonMenu)sender; + menu.issuccess = impRtnModel.CanSave; + } + else if (impRtnModel.ShowType.Equals("0") || impRtnModel.ShowType.Equals("00") || impRtnModel.ShowType.Equals("000"))//返回文件 + { + ControlModel controlModel = ControlObj.ControlModels.Where(n => n.LabelText.Equals("物料编码")).FirstOrDefault(); + if (controlModel == null) + { + MessageUtil.Show($"物料编码不存在"); + return; + } + string mxProductId = ControlObj.GetControlValue(controlModel); + if (string.IsNullOrEmpty(mxProductId)) + { + MessageUtil.Show($"物料编码必填"); + return; + } + ControlModel modeControlModel = ControlObj.ControlModels.Where(n => n.LabelText.Equals("上传模式")).FirstOrDefault(); + string addMode = ControlObj.GetControlValue(modeControlModel); + if (impRtnModel.ShowType.Equals("1") && string.IsNullOrEmpty(addMode)) + { + MessageUtil.Show($"上传模式必填"); + return; + } + ControlModel sepciesNoControlModel = ControlObj.ControlModels.Where(n => n.LabelText.Equals("文件分类")).FirstOrDefault(); + string sepciesNo = ControlObj.GetControlValue(sepciesNoControlModel); + if ((impRtnModel.ShowType.Equals("1") || impRtnModel.ShowType.Equals("6")) && string.IsNullOrEmpty(sepciesNo)) + { + MessageUtil.Show($"文件分类必填"); + return; + } + ControlModel fileIDControlModel = ControlObj.ControlModels.Where(n => n.LabelText.Equals("文件ID")).FirstOrDefault(); + string fileID = ControlObj.GetControlValue(fileIDControlModel); + ControlModel oldPIDControlModel = ControlObj.ControlModels.Where(n => n.LabelText.Equals("旧编码")).FirstOrDefault(); + string oldPID = ControlObj.GetControlValue(oldPIDControlModel); + DataTable sourceTable = gcMain.gridControl.DataSourceTable(); + if (impRtnModel.ShowType.Equals("000") && sourceTable.Rows.Cast().Where(n => n.RowState != DataRowState.Deleted).Count() > 0) + { + MessageUtil.Show($"只能选择单个文件,请删除后再添加"); + return; + } + if (sourceTable != null && impRtnModel.FileNames != null) + { + string afterBomFieldName = impRtnModel.AfterBomFieldName; + if (!sourceTable.Columns.Contains("BomFieldNameDir")) + { + sourceTable.Columns.Add("BomFieldNameDir"); + } + if (!sourceTable.Columns.Contains("BomFieldNamePath")) + { + sourceTable.Columns.Add("BomFieldNamePath"); + } + if (!sourceTable.Columns.Contains("BomMxMainProduct")) + { + sourceTable.Columns.Add("BomMxMainProduct"); + } + if (!sourceTable.Columns.Contains("BomMxAddState")) + { + sourceTable.Columns.Add("BomMxAddState"); + } + if (!sourceTable.Columns.Contains("qms_laddf_mode")) + { + sourceTable.Columns.Add("qms_laddf_mode"); + } + if (!sourceTable.Columns.Contains("BomAddSpeciesNo")) + { + sourceTable.Columns.Add("BomAddSpeciesNo"); + } + if (!sourceTable.Columns.Contains("BomAddChangeFileId")) + { + sourceTable.Columns.Add("BomAddChangeFileId"); + } + if (!sourceTable.Columns.Contains("BomAddOldProductId")) + { + sourceTable.Columns.Add("BomAddOldProductId"); + } + DataTable dataTable = new DataTable(); + dataTable.Columns.Add(afterBomFieldName); + dataTable.Columns.Add("BomFieldNameDir"); + dataTable.Columns.Add("BomFieldNamePath"); + dataTable.Columns.Add("BomMxMainProduct"); + dataTable.Columns.Add("BomMxAddState"); + dataTable.Columns.Add("qms_laddf_mode"); + dataTable.Columns.Add("BomAddSpeciesNo"); + dataTable.Columns.Add("BomAddChangeFileId"); + dataTable.Columns.Add("BomAddOldProductId"); + IEnumerable rowsIEnumerable = sourceTable.Rows.Cast().Where(n => n.RowState != DataRowState.Deleted); + foreach (string fileName in impRtnModel.FileNames) + { + string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName).Trim(); + //找到code相同的行 + DataRow selectRow = rowsIEnumerable.Where(n => (n[afterBomFieldName] + "").Trim().Equals(fileNameWithoutExtension, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); + if (selectRow != null) + { + //MessageUtil.Show($"{fileNameWithoutExtension}已存在,不允许重复创建"); + continue; + } + //DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid like '{code}%'"); + //if (productRow != null) + //{ + // MessageUtil.Show($"{code}已存在,不允许重复创建"); + // return; + //} + DataRow addRow = dataTable.NewRow(); + addRow[afterBomFieldName] = Path.GetFileName(fileName); + addRow["BomFieldNameDir"] = fileName; + addRow["BomFieldNamePath"] = Path.GetFileName(fileName); + addRow["BomMxMainProduct"] = mxProductId; + addRow["qms_laddf_mode"] = addMode; + addRow["BomAddSpeciesNo"] = sepciesNo; + addRow["BomAddChangeFileId"] = fileID; + addRow["BomAddOldProductId"] = oldPID; + addRow["BomMxAddState"] = this.BillModel.SaveState ? "修改" : "新增"; + dataTable.Rows.Add(addRow); + } + foreach (DataRow item in dataTable.Rows) + { + DataRow sourceRow = this.AddRowToGridView(item, true); + sourceRow["BomFieldNameDir"] = item["BomFieldNameDir"] + ""; + sourceRow["BomFieldNamePath"] = item["BomFieldNamePath"] + ""; + sourceRow["BomMxMainProduct"] = item["BomMxMainProduct"] + ""; + sourceRow["BomMxAddState"] = item["BomMxAddState"] + ""; + sourceRow["qms_laddf_mode"] = item["qms_laddf_mode"] + ""; + sourceRow["BomAddSpeciesNo"] = item["BomAddSpeciesNo"] + ""; + sourceRow["BomAddChangeFileId"] = item["BomAddChangeFileId"] + ""; + sourceRow["BomAddOldProductId"] = item["BomAddOldProductId"] + ""; + } + } + } + } + } + } + catch (Exception) + { + } + } + /// + /// 说明:打印完成需要参数 + /// 创建人:龚宇超 + /// 创建日期:2018-07-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + protected void GetPrintOtherParam() + { + Dictionary dataCaches = SysModel != null ? SysModel.DataCaches : null; + //取得打印完成后的参数 + if (!string.IsNullOrEmpty(this.BillModel.PrintSql) && this.BillModel.PrintSql.Contains("<<")) + { + string[] strs = this.BillModel.PrintSql.Split(new[] { ">>" }, 2, StringSplitOptions.None); + _mainPrintSql = strs[1]; + _printModeCond = strs[0].Replace("<<", ""); + } + if (!string.IsNullOrEmpty(_printModeCond) && _printModeCond.IndexOf(';') > 0) + { + string[] str = _printModeCond.Split(';'); + if (!dataCaches.GetValue(this, "PrintOtherSystemRow", out DataRow item)) + { + item = AttachImpl.GetSystemModule(str[0]); + } + if (item == null) return; + string tableName = item["TableName"] + ""; + string modetype = item["modType"] + ""; + if (!dataCaches.GetValue(this, "PrintOtherColumnPrefix", out string comprefix)) + { + comprefix = BaseImpl.GetColumnPrefix(tableName); + } + if (!dataCaches.GetValue(this, "PrintOtherPrimaryKey", out string primaryKey)) + { + primaryKey = modetype == "1" ? BaseImpl.GetBasePrimaryKey(str[0]) : comprefix + "billdocument_id"; + } + //表名,列前缀,主键字段,主键值,模块编号,主打印Sql + _printSaveParams = new List() { tableName, comprefix, primaryKey, str[1], str[0], _mainPrintSql }; + + //判断是否直接打印 modetype 区别单据和基础档案模块 + if (!dataCaches.GetValue(this, "PrintOtherIsExcPrint", out _isExcPrint)) + { + switch (modetype) + { + case "1": + ModuleModel mode = new ModuleModel(MainImpl.GetSystemdllTab(str[0])); + if (mode != null) _isExcPrint = mode.PrintType == 3; + break; + case "2": + BaseAccraditationModel model = new BaseAccraditationModel(BillAuditImpl.GetPubAuditProperty(str[0])); + if (model != null) _isExcPrint = model.BillPrintType == 3; + break; + } + } + } + } + /// + /// 说明:打印模版 + /// 创建人:龚宇超 + /// 创建日期:2017-11-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnPrintItemClick(object sender, ItemClickEventArgs e) + { + string printFile = e.Item.Tag + ""; + string printPath = PubUtil.PrintFileAbsolutelyPath; + + if (!File.Exists(printPath)) + { + MessageUtil.Show(ResourceKeys.NotFoundPrintFile); + return; + } + + bool isPrint = this.BillModel.SaveState; + if (!isPrint) + { + if (MessageUtil.Show(ResourceKeys.BillNotSavedAndNotPrint, MessageBoxButtons.YesNo) == DialogResult.Yes) + isPrint = this.BillSave(); + } + + if (isPrint) + { + try + { + // 判断是否满足打印条件 + + //DataRow masterRow = BillImpl.GetDataRowResult(this.BillModel.MasterSql.Replace("{" + this.BillModel.PrimaryKey + "}", this.lblOrderNo.Text)); + DataRow masterRow = BillImpl.GetDataRowResult(string.Format("select * from {0} where {1}='{2}'", BillModel.MasterTable, BillModel.PrimaryKey, this.lblOrderNo.Text)); + if (masterRow == null) + { + MessageUtil.Show(ResourceKeys.DataNotFount); + return; + } + + if (!ReplaceHelper.ReplaceRowParamCond(masterRow, this.BillModel.PrintCond)) + { + MessageUtil.Show(ResourceKeys.DisSatisfyPrintCond); + return; + } + + string tmpSql = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModel.PrintSql); + string tmpSql1 = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModel.PrintSql1); + string tmpSql2 = ReplaceHelper.ReplaceRowParam(masterRow, this.BillModel.PrintSql2); + + if (printFile.Contains(PrintUtil.TemplateFlag)) + { + //主Sql + string mainSql = string.Empty; + List tmpSqls = new List(); + if (_printSaveParams != null && _printSaveParams.Count > 0) + { + _printSaveParams[5] = mainSql = ReplaceHelper.ReplaceRowParam(masterRow, _mainPrintSql); + _printSaveParams[3] = masterRow.Table.Columns.Contains(_printSaveParams[2] + "") ? masterRow[_printSaveParams[2]] + "" : masterRow[BillModel.PrimaryKey] + ""; + tmpSqls.Add(mainSql); + tmpSqls.Add(tmpSql1); + tmpSqls.AddRange(tmpSql2.Split(';').ToList()); + } + else + { + if (!string.IsNullOrWhiteSpace(tmpSql)) tmpSqls.Add(tmpSql); + if (!string.IsNullOrWhiteSpace(tmpSql1)) tmpSqls.Add(tmpSql1); + if (!string.IsNullOrWhiteSpace(tmpSql2)) tmpSqls.AddRange(tmpSql2.Split(';').ToList()); + } + PrintUtil.OnAfterPrint -= new EventHandler(OnReportPrintAfter); + PrintUtil.OnAfterPrint += new EventHandler(OnReportPrintAfter); + PrintUtil.FastReportPrint(tmpSqls, printFile, _isExcPrint); + } + else + { + DelphiHelper.LoadDelphiDll(printPath, printPath, printFile, tmpSql, tmpSql1, this.BillModel.PrintFileType, tmpSql2); + } + //LogUtil.WriteDebug(this.SysModel.ModuleCode, "打印", "单据打印:" + printFile.Replace(".rmf", "").Replace(".frx", ""), "打印格式:" + printFile); + if (ScanCodeTextEdit != null) ScanCodeTextEdit.Focus(); + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message + "\r\n" + ex.StackTrace); + LogUtil.WriteError(ResourceKeys.BillModule + "打印模板错误", ex); + LogHelper.Instance.WriteError(ex); + } + } + } + + /// + /// 说明:计算列关联字段 + /// 创建人:龚宇超 + /// 创建日期:2017-12-18 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The model. + /// The field value. + protected virtual void SetUnionValue(GridColumnModel model, string fieldValue, DataRow rowItem) + { + DataTable table = this.gcMain.gridControl.DataSourceTable(); + //DataRow rowItem = this.gridView.GetFocusedDataRow(); + string unionValues = model.UnionValues; + if (rowItem != null && model != null) + { + unionValues = ReplaceHelper.ReplaceRowParam(rowItem, unionValues.Replace("{" + model.FieldName + "}", fieldValue)); + if (this.ControlObj != null) + { + unionValues = ControlObj.ReplaceParentControlValue(unionValues); + } + try + { + string[] fields = model.UnionFields.Trim(',').Split(','); + DataRow rowResult = BaseImpl.GetDataRowResult(unionValues); + if (rowResult != null) + { + for (int i = 0; i < fields.Length; i++) + { + string field = fields[i]; + string value = rowResult.Table.Columns.Contains(field) ? rowResult[field] + "" : null; + rowItem[field] = value; + } + } + else + { + // 设置为空 + for (int i = 0; i < fields.Length; i++) + { + string field = fields[i]; + rowItem[field] = DBNull.Value; + } + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("计算列关联字段--错误-->" + unionValues, ex); + } + } + } + /// + /// 说明:禁用控件条件 + /// 创建人:龚宇超 + /// 创建日期:2019-01-22 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The model. + /// The field value. + protected virtual void SetDisableColumn(GridColumnModel model, string fieldValue, DataRow rowItem) + { + if (model.EnableCond != string.Empty) + { + List columns = this.gcMain.ObjmControlList.FindAll(x => x.EnableCond.Contains("{" + model.FieldName + "}")).ToList(); + foreach (GridColumnModel item in columns) + { + try + { + string disableCond = ReplaceHelper.ReplaceRowParam(rowItem, item.EnableCond.Replace("{" + model.FieldName + "}", fieldValue)); + string diaableType = item.DisableType; + if (this.BillModel.DetailTreeTable) + { + (this.gcMain as TreeGridControlEx).TreeListObj.Columns.ColumnByFieldName(model.FieldName).Visible = ("true".Equals(EvalHelper.Eval(ReplaceHelper.ReplaceEvalCond(disableCond)) + "", StringComparison.OrdinalIgnoreCase)); + } + else + { + this.gcMain.GridView.Columns.ColumnByFieldName(model.FieldName).Visible = ("true".Equals(EvalHelper.Eval(ReplaceHelper.ReplaceEvalCond(disableCond)) + "", StringComparison.OrdinalIgnoreCase)); + } + } + catch (Exception) + { + } + } + } + } + /// + /// 说明:计算列计算公式 + /// 创建人:龚宇超 + /// 创建日期:2017-12-18 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The model. + /// The field value. + protected virtual void SetCalcValue(GridColumnModel model, string fieldValue, DataRow rowItem) + { + try + { + DataTable table = this.gcMain.gridControl.DataSourceTable(); + if (rowItem != null && model != null) + { + List calcModels = this.gcMain.ObjmControlList.FindAll(x => !string.IsNullOrEmpty(x.CalcExpr)).OrderBy(y => y.CalcOrder).ToList(); + + foreach (GridColumnModel gridModel in calcModels) + { + // 计算顺序小于当前控件则不计算 + if (gridModel.CalcOrder < model.CalcOrder) continue; + + if (!gridModel.FieldName.Equals(model.FieldName, StringComparison.OrdinalIgnoreCase)) + { + bool isTruncate = false; + string calcExpr = gridModel.CalcExpr; + if (calcExpr.StartsWith("@truncate:")) + { + calcExpr = calcExpr.Substring(10); + isTruncate = true; + } + + try + { + if (this.ControlObj != null) + calcExpr = ControlObj.ReplaceParentControlValue(calcExpr); + + calcExpr = ReplaceHelper.ReplaceRowParam(rowItem, calcExpr); + //EvalHelper.Eval2(ReplaceHelper.ReplaceEvalCond(calcExpr)) + "" + string result = EvalHelper.Eval2(ReplaceHelper.ReplaceEvalCond(calcExpr)) + ""; + if (isTruncate) + { + result += result.Contains(".") ? "0000000000" : ".0000000000"; + rowItem[gridModel.FieldName] = result.Substring(0, result.IndexOf(".")) + result.Substring(result.IndexOf("."), model.Decimals + 1); + //this.gridView.SetRowCellValue(this.gridView.FocusedRowHandle, this.gridView.Columns[gridModel.FieldName], result.Substring(0, result.IndexOf(".")) + result.Substring(result.IndexOf("."), model.Decimals + 1)); + } + else + { + try + { + double d = 0; + if (!string.IsNullOrEmpty(result) && + !"NaN".Equals(result, StringComparison.OrdinalIgnoreCase) && + !"非数字".Equals(result, StringComparison.OrdinalIgnoreCase) && + !"undefined".Equals(result, StringComparison.OrdinalIgnoreCase) && + result != "∞" && result != "-∞" && + !"正无穷大".Equals(result, StringComparison.OrdinalIgnoreCase) && + !"负无穷大".Equals(result, StringComparison.OrdinalIgnoreCase) && + double.TryParse(result, out d)) + { + if (string.IsNullOrEmpty(gridModel.DataFormat)) + { + result = Math.Round(Convert.ToDouble(d), model.Decimals, MidpointRounding.AwayFromZero) + ""; + } + else + { + //计算后先执行保存小数位数 + result = string.Format("{0:" + gridModel.DataFormat + "}", Convert.ToDecimal(result)); + } + if (model.FieldType == 7 && result.Contains('%')) + { + result = (double.Parse(result.Replace("%", "")) * 0.01).ToString(); + } + rowItem[gridModel.FieldName] = result; + // 判断计算列有无关联值 + GridColumnModel UnionModel = calcModels.FirstOrDefault(x => x.FieldName == gridModel.FieldName); + if (!string.IsNullOrEmpty(UnionModel.UnionFields)) + { + this.SetUnionValue(UnionModel, rowItem[gridModel.FieldName] + "", rowItem); + } + //this.gridView.SetRowCellValue(this.gridView.FocusedRowHandle, this.gridView.Columns[gridModel.FieldName], result); + } + } + catch (Exception) + { + + } + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("计算列计算公式--错误-->" + rowItem[gridModel.FieldName], ex); + } + } + } + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + string Message = ErrorMessage.PromptErrorMessage(ex); + // MessageUtil.Show(Message,ex.Message); + } + } + + /// + /// 说明:添加行到单据明细中 + /// 创建人:龚宇超 + /// 创建日期:2017-11-30 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The row item. + /// The union model. + private DataRow AddRowToGridView(DataRow rowItem, bool dataProcessing = true) + { + GridColumnCollection gridColumns = this.gcMain.GridView.Columns; + DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows(); + if (!gridTable.Columns.Contains(ERPInfo.Instance.isAddRows)) + { + gridTable.Columns.Add(ERPInfo.Instance.isAddRows, typeof(String)); + } + string repeatProduct = this.gcMain.GridView.Columns["ProductId"] != null && rowItem.Table.Columns.Contains("ProductId") ? "ProductId" : this.BillModel.DetailPreFix + "ProductId"; + AssociatedField = repeatProduct; + if ("1".Equals(this.BillModel.DetailDoubleClickTip) && rowItem.Table.Columns.Contains(repeatProduct)) + { + + //上面方法无法处理大小写,改成搜索的形式 + DataTable dt = this.gcMain.gridControl.DataSourceTable(); + if (dt != null && dt.Rows.Count > 0 && dt.Columns.Contains(repeatProduct)) + { + DataRow[] drs = dt.Select(repeatProduct + "='" + rowItem[repeatProduct] + "'"); + if (drs.Length >= 1) + { + DialogResult dialog = MessageUtil.Show(ResourceKeys.ProductIsRepet, MessageBoxButtons.YesNo); + if (dialog != DialogResult.Yes) + { + return null; + } + } + } + } + DataRow newRow = gridTable.NewRow(); + //if (gridTable.Columns.Contains(guidField)) + //{ + // newRow[guidField] = Guid.NewGuid().ToString(); + //} + //2024-1-29改成>=,之前为>导致选中第一行只会添加到最后一行(测试空白行没有影响) + int position = this.gcMain.GridView.FocusedRowHandle >= 0 ? gridTable.Rows.Count > 0 ? this.gcMain.GridView.FocusedRowHandle : 0 : gridTable.Rows.Count - 1; + bool isLastRow = this.gcMain.GridView.IsLastVisibleRow; + this.gcMain.GridView.BeginDataUpdate(); + GridView gridView = this.gcMain.GridView; + // 赋值明细字段 + foreach (GridColumn col in gridColumns) + { + try + { + // 未包含字段,则使用控件默认值. + GridColumnModel model = col.Tag as GridColumnModel; + if (model == null) + { + if (rowItem.Table.Columns.Contains(col.FieldName)) + { + // 来源列中是否包含对应字段,包含则使用值 + newRow[col.FieldName] = rowItem[col.FieldName]; + } + continue; + } + if (rowItem.Table.Columns.Contains(col.FieldName)) + { + // 来源列中是否包含对应字段,包含则使用值 + newRow[col.FieldName] = rowItem[col.FieldName]; + if (dataProcessing) + { + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, rowItem[col.FieldName] + "", newRow); + } + SetCalcValue(model, rowItem[col.FieldName] + "", newRow); + } + + } + else + { + + if (col.FieldName.Contains("_Ls")) + { + string[] unioFielName = col.FieldName.Split('_'); + string UnioValue = unioFielName[unioFielName.Length - 1]; + DataColumn grid = rowItem.Table.Columns.Cast().FirstOrDefault(x => x.ColumnName.Split('_')[x.ColumnName.Split('_').Length - 1].Equals(UnioValue)); + if (dataProcessing) + { + if (grid != null && !string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, rowItem[col.FieldName] + "", newRow); + } + SetCalcValue(model, rowItem[col.FieldName] + "", newRow); + } + + } + else + { + string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue); + //int nowPositon = !isLastRow ? position : gridTable.Rows.Count - 1; + + if (model.DefaultValue.Contains("{#")) + { + fieldValue = this.ControlObj.ReplaceParentControlValue(model.DefaultValue); + if (fieldValue.StartsWith("@")) + { + fieldValue = BaseImpl.GetDefaultValue(fieldValue); + } + if (!string.IsNullOrEmpty(fieldValue)) + { + newRow[col.FieldName] = fieldValue; + if (dataProcessing) + { + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, newRow[col.FieldName] + "", newRow); + } + SetCalcValue(model, newRow[col.FieldName] + "", newRow); + } + //计算规则配置在结果字段上,所以无需验证当前操作控件 + //this.gcMain.GridView.SetFocusedRowCellValue(col, fieldValue); + } + } + else if (!string.IsNullOrEmpty(model.DefaultValue)) + { + if (string.IsNullOrEmpty(newRow[col.FieldName] + "") || this.BillModel.DragFixedDefault) + { + newRow[col.FieldName] = fieldValue; + } + if (dataProcessing) + { + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, newRow[col.FieldName] + "", newRow); + } + SetCalcValue(model, newRow[col.FieldName] + "", newRow); + //this.gcMain.GridView.SetFocusedRowCellValue(col, fieldValue); + } + } + } + } + SetDisableColumn(model, newRow[col.FieldName] + "", newRow); + //GridColumnModel model = col.Tag as GridColumnModel; + if (model.LimitLength > 0) + { + DataRow HandleRow = newRow; + int MaxInputLength = System.Text.Encoding.Default.GetBytes(newRow[col.FieldName] + "").Length; + if (model.LimitLength < MaxInputLength) + HandleRow.SetColumnError(HandleRow.Table.Columns[col.ColumnHandle], "当前输入文本超过设定长度!");//满足条件设置错误信息 + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + //LogUtil.WriteError(col.FieldName + "添加出错!", ex); + } + } + this.gcMain.GridView.EndDataUpdate(); + + if (SystemInfo.Instance.BillAddAtTheEnd) isLastRow = true; + + if (!isLastRow) + { + // 插入数据行 + gridTable.Rows.InsertAt(newRow, position + 1); + this.gcMain.GridView.ClearSelection(); + this.gcMain.GridView.SelectRowHandler(position + 1); + } + else + { + // 添加数据行 + gridTable.Rows.Add(newRow); + this.gcMain.GridView.ClearSelection(); + this.gcMain.GridView.SelectRowHandler(gridTable.Rows.Count - 1); + } + + + // 插入数据后 + //if (isLastRow) + //{ + // this.gcMain.GridView.ClearSelection(); + // this.gcMain.GridView.SelectRowHandler(position + 1); + //} + if (!string.IsNullOrEmpty(NumberMc) && gridTable.Columns.Contains(mRecordPrimaryField)) + { + DataRow[] rt = gridTable.Rows.Cast().Where(x => (newRow[BillModel.DetailPreFix + "ProductId"] + "").Equals(x[BillModel.DetailPreFix + "ProductId"] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); + foreach (DataRow item in rt) + { + if (newRow != null) + { + newRow[NumberMc] = Convert.ToDouble(newRow[NumberMc]) - Convert.ToDouble(item[NumberMc]); + } + this.gcMain.OnGridViewCellValueChanged(this.gcMain, new CellValueChangedEventArgs(position + 1, this.gcMain.GridView.Columns[NumberMc], newRow[NumberMc] + "")); + this.gcMain.GridView.UpdateCurrentRow(); + this.gcMain.GridView.ShowEditor(); + if (Convert.ToDouble(newRow[NumberMc] + "") == 0.0) + { + gridTable.Rows.Remove(newRow); + MessageUtil.Show("数量已分配完毕!无需再进行拖拽!"); + } + } + } + gridTable.OrderBy(this.BillModel.DetailOrderField); + this.gcMain.GridView.UpdateCurrentRow(); + this.gcMain.GridView.ShowEditor(); + return newRow; + } + /// + /// 说明:添加多行到单据明细中 + /// 创建人:龚宇超 + /// 创建日期:2017-11-30 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The row item. + /// The union model. + private void AddRowsToGridView(DataTable dataTable, BillSourceUnionModel unionModel) + { + WaitForm.ShowForm(); + GridColumnCollection gridColumns = this.gcMain.GridView.Columns; + DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows().Copy(); + if (!gridTable.Columns.Contains(ERPInfo.Instance.isAddRows)) + { + gridTable.Columns.Add(ERPInfo.Instance.isAddRows, typeof(String)); + } + int position = this.gcMain.GridView.FocusedRowHandle; + bool isLastRow = this.gcMain.GridView.IsLastVisibleRow; + bool onlyOne = true; + foreach (DataRow rowItem in dataTable.Rows) + { + if (unionModel == null || ValidateDetailCond(rowItem, unionModel)) + { + string repeatProduct = this.gcMain.GridView.Columns["ProductId"] != null && dataTable.Columns.Contains("ProductId") ? "ProductId" : this.BillModel.DetailPreFix + "ProductId"; + AssociatedField = repeatProduct; + if ("1".Equals(this.BillModel.DetailDoubleClickTip) && this.gcMain.GridView.Columns[repeatProduct] != null && dataTable.Columns.Contains(repeatProduct)) + { + // 需要提示编码重复 + //GridView view = this.gcMain.GridView; + //bool result = (view.LocateByValue(repeatProduct, rowItem[repeatProduct], null) >= 0) | + // (view.LocateByValue(repeatProduct, rowItem[repeatProduct], null) >= 0) | + // (view.LocateByValue(repeatProduct, rowItem[repeatProduct], null) >= 0) | + // (view.LocateByValue(repeatProduct, rowItem[repeatProduct], null) >= 0); + //if (result) + //{ + // DialogResult dialog = MessageUtil.Show(ResourceKeys.ProductIsRepet, MessageBoxButtons.YesNo); + // if (dialog != DialogResult.Yes) + // return; + //} + + //上面方法无法处理大小写,改成搜索的形式 + DataTable dt = this.gcMain.gridControl.DataSourceTable(); + if (dt != null && dt.Rows.Count > 0 && dt.Columns.Contains(repeatProduct)) + { + DataRow[] drs = dt.Select(repeatProduct + "='" + rowItem[repeatProduct] + "'"); + if (drs.Length >= 1) + { + DialogResult dialog = MessageUtil.Show(ResourceKeys.ProductIsRepet, MessageBoxButtons.YesNo); + if (dialog != DialogResult.Yes) + return; + } + } + + } + + DataRow newRow = gridTable.NewRow(); + newRow.BeginEdit(); + // 赋值明细字段 + foreach (GridColumn col in gridColumns) + { + try + { + GridColumnModel model = col.Tag as GridColumnModel; + if (model == null) continue; + if (dataTable.Columns.Contains(col.FieldName)) + { + // 来源列中是否包含对应字段,包含则使用值 + newRow[col.FieldName] = rowItem[col.FieldName]; + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, rowItem[col.FieldName] + "", newRow); + } + SetCalcValue(model, rowItem[col.FieldName] + "", newRow); + + } + else + { + // 未包含字段,则使用控件默认值. + if (col.FieldName.Contains("_Ls")) + { + string[] unioFielName = col.FieldName.Split('_'); + string UnioValue = unioFielName[unioFielName.Length - 1]; + DataColumn grid = dataTable.Columns.Cast().FirstOrDefault(x => x.ColumnName.Split('_')[x.ColumnName.Split('_').Length - 1].Equals(UnioValue)); + if (grid != null && !string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, rowItem[col.FieldName] + "", newRow); + } + SetCalcValue(model, rowItem[col.FieldName] + "", newRow); + + } + else + { + string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue); + //int nowPositon = !isLastRow ? position : gridTable.Rows.Count - 1; + if (model.DefaultValue.Contains("{#")) + { + fieldValue = this.ControlObj.ReplaceParentControlValue(model.DefaultValue); + if (!string.IsNullOrEmpty(fieldValue)) + { + newRow[col.FieldName] = fieldValue; + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, fieldValue + "", newRow); + } + SetCalcValue(model, fieldValue + "", newRow); + + //计算规则配置在结果字段上,所以无需验证当前操作控件 + //this.gcMain.GridView.SetFocusedRowCellValue(col, fieldValue); + } + } + else if (!string.IsNullOrEmpty(model.DefaultValue)) + { + + if (string.IsNullOrEmpty(newRow[col.FieldName] + "") || this.BillModel.DragFixedDefault) + { + newRow[col.FieldName] = fieldValue; + } + + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, newRow[col.FieldName] + "", newRow); + } + SetCalcValue(model, newRow[col.FieldName] + "", newRow); + + //this.gcMain.GridView.SetFocusedRowCellValue(col, fieldValue); + } + } + } + SetDisableColumn(model, newRow[col.FieldName] + "", newRow); + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + //LogUtil.WriteError(col.FieldName + "添加出错!", ex); + } + } + newRow.EndEdit(); + + if (SystemInfo.Instance.BillAddAtTheEnd) isLastRow = true; + + if (!isLastRow) + { + // 插入数据行 + gridTable.Rows.InsertAt(newRow, position); + //this.gcMain.GridView.ClearSelection(); + //this.gcMain.GridView.SelectRowHandler(position); + } + else + { + // 添加数据行 + gridTable.Rows.Add(newRow); + // this.gcMain.GridView.ClearSelection(); + // this.gcMain.GridView.SelectRowHandler(gridTable.Rows.Count - 1); + } + position++; + //if (isLastRow) + //{ + // this.gcMain.GridView.ClearSelection(); + // this.gcMain.GridView.SelectRowHandler(position + 1); + //} + if (!string.IsNullOrEmpty(NumberMc) && gridTable.Columns.Contains(mRecordPrimaryField)) + { + DataRow[] rt = gridTable.Rows.Cast().Where(x => (newRow[BillModel.DetailPreFix + "ProductId"] + "").Equals(x[BillModel.DetailPreFix + "ProductId"] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); + foreach (DataRow item in rt) + { + if (newRow != null) + { + newRow[NumberMc] = Convert.ToDouble(newRow[NumberMc]) - Convert.ToDouble(item[NumberMc]); + } + this.gcMain.OnGridViewCellValueChanged(this.gcMain, new CellValueChangedEventArgs(position + 1, this.gcMain.GridView.Columns[NumberMc], newRow[NumberMc] + "")); + this.gcMain.GridView.UpdateCurrentRow(); + this.gcMain.GridView.ShowEditor(); + if (Convert.ToDouble(newRow[NumberMc] + "") == 0.0) + { + gridTable.Rows.Remove(newRow); + MessageUtil.Show("数量已分配完毕!无需再进行拖拽!"); + } + } + } + } + else + { + if (onlyOne) + { + onlyOne = false; + if (!string.IsNullOrEmpty(unionModel.ModelObj.DetailEnableMsg)) + { + if (unionModel.ModelObj.DetailEnableMsg.StartsWith("select", StringComparison.OrdinalIgnoreCase) || + unionModel.ModelObj.DetailEnableMsg.StartsWith("exec", StringComparison.OrdinalIgnoreCase)) + { + MessageUtil.Show(BaseImpl.GetResult(unionModel.ModelObj.DetailEnableMsg) + ""); + } + else + { + MessageUtil.Show(unionModel.ModelObj.DetailEnableMsg); + } + } + } + } + } + this.gcMain.GridControl.DataSource = gridTable; + if (position >= 0) + this.gcMain.GridView.SelectRowHandler(position); + else + this.gcMain.GridView.SelectRowHandler(gridTable.Rows.Count - 1); + //this.gcMain.GridView.SelectRowHandler(position); + gridTable.OrderBy(this.BillModel.DetailOrderField); + this.gcMain.GridView.UpdateCurrentRow(); + this.gcMain.GridView.ShowEditor(); + WaitForm.HideForm(); + } + + /// + /// 添加多行数据到单据明细中,禁用所有关联和默认值的获取 + /// + /// + /// + private void AddRowsToGridViewFast(DataRow[] rowItems) + { + try + { + DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows(); + foreach (DataRow rowItem in rowItems) + { + DataRow dataRow = gridTable.NewRow(); + foreach (DataColumn column in gridTable.Columns) + { + if (rowItem.Table.Columns.Contains(column.ColumnName)) + { + dataRow[column] = rowItem[column.ColumnName]; + } + } + gridTable.Rows.Add(dataRow); + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + /// + /// 说明:添加多条数据到单据明细 + /// 创建人:龚宇超 + /// 创建日期:2018-05-30 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The table. + private void AddMultiRowToGridView(DataTable table, BillSourceUnionModel unionModel = null) + { + if (table == null) return; + if (this.BillModel.DetailTreeTable) + { + this.AddRowsToTreeGridControl(table, unionModel); + } + else + { + + if (!this.BillModel.IsFastDragAddDetail) + { + this.AddRowsToGridView(table, unionModel); + } + else + { + // 全部行转数组 + DataRow[] dragRows = table.Select(); + this.AddRowsToGridViewFast(dragRows); + } + + } + + + Application.DoEvents(); + } + /// + /// 说明:是否允许添加明细 + /// 创建人:龚宇超 + /// 创建日期:2018-06-06 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// true if this instance [can add detail row]; otherwise, false. + private bool CanAddDetailRow() + { + // 检测是否正在筛选数据 + if (!string.IsNullOrEmpty(gcMain.GridView.FindFilterText.Trim()) || + !string.IsNullOrEmpty(gcMain.GridView.FilterPanelText.Trim())) + { + if (MessageUtil.Show(ResourceKeys.GridViewSearching, MessageBoxButtons.YesNo) == DialogResult.Yes) + { + this.gcMain.GridView.FindFilterText = ""; + return true; + } + return false; + } + // 检测是否点击了排序表格 + if (this.gcMain.GridView.HasSortColumn()) + { + //if (MessageUtil.Show(ResourceKeys.GridViewColumnSorting, MessageBoxButtons.YesNo) == DialogResult.Yes) + //{ + this.gcMain.GridView.Columns.ClearAllSort(); + // return true; + //} + //return false; + } + // 检测是否为提交或者终审模块 + string text = Business.Impl.LanguageTranslation.Translatable ? Business.Impl.LanguageTranslation.GetTranslatedText("已终审") : "已终审"; + if (_waterMark.Text.Contains(text) && !this.BillModel.BillFinalReviewAdd) + { + MessageUtil.Show(ResourceKeys.AddBillDetailed); + return false; + } + return true; + } + + /// + /// 说明:单据明细撤回操作 + /// 创建人:曹屹峰 + /// 创建日期:2021-11-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void OnToWithdraw(object sender, KeyEventArgs e) + { + if (e.Control && e.KeyCode == Keys.Z) + { + if (ToWithdrawRows.Count < 1) return; + DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows(); + Dictionary undo = ToWithdrawRows[ToWithdrawRows.Count - 1]; + foreach (int key in undo.Keys) + { + DataRow dr = gridTable.NewRow(); + dr.ItemArray = undo[key].ItemArray; + gridTable.Rows.InsertAt(dr, key); + this.gcMain.GridView.ClearSelection(); + this.gcMain.GridView.SelectRowHandler(key); + } + gridTable.OrderBy(this.BillModel.DetailOrderField); + ToWithdrawRows.RemoveAt(ToWithdrawRows.Count - 1); + } + if (e.Alt) + { + GridView gridView = sender as GridView; + if (gridView == null) return; + if (e.KeyCode == Keys.Up) + { + DataTable dtTable = gcMain.gridControl.DataSource as DataTable; + if (gridView.FocusedRowHandle > 0 && dtTable.Columns.Contains(this.BillModel.DetailOrderField)) + { + dtTable = SwapRow(gridView.FocusedRowHandle, gridView.FocusedRowHandle - 1, dtTable); + dtTable.OrderBy(this.BillModel.DetailOrderField); + //DataTableOrderBy(dtTable); + } + } + else if (e.KeyCode == Keys.Down) + { + DataTable dtTable = gcMain.gridControl.DataSource as DataTable; + if (gridView.FocusedRowHandle < dtTable.Rows.Count - 1 && dtTable.Columns.Contains(this.BillModel.DetailOrderField)) + { + dtTable = SwapRow(gridView.FocusedRowHandle, gridView.FocusedRowHandle + 1, dtTable); + dtTable.OrderBy(this.BillModel.DetailOrderField); + //DataTableOrderBy(dtTable); + } + } + } + } + private DataTable SwapRow(int index1, int index2, DataTable dt) + { + DataRow dr = dt.NewRow(); + dr.ItemArray = dt.Rows[index1].ItemArray; + dt.Rows[index1].ItemArray = dt.Rows[index2].ItemArray; + dt.Rows[index2].ItemArray = dr.ItemArray; + return dt; + } + private void DataTableOrderBy(DataTable dtTable) + { + try + { + if (dtTable.Columns.Contains(this.BillModel.DetailOrderField)) + { + for (int i = 0; i < dtTable.Rows.Count; i++) + { + DataRow row = dtTable.Rows[i]; + if (row.RowState != DataRowState.Deleted) + { + row[this.BillModel.DetailOrderField] = (i + 1); + } + } + } + } + catch (Exception) + { + } + } + + /// + /// 说明: + /// 创建人:龚宇超 + /// 创建日期:2017-11-30 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// true if XXXX, false otherwise. + private bool ValidateDetailCond(DataRow rowItem, BillSourceUnionModel unionModel) + { + bool validate = false; + + try + { + string detailCond = ReplaceHelper.ReplaceRowParam(rowItem, unionModel.ModelObj.DetailEnableCond); + detailCond = detailCond.ToLower();//2025-09-08 赵坤表示条件全部转成小写判断。 来源明细中不能配置单元格类型(不能配置 复选框条件 {xxx}=0 ),只能写{xxx}='Ture'。这种bit类型容易忘记大小的情况 + if (detailCond.Contains("#")) + { + List condition = ReplaceHelper.GetParamFields(detailCond); + foreach (string item in condition) + { + string fieldValue = this.ControlObj.GetControlValue(item.Replace("{#", "").Replace("}", "")); + detailCond = detailCond.Replace(item, fieldValue); + } + } + if (detailCond.StartsWith("@") || detailCond.StartsWith("!")) + { + validate = "1".Equals(BaseImpl.GetDefaultValue(detailCond)); + } + else + { + + validate = ReplaceHelper.EvalCond(detailCond); + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteLog(ex.StackTrace); + LogUtil.WriteError("验证多条添加条件出错!", ex); + //MessageUtil.Show(ResourceKeys.CondtionError + "\r\n" + unionModel.ModelObj.DetailEnableCond); + } + return validate; + } + /// + /// 说明:获取添加表头数据 + /// 创建人:龚宇超 + /// 创建日期:2017-12-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The parmary value. + /// System.String. + private string GetAddRecord(ref string parmaryValue) + { + if (BillModel.NewVer == 0 || BillModel.SaveVerifyBillNo) + { + // 检查当前的单据号是否已被占用. + string newBillNo = BillImpl.GetBillNo(this.BillModel.BillSeq); + + if (!parmaryValue.Equals(newBillNo)) + { + if (MessageUtil.Show(ResourceKeys.BillRecordRepeat, MessageBoxButtons.YesNo) == DialogResult.No) + { + return string.Empty; + } + else + { + this.lblOrderNo.Text = newBillNo; + parmaryValue = newBillNo; + } + } + } + + StringBuilder fieldBuilder = new StringBuilder(); + StringBuilder valueBuilder = new StringBuilder(); + + //DataTable DetailedProperties = BaseImpl.GetDataTableResult(string.Format("select COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name = '{0}'", BillModel.MasterTable)); + DataTable DetailedProperties = MainImpl.GetDatabaseProperty(BillModel.MasterTable); + + string errorMessage = string.Empty;//数据不符合数据库规范的信息 + foreach (ControlModel model in this.ControlObj.ControlModels) + { + if (!model.IsSave || + model.FieldName.Equals(BillModel.PrimaryKey, StringComparison.OrdinalIgnoreCase) || + model.FieldName.Equals(BillModel.RtagidKey, StringComparison.OrdinalIgnoreCase) || + model.FieldType == ControlType.LabPic || + model.FieldType == ControlType.LabPicEx || + model.FieldType == ControlType.LabPrompt) + continue; + + if (string.IsNullOrWhiteSpace(model.FieldName)) continue; + + string fieldValue = this.ControlObj.GetControlValue(model); + if (SystemInfo.Instance.TrimWhiteSpace) + fieldValue = fieldValue.Trim(); + if (fieldValue == "****") continue; + + errorMessage = errorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(DetailedProperties, model, fieldValue); + if (string.IsNullOrEmpty(fieldValue) && model.Isintordecimal) fieldValue = "0";//数值保存时为空的话默认保存为0; + + fieldBuilder.Append(model.FieldName + ","); + valueBuilder.Append(string.IsNullOrEmpty(fieldValue) ? this.ControlObj.GetNullValue(model) : string.Format("N'{0}',", fieldValue)); + + + + } + if (!string.IsNullOrWhiteSpace(errorMessage)) SaveErrorMessage = "表头错误:" + errorMessage; + // 增加主键 + fieldBuilder.Append(BillModel.PrimaryKey); + valueBuilder.Append("N'" + parmaryValue + "'"); + // 增加红蓝字单标记 + fieldBuilder.Append("," + BillModel.RtagidKey); + valueBuilder.Append(",N'" + (rdRed.Checked ? 1 : 0) + "'"); + + return string.Format("insert into {0}({1}) values ({2})", BillModel.MasterTable, fieldBuilder.ToString().TrimEnd(','), valueBuilder.ToString().TrimEnd(',')); + } + /// + /// 说明:获取修改表头数据 + /// 创建人:龚宇超 + /// 创建日期:2017-12-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// 单据值. + /// System.String. + private string GetUpdateRecord(string parmaryValue) + { + StringBuilder updateBuilder = new StringBuilder(); + + + //DataTable DetailedProperties = BaseImpl.GetDataTableResult(string.Format("select COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name = '{0}'", BillModel.MasterTable)); + DataTable DetailedProperties = MainImpl.GetDatabaseProperty(BillModel.MasterTable); + + string errorMessage = string.Empty;//数据不符合数据库规范的信息 + // 修改单据 + foreach (ControlModel model in this.ControlObj.ControlModels) + { + if (!model.IsSave || + model.FieldName.Equals(BillModel.RtagidKey, StringComparison.OrdinalIgnoreCase) || + model.FieldType == ControlType.LabPic || + model.FieldType == ControlType.LabPicEx || + model.FieldType == ControlType.LabPrompt) + continue; + + if (string.IsNullOrWhiteSpace(model.FieldName)) continue; + + BaseUserControl userControl = this.ControlObj.FindControl(model); + if (userControl != null) + { + string fieldValue = this.ControlObj.GetControlValue(model); + if (SystemInfo.Instance.TrimWhiteSpace) + fieldValue = fieldValue.Trim(); + if (fieldValue == "****") continue; + + errorMessage = errorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(DetailedProperties, model, fieldValue); + if (string.IsNullOrEmpty(fieldValue) && model.Isintordecimal) fieldValue = "0";//数值保存时为空的话默认保存为0; + + updateBuilder.Append(string.IsNullOrEmpty(fieldValue) ? string.Format("{0}={1}", model.FieldName, this.ControlObj.GetNullValue(model)) : string.Format("{0}=N'{1}',", model.FieldName, fieldValue.Contains("'") ? fieldValue.Replace("'", "''") : fieldValue)); + + } + + } + if (!string.IsNullOrWhiteSpace(errorMessage)) SaveErrorMessage = "表头错误:" + errorMessage; + return string.Format("update {0} set {1} where {2}='{3}'", BillModel.MasterTable, updateBuilder.ToString().TrimEnd(','), BillModel.PrimaryKey, parmaryValue); + } + + /// + /// 说明:获取保存明细数据 + /// 创建人:龚宇超 + /// 创建日期:2017-12-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// System.String. + private StringBuilder GetDetailRecord(string guid, string billNo, List addRowList) + { + // 构造明细 + StringBuilder detailBuilder = new StringBuilder(); + DataTable detailTable = this.gcMain.GridControl.DataSourceTable().TrimDeleteRows(); + if (this.BillModel.DetailTreeTable) + { + detailTable = ((this.gcMain as TreeGridControlEx).TreeListObj.DataSource as DataTable).TrimDeleteRows(); + } + + //string Autogrowcolumn = SqlHelper.ExecuteScalar(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", BillModel.DetailTable)) + ""; ;//自增长列 + //DataTable DetailedProperties = BaseImpl.GetDataTableResult(string.Format("select COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name = '{0}'", BillModel.DetailTable + "_temp"));//单据明细性表 + + string Autogrowcolumn = MainImpl.GetAutogrowcolumn(BillModel.DetailTable); + DataTable DetailedProperties = MainImpl.GetDatabaseProperty(BillModel.DetailTable + "_temp");//单据明细性表 + + //主键 + //DataTable primaryKeydt = BaseImpl.GetDataTableResult(string.Format("SELECT TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME='{0}'", BillModel.DetailTable)); + //string primaryKey = string.Empty; + //bool AddPrimaryKey = false; + //if (primaryKeydt.Rows.Count > 0) + //{ + // primaryKey = primaryKeydt.Rows[0]["COLUMN_NAME"] + ""; + //} + //if (!string.IsNullOrWhiteSpace(primaryKey)) + //{ + // DataTable dt = this.gcMain.gridControl.DataSource as DataTable; + // if (dt.Columns.Contains(primaryKey)) + // { + // AddPrimaryKey = true; + // } + //} + + if (detailTable.Rows.Count > 0) + { + int lineNumber = 1; + DataTable BillColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", BillModel.DetailTable)); + DataTable BillTempColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", BillModel.DetailTable + "_temp")); + foreach (DataRow dataRow in detailTable.Rows) + { + string errorMessage = string.Empty;//数据不符合数据库规范的信息 + StringBuilder fields = new StringBuilder(); + StringBuilder values = new StringBuilder(); + string detailSql = @"insert into " + BillModel.DetailTable + "_temp" + "({0}) values({1});"; + fields.Append("sysstr,"); + values.Append("'" + guid + "',"); + + foreach (DataColumn item in BillColumns.Columns) + { + //GridColumn col = this.gcMain.GridView.VisibleColumns.OfType().FirstOrDefault(x => x.FieldName == item.ColumnName); + //if (col == null) + //{ + // continue; + //} + if (item.ColumnName.Equals(guidField) || item.ColumnName.Equals(mRecordPrimaryField) || item.ColumnName.Equals(ERPInfo.Instance.isAddRows)) continue; + if (!BillTempColumns.Columns.Contains(item.ColumnName)) + { + string type = "varchar(100)"; + if (item.DataType == typeof(DateTime)) + { + type = "datetime"; + } + BaseImpl.ExecSqlValue(string.Format("alter table {0} add {1} {2}", BillModel.DetailTable + "_temp", item.ColumnName, type)); + } + + if (this.BillModel.DetailTreeTable) + { + TreeListColumn[] TreeListColumns = (this.gcMain as TreeGridControlEx).TreeListObj.Columns.Cast().Where(x => x.FieldName.Equals(item.Caption, StringComparison.OrdinalIgnoreCase)).ToArray(); + if (TreeListColumns.Count() == 0 && item.Caption.Equals(BillModel.PrimaryDetailKey)) + { + string primaryValues = dataRow[BillModel.PrimaryDetailKey] + ""; + if (!string.IsNullOrWhiteSpace(primaryValues)) + { + fields.Append(item.ColumnName + ","); + values.Append("N'" + primaryValues.Replace("'", "''") + "',"); + } + } + if (TreeListColumns.Count() == 0) continue; + } + else + { + GridColumn[] gridColumns = gcMain.GridView.Columns.Cast().Where(x => x.FieldName.Equals(item.Caption, StringComparison.OrdinalIgnoreCase)).ToArray(); + + if (gridColumns.Count() == 0 && item.Caption.Equals(BillModel.PrimaryDetailKey)) + { + string primaryValues = dataRow[BillModel.PrimaryDetailKey] + ""; + if (!string.IsNullOrWhiteSpace(primaryValues)) + { + fields.Append(item.ColumnName + ","); + values.Append("N'" + primaryValues.Replace("'", "''") + "',"); + } + } + if (gridColumns.Count() == 0) continue; + } + + + fields.Append(item.ColumnName + ","); + string fieldValue = dataRow.Table.Columns.Contains(item.ColumnName) ? dataRow[item.ColumnName] + "" : string.Empty; + if (addRowList != null && addRowList.Contains(dataRow) && Autogrowcolumn.Equals(item.ColumnName)) + { + fieldValue = ""; + }; + //if (SystemInfo.Instance.TrimWhiteSpace) + // fieldValue = fieldValue.Trim(); + if (item.ColumnName.Equals(BillModel.PrimaryDetailKey, StringComparison.OrdinalIgnoreCase)) + fieldValue = billNo; + if (!string.IsNullOrWhiteSpace(fieldValue)) + { + values.Append(item.DataType == typeof(DateTime) ? "'" + Convert.ToDateTime(fieldValue).ToString("yyyy-MM-dd HH:mm:ss") + "'," : fieldValue.Contains("'") ? "N'" + fieldValue.Replace("'", "''") + "'," : "N'" + fieldValue + "',"); + } + else + { + if (item.DataType == typeof(Decimal) || + item.DataType == typeof(Double) || + item.DataType == typeof(Int16) || + item.DataType == typeof(Int32) || + item.DataType == typeof(Int64)) + values.Append("0,"); + else if (item.DataType == typeof(DateTime)) + { + values.Append("NULL,"); + } + else + { + values.Append("'',"); + + } + + } + errorMessage = errorMessage + DatabaseFormatJudgment.SaveOrModifyBalidation(_detailColumns, DetailedProperties, dataRow, item, fieldValue); + + //SaveErrorMessage = SaveErrorMessage +(string.IsNullOrWhiteSpace(DatabaseFormatJudgment.SaveOrModifyBalidation(_detailColumns, DetailedProperties, dataRow, item, fieldValue))?"":); + } + + + + detailBuilder.AppendFormat(detailSql, fields.ToString().Trim(','), values.ToString().Trim(',')); + if (!string.IsNullOrWhiteSpace(errorMessage)) errorMessage = "第" + lineNumber + "行:" + errorMessage; + SaveErrorMessage = SaveErrorMessage + errorMessage; + lineNumber++; + } + } + return detailBuilder; + } + /// + /// 说明:保存单据 + /// 创建人:龚宇超 + /// 创建日期:2018-04-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// 是否继续执行(0.1). + /// 是否显示成功提示信息 + /// true if XXXX, false otherwise. + private bool BillSave(int comfirm = 0, bool canTipMsg = true) + { + bool saveResult = false; + if (this.ControlObj.VerifyNull()) + { + //保存前执行某个右键 + if (!string.IsNullOrEmpty(BillModel.BeforeBillSaveExec)) + { + DataRow menuRow = BaseModuleImpl.GetBaseGridRightMenuById(BillModel.BeforeBillSaveExec); + if (menuRow != null) + { + DataTable table = gcMain.gridControl.DataSourceTable(); + ControlModel modeControlModel = ControlObj.ControlModels.Where(n => n.LabelText.Equals("上传模式")).FirstOrDefault(); + string addMode = ControlObj.GetControlValue(modeControlModel); + if (modeControlModel != null && table.Columns.Contains("qms_laddf_mode")) + { + foreach (DataRow item in table.Rows) + { + item["qms_laddf_mode"] = addMode; + } + } + ControlModel speciesNoControlModel = ControlObj.ControlModels.Where(n => n.LabelText.Equals("文件分类")).FirstOrDefault(); + string speciesNo = ControlObj.GetControlValue(speciesNoControlModel); + if (speciesNoControlModel != null && table.Columns.Contains("BomAddSpeciesNo")) + { + foreach (DataRow item in table.Rows) + { + item["BomAddSpeciesNo"] = speciesNo; + } + } + CommonMenu menu = new CommonMenu(this.SysModel, this.ControlObj, this.gcMain); + menu.ApplyBefore += new CommonToolApplyEventHandler(OnMenuApplyBefore); + menu.DynamicLinkAfter += new CommonToolAfterDynamicLinkEventHandler(OnDynamicLinkAfter); + StaticControl.RightMenuGridView = gcMain.GridView; + StaticControl.Comprefix = this.BillModel.DetailPreFix; + StaticControl.RightMenuMyControl = ControlObj; + menu.Apply(menuRow); + if (!menu.issuccess) + { + return false; + } + } + } + //记录表格状态 + List addRowList = new List(); + DataTable sourceTable = gcMain.GridControl.DataSourceTable(); + foreach (DataRow dataRow in sourceTable.Rows) + { + if (dataRow.RowState == DataRowState.Added) + { + addRowList.Add(dataRow); + } + } + // 保存之前先进行表格更新 + if (this.BillModel.DetailTreeTable) + { + (this.gcMain as TreeGridControlEx).TreeListObj.PostEditor(); + //(this.gcMain as TreeGridControlEx).TreeListObj.UpdateCurrentRow(); + } + else + { + this.gcMain.GridView.PostEditor(); + this.gcMain.GridView.UpdateCurrentRow(); + } + //虚构一个保存存储过程 + DataTable tvp = new DataTable(); + //更新前进行数据源筛选 + if (DateColumnList.Count > 0) + { + // 创建临时表 + tvp.Columns.Add("lblOrderNo", typeof(string)); // 固定主键 + tvp.Columns.Add("billdocument_id", typeof(string)); // 固定主键 + tvp.Columns.Add("showday", typeof(string)); + tvp.Columns.Add("amount", typeof(decimal)); + + // 获取主数据源 + DataTable mainDataSource = gcMain.GridControl.DataSourceTable(); + if (mainDataSource.Columns.Contains(BillModel.DetailUUIDKey)) + { + // 遍历主数据源 + foreach (DataRow row in mainDataSource.Rows) + { + if (row.RowState == DataRowState.Modified || row.RowState == DataRowState.Added) + { + // 提取 billdocument_id + string key = row[BillModel.DetailUUIDKey].ToString(); + if (!string.IsNullOrEmpty(key)) + { + // 遍历列并处理虚拟列 + foreach (GridColumn col in DateColumnList) + { + // 检查值是否发生变化 + bool isVerifyupd = true; + if (row.RowState == DataRowState.Modified) + { + object originalValue = row[col.FieldName, DataRowVersion.Original]; + object currentValue = row[col.FieldName, DataRowVersion.Current]; + isVerifyupd = !object.Equals(originalValue, currentValue); + } + + if (isVerifyupd) + { + // 解析金额 + decimal newAmount = 0m; + if (row[col.FieldName] != DBNull.Value && !string.IsNullOrWhiteSpace(row[col.FieldName].ToString())) + { + decimal.TryParse(row[col.FieldName].ToString(), out newAmount); + } + // 插入数据到临时表 + DataRow dr = tvp.NewRow(); + dr["billdocument_id"] = key; + dr["showday"] = col.FieldName; //列名如 "2025-03-06" + dr["amount"] = newAmount; + tvp.Rows.Add(dr); + } + } + } + } + } + } + } + try + { + if (this.gcMain.VerifyNull()) + { + if (this.gcMain.RepeatedVerificationNames.Count > 0 && this.gcMain.VerifyDuplicateColumns()) + { + MessageUtil.Show("表格中数据内容重复,保存失败!"); + return saveResult; + } + //if(!VerificationCond()) return saveResult; + + WaitForm.ShowForm(ResourceKeys.DataSaving); + string billNo = this.lblOrderNo.Text.Trim(); + string detailGuid = Guid.NewGuid().ToString(); + + string masterSql = BillModel.SaveState ? GetUpdateRecord(billNo) : GetAddRecord(ref billNo); + string detailSql = GetDetailRecord(detailGuid, billNo, addRowList).ToString(); + // 检查单据头数据合法性 + if (string.IsNullOrEmpty(masterSql)) return false; + + // 验证明细合法性 + if (string.IsNullOrEmpty(detailSql) && !this.BillModel.SaveNullDetail) + { + MessageUtil.Show(ResourceKeys.BillDetailIsNotNull); + return false; + } + + + string tipMsg = string.Empty; + int result = BillImpl.BillSave(masterSql, detailSql, BillModel.DetailTable, ref billNo, detailGuid, BillModel.BillSeq, BillModel.SaveState ? 2 : 1, comfirm, out tipMsg, 0, this.BillModel.NewVer); + WaitForm.HideForm(); + switch (result) + { + case 1: + // 保存成功 + if (canTipMsg) MessageUtil.Show(BillModel.TypeName + ResourceKeys.SaveSuccess); + if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.AfterModuleDataChange, this.SysModel.ModuleCode, 0)) + { + ApiHelper apiHelper = new ApiHelper(this.SysModel.ModuleCode, billNo, BillModel.PrimaryKey, BillModel.MasterTable, 0); + switch (BillModel.SaveState) + { + case false: + apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleDataChange, Interface.Api.ActionType.Add);//添加 + break; + case true: + apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleDataChange, Interface.Api.ActionType.Update);//更新 + break; + } + if (!apiHelper.apiHandler.GetApiSuccess(apiHelper.apiHandlerModels) && canTipMsg) + { + MessageUtil.Show(apiHelper.apiResutMsg); + } + } + this.lblOrderNo.Text = billNo; + this.SetBillStatus(BillImpl.GetDataRowResult(string.Format("select * from {0} where {1}='{2}'", BillModel.MasterTable, BillModel.PrimaryKey, billNo))); + saveResult = true; + OnBillChanged(EventArgs.Empty); + RefreshPrindMenu(); + + //保存完成后所有数据源进行拼接执行保存 + if (tvp != null && tvp.Rows.Count > 0) + { + if (gcMain.jhrowitem != null) + { + // 插入数据到临时表 + DataRow dr = tvp.NewRow(); + dr["lblOrderNo"] = billNo; + dr["billdocument_id"] = "计划文件" + gcMain.jhrowitem.ToJsonObject(); + if (DateColumnList.Count > 0 && DateColumnList[0].Tag is DateTime dateTime) + { + dr["showday"] = dateTime.ToString("yyyy-MM-dd"); //日期 + } + tvp.Rows.Add(dr); + + } + foreach (DataRow item in tvp.Rows) + { + item["lblOrderNo"] = billNo; + } + + // 调用存储过程保存变更数据 + string msg; + int ret = SaveDayPlanChanges(tvp, out msg); + if (ret != 1) + { + MessageUtil.Show("保存失败:" + msg); + } + OnGcMainDataSourceChanged(gcMain.GridView, null);//手动刷新日期合计数据源 + } + break; + case 9: + // 继续执行保存 + if (string.IsNullOrWhiteSpace(tipMsg)) tipMsg = "保存单据临时表失败"; + if (MessageUtil.Show(tipMsg, MessageBoxButtons.YesNo) == DialogResult.Yes) + saveResult = this.BillSave(1, canTipMsg); + break; + default: + // 保存失败 + SaveErrorMessage = SaveErrorMessage + "\r\n" + "出错原因:\r\n" + tipMsg; + MessageUtil.Show(BillModel.TypeName + ResourceKeys.SaveFault + "\r\n" + SaveErrorMessage); + SaveErrorMessage = string.Empty; + + if (tipMsg.Contains("ruleid") && false) + { + string ruleid = tipMsg.Split(',')[0].Replace("ruleid", "").Replace("=", "").Trim(); + string sql = string.Format("select * from p_systembusinesslogictab where id = '{0}'", ruleid); + string rulesModid = string.Empty; + string rulesParam = this.ControlObj.ReplaceParentControlValue(ReplaceHelper.ReplaceUserInfo("")); + + } + + if (tipMsg.StartsWith("@") && false) + { + //根据tipMsg中数据找到pMenu中对应的右键 + foreach (BarItemLink itemLink in pMenu.ItemLinks) + { + if (false) + { + ErrorRestriction errorRestriction = new ErrorRestriction(tipMsg, this.SysModel, this.ControlObj, itemLink, this.BillModel, this.lblOrderNo.Text.Trim()); + DialogResult drr = errorRestriction.ShowDialog(); + errorRestriction.Dispose(); + } + } + } + break; + } + } + } + catch (Exception ex) + { + + if (string.IsNullOrWhiteSpace(SaveErrorMessage)) + { + MessageUtil.Show(ex.Message); + } + else + { + MessageUtil.Show("保存单据失败!\r\n" + SaveErrorMessage); + } + SaveErrorMessage = string.Empty; + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("保存单据失败!", ex); + } + finally + { + WaitForm.HideForm(); + } + } + return saveResult; + } + + /// + /// 说明:通过配置条件刷新打印菜单 + /// 创建人:王一帆 + /// 创建日期:2020-04-10 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The hint MSG. + /// true if XXXX, false otherwise. + public void RefreshPrindMenu() + { + if (!string.IsNullOrWhiteSpace(BillModel.BillPrintTag)) + { + pMprint.ClearLinks(); + // 打印模版 + DataRow rowItem = this.gcMain.GridView.GetDataRow(this.gcMain.GridView.FocusedRowHandle); + string BillPrintTag = this.ControlObj.ReplaceParentControlValue(BillModel.BillPrintTag); + BillPrintTag = ReplaceHelper.ReplaceRowParam(rowItem, BillPrintTag); + // BillPrintTag = ReplaceHelper.ReplaceParamToValue(BillPrintTag,this.lblOrderNo.Text.Trim()); + string value = MainImpl.GetResult(ReplaceHelper.ReplaceRowParam(rowItem, BillPrintTag)) + ""; + string[] files = value.Split('|'); + for (int i = 0; i < files.Length; i++) + { + string fileName = files[i]; + if (!string.IsNullOrWhiteSpace(fileName)) + { + BarButtonItem itemPrint = new BarButtonItem(); + int index = i + 1; + itemPrint.Caption = files[i].Replace(".rmf", "").Replace(".frx", ""); + itemPrint.Tag = files[i]; + itemPrint.ItemClick += new ItemClickEventHandler(OnPrintItemClick); + pMprint.AddItem(itemPrint); + } + } + } + } + /// + /// 说明:单据提交 + /// 创建人:龚宇超 + /// 创建日期:2017-12-13 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The hint MSG. + /// true if XXXX, false otherwise. + private void BillApply(string hintMsg, int comfirm = 0) + { + try + { + WaitForm.ShowForm(ResourceKeys.Handing); + string tipMsg = string.Empty; + string billNo = this.lblOrderNo.Text.Trim(); + if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.BeforeModuleAuditStateChange, this.SysModel.ModuleCode, 0)) + { + ApiHelper apiHelper = new ApiHelper(this.SysModel.ModuleCode, billNo, this.BillModel.PrimaryKey, this.BillModel.MasterTable, 0); + apiHelper.OnEvent(Interface.Api.OperateEvent.BeforeModuleAuditStateChange, Interface.Api.ActionType.Submit);//提交 + if (!apiHelper.apiHandler.GetApiSuccess(apiHelper.apiHandlerModels)) + { + MessageUtil.Show(ResourceKeys.ApplyFault + "\r\n" + apiHelper.apiResutMsg); + return; + } + } + int result = BillImpl.BillApply(this.SysModel.ModuleCode, billNo, "", 1, out tipMsg, comfirm); + WaitForm.HideForm(); + switch (result) + { + case 1: + // 提交成功 + if (!this.BillModel.DisableSubmitPrompt) MessageUtil.Show(BillModel.TypeName + ResourceKeys.ApplySuccess); + this.SetBillStatus(BillImpl.GetDataRowResult(string.Format("select * from {0} where {1}='{2}'", BillModel.MasterTable, BillModel.PrimaryKey, billNo))); + OnBillChanged(EventArgs.Empty); + + if (this.BillModel.ApplyRefresh) + { + this.SetBillStatus(null); + this.ControlObj.ResetControlValue(); + } + if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.AfterModuleAuditStateChange, this.SysModel.ModuleCode, 0)) + { + ApiHelper apiHelper = new ApiHelper(this.SysModel.ModuleCode, billNo, this.BillModel.PrimaryKey, this.BillModel.MasterTable, 0); + apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleAuditStateChange, Interface.Api.ActionType.Submit);//提交 + if (!apiHelper.apiHandler.GetApiSuccess(apiHelper.apiHandlerModels)) + { + MessageUtil.Show(apiHelper.apiResutMsg); + } + } + if (BillModel.IsApplyAferAdd || SystemInfo.Instance.BillNewAfterCommit) + { + this.OnBillAddClick(this.btnBillAdd, null); + //this.btnBillAdd.PerformClick(); + } + // 推送消息 + PushHelper push = new PushHelper(billNo, "0", this.SysModel.ModuleCode, "", "", 0); + push.Push_Bill_Oper_Message(); + + break; + case 9: + // 继续执行保存 + if (string.IsNullOrWhiteSpace(tipMsg)) tipMsg = "提交单据失败"; + if (MessageUtil.Show(tipMsg, MessageBoxButtons.YesNo) == DialogResult.Yes) + this.BillApply("", 1); + break; + case 99: + // 继续执行提交 + if (MessageUtil.Show(tipMsg, MessageBoxButtons.YesNo) == DialogResult.Yes) + { + FrmPrompt prompt = new FrmPrompt(tipMsg); + prompt.Size = new Size(300, 200); + + DialogResult dialog = prompt.ShowDialog(); + if (dialog == DialogResult.OK) + { + this.BillApply(prompt.PromptMsg); + } + } + break; + default: + // 提交失败 + MessageUtil.Show(BillModel.TypeName + ResourceKeys.ApplyFault + "\r\n" + tipMsg); + break; + } + } + catch + { + throw; + } + finally + { + WaitForm.HideForm(); + } + } + /// + /// 说明:点击空白界面后需要获取焦点 + /// 创建人:王一帆 + /// 创建日期:2020-09-04 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void OnMainFocusAfter(object sender, EventArgs e) + { + this.pl_main_center_master.Focus(); + } + /// + /// 说明:打印完成后回调 + /// 创建人:龚宇超 + /// 创建日期:2018-07-05 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The e. + private void OnReportPrintAfter(object sender, EventArgs e) + { + //打印完成后添加数据库 + if (_printSaveParams != null && _printSaveParams.Count > 0) + { + int result = BaseModuleImpl.SavePrintRecord(_printSaveParams[0], _printSaveParams[1], _printSaveParams[2], _printSaveParams[3], _printSaveParams[4]); + } + + } + /// + /// 说明: + /// 创建人:龚宇超 + /// 创建日期:2017-11-28 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnFrmMainKeyDown(object sender, KeyEventArgs e) + { + } + + /// + /// 主表数据源改变时 + /// + /// + /// + private void OnGcMainDataSourceChanged(object sender, EventArgs e) + { + if (DateColumnList.Count > 0 && DateColumnList[0].Tag is DateTime dateTime) + { + string billNo = this.lblOrderNo.Text; + this.gcMain.GridControl.DataSourceChanged -= OnGcMainDataSourceChanged; + DataTable dataTable = gcMain.GridControl.DataSource as DataTable; + if (dataTable != null) + { + //DataTable dataMain = dataTable.Copy(); + //string sqlValue = "select * from RD_worktimetab where 1 = 1"; + //sqlValue = $"{sqlValue} and lblOrderNo = '{billNo}' and showday >= '{dateTime.ToString("yyyy-MM-dd")}'"; + //DataTable dataDayPlan = BaseImpl.GetDataTableResult(sqlValue); + //---------- 查询①:渲染表格排程” ---------- + string sqlExcludePlan = "SELECT * FROM RD_worktimetab WHERE 1 = 1"; + sqlExcludePlan += $" AND lblOrderNo = '{billNo}'"; + sqlExcludePlan += $" AND showday >= '{dateTime:yyyy-MM-dd}'"; + sqlExcludePlan += " AND billdocument_id NOT LIKE N'计划文件%'"; + // 获取结果 + DataTable dataNoPlanFile = BaseImpl.GetDataTableResult(sqlExcludePlan); + // ---------- 查询②:只包含“计划文件” ---------- + string sqlIncludePlan = "SELECT billdocument_id FROM RD_worktimetab WHERE 1 = 1"; + sqlIncludePlan += $" AND lblOrderNo = '{billNo}'"; + sqlIncludePlan += $" AND showday >= '{dateTime:yyyy-MM-dd}'"; + sqlIncludePlan += " AND billdocument_id LIKE N'计划文件%'"; + // 获取结果 + DataTable dataOnlyPlanFile = BaseImpl.GetDataTableResult(sqlIncludePlan); + MergeMainDataWithDayPlan(dataTable, dataNoPlanFile, dateTime); + //若存在缓存计划数据则渲染合计 + if (dataOnlyPlanFile.Rows.Count > 0) + { + string jhrowtiemjson = (dataOnlyPlanFile.Rows[0]["billdocument_id"] + "").Replace("计划文件", ""); + try + { + JObject rowObject = JsonConvert.DeserializeObject(jhrowtiemjson); + JArray jArray = new JArray(); + jArray.Add(rowObject); + DataRow jhrowitem = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(jArray)).Rows[0]; + //渲染计划合计 + gcMain.AddHeadquarters(jhrowitem); + } + catch (Exception) + { + } + } + //else + //{ + // gcMain.AddHeadquarters(null); + //} + gcMain.RefreshHeaderColor(); + this.gcMain.GridControl.DataSource = null; + this.gcMain.GridControl.DataSource = dataTable; + } + this.gcMain.GridControl.DataSourceChanged += OnGcMainDataSourceChanged; + } + } + + /// + /// 保存日计划变更数据(批量保存)。 + /// 调用存储过程 usp_MergeDayPlanChanges,将所有变更记录一次性提交到数据库。 + /// 通过 TVP 参数传递数据,同时捕获输出参数 @msg 和返回值。 + /// + /// 包含所有变更记录的 DataTable,必须与 dbo.DayPlanChangeType 定义一致 + /// 输出提示信息,存储过程执行后的返回消息 + /// 存储过程返回值,成功返回 1,失败返回 0 + public int SaveDayPlanChanges(DataTable tvp, out string message) + { + // 创建输出参数 @msg + SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000) + { + Direction = ParameterDirection.Output + }; + // 创建返回值参数 @return + SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int) + { + Direction = ParameterDirection.ReturnValue + }; + // 创建 TVP 参数,名称必须与存储过程参数一致 + SqlParameter tvpParam = new SqlParameter("@DayPlanChanges", SqlDbType.Structured) + { + TypeName = "dbo.DayPlanChangeTVP", + Value = tvp + }; + // 构造参数数组 + SqlParameter[] parameters = new SqlParameter[] { tvpParam, pMsg, returnValue }; + // 执行存储过程,此处调用 ExecuteNonQuery 即可,不需要返回数据集 + // 请确保 DBUtil.ExecuteNonQuery 方法能够传递参数并执行存储过程 + BaseImpl.ExecProcedure("usp_MergeDayPlanChanges2025", parameters); + // 获取输出参数 @msg 中的提示信息 + message = pMsg.Value.ToString(); + // 获取存储过程的返回值 + int result = Convert.ToInt32(returnValue.Value); + return result; + } + + /// + /// 计划明细与主数据合并: + /// 1) 按 起算 7 天动态生成列; + /// 2) 把 dataDayPlan 中对应日期的 amount 值填入主表; + /// 3) 计算行级合计写入 “heji” 列。 + /// + private DataTable MergeMainDataWithDayPlan(DataTable dataMain, DataTable dataDayPlan, DateTime startDate) + { + const string rightPrimaryKey = "billdocument_id"; // dataDayPlan 主键 + const string dateField = "showday"; + const string amountField = "amount"; + string topPrimaryKey = BillModel.DetailUUIDKey; // dataMain 主键 + + int dayCount = 0; + BaseUserControl baseUserControl = ControlObj.FindControl("bom_rdm_tianshu"); + if (baseUserControl != null) + { + int.TryParse(baseUserControl.EditText, out dayCount); + } + if (dayCount <= 0) + { + dayCount = 7; + } + DateTime endDate = startDate.AddDays(dayCount); + + // ---------- 1. 预索引 dataDayPlan:billdocument_id -> List ---------- + var dayPlanMap = new Dictionary>(); + foreach (DataRow row in dataDayPlan.Rows) + { + string billId = row[rightPrimaryKey].ToString(); + if (!dayPlanMap.TryGetValue(billId, out var list)) + { + list = new List(); + dayPlanMap[billId] = list; + } + list.Add(row); + } + + // ---------- 2. 为主表添加日期列和合计列 ---------- + for (DateTime d = startDate; d <= endDate; d = d.AddDays(1)) + { + string colName = d.ToString("yyyy-MM-dd"); + if (!dataMain.Columns.Contains(colName)) + dataMain.Columns.Add(colName, typeof(decimal)); + } + if (!dataMain.Columns.Contains("workingsum")) + dataMain.Columns.Add("workingsum", typeof(decimal)); + + // ---------- 3. 预构建填充映射:主键 -> (日期列名, 金额) ---------- + var dataMap = new Dictionary>(); + foreach (DataRow mainRow in dataMain.Rows) + { + string key = mainRow[topPrimaryKey].ToString(); + var inner = new Dictionary(); + dataMap[key] = inner; + + if (dayPlanMap.TryGetValue(key, out var rows)) + { + foreach (DataRow dayRow in rows) + { + if (dayRow[dateField] == DBNull.Value) continue; + + DateTime d = Convert.ToDateTime(dayRow[dateField]); + if (d < startDate || d > endDate) continue; + + string col = d.ToString("yyyy-MM-dd"); + if (!dataMain.Columns.Contains(col)) continue; + + if (decimal.TryParse(dayRow[amountField]?.ToString(), out decimal amt)) + inner[col] = amt; + } + } + } + + // ---------- 4. 一次性填充并计算行合计 ---------- + foreach (DataRow mainRow in dataMain.Rows) + { + string key = mainRow[topPrimaryKey].ToString(); + decimal rowSum = 0m; + + if (dataMap.TryGetValue(key, out var inner)) + { + foreach (var kv in inner) + { + mainRow[kv.Key] = kv.Value; + rowSum += kv.Value; + } + } + + mainRow["workingsum"] = rowSum; // 行汇总 + } + + return dataMain; + } + + /// + /// 构建带日期的数据源 + /// + /// + /// + /// + /// + private void UpdateRowWithDayPlan(DataRow focusedRow, DataTable dataDayPlan, DateTime startDate) + { + string rightPrimaryKey = "billdocument_id"; + string dateField = "showday"; + string amountField = "amount"; + string topPrimaryKey = BillModel.DetailUUIDKey; + + int dayCount = 0; + BaseUserControl baseUserControl = ControlObj.FindControl("bom_rdm_tianshu"); + if (baseUserControl != null) + { + int.TryParse(baseUserControl.EditText, out dayCount); + } + if (dayCount <= 0) + { + dayCount = 7; + } + + DateTime endDate = startDate.AddDays(dayCount); // 计算结束日期 + // **1. 预索引 dataDayPlan 数据(billdocument_id -> 该 key 相关的所有行)** + Dictionary> dayPlanMap = new Dictionary>(); + foreach (DataRow row in dataDayPlan.Rows) + { + string billId = row[rightPrimaryKey].ToString(); + if (!dayPlanMap.ContainsKey(billId)) + { + dayPlanMap[billId] = new List(); + } + dayPlanMap[billId].Add(row); + } + // **2. 预构建主数据的列** + for (DateTime dt = startDate; dt <= endDate; dt = dt.AddDays(1)) + { + string colName = dt.ToString("yyyy-MM-dd"); + if (!focusedRow.Table.Columns.Contains(colName)) + { + focusedRow.Table.Columns.Add(colName, typeof(decimal)); // 确保列存在 + } + } + // **3. 预构建数据填充映射表** + Dictionary> dataMap = new Dictionary>(); + string key = focusedRow[topPrimaryKey].ToString(); + if (!dataMap.ContainsKey(key)) + { + dataMap[key] = new Dictionary(); + } + // **查找 key 关联的时间数据** + if (dayPlanMap.ContainsKey(key)) + { + foreach (DataRow dayRow in dayPlanMap[key]) + { + if (dayRow[dateField] != DBNull.Value) + { + DateTime dayValue = Convert.ToDateTime(dayRow[dateField]); + string colName = dayValue.ToString("yyyy-MM-dd"); + if (dayValue >= startDate && dayValue <= endDate && focusedRow.Table.Columns.Contains(colName)) + { + decimal.TryParse(dayRow[amountField] + "", out decimal amountValue); + dataMap[key][colName] = amountValue; + } + } + } + } + // **4. 一次性填充 DataTable(避免逐行赋值带来的性能问题)** + if (dataMap.ContainsKey(key)) + { + foreach (var col in dataMap[key]) + { + focusedRow[col.Key] = col.Value; + } + } + } + + /// + /// 说明:单据空行新增时初始化默认值 + /// 创建人:dl + /// 创建日期:2019-01-29 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + private void OnGridViewInitNewRow(object sender, InitNewRowEventArgs e) + { + GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView; + DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows(); + DataRow tmpRow = view.GetDataRow(e.RowHandle); + GridColumnCollection gridColumns = view.Columns; + //gridTable.Rows.Add(tmpRow); + int position = gridTable.Rows.Count; + foreach (GridColumn col in gridColumns) + { + GridColumnModel model = col.Tag as GridColumnModel; + if (model == null) + { + continue; + } + string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue); + + if (model.DefaultValue.Contains("{#")) + { + fieldValue = this.ControlObj.ReplaceParentControlValue(model.DefaultValue); + if (!string.IsNullOrEmpty(fieldValue)) + { + tmpRow[col.FieldName] = fieldValue; + view.SetFocusedRowCellValue(col, fieldValue); + } + } + else if (!string.IsNullOrEmpty(model.DefaultValue)) + { + + tmpRow[col.FieldName] = fieldValue; + view.SetFocusedRowCellValue(col, fieldValue); + + if (model.DefaultValue.Contains("{ROW")) + { + if (position > 0) + { + + fieldValue = ReplaceHelper.GetParamFields(model.DefaultValue)[0]; + fieldValue = fieldValue.Replace("}", "").Replace("{", ""); + fieldValue = fieldValue.Substring(fieldValue.IndexOf('_') + 1); + string topFieldValue = gridTable.Rows[position - 1][fieldValue] + ""; + if (gridTable.Columns[model.FieldName].DataType == typeof(DateTime)) + { + if (!string.IsNullOrEmpty(topFieldValue)) + { + tmpRow[model.FieldName] = Convert.ToDateTime(topFieldValue); + view.SetFocusedRowCellValue(col, topFieldValue); + } + } + else + { + tmpRow[model.FieldName] = topFieldValue; + view.SetFocusedRowCellValue(col, topFieldValue); + } + } + } + else + { + tmpRow[model.FieldName] = fieldValue; + view.SetFocusedRowCellValue(col, fieldValue); + } + + } + } + //设置序号 + gridTable.OrderBy(this.BillModel.DetailOrderField, false); + //设置当前行序号 + if (gridTable != null && gridTable.Rows.Count > 0 && !string.IsNullOrEmpty(this.BillModel.DetailOrderField) && gridTable.Columns.Contains(this.BillModel.DetailOrderField)) + { + bool getMaxIndex = int.TryParse(gridTable.Rows.Cast().Max(n => n[this.BillModel.DetailOrderField]) + "", out int maxIndex); + if (getMaxIndex) + { + tmpRow[this.BillModel.DetailOrderField] = maxIndex + 1; + } + } + if (gridTable.Columns.Contains(this.BillModel.DetailOrderField) && gridTable.Rows.Count == 0) + { + tmpRow[this.BillModel.DetailOrderField] = 1; + } + //this.gcMain.GridView.UpdateCurrentRow(); + //this.gcMain.GridView.ShowEditor(); + } + /// + /// 说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新 + /// 创建人:龚宇超 + /// 创建日期:2017-11-02 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + private void OnGridViewRightCallBack(object sender, EventArgs e) + { + string billNo = this.lblOrderNo.Text.Trim(); + this.SetBillStatus(BillImpl.GetDataRowResult(string.Format("select * from {0} where {1}='{2}'", BillModel.MasterTable, BillModel.PrimaryKey, billNo))); + } + /// + /// 说明:重绘单据水印 + /// 创建人:龚宇超 + /// 创建日期:2017-12-04 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnLabelTitlePaint(object sender, PaintEventArgs e) + { + if (this._waterMark != null) + { + GraphicsText graphicsText = new GraphicsText(); + graphicsText.Graphics = e.Graphics; + + // 绘制围绕点旋转的文本 + StringFormat format = new StringFormat(); + format.Alignment = StringAlignment.Center; + format.LineAlignment = StringAlignment.Center; + + // 绘制单据状态文本 + if (!string.IsNullOrEmpty(this._waterMark.Text)) + { + + + if (Business.Impl.LanguageTranslation.Translatable) + { + graphicsText.DrawString(this._waterMark.Text, new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Red), new PointF(50, 21), format, 0f); + // 测量文本实际尺寸(含字体和格式影响) + SizeF textSize = e.Graphics.MeasureString(this._waterMark.Text, new Font("宋体", 12, FontStyle.Bold), new SizeF(float.MaxValue, float.MaxValue), format); + int rectWidth = (int)textSize.Width + 10; + int rectHeight = (int)textSize.Height + 5; + // 文本中心点是(50,21),计算边框左上角坐标(确保边框围绕文本居中) + int rectX = 50 - rectWidth / 2; + int rectY = 21 - rectHeight / 2; + + e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(rectX, rectY, rectWidth, 21)); + } + else + { + graphicsText.DrawString(this._waterMark.Text, new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Red), new PointF(50, 21), format, -15f); + + e.Graphics.TranslateTransform(0, 0); + e.Graphics.RotateTransform(-15f); + e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(14, 20, 55, 21)); + } + + } + + // 绘制打印次数文本 + e.Graphics.ResetTransform(); + if (!string.IsNullOrEmpty(this._waterMark.Print)) + { + + + if (Business.Impl.LanguageTranslation.Translatable) + { + graphicsText.DrawString(this._waterMark.Print, new Font("宋体", 11, FontStyle.Bold), new SolidBrush(Color.Red), new PointF((this.lbTitle.Width - 70), 21), format, 0f); + // 测量文本实际尺寸(含字体和格式影响) + SizeF textSize = e.Graphics.MeasureString(this._waterMark.Print, new Font("宋体", 11, FontStyle.Bold), new SizeF(float.MaxValue, float.MaxValue), format); + int rectWidth = (int)textSize.Width + 10; + int rectHeight = (int)textSize.Height + 5; + // 文本中心点是(this.lbTitle.Width - 70,21),计算边框左上角坐标(确保边框围绕文本居中) + int rectX = (this.lbTitle.Width - 70) - rectWidth / 2; + int rectY = 21 - rectHeight / 2; + + e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(rectX, rectY, rectWidth, 21)); + } + else + { + graphicsText.DrawString(this._waterMark.Print, new Font("宋体", 11, FontStyle.Bold), new SolidBrush(Color.Red), new PointF((this.lbTitle.Width - 70), 21), format, -15f); + e.Graphics.TranslateTransform(this.lbTitle.Width - 70, 21); + e.Graphics.RotateTransform(-15f); + e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(-35, -14, 70, 21)); + } + + } + + // 绘制收款文本 + e.Graphics.ResetTransform(); + if (!string.IsNullOrEmpty(this._waterMark.Collect)) + { + + + if (Business.Impl.LanguageTranslation.Translatable) + { + graphicsText.DrawString(this._waterMark.Collect, new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Red), new PointF((this.lbTitle.Width - 170), 21), format, 0f); + // 测量文本实际尺寸(含字体和格式影响) + SizeF textSize = e.Graphics.MeasureString(this._waterMark.Collect, new Font("宋体", 12, FontStyle.Bold), new SizeF(float.MaxValue, float.MaxValue), format); + int rectWidth = (int)textSize.Width + 10; + int rectHeight = (int)textSize.Height + 5; + // 文本中心点是(this.lbTitle.Width - 170,21),计算边框左上角坐标(确保边框围绕文本居中) + int rectX = (this.lbTitle.Width - 170) - rectWidth / 2; + int rectY = 21 - rectHeight / 2; + + e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(rectX, rectY, rectWidth, 21)); + } + else + { + graphicsText.DrawString(this._waterMark.Collect, new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Red), new PointF((this.lbTitle.Width - 170), 21), format, -15f); + + e.Graphics.TranslateTransform(this.lbTitle.Width - 100, 21); + e.Graphics.RotateTransform(-15f); + e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(-100, -32, 55, 21)); + } + + + } + } + } + /// + /// 说明:新增单据 + /// 创建人:龚宇超 + /// 创建日期:2017-12-14 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnBillAddClick(object sender, EventArgs e) + { + if (!this.BillModel.SaveState && this.gcMain.DataRowCount() > 0) + { + DialogResult result = MessageUtil.Show(("数据未保存,是否确定新建单据?"), MessageBoxButtons.YesNo); + if (result == DialogResult.Yes) + { + this.SetBillStatus(null); + this.ControlObj.ResetControlValue(this.BillModel.ManuallyTriggerCorrelation, true); + } + } + else + { + this.SetBillStatus(null); + this.ControlObj.ResetControlValue(this.BillModel.ManuallyTriggerCorrelation, true); + } + if (ScanCodeTextEdit != null) ScanCodeTextEdit.Focus(); + } + + /// + /// 关闭时判断是否存在为保存新增单据 + /// + /// + public bool closeTheJudgment() + { + //if(this.ControlObj.VerifyUpdated()) + if (!this.BillModel.SaveState && this.gcMain.DataRowCount() > 0) + { + return true; + } + return false; + + } + + + /// + /// 说明:删除明细记录 + /// 创建人:龚宇超 + /// 创建日期:2017-12-05 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnDeleteClick(object sender, EventArgs e) + { + try + { + //树表格删除 + if (this.BillModel.DetailTreeTable) + { + string deleteCond = this.ControlObj.ReplaceParentControlValue(BillModel.DeleteDetailCond); + (this.gcMain as TreeGridControlEx).DeleteSelectedRows(deleteCond); + return; + } + + + + int[] rows = this.gcMain.GridView.GetSelectedRows(); + if (rows.Length < 1) + return; + + DataTable dt = this.gcMain.GridView.GetGridViewFilteredAndSortedDataToDataTable(); + + + if (string.IsNullOrEmpty(BillModel.DeleteDetailCond)) + { + DialogResult result = MessageUtil.Show(string.Format(ResourceKeys.DeleteRows, rows.Length), MessageBoxButtons.YesNo); + if (result == DialogResult.Yes) + { + //保存删除的行和对应的行号 + //撤销多次 + Dictionary undo = new Dictionary(); + for (int i = 0; i < rows.Length; i++) + { + DataRow rowItem = this.gcMain.GridView.GetDataRow(rows[i]); + DataRow dr = dt.NewRow(); + dr.ItemArray = rowItem.ItemArray; + undo.Add(rows[i], dr); + } + ToWithdrawRows.Add(undo); + this.gcMain.GridView.Columns.ClearAllSort(); + this.gcMain.GridView.DeleteSelectedRows(); + this.gcMain.GridView.ClearSelection(); + this.gcMain.GridView.SelectRow(this.gcMain.GridView.FocusedRowHandle); + this.gcMain.GridControl.DataSourceTable().OrderBy(this.BillModel.DetailOrderField); + } + } + else + { + string successMsg = string.Empty, faultMsg = string.Empty; + string deleteCond = this.ControlObj.ReplaceParentControlValue(BillModel.DeleteDetailCond); + List deleteRows = new List(); + List faultInts = new List(); + //ToWithdrawRows.Clear();//清空上一次记录的删除行 + Dictionary undo = new Dictionary(); + + foreach (int rowIndex in rows) + { + DataRow rowItem = this.gcMain.GridView.GetDataRow(rowIndex); + + string deleteCond2 = ReplaceHelper.ReplaceRowParam(rowItem, deleteCond); + + if (ReplaceHelper.EvalCond(deleteCond2)) + { + deleteRows.Add(rowItem); + DataRow dr = dt.NewRow(); + dr.ItemArray = rowItem.ItemArray; + undo.Add(rowIndex, dr); + + } + else + { + faultInts.Add(rowIndex); + } + } + ToWithdrawRows.Add(undo); + DataTable table = this.gcMain.GridControl.DataSourceTable(); + foreach (DataRow item in deleteRows) + { + table.Rows.Remove(item); + } + + if (faultInts != null && faultInts.Count > 0) + { + MessageUtil.Show("发现如下:" + string.Join(",", faultInts.ToArray()) + "行不满足条件无法删除!"); + } + else + { + MessageUtil.Show("删除成功!"); + } + } + if (ScanCodeTextEdit != null) ScanCodeTextEdit.Focus(); + return; + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + } + + } + + + + /// + /// 说明:单据保存 + /// 创建人:龚宇超 + /// 创建日期:2017-12-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnBillSaveClick(object sender, EventArgs e) + { + try + { + if (this.BillSave()) + { + ToWithdrawRows.Clear(); + } + if (ScanCodeTextEdit != null) ScanCodeTextEdit.Focus(); + } + catch (Exception ex) + { + MessageUtil.Show(ex); + } + } + /// + /// 说明:单据保存提交 + /// 创建人:龚宇超 + /// 创建日期:2017-12-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnBillApplyClick(object sender, EventArgs e) + { + try + { + DialogResult result = MessageUtil.Show(ResourceKeys.BillApply, MessageBoxButtons.YesNo); + if (result == DialogResult.Yes) + { + if (this.BillSave(0, false)) + { + ToWithdrawRows.Clear(); + this.BillApply(""); + } + } + if (ScanCodeTextEdit != null) ScanCodeTextEdit.Focus(); + return; + } + catch (Exception ex) + { + MessageUtil.Show(ex); + } + + } + /// + /// 说明:帮助文档 + /// 创建人:龚宇超 + /// 创建日期:2020-01-15 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + private void OnHelpClick(object sender, EventArgs e) + { + WebBrowserUtil.StartWebBrowser(this.SysModel.ModuleCode, this.BillModel.TypeName); + } + + /// + /// 说明:分配明细 + /// 创建人:龚宇超 + /// 创建日期:2020-01-15 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnBtnFPOldClick(object sender, EventArgs e) + { + this.gcMain.GridView.PostEditor(); + FPOld(); + } + private void OnBtnFPNewClick(object sender, EventArgs e) + { + this.gcMain.GridView.PostEditor(); + FPNew(); + } + + /// + /// 新版分配 + /// + private void FPNew(int rowHandle = 0) + { + try + { + this.gcMain.GridView.FocusedRowHandle = rowHandle; + DataTable table = this.gcMain.GridControl.DataSource as DataTable; + if (!table.Columns.Contains(guidField)) + { + table.Columns.Add(guidField, typeof(string)); + } + string[] args = { this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode, this.SysModel.ModuleId + "", this.BillModel.PopupUnionCode, "1000" }; + DynamicBaseSelectModel baseModel = new DynamicBaseSelectModel(args); + using (FrmBaseSelectBatch frmSelect = new FrmBaseSelectBatch(baseModel, this.ControlObj, this.gcMain)) + { + frmSelect.Text = this.BillModel.TypeName; + frmSelect.InitControl(); + frmSelect.OnAfterFPCallback += OnAfterFPCallback; + DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow(); + if (rowItem == null) + { + return; + } + rowItem[guidField] = Guid.NewGuid().ToString(); + if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField)) + { + // 检查数据是否为分配后的行 + if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "")) + { + if (this.gcMain.GridView.FocusedRowHandle + 1 <= this.gcMain.GridView.RowCount - 1) + { + int focusedRowHandle = this.gcMain.GridView.FocusedRowHandle + 1; + this.gcMain.GridView.FocusedRowHandle = focusedRowHandle; + if (this.gcMain.GridView.FocusedRowHandle == focusedRowHandle) + { + FPNew(focusedRowHandle); + } + else + { + MessageUtil.Show("全部分配完毕"); + } + } + return; + } + } + if (!string.IsNullOrEmpty(mRecordPrimaryField)) + { + frmSelect.FpRows = table.Rows.Cast().Where(x => (rowItem[guidField] + "").Equals(x[guidField] + "")).ToArray(); + if (frmSelect.FpRows != null && frmSelect.FpRows.Length > 0) + { + List rows = frmSelect.FpRows.ToList(); + rows.Remove(rowItem); + frmSelect.FpRows = rows.ToArray(); + } + if (table.Columns.Contains(mRecordPrimaryField)) + { + frmSelect.FpOtherRows = table.Rows.Cast().Where(x => !(rowItem[guidField] + "").Equals(x[guidField] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); + } + } + frmSelect.InitData(rowItem); + frmSelect.OnBtnFPClick(null, null); + //frmSelect.ShowDialog(); + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + /// + /// 分配完成后回调 + /// + /// + /// + private void OnAfterFPCallback(object sender, EventArgs e) + { + WaitForm.ShowForm(); + try + { + // 临时禁用新增行(空白行) + if (this.BillModel.DefaultAddEmptyRow) this.gcMain.GridView.OptionsView.NewItemRowPosition = NewItemRowPosition.None; + DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow(); + if (rowItem == null) + { + return; + } + DataTable table = this.gcMain.GridControl.DataSource as DataTable; + FrmBaseSelectBatch frmSelect = (FrmBaseSelectBatch)sender; + rowItem[guidField] = Guid.NewGuid().ToString(); + if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField)) + { + // 检查数据是否为分配后的行 + if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "")) + { + if (this.gcMain.GridView.FocusedRowHandle + 1 <= this.gcMain.GridView.RowCount - 1) + { + this.gcMain.GridView.FocusedRowHandle += 1; + OnAfterFPCallback(sender, e); + } + return; + } + } + if (!string.IsNullOrEmpty(mRecordPrimaryField)) + { + frmSelect.FpRows = table.Rows.Cast().Where(x => (rowItem[guidField] + "").Equals(x[guidField] + "")).ToArray(); + if (frmSelect.FpRows != null && frmSelect.FpRows.Length > 0) + { + List rows = frmSelect.FpRows.ToList(); + rows.Remove(rowItem); + frmSelect.FpRows = rows.ToArray(); + } + if (table.Columns.Contains(mRecordPrimaryField)) + { + frmSelect.FpOtherRows = table.Rows.Cast().Where(x => !(rowItem[guidField] + "").Equals(x[guidField] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); + } + } + frmSelect.InitData(rowItem); + bool success = frmSelect.FP(); + if (success) + { + if (frmSelect.SelectedRows != null && frmSelect.SelectedRows.Length > 0) + { + // 增加标识列 + if (!table.Columns.Contains(frmSelect.RecordPrimaryField)) + { + this.mRecordPrimaryField = frmSelect.RecordPrimaryField; + table.Columns.Add(this.mRecordPrimaryField, typeof(String)); + } + foreach (DataRow item in frmSelect.SelectedRows) + { + DataRow newRow = table.NewRow(); + newRow.ItemArray = rowItem.ItemArray; + newRow[guidField] = rowItem[guidField]; + DataColumn IsIdentCol = newRow.Table.Columns.Cast().FirstOrDefault(x => x.ColumnName == BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", BillModel.DetailTable)) + ""); + //自增长列分配按空值取 + if (IsIdentCol != null) + { + if (IsIdentCol.DataType == typeof(Decimal) || + IsIdentCol.DataType == typeof(Double) || + IsIdentCol.DataType == typeof(Int16) || + IsIdentCol.DataType == typeof(Int32) || + IsIdentCol.DataType == typeof(Int64)) + { + newRow[IsIdentCol.ColumnName] = 0; + } + } + foreach (DataColumn col in item.Table.Columns) + { + if (table.Columns.Contains(col.ColumnName)) + { + //newRow[col.ColumnName] = item[col.ColumnName]; + newRow[col.ColumnName] = item[col.ColumnName]; + GridColumn column = this.gcMain.GridView.Columns[col.ColumnName]; + if (column != null) + { + GridColumnModel model = column.Tag as GridColumnModel; + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, rowItem[column.FieldName] + "", newRow); + } + SetCalcValue(model, rowItem[column.FieldName] + "", newRow); + } + } + } + newRow[frmSelect.AmountField] = item[frmSelect.AmountField]; + newRow[frmSelect.RecordPrimaryField] = item[frmSelect.RecordPrimaryField]; + table.Rows.Add(newRow); + } + NumberMc = frmSelect.AmountField; + table.Rows.Remove(rowItem); + // 重排顺序 + table.OrderBy(this.BillModel.DetailOrderField); + this.gcMain.GridView.UpdateCurrentRow(); + this.gcMain.GridView.ShowEditor(); + if (frmSelect.isNextOne) + { + int SourceRowIndex = this.gcMain.GridView.GetFocusedDataSourceRowIndex(); + DataRow[] a = table.Rows.Cast().Where(x => string.IsNullOrEmpty(x[guidField].ToString())).ToArray(); + if (a.Length != 0) + { + this.gcMain.GridView.FocusedRowHandle = SourceRowIndex; + OnAfterFPCallback(sender, e); + } + else + { + MessageUtil.Show("全部分配完毕"); + // frmSelect.SelectRowItem = null; + } + } + } + } + else + { + if (this.gcMain.GridView.FocusedRowHandle + 1 <= this.gcMain.GridView.RowCount - 1) + { + this.gcMain.GridView.FocusedRowHandle += 1; + OnAfterFPCallback(sender, e); + } + else + { + MessageUtil.Show("全部分配完毕"); + } + } + } + catch (Exception) + { + throw; + } + finally + { + // 重新开启新增行(空白行) + if (this.BillModel.DefaultAddEmptyRow) this.gcMain.GridView.OptionsView.NewItemRowPosition = NewItemRowPosition.Bottom; + WaitForm.HideForm(); + } + } + + /// + /// 老版分配 + /// + private void FPOld() + { + try + { + DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow(); + if (rowItem == null) + { + MessageUtil.Show("请先选择一条明细在进行分配!"); + return; + } + DataTable table = this.gcMain.GridControl.DataSource as DataTable; + if (!table.Columns.Contains(guidField)) + { + table.Columns.Add(guidField, typeof(string)); + } + rowItem[guidField] = Guid.NewGuid().ToString(); ; + if (!string.IsNullOrEmpty(mRecordPrimaryField) && table.Columns.Contains(this.mRecordPrimaryField)) + { + // 检查数据是否为分配后的行 + if (!string.IsNullOrEmpty(rowItem[this.mRecordPrimaryField] + "") && !this.BillModel.IgnoreAllocated) + { + MessageUtil.Show("该行数据为已分配后的数据,无需分配!"); + return; + } + } + string[] args = { this.SysModel.FormText, this.SysModel.UserId, this.SysModel.UserName, this.SysModel.Privilege, this.SysModel.ModuleCode, this.SysModel.ModuleId + "", this.BillModel.PopupUnionCode, "1000" }; + DynamicBaseSelectModel baseModel = new DynamicBaseSelectModel(args); + using (FrmBaseSelect frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gcMain)) + { + //if (frmSelect.SelectRowItem == null) + //{ + // frmSelect = new FrmBaseSelect(baseModel, this.ControlObj, this.gcMain); + //} + frmSelect.Text = this.BillModel.TypeName; + frmSelect.SelectRowItem = rowItem; + bool isNextOne = false; + if (!string.IsNullOrEmpty(mRecordPrimaryField)) + { + frmSelect.FpRows = table.Rows.Cast().Where(x => (rowItem[guidField] + "").Equals(x[guidField] + "")).ToArray(); + if (frmSelect.FpRows != null && frmSelect.FpRows.Length > 0) + { + List rows = frmSelect.FpRows.ToList(); + rows.Remove(rowItem); + frmSelect.FpRows = rows.ToArray(); + } + if (table.Columns.Contains(mRecordPrimaryField)) + { + frmSelect.FpOtherRows = table.Rows.Cast().Where(x => !(rowItem[guidField] + "").Equals(x[guidField] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); + } + } + if (frmSelect.ShowDialog() == DialogResult.OK) + { + if (frmSelect.SelectedRows != null && frmSelect.SelectedRows.Length > 0) + { + //if (frmSelect.isNextOne) + //{ + // isNextOne = true; + //} + //else + //{ + // isNextOne = false; + //} + // 增加标识列 + if (!table.Columns.Contains(frmSelect.RecordPrimaryField)) + { + this.mRecordPrimaryField = frmSelect.RecordPrimaryField; + table.Columns.Add(this.mRecordPrimaryField, typeof(String)); + } + + foreach (DataRow item in frmSelect.SelectedRows) + { + DataRow newRow = table.NewRow(); + newRow.ItemArray = rowItem.ItemArray; + newRow[guidField] = rowItem[guidField]; + DataColumn IsIdentCol = newRow.Table.Columns.Cast().FirstOrDefault(x => x.ColumnName == BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", BillModel.DetailTable)) + ""); + //自增长列分配按空值取 + if (IsIdentCol != null) + { + if (IsIdentCol.DataType == typeof(Decimal) || + IsIdentCol.DataType == typeof(Double) || + IsIdentCol.DataType == typeof(Int16) || + IsIdentCol.DataType == typeof(Int32) || + IsIdentCol.DataType == typeof(Int64)) + { + newRow[IsIdentCol.ColumnName] = 0; + } + } + foreach (DataColumn col in item.Table.Columns) + { + if (table.Columns.Contains(col.ColumnName)) + { + //newRow[col.ColumnName] = item[col.ColumnName]; + newRow[col.ColumnName] = item[col.ColumnName]; + GridColumn column = this.gcMain.GridView.Columns[col.ColumnName]; + if (column != null) + { + GridColumnModel model = column.Tag as GridColumnModel; + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, rowItem[column.FieldName] + "", newRow); + } + SetCalcValue(model, rowItem[column.FieldName] + "", newRow); + } + } + } + newRow[frmSelect.AmountField] = item[frmSelect.AmountField]; + newRow[frmSelect.RecordPrimaryField] = item[frmSelect.RecordPrimaryField]; + table.Rows.Add(newRow); + } + NumberMc = frmSelect.AmountField; + //double syAmount = frmSelect.GetSyAmount(); + //if (syAmount > 0) + //{ + // rowItem[frmSelect.AmountField] = frmSelect.GetSyAmount(); + //} + //else + //{ + // table.Rows.Remove(rowItem); + //} + table.Rows.Remove(rowItem); + // 重排顺序 + table.OrderBy(this.BillModel.DetailOrderField); + this.gcMain.GridView.UpdateCurrentRow(); + this.gcMain.GridView.ShowEditor(); + } + } + if (frmSelect.isNextOne) + { + int SourceRowIndex = this.gcMain.GridView.GetFocusedDataSourceRowIndex(); + DataRow[] a = table.Rows.Cast().Where(x => string.IsNullOrEmpty(x[guidField].ToString())).ToArray(); + if (a.Length != 0) + { + this.gcMain.GridView.FocusedRowHandle = SourceRowIndex; + OnBtnFPOldClick(null, null); + } + else + { + MessageUtil.Show("全部分配完毕"); + // frmSelect.SelectRowItem = null; + } + } + } + } + catch (Exception ex) + { + MessageUtil.Show(ex); + } + } + private void cb_templete_QueryCloseUp(object sender, CancelEventArgs e) + { + this.SetTempSelect(true); + } + /// + /// 说明:快速录入明细 + /// 创建人:龚宇超 + /// 创建日期:2019-08-05 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InputGridView() + { + try + { + WaitForm.ShowForm(); + + string inputText = txt_input.Text.Trim(); + ComboBoxEditModel editObj = cb_input.SelectedItem as ComboBoxEditModel; + + if (string.IsNullOrWhiteSpace(inputText)) + { + MessageUtil.Show(ResourceKeys.KeyWordNotNull); + return; + } + if (editObj != null) + { + + DataTable table = BaseImpl.GetDataTableResult(this.ControlObj.ReplaceControlValue(ReplaceHelper.ReplaceSearchControlCond(editObj.SourceModel.CodeInputSql, inputText))); + if (table.Rows.Count == 0) + { + MessageUtil.Show(ResourceKeys.NotFoundKeyWord); + return; + } + else + { + bool onlyPopup = false; + foreach (DataRow rowItem in table.Rows) + { + this.AddRowToGridView(rowItem); + this.AddRowToGridViewByBom(rowItem, editObj.UnionModel, ref onlyPopup); + + } + } + + } + } + catch (Exception ex) + { + MessageUtil.Show(ex); + LogUtil.WriteError("单据快速录入明细出错!", ex); + } + finally + { + WaitForm.HideForm(); + } + } + /// + /// 说明:单据快速录入 + /// 创建人:龚宇超 + /// 创建日期:2018-04-19 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnInputClick(object sender, EventArgs e) + { + this.InputGridView(); + } + /// + /// 说明: + /// 创建人:龚宇超 + /// 创建日期:2019-08-05 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + private void OnInputKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + this.InputGridView(); + this.txt_input.EditValue = ""; + this.txt_input.Focus(); + } + } + private void SetTempSelect(bool isTip) + { + ComboBoxEditModel model = this.cb_templete.SelectedItem as ComboBoxEditModel; + + if (model != null) + { + bool isExec = true; + DataTable detailTable = gcMain.GridControl.DataSourceTable(); + if (detailTable != null && detailTable.Rows.Count > 0 && isTip) + { + DialogResult result = XtraMessageBox.Show("确定要切换模版?\r\n注:切换模版会清空明细数据.", "系统提示", MessageBoxButtons.YesNo); + isExec = result == DialogResult.Yes; + } + if (isExec) + { + if (isExec) + { + string title = model.RowItem["rpname"] + ""; + string brpId = model.RowItem["id"] + ""; + + // 设置标题 + this.Parent.Text = title; + // 清空明细 + detailTable.Clear(); + + // 设置主表固定字段 + LabelTextEdit textEdit = this.ControlObj.FindControl("brpid") as LabelTextEdit; + if (textEdit == null) + { + MessageUtil.Show(ResourceKeys.NotFountBrpID); + return; + } + textEdit.EditText = brpId; + + // 重新设置明细列 + DataTable columns = BillImpl.GetBillDetailBrpColumns(brpId); + if (columns != null && columns.Rows.Count > 0) + gcMain.SetEditColumns(columns); + else + gcMain.GridView.Columns.Clear(); + } + } + } + } + /// + /// 说明:初始化Brp模版 + /// 创建人:龚宇超 + /// 创建日期:2018-04-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void InitializeTemplete() + { + Dictionary dataCaches = SysModel != null ? SysModel.DataCaches : null; + if (!dataCaches.GetValue(this, "BillBrp", out DataTable table)) + { + table = BillImpl.GetBillBrp(this.SysModel.ModuleCode); + } + List tempModels = new List(); + + foreach (DataRow item in table.Rows) + { + ComboBoxEditModel editModel = new ComboBoxEditModel() + { + ValuemMeber = "id", + TextMember = "RpName", + RowItem = item + }; + this.cb_templete.Properties.Items.Add(editModel); + tempModels.Add(editModel); + } + this.cb_templete.Tag = tempModels; + } + /// + /// 说明:设置Brp模版 + /// 创建人:龚宇超 + /// 创建日期:2018-04-23 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void SetTempleteSelectedValue(string id) + { + List tempModels = this.cb_templete.Tag as List; + if (tempModels != null) + { + ComboBoxEditModel model = tempModels.Find(x => id.Equals(x.RowItem[x.ValuemMeber] + "")); + if (model == null) + gcMain.GridView.Columns.Clear(); + else + { + this.cb_templete.SelectedItem = model; + this.SetTempSelect(false); + } + } + } + /// + /// 说明:手动选择模版 + /// 创建人:龚宇超 + /// 创建日期:2018-04-23 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void OnTempleteClick(object sender, EventArgs e) + { + this._isSelectedTemplete = true; + } + /// + /// 说明:单据选中/取消选中数据 + /// 创建人:龚宇超 + /// 创建日期:2020-05-12 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + private void OnGridViewIsCheckClick(object sender, RowCellClickEventArgs e) + { + try + { + DataRow rowItem = (sender as GridView).GetFocusedDataRow(); + if (rowItem != null && e.Column.FieldName == "_check") + { + rowItem["_check"] = "True".Equals(rowItem["_check"] + "") ? 0 : 1; + rowItem.AcceptChanges(); + } + } + catch (Exception) + { + } + } + + + /// + /// 隐藏主表 + /// + /// + /// + private void OnMainTableHiding(object sender, EventArgs e) + { + if (this.pl_main_center_master.Dock == DockStyle.Top) + { + this.pl_main_center_master.Dock = DockStyle.None; + this.btnHiding.Text = "显示主表"; + } + else + { + this.pl_main_center_master.Dock = DockStyle.Top; + this.btnHiding.Text = "隐藏主表"; + } + } + + /// + /// 刷新明细表 + /// + /// + /// + private void btnRefresh_Click(object sender, EventArgs e) + { + try + { + WaitForm.ShowForm(); + //主表明细 + if (this.gcMain is TreeGridControlEx) + { + (this.gcMain as TreeGridControlEx).RefreshDataSource(); + } + else + { + this.gcMain.RefreshDataSource(); + } + + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + finally + { + WaitForm.HideForm(); + } + + } + /// + /// 说明:计算贷方的值 + /// 创建人:曹屹峰 + /// 创建日期:2022-01-19 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void OnGridControlKye(object sender, KeyEventArgs e) + { + try + { + if (!e.KeyData.Equals(Keys.F1)) return; + GridColumn column = this.gcMain.GridView.FocusedColumn; + //if (!string.IsNullOrWhiteSpace(column.View.EditingValue + "")) return; + GridColumnModel model = column.Tag as GridColumnModel; + int[] rows = this.gcMain.GridView.GetSelectedRows(); + if (model.FieldType == 115) + { + if (rows.Length != 1) return; + DataTable dataSource = this.gcMain.gridControl.DataSource as DataTable;//gridView.GetGridViewFilteredAndSortedDataToDataTable(); + GridColumn debit = this.gcMain.GridView.Columns.FirstOrDefault(x => x.Caption.Equals("借方金额")); + GridColumn credit = this.gcMain.GridView.Columns.FirstOrDefault(x => x.Caption.Equals("贷方金额")); + double debitAmount = 0;//借方金额 + double creditAmount = 0;//贷方金额 + foreach (DataRow item in dataSource.Rows) + { + if (!string.IsNullOrWhiteSpace(item[debit.FieldName].ToString())) debitAmount += double.Parse(item[debit.FieldName].ToString()); + if (!string.IsNullOrWhiteSpace(item[credit.FieldName].ToString())) creditAmount += double.Parse(item[credit.FieldName].ToString()); + } + //借方和贷方是否相等 + double differenceAmount = debitAmount - creditAmount; + if (differenceAmount > 0 && column.FieldName.Equals(credit.FieldName)) + { + dataSource.Rows[rows[0]][column.FieldName] = differenceAmount + double.Parse(dataSource.Rows[rows[0]][column.FieldName] + ""); + this.gcMain.GridView.UpdateCurrentRow(); + this.gcMain.GridView.ShowEditor(); + } + if (differenceAmount < 0 && column.FieldName.Equals(debit.FieldName)) + { + dataSource.Rows[rows[0]][column.FieldName] = differenceAmount * -1 + double.Parse(dataSource.Rows[rows[0]][column.FieldName] + ""); + this.gcMain.GridView.UpdateCurrentRow(); + this.gcMain.GridView.ShowEditor(); + } + + SendKeys.Send("{Esc}"); + //e.Handled = true; + + } + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + } + } + + + + /// + /// 重新计算右上角按钮坐标 + /// + private void CalculateCoordinates() + { + List buttons = new List();//没有隐藏的按钮集合 + + //帮助文档按钮 + if (SystemInfo.Instance.HideHelpDocument) + { + this.btnHelp.Visible = false; + } + else + { + buttons.Add(this.btnHelp); + } + //隐藏主表 + if (this.BillModel.HiddenMasterTable) + { + this.btnHiding.Visible = true; + buttons.Add(this.btnHiding); + } + //刷新按钮 + if (SystemInfo.Instance.HideTableRefresh) + { + this.btnRefresh.Visible = false; + } + else + { + buttons.Add(this.btnRefresh); + } + //分配按钮 + buttons.Add(this.dbpFP); + + + //从最后开始计算 + int x = this.dpbTools.Location.X; + //判断是否隐藏常用工具按钮,隐藏的话x为导出导入按钮的坐标 + if (SystemInfo.Instance.HiddenTools) + { + this.dpbTools.Visible = false; + x = this.dpbImport.Location.X; + } + if (buttons.Count != 4) + { + foreach (SimpleButton item in buttons) + { + item.Location = new Point(x - 2 - item.Width, this.dpbTools.Location.Y); + x = x - 2 - item.Width; + } + } + + //设置扫码控件 + if (!string.IsNullOrWhiteSpace(this.BillModel.CodeExecuteSql) && !string.IsNullOrWhiteSpace(this.BillModel.CodeExecuteParameter)) + { + this.pl_input.Controls.Clear(); + this.pl_input.Visible = false; + + LabelControl label = new LabelControl(); + label.Font = new Font("宋体", 12F); + label.Text = "串号扫描"; + label.Top = (pl_main_bottom.Height - label.Height) / 2; + label.Left = 10; + label.Parent = pl_main_bottom; + + this.ScanCodeTextEdit = new TextEdit(); + ScanCodeTextEdit.Height = this.pl_input.Height; + ScanCodeTextEdit.Width = this.pl_input.Width; + ScanCodeTextEdit.Properties.Appearance.Font = new Font("宋体", 10.5F); + ScanCodeTextEdit.Left = label.Width + 15; + ScanCodeTextEdit.Top = (pl_main_bottom.Height - ScanCodeTextEdit.Height) / 2; + ScanCodeTextEdit.BackColor = ColorTranslator.FromHtml("#FFC0CB"); + ScanCodeTextEdit.KeyDown += Text_KeyDown; + ScanCodeTextEdit.Parent = pl_main_bottom; + + } + + + } + + /// + /// 扫码回车事件 + /// + /// + /// + private void Text_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + TextEdit textEdit = sender as TextEdit; + string inputText = textEdit.Text; + if (!string.IsNullOrWhiteSpace(this.BillModel.CodeExecuteSql) && !string.IsNullOrWhiteSpace(this.BillModel.CodeExecuteParameter)) + { + if (inputText.Length > 50) + { + MessageUtil.Show("扫码长度过长,请重新扫码"); + return; + } + + //获取选中行 + DataRow MainRowItem = gcMain.GridView.GetFocusedDataRow(); + if (MainRowItem == null) + { + MainRowItem = gcMain.GridControl.DataSourceTable().NewRow(); + } + //获取红蓝单据 + string DocumentColor = this.rdBlue.Checked ? "0" : this.rdRed.Checked ? "1" : ""; + //数量,默认为1 + int Quantity = 1; + /* + A:弹框输入数量 + B;不弹框,默认数量为1 + C:配置了扫码关联模块,根据数量sql结果。判断是否弹窗。数量默认为1 + + this.BillModel.ScanCodeFixedPrefix为条码前缀,扫码内容前缀和配置相同,默认为B + */ + string Type = string.Empty; + if (!string.IsNullOrWhiteSpace(this.BillModel.ScanCodeFixedPrefix) && inputText.StartsWith(this.BillModel.ScanCodeFixedPrefix)) + { + Type = "B"; + } + else + { + string Sql = string.Format("select line_str from wms_ScanCodeLinetab a where modid='{0}' and hl_tig='{1}'", this.SysModel.ModuleCode, DocumentColor); + Type = SqlHelper.ExecuteScalar(Sql) + ""; + if (string.IsNullOrWhiteSpace(Type)) + { + MessageUtil.Show("扫码配置错误,请联系朗速服务人员"); + return; + } + } + switch (Type.ToUpper()) + { + case "A": + + FrmAdd frmAdd = new FrmAdd(); + if (frmAdd.ShowDialog() == DialogResult.OK) + { + Quantity = frmAdd.Quantity; + } + else + { + textEdit.EditValue = ""; + textEdit.Focus(); + return; + } + this.ExecuteWcanningSQL(MainRowItem, Quantity + "", DocumentColor, inputText); + break; + case "B": + this.ExecuteWcanningSQL(MainRowItem, Quantity + "", DocumentColor, inputText); + break; + case "C": + if (!string.IsNullOrWhiteSpace(this.BillModel.ScanCodeModuleCode)) + { + //根据传入的模块号获取模块信息 + DataRow modelRow = MainImpl.GetSystemdllTab(this.BillModel.ScanCodeModuleCode);//获取模块信息 + if (modelRow == null) + { + MessageUtil.Show("模块编号[" + this.BillModel.ScanCodeModuleCode + "],配置错误!\r\n该模块信息未找到!"); + return; + } + if (modelRow.Table.Columns.Contains("countSql") && !string.IsNullOrWhiteSpace(modelRow["countSql"] + "")) + { + string sql = modelRow["countSql"] + ""; + sql = ReplaceHelper.ReplaceUserInfo(sql); + sql = ReplaceHelper.ReplaceParamToValue(sql, "{value}", inputText); + string num = SqlHelper.ExecuteScalar(sql) + ""; + num = this.IsNumberic(num) ? num : "0"; + if (int.Parse(num) == 0) + { + MessageUtil.Show("未检测到扫码信息存在,请检查相应前序业务!"); + } + else if (int.Parse(num) == 1) + { + this.ExecuteWcanningSQL(MainRowItem, Quantity + "", DocumentColor, inputText); + } + else if (int.Parse(num) > 1) + { + FrmScanCodeAssociation frmScanCodeAssociation = new FrmScanCodeAssociation(modelRow, inputText); + if (frmScanCodeAssociation.ShowDialog() == DialogResult.OK) + { + string Codes = frmScanCodeAssociation.StringCodes; + this.ExecuteWcanningSQL(MainRowItem, Quantity + "", DocumentColor, Codes); + } + else + { + textEdit.EditValue = ""; + textEdit.Focus(); + return; + } + } + } + } + else + { + MessageUtil.Show("扫码配置错误"); + return; + } + break; + + } + } + + textEdit.EditValue = ""; + textEdit.Focus(); + } + } + + + /// + /// 执行扫码的存储过程 + /// + /// 明细选中行 + ///数量 + ///红蓝单据字段 + ///串码,多个用;隔开 + public void ExecuteWcanningSQL(DataRow MainRowItem, string Quantity, string DocumentColor, string Codes) + { + int j = 0; + foreach (string code in Codes.TrimEnd(';').Split(';')) + { + if (string.IsNullOrWhiteSpace(code)) continue; + List Parameter = this.BillModel.CodeExecuteParameter.Split(',').ToList(); + for (int i = 0; i < Parameter.Count; i++) + { + string item = Parameter[i]; + if (item.Contains("{DocumentColor}")) + { + item = ReplaceHelper.ReplaceParamToValue(item, "{DocumentColor}", DocumentColor); + } + if (item.Contains("{amount}")) + { + item = Quantity + ""; + } + //替换单据号 + item = ReplaceHelper.ReplaceParamToValue(item, "{" + this.BillModel.PrimaryKey + "}", this.lblOrderNo.Text); + //替换选中行(没有就传空) + item = ReplaceHelper.ReplaceRowParam(MainRowItem, item); + //替换扫码内容 + item = ReplaceHelper.ReplaceParamToValue(item, "{value}", code); + Parameter[i] = item; + } + + + List procParams = ReplaceHelper.GetParamFields(this.BillModel.CodeExecuteSql); + List sqlParamList = new List(); + string[] paramStr = procParams[0].Replace("{", "").Replace("}", "").Split(','); + SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000); + + for (int i = 0; i < paramStr.Length; i++) + { + string item = paramStr[i]; + if (paramStr[i].Equals("@msg", StringComparison.OrdinalIgnoreCase)) + { + pMsg.Direction = ParameterDirection.InputOutput; + pMsg.Value = Parameter.Count > i ? string.IsNullOrEmpty(Parameter[i]) ? "" : Parameter[i] : ""; + sqlParamList.Add(pMsg); + } + else + { + string paramStr1 = paramStr[i]; + SqlParameter param = new SqlParameter(string.Format("{0}", paramStr1), SqlDbType.VarChar); + param.Value = Parameter[i]; + sqlParamList.Add(param); + } + } + SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4); + returnValue.Direction = ParameterDirection.ReturnValue; + int result; + sqlParamList.Add(returnValue); + + try + { + result = MainImpl.ExecProcedure(this.BillModel.CodeExecuteSql.Replace(procParams[0], "").Trim(), sqlParamList.ToArray()); + } + catch (SqlException sex) + { + string Message = ErrorMessage.PromptErrorMessage(sex); + MessageUtil.Show(Message, sex.Message); + return; + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + return; + } + int rValue = Convert.ToInt32(returnValue.Value); + string varchar = pMsg.Value + ""; + switch (rValue) + { + case 1: + if (string.IsNullOrWhiteSpace(varchar)) + { + //刷新当前单据 + if (j == Codes.TrimEnd(';').Split(';').Length - 1) + { + this.SetBillStatus(BillImpl.GetDataRowResult(string.Format("select * from {0} where {1}='{2}'", BillModel.MasterTable, BillModel.PrimaryKey, this.lblOrderNo.Text))); + } + + } + else + { + //刷新返回的单据号 + this.lblOrderNo.Text = varchar; + this.SetBillStatus(BillImpl.GetDataRowResult(string.Format("select * from {0} where {1}='{2}'", BillModel.MasterTable, BillModel.PrimaryKey, varchar))); + } + break; + case -1: + MessageUtil.Show(ResourceKeys.OperFault + "\n" + pMsg.Value); + break; + } + j++; + } + } + + /// + /// 判断是不是数值 + /// + /// + /// + private bool IsNumberic(string oText) + { + try + { + int var1 = Convert.ToInt32(oText); + return true; + } + catch + { + return false; + } + } + + /// + /// 打开来源模块,并把选中的数据反写到主表明细中 + /// + /// + /// + private void OpenTheSourcePopup(object sender, EventArgs e) + { + string SourceId = sender + ""; + if (string.IsNullOrWhiteSpace(SourceId)) return; + FrmDocumentSource frmSource = new FrmDocumentSource(SourceId); + frmSource.WindowState = FormWindowState.Maximized; + if (frmSource.ShowDialog() == DialogResult.OK) + { + this.gcMain.GridView.BeginUpdate(); + foreach (DataRow rowItem in frmSource.DataRows) + { + this.AddRowToGridView(rowItem); + } + this.gcMain.GridView.EndUpdate(); + } + + } + + /// + /// 所有粘贴完成后执行 + /// + /// + /// + private void OnAllAfterParseCallBack(object sender, EventArgs e) + { + DataTable gridTable = (this.gcMain.GridControl.DataSource as DataTable).TrimDeleteRows(); + gridTable.OrderBy(this.BillModel.DetailOrderField); + this.gcMain.GridView.UpdateCurrentRow(); + this.gcMain.GridView.ShowEditor(); + } + + + + /// + /// 说明:添加多行到单据明细中 + /// 创建人:龚宇超 + /// 创建日期:2017-11-30 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The row item. + /// The union model. + private void AddRowsToTreeGridControl(DataTable dataTable, BillSourceUnionModel unionModel) + { + WaitForm.ShowForm(); + TreeListColumnCollection gridColumns = (this.gcMain as TreeGridControlEx).TreeListObj.Columns; + DataTable gridTable = ((this.gcMain as TreeGridControlEx).TreeListObj.DataSource as DataTable).TrimDeleteRows().Copy(); + + if (!gridTable.Columns.Contains(ERPInfo.Instance.isAddRows)) + { + gridTable.Columns.Add(ERPInfo.Instance.isAddRows, typeof(String)); + } + + TreeListNode treeNode = (this.gcMain as TreeGridControlEx).TreeListObj.FocusedNode as TreeListNode; + int position = 0; + if (treeNode != null) position = treeNode.Id; + + + //bool isLastRow = this.gcMain.GridView.IsLastVisibleRow; + + + + bool onlyOne = true; + foreach (DataRow rowItem in dataTable.Rows) + { + if (unionModel == null || ValidateDetailCond(rowItem, unionModel)) + { + + string repeatProduct = (this.gcMain as TreeGridControlEx).TreeListObj.Columns["ProductId"] != null && rowItem.Table.Columns.Contains("ProductId") ? "ProductId" : this.BillModel.DetailPreFix + "ProductId"; + AssociatedField = repeatProduct; + + if ("1".Equals(this.BillModel.DetailDoubleClickTip) && gridColumns[repeatProduct] != null && dataTable.Columns.Contains(repeatProduct)) + { + //上面方法无法处理大小写,改成搜索的形式 + DataTable dt = (this.gcMain as TreeGridControlEx).TreeListObj.DataSource as DataTable; + if (dt != null && dt.Rows.Count > 0 && dt.Columns.Contains(repeatProduct)) + { + DataRow[] drs = dt.Select(repeatProduct + "='" + rowItem[repeatProduct] + "'"); + if (drs.Length >= 1) + { + DialogResult dialog = MessageUtil.Show(ResourceKeys.ProductIsRepet, MessageBoxButtons.YesNo); + if (dialog != DialogResult.Yes) + return; + } + } + + } + + DataRow newRow = gridTable.NewRow(); + newRow.BeginEdit(); + // 赋值明细字段 + foreach (TreeListColumn col in gridColumns) + { + try + { + GridColumnModel model = col.Tag as GridColumnModel; + if (dataTable.Columns.Contains(col.FieldName)) + { + // 来源列中是否包含对应字段,包含则使用值 + newRow[col.FieldName] = rowItem[col.FieldName]; + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, rowItem[col.FieldName] + "", newRow); + } + SetCalcValue(model, rowItem[col.FieldName] + "", newRow); + } + else + { + // 未包含字段,则使用控件默认值. + if (col.FieldName.Contains("_Ls")) + { + string[] unioFielName = col.FieldName.Split('_'); + string UnioValue = unioFielName[unioFielName.Length - 1]; + DataColumn grid = dataTable.Columns.Cast().FirstOrDefault(x => x.ColumnName.Split('_')[x.ColumnName.Split('_').Length - 1].Equals(UnioValue)); + if (grid != null && !string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, rowItem[col.FieldName] + "", newRow); + } + SetCalcValue(model, rowItem[col.FieldName] + "", newRow); + + } + else + { + string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue); + + if (model.DefaultValue.Contains("{#")) + { + fieldValue = this.ControlObj.ReplaceParentControlValue(model.DefaultValue); + if (!string.IsNullOrEmpty(fieldValue)) + { + newRow[col.FieldName] = fieldValue; + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, fieldValue + "", newRow); + } + SetCalcValue(model, fieldValue + "", newRow); + + //计算规则配置在结果字段上,所以无需验证当前操作控件 + //this.gcMain.GridView.SetFocusedRowCellValue(col, fieldValue); + } + } + else if (!string.IsNullOrEmpty(model.DefaultValue)) + { + newRow[col.FieldName] = fieldValue; + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, fieldValue + "", newRow); + } + SetCalcValue(model, fieldValue + "", newRow); + + } + } + } + SetDisableColumn(model, newRow[col.FieldName] + "", newRow); + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + } + } + // newRow[(this.gcMain as TreeGridControlEx).TreeListObj.KeyFieldName] = (this.gcMain as TreeGridControlEx).GetNewNodesId();//节点id + newRow.EndEdit(); + gridTable.Rows.Add(newRow); + + position++; + + if (!string.IsNullOrEmpty(NumberMc) && gridTable.Columns.Contains(mRecordPrimaryField)) + { + DataRow[] rt = gridTable.Rows.Cast().Where(x => (newRow[BillModel.DetailPreFix + "ProductId"] + "").Equals(x[BillModel.DetailPreFix + "ProductId"] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); + foreach (DataRow item in rt) + { + if (newRow != null) + { + newRow[NumberMc] = Convert.ToDouble(newRow[NumberMc]) - Convert.ToDouble(item[NumberMc]); + } + //(this.gcMain as TreeGridControlEx).GcMain_CellValueChanged(this.gcMain as TreeGridControlEx, new CellValueChangedEventArgs(position, this.gcMain.GridView.Columns[NumberMc], newRow[NumberMc] + "")); + //this.gcMain.GridView.UpdateCurrentRow(); + //this.gcMain.GridView.ShowEditor(); + if (Convert.ToDouble(newRow[NumberMc] + "") == 0.0) + { + gridTable.Rows.Remove(newRow); + MessageUtil.Show("数量已分配完毕!无需再进行拖拽!"); + } + } + } + } + else + { + if (onlyOne) + { + onlyOne = false; + if (!string.IsNullOrEmpty(unionModel.ModelObj.DetailEnableMsg)) + { + if (unionModel.ModelObj.DetailEnableMsg.StartsWith("select", StringComparison.OrdinalIgnoreCase) || + unionModel.ModelObj.DetailEnableMsg.StartsWith("exec", StringComparison.OrdinalIgnoreCase)) + { + MessageUtil.Show(BaseImpl.GetResult(unionModel.ModelObj.DetailEnableMsg) + ""); + } + else + { + MessageUtil.Show(unionModel.ModelObj.DetailEnableMsg); + } + } + } + } + } + (this.gcMain as TreeGridControlEx).SetGridViewDataSourceGenerateID(gridTable); + //this.gcMain.GridControl.DataSource = gridTable; + //if (position >= 0) + // this.gcMain.GridView.SelectRowHandler(position); + //else + // this.gcMain.GridView.SelectRowHandler(gridTable.Rows.Count - 1); + + //gridTable.OrderBy(this.BillModel.DetailOrderField); + //this.gcMain.GridView.UpdateCurrentRow(); + //this.gcMain.GridView.ShowEditor(); + gridTable.OrderBy(this.BillModel.DetailOrderField); + (this.gcMain as TreeGridControlEx).DataSourceSorting(); + WaitForm.HideForm(); + } + + /// + /// 说明:是否允许添加明细 + /// 创建人:龚宇超 + /// 创建日期:2018-06-06 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// true if this instance [can add detail row]; otherwise, false. + private bool CanAddTreeDetailRow() + { + // 检测是否正在筛选数据 + if (!string.IsNullOrEmpty((this.gcMain as TreeGridControlEx).TreeListObj.FindFilterText.Trim()) || + !string.IsNullOrEmpty((this.gcMain as TreeGridControlEx).TreeListObj.FilterPanelText.Trim())) + { + if (MessageUtil.Show(ResourceKeys.GridViewSearching, MessageBoxButtons.YesNo) == DialogResult.Yes) + { + (this.gcMain as TreeGridControlEx).TreeListObj.FindFilterText = ""; + return true; + } + return false; + } + // 检测是否点击了排序表格 + if ((this.gcMain as TreeGridControlEx).IsColumnSorted()) + { + (this.gcMain as TreeGridControlEx).ClearAllSort(); + } + // 检测是否为提交或者终审模块 + string text = Business.Impl.LanguageTranslation.Translatable ? Business.Impl.LanguageTranslation.GetTranslatedText("已终审") : "已终审"; + if (_waterMark.Text.Contains(text) && !this.BillModel.BillFinalReviewAdd) + { + MessageUtil.Show(ResourceKeys.AddBillDetailed); + return false; + } + return true; + } + + + + /// + /// 说明:检查可用条件 + /// 创建人:龚宇超 + /// 创建日期:2017-11-09 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The cond. + /// The data row. + /// true if XXXX, false otherwise. + private bool ValidateCond(string cond, DataRow dataRow) + { + bool result = false; + string condition = cond; + try + { + if (string.IsNullOrWhiteSpace(cond)) return true;//如果值是空格或者空行,默认正确 + cond = ReplaceHelper.ReplaceRowParam(dataRow, cond); + if (cond.StartsWith("@") || cond.StartsWith("!")) + { + result = "1".Equals(BaseImpl.GetDefaultValue(cond)); + } + else if (dataRow == null) + { + result = ReplaceHelper.EvalCond(cond); + } + else + { + result = ReplaceHelper.ReplaceRowParamCond(dataRow, cond); + } + return result; + } + catch (Exception ex) + { + + } + return result; + } + + + + + /// + /// 说明:设置图片事件 + /// 创建人:龚宇超 + /// 创建日期:2018-02-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void SetImageEvent(DataTable table) + { + if (table == null || table.Rows.Count == 0) return; + DataRow[] imageRows = table.Select("fieldTypeId=" + (int)ControlType.LabPicEx); + + foreach (DataRow item in imageRows) + { + string fieldName = item["fieldName"] + ""; + LabelImageEdit imageEdit = this.ControlObj.FindControl(fieldName) as LabelImageEdit; + if (imageEdit != null) + { + imageEdit.UploadEvent += new LabelImageEdit.UploadEventHander(OnImageUploadEvent); + imageEdit.DeleteEvent += new LabelImageEdit.DeleteEventHander(OnImageDeleteEvent); + } + } + } + + + /// + /// 说明:上传附件 + /// 创建人:龚宇超 + /// 创建日期:2018-02-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + protected void OnImageUploadEvent(object sender) + { + try + { + _imageEdit = sender as LabelImageEdit; + if (string.IsNullOrWhiteSpace(this.lblOrderNo.Text)) + { + MessageUtil.Show(ResourceKeys.UnSaveData); + } + else + { + //string prefix = "001"; + //string imagePath = _imageEdit.SaveImageToLocal(prefix); + OpenFileDialog openFileDialog = new OpenFileDialog(); + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + WaitForm.ShowForm("上传中..."); + if (!string.IsNullOrEmpty(openFileDialog.FileName)) + { + Image image = null; + bool isImage = true; + try + { + image = Image.FromFile(openFileDialog.FileName); + } + catch (Exception) + { + isImage = false; + } + if (image != null && isImage) + { + _imageEdit.TextEdit.Image = image; + } + else + { + _imageEdit.TextEdit.Image = global::Lskj.Control.Properties.Resources.file; + } + _imageEdit.CurrentImagePath = openFileDialog.FileName; + } + else + { + _imageEdit.CurrentImagePath = string.Empty; + } + string imagePath = _imageEdit.CurrentImagePath; + if (!string.IsNullOrEmpty(imagePath)) + { + //string speciesNo = string.IsNullOrEmpty(lteSpeciesNo.TextEdit.Text) ? "01" : lteSpeciesNo.TextEdit.Text; + //int directotyId = AttachImpl.GetAttachDirectoryId(this.SysModel.MenuDirId + "", this.PrimaryValue); + //AttachHelper.UpLoadFile(this.Handle, directotyId + "", speciesNo, "001", imagePath); + bool isSuccess = UploadFile(imagePath); + if (!isSuccess) + { + _imageEdit.CurrentImagePath = string.Empty; + _imageEdit.TextEdit.Image = null; + } + } + else + { + MessageUtil.Show("未选择上传文件"); + } + WaitForm.HideForm(); + } + } + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + + } + /// + /// 上传附件(新) + /// + private bool UploadFile(string filePath) + { + bool isUpload = true; + try + { + string token = ""; + string loginUrl = $"{SystemInfo.Instance.OAUrl}/Api/SysUserAjaxApi.ashx"; + HttpTools.setting("application/x-www-form-urlencoded", null, null, HttpTools.Encode.UTF8); + Dictionary loginPmsDic = new Dictionary(); + loginPmsDic.Add("method", "Login"); + loginPmsDic.Add("username", ERPInfo.Instance.UserName); + loginPmsDic.Add("password", ERPInfo.Instance.InPassWord); + HttpWebResponse loginResponse = HttpTools.Post(loginUrl, "", loginPmsDic, HttpTools.Method.POST, out CookieCollection loginCookie, out string loginResult); + if (loginResponse != null && !string.IsNullOrEmpty(loginResult)) + { + JObject jObject = JsonConvert.DeserializeObject(loginResult); + if (jObject.ContainsKey("success")) + { + if ((jObject["success"] + "").Equals("True")) + { + if (jObject.ContainsKey("token")) + { + token = jObject["token"] + ""; + } + } + } + } + if (!string.IsNullOrEmpty(token)) + { + byte[] fileBytes = ConvertFileToBytes(filePath); + string fileBase64Str = Convert.ToBase64String(fileBytes) + ""; + string postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&folder={3}&totsize={4}&position={5}&filename={6}&method={7}"; + Dictionary headerDic = new Dictionary(); + headerDic.Add("Authorization", $"Bearer {token}"); + postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, this.SysModel.ModuleCode, this.lblOrderNo.Text, "UploadFilesTemp", fileBytes.Length, 0, System.Web.HttpUtility.UrlEncode($"{Guid.NewGuid()}_{Path.GetFileName(_imageEdit.CurrentImagePath)}"), "DoWebUpload"); + HttpTools.setting("application/x-www-form-urlencoded", null, null); + HttpWebResponse webResponse = HttpTools.Post(postUrl, fileBase64Str, null, headerDic, HttpTools.Method.POST, out CookieCollection cookieCollection, out string result); + if (webResponse != null && !string.IsNullOrEmpty(result)) + { + JObject jsonObject = (JObject)JsonConvert.DeserializeObject(result); + string isSuccess = jsonObject["success"] + ""; + if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase)) + { + string fileId = jsonObject["other"] + ""; + string webpath = jsonObject["data"]["WebRelPath"] + ""; + BaseModuleImpl.UpdateRecord(this.BillModel.MasterTable, _imageEdit.Model.FieldName, webpath, this.BillModel.PrimaryKey, this.lblOrderNo.Text); + //string searchSql = @"update P_fm_FileTab set author='{2}',CreationTime='{3}' ,Uploader='{4}' ,UploadTime='{5}' + // where dllcoid = '{0}' and + // parentid = (select dirid from P_fm_DirectoryTab where + // ParentId = (select dirid from v_systemdlltab where DllCoid = '{0}') and PID = '{1}') and fileId='{6}' "; + //searchSql = string.Format(searchSql, this.Model.ModuleCode, this.leftTreeGridIdValue, dataRow["author"], fi.CreationTime, ERPInfo.Instance.UserName, dataRow["UploadTime"], fileId); + //SqlHelper.ExecuteNonQuery(searchSql); + } + else + { + if (jsonObject.ContainsKey("msg")) + { + string returnMsg = jsonObject["msg"] + ""; + MessageUtil.Show(string.Format("上传失败,原因:{0}", returnMsg)); + } + isUpload = false; + } + } + else + { + MessageUtil.Show(string.Format("上传失败,原因:{0}", result)); + } + } + else + { + MessageUtil.Show(string.Format("验证失败,原因:{0}", loginResult)); + } + } + catch (Exception ex) + { + MessageUtil.Show(string.Format("上传失败,原因:{0}", ex.Message)); + isUpload = false; + } + return isUpload; + } + /// + /// 附件转换byte[] + /// + /// 附件路径 + /// 二进制 + private byte[] ConvertFileToBytes(string filePath) + { + byte[] bytContent = null; + System.IO.FileStream fs = null; + System.IO.BinaryReader br = null; + try + { + fs = new FileStream(filePath, System.IO.FileMode.Open, FileAccess.Read, FileShare.Read); + } + catch (Exception) + { + throw; + } + if (fs != null) + br = new BinaryReader((Stream)fs); + if (br != null) + bytContent = br.ReadBytes((Int32)fs.Length); + if (fs != null) + fs.Dispose(); + return bytContent; + } + + /// + /// 说明:删除附件 + /// 创建人:龚宇超 + /// 创建日期:2018-02-27 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + protected void OnImageDeleteEvent(object sender) + { + try + { + LabelImageEdit imageEdit = sender as LabelImageEdit; + if (imageEdit != null) + { + int result = BaseModuleImpl.UpdateRecord(this.BillModel.MasterTable, imageEdit.Model.FieldName, "", this.BillModel.PrimaryKey, this.lblOrderNo.Text); + MessageUtil.Show(result > 0 ? ResourceKeys.OperSuccess : ResourceKeys.OperFault); + } + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + + } + + /// + /// 设置打印按钮条件 + /// + /// + public bool SetPrintButton(DataRow rowItem) + { + try + { + bool result = false; + //判断打印按钮条件 + if (!string.IsNullOrWhiteSpace(this.BillModel.PrintingConditions)) + { + if (rowItem == null) return result; + + string cond = ReplaceHelper.ReplaceRowParam(rowItem, this.BillModel.PrintingConditions); + if (cond.StartsWith("@") || cond.StartsWith("!")) + { + result = "1".Equals(BaseImpl.GetDefaultValue(cond)); + } + else + { + result = ReplaceHelper.ReplaceRowParamCond(rowItem, cond); + } + return result; + } + else + { + return true; + } + } + catch (Exception ex) + { + return false; + } + } + + + /// + /// 改变选中行的颜色 + /// + /// + /// + private void GridView_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e) + { + } + + /// + /// 清空记录的选中行 + /// + /// + public void ClearHighlightRows(GridView gridview) + { + } + + + public bool VerificationCond() + { + + DataTable detailTable = this.gcMain.GridControl.DataSourceTable().TrimDeleteRows(); + + foreach (DataRow CondItem in SaveCondTab.Rows) + { + string condition = CondItem["condition"] + ""; + if (!string.IsNullOrWhiteSpace(condition)) + { + + if (detailTable != null && detailTable.Rows.Count > 0) + { + condition = this.ControlObj.ReplaceParentControlValue(condition); + foreach (DataRow item in detailTable.Rows) + { + if (!ValidateCond(condition, item)) + { + MessageUtil.Show(string.IsNullOrWhiteSpace(CondItem["hintmsg"] + "") ? "条件验证失败" : CondItem["hintmsg"] + ""); + return false; + } + } + } + else + { + List conditionlist = ReplaceHelper.GetParamFields(condition); + foreach (string item in conditionlist) + { + if (!item.Contains("{#")) continue;//只有所有替换参数都包含了{#的(全部都是主表参数),才会去验证条件 + } + condition = this.ControlObj.ReplaceParentControlValue(condition); + if (!ValidateCond(condition, null)) + { + MessageUtil.Show(string.IsNullOrWhiteSpace(CondItem["hintmsg"] + "") ? "条件验证失败" : CondItem["hintmsg"] + ""); + return false; + } + } + } + } + return true; + } + + /// + /// 点击第一个默认新增行新增默认数据 + /// + /// + /// + private void GridView_MouseDown(object sender, MouseEventArgs e) + { + + } + /// + /// 说明:检查添加数据到表格中是否包含 + /// + /// 创建人:龚宇超 + /// 创建日期:2018-04-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The row item. + /// The union model. + /// if set to true [only popup]. + private void AddRowToGridViewByBom(DataRow rowItem, BillSourceUnionModel unionModel, ref bool onlyPopup) + { + if (!string.IsNullOrEmpty(unionModel.ModelObj.BomSql)) + { + string bomSql = unionModel.ModelObj.BomSql; + // 检查是否有bom配置 + if (unionModel.ModelObj.LoadBom == 1) + { + // 自动带出bom数据,不弹出选择 + DataTable table = BaseImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, bomSql)); + foreach (DataRow item in table.Rows) + { + this.AddRowToGridView(item); + } + } + else if (unionModel.ModelObj.LoadBom == 2) + { + DataTable table = BaseImpl.GetDataTableResult(ReplaceHelper.ReplaceRowParam(rowItem, bomSql)); + + if (!onlyPopup && table.Rows.Count > 0) + { + // 自动带出bom数据,弹出选择 + FrmBomSelect frmSelect = new FrmBomSelect(); + frmSelect.Caption = unionModel.ModelObj.BomCaption; + frmSelect.GridColumns = unionModel.GridDetailControlObj.GridView.Columns; + frmSelect.BomDataTable = table; + + DialogResult result = frmSelect.ShowDialog(); + onlyPopup = frmSelect.OnlyPopup; + + if (result == DialogResult.OK && frmSelect.SelectBomRows != null && frmSelect.SelectBomRows.Length > 0) + { + foreach (DataRow item in frmSelect.SelectBomRows) + { + this.AddRowToGridView(item); + } + } + } + else + { + foreach (DataRow item in table.Rows) + { + this.AddRowToGridView(item); + } + } + } + } + } + + + + + /// + /// 说明:添加行到单据明细中 + /// 创建人:龚宇超 + /// 创建日期:2017-11-30 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The row item. + /// The union model. + private void AddRowToTreeGridControl(DataRow rowItem, string Pid) + { + TreeListColumnCollection gridColumns = (this.gcMain as TreeGridControlEx).TreeListObj.Columns; + DataTable gridTable = ((this.gcMain as TreeGridControlEx).TreeListObj.DataSource as DataTable).TrimDeleteRows(); + if (!gridTable.Columns.Contains(ERPInfo.Instance.isAddRows)) + { + gridTable.Columns.Add(ERPInfo.Instance.isAddRows, typeof(String)); + } + string repeatProduct = (this.gcMain as TreeGridControlEx).TreeListObj.Columns["ProductId"] != null && rowItem.Table.Columns.Contains("ProductId") ? "ProductId" : this.BillModel.DetailPreFix + "ProductId"; + AssociatedField = repeatProduct; + if ("1".Equals(this.BillModel.DetailDoubleClickTip) && rowItem.Table.Columns.Contains(repeatProduct)) + { + // 需要提示编码重复 + DataTable dt = (this.gcMain as TreeGridControlEx).TreeListObj.DataSource as DataTable; + if (dt != null && dt.Rows.Count > 0 && dt.Columns.Contains(repeatProduct)) + { + DataRow[] drs = dt.Select(repeatProduct + "='" + rowItem[repeatProduct] + "'"); + if (drs.Length >= 1) + { + DialogResult dialog = MessageUtil.Show(ResourceKeys.ProductIsRepet, MessageBoxButtons.YesNo); + if (dialog != DialogResult.Yes) + return; + } + } + } + DataRow newRow = gridTable.NewRow(); + //2024-1-29改成>=,之前为>导致选中第一行只会添加到最后一行(测试空白行没有影响) + int position = this.gcMain.GridView.FocusedRowHandle >= 0 ? gridTable.Rows.Count > 0 ? this.gcMain.GridView.FocusedRowHandle : 0 : gridTable.Rows.Count - 1; + + + + (this.gcMain as TreeGridControlEx).TreeListObj.BeginUpdate(); + GridView gridView = this.gcMain.GridView; + // 赋值明细字段 + foreach (TreeListColumn col in gridColumns) + { + try + { + // 未包含字段,则使用控件默认值. + GridColumnModel model = col.Tag as GridColumnModel; + + if (rowItem.Table.Columns.Contains(col.FieldName)) + { + // 来源列中是否包含对应字段,包含则使用值 + newRow[col.FieldName] = rowItem[col.FieldName]; + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, rowItem[col.FieldName] + "", newRow); + } + SetCalcValue(model, rowItem[col.FieldName] + "", newRow); + } + else + { + + if (col.FieldName.Contains("_Ls")) + { + string[] unioFielName = col.FieldName.Split('_'); + string UnioValue = unioFielName[unioFielName.Length - 1]; + DataColumn grid = rowItem.Table.Columns.Cast().FirstOrDefault(x => x.ColumnName.Split('_')[x.ColumnName.Split('_').Length - 1].Equals(UnioValue)); + if (grid != null && !string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, rowItem[col.FieldName] + "", newRow); + } + SetCalcValue(model, rowItem[col.FieldName] + "", newRow); + } + else + { + string fieldValue = BaseImpl.GetDefaultValue(model.DefaultValue); + + if (model.DefaultValue.Contains("{#")) + { + fieldValue = this.ControlObj.ReplaceParentControlValue(model.DefaultValue); + if (!string.IsNullOrEmpty(fieldValue)) + { + newRow[col.FieldName] = fieldValue; + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, fieldValue + "", newRow); + } + SetCalcValue(model, fieldValue + "", newRow); + } + } + else if (!string.IsNullOrEmpty(model.DefaultValue)) + { + newRow[col.FieldName] = fieldValue; + if (!string.IsNullOrEmpty(model.UnionFields)) + { + this.SetUnionValue(model, fieldValue + "", newRow); + } + SetCalcValue(model, fieldValue + "", newRow); + } + } + } + SetDisableColumn(model, newRow[col.FieldName] + "", newRow); + if (model.LimitLength > 0) + { + DataRow HandleRow = newRow; + int MaxInputLength = System.Text.Encoding.Default.GetBytes(newRow[col.FieldName] + "").Length; + if (model.LimitLength < MaxInputLength) + HandleRow.SetColumnError(HandleRow.Table.Columns[col.ColumnHandle], "当前输入文本超过设定长度!");//满足条件设置错误信息 + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + } + } + (this.gcMain as TreeGridControlEx).TreeListObj.EndUpdate(); + if (string.IsNullOrWhiteSpace(newRow[(this.gcMain as TreeGridControlEx).TreeListObj.KeyFieldName] + "")) + { + newRow[(this.gcMain as TreeGridControlEx).TreeListObj.KeyFieldName] = (this.gcMain as TreeGridControlEx).GetNewNodesId();//节点id为空,就默认给当前数据源最大id+1 + } + + if (!string.IsNullOrWhiteSpace(Pid)) + { + newRow[(this.gcMain as TreeGridControlEx).TreeListObj.ParentFieldName] = Pid;//拖拽到目标节点的id + } + // 添加数据行 + gridTable.Rows.Add(newRow); + + + if (!string.IsNullOrEmpty(NumberMc) && gridTable.Columns.Contains(mRecordPrimaryField)) + { + DataRow[] rt = gridTable.Rows.Cast().Where(x => (newRow[BillModel.DetailPreFix + "ProductId"] + "").Equals(x[BillModel.DetailPreFix + "ProductId"] + "") && !string.IsNullOrEmpty(x[mRecordPrimaryField] + "")).ToArray(); + foreach (DataRow item in rt) + { + if (newRow != null) + { + newRow[NumberMc] = Convert.ToDouble(newRow[NumberMc]) - Convert.ToDouble(item[NumberMc]); + } + //this.gcMain.OnGridViewCellValueChanged(this.gcMain, new CellValueChangedEventArgs(position + 1, this.gcMain.GridView.Columns[NumberMc], newRow[NumberMc] + "")); + //this.gcMain.GridView.UpdateCurrentRow(); + //this.gcMain.GridView.ShowEditor(); + if (Convert.ToDouble(newRow[NumberMc] + "") == 0.0) + { + gridTable.Rows.Remove(newRow); + MessageUtil.Show("数量已分配完毕!无需再进行拖拽!"); + } + } + } + //gridTable.OrderBy(this.BillModel.DetailOrderField); + //设置排序列的值 + (this.gcMain as TreeGridControlEx).DataSourceSorting(); + } + + } +} diff --git a/插件库/Lskj.PubBillManagement/FrmBill.resx b/插件库/Lskj.PubBillManagement/FrmBill.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmBill.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/FrmBomSelect.Designer.cs b/插件库/Lskj.PubBillManagement/FrmBomSelect.Designer.cs new file mode 100644 index 0000000..39ddc58 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmBomSelect.Designer.cs @@ -0,0 +1,196 @@ +namespace Lskj.PubBillManagement +{ + partial class FrmBomSelect + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panelControl1 = new DevExpress.XtraEditors.PanelControl(); + this.pl_main = new DevExpress.XtraEditors.PanelControl(); + this.gcMain = new Lskj.Control.GridControlEx(); + this.pl_bottom = new DevExpress.XtraEditors.PanelControl(); + this.chkOperate = new DevExpress.XtraEditors.CheckEdit(); + this.btnClearSelectAll = new DevExpress.XtraEditors.SimpleButton(); + this.btnCancel = new DevExpress.XtraEditors.SimpleButton(); + this.btnSelectAll = new DevExpress.XtraEditors.SimpleButton(); + this.btnOk = new DevExpress.XtraEditors.SimpleButton(); + ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit(); + this.panelControl1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_main)).BeginInit(); + this.pl_main.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_bottom)).BeginInit(); + this.pl_bottom.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.chkOperate.Properties)).BeginInit(); + this.SuspendLayout(); + // + // panelControl1 + // + this.panelControl1.Controls.Add(this.pl_main); + this.panelControl1.Controls.Add(this.pl_bottom); + this.panelControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panelControl1.Location = new System.Drawing.Point(0, 0); + this.panelControl1.Name = "panelControl1"; + this.panelControl1.Size = new System.Drawing.Size(515, 341); + this.panelControl1.TabIndex = 0; + // + // pl_main + // + this.pl_main.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_main.Appearance.Options.UseBackColor = true; + this.pl_main.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_main.Controls.Add(this.gcMain); + this.pl_main.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_main.Location = new System.Drawing.Point(2, 2); + this.pl_main.Name = "pl_main"; + this.pl_main.Size = new System.Drawing.Size(511, 303); + this.pl_main.TabIndex = 1; + // + // gcMain + // + this.gcMain.AdapterObj = null; + this.gcMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.gcMain.Location = new System.Drawing.Point(0, 0); + this.gcMain.Name = "gcMain"; + this.gcMain.Size = new System.Drawing.Size(511, 303); + this.gcMain.TabIndex = 0; + // + // pl_bottom + // + this.pl_bottom.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_bottom.Appearance.Options.UseBackColor = true; + this.pl_bottom.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_bottom.Controls.Add(this.chkOperate); + this.pl_bottom.Controls.Add(this.btnClearSelectAll); + this.pl_bottom.Controls.Add(this.btnCancel); + this.pl_bottom.Controls.Add(this.btnSelectAll); + this.pl_bottom.Controls.Add(this.btnOk); + this.pl_bottom.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pl_bottom.Location = new System.Drawing.Point(2, 305); + this.pl_bottom.Name = "pl_bottom"; + this.pl_bottom.Size = new System.Drawing.Size(511, 34); + this.pl_bottom.TabIndex = 0; + // + // chkOperate + // + this.chkOperate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.chkOperate.Location = new System.Drawing.Point(250, 8); + this.chkOperate.Name = "chkOperate"; + this.chkOperate.Properties.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.chkOperate.Properties.Appearance.Options.UseFont = true; + this.chkOperate.Properties.Caption = "应用到所有操作"; + this.chkOperate.Size = new System.Drawing.Size(115, 19); + this.chkOperate.TabIndex = 28; + // + // btnClearSelectAll + // + this.btnClearSelectAll.AllowFocus = false; + this.btnClearSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnClearSelectAll.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnClearSelectAll.Appearance.Options.UseFont = true; + this.btnClearSelectAll.Location = new System.Drawing.Point(73, 4); + this.btnClearSelectAll.Name = "btnClearSelectAll"; + this.btnClearSelectAll.Size = new System.Drawing.Size(67, 26); + this.btnClearSelectAll.TabIndex = 27; + this.btnClearSelectAll.Text = "反选(&N)"; + this.btnClearSelectAll.Click += new System.EventHandler(this.OnClearSelectAllClick); + // + // btnCancel + // + this.btnCancel.AllowFocus = false; + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnCancel.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnCancel.Appearance.Options.UseFont = true; + this.btnCancel.Location = new System.Drawing.Point(440, 4); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(67, 26); + this.btnCancel.TabIndex = 27; + this.btnCancel.Text = "取消(&C)"; + this.btnCancel.Click += new System.EventHandler(this.OnCancelButtonClick); + // + // btnSelectAll + // + this.btnSelectAll.AllowFocus = false; + this.btnSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnSelectAll.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnSelectAll.Appearance.Options.UseFont = true; + this.btnSelectAll.Location = new System.Drawing.Point(4, 4); + this.btnSelectAll.Name = "btnSelectAll"; + this.btnSelectAll.Size = new System.Drawing.Size(67, 26); + this.btnSelectAll.TabIndex = 26; + this.btnSelectAll.Text = "全选(&Y)"; + this.btnSelectAll.Click += new System.EventHandler(this.OnSelectAllClick); + // + // btnOk + // + this.btnOk.AllowFocus = false; + this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnOk.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnOk.Appearance.Options.UseFont = true; + this.btnOk.Location = new System.Drawing.Point(371, 4); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(67, 26); + this.btnOk.TabIndex = 26; + this.btnOk.Text = "确定(&S)"; + this.btnOk.Click += new System.EventHandler(this.OnOkButtonClick); + // + // FrmBomSelect + // + this.Appearance.BackColor = System.Drawing.Color.Transparent; + this.Appearance.Options.UseBackColor = true; + this.Appearance.Options.UseFont = true; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(515, 341); + this.Controls.Add(this.panelControl1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FrmBomSelect"; + this.Text = "Bom选择"; + ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit(); + this.panelControl1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_main)).EndInit(); + this.pl_main.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_bottom)).EndInit(); + this.pl_bottom.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.chkOperate.Properties)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DevExpress.XtraEditors.PanelControl panelControl1; + private DevExpress.XtraEditors.PanelControl pl_main; + private DevExpress.XtraEditors.PanelControl pl_bottom; + private Control.GridControlEx gcMain; + private DevExpress.XtraEditors.SimpleButton btnCancel; + private DevExpress.XtraEditors.SimpleButton btnOk; + private DevExpress.XtraEditors.SimpleButton btnClearSelectAll; + private DevExpress.XtraEditors.SimpleButton btnSelectAll; + private DevExpress.XtraEditors.CheckEdit chkOperate; + + } +} \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/FrmBomSelect.cs b/插件库/Lskj.PubBillManagement/FrmBomSelect.cs new file mode 100644 index 0000000..39b8380 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmBomSelect.cs @@ -0,0 +1,260 @@ +/****************************** +* 说明:Bom选择 +* 创建人:龚宇超 +* 创建日期:2018-02-06 +* 修改人: +* 修改日期: +* 修改备注: +* 版本:1.0.0.0 +******************************/ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Lskj.Control; +using Lskj.Control.Model; +using Lskj.PubBillManagement.Model; +using Lskj.Business.Impl; +using DevExpress.XtraGrid.Columns; +using DevExpress.XtraGrid; +using Lskj.Data; + +namespace Lskj.PubBillManagement +{ + /// + /// Bom选择 + /// + public partial class FrmBomSelect : BaseForm + { + /// + /// 是否记住操作,后续不在弹出界面 + /// + public bool OnlyPopup; + /// + /// 标题 + /// + public string Caption; + /// + /// 选中的bom数据 + /// + public DataRow[] SelectBomRows; + /// + /// The bom data table + /// + public DataTable BomDataTable; + /// + /// 单据明细表格列 + /// + public GridColumnCollection GridColumns; + + public FrmBomSelect() + { + InitializeComponent(); + } + + /// + /// 说明:窗口加载 + /// 创建人:龚宇超 + /// 创建日期:2018-02-06 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The instance containing the event data. + protected override void OnLoad(EventArgs e) + { + try + { + base.OnLoad(e); + if (BomDataTable != null) + { + this.Text = string.IsNullOrEmpty(Caption) ? this.Text : this.Caption; + + DataColumn dataColumn = new DataColumn("Id", typeof(bool)); + dataColumn.DefaultValue = true; + + this.BomDataTable.Columns.Add(dataColumn); + this.InitGridView(); + } + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message,ex.Message); + } + } + + /// + /// 说明:初始化表格控件 + /// 创建人:龚宇超 + /// 创建日期:2018-02-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The table. + private void InitGridView() + { + // 增加选择列 + GridColumn gridColumn = new GridColumn(); + gridColumn.FieldName = gridColumn.Name = "Id"; + gridColumn.Caption = "选择"; + gridColumn.Width = 50; + gridColumn.VisibleIndex = 1; + gridColumn.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; + gridColumn.Visible = true; + + gcMain.GridView.Columns.Add(gridColumn); + + // 添加其他列 + foreach (GridColumn item in GridColumns) + { + GridColumn column = new GridColumn(); + column.Caption = item.Caption; + column.FieldName = item.FieldName; + column.OptionsColumn.AllowEdit = false; + column.OptionsColumn.ReadOnly = true; + column.Width = item.Width; + column.VisibleIndex = item.VisibleIndex; + column.Visible = item.Visible; + gcMain.GridView.Columns.Add(column); + } + + gcMain.SetGridViewDataSource(BomDataTable); + } + /// + /// 说明:获取选中数据 + /// 创建人:龚宇超 + /// 创建日期:2018-02-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// DataRow[]. + private DataRow[] GetSelectRows() + { + DataTable table = gcMain.GridControl.DataSourceTable(); + + return table.Select("Id = true").ToArray(); + } + + /// + /// 说明:全选 + /// 创建人:龚宇超 + /// 创建日期:2018-02-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + void OnSelectAllClick(object sender, EventArgs e) + { + try + { + DataTable table = gcMain.GridControl.DataSourceTable(); + foreach (DataRow item in table.Rows) + { + item["Id"] = true; + } + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message,ex.Message); + } + } + /// + /// 说明:反选 + /// 创建人:龚宇超 + /// 创建日期:2018-02-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + void OnClearSelectAllClick(object sender, EventArgs e) + { + try + { + DataTable table = gcMain.GridControl.DataSourceTable(); + foreach (DataRow item in table.Rows) + { + item["Id"] = false; + } + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message,ex.Message); + } + } + /// + /// 说明:确定 + /// 创建人:龚宇超 + /// 创建日期:2018-02-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + void OnOkButtonClick(object sender, EventArgs e) + { + try + { + DataRow[] rows = GetSelectRows(); + if (rows == null || rows.Length == 0) + { + MessageUtil.Show(ResourceKeys.SelectRowIsNull); + return; + } + + this.SelectBomRows = rows; + this.OnlyPopup = chkOperate.Checked; + this.DialogResult = DialogResult.OK; + } + catch (Exception ex) + { + //MessageUtil.Show("确定事件出错!" + ex); + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message,ex.Message); + } + + } + /// + /// 说明:取消 + /// 创建人:龚宇超 + /// 创建日期:2018-02-07 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + void OnCancelButtonClick(object sender, EventArgs e) + { + try + { + this.DialogResult = DialogResult.Cancel; + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message,ex.Message); + } + } + } +} \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/FrmBomSelect.resx b/插件库/Lskj.PubBillManagement/FrmBomSelect.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmBomSelect.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/FrmDocumentSource.Designer.cs b/插件库/Lskj.PubBillManagement/FrmDocumentSource.Designer.cs new file mode 100644 index 0000000..d9372d5 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmDocumentSource.Designer.cs @@ -0,0 +1,245 @@ + +namespace Lskj.PubBillManagement +{ + partial class FrmDocumentSource + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.splitMain = new DevExpress.XtraEditors.SplitContainerControl(); + this.pl_left = new DevExpress.XtraEditors.PanelControl(); + this.pl_left_main = new System.Windows.Forms.Panel(); + this.pl_gridandtree_container = new DevExpress.XtraEditors.PanelControl(); + this.treeLeft = new Lskj.Control.TreeViewEx(); + this.gridLeft = new Lskj.Control.GridControlEx(); + this.pl_left_top = new DevExpress.XtraEditors.PanelControl(); + this.pl_top = new DevExpress.XtraEditors.PanelControl(); + this.panelControl1 = new DevExpress.XtraEditors.PanelControl(); + this.btnCancel = new DevExpress.XtraEditors.SimpleButton(); + this.btnOk = new DevExpress.XtraEditors.SimpleButton(); + this.gcMain = new Lskj.Control.GridControlEx(); + ((System.ComponentModel.ISupportInitialize)(this.splitMain)).BeginInit(); + this.splitMain.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_left)).BeginInit(); + this.pl_left.SuspendLayout(); + this.pl_left_main.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_gridandtree_container)).BeginInit(); + this.pl_gridandtree_container.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_left_top)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_top)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit(); + this.panelControl1.SuspendLayout(); + this.SuspendLayout(); + // + // splitMain + // + this.splitMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitMain.Location = new System.Drawing.Point(0, 0); + this.splitMain.Margin = new System.Windows.Forms.Padding(4); + this.splitMain.Name = "splitMain"; + this.splitMain.Panel1.Controls.Add(this.pl_left); + this.splitMain.Panel1.Text = "Panel1"; + this.splitMain.Panel2.Controls.Add(this.gcMain); + this.splitMain.Panel2.Controls.Add(this.panelControl1); + this.splitMain.Panel2.Controls.Add(this.pl_top); + this.splitMain.Panel2.Text = "Panel2"; + this.splitMain.Size = new System.Drawing.Size(800, 450); + this.splitMain.SplitterPosition = 260; + this.splitMain.TabIndex = 1; + this.splitMain.Text = "splitContainerControl1"; + // + // pl_left + // + this.pl_left.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_left.Appearance.Options.UseBackColor = true; + this.pl_left.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_left.Controls.Add(this.pl_left_main); + this.pl_left.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_left.Location = new System.Drawing.Point(0, 0); + this.pl_left.Margin = new System.Windows.Forms.Padding(4); + this.pl_left.Name = "pl_left"; + this.pl_left.Size = new System.Drawing.Size(260, 450); + this.pl_left.TabIndex = 1; + // + // pl_left_main + // + this.pl_left_main.BackColor = System.Drawing.Color.Transparent; + this.pl_left_main.Controls.Add(this.pl_gridandtree_container); + this.pl_left_main.Controls.Add(this.pl_left_top); + this.pl_left_main.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_left_main.Location = new System.Drawing.Point(0, 0); + this.pl_left_main.Margin = new System.Windows.Forms.Padding(4); + this.pl_left_main.Name = "pl_left_main"; + this.pl_left_main.Size = new System.Drawing.Size(260, 450); + this.pl_left_main.TabIndex = 6; + // + // pl_gridandtree_container + // + this.pl_gridandtree_container.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_gridandtree_container.Controls.Add(this.treeLeft); + this.pl_gridandtree_container.Controls.Add(this.gridLeft); + this.pl_gridandtree_container.Dock = System.Windows.Forms.DockStyle.Fill; + this.pl_gridandtree_container.Location = new System.Drawing.Point(0, 45); + this.pl_gridandtree_container.Margin = new System.Windows.Forms.Padding(4); + this.pl_gridandtree_container.Name = "pl_gridandtree_container"; + this.pl_gridandtree_container.Size = new System.Drawing.Size(260, 405); + this.pl_gridandtree_container.TabIndex = 9; + // + // treeLeft + // + this.treeLeft.Dock = System.Windows.Forms.DockStyle.Fill; + this.treeLeft.Location = new System.Drawing.Point(0, 0); + this.treeLeft.Margin = new System.Windows.Forms.Padding(4); + this.treeLeft.Name = "treeLeft"; + this.treeLeft.Size = new System.Drawing.Size(260, 405); + this.treeLeft.TabIndex = 7; + this.treeLeft.Visible = false; + // + // gridLeft + // + this.gridLeft.AdapterObj = null; + this.gridLeft.BackColor = System.Drawing.SystemColors.Control; + this.gridLeft.Dock = System.Windows.Forms.DockStyle.Fill; + this.gridLeft.Location = new System.Drawing.Point(0, 0); + this.gridLeft.Margin = new System.Windows.Forms.Padding(5); + this.gridLeft.Name = "gridLeft"; + this.gridLeft.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gridLeft.Size = new System.Drawing.Size(260, 405); + this.gridLeft.SysModel = null; + this.gridLeft.TabIndex = 6; + // + // pl_left_top + // + this.pl_left_top.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.pl_left_top.Appearance.Options.UseBackColor = true; + this.pl_left_top.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_left_top.Dock = System.Windows.Forms.DockStyle.Top; + this.pl_left_top.Location = new System.Drawing.Point(0, 0); + this.pl_left_top.Margin = new System.Windows.Forms.Padding(4); + this.pl_left_top.Name = "pl_left_top"; + this.pl_left_top.Size = new System.Drawing.Size(260, 45); + this.pl_left_top.TabIndex = 8; + // + // pl_top + // + this.pl_top.Appearance.BackColor = System.Drawing.Color.Transparent; + this.pl_top.Appearance.Options.UseBackColor = true; + this.pl_top.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_top.Dock = System.Windows.Forms.DockStyle.Top; + this.pl_top.Location = new System.Drawing.Point(0, 0); + this.pl_top.Name = "pl_top"; + this.pl_top.Size = new System.Drawing.Size(535, 34); + this.pl_top.TabIndex = 13; + // + // panelControl1 + // + this.panelControl1.Controls.Add(this.btnCancel); + this.panelControl1.Controls.Add(this.btnOk); + this.panelControl1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panelControl1.Location = new System.Drawing.Point(0, 403); + this.panelControl1.Margin = new System.Windows.Forms.Padding(4); + this.panelControl1.Name = "panelControl1"; + this.panelControl1.Size = new System.Drawing.Size(535, 47); + this.panelControl1.TabIndex = 15; + // + // btnCancel + // + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnCancel.Location = new System.Drawing.Point(441, 5); + this.btnCancel.Margin = new System.Windows.Forms.Padding(4); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(79, 35); + this.btnCancel.TabIndex = 24; + this.btnCancel.Text = "取消(&C)"; + // + // btnOk + // + this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnOk.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnOk.Appearance.Options.UseFont = true; + this.btnOk.Location = new System.Drawing.Point(357, 5); + this.btnOk.Margin = new System.Windows.Forms.Padding(4); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(76, 35); + this.btnOk.TabIndex = 23; + this.btnOk.TabStop = false; + this.btnOk.Text = "确定(&O)"; + // + // gcMain + // + this.gcMain.AdapterObj = null; + this.gcMain.BackColor = System.Drawing.Color.Transparent; + this.gcMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.gcMain.Location = new System.Drawing.Point(0, 34); + this.gcMain.Margin = new System.Windows.Forms.Padding(5); + this.gcMain.Name = "gcMain"; + this.gcMain.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gcMain.Size = new System.Drawing.Size(535, 369); + this.gcMain.SysModel = null; + this.gcMain.TabIndex = 16; + // + // FrmDocumentSource + // + this.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.Appearance.Options.UseBackColor = true; + this.Appearance.Options.UseFont = true; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.splitMain); + this.Name = "FrmDocumentSource"; + this.Text = "FrmDocumentSource"; + ((System.ComponentModel.ISupportInitialize)(this.splitMain)).EndInit(); + this.splitMain.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_left)).EndInit(); + this.pl_left.ResumeLayout(false); + this.pl_left_main.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_gridandtree_container)).EndInit(); + this.pl_gridandtree_container.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_left_top)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pl_top)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit(); + this.panelControl1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private DevExpress.XtraEditors.SplitContainerControl splitMain; + private DevExpress.XtraEditors.PanelControl pl_left; + private System.Windows.Forms.Panel pl_left_main; + private DevExpress.XtraEditors.PanelControl pl_gridandtree_container; + private Control.TreeViewEx treeLeft; + private Control.GridControlEx gridLeft; + private DevExpress.XtraEditors.PanelControl pl_left_top; + private Control.GridControlEx gcMain; + private DevExpress.XtraEditors.PanelControl panelControl1; + private DevExpress.XtraEditors.SimpleButton btnCancel; + private DevExpress.XtraEditors.SimpleButton btnOk; + private DevExpress.XtraEditors.PanelControl pl_top; + } +} \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/FrmDocumentSource.cs b/插件库/Lskj.PubBillManagement/FrmDocumentSource.cs new file mode 100644 index 0000000..a47517b --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmDocumentSource.cs @@ -0,0 +1,601 @@ +using DevExpress.XtraEditors; +using DevExpress.XtraGrid.Columns; +using DevExpress.XtraGrid.Views.Grid; +using Lskj.Business; +using Lskj.Business.Impl; +using Lskj.Control; +using Lskj.Control.Model; +using Lskj.Data; +using Lskj.Model; +using Lskj.Util; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Data.SqlClient; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Lskj.PubBillManagement +{ + public partial class FrmDocumentSource : BaseForm + { + + + + /// + /// 配置的关联ModuleCodel值 + /// + /// The Union ModuleCodel. + public string UnionModuleCodel; + /// + /// 左侧树数据 + /// + public DataRow LeftRowObj; + /// + /// 系统模块实体对象 + /// + /// The system model. + public ModuleModel SysModel { get; private set; } + /// + /// 自定义查询条件 + /// + public MyControl SearchObj { get; private set; } + /// + /// 第一次进入 + /// + private bool isFirst = true; + /// + /// 第一次进入 + /// + private bool isFirstSearch = true; + /// + /// 左侧树结构 + /// + public TreeViewEx LeftTreeViewEx; + /// + /// 左侧表格 + /// + public GridControlEx LeftGridEx; + /// + /// 左侧结构关联字段 + /// + public string ParentUnionField; + /// + /// 左侧树结构、表格主键 + /// + public string ParentKeyField; + /// + /// CurrentOperColumnKey值(保存表格属性会用) + /// + /// The data source. + public string CurrentOperColumnKey = string.Empty; + /// + /// 左侧表格查询条件 + /// + private MyControl _leftGridSearchObj; + /// + /// 返回行 + /// + public DataRow[] DataRows = null; + + + public FrmDocumentSource(string ModuleCodel) + { + InitializeComponent(); + this.UnionModuleCodel = ModuleCodel; + this.Disposed += new EventHandler(OnFrmModelLookUp_Disposed); + this.gcMain.GridView.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown; + + DataRow modelRow = MainImpl.GetSystemdllTab(this.UnionModuleCodel);//获取单个模块信息 + if (modelRow == null) + { + MessageUtil.Show("模块编号[" + UnionModuleCodel + "],配置错误!\r\n该模块信息未找到!"); + return; + } + + this.SysModel = new ModuleModel(modelRow);// 系统模块实体对象 + //设置关联模块(左侧) + this.InitLeftControls(); + //设置主表 + this.InitMainControls(); + + this.btnCancel.Click += btnCancel_Click; + this.btnOk.Click += btnOk_Click; + } + + + /// + /// 初始化左侧表 + /// + public void InitLeftControls() + { + if (this.SysModel != null) + { + switch (this.SysModel.MenuType) + { + case 1: // 左侧为树节点 + this.pl_left_top.Visible = false; + this.gridLeft.Visible = false; + this.treeLeft.Visible = true; + this.InitlizeSpiltLocation();//设置分割条位置 + this.SetLeftTreeView();//设置左侧树数据 + this.LeftTreeViewEx = this.treeLeft; + break; + case 2: // 左侧为表格 + this.gridLeft.Visible = true; + this.treeLeft.Visible = false; + this.InitlizeSpiltLocation(); + this.SetLeftGridView(); + this.LeftGridEx = this.gridLeft; + break; + case 3: // 左侧为空 + default: + this.splitMain.PanelVisibility = SplitPanelVisibility.Panel2; + break; + } + + } + else + { + this.splitMain.PanelVisibility = SplitPanelVisibility.Panel2; + } + + + } + + /// + /// 初始化主表 + /// + public void InitMainControls() + { + + //设置上方条件 + this.pl_top.Controls.Clear(); + DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(this.SysModel.CondKey);//加载自定义配置字段 + this.SearchObj = new MyControl(this.SysModel.MenuSql, this.gcMain, LeftTreeViewEx, LeftGridEx); + this.SearchObj.ParentKeyField = this.ParentKeyField; + this.SearchObj.ParentUnionField = this.ParentUnionField; + this.SearchObj.OnDataSourceBindCallBack += new EventHandler(OnFirstPageDataSourceBindCallBack); + this.SearchObj.OnSearchAfterCallBack += new EventHandler(OnSearchAfterd); + this.pl_top.Height = 0; + this.pl_top.Height = this.SearchObj.InitSearchControl(queryTable, this.pl_top); + //创建表格列 + DataTable _gridColumns = BaseModuleImpl.GetBaseGridColumns(this.UnionModuleCodel); + this.gcMain.SetReadOnlyColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + this.SysModel.FormKey); + //this.SetCustomColumns(); + //设置复选框 + GridDragGrid.GridAddCheckBox(gcMain.GridView); + //右键 + DataTable dt = BaseModuleImpl.GetBaseGridRightMenus(this.UnionModuleCodel); + string[] obj = new string[]{ + "", + ERPInfo.Instance.UserId, + ERPInfo.Instance.UserName, + "3", + this.UnionModuleCodel, + }; ; + DynamicModel dynamicModel = new DynamicModel(obj); + this.gcMain.SetGridRightMenus(dt, dynamicModel, this.OnGridViewRightCallBack, this.SearchObj, null); + //this.gcMain.GridView.OptionsView.ColumnAutoWidth = true; + + + } + + + /// + /// 查询后清空复选框勾选 + /// + /// + /// + private void OnSearchAfterd(object sender, EventArgs e) + { + this.gcMain.GridView.ClearSelection(); + } + + /// + /// 初始化后默认查询 + /// + /// + /// + private void OnFirstPageDataSourceBindCallBack(object sender, EventArgs e) + { + //打开时默认选中第一条 + if (LeftTreeViewEx != null && LeftTreeViewEx.TreeView.Nodes.Count > 0) + { + LeftTreeViewEx.TreeView.SelectedNode = LeftTreeViewEx.TreeView.Nodes[0]; + LeftTreeViewEx.TreeView.Nodes[0].Expand(); + } + else if (LeftGridEx != null) + { + LeftGridEx.GridView.SelectRow(0); + } + this.SearchObj.SearchGrid(); + } + + + + #region 设置分割条位置 + /// + /// 说明:设置分割条位置 + /// 创建人:王一帆 + /// 创建日期:2021-07-21 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + protected void InitlizeSpiltLocation() + { + try + { + string width = IniHelper.Read(string.Format("bill_Special_Width_{0}", this.UnionModuleCodel));//通过Key获取Value值 + if (!string.IsNullOrEmpty(width)) + { + this.splitMain.SplitterPosition = Convert.ToInt32(width); + + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + MessageUtil.Show(ex); + } + } + #endregion + #region 保存表格属性 + /// + /// 说明:保存表格属性 + /// 创建人:王一帆 + /// 创建日期:2021-07-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + protected virtual void SaveItemClick(object sender, EventArgs e) + { + DataRow rowItem = null; + bool success = BaseImpl.HasExistsDataRow(ResourceKeys.SettingTableName, "formKey", CurrentOperColumnKey, string.Format(" and OperatorId='{0}' ", ERPInfo.Instance.UserId), out rowItem); + if (!success) + { + MessageUtil.Show(ResourceKeys.NotFoundSettingColumnTable); + return; + } + + if (MessageUtil.Show(ResourceKeys.IsSaveColumn, MessageBoxButtons.YesNo) == DialogResult.Yes) + { + try + { + if (rowItem == null) + { + success = this.gcMain.GridView.SaveCustomColumnToDatabase(this.CurrentOperColumnKey); + } + else + { + success = this.gcMain.GridView.UpdateCustomColumnToDatabase(this.CurrentOperColumnKey); + } + MessageUtil.Show(success ? ResourceKeys.SaveSuccess : ResourceKeys.SaveFault); + } + catch (SqlException sex) + { + if (sex.Message.Contains(ResourceKeys.FieldLenIsShort) && + MessageUtil.Show(ResourceKeys.SaveFault + "\r\n" + ResourceKeys.CanUpgradeTable, MessageBoxButtons.YesNo) == DialogResult.Yes && + BaseImpl.UpdateTableField(ResourceKeys.SettingTableName, "formKey", "varchar(200)")) + { + MessageUtil.Show(ResourceKeys.UpdateSuccess); + } + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + LogUtil.WriteError("保存表格属性出错", ex); + MessageUtil.Show(ex); + } + } + } + #endregion + + + + #region 加载自定义列 + /// + /// 说明:加载自定义列 + /// 创建人:王一帆 + /// 创建日期:2019-9-16 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + private void SetCustomColumns() + { + if (string.IsNullOrEmpty(this.CurrentOperColumnKey) || !BaseImpl.HasExistsTable(ResourceKeys.SettingTableName)) return; + + DataTable customTable = this.gcMain.GridView.GetCustomColumnByDatabase(this.CurrentOperColumnKey); + if (customTable != null && customTable.Rows.Count > 0) + { + foreach (DataRow rowItem in customTable.Rows) + { + string fieldName = rowItem["fieldName"] + ""; + int fieldWidth = Convert.ToInt32(rowItem["fieldWidth"]); + int index = Convert.ToInt32(rowItem["orderid"]); + bool visible = "1".Equals(rowItem["isVisible"] + "") && fieldWidth > 0; + bool isFix = "True".Equals(rowItem["IfFixColumn"] + "", StringComparison.OrdinalIgnoreCase); + + GridColumn gridColumn = this.gcMain.GridView.Columns.ColumnByName(fieldName); + if (gridColumn != null && gridColumn.Visible && gridColumn.Width > 0) + { + GridColumn colObj = this.gcMain.GridView.Columns[fieldName]; + colObj.VisibleIndex = index; + colObj.Width = fieldWidth; + colObj.Visible = visible; + colObj.Fixed = isFix ? FixedStyle.Left : FixedStyle.None; + } + } + } + } + #endregion + + #region 刷新左侧树数据 + /// + /// 说明:设置左侧树数据 + /// 创建人:王一帆 + /// 创建日期:2021-07-21 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + protected void SetLeftTreeView() + { + this.LeftRowObj = BaseModuleImpl.GetBaseLeftTreeField(this.UnionModuleCodel);//获取表格左侧树字段 + if (this.LeftRowObj != null) + { + //this.ModuleGridObj.ParentUnionField = this.LeftRowObj["fieldname"] + ""; + this.ParentUnionField = this.LeftRowObj["fieldname"] + ""; + this.ParentKeyField = this.LeftRowObj["fieldsqlid"] + ""; + this.treeLeft.TreeNodeKeyField = this.LeftRowObj["fieldsqlid"] + ""; + this.treeLeft.TreeNodeTextField = this.LeftRowObj["fieldsqlname"] + ""; + this.treeLeft.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeLeftTreeNodeSelected); + this.treeLeft.BindTreeView(BaseImpl.GetDataTableResult(this.LeftRowObj["fieldsql"] + "")); + } + else + { + // 根据模块上配置的sql加载树 + if (this.SysModel != null && !string.IsNullOrEmpty(this.SysModel.TreeSQL)) + { + this.ParentUnionField = "SpeciesNo"; + this.ParentKeyField = "SpeciesNo"; + this.treeLeft.TreeNodeKeyField = "SpeciesNo"; + this.treeLeft.TreeNodeTextField = "SpeciesName"; + this.treeLeft.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeLeftTreeNodeSelected); + this.treeLeft.BindTreeView(BaseImpl.GetDataTableResult(this.SysModel.TreeSQL)); + } + } + } + /// + /// 说明:树节点点击后刷新数据 + /// 创建人:龚宇超 + /// 创建日期:2017-10-26 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnTreeLeftTreeNodeSelected(object sender, TreeViewEventArgs e) + { + string where = string.Format(" and {0} like '{1}%' ", this.treeLeft.TreeNodeKeyField, e.Node.Name); + + string sqlValue = ReplaceHelper.IsProcedure(this.SysModel.MenuSql) ? + ReplaceHelper.ReplaceTreeViewParentKeyCond(this.SysModel.MenuSql, treeLeft.GetSelectNodeValue()) : + ReplaceHelper.ReplaceWhereCond(this.SysModel.MenuSql) + where; + //this.gcMain.gridControl.DataSource = MainImpl.GetDataTableResult(sqlValue); + this.SearchObj.SearchGrid(sqlValue); + this.gcMain.GridView.ClearSelection(); + } + + + + #region 设置左侧表格数据 + /// + /// 说明:设置左侧表格数据 + /// 创建人:龚宇超 + /// 创建日期:2017-10-25 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + protected void SetLeftGridView() + { + this.LeftRowObj = BaseModuleImpl.GetBaseLeftTreeField(UnionModuleCodel);//获取表格左侧树字段 + if (this.LeftRowObj != null) + { + DataTable dtTable = BaseModuleImpl.GetBaseLeftGridField(UnionModuleCodel); + DataTable dtColorTable = BaseModuleImpl.GetBaseGridRowColors(this.LeftRowObj["fieldKey"] + ""); + this.gridLeft.GridView.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(OnGridViewRowClick); + this.gridLeft.SetGridRowColors(dtColorTable); + this.gridLeft.SetReadOnlyColumns(dtTable, GridCustomColumnStruct.BaseLeftGridView + UnionModuleCodel); + this.ParentUnionField = this.LeftRowObj["fieldname"] + ""; + this.ParentKeyField = this.LeftRowObj["fieldsqlid"] + ""; + + //this.ModuleGridObj.ParentKeyField = this.LeftRowObj["fieldsqlid"] + ""; + //this.ModuleGridObj.ParentUnionField = this.LeftRowObj["fieldname"] + ""; + + DataTable table = BaseModuleImpl.GetCustomQueryFields(this.LeftRowObj["fieldKey"] + ""); + string searchSql = this.LeftRowObj["fieldsql"] + ""; + if (table != null && table.Rows.Count > 0) + { + // 自定义查询条件 + + this._leftGridSearchObj = new MyControl(searchSql, this.gridLeft); + this.pl_left_top.Height = this._leftGridSearchObj.InitSearchControl(table, this.pl_left_top); + this._leftGridSearchObj.OnDataSourceBindCallBack += new EventHandler(OnLeftControlObjDataSourceBindCallBack); + } + else + { + DataTable leftGridCondtionTable = BaseImpl.GetDataTableResult(searchSql); + this.pl_left_top.Visible = false; + this.gridLeft.GridControl.DataSource = leftGridCondtionTable; + } + + } + } + #endregion + + + #region 刷新右侧表格数据 + /// + /// 说明:刷新右侧表格数据 + /// 创建人:龚宇超 + /// 创建日期:2018-03-19 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnGridViewRowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) + { + try + { + string sqlValue = ReplaceHelper.ReplaceWhereCond(this.SysModel.MenuSql); + if (this.gridLeft.Visible) + { + DataRow rowitem = this.gridLeft.GridView.GetFocusedDataRow(); + sqlValue = this._leftGridSearchObj != null ? this._leftGridSearchObj.ReplaceParentControlValue(sqlValue) : sqlValue; + sqlValue = ReplaceHelper.ReplaceRowParam(rowitem, sqlValue); + } + + this.SearchObj.SearchGrid(sqlValue); + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + } + #endregion + #endregion + #region 事件 + + /// + /// 说明:数据绑定完成后加载数据 + /// 创建人:龚宇超 + /// 创建日期: + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + protected void OnLeftControlObjDataSourceBindCallBack(object sender, EventArgs e) + { + try + { + this._leftGridSearchObj.SearchGrid(); + + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + } + + #region 确定 + /// + /// 说明:确定 + /// 创建人:龚宇超 + /// 创建日期:2018-03-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void btnOk_Click(object sender, EventArgs e) + { + + this.DataRows = gcMain.GetViewFocusedDataRows(); + if (DataRows.Length > 0) + { + this.DialogResult = System.Windows.Forms.DialogResult.OK; + } + this.Close(); + } + #endregion + + #region 取消 + /// + /// 说明:取消 + /// 创建人:龚宇超 + /// 创建日期:2018-03-20 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The source of the event. + /// The instance containing the event data. + private void btnCancel_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + } + #endregion + + #region 释放时清理数据源 + /// + /// 说明:释放时清理数据源 + /// 创建人:龚宇超 + /// 创建日期:2018-03-16 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + private void OnFrmModelLookUp_Disposed(object sender, EventArgs e) + { + GC.Collect(); + } + #endregion + #endregion + + /// + /// 说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新 + /// 创建人:龚宇超 + /// 创建日期:2017-11-02 + /// 修改人: + /// 修改日期: + /// 修改备注: + /// 版本:1.0 + /// + /// The sender. + /// The instance containing the event data. + protected void OnGridViewRightCallBack(object sender, EventArgs e) + { + try + { + this.SearchObj.SearchLastGrid(); + + } + catch (Exception ex) + { + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + + } + + + } +} diff --git a/插件库/Lskj.PubBillManagement/FrmDocumentSource.resx b/插件库/Lskj.PubBillManagement/FrmDocumentSource.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmDocumentSource.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/FrmMain.Designer.cs b/插件库/Lskj.PubBillManagement/FrmMain.Designer.cs new file mode 100644 index 0000000..fcea0c3 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmMain.Designer.cs @@ -0,0 +1,64 @@ +namespace Lskj.PubBillManagement +{ + partial class FrmMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.billModule1 = new Lskj.PubBillManagement.BillModule(); + this.SuspendLayout(); + // + // billModule1 + // + this.billModule1.Dock = System.Windows.Forms.DockStyle.Fill; + this.billModule1.Location = new System.Drawing.Point(0, 0); + this.billModule1.Margin = new System.Windows.Forms.Padding(4); + this.billModule1.Name = "billModule1"; + this.billModule1.Size = new System.Drawing.Size(1579, 912); + this.billModule1.TabIndex = 0; + // + // FrmMain + // + this.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.Appearance.Options.UseBackColor = true; + this.Appearance.Options.UseFont = true; + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.ClientSize = new System.Drawing.Size(1579, 912); + this.Controls.Add(this.billModule1); + this.Margin = new System.Windows.Forms.Padding(5); + this.Name = "FrmMain"; + this.Text = "单据模版"; + this.ResumeLayout(false); + + } + + #endregion + + private BillModule billModule1; + + + } +} \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/FrmMain.cs b/插件库/Lskj.PubBillManagement/FrmMain.cs new file mode 100644 index 0000000..f5bcc76 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmMain.cs @@ -0,0 +1,186 @@ +/****************************** +* 说明:单据模版 +* 创建人:龚宇超 +* 创建日期:2017-11-23 +* 修改人: +* 修改日期: +* 修改备注: +* 版本:1.0.0.0 +******************************/ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Lskj.Control; +using Lskj.Model; +using Lskj.Control.Model; +using Lskj.Util; +using Lskj.Business.Impl; +using DevExpress.XtraGrid.Views.Grid; +using Lskj.Data; +using DevExpress.XtraBars; +using DevExpress.XtraTab; +using DevExpress.XtraEditors; +using System.Collections; +using Lskj.PubBillManagement.Model; +using DevExpress.Data; +using DevExpress.XtraGrid.Columns; +using System.IO; +using Lskj.Business; +using Lskj.Main.Model; +using System.Threading.Tasks; +using Lskj.Core; + +namespace Lskj.PubBillManagement +{ + /// + /// 单据模版 + /// + public partial class FrmMain : BaseForm + { + /// + /// 入口参数 + /// + public DynamicBillModel SysModel; + /// + /// 第一次进入页面 + /// + public bool isInitialization = true; + + + public FrmMain() + { + InitializeComponent(); + } + + protected override void OnLoad(EventArgs e) + { + try + { + WaitForm.ShowForm(); + Dictionary dataCaches = SysModel != null ? SysModel.DataCaches : null; + if (!dataCaches.GetValue(this, "Privilege", out string privilege)) + { + privilege = SysModel.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(SysModel.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(SysModel.ModuleCode) + ""; + } + this.SysModel.Privilege = privilege; + + if (!this.SysModel.HasPrivilege()) + { + MessageUtil.Show(ResourceKeys.UnPurview); + this.Close(); + } + else + { + billModule1.OnLoad(SysModel); + // 右键菜单调用方式,则模块名称按照系统设置设定 + if (!string.IsNullOrEmpty(this.SysModel.BillMasterSql) || + !string.IsNullOrEmpty(this.SysModel.BillDetailSql) || + !string.IsNullOrEmpty(this.SysModel.BillOrderNo)) + { + + this.Text = this.billModule1.BillModel.TypeName; + if (this.SysModel.BillDetailSql.StartsWith("*")) + { + string rightid = this.SysModel.BillDetailSql.TrimStart('*'); + string sqlValue = "select AllowNullExec,* from p_systempopupmenu "; + sqlValue = $"{sqlValue} where id = '{rightid}'"; + DataRow rowItem = BaseImpl.GetDataRowResult(sqlValue); + //if (rowItem != null) + //{ + // CommonMenu menu = new CommonMenu(this.SysModel, this.billModule1.ControlObj, this.billModule1.gcMainDetilObj); + // menu.DynamicLinkAfter += new CommonToolAfterDynamicLinkEventHandler(OnDynamicLinkAfter); + // menu.Apply(rowItem); + //} + } + } + this.FormClosing += new FormClosingEventHandler(OnClose); + } + + + } + catch (Exception ex) + { + LogHelper.Instance.WriteError(ex); + //MessageUtil.Show(ex); + string Message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(Message, ex.Message); + } + finally + { + + Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this); + WaitForm.HideForm(); + } + } + /// + /// 执行完成后若是取消状态则关闭当前界面 + /// + /// + private void OnDynamicLinkAfter(object sender, ApplyArgs e) + { + if (e.DialogModel != null && e.DialogModel.PubDialogType == DialogType.Pubcolsed) + { + this.Close(); + } + } + + + /// + /// 获取数据源缓存 + /// + /// + public void GetDataCaches(Dictionary cachesDic) + { + //全局数据 + Task dynamicModelTask = cachesDic.AddTask(this, "DynamicModel", new Task(() => + { + return SysModel;//动态链接库对象 + })); + Task systemDllRowTask = cachesDic.AddTask(this, "SystemDllRow", new Task(() => + { + return MainImpl.GetSystemdllTab(SysModel.ModuleCode);//获取单个模块信息 + })); + Task sysModelTask = cachesDic.AddTask(this, "SysModel", new Task(() => + { + ModuleModel sysModel = new ModuleModel(systemDllRowTask.Result); + return sysModel;//系统模块实体对象 + })); + Task formTypeTask = cachesDic.AddTask(this, "FormType", new Task(() => + { + return BaseImpl.GetBillDetailType(SysModel.ModuleCode); + })); + Task privilegeTask = cachesDic.AddTask(this, "Privilege", new Task(() => + { + return SysModel.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(SysModel.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(SysModel.ModuleCode) + ""; + })); + //获取billModule1控件的数据 + if (dynamicModelTask.Result.HasPrivilege()) + { + //添加数据到billModule1 + cachesDic.AddTask(billModule1, "DynamicModel", dynamicModelTask); + cachesDic.AddTask(billModule1, "SystemDllRow", systemDllRowTask); + cachesDic.AddTask(billModule1, "SysModel", sysModelTask); + billModule1.GetDataCaches(cachesDic); + } + } + + + + + + private void OnClose(object sender, FormClosingEventArgs e) + { + string guid = this.Tag + ""; + if (string.IsNullOrWhiteSpace(guid)) return; + DllModule m = Manager.ModuleForms[guid]; + m.IsClose = true; + + + } + } +} \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/FrmMain.resx b/插件库/Lskj.PubBillManagement/FrmMain.resx new file mode 100644 index 0000000..c8a3129 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmMain.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 44 + + \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/FrmScanCodeAssociation.Designer.cs b/插件库/Lskj.PubBillManagement/FrmScanCodeAssociation.Designer.cs new file mode 100644 index 0000000..62c2576 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmScanCodeAssociation.Designer.cs @@ -0,0 +1,98 @@ + +namespace Lskj.PubBillManagement +{ + partial class FrmScanCodeAssociation + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.plm_bottom = new DevExpress.XtraEditors.PanelControl(); + this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton(); + this.gcMain = new Lskj.Control.GridControlEx(); + ((System.ComponentModel.ISupportInitialize)(this.plm_bottom)).BeginInit(); + this.plm_bottom.SuspendLayout(); + this.SuspendLayout(); + // + // plm_bottom + // + this.plm_bottom.Controls.Add(this.simpleButton1); + this.plm_bottom.Dock = System.Windows.Forms.DockStyle.Bottom; + this.plm_bottom.Location = new System.Drawing.Point(0, 410); + this.plm_bottom.Margin = new System.Windows.Forms.Padding(4); + this.plm_bottom.Name = "plm_bottom"; + this.plm_bottom.Size = new System.Drawing.Size(800, 40); + this.plm_bottom.TabIndex = 18; + // + // simpleButton1 + // + this.simpleButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.simpleButton1.Appearance.Font = new System.Drawing.Font("宋体", 9F); + this.simpleButton1.Appearance.Options.UseFont = true; + this.simpleButton1.Location = new System.Drawing.Point(696, 6); + this.simpleButton1.Margin = new System.Windows.Forms.Padding(4); + this.simpleButton1.Name = "simpleButton1"; + this.simpleButton1.Size = new System.Drawing.Size(90, 30); + this.simpleButton1.TabIndex = 41; + this.simpleButton1.Text = "确定"; + this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click); + // + // gcMain + // + this.gcMain.AdapterObj = null; + this.gcMain.BackColor = System.Drawing.Color.Transparent; + this.gcMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.gcMain.Location = new System.Drawing.Point(0, 0); + this.gcMain.Margin = new System.Windows.Forms.Padding(5); + this.gcMain.Name = "gcMain"; + this.gcMain.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gcMain.Size = new System.Drawing.Size(800, 410); + this.gcMain.TabIndex = 21; + // + // FrmScanCodeAssociation + // + this.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.Appearance.Options.UseBackColor = true; + this.Appearance.Options.UseFont = true; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.gcMain); + this.Controls.Add(this.plm_bottom); + this.Name = "FrmScanCodeAssociation"; + this.Text = "串码选择"; + ((System.ComponentModel.ISupportInitialize)(this.plm_bottom)).EndInit(); + this.plm_bottom.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private DevExpress.XtraEditors.PanelControl plm_bottom; + private DevExpress.XtraEditors.SimpleButton simpleButton1; + private Control.GridControlEx gcMain; + } +} \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/FrmScanCodeAssociation.cs b/插件库/Lskj.PubBillManagement/FrmScanCodeAssociation.cs new file mode 100644 index 0000000..d1c4ddf --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmScanCodeAssociation.cs @@ -0,0 +1,82 @@ +using Lskj.Business.Impl; +using Lskj.Control; +using Lskj.Control.Model; +using Lskj.Core; +using Lskj.Model; +using Lskj.Util; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Lskj.PubBillManagement +{ + public partial class FrmScanCodeAssociation : BaseForm + { + + /// + /// 系统模块实体对象 + /// + /// The system model. + public ModuleModel SysModel { get; private set; } + /// + ///主表条件控件 + /// + public MyControl SearchMainObj; + /// + ///扫码内容 + /// + public string ScanCodeData; + /// + //选中的串码 + /// + public string StringCodes; + + public FrmScanCodeAssociation() + { + InitializeComponent(); + } + + public FrmScanCodeAssociation(DataRow modelRow, string scanCodeData) + { + InitializeComponent(); + this.ScanCodeData = scanCodeData; + //根据传入的模块号获取模块信息 + this.SysModel = new ModuleModel(modelRow); + DataTable mainGridColumns = BaseModuleImpl.GetBaseGridColumns(this.SysModel.ModeCode); + this.gcMain.SetReadOnlyColumns(mainGridColumns, GridCustomColumnStruct.BaseMainGridView + this.SysModel.FormKey);//创建列 + string sql = ReplaceHelper.ReplaceParamToValue(SysModel.MenuSql, "{value}", this.ScanCodeData); + DataTable dt = BillImpl.GetDataTableResult(sql); + this.gcMain.GridControl.DataSource = dt; + //加载复选框 + GridDragGrid.GridAddCheckBox(this.gcMain.GridView); + + } + + + + private void simpleButton1_Click(object sender, EventArgs e) + { + DataRow[] dataRows = this.gcMain.GetViewFocusedDataRows(); + if (dataRows.Length > 0) + { + string name=this.gcMain.GridView.Columns[0].FieldName; + string text = string.Empty; + for (int i = 0; i < dataRows.Length; i++) + { + text += dataRows[i][name] + ";"; + } + + StringCodes = text.Trim(';'); + this.Close(); + this.DialogResult = System.Windows.Forms.DialogResult.OK; + } + + } + + } +} diff --git a/插件库/Lskj.PubBillManagement/FrmScanCodeAssociation.resx b/插件库/Lskj.PubBillManagement/FrmScanCodeAssociation.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/FrmScanCodeAssociation.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/Lskj.PubBillManagement.csproj b/插件库/Lskj.PubBillManagement/Lskj.PubBillManagement.csproj new file mode 100644 index 0000000..92aa296 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/Lskj.PubBillManagement.csproj @@ -0,0 +1,209 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {6CE319BA-1253-41F2-8B59-8173FD7BE3F3} + Library + Properties + Lskj.PubBillManagement + Lskj.PubBillManagement + v4.0 + 512 + + + + + true + full + false + ..\..\Debug\Lib\ + DEBUG;TRACE + prompt + 4 + ..\..\Debug\AllMethodXml\Lskj.PubBill.XML + + + none + true + ..\..\Release\Lib\ + TRACE + prompt + 4 + + + + + + + + False + + + + + + + False + C:\Program Files\DevExpress 15.2\Components\Bin\Framework\DevExpress.XtraTreeList.v15.2.dll + + + False + ..\..\引用DLL\Lskj.Data.ADO.dll + + + False + ..\..\引用DLL\Lskj.Data.Api.dll + + + False + ..\..\引用DLL\Lskj.Web.Core.dll + + + False + ..\..\引用DLL\Lskj.WebErp.Core.dll + + + False + ..\..\引用DLL\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + UserControl + + + BillModule.cs + + + Form + + + FrmAdd.cs + + + Form + + + FrmBill.cs + + + Form + + + FrmBomSelect.cs + + + Form + + + FrmDocumentSource.cs + + + Form + + + FrmScanCodeAssociation.cs + + + + + + Form + + + FrmMain.cs + + + + + + + + BillModule.cs + Designer + + + FrmAdd.cs + + + FrmBill.cs + + + FrmBomSelect.cs + + + FrmDocumentSource.cs + + + FrmMain.cs + + + FrmScanCodeAssociation.cs + + + + + + {7EAFCCC2-A18F-49E9-85C6-A984966CFD01} + Lskj.Business + + + {447cdc40-659f-4cca-9ed6-8e818b4cf8bf} + Lskj.Control + + + {2a1be6ac-1077-491b-a754-c5822fe8121e} + Lskj.Core + + + {308B9B18-9BE2-495C-9C64-EED81D567813} + Lskj.Data + + + {24e9a18a-baf8-4052-809e-582b4fc6a8c4} + Lskj.Interface.Api + + + {bca1e2b3-c4ab-4d2c-b519-3dcfdb5b83d6} + Lskj.Main + + + {52BC40E0-C0C6-4F78-996B-CAE028D209CA} + Lskj.Model + + + {A51BF642-6543-4DE3-8948-83F558B72BD4} + Lskj.Util + + + + + + + + + + + + \ No newline at end of file diff --git a/插件库/Lskj.PubBillManagement/Model/BillModuleModel.cs b/插件库/Lskj.PubBillManagement/Model/BillModuleModel.cs new file mode 100644 index 0000000..3e1e16b --- /dev/null +++ b/插件库/Lskj.PubBillManagement/Model/BillModuleModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Lskj.PubBillManagement.Model +{ + public class BillModuleModel + { + public BillSourceModel SourceModel { get; set; } + public object SourceControl { get;set; } + public object SourceDetailControl { get; set; } + public object SourceDetailDetailControl { get; set; } + } +} diff --git a/插件库/Lskj.PubBillManagement/Model/BillSourceModel.cs b/插件库/Lskj.PubBillManagement/Model/BillSourceModel.cs new file mode 100644 index 0000000..c3eee2f --- /dev/null +++ b/插件库/Lskj.PubBillManagement/Model/BillSourceModel.cs @@ -0,0 +1,133 @@ +/****************************** +* 说明:单据来源对象 +* 创建人:龚宇超 +* 创建日期:2017-11-28 +* 修改人: +* 修改日期: +* 修改备注: +* 版本:1.0.0.0 +******************************/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Data; + +namespace Lskj.PubBillManagement.Model +{ + /// + /// 单据来源对象 + /// + public class BillSourceModel + { + public int Id { get; private set; } + public int SourceType { get; private set; } + public int LoadBom { get; private set; } + public bool CadDragDetail { get; private set; } + public string UserName { get; private set; } + public string FormKey { get; private set; } + public string SourceKeyField { get; private set; } + public string SourceResult { get; private set; } + public string SourceSql { get; private set; } + public string DetailSql { get; private set; } + public string BomSql { get; private set; } + public string BomCaption { get; private set; } + public string DetailEnableCond { get; private set; } + public string CodeInputSql { get; private set; } + public string CodeInputCaption { get; private set; } + public string CodeInputHint { get; private set; } + public string SearchDefaultField { get; private set; } + public string DetailEnableMsg { get; private set; } + public bool SaveRefreshFlag { get; private set; } + public string SourceDetailsDetailsSql { get; private set; }//来源明细的明细 + public string sourceDetailType { get; private set; }//来源明细的类型 + public bool DisableShowSourceCount { get; private set; }//是否显示来源数量 + public string AddDataSql { get; private set; }// 添加数据sql(来源明细添加到主表明细时,执行sql把查询数据源一并添加到来源明细中) + public string AddDataCondition { get; private set; }// 添加数据条件 + public bool LoadFilter { get; private set; }//来源筛选行是否显示 + public bool DetailedLoadFilter { get; private set; }//来源明细筛选行是否显示 + + public bool DetailsDoubleClick;// 单据来源刷新来源明细模式,默认单击,1为双击 + + public string MainDetailsAddType;// 主表明细新增模式 (默认来源明细和来源明细的明细都可以添加到主表, 1为来源明细添加 2为来源明细的明细添加) + + public string SourceKeyFieldName;// 节点id(来源主表为树表格时) + + public string SourceParentFieldName;// 父节点id(来源主表为树表格时 ) + + public bool DragAndSave;// 拖拽后保存 + + public bool TreeInhibitSort;// 树节点 禁用默认排序 + + public string Orderid;// 来源页签序号 + + public string DetailMenuCode;// 来源模块号 + + + + public BillSourceModel(DataRow item) + { + if (item == null) return; + + this.Id = Convert.ToInt32(item["Id"] + ""); + this.SourceType = string.IsNullOrEmpty(item["sourceType"] + "") ? 0 : Convert.ToInt32(item["sourceType"] + ""); + this.LoadBom = string.IsNullOrEmpty(item["loadbom"] + "") ? 0 : Convert.ToInt32(item["loadbom"] + ""); + this.CadDragDetail = item.Table.Columns.Contains("dragDetailEnable") ? "1" != item["dragDetailEnable"] + "" : true; + this.UserName = item["userName"] + ""; + if (Business.Impl.LanguageTranslation.Translatable) + { + this.UserName = Business.Impl.LanguageTranslation.GetTranslatedText(this.UserName); + } + + this.FormKey = item["FormKey"] + ""; + this.SourceKeyField = item["sourceKeyField"] + ""; + this.SourceResult = item["sourceResult"] + ""; + this.SourceSql = item["SourceSql"] + ""; + this.DetailSql = item["DetailSql"] + ""; + this.BomSql = item["BomSql"] + ""; + this.BomCaption = item["BomCaption"] + ""; + this.DetailEnableCond = item["DetailEnableCond"] + ""; + this.CodeInputSql = item["CodeInputSql"] + ""; + this.CodeInputCaption = item["CodeInputCaption"] + ""; + this.CodeInputHint = item["CodeInputHint"] + ""; + this.SearchDefaultField = item["SearchDefault"] + ""; + this.DetailEnableMsg = item["DetailEnableMsg"] + ""; + this.SaveRefreshFlag = item.Table.Columns.Contains("SaveRefreshFlag") && "1".Equals(item["SaveRefreshFlag"] + "") ? true : false; + this.SourceDetailsDetailsSql = item.Table.Columns.Contains("detailSQL1") ? item["detailSQL1"] + "" : ""; + this.sourceDetailType = item.Table.Columns.Contains("sourceDetailType") ? item["sourceDetailType"] + "" : ""; + this.DisableShowSourceCount = item.Table.Columns.Contains("DisableShowSourceCount") && "1".Equals(item["DisableShowSourceCount"] + "") ? true : false; + + this.AddDataSql = item.Table.Columns.Contains("AddDataSql") ? item["AddDataSql"] + "" : ""; + this.AddDataCondition = item.Table.Columns.Contains("AddDataCondition") ? item["AddDataCondition"] + "" : ""; + + this.LoadFilter = item.Table.Columns.Contains("LoadFilter") && "1".Equals(item["LoadFilter"] + "") ? true : false; + this.DetailedLoadFilter = item.Table.Columns.Contains("DetailedLoadFilter") && "1".Equals(item["DetailedLoadFilter"] + "") ? true : false; + this.DetailsDoubleClick = item.Table.Columns.Contains("DetailsDoubleClick") && "1".Equals(item["DetailsDoubleClick"] + "") ? true : false; + this.MainDetailsAddType = item.Table.Columns.Contains("MainDetailsAddType") ? item["MainDetailsAddType"] + "" : ""; + + this.SourceKeyFieldName = item.Table.Columns.Contains("SourceKeyFieldName") ? item["SourceKeyFieldName"] + "" : ""; + this.SourceParentFieldName = item.Table.Columns.Contains("SourceParentFieldName") ? item["SourceParentFieldName"] + "" : ""; + this.DragAndSave = item.Table.Columns.Contains("DragAndSave") && "1".Equals(item["DragAndSave"] + "") ? true : false; + this.TreeInhibitSort = item.Table.Columns.Contains("TreeInhibitSort") && "1".Equals(item["TreeInhibitSort"] + "") ? true : false; + this.Orderid = item.Table.Columns.Contains("Orderid") ? item["Orderid"] + "" : ""; + this.DetailMenuCode = item.Table.Columns.Contains("DetailMenuCode") ? item["DetailMenuCode"] + "" : ""; + } + /// + /// 改变来源类型 + /// + /// + public void ChangeSourceType(int sourceType) + { + this.SourceType = sourceType; + } + + /// + /// 改变来源明细类型 + /// + /// + public void ChangeSourceDetailType(string sourceDetailType) + { + this.sourceDetailType = sourceDetailType; + } + } +} diff --git a/插件库/Lskj.PubBillManagement/Model/BillSourceUnionModel.cs b/插件库/Lskj.PubBillManagement/Model/BillSourceUnionModel.cs new file mode 100644 index 0000000..78abfca --- /dev/null +++ b/插件库/Lskj.PubBillManagement/Model/BillSourceUnionModel.cs @@ -0,0 +1,76 @@ +/****************************** +* 说明:单据来源关联类 +* 创建人:龚宇超 +* 创建日期:2017-11-28 +* 修改人: +* 修改日期: +* 修改备注: +* 版本:1.0.0.0 +******************************/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Lskj.Control; +using Lskj.Control.Model; + +namespace Lskj.PubBillManagement.Model +{ + /// + /// 单据来源关联类 + /// + public class BillSourceUnionModel + { + /// + /// 单据来源对象 + /// + public BillSourceModel ModelObj; + /// + /// 单据来源树 + /// + public TreeViewEx TreeViewObj; + /// + /// 单据来源表格 + /// + public GridControlEx GridControlObj; + /// + /// 单据来源表格树 + /// + public TreeGridControlEx TreeGridControlObj; + /// + /// 单据来源明细表格 + /// + public GridControlEx GridDetailControlObj; + /// + /// 单据来源明细表格树 + /// + public TreeGridControlEx TreeGridDetailControlObj; + /// + /// 单据来源查询条件 + /// + public MyControl SearchObj; + + /// + /// 单据来源明细表格的明细 + /// + public GridControlEx GridDetailDetailControlObj; + /// + /// 单据来源明细模块 + /// + public ModuleGridEx GridDetailModuleGridEx; + + + public bool IsChange = false; + + /// + /// 添加数据sql(来源明细添加到主表明细时,执行sql把查询数据源一并添加到来源明细中) + /// + public string AddDataSql; + /// + /// 添加数据条件 + /// + public string AddDataCondition; + + + } +} diff --git a/插件库/Lskj.PubBillManagement/Model/ComboxEditModel.cs b/插件库/Lskj.PubBillManagement/Model/ComboxEditModel.cs new file mode 100644 index 0000000..50ca53d --- /dev/null +++ b/插件库/Lskj.PubBillManagement/Model/ComboxEditModel.cs @@ -0,0 +1,41 @@ +/****************************** +* 说明:ComboxEdit数据源对象 +* 创建人:龚宇超 +* 创建日期:2018-04-19 +* 修改人: +* 修改日期: +* 修改备注: +* 版本:1.0.0.0 +******************************/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Data; + +namespace Lskj.PubBillManagement.Model +{ + /// + /// ComboxEdit数据源对象 + /// + public class ComboBoxEditModel + { + public string ValuemMeber; + public string TextMember; + + public DataRow RowItem; + /// + /// 单据来源对象 + /// + public BillSourceModel SourceModel; + /// + /// 单据来源关联明细对象 + /// + public BillSourceUnionModel UnionModel; + + public override string ToString() + { + return RowItem[TextMember] + ""; + } + } +} diff --git a/插件库/Lskj.PubBillManagement/Properties/AssemblyInfo.cs b/插件库/Lskj.PubBillManagement/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..dd29c1a --- /dev/null +++ b/插件库/Lskj.PubBillManagement/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Lskj.PubBillManagement")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Lskj.PubBillManagement")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("53e8153b-112d-4428-b9b2-a3b62ccbaf46")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 内部版本号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/插件库/Lskj.PubBillManagement/Properties/licenses.licx b/插件库/Lskj.PubBillManagement/Properties/licenses.licx new file mode 100644 index 0000000..0861976 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/Properties/licenses.licx @@ -0,0 +1,3 @@ +DevExpress.XtraEditors.TextEdit, DevExpress.XtraEditors.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraEditors.ComboBoxEdit, DevExpress.XtraEditors.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraBars.BarManager, DevExpress.XtraBars.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a diff --git a/插件库/Lskj.PubBillManagement/app.config b/插件库/Lskj.PubBillManagement/app.config new file mode 100644 index 0000000..7943c70 --- /dev/null +++ b/插件库/Lskj.PubBillManagement/app.config @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/插件库/Lskj.PubPower/FrmMain.cs b/插件库/Lskj.PubPower/FrmMain.cs index 2373d41..47361de 100644 --- a/插件库/Lskj.PubPower/FrmMain.cs +++ b/插件库/Lskj.PubPower/FrmMain.cs @@ -879,7 +879,7 @@ namespace Lskj.PubPower } } } - catch (Exception) + catch (Exception ex) { } diff --git a/插件库/Lskj.PubUpdatePwd/DllBaseClass.cs b/插件库/Lskj.PubUpdatePwd/DllBaseClass.cs new file mode 100644 index 0000000..447f246 --- /dev/null +++ b/插件库/Lskj.PubUpdatePwd/DllBaseClass.cs @@ -0,0 +1,57 @@ +using Lskj.Business; +using Lskj.Model; +using Lskj.Util; +using System; +using System.Windows.Forms; + +namespace Lskj.PubUpdatePwd +{ + /// + /// 动态链接库统一入口。 + /// + public sealed class DllBaseClass : IForm + { + public DllBaseClass() + { + } + + public DllBaseClass(string[] obj) + { + try + { + DynamicUpdatePwd moduleModel = new DynamicUpdatePwd(obj); + FrmMain main = new FrmMain(); + main.Model = moduleModel; + SubForm = main; + } + catch (Exception ex) + { + LogUtil.WriteError("Lskj.PubUpdatePwd.dll--参数错误-->", ex); + } + } + + public Form SubForm { get; set; } + } + + public class DynamicUpdatePwd : DynamicModel + { + //打开时默认选中人员id + public string PersonnelID { get; private set; } + //修改后关闭 + public string AfterClose = ""; + + + public DynamicUpdatePwd(string[] args) + : base(args) + { + if (args != null && args.Length > 5 && !string.IsNullOrWhiteSpace(args[5])) + { + PersonnelID = args[5].Trim(); + } + if (args != null && args.Length > 6 && !string.IsNullOrWhiteSpace(args[6])) + { + AfterClose = args[6].Trim(); + } + } + } +} diff --git a/插件库/Lskj.PubUpdatePwd/FrmMain.Designer.cs b/插件库/Lskj.PubUpdatePwd/FrmMain.Designer.cs new file mode 100644 index 0000000..eee0ab3 --- /dev/null +++ b/插件库/Lskj.PubUpdatePwd/FrmMain.Designer.cs @@ -0,0 +1,193 @@ +namespace Lskj.PubUpdatePwd +{ + partial class FrmMain + { + /// + /// + /// + private System.ComponentModel.IContainer components = null; + + /// + /// ʹõԴ + /// + /// ӦͷйԴΪ trueΪ false + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows ɵĴ + + /// + /// ֧ķ - Ҫ޸ + /// ʹô༭޸Ĵ˷ݡ + /// + private void InitializeComponent() + { + this.newPwd = new DevExpress.XtraEditors.LabelControl(); + this.txtNewPass = new DevExpress.XtraEditors.TextEdit(); + this.ConfirmPwd = new DevExpress.XtraEditors.LabelControl(); + this.txtPassConfirm = new DevExpress.XtraEditors.TextEdit(); + this.btnOK = new DevExpress.XtraEditors.SimpleButton(); + this.btnCancel = new DevExpress.XtraEditors.SimpleButton(); + this.lueUserName = new Lskj.Control.AutoGridLookUp(); + this.labelControl1 = new DevExpress.XtraEditors.LabelControl(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.txtNewPass.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.txtPassConfirm.Properties)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.lueUserName.Properties)).BeginInit(); + this.SuspendLayout(); + // + // newPwd + // + this.newPwd.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far; + this.newPwd.Location = new System.Drawing.Point(32, 56); + this.newPwd.Name = "newPwd"; + this.newPwd.Size = new System.Drawing.Size(36, 14); + this.newPwd.TabIndex = 0; + this.newPwd.Text = ""; + // + // txtNewPass + // + this.txtNewPass.Location = new System.Drawing.Point(98, 53); + this.txtNewPass.Name = "txtNewPass"; + this.txtNewPass.Size = new System.Drawing.Size(153, 20); + this.txtNewPass.TabIndex = 1; + // + // ConfirmPwd + // + this.ConfirmPwd.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far; + this.ConfirmPwd.Location = new System.Drawing.Point(32, 93); + this.ConfirmPwd.Name = "ConfirmPwd"; + this.ConfirmPwd.Size = new System.Drawing.Size(48, 14); + this.ConfirmPwd.TabIndex = 3; + this.ConfirmPwd.Text = "ȷ"; + // + // txtPassConfirm + // + this.txtPassConfirm.Location = new System.Drawing.Point(98, 90); + this.txtPassConfirm.Name = "txtPassConfirm"; + this.txtPassConfirm.Size = new System.Drawing.Size(153, 20); + this.txtPassConfirm.TabIndex = 4; + // + // btnOK + // + this.btnOK.Location = new System.Drawing.Point(32, 187); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(80, 25); + this.btnOK.TabIndex = 8; + this.btnOK.Text = "ȷ"; + this.btnOK.Click += new System.EventHandler(this.btnOK_Click); + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(171, 187); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(80, 25); + this.btnCancel.TabIndex = 9; + this.btnCancel.Text = "ȡ"; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // lueUserName + // + this.lueUserName.DataSource = null; + this.lueUserName.EditValue = ""; + this.lueUserName.Location = new System.Drawing.Point(98, 12); + this.lueUserName.Name = "lueUserName"; + this.lueUserName.Properties.Appearance.Font = new System.Drawing.Font("΢ź", 11F); + this.lueUserName.Properties.Appearance.Options.UseFont = true; + this.lueUserName.Properties.NullValuePrompt = "˺"; + this.lueUserName.Properties.NullValuePromptShowForEmptyValue = true; + this.lueUserName.Size = new System.Drawing.Size(153, 26); + this.lueUserName.TabIndex = 10; + // + // labelControl1 + // + this.labelControl1.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far; + this.labelControl1.Location = new System.Drawing.Point(32, 18); + this.labelControl1.Name = "labelControl1"; + this.labelControl1.Size = new System.Drawing.Size(48, 14); + this.labelControl1.TabIndex = 11; + this.labelControl1.Text = "Ա"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(96, 164); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(89, 12); + this.label4.TabIndex = 23; + this.label4.Text = "38ַ"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(96, 146); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(155, 12); + this.label3.TabIndex = 22; + this.label3.Text = "2Сддĸ"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(36, 126); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(155, 12); + this.label2.TabIndex = 21; + this.label2.Text = "Ҫ1"; + // + // FrmMain + // + this.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.Appearance.Options.UseBackColor = true; + this.Appearance.Options.UseFont = true; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(290, 224); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.labelControl1); + this.Controls.Add(this.lueUserName); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOK); + this.Controls.Add(this.txtPassConfirm); + this.Controls.Add(this.ConfirmPwd); + this.Controls.Add(this.txtNewPass); + this.Controls.Add(this.newPwd); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FrmMain"; + this.Text = "޸"; + this.Load += new System.EventHandler(this.FrmMain_Load); + ((System.ComponentModel.ISupportInitialize)(this.txtNewPass.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.txtPassConfirm.Properties)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.lueUserName.Properties)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private DevExpress.XtraEditors.LabelControl newPwd; + private DevExpress.XtraEditors.TextEdit txtNewPass; + private DevExpress.XtraEditors.LabelControl ConfirmPwd; + private DevExpress.XtraEditors.TextEdit txtPassConfirm; + private DevExpress.XtraEditors.SimpleButton btnOK; + private DevExpress.XtraEditors.SimpleButton btnCancel; + private Control.AutoGridLookUp lueUserName; + private DevExpress.XtraEditors.LabelControl labelControl1; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + } +} diff --git a/插件库/Lskj.PubUpdatePwd/FrmMain.cs b/插件库/Lskj.PubUpdatePwd/FrmMain.cs new file mode 100644 index 0000000..bea3e19 --- /dev/null +++ b/插件库/Lskj.PubUpdatePwd/FrmMain.cs @@ -0,0 +1,277 @@ +using Lskj.Business; +using Lskj.Business.Impl; +using Lskj.Control; +using Lskj.Core; +using Lskj.Model; +using Lskj.Util; +using System; +using System.Data; +using System.Linq; +using System.Text.RegularExpressions; +using System.Windows.Forms; + +namespace Lskj.PubUpdatePwd +{ + public partial class FrmMain : BaseForm + { + private static readonly Regex PasswordRegex = new Regex( + @"(?=.*[0-9]) + (?=.*[a-zA-Z]) + (?=.*[^a-zA-Z0-9]) + .{8,18}", + RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace); + + public DynamicUpdatePwd Model; + + public FrmMain() + { + InitializeComponent(); + } + + private void FrmMain_Load(object sender, EventArgs e) + { + try + { + txtNewPass.Text = string.Empty; + txtPassConfirm.Text = string.Empty; + txtNewPass.Properties.PasswordChar = '*'; + txtPassConfirm.Properties.PasswordChar = '*'; + + BindUserSelectionEvents(); + InitializeUsers(); + UpdateConfirmButtonState(); + } + catch (Exception ex) + { + string message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show(message, ex.Message); + } + } + + /// + /// 绑定人员选择事件,兼容鼠标选择和键盘回车选择。 + /// + private void BindUserSelectionEvents() + { + lueUserName.TextChanged -= OnUserSelectionChanged; + lueUserName.TextChanged += OnUserSelectionChanged; + lueUserName.Popup.OnGridViewMouseClick -= OnUserSelectionChanged; + lueUserName.Popup.OnGridViewMouseClick += OnUserSelectionChanged; + lueUserName.Popup.OnGridViewEnter -= OnUserSelectionEnter; + lueUserName.Popup.OnGridViewEnter += OnUserSelectionEnter; + } + + private void OnUserSelectionChanged(object sender, EventArgs e) + { + UpdateConfirmButtonState(); + } + + private void OnUserSelectionEnter(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + UpdateConfirmButtonState(); + } + } + + /// + /// 管理员不能在本模块中修改自己的密码。 + /// + private void UpdateConfirmButtonState() + { + bool isAdministrator = string.Equals( + ERPInfo.Instance.UserName, + "管理员", + StringComparison.OrdinalIgnoreCase); + string personnelId = lueUserName.EditValue == null + ? string.Empty + : lueUserName.EditValue.Trim(); + bool isCurrentUser = !string.IsNullOrWhiteSpace(personnelId) + && string.Equals(personnelId, ERPInfo.Instance.UserId, StringComparison.OrdinalIgnoreCase); + + btnOK.Enabled = isAdministrator && !isCurrentUser; + } + + /// + /// 初始化可修改密码的人员列表。 + /// + private void InitializeUsers() + { + string displayName = "UserName"; + string additionalFields = string.Empty; + + if (!string.IsNullOrWhiteSpace(SystemInfo.Instance.LoginUsername) + && BaseImpl.HasExistsColumn("P_EmployeeTab", SystemInfo.Instance.LoginUsername)) + { + displayName = SystemInfo.Instance.LoginUsername; + additionalFields = " ," + displayName; + } + + lueUserName.ValueField = lueUserName.ValueMember = "UserId"; + lueUserName.TextMember = displayName; + lueUserName.SourceSQL = string.Format( + "select EmployeeId UserId,LoginAccount UserCode,EmployeeName UserName {0} " + + "from P_EmployeeTab where sign=0 and UseFlag=1", + additionalFields); + + DataTable userTable; + //if (SystemInfo.Instance.DisplayUserCode) + //{ + // lueUserName.SourceSQL = string.Format( + // "select EmployeeId UserId,LoginAccount UserCode,EmployeeName UserName,LoginAccount 工号 {0} " + // + "from P_EmployeeTab where sign=0 and UseFlag=1", + // additionalFields); + // userTable = MainImpl.GetEmployeeListNew(); + //} + //else + //{ + // userTable = MainImpl.GetEmployeeList(); + //} + userTable = MainImpl.GetEmployeeList(); + lueUserName.DataSource = userTable; + lueUserName.Properties.NullValuePrompt = "请选择人员"; + + string personnelId = Model == null ? string.Empty : Model.PersonnelID; + if (string.IsNullOrWhiteSpace(personnelId)) + { + lueUserName.Focus(); + return; + } + + DataRow userRow = userTable.Rows.Cast().FirstOrDefault( + row => string.Equals(row["UserId"] + string.Empty, personnelId, StringComparison.OrdinalIgnoreCase)); + + if (userRow == null) + { + lueUserName.Properties.ReadOnly = true; + MessageUtil.Show("未找到指定人员,无法修改密码!", "提示"); + return; + } + + lueUserName.EditValue = userRow["UserId"] + string.Empty; + lueUserName.Properties.ReadOnly = true; + txtNewPass.Focus(); + } + + /// + /// 确定按钮点击事件。 + /// + private void btnOK_Click(object sender, EventArgs e) + { + string personnelId = lueUserName.EditValue == null + ? string.Empty + : lueUserName.EditValue.Trim(); + string newPassword = txtNewPass.Text.Trim(); + string confirmPassword = txtPassConfirm.Text.Trim(); + + if (string.IsNullOrWhiteSpace(personnelId)) + { + MessageUtil.Show("请选择需要修改密码的人员!", "提示"); + lueUserName.Focus(); + return; + } + if (string.Equals(personnelId, ERPInfo.Instance.UserId, StringComparison.OrdinalIgnoreCase)) + { + btnOK.Enabled = false; + MessageUtil.Show("管理员不能在此模块中修改自己的密码!", "提示"); + return; + } + if (string.IsNullOrWhiteSpace(newPassword)) + { + MessageUtil.Show("新密码不能为空!"); + txtNewPass.Focus(); + return; + } + if (string.IsNullOrWhiteSpace(confirmPassword)) + { + MessageUtil.Show("确认密码不能为空!"); + txtPassConfirm.Focus(); + return; + } + if (!newPassword.Equals(confirmPassword)) + { + MessageUtil.Show("两次输入的密码不一致!"); + txtPassConfirm.Focus(); + return; + } + if (SystemInfo.Instance.VerfyPasswordStrength && !PasswordRegex.IsMatch(confirmPassword)) + { + MessageUtil.Show("密码不符合要求!"); + txtNewPass.Focus(); + return; + } + + try + { + btnOK.Enabled = false; + + string tipMessage; + int result; + bool useChangePasswordProcedure = BaseImpl.HasExistsStoredProcedure("pr_sytemchangepsw"); + + if (useChangePasswordProcedure) + { + result = MainImpl.ChangePassword(personnelId, newPassword, out tipMessage); + } + else + { + result = MainImpl.ForceUpdatePassword(personnelId, newPassword); + tipMessage = result == 0 ? "用户不存在" : string.Empty; + } + + if (result != 1) + { + MessageUtil.Show("修改失败:" + tipMessage); + return; + } + + if (!useChangePasswordProcedure && SystemInfo.Instance.UpdPwdAllSystem) + { + if (MainImpl.UpdatePasswordAllSubsystem(personnelId, newPassword)) + { + MessageUtil.Show("用户对应账套密码修改成功"); + } + else + { + MessageUtil.Show("当前账套密码修改成功,但用户对应账套密码修改失败"); + } + } + + MainImpl.RecordPassword(newPassword,"修改密码,"+ ERPInfo.Instance.UserName + "修改"+ lueUserName.Text); + MessageUtil.Show("密码修改成功!"); + if (Model.AfterClose.Equals("1")) + { + DialogResult = DialogResult.OK; + Close(); + } + else + { + txtNewPass.Text = string.Empty; + txtPassConfirm.Text = string.Empty; + } + + } + catch (Exception ex) + { + string message = ErrorMessage.PromptErrorMessage(ex); + MessageUtil.Show("修改密码出错!" + message); + } + finally + { + if (!IsDisposed) + { + UpdateConfirmButtonState(); + } + } + } + + /// + /// 取消按钮点击事件。 + /// + private void btnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/插件库/Lskj.PubUpdatePwd/FrmMain.resx b/插件库/Lskj.PubUpdatePwd/FrmMain.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/插件库/Lskj.PubUpdatePwd/FrmMain.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/插件库/Lskj.PubUpdatePwd/Lskj.PubUpdatePwd.csproj b/插件库/Lskj.PubUpdatePwd/Lskj.PubUpdatePwd.csproj new file mode 100644 index 0000000..ebaf754 --- /dev/null +++ b/插件库/Lskj.PubUpdatePwd/Lskj.PubUpdatePwd.csproj @@ -0,0 +1,112 @@ + + + + + Debug + AnyCPU + {91470E21-B8FB-4A16-967A-912F9E4807E1} + Library + Lskj.PubUpdatePwd + Lskj.PubUpdatePwd + v4.0 + 512 + true + + + x86 + true + full + false + ..\..\Debug\Lib\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + Form + + + FrmMain.cs + + + + FrmMain.cs + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + {7eafccc2-a18f-49e9-85c6-a984966cfd01} + Lskj.Business + + + {447CDC40-659F-4CCA-9ED6-8E818B4CF8BF} + Lskj.Control + + + {2A1BE6AC-1077-491B-A754-C5822FE8121E} + Lskj.Core + + + {52BC40E0-C0C6-4F78-996B-CAE028D209CA} + Lskj.Model + + + {A51BF642-6543-4DE3-8948-83F558B72BD4} + Lskj.Util + + + + \ No newline at end of file diff --git a/插件库/Lskj.PubUpdatePwd/Program.cs b/插件库/Lskj.PubUpdatePwd/Program.cs new file mode 100644 index 0000000..18b89d6 --- /dev/null +++ b/插件库/Lskj.PubUpdatePwd/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace Lskj.PubTabDll +{ + static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new FrmMain()); + } + } +} diff --git a/插件库/Lskj.PubUpdatePwd/Properties/AssemblyInfo.cs b/插件库/Lskj.PubUpdatePwd/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..53e0e89 --- /dev/null +++ b/插件库/Lskj.PubUpdatePwd/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Lskj.PubUpdatePwd")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Lskj.PubUpdatePwd")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("aeb20c62-d8de-4adc-85c7-4bcf3d6aa950")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/插件库/Lskj.PubUpdatePwd/Properties/Resources.Designer.cs b/插件库/Lskj.PubUpdatePwd/Properties/Resources.Designer.cs new file mode 100644 index 0000000..d655bd8 --- /dev/null +++ b/插件库/Lskj.PubUpdatePwd/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace Lskj.PubUpdatePwd.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Lskj.PubUpdatePwd.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/插件库/Lskj.PubUpdatePwd/Properties/Resources.resx b/插件库/Lskj.PubUpdatePwd/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/插件库/Lskj.PubUpdatePwd/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/插件库/Lskj.PubUpdatePwd/Properties/Settings.Designer.cs b/插件库/Lskj.PubUpdatePwd/Properties/Settings.Designer.cs new file mode 100644 index 0000000..057f476 --- /dev/null +++ b/插件库/Lskj.PubUpdatePwd/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace Lskj.PubUpdatePwd.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/插件库/Lskj.PubUpdatePwd/Properties/Settings.settings b/插件库/Lskj.PubUpdatePwd/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/插件库/Lskj.PubUpdatePwd/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/插件库/Lskj.PubUpdatePwd/Properties/licenses.licx b/插件库/Lskj.PubUpdatePwd/Properties/licenses.licx new file mode 100644 index 0000000..c05e9a5 --- /dev/null +++ b/插件库/Lskj.PubUpdatePwd/Properties/licenses.licx @@ -0,0 +1,3 @@ +DevExpress.XtraEditors.ComboBoxEdit, DevExpress.XtraEditors.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraEditors.TextEdit, DevExpress.XtraEditors.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a diff --git a/插件库/Lskj.PubUserTomodule/FrmMain.Designer.cs b/插件库/Lskj.PubUserTomodule/FrmMain.Designer.cs index 04f71ab..b2fac3f 100644 --- a/插件库/Lskj.PubUserTomodule/FrmMain.Designer.cs +++ b/插件库/Lskj.PubUserTomodule/FrmMain.Designer.cs @@ -849,6 +849,7 @@ // this.name_lde.BackColor = System.Drawing.Color.Transparent; this.name_lde.BackgroundColor = System.Drawing.Color.Empty; + this.name_lde.ContentBold = false; this.name_lde.EditText = ""; this.name_lde.FontSize = 0F; this.name_lde.LabelText = "姓名"; @@ -866,6 +867,7 @@ // this.end_lde.BackColor = System.Drawing.Color.Transparent; this.end_lde.BackgroundColor = System.Drawing.Color.Empty; + this.end_lde.ContentBold = false; this.end_lde.EditText = ""; this.end_lde.FontSize = 0F; this.end_lde.LabelText = "结束时间"; @@ -883,6 +885,7 @@ // this.start_lde.BackColor = System.Drawing.Color.Transparent; this.start_lde.BackgroundColor = System.Drawing.Color.Empty; + this.start_lde.ContentBold = false; this.start_lde.EditText = ""; this.start_lde.FontSize = 0F; this.start_lde.LabelText = "开始时间"; @@ -1036,6 +1039,7 @@ this.searchModuleLab.BackColor = System.Drawing.Color.Transparent; this.searchModuleLab.BackgroundColor = System.Drawing.Color.Empty; this.searchModuleLab.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.searchModuleLab.ContentBold = false; this.searchModuleLab.Dock = System.Windows.Forms.DockStyle.Fill; this.searchModuleLab.EditText = ""; this.searchModuleLab.FontSize = 0F; @@ -1105,7 +1109,7 @@ this.Appearance.Options.UseBackColor = true; this.Appearance.Options.UseFont = true; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; - this.ClientSize = new System.Drawing.Size(1284, 641); + this.ClientSize = new System.Drawing.Size(1605, 801); this.Controls.Add(this.splitContainerControl1); this.Name = "FrmMain"; this.Text = "权限设置器";