29 Commits

Author SHA1 Message Date
tdx fddab16bd2 优化模块资源释放与异步预加载 2026-09-03 14:16:48 +08:00
SugarChes a263522b47 chore(legacy): update generated binaries and query source 2026-09-01 16:31:06 +08:00
tdx 7c02f14e9a Merge branch 'main' of http://192.168.0.7:4133/cyf/lserp_cs_6.0 2026-09-01 16:09:23 +08:00
SugarChes 4bb5434385 fix(legacy): remove WPF splitter width workaround 2026-09-01 16:06:03 +08:00
SugarChes efc281c188 fix(legacy): remove forced horizontal scrollbar handling 2026-09-01 15:51:59 +08:00
SugarChes 5eb0077221 fix(legacy): defer WinForms module showing for WPF host 2026-09-01 15:43:24 +08:00
cyf c1d10f22f5 feat: 完善个人设置及表格功能 2026-08-31 18:03:47 +08:00
tdx 0058939a8a fix(legacy): keep bill cache control creation on UI thread 2026-08-30 21:42:56 +08:00
tdx 769aa52241 fix(legacy): release hosted module resources safely 2026-08-30 18:12:09 +08:00
cyf 641d3c232d feat: 优化主界面及控件功能 2026-08-30 12:00:03 +08:00
tdx 24653fbe6c Merge branch 'main' of http://192.168.0.7:4133/cyf/lserp_cs_6.0
# Conflicts:
#	插件库/Lskj.PubModuleDetail/FrmMain.cs
2026-08-29 21:54:25 +08:00
tdx 9f5f548dea fix(legacy): complete hosted module cleanup 2026-08-29 20:34:39 +08:00
SugarChes 176952d52c fix(legacy): finalize hosted module lifecycle cleanup 2026-08-29 18:03:44 +08:00
cyf 98a119ed25 feat: 新增主界面模块功能 2026-08-28 23:32:47 +08:00
tdx e27d445844 Merge branch 'main' of http://192.168.0.7:4133/cyf/lserp_cs_6.0 2026-08-28 12:01:00 +08:00
tdx 1c59fda8b8 feat(legacy): add shell-independent module page compatibility 2026-08-28 11:56:48 +08:00
cyf b33c847b27 refactor: 迁移初始化参数缓存并优化等待界面 2026-08-27 11:46:06 +08:00
tdx 8472004711 Merge branch 'main' of http://192.168.0.7:4133/cyf/lserp_cs_6.0 2026-08-26 09:44:38 +08:00
tdx 1e06682a12 fix(winforms): release module grid resources 2026-08-26 01:10:27 +08:00
cyf dd58f12374 feat: 更新业务及控件功能 2026-08-21 17:21:18 +08:00
tdx 6cde5df2f2 fix(browser): remove stale lifetime coordinator call 2026-08-20 16:44:23 +08:00
tdx da34905fb2 chore(browser): remove unused lifetime coordinator 2026-08-18 19:02:18 +08:00
tdx d3587a16f1 chore(browser): sync current working implementation
Rollback tag: pre-current-browser-sync-20260818
2026-08-18 14:30:23 +08:00
tdx 6b78bbbf04 fix: 恢复 ModuleGridEx 组件容器管理 2026-08-15 22:37:07 +08:00
cyf 57dedb5e9d feat: 新增时间输入和Alt按钮快捷键 2026-08-15 22:26:11 +08:00
tdx a65dfab897 fix: synchronize module data cache cleanup 2026-08-15 18:39:26 +08:00
tdx d098dde830 chore(report): 清理临时资源诊断代码 2026-08-15 16:37:10 +08:00
tdx ef13d46fa2 Merge branch 'main' of http://192.168.0.7:4133/cyf/lserp_cs_6.0 2026-08-15 16:35:25 +08:00
tdx fc5faab65d fix(control): 修复金额单元格关闭阶段异常 2026-08-15 16:00:10 +08:00
124 changed files with 17737 additions and 13614 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -32,10 +32,11 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.btnCancel = new DevExpress.XtraEditors.SimpleButton();
this.btnFileManger = new DevExpress.XtraEditors.SimpleButton();
this.p_menu = new DevExpress.XtraBars.PopupMenu();
this.barManager1 = new DevExpress.XtraBars.BarManager();
this.p_menu = new DevExpress.XtraBars.PopupMenu(this.components);
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
@@ -55,7 +56,7 @@
this.gridSign = new Lskj.Control.GridControlEx();
this.pl_bottom = new DevExpress.XtraEditors.PanelControl();
this.btnPrint = new DevExpress.XtraEditors.DropDownButton();
this.pMprint = new DevExpress.XtraBars.PopupMenu();
this.pMprint = new DevExpress.XtraBars.PopupMenu(this.components);
this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton();
this.pl_right = new DevExpress.XtraEditors.PanelControl();
this.pl_right_bottom = new DevExpress.XtraEditors.PanelControl();
@@ -107,7 +108,7 @@
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(80, 28);
this.btnCancel.TabIndex = 4;
this.btnCancel.Text = "退出(&C)";
this.btnCancel.Text = "退出(C)";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnFileManger
@@ -175,7 +176,7 @@
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(80, 28);
this.btnSave.TabIndex = 11;
this.btnSave.Text = "保存(&S)";
this.btnSave.Text = "保存(S)";
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// dpb_Tools
@@ -458,7 +459,7 @@
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(58, 23);
this.btnClose.TabIndex = 12;
this.btnClose.Text = "关闭(&Q)";
this.btnClose.Text = "关闭(Q)";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// labeltxt_managerAudit
@@ -39,6 +39,9 @@ namespace Lskj.BaseAccraditation
{
public partial class FrmBaseAccraditation : BaseForm
{
private readonly AltButtonShortcutManager mAltButtonShortcuts =
new AltButtonShortcutManager();
#region
/// <summary>
/// 审批模型
@@ -190,6 +193,23 @@ namespace Lskj.BaseAccraditation
public FrmBaseAccraditation()
{
InitializeComponent();
InitializeAltButtonShortcuts();
}
private void InitializeAltButtonShortcuts()
{
mAltButtonShortcuts.Register(btnCancel, Keys.C);
mAltButtonShortcuts.Register(btnSave, Keys.S);
mAltButtonShortcuts.Register(btnAudit, Keys.Y);
mAltButtonShortcuts.Register(btnClose, Keys.Q);
mAltButtonShortcuts.Register(btnReturnd, Keys.N);
}
protected override bool ProcessCmdKey(
ref System.Windows.Forms.Message msg, Keys keyData)
{
return mAltButtonShortcuts.ProcessKey(keyData) ||
base.ProcessCmdKey(ref msg, keyData);
}
private void ReleaseResourcesForDispose()
@@ -219,7 +239,7 @@ namespace Lskj.BaseAccraditation
}
if (SysModel != null && SysModel.DataCaches != null)
{
SysModel.DataCaches.Remove(this);
SysModel.DataCaches.RemoveCache(this);
}
}
catch
@@ -517,7 +537,8 @@ namespace Lskj.BaseAccraditation
}));
cachesDic.AddTask(tab_basicInfo, "DynamicModel", dynamicModelTask);
cachesDic.AddTask(tab_basicInfo, "Details", detailTask);
tab_basicInfo.GetDataCaches(cachesDic);
// TabControlEx.GetDataCaches 会创建明细页中的 WinForms/DevExpress
// 控件,不能在此后台预加载阶段调用;BindTab 在 UI 线程补充创建。
//初始化常用工具
Task<DataTable> GetBaseGridRightMenusTask = cachesDic.AddTask(this, "GetBaseGridRightMenus", new Task<DataTable>(() =>
{
@@ -1171,6 +1192,12 @@ namespace Lskj.BaseAccraditation
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
this.tab_basicInfo.Model = this.SysModel;
this.tab_basicInfo.ParentControlEx = this.ControlObj;
if (dataCaches != null &&
dataCaches.GetTask<DynamicModel>(tab_basicInfo, "DynamicModel") != null &&
dataCaches.GetTask<List<GridDetailModel>>(tab_basicInfo, "Details") != null)
{
tab_basicInfo.GetDataCaches(dataCaches);
}
if (!dataCaches.GetValue(tab_basicInfo, "Details", out List<GridDetailModel> details))
{
details = GetTabDetails();
@@ -1480,7 +1507,7 @@ namespace Lskj.BaseAccraditation
{
this.btnAudit.Enabled = true;
this.btnClose.Visible = this.btnRemindAccradit.Visible = this.btnRemindBack.Visible = this.btnSave.Visible = this.btnReturnd.Visible = false;
this.btnAudit.Text = "确认(&Y)";
this.btnAudit.Text = "确认(Y)";
this.label_auditPerson.Text = "确认意见";
this.labeltxt_managerAudit.Text = "会签人";
this.txt_remark.Text = "确认";
@@ -2057,15 +2084,15 @@ namespace Lskj.BaseAccraditation
if (refreshThePage != null)
{
refreshThePage("审核成功", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("审核成功", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
@@ -2073,13 +2100,13 @@ namespace Lskj.BaseAccraditation
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -2241,15 +2268,15 @@ namespace Lskj.BaseAccraditation
this.DialogResult = DialogResult.OK;
if (refreshThePage != null)
{
refreshThePage("审核成功", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("审核成功", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
@@ -2257,13 +2284,13 @@ namespace Lskj.BaseAccraditation
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -2371,15 +2398,15 @@ namespace Lskj.BaseAccraditation
if (refreshThePage != null)
{
refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
@@ -2387,13 +2414,13 @@ namespace Lskj.BaseAccraditation
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -2431,15 +2458,15 @@ namespace Lskj.BaseAccraditation
if (refreshThePage != null)
{
refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
@@ -2447,13 +2474,13 @@ namespace Lskj.BaseAccraditation
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -2507,15 +2534,15 @@ namespace Lskj.BaseAccraditation
if (refreshThePage != null)
{
refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
@@ -2523,13 +2550,13 @@ namespace Lskj.BaseAccraditation
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -2589,15 +2616,15 @@ namespace Lskj.BaseAccraditation
this.DialogResult = DialogResult.OK;
if (refreshThePage != null)
{
refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
@@ -2605,13 +2632,13 @@ namespace Lskj.BaseAccraditation
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -2649,15 +2676,15 @@ namespace Lskj.BaseAccraditation
this.DialogResult = DialogResult.OK;
if (refreshThePage != null)
{
refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
@@ -2665,13 +2692,13 @@ namespace Lskj.BaseAccraditation
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
+23 -13
View File
@@ -317,7 +317,7 @@ namespace Lskj.BaseAccraditation
if (SystemInfo.Instance.PageOpen)
{
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
int interceptionLocation = tablepage.Text.Length - frmbaseAccradit.SysModel.PrimaryValue.Length - 1;
if (interceptionLocation > 0 && tablepage.Text.Length > frmbaseAccradit.SysModel.PrimaryValue.Length)
@@ -326,7 +326,7 @@ namespace Lskj.BaseAccraditation
if (documentNo.Equals(frmbaseAccradit.SysModel.PrimaryValue))
{
MessageUtil.Show("已设置不能打开多个相同模块!");
ERPInfo.Instance.PageControl.SelectedTabPage = tablepage;
ERPInfo.Instance.CurrentModulePage = tablepage;
return;
}
}
@@ -336,7 +336,7 @@ namespace Lskj.BaseAccraditation
DllName = "",
Id = SysModel.ModuleId + "",
Name = SysModel.FormText,
BeforePage = ERPInfo.Instance.PageControl.SelectedTabPage,
BeforePage = ERPInfo.Instance.CurrentModulePage,
ModuleForm = frmbaseAccradit
};
frmbaseAccradit.refreshThePage += new FrmBaseAccraditation.RefreshThePage(refreshThePage);
@@ -353,11 +353,16 @@ namespace Lskj.BaseAccraditation
tp.Controls.Add(frmbaseAccradit);
tp.ShowCloseButton = DefaultBoolean.True;
tp.Dock = DockStyle.Fill;
ERPInfo.Instance.PageControl.TabPages.Add(tp);
ERPInfo.Instance.PageControl.SelectedTabPage = tp;
StaticControl.ModuleResourceScope moduleScope =
StaticControl.RegisterModulePage(module, tp, frmbaseAccradit);
ERPInfo.Instance.AddModulePage(tp);
ERPInfo.Instance.CurrentModulePage = tp;
frmbaseAccradit.Opacity = 0;
frmbaseAccradit.SetFormSize();
using (StaticControl.PushModuleScope(moduleScope))
{
frmbaseAccradit.Show();
}
ERPInfo.Instance.ModuleForms.Add(guid, module);
}
else
@@ -440,7 +445,7 @@ namespace Lskj.BaseAccraditation
if (SystemInfo.Instance.PageOpen)
{
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
int interceptionLocation = tablepage.Text.Length - frmbaseAccradit.SysModel.PrimaryValue.Length - 1;
if (interceptionLocation > 0 && tablepage.Text.Length > frmbaseAccradit.SysModel.PrimaryValue.Length)
@@ -449,7 +454,7 @@ namespace Lskj.BaseAccraditation
if (documentNo.Equals(frmbaseAccradit.SysModel.PrimaryValue))
{
MessageUtil.Show("已设置不能打开多个相同模块!");
ERPInfo.Instance.PageControl.SelectedTabPage = tablepage;
ERPInfo.Instance.CurrentModulePage = tablepage;
return;
}
}
@@ -459,7 +464,7 @@ namespace Lskj.BaseAccraditation
DllName = "",
Id = SysModel.ModuleId + "",
Name = SysModel.FormText,
BeforePage = ERPInfo.Instance.PageControl.SelectedTabPage,
BeforePage = ERPInfo.Instance.CurrentModulePage,
ModuleForm = frmbaseAccradit
};
frmbaseAccradit.refreshThePage += new FrmBaseAccraditation.RefreshThePage(refreshThePage);
@@ -477,11 +482,16 @@ namespace Lskj.BaseAccraditation
tp.Controls.Add(frmbaseAccradit);
tp.ShowCloseButton = DefaultBoolean.True;
tp.Dock = DockStyle.Fill;
ERPInfo.Instance.PageControl.TabPages.Add(tp);
ERPInfo.Instance.PageControl.SelectedTabPage = tp;
StaticControl.ModuleResourceScope moduleScope =
StaticControl.RegisterModulePage(module, tp, frmbaseAccradit);
ERPInfo.Instance.AddModulePage(tp);
ERPInfo.Instance.CurrentModulePage = tp;
frmbaseAccradit.Opacity = 0;
frmbaseAccradit.SetFormSize();
using (StaticControl.PushModuleScope(moduleScope))
{
frmbaseAccradit.Show();
}
ERPInfo.Instance.ModuleForms.Add(guid, module);
}
else
@@ -521,13 +531,13 @@ namespace Lskj.BaseAccraditation
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
}
}
}
+2 -1
View File
@@ -373,7 +373,8 @@ namespace Lskj.Business.Impl
.Replace("#", "%23")
.Replace("%2f", "/")
.Replace("", "%ef%bc%88")
.Replace("", "%ef%bc%89");
.Replace("", "%ef%bc%89")
.Replace(" ", "%20");
// 完全参数化 SQL,彻底杜绝 SQL 注入!
sqlValue = @"SELECT * FROM P_fm_FileTab
+9
View File
@@ -100,12 +100,15 @@ namespace Lskj.Business.Impl
/// <param name="colName">Name of the col.</param>
/// <returns><c>true</c> if [has contain column]; otherwise, <c>false</c>.</returns>
public static bool HasExistsColumn(string tableName, string colName, string colType)
{
return InitialParamCache.GetColumnExists(tableName, colName, colType, delegate
{
if (!HasExistsColumn(tableName, colName))
{
return ExecSqlValue(string.Format("ALTER TABLE {0} ADD {1} {2}", tableName, colName, colType)) > 0;
}
return true;
});
}
/// <summary>
/// <para>说明:是否存在xxx表</para>
@@ -119,6 +122,8 @@ namespace Lskj.Business.Impl
/// <param name="tableName">Name of the table.</param>
/// <returns><c>true</c> if [has exists table] [the specified table name]; otherwise, <c>false</c>.</returns>
public static bool HasExistsTable(string tableName)
{
return InitialParamCache.GetTableExists(tableName, delegate
{
try
{
@@ -129,6 +134,7 @@ namespace Lskj.Business.Impl
{
}
return false;
});
}
/// <summary>
@@ -972,9 +978,12 @@ namespace Lskj.Business.Impl
/// <param name="tableName">Name of the table.</param>
/// <returns>DataTable.</returns>
public static DataTable GetTableColumns(string tableName)
{
return InitialParamCache.GetTableColumns(tableName, delegate
{
string sqlValue = string.Format("select * from {0} where 1<>1", tableName);
return SqlHelper.ExecuteDataTable(sqlValue);
});
}
/// <summary>
/// <para>说明:执行SQL语句返回结果集</para>
+3 -32
View File
@@ -926,15 +926,7 @@ namespace Lskj.Business.Impl
{
string field = string.Empty;
DataTable dataTable;
try
{
dataTable = InitialParamCache.GetTableColumns("p_systembillsourcecond", delegate { return GetTableColumns("p_systembillsourcecond"); });
}
catch (Exception)
{
dataTable = GetTableColumns("p_systembillsourcecond");
}
DataTable dataTable = GetTableColumns("p_systembillsourcecond");
if (dataTable.Columns.Contains("FontSize"))
{
@@ -1150,16 +1142,7 @@ namespace Lskj.Business.Impl
switch (type)
{
case ModuleType.MrpClickBtn:
bool isMrpClickBtnExists;
try
{
isMrpClickBtnExists = InitialParamCache.GetColumnExists("P_systempopupmenu", "isMrpClickBtn", "int", delegate { return BaseImpl.HasExistsColumn("P_systempopupmenu", "isMrpClickBtn", "int"); });
}
catch (Exception)
{
isMrpClickBtnExists = BaseImpl.HasExistsColumn("P_systempopupmenu", "isMrpClickBtn", "int");
}
if (isMrpClickBtnExists)
if (BaseImpl.HasExistsColumn("P_systempopupmenu", "isMrpClickBtn", "int"))
{
where = " and isnull(isMrpClickBtn,0)=1 and visible1=0 ";
}
@@ -1581,19 +1564,7 @@ namespace Lskj.Business.Impl
//保存条件表
public static DataTable GetClientCond(string MenuCode)
{
const string tableName = "P_SystemClientCondTab";
bool tableExists;
try
{
tableExists = InitialParamCache.GetTableExists(tableName, delegate { return BaseImpl.HasExistsTable(tableName); });
}
catch (Exception)
{
// 缓存未能正常读取或记录时,重新查询,避免影响原有功能。
tableExists = BaseImpl.HasExistsTable(tableName);
}
if (tableExists)
if (BaseImpl.HasExistsTable("P_SystemClientCondTab"))
{
string sqlValue = string.Format(@"select * from P_SystemClientCondTab where tab='{0}' and disableflag=0 order by orderid ", MenuCode);
return GetDataTableResult(sqlValue);
+1
View File
@@ -869,6 +869,7 @@ namespace Lskj.Business.Impl
+ ")a join p_formmenuconfigtab b on a.LMenuId=b.MenuId" +
" left join P_SubSystemTab z on a.LSubSysId=z.SubSysId where LinkModeTag=1 order by grouptagid,ItemTagId", ERPInfo.Instance.UserId);
return SqlHelper.ExecuteDataTable(sqlValue);
}
@@ -340,9 +340,21 @@ namespace Lskj.Business
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";
}
Instance.IsSpecialAuditSave = item.Table.Columns.Contains("IsSpecialAuditSave") && !string.IsNullOrEmpty(item["IsSpecialAuditSave"] + "") ? "1".Equals(item["IsSpecialAuditSave"] + "") : false;
Instance.SuppressImportSuccessTip = item.Table.Columns.Contains("SuppressImportSuccessTip") && !string.IsNullOrEmpty(item["SuppressImportSuccessTip"] + "") ? "1".Equals(item["SuppressImportSuccessTip"] + "") : false;
Instance.NewMain = item.Table.Columns.Contains("NewMain") && !string.IsNullOrEmpty(item["NewMain"] + "") ? "1".Equals(item["NewMain"] + "") : false;
if (Instance.NewMain)
{
Instance.MainLeftShowMode = "1";
Instance.DefaultMainTag = 4;
Instance.MainTopColor = item.Table.Columns.Contains("MainTopColor") && !string.IsNullOrEmpty(item["MainTopColor"] + "") ? item["MainTopColor"] + "" : "";
Instance.MainLeftSelectColor = item.Table.Columns.Contains("MainLeftSelectColor") && !string.IsNullOrEmpty(item["MainLeftSelectColor"] + "") ? item["MainLeftSelectColor"] + "" : "";
Instance.MainLeftColor = item.Table.Columns.Contains("MainLeftColor") && !string.IsNullOrEmpty(item["MainLeftColor"] + "") ? item["MainLeftColor"] + "" : "";
Instance.MainTopFontSize = item.Table.Columns.Contains("MainTopFontSize") && !string.IsNullOrEmpty(item["MainTopFontSize"] + "") ? Convert.ToInt32(item["MainTopFontSize"] + "") : 0;
Instance.MainLeftFontSize = item.Table.Columns.Contains("MainLeftFontSize") && !string.IsNullOrEmpty(item["MainLeftFontSize"] + "") ? Convert.ToInt32(item["MainLeftFontSize"] + "") : 0;
}
}
/// <summary>
/// 高拍仪AccessKey
/// </summary>
@@ -1179,5 +1191,34 @@ namespace Lskj.Business
/// P_MessageToolLinkDllTab表中cardId=-99为通用模块(右侧快捷通道通用模块) 2023-12-4 徐成说的cardId=-99的配置
/// </summary>
//public DataTable DefaultPermissionTable;
/// <summary>
/// 导入成功不会提示,直接关闭导入框(失败时还是会提示)
/// </summary>
public bool SuppressImportSuccessTip;
/// <summary>
/// 新版界面(读取 P_SystemTab.NewMaintrue 时加载 MainPanelControlEx2,默认使用旧界面)
/// </summary>
public bool NewMain;
/// <summary>
/// 新版界面顶部背景色
/// </summary>
public string MainTopColor;
/// <summary>
/// 新版界面左侧背景色
/// </summary>
public string MainLeftColor;
/// <summary>
/// 新版界面左侧选中背景色
/// </summary>
public string MainLeftSelectColor;
/// <summary>
/// 新版界面顶部字体大小
/// </summary>
public int MainTopFontSize;
/// <summary>
/// 新版界面左侧字体大小
/// </summary>
public int MainLeftFontSize;
}
}
@@ -87,7 +87,6 @@
<Compile Include="Impl\BillImpl.cs" />
<Compile Include="Impl\ConditionalCaching.cs" />
<Compile Include="Impl\ErrorMessage.cs" />
<Compile Include="Impl\InitialParamCache.cs" />
<Compile Include="Impl\LanguageTranslation.cs" />
<Compile Include="Impl\MainImpl.cs" />
<Compile Include="Impl\BillAuditImpl.cs" />
+8 -8
View File
@@ -175,7 +175,7 @@
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 26);
this.btnClose.TabIndex = 22;
this.btnClose.Text = "关闭(&Q)";
this.btnClose.Text = "关闭(Q)";
//
// btnBack
//
@@ -187,7 +187,7 @@
this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(75, 26);
this.btnBack.TabIndex = 21;
this.btnBack.Text = "返退(&N)";
this.btnBack.Text = "返退(N)";
this.btnBack.Click += new System.EventHandler(this.btnReturn_Click);
//
// btnSave
@@ -200,7 +200,7 @@
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(75, 26);
this.btnSave.TabIndex = 25;
this.btnSave.Text = "保存(&S)";
this.btnSave.Text = "保存(S)";
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// btnAccradit
@@ -213,7 +213,7 @@
this.btnAccradit.Name = "btnAccradit";
this.btnAccradit.Size = new System.Drawing.Size(75, 26);
this.btnAccradit.TabIndex = 20;
this.btnAccradit.Text = "审核(&Y)";
this.btnAccradit.Text = "审核(Y)";
this.btnAccradit.Click += new System.EventHandler(this.btnAccradit_Click);
//
// btnPrint
@@ -256,7 +256,7 @@
this.btnSpare.Name = "btnSpare";
this.btnSpare.Size = new System.Drawing.Size(75, 26);
this.btnSpare.TabIndex = 27;
this.btnSpare.Text = "分单(&P)";
this.btnSpare.Text = "分单(P)";
this.btnSpare.Click += new System.EventHandler(this.btnSpare_Click);
//
// pcTool
@@ -381,7 +381,7 @@
this.btnReflash.Name = "btnReflash";
this.btnReflash.Size = new System.Drawing.Size(75, 26);
this.btnReflash.TabIndex = 27;
this.btnReflash.Text = "刷新(&R)";
this.btnReflash.Text = "刷新(R)";
this.btnReflash.Click += new System.EventHandler(this.btnReflash_Click);
//
// panelControl1
@@ -523,7 +523,7 @@
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(72, 26);
this.btnSearch.TabIndex = 6;
this.btnSearch.Text = "搜索(&Q)";
this.btnSearch.Text = "搜索(Q)";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// labeldate_end
@@ -571,7 +571,7 @@
this.btnBackTop.Name = "btnBackTop";
this.btnBackTop.Size = new System.Drawing.Size(72, 26);
this.btnBackTop.TabIndex = 8;
this.btnBackTop.Text = "返审(&W)";
this.btnBackTop.Text = "返审(W)";
this.btnBackTop.Click += new System.EventHandler(this.btnBack_Click);
//
// pcBillDetail
+61 -2
View File
@@ -29,11 +29,35 @@ namespace Lskj.Control
{
public partial class AuditPanel2 : UserControl
{
private readonly AltButtonShortcutManager mAltButtonShortcuts =
new AltButtonShortcutManager();
public AuditPanel2()
{
InitializeComponent();
InitializeAltButtonShortcuts();
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.Selectable | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
}
private void InitializeAltButtonShortcuts()
{
mAltButtonShortcuts.Register(btnClose, Keys.Q);
mAltButtonShortcuts.Register(btnBack, Keys.N);
mAltButtonShortcuts.Register(btnSave, Keys.S);
mAltButtonShortcuts.Register(btnAccradit, Keys.Y);
mAltButtonShortcuts.Register(btnSpare, Keys.P);
mAltButtonShortcuts.Register(btnReflash, Keys.R);
mAltButtonShortcuts.Register(btnSearch, Keys.Q);
mAltButtonShortcuts.Register(btnBackTop, Keys.W);
}
protected override bool ProcessCmdKey(
ref System.Windows.Forms.Message msg, Keys keyData)
{
return mAltButtonShortcuts.ProcessKey(keyData) ||
base.ProcessCmdKey(ref msg, keyData);
}
#region
public string modelkeyName = "";
/// <summary>
@@ -1347,9 +1371,41 @@ namespace Lskj.Control
{
try
{
string billNo = this.SysModel.BillDocumentId;
List<string> billNoItems = new List<string>();
if (BaseAccraditModelObj.MuitlAuditFlag || BaseAccraditModelObj.MuitlAuditBackFlag)
{
foreach (TabPageObj tab in this._tabPageObjs)
{
if (tab.TabPage == this.tabMain.SelectedTabPage)
{
foreach (TabPageItemObj item in tab.TabPageItemObjs)
{
int[] mSelectRows = item.GridControlObj.GridView.GetSelectedRows();
foreach (int itemIndex in mSelectRows)
{
DataRow selectRow = item.GridControlObj.GridView.GetDataRow(itemIndex);
if (selectRow.Table.Columns.Contains(this.BillModelObj.PrimaryKey))
{
billNoItems.Add(selectRow[this.BillModelObj.PrimaryKey] + "");
}
}
}
}
}
}
else
{
billNoItems.Add(this.SysModel.BillDocumentId);
}
string printPath = PubUtil.PrintFileAbsolutelyPath;
string printFile = e.Item.Tag + "";
foreach (string billNo in billNoItems)
{
//string billNo = this.SysModel.BillDocumentId;
if (!string.IsNullOrEmpty(billNo))
{
DataRow masterRow = BillImpl.GetDataRowResult(ReplaceHelper.ReplaceParamToValue(this.BillModelObj.MasterSql, billNo));
@@ -1398,6 +1454,9 @@ namespace Lskj.Control
}
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
@@ -1601,7 +1660,7 @@ namespace Lskj.Control
this.btnClose.Enabled = this.btnSave.Enabled = this.btnAccradit.Enabled = this.btnBack.Enabled = this.btnSpare.Enabled = false;
this.btnSave.Visible = this.btnClose.Visible = this.btnBack.Visible = this.pcTool.Visible = true;
this.btnAccradit.Text = "确认(&Y)";
this.btnAccradit.Text = "确认(Y)";
return;
}
+174 -173
View File
@@ -32,14 +32,15 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label_tips = new DevExpress.XtraEditors.LabelControl();
this.label_date = new DevExpress.XtraEditors.LabelControl();
this.pl_bottom = new DevExpress.XtraEditors.PanelControl();
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.barManager1 = new DevExpress.XtraBars.BarManager();
this.p_menu = new DevExpress.XtraBars.PopupMenu(this.components);
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
@@ -48,34 +49,34 @@
this.btnBackAudit = new DevExpress.XtraEditors.SimpleButton();
this.btnRefresh = new DevExpress.XtraEditors.SimpleButton();
this.tabpage_finish = new DevExpress.XtraTab.XtraTabPage();
this.pl_top = new DevExpress.XtraEditors.PanelControl();
this.pl_top_right = new DevExpress.XtraEditors.PanelControl();
this.btnBack = new DevExpress.XtraEditors.SimpleButton();
this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton();
this.pl_top_searchCond = new DevExpress.XtraEditors.PanelControl();
this.labeldate_end = new Lskj.Control.LabelCheckDateEdit();
this.btnSearch = new DevExpress.XtraEditors.SimpleButton();
this.labeltxt_dataFlag = new Lskj.Control.LabelTextEdit();
this.labelcheck_finalAuditor = new Lskj.Control.LabelCheckAutoTextEdit();
this.labeldate_start = new Lskj.Control.LabelCheckDateEdit();
this.splitBelow = new DevExpress.XtraEditors.SplitContainerControl();
this.gridDetail = new Lskj.Control.GridControlEx();
this.gridFlow = new Lskj.Control.GridControlEx();
this.gridFinish = new Lskj.Control.GridControlEx();
this.splitBelow = new DevExpress.XtraEditors.SplitContainerControl();
this.gridFlow = new Lskj.Control.GridControlEx();
this.gridDetail = new Lskj.Control.GridControlEx();
this.pl_top = new DevExpress.XtraEditors.PanelControl();
this.pl_top_searchCond = new DevExpress.XtraEditors.PanelControl();
this.labeldate_start = new Lskj.Control.LabelCheckDateEdit();
this.labelcheck_finalAuditor = new Lskj.Control.LabelCheckAutoTextEdit();
this.labeltxt_dataFlag = new Lskj.Control.LabelTextEdit();
this.btnSearch = new DevExpress.XtraEditors.SimpleButton();
this.labeldate_end = new Lskj.Control.LabelCheckDateEdit();
this.pl_top_right = new DevExpress.XtraEditors.PanelControl();
this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton();
this.btnBack = new DevExpress.XtraEditors.SimpleButton();
this.tabMain = new DevExpress.XtraTab.XtraTabControl();
((System.ComponentModel.ISupportInitialize)(this.pl_bottom)).BeginInit();
this.pl_bottom.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.p_menu)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.barManager1)).BeginInit();
this.tabpage_finish.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pl_top)).BeginInit();
this.pl_top.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pl_top_right)).BeginInit();
this.pl_top_right.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pl_top_searchCond)).BeginInit();
this.pl_top_searchCond.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitBelow)).BeginInit();
this.splitBelow.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pl_top)).BeginInit();
this.pl_top.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pl_top_searchCond)).BeginInit();
this.pl_top_searchCond.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pl_top_right)).BeginInit();
this.pl_top_right.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.tabMain)).BeginInit();
this.tabMain.SuspendLayout();
this.SuspendLayout();
@@ -208,7 +209,7 @@
this.btnOkAudit.Name = "btnOkAudit";
this.btnOkAudit.Size = new System.Drawing.Size(82, 26);
this.btnOkAudit.TabIndex = 7;
this.btnOkAudit.Text = "批量审核(&Y)";
this.btnOkAudit.Text = "批量审核(Y)";
this.btnOkAudit.Visible = false;
this.btnOkAudit.Click += new System.EventHandler(this.OnBtnOkAuditClick);
//
@@ -221,7 +222,7 @@
this.btnBackAudit.Name = "btnBackAudit";
this.btnBackAudit.Size = new System.Drawing.Size(86, 26);
this.btnBackAudit.TabIndex = 6;
this.btnBackAudit.Text = "批量返审(&B)";
this.btnBackAudit.Text = "批量返审(B)";
this.btnBackAudit.Visible = false;
this.btnBackAudit.Click += new System.EventHandler(this.OnBtnBackAuditClick);
//
@@ -234,7 +235,7 @@
this.btnRefresh.Name = "btnRefresh";
this.btnRefresh.Size = new System.Drawing.Size(72, 26);
this.btnRefresh.TabIndex = 5;
this.btnRefresh.Text = "刷新(&R)";
this.btnRefresh.Text = "刷新(R)";
this.btnRefresh.Click += new System.EventHandler(this.BtnReflash_Click);
//
// tabpage_finish
@@ -246,6 +247,57 @@
this.tabpage_finish.Size = new System.Drawing.Size(1570, 1007);
this.tabpage_finish.Text = "已完成单据";
//
// gridFinish
//
this.gridFinish.AdapterObj = null;
this.gridFinish.AutoSize = true;
this.gridFinish.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridFinish.Location = new System.Drawing.Point(0, 39);
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(1570, 675);
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, 714);
this.splitBelow.Name = "splitBelow";
this.splitBelow.Panel1.Controls.Add(this.gridFlow);
this.splitBelow.Panel1.Text = "Panel1";
this.splitBelow.Panel2.Controls.Add(this.gridDetail);
this.splitBelow.Panel2.Text = "Panel2";
this.splitBelow.Size = new System.Drawing.Size(1570, 293);
this.splitBelow.SplitterPosition = 453;
this.splitBelow.TabIndex = 28;
this.splitBelow.Text = "splitContainerControl1";
//
// gridFlow
//
this.gridFlow.AdapterObj = null;
this.gridFlow.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridFlow.Location = new System.Drawing.Point(0, 0);
this.gridFlow.Margin = new System.Windows.Forms.Padding(4);
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
//
this.gridDetail.AdapterObj = null;
this.gridDetail.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridDetail.Location = new System.Drawing.Point(0, 0);
this.gridDetail.Margin = new System.Windows.Forms.Padding(4);
this.gridDetail.Name = "gridDetail";
this.gridDetail.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum;
this.gridDetail.Size = new System.Drawing.Size(1112, 293);
this.gridDetail.SysModel = null;
this.gridDetail.TabIndex = 20;
//
// pl_top
//
this.pl_top.Controls.Add(this.pl_top_searchCond);
@@ -256,41 +308,6 @@
this.pl_top.Size = new System.Drawing.Size(1570, 39);
this.pl_top.TabIndex = 25;
//
// pl_top_right
//
this.pl_top_right.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.pl_top_right.Controls.Add(this.simpleButton1);
this.pl_top_right.Controls.Add(this.btnBack);
this.pl_top_right.Dock = System.Windows.Forms.DockStyle.Right;
this.pl_top_right.Location = new System.Drawing.Point(1305, 2);
this.pl_top_right.Name = "pl_top_right";
this.pl_top_right.Size = new System.Drawing.Size(263, 35);
this.pl_top_right.TabIndex = 24;
//
// btnBack
//
this.btnBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnBack.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnBack.Appearance.Options.UseFont = true;
this.btnBack.Location = new System.Drawing.Point(100, 5);
this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(82, 26);
this.btnBack.TabIndex = 8;
this.btnBack.Text = "返审(&W)";
this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
//
// 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, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.simpleButton1.Appearance.Options.UseFont = true;
this.simpleButton1.Location = new System.Drawing.Point(188, 5);
this.simpleButton1.Name = "simpleButton1";
this.simpleButton1.Size = new System.Drawing.Size(72, 26);
this.simpleButton1.TabIndex = 9;
this.simpleButton1.Text = "帮助文档";
this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click);
//
// pl_top_searchCond
//
this.pl_top_searchCond.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
@@ -305,71 +322,6 @@
this.pl_top_searchCond.Size = new System.Drawing.Size(1303, 35);
this.pl_top_searchCond.TabIndex = 23;
//
// 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 = "终审时间止";
this.labeldate_end.Location = new System.Drawing.Point(216, 8);
this.labeldate_end.Margin = new System.Windows.Forms.Padding(4);
this.labeldate_end.Model = null;
this.labeldate_end.Name = "labeldate_end";
this.labeldate_end.NullText = null;
this.labeldate_end.ReadOnly = false;
this.labeldate_end.Required = false;
this.labeldate_end.Size = new System.Drawing.Size(196, 21);
this.labeldate_end.TabIndex = 12;
//
// btnSearch
//
this.btnSearch.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnSearch.Appearance.Options.UseFont = true;
this.btnSearch.Location = new System.Drawing.Point(774, 5);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(72, 26);
this.btnSearch.TabIndex = 6;
this.btnSearch.Text = "搜索(&Q)";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// 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 = "数据标识号";
this.labeltxt_dataFlag.Location = new System.Drawing.Point(605, 8);
this.labeltxt_dataFlag.Margin = new System.Windows.Forms.Padding(4);
this.labeltxt_dataFlag.Model = null;
this.labeltxt_dataFlag.Name = "labeltxt_dataFlag";
this.labeltxt_dataFlag.NullText = "";
this.labeltxt_dataFlag.ReadOnly = false;
this.labeltxt_dataFlag.Required = false;
this.labeltxt_dataFlag.Size = new System.Drawing.Size(164, 21);
this.labeltxt_dataFlag.TabIndex = 10;
//
// 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 = "终审人";
this.labelcheck_finalAuditor.Location = new System.Drawing.Point(419, 8);
this.labelcheck_finalAuditor.Margin = new System.Windows.Forms.Padding(4);
this.labelcheck_finalAuditor.Model = null;
this.labelcheck_finalAuditor.Name = "labelcheck_finalAuditor";
this.labelcheck_finalAuditor.NullText = null;
this.labelcheck_finalAuditor.ReadOnly = false;
this.labelcheck_finalAuditor.Required = false;
this.labelcheck_finalAuditor.Size = new System.Drawing.Size(180, 21);
this.labelcheck_finalAuditor.TabIndex = 13;
//
// labeldate_start
//
this.labeldate_start.BackColor = System.Drawing.Color.Transparent;
@@ -388,56 +340,105 @@
this.labeldate_start.Size = new System.Drawing.Size(196, 21);
this.labeldate_start.TabIndex = 11;
//
// splitBelow
// labelcheck_finalAuditor
//
this.splitBelow.Dock = System.Windows.Forms.DockStyle.Bottom;
this.splitBelow.Location = new System.Drawing.Point(0, 714);
this.splitBelow.Name = "splitBelow";
this.splitBelow.Panel1.Controls.Add(this.gridFlow);
this.splitBelow.Panel1.Text = "Panel1";
this.splitBelow.Panel2.Controls.Add(this.gridDetail);
this.splitBelow.Panel2.Text = "Panel2";
this.splitBelow.Size = new System.Drawing.Size(1570, 293);
this.splitBelow.SplitterPosition = 453;
this.splitBelow.TabIndex = 28;
this.splitBelow.Text = "splitContainerControl1";
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 = "终审人";
this.labelcheck_finalAuditor.Location = new System.Drawing.Point(419, 8);
this.labelcheck_finalAuditor.Margin = new System.Windows.Forms.Padding(4);
this.labelcheck_finalAuditor.Model = null;
this.labelcheck_finalAuditor.Name = "labelcheck_finalAuditor";
this.labelcheck_finalAuditor.NullText = null;
this.labelcheck_finalAuditor.ReadOnly = false;
this.labelcheck_finalAuditor.Required = false;
this.labelcheck_finalAuditor.Size = new System.Drawing.Size(180, 21);
this.labelcheck_finalAuditor.TabIndex = 13;
//
// gridDetail
// labeltxt_dataFlag
//
this.gridDetail.AdapterObj = null;
this.gridDetail.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridDetail.Location = new System.Drawing.Point(0, 0);
this.gridDetail.Margin = new System.Windows.Forms.Padding(4);
this.gridDetail.Name = "gridDetail";
this.gridDetail.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum;
this.gridDetail.Size = new System.Drawing.Size(1112, 293);
this.gridDetail.SysModel = null;
this.gridDetail.TabIndex = 20;
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 = "数据标识号";
this.labeltxt_dataFlag.Location = new System.Drawing.Point(605, 8);
this.labeltxt_dataFlag.Margin = new System.Windows.Forms.Padding(4);
this.labeltxt_dataFlag.Model = null;
this.labeltxt_dataFlag.Name = "labeltxt_dataFlag";
this.labeltxt_dataFlag.NullText = "";
this.labeltxt_dataFlag.ReadOnly = false;
this.labeltxt_dataFlag.Required = false;
this.labeltxt_dataFlag.Size = new System.Drawing.Size(164, 21);
this.labeltxt_dataFlag.TabIndex = 10;
//
// gridFlow
// btnSearch
//
this.gridFlow.AdapterObj = null;
this.gridFlow.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridFlow.Location = new System.Drawing.Point(0, 0);
this.gridFlow.Margin = new System.Windows.Forms.Padding(4);
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;
this.btnSearch.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnSearch.Appearance.Options.UseFont = true;
this.btnSearch.Location = new System.Drawing.Point(774, 5);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(72, 26);
this.btnSearch.TabIndex = 6;
this.btnSearch.Text = "搜索(Q)";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// gridFinish
// labeldate_end
//
this.gridFinish.AdapterObj = null;
this.gridFinish.AutoSize = true;
this.gridFinish.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridFinish.Location = new System.Drawing.Point(0, 39);
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(1570, 675);
this.gridFinish.SysModel = null;
this.gridFinish.TabIndex = 29;
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 = "终审时间止";
this.labeldate_end.Location = new System.Drawing.Point(216, 8);
this.labeldate_end.Margin = new System.Windows.Forms.Padding(4);
this.labeldate_end.Model = null;
this.labeldate_end.Name = "labeldate_end";
this.labeldate_end.NullText = null;
this.labeldate_end.ReadOnly = false;
this.labeldate_end.Required = false;
this.labeldate_end.Size = new System.Drawing.Size(196, 21);
this.labeldate_end.TabIndex = 12;
//
// pl_top_right
//
this.pl_top_right.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.pl_top_right.Controls.Add(this.simpleButton1);
this.pl_top_right.Controls.Add(this.btnBack);
this.pl_top_right.Dock = System.Windows.Forms.DockStyle.Right;
this.pl_top_right.Location = new System.Drawing.Point(1305, 2);
this.pl_top_right.Name = "pl_top_right";
this.pl_top_right.Size = new System.Drawing.Size(263, 35);
this.pl_top_right.TabIndex = 24;
//
// 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, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.simpleButton1.Appearance.Options.UseFont = true;
this.simpleButton1.Location = new System.Drawing.Point(188, 5);
this.simpleButton1.Name = "simpleButton1";
this.simpleButton1.Size = new System.Drawing.Size(72, 26);
this.simpleButton1.TabIndex = 9;
this.simpleButton1.Text = "帮助文档";
this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click);
//
// btnBack
//
this.btnBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnBack.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnBack.Appearance.Options.UseFont = true;
this.btnBack.Location = new System.Drawing.Point(100, 5);
this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(82, 26);
this.btnBack.TabIndex = 8;
this.btnBack.Text = "返审(W)";
this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
//
// tabMain
//
@@ -470,14 +471,14 @@
((System.ComponentModel.ISupportInitialize)(this.barManager1)).EndInit();
this.tabpage_finish.ResumeLayout(false);
this.tabpage_finish.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pl_top)).EndInit();
this.pl_top.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pl_top_right)).EndInit();
this.pl_top_right.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pl_top_searchCond)).EndInit();
this.pl_top_searchCond.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitBelow)).EndInit();
this.splitBelow.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pl_top)).EndInit();
this.pl_top.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pl_top_searchCond)).EndInit();
this.pl_top_searchCond.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pl_top_right)).EndInit();
this.pl_top_right.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.tabMain)).EndInit();
this.tabMain.ResumeLayout(false);
this.ResumeLayout(false);
+24 -2
View File
@@ -42,10 +42,29 @@ namespace Lskj.Control
public partial class AuditPanelEx : UserControl
{
private bool mResourcesReleased;
private readonly AltButtonShortcutManager mAltButtonShortcuts =
new AltButtonShortcutManager();
public AuditPanelEx()
{
InitializeComponent();
InitializeAltButtonShortcuts();
}
private void InitializeAltButtonShortcuts()
{
mAltButtonShortcuts.Register(btnOkAudit, Keys.Y);
mAltButtonShortcuts.Register(btnBackAudit, Keys.B);
mAltButtonShortcuts.Register(btnRefresh, Keys.R);
mAltButtonShortcuts.Register(btnBack, Keys.W);
mAltButtonShortcuts.Register(btnSearch, Keys.Q);
}
protected override bool ProcessCmdKey(
ref System.Windows.Forms.Message msg, Keys keyData)
{
return mAltButtonShortcuts.ProcessKey(keyData) ||
base.ProcessCmdKey(ref msg, keyData);
}
internal void ReleaseResourcesForDispose()
@@ -94,7 +113,7 @@ namespace Lskj.Control
{
if (SysModel != null && SysModel.DataCaches != null)
{
SysModel.DataCaches.Remove(this);
SysModel.DataCaches.RemoveCache(this);
}
}
catch
@@ -673,6 +692,9 @@ namespace Lskj.Control
gridPanel.Dock = DockStyle.Right;
gridPanel.BorderStyle = BorderStyles.NoBorder;
GridControlEx grid = new GridControlEx();
grid.Model = this.SysModel;
if (dataCaches != null)
{
grid.GetDataCaches(dataCaches, modelkeyName + key);
@@ -693,7 +715,7 @@ namespace Lskj.Control
grid.SetGridRightMenus(dtGridRightMenus, SysModel);
grid.GridView.Tag = accrModel;
grid.GridView.DoubleClick += new EventHandler(OnGridViewDoubleClick);
grid.Model = this.SysModel;
//grid.Model = this.SysModel;
// 追加复选框用于批量审批
if (BaseAccraditModelObj.MuitlAuditFlag || BaseAccraditModelObj.MuitlAuditBackFlag)
{
+252 -5
View File
@@ -122,6 +122,8 @@ namespace Lskj.Control
this.bandedGridView.PopupMenuShowing += new DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventHandler(this.OnGridViewPopupMenuShowing);
this.bandedGridView.Click += new EventHandler(OnBandedGridView_Click);
this.bandedGridView.DoubleClick += new EventHandler(OnBandedGridViewDoubleClick);
// 多表头的操作列使用 BandedGridView,复用基类的禁编按钮点击处理。
this.bandedGridView.MouseDown += GridView_MouseDown;
this.bandedGridView.CustomDrawGroupRow += new RowObjectCustomDrawEventHandler(OnGridCustomDrawGroupRow);
this.bandedGridView.LeftCoordChanged += OnBandedLeftCoordChanged;
this.SetGridRowHeightAndFont();
@@ -133,6 +135,236 @@ namespace Lskj.Control
this.bandedGridView.ShowingEditor += GridView_ShowingEditor;
}
/// <summary>
/// 多表头创建或重建操作列。
/// 操作列不参与业务列配置,只挂到空白一级表头的最右侧。
/// </summary>
protected override void TryInitRightMenuBtnEdit(bool rebuild)
{
if (!this.gridColumnsInitialized || this.Model == null ||
(this.CustomColumKey ?? string.Empty).Contains("BaseLeftGridView_"))
{
return;
}
BandedGridColumn oldColumn = this.bandedGridView.Columns["RightMenuBtnEdit"];
bool showButtonColumn = this.rightMenuButtonTable != null &&
this.rightMenuButtonTable.Rows.Cast<DataRow>().Any(row =>
(row.Table.Columns.Contains("IcoName") &&
!string.IsNullOrWhiteSpace(row["IcoName"] + "")) ||
(row.Table.Columns.Contains("showtoolbar") &&
"1".Equals(row["showtoolbar"] + "")));
if (!showButtonColumn)
{
if (oldColumn != null)
{
this.RemoveRightMenuButtonColumn(oldColumn);
}
return;
}
if (oldColumn != null)
{
if (!rebuild)
{
return;
}
this.RemoveRightMenuButtonColumn(oldColumn);
}
this.InitRightMenuBtnEdit(this.rightMenuButtonTable);
DataTable dataSource = this.GridControl == null ? null : this.GridControl.DataSource as DataTable;
if (dataSource != null && !dataSource.Columns.Contains("RightMenuBtnEdit"))
{
dataSource.Columns.Add("RightMenuBtnEdit");
}
}
/// <summary>
/// 删除旧操作列,同时保持空白一级表头下其他列的现有宽度。
/// </summary>
private void RemoveRightMenuButtonColumn(BandedGridColumn oldColumn)
{
GridBand ownerBand = oldColumn.OwnerBand;
int oldColumnWidth = oldColumn.Width;
int originalBandWidth = ownerBand == null ? 0 : ownerBand.Width;
Dictionary<BandedGridColumn, int> originalColumnWidths = ownerBand == null
? new Dictionary<BandedGridColumn, int>()
: ownerBand.Columns.Cast<BandedGridColumn>()
.Where(column => column != oldColumn)
.ToDictionary(column => column, column => column.Width);
this.bandedGridView.BeginUpdate();
try
{
this.bandedGridView.Columns.Remove(oldColumn);
if (ownerBand == null)
{
return;
}
if (ownerBand.Columns.Count == 0)
{
this.bandedGridView.Bands.Remove(ownerBand);
}
else
{
ownerBand.Width = Math.Max(0, originalBandWidth - oldColumnWidth);
foreach (KeyValuePair<BandedGridColumn, int> item in originalColumnWidths)
{
item.Key.Width = item.Value;
}
}
}
finally
{
this.bandedGridView.EndUpdate();
}
}
/// <summary>
/// 创建多表头操作列,并将其放到空白一级表头的最右侧。
/// </summary>
protected override void InitRightMenuBtnEdit(DataTable rightMenuTab)
{
if (rightMenuTab == null)
{
return;
}
BandedGridColumn gridColumn = new BandedGridColumn();
gridColumn.FieldName = "RightMenuBtnEdit";
gridColumn.Name = "RightMenuBtnEdit";
gridColumn.Caption = "操作列";
gridColumn.Visible = true;
gridColumn.OptionsColumn.AllowEdit = true;
RepositoryItemButtonEdit itemButtonEdit = new RepositoryItemButtonEdit();
itemButtonEdit.Buttons.Clear();
itemButtonEdit.AppearanceDisabled.Options.UseTextOptions = true;
itemButtonEdit.AppearanceDisabled.TextOptions.HAlignment = HorzAlignment.Center;
itemButtonEdit.TextEditStyle = TextEditStyles.HideTextEditor;
itemButtonEdit.ButtonsStyle = BorderStyles.UltraFlat;
itemButtonEdit.BorderStyle = BorderStyles.NoBorder;
itemButtonEdit.ButtonClick += new ButtonPressedEventHandler(OnItemButtonEdit_ButtonClick);
int columnWidth = 0;
if (rightMenuTab.Columns.Contains("IcoName"))
{
DataRow[] rightMenuButtons = rightMenuTab.Select()
.Where(n => !string.IsNullOrEmpty(n["IcoName"] + ""))
.ToArray();
int pictureWidth = 30;
foreach (DataRow rightMenu in rightMenuButtons)
{
GridRightMenuModel menuModel = new GridRightMenuModel(rightMenu);
if (string.IsNullOrWhiteSpace(menuModel.MenuName))
{
continue;
}
EditorButton editorButton = new EditorButton();
editorButton.Appearance.BackColor = Color.Transparent;
if (!string.IsNullOrEmpty(menuModel.IcoName))
{
try
{
Image image = GetRightMenuButtonImage(menuModel.IcoName);
if (image != null && image.Width > 30)
{
pictureWidth = image.Width;
}
editorButton.Image = image;
}
catch (Exception)
{
}
}
editorButton.ToolTip = menuModel.MenuName;
editorButton.Kind = ButtonPredefines.Glyph;
editorButton.Width = pictureWidth;
editorButton.Tag = menuModel;
itemButtonEdit.Buttons.Add(editorButton);
}
columnWidth = rightMenuButtons.Length * pictureWidth;
}
if (rightMenuTab.Columns.Contains("showtoolbar"))
{
DataRow[] rightMenuTextButtons = rightMenuTab.Select()
.Where(n => "1".Equals(n["showtoolbar"] + ""))
.ToArray();
foreach (DataRow rightMenu in rightMenuTextButtons)
{
GridRightMenuModel menuModel = new GridRightMenuModel(rightMenu);
if (string.IsNullOrWhiteSpace(menuModel.MenuName))
{
continue;
}
EditorButton editorButton = new EditorButton();
editorButton.Caption = menuModel.MenuName + "";
editorButton.ToolTip = menuModel.MenuName;
editorButton.Kind = ButtonPredefines.Glyph;
editorButton.Width = this.CalculateTextWidth(editorButton.Caption, editorButton.Appearance.Font);
editorButton.Tag = menuModel;
editorButton.Appearance.BackColor = Color.FromArgb(240, 240, 240);
editorButton.Appearance.BorderColor = Color.FromArgb(180, 180, 180);
editorButton.Appearance.ForeColor = Color.FromArgb(50, 50, 50);
editorButton.Appearance.Options.UseBackColor = true;
editorButton.Appearance.Options.UseBorderColor = true;
editorButton.Appearance.Options.UseForeColor = true;
itemButtonEdit.Buttons.Add(editorButton);
columnWidth += editorButton.Width;
}
}
gridColumn.ColumnEdit = itemButtonEdit;
gridColumn.MaxWidth = columnWidth;
gridColumn.MinWidth = columnWidth;
gridColumn.Width = columnWidth;
GridBand emptyBand = this.bandedGridView.Bands.Cast<GridBand>()
.FirstOrDefault(x => string.IsNullOrEmpty(x.Caption));
if (emptyBand == null)
{
emptyBand = new GridBand();
emptyBand.Caption = "";
emptyBand.AppearanceHeader.Options.UseFont = true;
emptyBand.AppearanceHeader.Font = new Font("宋体", 9, FontStyle.Bold);
emptyBand.AppearanceHeader.Options.UseTextOptions = true;
emptyBand.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
this.bandedGridView.Bands.Add(emptyBand);
}
int originalBandWidth = emptyBand.Width;
Dictionary<BandedGridColumn, int> originalColumnWidths = emptyBand.Columns
.Cast<BandedGridColumn>()
.ToDictionary(column => column, column => column.Width);
this.bandedGridView.BeginUpdate();
try
{
emptyBand.Columns.Add(gridColumn);
this.bandedGridView.Columns.Add(gridColumn);
gridColumn.ColVIndex = emptyBand.Columns.Count - 1;
// DevExpress 默认保持 Band 总宽度,新增列时会压缩同一 Band 下的原列。
// 恢复原列宽,并单独为操作列扩展一级表头宽度。
emptyBand.Width = originalBandWidth + columnWidth;
foreach (KeyValuePair<BandedGridColumn, int> item in originalColumnWidths)
{
item.Key.Width = item.Value;
}
gridColumn.Width = columnWidth;
}
finally
{
this.bandedGridView.EndUpdate();
}
this.bandedGridView.OptionsBehavior.EditorShowMode = EditorShowMode.MouseDown;
}
/// <summary>
@@ -574,6 +806,7 @@ namespace Lskj.Control
protected void AddBandColumns(DataTable table, bool readOnly = true)
{
if (table == null) return;
this.gridColumnsInitialized = false;
this.InitGridColumsTab = table;
this.mControlList.Clear();
List<String> bandFieldstr = new List<String>();
@@ -844,6 +1077,8 @@ namespace Lskj.Control
// 加载数据源
//BindDataSource();
this.SetCustomColumns();//加载多表头自定义列
this.gridColumnsInitialized = true;
this.TryInitRightMenuBtnEdit(false);
//多表头冻结
foreach (BandedGridColumn item in FrozenColumns)
@@ -2512,10 +2747,17 @@ namespace Lskj.Control
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected virtual void Multifunction(object sender, EventArgs e)
{
StaticControl.ModuleResourceScope moduleScope = null;
try
{
//DataTable newDt = this.SetDealWithValueTab();
FrmGridSift frmGridSift = new FrmGridSift();
string guid = Guid.NewGuid().ToString();
moduleScope = new StaticControl.ModuleResourceScope(guid);
FrmGridSift frmGridSift;
using (StaticControl.PushModuleScope(moduleScope))
{
frmGridSift = new FrmGridSift();
}
frmGridSift.CustomColumKey = this.CustomColumKey;
//frmGridSift.source = newDt;
frmGridSift.ParentGridEx = this;
@@ -2524,10 +2766,9 @@ namespace Lskj.Control
DllName = "",
Id = this.Model.ModuleCode,
Name = this.Model.FormText,
BeforePage = ERPInfo.Instance.PageControl.SelectedTabPage
BeforePage = ERPInfo.Instance.CurrentModulePage
};
module.ModuleForm = frmGridSift;
string guid = Guid.NewGuid().ToString();
DevExpress.XtraTab.XtraTabPage tp = new DevExpress.XtraTab.XtraTabPage();
tp.Tag = guid;
// 这个必须有不然会提示:"不能向tabControl中添加顶级控件"
@@ -2541,13 +2782,19 @@ namespace Lskj.Control
tp.Controls.Add(frmGridSift);
tp.ShowCloseButton = DefaultBoolean.True;
tp.Dock = DockStyle.Fill;
ERPInfo.Instance.PageControl.TabPages.Add(tp);
ERPInfo.Instance.PageControl.SelectedTabPage = tp;
StaticControl.RegisterModulePage(module, tp, frmGridSift);
ERPInfo.Instance.AddModulePage(tp);
ERPInfo.Instance.CurrentModulePage = tp;
ERPInfo.Instance.ModuleForms.Add(guid, module);
using (StaticControl.PushModuleScope(moduleScope))
{
frmGridSift.Show();
}
}
catch (Exception ex)
{
if (moduleScope != null)
moduleScope.Dispose();
string Message = ErrorMessage.PromptErrorMessage(ex, Model.ModuleCode);
MessageUtil.Show(Message, ex.Message);
}
+4 -2
View File
@@ -75,12 +75,14 @@ namespace Lskj.Control
case ControlType.LabDate:
case ControlType.LabDateTime:
case ControlType.LabDateTimeShort:
case ControlType.LabTime:
case ControlType.LabShortTime:
// 日期控件
LabelDateEdit dateEdit = this as LabelDateEdit;
UpdContrast = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.EditValue.ToString();
break;
case ControlType.LabTime:
case ControlType.LabShortTime:
LabelTimeEdit timeEdit = this as LabelTimeEdit;
return timeEdit != null && !timeEdit.IsSameTime(this.Model.Text);
}
return this.Model == null || this.Model.Text == null || !this.Model.Text.Equals(UpdContrast, StringComparison.OrdinalIgnoreCase);
}
+60 -109
View File
@@ -78,17 +78,17 @@ namespace Lskj.Control.BrowserSetting
string arg2 = message.Arguments.GetString(2);
string arg3 = message.Arguments.GetString(3);
string arg4 = message.Arguments.GetString(4);
PostToUiThread(
ERPInfo.Instance.MainControl,
delegate
if (ERPInfo.Instance.MainControl.InvokeRequired)
{
BsOpenModuleHandler.OpenModule(
arg0,
arg1,
arg2,
arg3,
arg4);
});
ERPInfo.Instance.MainControl.Invoke(new Action(() =>
{
BsOpenModuleHandler.OpenModule(arg0, arg1, arg2, arg3, arg4);
}));
}
else
{
BrowserSetting.BsOpenModuleHandler.OpenModule(arg0, arg1, arg2, arg3, arg4);
}
}
else if (message.Name.Equals("OpenOnRightClick"))
{
@@ -96,103 +96,75 @@ namespace Lskj.Control.BrowserSetting
string arg1 = message.Arguments.GetString(1);
string arg2 = message.Arguments.GetString(2);
string arg3 = message.Arguments.GetString(3);
PostToUiThread(
ERPInfo.Instance.MainControl,
delegate
if (ERPInfo.Instance.MainControl.InvokeRequired)
{
BsOpenModuleHandler.OpenRightModule(
arg0,
arg1,
arg2,
arg3);
});
ERPInfo.Instance.MainControl.Invoke(new Action(() =>
{
BsOpenModuleHandler.OpenRightModule(arg0, arg1, arg2, arg3);
}));
}
else
{
BsOpenModuleHandler.OpenRightModule(arg0, arg1, arg2, arg3);
}
}
else if (message.Name.Equals("CloseWin"))
{
var browserControl = frmWebBrowser;
PostToUiThread(
browserControl,
delegate
if (frmWebBrowser != null && frmWebBrowser.Parent != null && frmWebBrowser.Parent.Parent != null && frmWebBrowser.Parent.Parent is BaseForm baseForm)
{
if (baseForm.InvokeRequired)
{
baseForm.Invoke(new Action(() =>
{
// Parent/Parent is a WinForms control-tree read and must
// not run on CEF's UI thread.
var parent = browserControl.Parent;
var baseForm = parent == null
? null
: parent.Parent as BaseForm;
if (baseForm == null || baseForm.IsDisposed)
return;
baseForm.DialogResult = DialogResult.OK;
baseForm.Close();
});
}));
}
else
{
baseForm.DialogResult = DialogResult.OK;
baseForm.Close();
}
}
}
else if (message.Name.Equals("SelectPro"))
{
string arg0 = message.Arguments.GetString(0);
string arg1 = message.Arguments.GetString(1);
bool isclose = arg1!=null&&!string.IsNullOrWhiteSpace(arg1) && arg1.Equals("1") ? true : false;
var browserControl = frmWebBrowser;
PostToUiThread(
browserControl,
delegate
if (frmWebBrowser != null && frmWebBrowser.Parent != null && frmWebBrowser.Parent.Parent != null && frmWebBrowser.Parent.Parent is BaseForm baseForm)
{
if (baseForm.InvokeRequired)
{
baseForm.Invoke(new Action(() =>
{
var parent = browserControl.Parent;
var baseForm = parent == null
? null
: parent.Parent as BaseForm;
if (baseForm == null || baseForm.IsDisposed)
return;
BsOpenModuleHandler.AddReturnRow(arg0);
if (isclose)
{
baseForm.DialogResult = DialogResult.OK;
baseForm.Close();
}
});
}));
}
else
{
BsOpenModuleHandler.AddReturnRow(arg0);
if (isclose)
{
baseForm.DialogResult = DialogResult.OK;
baseForm.Close();
}
}
}
}
return base.OnProcessMessageReceived(browser, frame, sourceProcess, message);
}
private static void PostToUiThread(
System.Windows.Forms.Control control,
Action action)
{
if (control == null || action == null || control.IsDisposed ||
!control.IsHandleCreated)
return;
Action guardedAction = delegate
{
if (control.IsDisposed)
return;
try
{
action();
}
catch (Exception exception)
{
ReportProcessMessageFailure(exception);
}
};
try
{
// CEF invokes OnProcessMessageReceived on its UI thread. A
// synchronous Control.Invoke can block that thread inside a
// modal dialog while the dialog waits for CEF to create its
// browser. Always queue the operation and return to CEF first.
control.BeginInvoke(guardedAction);
}
catch (Exception exception)
{
ReportProcessMessageFailure(exception);
}
}
private static void ReportProcessMessageFailure(Exception exception)
{
try
@@ -201,10 +173,10 @@ namespace Lskj.Control.BrowserSetting
}
catch
{
// Never propagate logging failures into a native CEF callback.
// Logging must never rethrow across the native CEF callback.
}
Action showError = delegate
Action showError = () =>
{
try
{
@@ -212,14 +184,14 @@ namespace Lskj.Control.BrowserSetting
}
catch
{
// Error reporting must never terminate the browser callback.
}
};
try
{
System.Windows.Forms.Control mainControl = ERPInfo.Instance.MainControl;
if (mainControl == null || mainControl.IsDisposed ||
!mainControl.IsHandleCreated)
if (mainControl == null || mainControl.IsDisposed || !mainControl.IsHandleCreated)
return;
if (mainControl.InvokeRequired)
@@ -229,36 +201,15 @@ namespace Lskj.Control.BrowserSetting
}
catch
{
// The main window may close while the callback is reporting.
// The main window may close while the CEF callback is reporting.
}
}
public void Created(CefBrowser cefBrowser)
{
if (frmWebBrowser != null && OnCreated != null)
if (OnCreated != null)
{
OnCreated(cefBrowser, EventArgs.Empty);
}
}
public bool Closing(CefBrowser browser)
{
var control = frmWebBrowser;
return control != null && control.BrowserClosing(browser);
}
public void Closed(CefBrowser browser)
{
var control = frmWebBrowser;
if (control != null)
{
control.BrowserClosed(browser);
if (control.cefBrowserSettings == null)
{
frmWebBrowser = null;
OnCreated = null;
}
}
}
}
}
@@ -42,7 +42,7 @@ namespace Lskj.Control.BrowserSetting
}
if (BsClient != null && BsClient.frmWebBrowser != null && BsClient.frmWebBrowser.Parent != null && BsClient.frmWebBrowser.Parent.Name.Equals("previewFrm"))
{
BsClient.frmWebBrowser.CloseBrowser();
browser.GetHost().CloseBrowser();
}
else if (BsClient != null && BsClient.frmWebBrowser != null)
{
@@ -196,24 +196,11 @@ namespace Lskj.Control.BrowserSetting
try
{
if (browser == null) return null;
IntPtr browserHandle;
using (var browserHost = browser.GetHost())
{
browserHandle = browserHost.GetWindowHandle();
}
IntPtr browserHandle = browser.GetHost().GetWindowHandle();
if (browserHandle == IntPtr.Zero) return null;
IntPtr parentHandle = GetParent(browserHandle);
System.Windows.Forms.Control control = null;
while (parentHandle != IntPtr.Zero && control == null)
{
// The CEF child now sits inside an application-owned native
// host. Walk through that host to preserve the original
// FrmWebBrowser-based module lookup.
control = System.Windows.Forms.Control.FromHandle(parentHandle);
parentHandle = GetParent(parentHandle);
}
if (control == null) return null;
if (parentHandle == IntPtr.Zero) return null;
System.Windows.Forms.Control control = System.Windows.Forms.Control.FromHandle(parentHandle);
if (control != null && control.Parent != null && control.Parent.Parent != null)
{
@@ -20,20 +20,9 @@ namespace Lskj.Control.BrowserSetting
base.OnAfterCreated(browser);
BsClient.Created(browser);
}
protected override bool DoClose(CefBrowser browser)
{
// CEF sends WM_CLOSE to the parked application-owned host after
// this callback. The host only allows that second close attempt.
return BsClient.Closing(browser);
}
protected override void OnBeforeClose(CefBrowser browser)
{
base.OnBeforeClose(browser);
// Release owner references after CEF completes its async close.
BsClient.Closed(browser);
}
protected override bool OnBeforePopup(
@@ -171,12 +171,12 @@ namespace Lskj.Control.BrowserSetting
dllName = MainImpl.GetDefaultValue(dllName);
if (SystemInfo.Instance.SoftOpenMode)
{
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Text == menuName)
{
MessageUtil.Show("已设置不能打开多个相同模块!");
ERPInfo.Instance.PageControl.SelectedTabPage = tablepage;
ERPInfo.Instance.CurrentModulePage = tablepage;
return;
}
}
@@ -247,13 +247,25 @@ namespace Lskj.Control.BrowserSetting
/// <param name="args">The arguments.</param>
public static void AddModuleToTab(DllModule module, string[] args)
{
StaticControl.ModuleResourceScope moduleScope = null;
try
{
string guid = Guid.NewGuid().ToString();
XtraTabPage tp = new XtraTabPage();
moduleScope = new StaticControl.ModuleResourceScope(guid);
StaticControl.AttachModuleScope(tp, moduleScope);
moduleScope.Register(tp, () =>
{
if (!tp.IsDisposed)
tp.Dispose();
});
ERPInfo.Instance.selectFormModleId = module.Id;
IForm iform = FormHelper.LoadDllForm(module.DllName, args);
IForm iform;
using (StaticControl.PushModuleScope(moduleScope))
{
iform = FormHelper.LoadDllForm(module.DllName, args);
}
// 菜单打开的模块默认最大化,界面FormState设置为Normal模式,否则会出现界面不是全屏,会显示默认阴影界面
//iform.SubForm.WindowState = _frmMain.WindowState;
iform.SubForm.WindowState = FormWindowState.Normal; ;
@@ -278,37 +290,37 @@ namespace Lskj.Control.BrowserSetting
tp.ShowCloseButton = DefaultBoolean.True;
tp.Dock = DockStyle.Fill;
//module.Tag = "1";
module.Tag = guid;
module.ModuleForm = form;
StaticControl.RegisterModulePage(module, tp, form);
// OnLoad may create additional non-visual helpers. Keep the
// module scope active until the form has finished loading so
// those helpers are registered with the same page lifetime.
using (StaticControl.PushModuleScope(moduleScope))
{
form.Show();
}
if (args != null && !string.IsNullOrEmpty(args[4] + ""))
{
ModuleModel moduleModel = new ModuleModel(MainImpl.GetSystemdllTab(args[4] + ""));
if (!string.IsNullOrEmpty(moduleModel.SearchCondFormModuleCode))
{
ModuleConditionsPanelEx mcpex = new ModuleConditionsPanelEx();
using (ModuleConditionsPanelEx mcpex = new ModuleConditionsPanelEx())
{
mcpex.InitializeControl(new ModuleModel(MainImpl.GetSystemdllTab(moduleModel.SearchCondFormModuleCode)), null, null, true);
if (StaticControl.ConditionsPanelDic.ContainsKey(args[4] + ""))
{
StaticControl.ConditionsPanelDic[args[4] + ""].Dispose();
StaticControl.ConditionsPanelDic[args[4] + ""] = mcpex;
}
else
{
StaticControl.ConditionsPanelDic.Add(args[4] + "", mcpex);
}
StaticControl.RegisterConditionPanel(args[4] + "", mcpex);
DialogResult dialogResult = mcpex.ShowDialog();
}
}
ERPInfo.Instance.PageControl.TabPages.Add(tp);
ERPInfo.Instance.PageControl.SelectedTabPage = tp;
}
ERPInfo.Instance.AddModulePage(tp);
ERPInfo.Instance.CurrentModulePage = tp;
ERPInfo.Instance.ModuleForms.Add(guid, module);
}
catch (Exception ex)
{
if (moduleScope != null)
moduleScope.Dispose();
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
LogHelper.Instance.WriteError(ex);
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xilium.CefGlue;
using Lskj.Business;
namespace Lskj.Control.BrowserSetting
{
@@ -47,12 +46,7 @@ namespace Lskj.Control.BrowserSetting
protected override void OnRenderProcessTerminated(CefBrowser browser, CefTerminationStatus status)
{
// Reloading immediately from this callback can create a new
// renderer while the old one is tearing down and cause a native
// libcef crash loop. Record the termination and let the module
// lifecycle decide whether a later reopen is appropriate.
LogUtil.WriteError("CEF 渲染进程已终止,状态=" + status,
new InvalidOperationException("CEF renderer termination status=" + status));
browser.Reload();
}
}
@@ -1,6 +1,5 @@
using Lskj.Business;
using Lskj.Model;
using Lskj.Util;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -55,19 +54,6 @@ namespace Lskj.Control.BrowserSetting2
return contextMenuHandler;
}
protected override bool OnProcessMessageReceived(CefBrowser browser, CefFrame frame, CefProcessId sourceProcess, CefProcessMessage message)
{
try
{
return OnProcessMessageReceivedCore(browser, frame, sourceProcess, message);
}
catch (Exception exception)
{
ReportProcessMessageFailure(exception);
return true;
}
}
private bool OnProcessMessageReceivedCore(CefBrowser browser, CefFrame frame, CefProcessId sourceProcess, CefProcessMessage message)
{
if (message.Name.Equals("OpenModule"))
{
@@ -76,17 +62,17 @@ namespace Lskj.Control.BrowserSetting2
string arg2 = message.Arguments.GetString(2);
string arg3 = message.Arguments.GetString(3);
string arg4 = message.Arguments.GetString(4);
PostToUiThread(
ERPInfo.Instance.MainControl,
delegate
if (ERPInfo.Instance.MainControl.InvokeRequired)
{
BrowserSetting.BsOpenModuleHandler.OpenModule(
arg0,
arg1,
arg2,
arg3,
arg4);
});
ERPInfo.Instance.MainControl.Invoke(new Action(() =>
{
BrowserSetting.BsOpenModuleHandler.OpenModule(arg0, arg1, arg2, arg3, arg4);
}));
}
else
{
BrowserSetting.BsOpenModuleHandler.OpenModule(arg0, arg1, arg2, arg3, arg4);
}
}
else if (message.Name.Equals("OpenOnRightClick"))
{
@@ -94,140 +80,43 @@ namespace Lskj.Control.BrowserSetting2
string arg1 = message.Arguments.GetString(1);
string arg2 = message.Arguments.GetString(2);
string arg3 = message.Arguments.GetString(3);
PostToUiThread(
ERPInfo.Instance.MainControl,
delegate
if (ERPInfo.Instance.MainControl.InvokeRequired)
{
BrowserSetting.BsOpenModuleHandler.OpenRightModule(
arg0,
arg1,
arg2,
arg3);
});
ERPInfo.Instance.MainControl.Invoke(new Action(() =>
{
BrowserSetting.BsOpenModuleHandler.OpenRightModule(arg0, arg1, arg2, arg3);
}));
}
else
{
BrowserSetting.BsOpenModuleHandler.OpenRightModule(arg0, arg1, arg2, arg3);
}
}
else if (message.Name.Equals("CloseWin"))
{
var browserControl = frmWebBrowser;
PostToUiThread(
browserControl,
delegate
if (frmWebBrowser != null && frmWebBrowser.Parent != null && frmWebBrowser.Parent.Parent != null && frmWebBrowser.Parent.Parent is BaseForm baseForm)
{
if (baseForm.InvokeRequired)
{
baseForm.Invoke(new Action(() =>
{
// Resolve the owning form only after returning to the
// WinForms UI thread.
var parent = browserControl.Parent;
var baseForm = parent == null
? null
: parent.Parent as BaseForm;
if (baseForm == null || baseForm.IsDisposed)
return;
baseForm.Close();
});
}));
}
else
{
baseForm.Close();
}
}
}
return base.OnProcessMessageReceived(browser, frame, sourceProcess, message);
}
private static void PostToUiThread(
System.Windows.Forms.Control control,
Action action)
{
if (control == null || action == null || control.IsDisposed ||
!control.IsHandleCreated)
return;
Action guardedAction = delegate
{
if (control.IsDisposed)
return;
try
{
action();
}
catch (Exception exception)
{
ReportProcessMessageFailure(exception);
}
};
try
{
// Never keep CEF's UI thread blocked while WinForms opens a
// modal module that may create another CEF browser.
control.BeginInvoke(guardedAction);
}
catch (Exception exception)
{
ReportProcessMessageFailure(exception);
}
}
private static void ReportProcessMessageFailure(Exception exception)
{
try
{
LogHelper.Instance.WriteError(exception);
}
catch
{
// Never propagate logging failures into a native CEF callback.
}
Action showError = delegate
{
try
{
MessageUtil.Show(exception);
}
catch
{
}
};
try
{
System.Windows.Forms.Control mainControl = ERPInfo.Instance.MainControl;
if (mainControl == null || mainControl.IsDisposed ||
!mainControl.IsHandleCreated)
return;
if (mainControl.InvokeRequired)
mainControl.BeginInvoke(showError);
else
showError();
}
catch
{
// The main window may close while the callback is reporting.
}
}
public void Created(CefBrowser cefBrowser)
{
if (frmWebBrowser != null && OnCreated != null)
if (OnCreated != null)
{
OnCreated(cefBrowser, EventArgs.Empty);
}
}
public bool Closing(CefBrowser browser)
{
var control = frmWebBrowser;
return control != null && control.BrowserClosing(browser);
}
public void Closed(CefBrowser browser)
{
var control = frmWebBrowser;
if (control != null)
{
control.BrowserClosed(browser);
if (control.cefBrowserSettings == null)
{
frmWebBrowser = null;
OnCreated = null;
}
}
}
}
}
@@ -20,20 +20,9 @@ namespace Lskj.Control.BrowserSetting2
base.OnAfterCreated(browser);
BsClient.Created(browser);
}
protected override bool DoClose(CefBrowser browser)
{
// CEF sends WM_CLOSE to the parked application-owned host after
// this callback. The host only allows that second close attempt.
return BsClient.Closing(browser);
}
protected override void OnBeforeClose(CefBrowser browser)
{
base.OnBeforeClose(browser);
// Release owner references after CEF completes its async close.
BsClient.Closed(browser);
}
protected override bool OnBeforePopup(
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xilium.CefGlue;
using Lskj.Business;
namespace Lskj.Control.BrowserSetting2
{
@@ -47,9 +46,7 @@ namespace Lskj.Control.BrowserSetting2
protected override void OnRenderProcessTerminated(CefBrowser browser, CefTerminationStatus status)
{
// Do not start a new renderer during native teardown.
LogUtil.WriteError("CEF 渲染进程已终止,状态=" + status,
new InvalidOperationException("CEF renderer termination status=" + status));
browser.Reload();
}
}
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -102,7 +102,8 @@ namespace Lskj.Control
this.SizeChanged += OnFrmAutoSqlLoad_SizeChanged;
this.topSplitContainerControl.SplitterPositionChanged += OnTopSplitContainerControl_SplitterPositionChanged;
this.clearBtn.Click += OnClearBtn_Click;//清除按钮点击
popupMenu = new DevExpress.XtraBars.PopupMenu(barManager);//右键菜单
popupMenu = new DevExpress.XtraBars.PopupMenu(this.components);//右键菜单
popupMenu.Manager = barManager;
BarButtonItem barButtonItemFull = new DevExpress.XtraBars.BarButtonItem();
barButtonItemFull.Caption = "全连接";
barButtonItemFull.Name = "join";
+7 -1
View File
@@ -178,6 +178,12 @@ namespace Lskj.Control
foreach (GridColumn col in gridView.Columns)
{
if (col.FieldName.Equals("RightMenuBtnEdit", StringComparison.OrdinalIgnoreCase))
{
// 操作列仅用于界面按钮,不应进入导出结果。
hasBoolean = true;
continue;
}
if ((col.ColumnEdit != null && col.ColumnEdit.GetType() == typeof(RepositoryItemCheckEdit)) ||
(col.ColumnType != null && col.ColumnType.Name.ToLower() == "boolean"))
{
@@ -209,7 +215,7 @@ namespace Lskj.Control
foreach (BandedGridColumn col in gridView.Columns)
{
GridColumnModel gridModel = col.Tag as GridColumnModel;
if (col.Visible)
if (col.Visible && !col.FieldName.Equals("RightMenuBtnEdit", StringComparison.OrdinalIgnoreCase))
{
BandedGridColumn newCol = new BandedGridColumn();
newCol.Tag = col.Tag;
+2 -1
View File
@@ -28,7 +28,8 @@
/// </summary>
private void InitializeComponent()
{
this.barManager = new DevExpress.XtraBars.BarManager();
this.components = new System.ComponentModel.Container();
this.barManager = new DevExpress.XtraBars.BarManager(this.components);
this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
+5 -3
View File
@@ -1660,7 +1660,7 @@ namespace Lskj.Control
BarButtonItem itemExportDetail = new BarButtonItem();
itemExportDetail.Caption = "导出明细Excel";
itemExportDetail.ItemClick += new ItemClickEventHandler(OnItemExportDetail_ItemClick);
PopupMenu exportPopupMenu = new PopupMenu();
PopupMenu exportPopupMenu = new PopupMenu(this.components);
exportPopupMenu.Manager = this.barManager;
exportPopupMenu.AddItems(new BarItem[] { itemExportExcel, itemExportDetail });
this.exportDropBtn.DropDownControl = exportPopupMenu;
@@ -1682,7 +1682,8 @@ namespace Lskj.Control
#region
private void InitResultRightMenu()
{
popupMenu = new DevExpress.XtraBars.PopupMenu(barManager);
popupMenu = new DevExpress.XtraBars.PopupMenu(this.components);
popupMenu.Manager = barManager;
BarButtonItem barButtonItemSum = new DevExpress.XtraBars.BarButtonItem();
barButtonItemSum.Caption = "求和";
barButtonItemSum.Name = "Sum";
@@ -1704,7 +1705,8 @@ namespace Lskj.Control
popupMenu.ItemLinks[i].BeginGroup = true;//设置分割条
popupMenu.ItemLinks[i].Item.ItemClick += OnItem_ItemClick;
}
allpopupMenu = new DevExpress.XtraBars.PopupMenu(barManager);
allpopupMenu = new DevExpress.XtraBars.PopupMenu(this.components);
allpopupMenu.Manager = barManager;
BarButtonItem barButtonItemAllSum = new DevExpress.XtraBars.BarButtonItem();
barButtonItemAllSum.Caption = "一键求和";
barButtonItemAllSum.Name = "Sum";
+14 -1
View File
@@ -143,6 +143,10 @@ namespace Lskj.Control
}
bool isAdmin = ERPInfo.Instance.UserName.Equals("管理员");
this.btnCover.Visible = SysModel == null ? isAdmin : isAdmin ? true : SysModel.OperPermissionsUser.Contains(ERPInfo.Instance.UserName);
//if (SysModel!=null&&!string.IsNullOrWhiteSpace(SysModel.OperPermissionsUser) && SysModel.OperPermissionsUser.Equals("无")) this.btnCover.Visible = false;
this.SourceColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", _tableName)).Columns;
DataTable dtCalcFields = BaseImpl.GetDataTableResult(string.Format("select name from sys.columns where object_id=object_id('{0}') and is_computed=1", _tableName));
if ((dtCalcFields != null) && (dtCalcFields.Rows.Count > 0))
@@ -632,7 +636,11 @@ namespace Lskj.Control
}
dt.AcceptChanges();
if (failedData.Rows.Count > 0 || !SystemInfo.Instance.SuppressImportSuccessTip)
{
XtraMessageBox.Show("数据导入完成,成功" + success.ToString() + "条,失败" + failed.ToString() + "条", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
if (failedData.Rows.Count > 0)
{
MessageUtil.Show(failedData.Rows[0]["import_errormsg"].ToString());
@@ -658,6 +666,9 @@ namespace Lskj.Control
}
}
if (failed == 0 && datatb.Rows.Count > 0) this._isImported = true;
datatb.Clear();
dt.Clear();
if (failed > 0)
@@ -1026,7 +1037,7 @@ namespace Lskj.Control
{
if (MessageUtil.Show("如果导入数据量太多将花费较长时间,是否确认导入", MessageBoxButtons.YesNo) != DialogResult.Yes)
return;
this._isImported = true;
if (!this.DetermineImportConditions())
{
@@ -1038,6 +1049,8 @@ namespace Lskj.Control
// 采用存储过程保存
//this.SaveImportData(table);
if(this._isImported&& SystemInfo.Instance.SuppressImportSuccessTip) this.DialogResult = DialogResult.OK;
}
else
{
-2
View File
@@ -14,8 +14,6 @@ namespace Lskj.Control
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing)
CloseBrowserForDispose();
if (disposing && (components != null))
{
components.Dispose();
-39
View File
@@ -109,45 +109,6 @@ namespace Lskj.Control
cefBrowserSettings.GetMainFrame().LoadUrl(webResponse.ResponseUri.AbsoluteUri);
}
}
internal bool BrowserClosing(CefBrowser browser)
{
return false;
}
internal void BrowserClosed(CefBrowser browser)
{
var currentBrowser = cefBrowserSettings;
if (currentBrowser == null || browser == null)
return;
bool sameBrowser = ReferenceEquals(currentBrowser, browser);
if (!sameBrowser)
{
try
{
sameBrowser = currentBrowser.IsSame(browser);
}
catch (Exception)
{
}
}
if (sameBrowser)
Interlocked.CompareExchange(ref cefBrowserSettings, null, currentBrowser);
}
internal void CloseBrowser()
{
var browser = cefBrowserSettings;
if (browser != null)
browser.GetHost().CloseBrowser();
}
private void CloseBrowserForDispose()
{
}
public static string ToEnUrl(string url)
{
string[] urlParams = url.Split('?');
-2
View File
@@ -14,8 +14,6 @@ namespace Lskj.Control
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing)
CloseBrowserForDispose();
if (disposing && (components != null))
{
components.Dispose();
-39
View File
@@ -126,45 +126,6 @@ namespace Lskj.Control
cefBrowserSettings.GetMainFrame().LoadUrl(webResponse.ResponseUri.AbsoluteUri);
}
}
internal bool BrowserClosing(CefBrowser browser)
{
return false;
}
internal void BrowserClosed(CefBrowser browser)
{
var currentBrowser = cefBrowserSettings;
if (currentBrowser == null || browser == null)
return;
bool sameBrowser = ReferenceEquals(currentBrowser, browser);
if (!sameBrowser)
{
try
{
sameBrowser = currentBrowser.IsSame(browser);
}
catch (Exception)
{
}
}
if (sameBrowser)
Interlocked.CompareExchange(ref cefBrowserSettings, null, currentBrowser);
}
internal void CloseBrowser()
{
var browser = cefBrowserSettings;
if (browser != null)
browser.GetHost().CloseBrowser();
}
private void CloseBrowserForDispose()
{
}
public static string ToEnUrl(string url)
{
string[] urlParams = url.Split('?');
+412 -28
View File
@@ -184,8 +184,8 @@ namespace Lskj.Control
/// <summary>
/// 外部设置的右键菜单数据,用于创建每行操作列。
/// </summary>
private DataTable rightMenuButtonTable;
private bool gridColumnsInitialized;
protected DataTable rightMenuButtonTable;
protected bool gridColumnsInitialized;
/// <summary>
/// 新版模块选择框缓存。同一关联模块的单选和多选界面分别复用。
@@ -508,6 +508,7 @@ namespace Lskj.Control
{
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.Selectable | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
InitializeComponent();
StaticControl.RegisterOwnedControl(this);
this.Disposed += OnGridControlExDisposed;
// 自定义选中区域方式
@@ -629,6 +630,125 @@ namespace Lskj.Control
}
}
internal void ReleaseResourcesForDispose()
{
// 模块级清理只解除事件和菜单引用。GridControl/GridView 的生命周期
// 由真正的 WinForms 父容器负责,并在 Dispose(bool) 中统一结束。
DetachGridViewEventHandlers();
DisposeOwnedLookupFormsForDispose();
if (gridViewRightMenu != null)
{
gridViewRightMenu.ReleaseResourcesForDispose();
gridViewRightMenu = null;
}
ParentControl = null;
}
private void DetachGridViewEventHandlers()
{
if (gridView == null)
{
return;
}
gridView.CustomDrawRowIndicator -= OnGridViewCustomDrawRowIndicator;
gridView.SelectionChanged -= OnGridViewSelectionChanged;
gridView.FocusedRowObjectChanged -= OnGridViewFocusedRowObjectChanged;
gridView.BeforeLeaveRow -= OnGridView_BeforeLeaveRow;
gridView.CustomDrawCell -= OnGridViewCustomDrawCell;
gridView.CellValueChanged -= OnGridViewCellValueChanged;
gridView.DragObjectDrop -= OnGridViewDragObjectDrop;
gridView.CustomDrawGroupRow -= OnGridCustomDrawGroupRow;
gridView.KeyDown -= OnGridViewKeyDown;
gridView.DoubleClick -= OnGridViewDoubleClick;
gridView.Click -= OnGridViewClick;
gridView.Click -= OnGridView_Click;
gridView.CellMerge -= OnGridViewCellMerge;
gridView.CustomSummaryCalculate -= OnGridViewSummaryCalculate;
gridView.ShowFilterPopupCheckedListBox -= OnShowFilterPopupCheckedListBox;
gridView.DataSourceChanged -= OnGridDataSourceChanged;
gridView.RowCellStyle -= GridView_RowCellStyle;
// These handlers are attached dynamically by SetGridRowColors and
// AddHeadquarters. They are not part of the constructor hookup, so
// removing only the static handlers above leaves a GridView event
// delegate rooted to this GridControlEx after module close.
gridView.RowCellStyle -= OnGridViewRowCellStyle;
gridView.RowStyle -= OnGridViewRowStyle;
gridView.CellValueChanged -= onCellValueChanged;
gridView.CustomRowFilter -= GridView_CustomRowFilter;
gridView.EndGrouping -= GridView_EndGrouping;
gridView.ShowingEditor -= GridView_ShowingEditor;
gridView.MouseDown -= GridView_MouseDown;
gridView.MouseWheel -= GridView_MouseWheel;
gridView.PopupMenuShowing -= OnGridViewPopupMenuShowing;
gridView.EndSorting -= OnGridViewEndSorting;
LabPicUrlPreview.Detach(gridView);
}
private void DisposeOwnedLookupFormsForDispose()
{
HashSet<Form> forms = new HashSet<Form>();
foreach (FrmModelLookUp2 modelLookUp in
selectReturnModelLookUpCache.Values.Distinct())
{
if (modelLookUp != null)
{
forms.Add(modelLookUp);
}
}
selectReturnModelLookUpCache.Clear();
selectReturnDisplaySourceCache.Clear();
RepositoryItem[] repositoryItems = null;
try
{
if (gridControl != null)
{
repositoryItems = gridControl.RepositoryItems
.Cast<RepositoryItem>()
.ToArray();
}
}
catch
{
// The inner control may already be disposing its repository collection.
}
if (repositoryItems != null)
{
foreach (RepositoryItemButtonEdit buttonEditor in
repositoryItems.OfType<RepositoryItemButtonEdit>())
{
foreach (EditorButton button in buttonEditor.Buttons)
{
Form form = button.Tag as Form;
if (form == null)
{
continue;
}
button.Tag = null;
forms.Add(form);
}
}
}
foreach (Form form in forms)
{
try
{
if (!form.IsDisposed)
{
form.Dispose();
}
}
catch
{
// A helper form must not prevent its owning grid from closing.
}
}
}
private void DisposeGridResources()
{
if (_gridResourcesDisposed)
@@ -637,6 +757,11 @@ namespace Lskj.Control
}
_gridResourcesDisposed = true;
if (cellHelper != null)
{
cellHelper.Dispose();
cellHelper = null;
}
StopColumnSourceTimer();
if (mTimer != null)
{
@@ -664,10 +789,16 @@ namespace Lskj.Control
mControlList.Clear();
ColumnList.Clear();
AutoPadDataReleColList.Clear();
DisposeOwnedLookupFormsForDispose();
FrozenColumns.Clear();
ImageList.Clear();
RepeatedVerificationNames.Clear();
PromptMessage.Clear();
DetachGridViewEventHandlers();
DisposeGridViews();
DisposeRepositoryItems();
gridViewRightMenu?.ReleaseResourcesForDispose();
gridViewRightMenu = null;
ParentControl = null;
Model = null;
SysModel = null;
@@ -686,6 +817,52 @@ namespace Lskj.Control
customFont.Dispose();
customFont = null;
}
// Dispose 完成后,包装对象不应继续保留已释放的 DevExpress 控件、
// 数据表和模块字典。尤其是左右联动事件链仍可能短暂持有包装对象,
// 这里主动断开引用可以避免已关闭页签继续保留整棵控件对象图。
gridView = null;
gridControl = null;
GridRowColorsTable = null;
ChartTable = null;
rightMenuButtonTable = null;
InitGridColumsTab = null;
ModuleEnclosure?.Clear();
ModuleEnclosure = null;
mControlSourceDic?.Clear();
mControlSourceDic = null;
mControlList?.Clear();
mControlList = null;
ColumnList?.Clear();
ColumnList = null;
AutoPadDataReleColList?.Clear();
AutoPadDataReleColList = null;
ImageList?.Clear();
ImageList = null;
RepeatedVerificationNames?.Clear();
RepeatedVerificationNames = null;
PromptMessage?.Clear();
PromptMessage = null;
_CheckedList?.Clear();
_CheckedList = null;
modifyThePosition?.Clear();
modifyThePosition = null;
ColumnsList?.Clear();
ColumnsList = null;
SelectedDataSource?.Clear();
SelectedDataSource = null;
ProgressBarColumn?.Clear();
ProgressBarColumn = null;
ManuallyAddData?.Clear();
ManuallyAddData = null;
FrozenColumns = null;
CurrentOperGridView = null;
CurrentOperModel = null;
HeaderColumnSift = null;
sumPanel = null;
PopupEdit = null;
CustomGroupBandEx = null;
CustomGroupTreeBandEx = null;
}
private void PrepareForColumnRebuild()
@@ -714,14 +891,127 @@ namespace Lskj.Control
private void DisposeRepositoryItems()
{
RepositoryItem[] repositoryItems = gridControl.RepositoryItems
RepositoryItem[] repositoryItems;
try
{
if (gridControl == null)
{
return;
}
repositoryItems = gridControl.RepositoryItems
.Cast<RepositoryItem>()
.ToArray();
}
catch
{
// The inner control may already have released its repository collection.
return;
}
DisposeRepositoryButtonForms(repositoryItems);
try
{
gridControl.RepositoryItems.Clear();
}
catch
{
// Continue disposing the captured items.
}
foreach (RepositoryItem repositoryItem in repositoryItems)
{
try
{
repositoryItem.Dispose();
}
catch
{
// Continue releasing the remaining repository items.
}
}
}
private static void DisposeRepositoryButtonForms(IEnumerable<RepositoryItem> repositoryItems)
{
HashSet<Form> forms = new HashSet<Form>();
foreach (RepositoryItemButtonEdit buttonEditor in repositoryItems.OfType<RepositoryItemButtonEdit>())
{
foreach (EditorButton button in buttonEditor.Buttons)
{
Form form = button.Tag as Form;
if (form == null)
{
continue;
}
button.Tag = null;
forms.Add(form);
}
}
foreach (Form form in forms)
{
try
{
form.Dispose();
}
catch
{
// A lookup window must not prevent its owning grid from being released.
}
}
}
private void DisposeGridViews()
{
HashSet<BaseView> views = new HashSet<BaseView>();
if (gridView != null)
{
views.Add(gridView);
}
try
{
if (gridControl != null)
{
foreach (BaseView view in gridControl.ViewCollection.Cast<BaseView>().ToArray())
{
if (view != null)
{
views.Add(view);
}
}
}
}
catch
{
// The inner control may already be disposing its view collection.
}
foreach (BaseView view in views)
{
GridView disposableGridView = view as GridView;
if (disposableGridView != null)
{
try
{
StaticControl.ReleaseGridViewReferences(disposableGridView);
}
catch
{
// Static cleanup is best-effort; the view must still be disposed.
}
}
try
{
view.Dispose();
}
catch
{
// Continue releasing the remaining views during control disposal.
}
}
}
private void ScheduleColumnSources()
@@ -3651,10 +3941,17 @@ namespace Lskj.Control
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected virtual void Multifunction(object sender, EventArgs e)
{
StaticControl.ModuleResourceScope moduleScope = null;
try
{
//DataTable newDt = this.SetDealWithValueTab();
FrmGridSift frmGridSift = new FrmGridSift();
string guid = Guid.NewGuid().ToString();
moduleScope = new StaticControl.ModuleResourceScope(guid);
FrmGridSift frmGridSift;
using (StaticControl.PushModuleScope(moduleScope))
{
frmGridSift = new FrmGridSift();
}
frmGridSift.CustomColumKey = this.CustomColumKey;
//frmGridSift.source = newDt;
frmGridSift.ParentGridEx = this;
@@ -3663,10 +3960,9 @@ namespace Lskj.Control
DllName = "",
Id = this.Model.ModuleCode,
Name = this.Model.FormText,
BeforePage = ERPInfo.Instance.PageControl.SelectedTabPage
BeforePage = ERPInfo.Instance.CurrentModulePage
};
module.ModuleForm = frmGridSift;
string guid = Guid.NewGuid().ToString();
DevExpress.XtraTab.XtraTabPage tp = new DevExpress.XtraTab.XtraTabPage();
tp.Tag = guid;
// 这个必须有不然会提示:"不能向tabControl中添加顶级控件"
@@ -3680,13 +3976,19 @@ namespace Lskj.Control
tp.Controls.Add(frmGridSift);
tp.ShowCloseButton = DefaultBoolean.True;
tp.Dock = DockStyle.Fill;
ERPInfo.Instance.PageControl.TabPages.Add(tp);
ERPInfo.Instance.PageControl.SelectedTabPage = tp;
StaticControl.RegisterModulePage(module, tp, frmGridSift);
ERPInfo.Instance.AddModulePage(tp);
ERPInfo.Instance.CurrentModulePage = tp;
ERPInfo.Instance.ModuleForms.Add(guid, module);
using (StaticControl.PushModuleScope(moduleScope))
{
frmGridSift.Show();
}
}
catch (Exception ex)
{
if (moduleScope != null)
moduleScope.Dispose();
string Message = ErrorMessage.PromptErrorMessage(ex, Model.ModuleCode);
MessageUtil.Show(Message, ex.Message);
}
@@ -4239,6 +4541,29 @@ namespace Lskj.Control
RepositoryItemTimeEdit timeEdit = new RepositoryItemTimeEdit();
timeEdit.DisplayFormat.FormatString = timeEdit.EditFormat.FormatString = timeEdit.Mask.EditMask = DateFormat.Format(fieldType);
timeEdit.DisplayFormat.FormatType = timeEdit.EditFormat.FormatType = DevExpress.Utils.FormatType.Custom;
timeEdit.ParseEditValue += delegate(object sender, ConvertEditValueEventArgs e)
{
// SQL Server 的 time 字段在 DataTable 中是 TimeSpanTimeEdit 输入后返回 DateTime。
// 只转换 TimeSpan 绑定列,不改变原有 DateTime 类型列的行为。
if (gridColumn.ColumnType != typeof(TimeSpan) || e.Value == null || e.Value == DBNull.Value)
{
return;
}
if (e.Value is DateTime)
{
e.Value = ((DateTime)e.Value).TimeOfDay;
e.Handled = true;
return;
}
TimeSpan timeValue;
if (!(e.Value is TimeSpan) && TimeSpan.TryParse(e.Value.ToString(), out timeValue))
{
e.Value = timeValue;
e.Handled = true;
}
};
@@ -5337,8 +5662,8 @@ namespace Lskj.Control
/// </summary>
internal void SetRightMenuButtonTable(DataTable table)
{
// 树表格和多表头表格原来不在此处创建操作列,维持原有行为
if (this is TreeGridControlEx || this is BandedGridControlEx)
// 树表格仍由原有逻辑处理,不创建操作列
if (this is TreeGridControlEx)
{
return;
}
@@ -5347,7 +5672,7 @@ namespace Lskj.Control
this.TryInitRightMenuBtnEdit(true);
}
private void TryInitRightMenuBtnEdit(bool rebuild)
protected virtual void TryInitRightMenuBtnEdit(bool rebuild)
{
if (!this.gridColumnsInitialized || this.Model == null ||
this.CustomColumKey.Contains("BaseLeftGridView_"))
@@ -5377,7 +5702,7 @@ namespace Lskj.Control
}
}
private void InitRightMenuBtnEdit(DataTable rightMenuTab)
protected virtual void InitRightMenuBtnEdit(DataTable rightMenuTab)
{
GridColumn gridColumn = new GridColumn();
gridColumn.FieldName = "RightMenuBtnEdit";
@@ -5508,6 +5833,9 @@ namespace Lskj.Control
modelLookUp.Tag = model;
RepositoryItemCheckedComboBoxEdit btnEdit = new RepositoryItemCheckedComboBoxEdit();
btnEdit.ShowDropDown = ShowDropDown.Never;
btnEdit.NullText = "";
btnEdit.PopupBorderStyle = PopupBorderStyles.Flat;
btnEdit.AllowNullInput = DefaultBoolean.False;
@@ -5552,6 +5880,9 @@ namespace Lskj.Control
}
RepositoryItemCheckedComboBoxEdit btnEdit = new RepositoryItemCheckedComboBoxEdit();
btnEdit.ShowDropDown = ShowDropDown.Never;
btnEdit.NullText = "";
btnEdit.PopupBorderStyle = PopupBorderStyles.Flat;
btnEdit.AllowNullInput = DefaultBoolean.False;
@@ -6278,6 +6609,8 @@ namespace Lskj.Control
this.gridView.RowCount > 0 &&
this.gridView.OptionsBehavior.Editable)
{
GridColumnModel model = column.Tag as GridColumnModel;
// 允许操作
int focusedRowHandle = this.gridView.FocusedRowHandle;
int totalRowCount = this.gridView.RowCount;
@@ -6292,7 +6625,58 @@ namespace Lskj.Control
int valueNum = 0;
object obj = this.gridView.GetFocusedRowCellValue(column);
if (!string.IsNullOrEmpty(obj + ""))
if (model != null && (ControlType.IsDate(model.FieldType) || model.FieldType == ControlType.LabShortDate))
{
DateTime dateValue;
if (!DateTime.TryParse(obj + "", out dateValue))
{
MessageUtil.Show("当前单元格不是有效日期,无法按日期生成。");
e.Handled = true;
return;
}
string dateFormat = DateFormat.Format(model.FieldType);
bool onlyYear = !string.IsNullOrEmpty(dateFormat)
&& dateFormat.IndexOf("y", StringComparison.OrdinalIgnoreCase) >= 0
&& dateFormat.IndexOf("M", StringComparison.Ordinal) < 0
&& dateFormat.IndexOf("d", StringComparison.OrdinalIgnoreCase) < 0;
bool onlyMonth = !string.IsNullOrEmpty(dateFormat)
&& dateFormat.IndexOf("M", StringComparison.Ordinal) >= 0
&& dateFormat.IndexOf("d", StringComparison.OrdinalIgnoreCase) < 0;
this.gridView.BeginUpdate();
this.gridView.BeginDataUpdate();
try
{
for (int i = focusedRowHandle; i < totalRowCount; i++)
{
gridView.SetRowCellValue(i, column, dateValue);
if (onlyYear)
{
dateValue = dateValue.AddYears(1);
}
else if (onlyMonth)
{
dateValue = dateValue.AddMonths(1);
}
else
{
dateValue = dateValue.AddDays(1);
}
}
}
finally
{
this.gridView.EndDataUpdate();
this.gridView.EndUpdate();
}
gridView.FocusedRowHandle = totalRowCount - 1;
e.Handled = true;
return;
}
else if (!string.IsNullOrEmpty(obj + ""))
{
//isExec = Int64.TryParse(obj + "", out value);
Regex regex = new Regex(@"\D", RegexOptions.RightToLeft);
@@ -9400,7 +9784,7 @@ namespace Lskj.Control
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnItemButtonEdit_ButtonClick(object sender, ButtonPressedEventArgs e)
protected void OnItemButtonEdit_ButtonClick(object sender, ButtonPressedEventArgs e)
{
EditorButton editorButton = e.Button as EditorButton;
GridRightMenuModel menuModel = editorButton.Tag as GridRightMenuModel;
@@ -9408,8 +9792,8 @@ namespace Lskj.Control
if (toolStripMenuItem != null)
{
bool allowClick = true;
int[] mSelectRows = this.gridView.GetSelectedRows();
DataRow mSelectRow = this.gridView.GetDataRow(mSelectRows[0]);
int[] mSelectRows = this.GridView.GetSelectedRows();
DataRow mSelectRow = this.GridView.GetDataRow(mSelectRows[0]);
if (menuModel != null)
{
if (menuModel.PrivilegeOper.Length > 1 && !menuModel.PrivilegeOper.Contains(ERPInfo.Instance.UserName + ","))
@@ -9426,13 +9810,13 @@ namespace Lskj.Control
if (this.gridViewRightMenu.ControlObj != null)
cond = this.gridViewRightMenu.ControlObj.ReplaceParentControlValue(menuModel.MenuCond);
cond = ReplaceHelper.ReplaceRowParam(mSelectRow, menuModel.MenuCond);
if (this.gridView != null)
if (this.GridView != null)
{
GridCell[] cells = this.gridView.GetSelectedCells();
GridCell[] cells = this.GridView.GetSelectedCells();
if (cells != null && cells.Length > 0 && cond.Contains("{COLUMN_"))
{
GridCell cell = cells[0];
DataRow focusedRow = this.gridView.GetFocusedDataRow();
DataRow focusedRow = this.GridView.GetFocusedDataRow();
string colValue = focusedRow == null || !focusedRow.Table.Columns.Contains(cell.Column.Name) ? "" : focusedRow[cell.Column.Name] + "";
cond = cond.ReplaceColumnParam(cell.Column.Name, cell.Column.Caption, colValue);
}
@@ -10742,7 +11126,7 @@ namespace Lskj.Control
return Math.Max(textWidth + padding, 40);
}
private Image GetRightMenuButtonImage(string imageName)
protected Image GetRightMenuButtonImage(string imageName)
{
if (string.IsNullOrWhiteSpace(imageName))
{
@@ -10806,7 +11190,7 @@ namespace Lskj.Control
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void GridView_MouseDown(object sender, MouseEventArgs e)
protected void GridView_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left) return;
@@ -10819,7 +11203,7 @@ namespace Lskj.Control
RepositoryItemButtonEdit repo = hitInfo.Column.ColumnEdit as RepositoryItemButtonEdit;
if (!hitInfo.Column.FieldName.Equals("RightMenuBtnEdit")) return;
int rowHandle = hitInfo.RowHandle;
this.gridView.SelectRowHandler(rowHandle);
view.SelectRowHandler(rowHandle);
int buttonIndex = this.GetClickedButtonIndex(repo, view, rowHandle, hitInfo.Column, e.Location, hitInfo.Column.Width);
if (buttonIndex != -1)
@@ -10836,7 +11220,7 @@ namespace Lskj.Control
/// 执行点击的右键按钮
/// </summary>
/// <param name="editorButton"></param>
private void RightButtonClick(EditorButton editorButton)
protected void RightButtonClick(EditorButton editorButton)
{
GridRightMenuModel menuModel = editorButton.Tag as GridRightMenuModel;
@@ -10844,8 +11228,8 @@ namespace Lskj.Control
if (toolStripMenuItem != null)
{
bool allowClick = true;
int[] mSelectRows = this.gridView.GetSelectedRows();
DataRow mSelectRow = this.gridView.GetDataRow(mSelectRows[0]);
int[] mSelectRows = this.GridView.GetSelectedRows();
DataRow mSelectRow = this.GridView.GetDataRow(mSelectRows[0]);
if (menuModel != null)
{
if (menuModel.PrivilegeOper.Length > 1 && !menuModel.PrivilegeOper.Contains(ERPInfo.Instance.UserName + ","))
@@ -10862,13 +11246,13 @@ namespace Lskj.Control
if (this.gridViewRightMenu.ControlObj != null)
cond = this.gridViewRightMenu.ControlObj.ReplaceParentControlValue(menuModel.MenuCond);
cond = ReplaceHelper.ReplaceRowParam(mSelectRow, menuModel.MenuCond);
if (this.gridView != null)
if (this.GridView != null)
{
GridCell[] cells = this.gridView.GetSelectedCells();
GridCell[] cells = this.GridView.GetSelectedCells();
if (cells != null && cells.Length > 0 && cond.Contains("{COLUMN_"))
{
GridCell cell = cells[0];
DataRow focusedRow = this.gridView.GetFocusedDataRow();
DataRow focusedRow = this.GridView.GetFocusedDataRow();
string colValue = focusedRow == null || !focusedRow.Table.Columns.Contains(cell.Column.Name) ? "" : focusedRow[cell.Column.Name] + "";
cond = cond.ReplaceColumnParam(cell.Column.Name, cell.Column.Caption, colValue);
}
@@ -12,10 +12,15 @@ using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
// Token: 0x02000003 RID: 3
public class AmountCellRender
public class AmountCellRender : IDisposable
{
public AmountCellRender(GridView gridView_0)
{
if (gridView_0 == null)
{
throw new ArgumentNullException("gridView_0");
}
Class5.gBkiB4AzUqwkh();
this.colorGray = Color.FromArgb(189, 185, 185);
this.colorGreen = Color.Green;
@@ -25,23 +30,58 @@ public class AmountCellRender
this.dictionary_0 = new Dictionary<string, Class2>();
this.list_0 = new List<GridColumn>();
this.object_0 = gridView_0;
this.gridControl_0 = this.object_0.GridControl;
this.object_0.CustomDrawCell += this.object_0_CustomDrawCell;
this.object_0.CustomDrawColumnHeader += this.object_0_CustomDrawColumnHeader;
this.object_0.CustomDrawFooterCell += this.object_0_CustomDrawFooterCell;
this.object_0.GridControl.Paint += this.method_0;
if (this.gridControl_0 != null)
{
this.gridControl_0.Paint += this.method_0;
}
}
private void method_0(object sender, PaintEventArgs e)
{
BaseViewInfo viewInfo = ((sender as GridControl).FocusedView as GridView).GetViewInfo();
if (this.disposed || this.list_0.Count == 0)
{
return;
}
GridControl gridControl = sender as GridControl;
if (gridControl == null || gridControl.IsDisposed || gridControl.Disposing)
{
return;
}
GridView gridView = gridControl.FocusedView as GridView;
if (gridView == null)
{
return;
}
GridViewInfo gridViewInfo = gridView.GetViewInfo() as GridViewInfo;
if (gridViewInfo == null || gridViewInfo.ColumnsInfo == null)
{
return;
}
foreach (GridColumn gridColumn in this.list_0)
{
Class2 @class = this.dictionary_0[gridColumn.Name];
Class2 @class;
if (gridColumn == null ||
!this.dictionary_0.TryGetValue(gridColumn.Name, out @class) ||
@class == null)
{
continue;
}
if (@class.IsCountinuousCell())
{
GridViewInfo gridViewInfo = viewInfo as GridViewInfo;
GridColumnInfoArgs gridColumnInfoArgs = gridViewInfo.ColumnsInfo[gridColumn];
if (gridColumnInfoArgs == null) return;
if (gridColumnInfoArgs == null)
{
continue;
}
int num = 0;
int int_;
if (@class.method_4())
@@ -82,10 +122,16 @@ public class AmountCellRender
private void object_0_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
{
if (this.dictionary_0.ContainsKey(e.Column.Name))
if (this.disposed || e.Column == null)
{
return;
}
Class2 @class;
if (this.dictionary_0.TryGetValue(e.Column.Name, out @class) &&
@class != null)
{
e.DisplayText = "";
Class2 @class = this.dictionary_0[e.Column.Name];
Rectangle bounds = e.Bounds;
Rectangle rectangle_ = bounds;
Graphics graphics = e.Graphics;
@@ -98,14 +144,20 @@ public class AmountCellRender
private void object_0_CustomDrawFooterCell(object sender, FooterCellCustomDrawEventArgs e)
{
if (this.dictionary_0.ContainsKey(e.Column.Name))
if (this.disposed || e.Column == null)
{
return;
}
Class2 @class;
if (this.dictionary_0.TryGetValue(e.Column.Name, out @class) &&
@class != null)
{
Class2 @class = this.dictionary_0[e.Column.Name];
if (@class.method_8())
{
e.Info.DisplayText = "";
Rectangle bounds = e.Bounds;
@class.method_17(bounds, e.Graphics, e.Appearance.Font, e.Info.Value.ToString());
@class.method_17(bounds, e.Graphics, e.Appearance.Font, Convert.ToString(e.Info.Value));
e.Handled = true;
}
}
@@ -113,13 +165,15 @@ public class AmountCellRender
private void object_0_CustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e)
{
if (e.Column == null)
if (this.disposed || e.Column == null)
{
return;
}
if (this.dictionary_0.ContainsKey(e.Column.Name))
Class2 @class;
if (this.dictionary_0.TryGetValue(e.Column.Name, out @class) &&
@class != null)
{
Class2 @class = this.dictionary_0[e.Column.Name];
if (@class.method_6())
{
e.Column.Caption = "";
@@ -204,14 +258,44 @@ public class AmountCellRender
public void RemoveAmountColumn(GridColumn gridColumn_0)
{
if (this.dictionary_0.ContainsKey(gridColumn_0.Name))
if (gridColumn_0 != null && this.dictionary_0.ContainsKey(gridColumn_0.Name))
{
this.dictionary_0.Remove(gridColumn_0.Name);
this.list_0.Remove(gridColumn_0);
}
}
public void Dispose()
{
if (this.disposed)
{
return;
}
this.disposed = true;
GridView gridView = this.object_0;
GridControl gridControl = this.gridControl_0;
this.object_0 = null;
this.gridControl_0 = null;
if (gridView != null)
{
gridView.CustomDrawCell -= this.object_0_CustomDrawCell;
gridView.CustomDrawColumnHeader -= this.object_0_CustomDrawColumnHeader;
gridView.CustomDrawFooterCell -= this.object_0_CustomDrawFooterCell;
}
if (gridControl != null)
{
gridControl.Paint -= this.method_0;
}
this.dictionary_0.Clear();
this.list_0.Clear();
}
private GridView object_0;
private GridControl gridControl_0;
private bool disposed;
private Color colorGray;
private Color colorGreen;
+9 -3
View File
@@ -255,7 +255,10 @@ public class Class2
if (color != Color.Empty)
{
Rectangle rect = new Rectangle(rectangle_0.Left + i - 2, int_2, int_1, int_3);
graphics_0.FillRectangle(new SolidBrush(color), rect);
using (SolidBrush solidBrush = new SolidBrush(color))
{
graphics_0.FillRectangle(solidBrush, rect);
}
}
}
else
@@ -265,9 +268,12 @@ public class Class2
num++;
}
Rectangle rect2 = new Rectangle(rectangle_0.Left - 1, int_2, int_1 + 1, int_3);
graphics_0.FillRectangle(new SolidBrush(Color.FromArgb(161, 157, 157)), rect2);
Rectangle rect3 = new Rectangle(rectangle_0.Left + rectangle_0.Width - 1, int_2, int_1 + 1, int_3);
graphics_0.FillRectangle(new SolidBrush(Color.FromArgb(161, 157, 157)), rect3);
using (SolidBrush solidBrush = new SolidBrush(Color.FromArgb(161, 157, 157)))
{
graphics_0.FillRectangle(solidBrush, rect2);
graphics_0.FillRectangle(solidBrush, rect3);
}
}
// Token: 0x06000028 RID: 40 RVA: 0x00002CC8 File Offset: 0x00000EC8
@@ -13,6 +13,10 @@
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing)
{
ReleaseLookupFormForDispose();
}
if (disposing && (components != null))
{
components.Dispose();
@@ -315,6 +315,7 @@ namespace Lskj.Control
/// <param name="dataSource">数据源</param>
public void InitialFrame()
{
ReleaseLookupFormForDispose();
_lookUpForm = new FrmModelLookUp2(UnionModuleCodel, IsRadio);
_lookUpForm.ConfigureColumnMode = ConfigureColumnMode;
_lookUpForm.ValueField = ValueField;
@@ -332,6 +333,25 @@ namespace Lskj.Control
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
internal void ReleaseLookupFormForDispose()
{
FrmModelLookUp2 lookUpForm = _lookUpForm;
_lookUpForm = null;
if (lookUpForm == null || lookUpForm.IsDisposed)
{
return;
}
try
{
lookUpForm.Dispose();
}
catch
{
// A helper form must not prevent its owner from closing.
}
}
public void ClearSelectForm()
{
// _lookUpForm.ClearSelect();
+252
View File
@@ -0,0 +1,252 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraEditors;
namespace Lskj.Control
{
/// <summary>
/// 带标题的时间输入控件,使用上下按钮调整时间。
/// </summary>
public class LabelTimeEdit : BaseUserControl
{
private readonly Panel plLeft;
private readonly Panel plRight;
private readonly Label lblText;
private readonly TimeEdit txtEdit;
private string formatString = "HH:mm:ss";
public LabelTimeEdit()
{
plLeft = new Panel();
plRight = new Panel();
lblText = new Label();
txtEdit = new TimeEdit();
SuspendLayout();
plLeft.SuspendLayout();
plRight.SuspendLayout();
((System.ComponentModel.ISupportInitialize)txtEdit.Properties).BeginInit();
plLeft.BackColor = Color.Transparent;
plLeft.Controls.Add(lblText);
plLeft.Dock = DockStyle.Left;
plLeft.Size = new Size(40, 21);
lblText.AutoSize = true;
lblText.Location = new Point(5, 4);
lblText.Text = "名称";
plRight.Controls.Add(txtEdit);
plRight.Dock = DockStyle.Fill;
plRight.Location = new Point(40, 0);
txtEdit.Dock = DockStyle.Fill;
txtEdit.EditValue = null;
txtEdit.Properties.Buttons.Clear();
txtEdit.Properties.Buttons.Add(new DevExpress.XtraEditors.Controls.EditorButton(
DevExpress.XtraEditors.Controls.ButtonPredefines.Combo));
txtEdit.Properties.TimeEditStyle = DevExpress.XtraEditors.Repository.TimeEditStyle.SpinButtons;
AutoScaleMode = AutoScaleMode.None;
BackColor = Color.Transparent;
Controls.Add(plRight);
Controls.Add(plLeft);
Size = new Size(162, 21);
((System.ComponentModel.ISupportInitialize)txtEdit.Properties).EndInit();
plRight.ResumeLayout(false);
plLeft.ResumeLayout(false);
plLeft.PerformLayout();
ResumeLayout(false);
}
/// <summary>
/// 时间编辑器。
/// </summary>
public TimeEdit TextEdit
{
get { return txtEdit; }
}
public override string LabelText
{
get { return lblText.Text; }
set
{
lblText.Text = value;
if (FontSize > 0)
{
plLeft.AutoSize = false;
lblText.AutoSize = false;
lblText.Dock = DockStyle.Fill;
lblText.Location = new Point(0, 0);
lblText.TextAlign = ContentAlignment.MiddleLeft;
txtEdit.Properties.AutoHeight = false;
plLeft.Width = value.Length * GetCharWidth();
GetCharWidthMultilingual(lblText, lblText.Text, plLeft);
}
else
{
plLeft.Width = lblText.Width + PaddingLeft;
}
}
}
public override float FontSize
{
get { return base.FontSize; }
set
{
base.FontSize = value;
if (value > 0)
{
lblText.Font = new Font(lblText.Font.FontFamily, value);
txtEdit.Font = new Font(txtEdit.Font.FontFamily, value);
}
}
}
public override string EditText
{
get { return txtEdit.EditValue == null ? string.Empty : txtEdit.Text; }
set
{
TimeSpan timeValue;
txtEdit.EditValue = TryGetTime(value, out timeValue)
? (object)DateTime.Today.Add(timeValue)
: null;
}
}
public override string NullText
{
get { return txtEdit.Properties.NullValuePrompt; }
set
{
if (!string.IsNullOrEmpty(value))
{
txtEdit.Properties.NullValuePromptShowForEmptyValue = true;
txtEdit.Properties.NullValuePrompt = value;
}
base.NullText = value;
}
}
public override bool ReadOnly
{
get { return base.ReadOnly; }
set
{
base.ReadOnly = value;
txtEdit.Properties.ReadOnly = value;
txtEdit.Enabled = !value;
lblText.ForeColor = value ? ReadOnlyLabelForceColor : Required ? RequiredLabelForceColor : DefaultLabelForceColor;
}
}
public override bool Required
{
get { return base.Required; }
set
{
base.Required = value;
if (value)
{
lblText.ForeColor = RequiredLabelForceColor;
}
}
}
public override Color BackgroundColor
{
get { return txtEdit.Properties.Appearance.BackColor; }
set { txtEdit.Properties.Appearance.BackColor = value; }
}
public override Color ForeColor
{
get { return txtEdit.Properties.Appearance.ForeColor; }
set { txtEdit.Properties.Appearance.ForeColor = value; }
}
public override bool ContentBold
{
get { return txtEdit.Properties.Appearance.Font.Bold; }
set
{
Font oldFont = txtEdit.Properties.Appearance.Font;
txtEdit.Properties.Appearance.Font = new Font(oldFont.FontFamily, oldFont.Size, value ? FontStyle.Bold : FontStyle.Regular);
}
}
/// <summary>
/// 设置时间的显示和输入格式。
/// </summary>
public void TimeFormat(string value)
{
if (string.IsNullOrWhiteSpace(value))
{
return;
}
formatString = value;
txtEdit.Properties.DisplayFormat.FormatString = value;
txtEdit.Properties.EditFormat.FormatString = value;
txtEdit.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom;
txtEdit.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Custom;
txtEdit.Properties.Mask.EditMask = value;
txtEdit.Properties.Mask.UseMaskAsDisplayFormat = true;
txtEdit.Properties.TimeFormat = value.IndexOf("ss", StringComparison.OrdinalIgnoreCase) >= 0
? DevExpress.XtraEditors.Controls.TimeFormat.HourMinSec
: DevExpress.XtraEditors.Controls.TimeFormat.HourMin;
}
/// <summary>
/// 按控件显示精度比较当前值和原值,避免 DateTime/TimeSpan 字符串格式差异造成误判。
/// </summary>
public bool IsSameTime(string value)
{
TimeSpan oldTime;
TimeSpan currentTime;
bool hasOldTime = TryGetTime(value, out oldTime);
bool hasCurrentTime = TryGetTime(EditText, out currentTime);
if (!hasOldTime || !hasCurrentTime)
{
return !hasOldTime && !hasCurrentTime;
}
if (formatString.IndexOf("ss", StringComparison.OrdinalIgnoreCase) >= 0)
{
return oldTime.Hours == currentTime.Hours &&
oldTime.Minutes == currentTime.Minutes &&
oldTime.Seconds == currentTime.Seconds;
}
return oldTime.Hours == currentTime.Hours && oldTime.Minutes == currentTime.Minutes;
}
private static bool TryGetTime(string value, out TimeSpan timeValue)
{
timeValue = TimeSpan.Zero;
if (string.IsNullOrWhiteSpace(value))
{
return false;
}
if (TimeSpan.TryParse(value, out timeValue))
{
return true;
}
DateTime dateValue;
if (DateTime.TryParse(value, out dateValue))
{
timeValue = dateValue.TimeOfDay;
return true;
}
return false;
}
}
}
+4 -1
View File
@@ -456,7 +456,6 @@
<Compile Include="BlinkBrowser.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CefBrowserLifetimeCoordinator.cs" />
<Compile Include="BrowserSetting2\BsClient.cs" />
<Compile Include="BrowserSetting2\BsContextMenuHandler.cs" />
<Compile Include="BrowserSetting2\BsDownloadHandler.cs" />
@@ -928,6 +927,7 @@
<DependentUpon>LabelWeigh.cs</DependentUpon>
</Compile>
<Compile Include="Model\AttachHelper.cs" />
<Compile Include="Model\AltButtonShortcutManager.cs" />
<Compile Include="AuditPanelEx.cs">
<SubType>UserControl</SubType>
</Compile>
@@ -1219,6 +1219,9 @@
<Compile Include="LabelDateEdit.Designer.cs">
<DependentUpon>LabelDateEdit.cs</DependentUpon>
</Compile>
<Compile Include="LabelTimeEdit.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="LabelImageEdit.cs">
<SubType>UserControl</SubType>
</Compile>
@@ -0,0 +1,122 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using DevExpress.XtraEditors;
namespace Lskj.Control.Model
{
/// <summary>
/// 将按钮原有的 &amp; 助记键改为必须按 Alt 才能触发的快捷键。
/// </summary>
public sealed class AltButtonShortcutManager
{
private sealed class ShortcutItem
{
public SimpleButton Button;
public Keys Key;
}
private readonly List<ShortcutItem> mShortcutItems =
new List<ShortcutItem>();
private bool mUpdatingText;
/// <summary>
/// 注册按钮快捷键,并移除标题中的 &amp;,保持界面显示为“按钮名(X)”。
/// </summary>
public void Register(SimpleButton button, Keys defaultKey)
{
if (button == null)
{
return;
}
ShortcutItem item = mShortcutItems.Find(
shortcut => ReferenceEquals(shortcut.Button, button));
if (item == null)
{
item = new ShortcutItem { Button = button, Key = defaultKey };
mShortcutItems.Add(item);
button.TextChanged += OnButtonTextChanged;
}
UpdateShortcut(item, defaultKey);
}
/// <summary>
/// 只响应 Alt+原助记键;未按 Alt、同时按下其他修饰键时均不处理。
/// </summary>
public bool ProcessKey(Keys keyData)
{
if ((keyData & Keys.Modifiers) != Keys.Alt)
{
return false;
}
Keys keyCode = keyData & Keys.KeyCode;
foreach (ShortcutItem item in mShortcutItems)
{
SimpleButton button = item.Button;
if (item.Key == keyCode && button != null &&
!button.IsDisposed && button.Visible && button.Enabled)
{
button.PerformClick();
return true;
}
}
return false;
}
private void OnButtonTextChanged(object sender, EventArgs e)
{
if (mUpdatingText)
{
return;
}
SimpleButton button = sender as SimpleButton;
ShortcutItem item = mShortcutItems.Find(
shortcut => ReferenceEquals(shortcut.Button, button));
if (item != null)
{
UpdateShortcut(item, item.Key);
}
}
private void UpdateShortcut(ShortcutItem item, Keys defaultKey)
{
string text = item.Button.Text ?? string.Empty;
int mnemonicIndex = FindMnemonicIndex(text);
if (mnemonicIndex >= 0)
{
item.Key = (Keys)char.ToUpperInvariant(text[mnemonicIndex + 1]);
mUpdatingText = true;
try
{
item.Button.Text = text.Remove(mnemonicIndex, 1);
}
finally
{
mUpdatingText = false;
}
}
else
{
item.Key = defaultKey;
}
}
private static int FindMnemonicIndex(string text)
{
for (int index = 0; index < text.Length - 1; index++)
{
if (text[index] == '&' && char.IsLetterOrDigit(text[index + 1]))
{
return index;
}
}
return -1;
}
}
}
@@ -44,19 +44,39 @@ namespace Lskj.Control.Model
Dictionary<BandedGridView, List<BandedGridDragGrid>> registrations,
BandedGridView gridView)
{
if (registrations == null)
return;
foreach (KeyValuePair<BandedGridView, List<BandedGridDragGrid>> entry in registrations.ToList())
{
bool removeKey = ReferenceEquals(entry.Key, gridView);
foreach (BandedGridDragGrid registration in entry.Value.ToList())
List<BandedGridDragGrid> registrationsForView = entry.Value;
if (registrationsForView == null)
{
if (removeKey || registration == null || registration._disposed || registration.References(gridView))
registrations.Remove(entry.Key);
continue;
}
foreach (BandedGridDragGrid registration in registrationsForView.ToList())
{
if (removeKey || registration == null || registration._disposed ||
registration.References(gridView))
{
if (registration != null)
{
try
{
registration.Dispose();
entry.Value.Remove(registration);
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine("清理带状表格拖拽注册失败:" + exception);
}
}
if (removeKey || entry.Value.Count == 0)
registrationsForView.Remove(registration);
}
}
if (removeKey || registrationsForView.Count == 0)
registrations.Remove(entry.Key);
}
}
@@ -65,23 +85,71 @@ namespace Lskj.Control.Model
Dictionary<GridView, List<BandedGridDragGrid>> registrations,
GridView gridView)
{
if (registrations == null)
return;
foreach (KeyValuePair<GridView, List<BandedGridDragGrid>> entry in registrations.ToList())
{
bool removeKey = ReferenceEquals(entry.Key, gridView);
foreach (BandedGridDragGrid registration in entry.Value.ToList())
List<BandedGridDragGrid> registrationsForView = entry.Value;
if (registrationsForView == null)
{
if (removeKey || registration == null || registration._disposed || registration.References(gridView))
registrations.Remove(entry.Key);
continue;
}
foreach (BandedGridDragGrid registration in registrationsForView.ToList())
{
if (removeKey || registration == null || registration._disposed ||
registration.References(gridView))
{
if (registration != null)
{
try
{
registration.Dispose();
entry.Value.Remove(registration);
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine("清理带状表格拖拽注册失败:" + exception);
}
}
if (removeKey || entry.Value.Count == 0)
registrationsForView.Remove(registration);
}
}
if (removeKey || registrationsForView.Count == 0)
registrations.Remove(entry.Key);
}
}
private static bool IsDisposedView(BandedGridView view)
{
if (view == null)
return true;
try
{
return view.GridControl == null || view.GridControl.IsDisposed;
}
catch
{
return true;
}
}
private static bool IsDisposedView(GridView view)
{
if (view == null)
return true;
try
{
return view.GridControl == null || view.GridControl.IsDisposed;
}
catch
{
return true;
}
}
internal bool References(GridView gridView)
{
return gridView != null &&
@@ -124,8 +192,14 @@ namespace Lskj.Control.Model
/// <param name="tarGridView">目标GridView.</param>
public BandedGridDragGrid(BandedGridView sourceView, GridView targetView)
{
// Do not retain an incomplete registration in the global dictionaries.
if (IsDisposedView(sourceView) || IsDisposedView(targetView))
return;
this._sourceGridView = sourceView;
this._targetGridView = targetView;
try
{
//记录所有拖拽类到来源表中,后每次进入目标表禁用其他拖拽类的拖拽事件
if (StaticBandedControl.BandedGridViewDragGridDic.ContainsKey(sourceView))
{
@@ -172,6 +246,21 @@ namespace Lskj.Control.Model
this._targetGridView.Disposed += OnGridViewDisposed;
}
}
catch
{
// Roll back dictionary entries and event handlers from a partial
// registration before surfacing the original failure.
try
{
Dispose();
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine("回滚带状表格拖拽注册失败:" + exception);
}
throw;
}
}
private void OnGridViewDisposed(object sender, EventArgs e)
{
@@ -225,7 +314,8 @@ namespace Lskj.Control.Model
if (ReferenceEquals(
StaticBandedControl.SourceDragBandedGridView,
sourceGridView))
sourceGridView) &&
!HasRegistrationForView(sourceGridView))
{
StaticBandedControl.SourceDragBandedGridView = null;
}
@@ -237,6 +327,37 @@ namespace Lskj.Control.Model
_targetGridView = null;
}
private static bool HasRegistrationForView(BandedGridView gridView)
{
if (gridView == null)
return false;
List<BandedGridDragGrid> items;
if (StaticBandedControl.BandedGridViewDragGridDic != null &&
StaticBandedControl.BandedGridViewDragGridDic.TryGetValue(gridView, out items) &&
ContainsLiveRegistration(items, gridView))
return true;
if (StaticBandedControl.BandedTargetViewDragGridDic != null)
foreach (KeyValuePair<GridView, List<BandedGridDragGrid>> entry in
StaticBandedControl.BandedTargetViewDragGridDic)
if (ContainsLiveRegistration(entry.Value, gridView))
return true;
return false;
}
private static bool ContainsLiveRegistration(
IEnumerable<BandedGridDragGrid> registrations,
GridView gridView)
{
if (registrations == null || gridView == null)
return false;
foreach (BandedGridDragGrid item in registrations)
if (item != null && !item._disposed && item.References(gridView))
return true;
return false;
}
private static void RemoveRegistration<TKey>(
Dictionary<TKey, List<BandedGridDragGrid>> registrations,
TKey key,
@@ -248,12 +369,23 @@ namespace Lskj.Control.Model
return;
}
if (registrations == null)
{
return;
}
List<BandedGridDragGrid> registrationsForView;
if (!registrations.TryGetValue(key, out registrationsForView))
{
return;
}
if (registrationsForView == null)
{
registrations.Remove(key);
return;
}
registrationsForView.Remove(registration);
if (registrationsForView.Count == 0)
{
+119 -6
View File
@@ -46,23 +46,62 @@ namespace Lskj.Control.Model
Dictionary<GridView, List<GridDragGrid>> registrations,
GridView gridView)
{
if (registrations == null)
return;
// A module-close operation must only remove registrations that
// reference the exact view being closed. Never infer ownership
// from GridControl.IsDisposed here: another open tab can be in a
// transient initialization/dispose state and its registration
// must remain untouched.
foreach (KeyValuePair<GridView, List<GridDragGrid>> entry in registrations.ToList())
{
bool removeKey = ReferenceEquals(entry.Key, gridView);
foreach (GridDragGrid registration in entry.Value.ToList())
List<GridDragGrid> registrationsForView = entry.Value;
if (registrationsForView == null)
{
if (removeKey || registration == null || registration._disposed || registration.References(gridView))
registrations.Remove(entry.Key);
continue;
}
foreach (GridDragGrid registration in registrationsForView.ToList())
{
if (removeKey || registration == null || registration._disposed ||
registration.References(gridView))
{
if (registration != null)
{
try
{
registration.Dispose();
entry.Value.Remove(registration);
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine("清理表格拖拽注册失败:" + exception);
}
}
if (removeKey || entry.Value.Count == 0)
registrationsForView.Remove(registration);
}
}
if (removeKey || registrationsForView.Count == 0)
registrations.Remove(entry.Key);
}
}
private static bool IsDisposedView(GridView view)
{
if (view == null)
return true;
try
{
return view.GridControl == null || view.GridControl.IsDisposed;
}
catch
{
return true;
}
}
internal bool References(GridView gridView)
{
return gridView != null &&
@@ -115,8 +154,16 @@ namespace Lskj.Control.Model
/// <param name="tarGridView">目标GridView.</param>
public GridDragGrid(GridView sourceView, GridView targetView)
{
// Do not put an incomplete registration in the global dictionaries.
// A GridView without an owner GridControl cannot receive the drag
// events below and would otherwise remain a strong static reference.
if (IsDisposedView(sourceView) || IsDisposedView(targetView))
return;
this._sourceGridView = sourceView;
this._targetGridView = targetView;
try
{
//记录所有拖拽类到来源表中,后每次进入目标表禁用其他拖拽类的拖拽事件
if (StaticControl.GridViewDragGridDic.ContainsKey(sourceView))
{
@@ -163,6 +210,21 @@ namespace Lskj.Control.Model
this._targetGridView.Disposed += OnGridViewDisposed;
}
}
catch
{
// Registration is a two-dictionary operation. If event wiring
// fails, undo everything that was attached before rethrowing.
try
{
Dispose();
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine("回滚表格拖拽注册失败:" + exception);
}
throw;
}
}
private void OnGridViewDisposed(object sender, EventArgs e)
{
@@ -214,7 +276,8 @@ namespace Lskj.Control.Model
targetGridView,
this);
if (ReferenceEquals(StaticControl.SourceDragGridView, sourceGridView))
if (ReferenceEquals(StaticControl.SourceDragGridView, sourceGridView) &&
!HasRegistrationForView(sourceGridView))
{
StaticControl.SourceDragGridView = null;
}
@@ -226,6 +289,45 @@ namespace Lskj.Control.Model
_targetGridView = null;
}
private static bool HasRegistrationForView(GridView gridView)
{
if (gridView == null)
return false;
return HasRegistration(StaticControl.GridViewDragGridDic, gridView) ||
HasRegistration(StaticControl.TargetViewDragGridDic, gridView);
}
internal static void ClearSourceReferenceIfUnused(GridView gridView)
{
if (gridView != null &&
ReferenceEquals(StaticControl.SourceDragGridView, gridView) &&
!HasRegistrationForView(gridView))
{
StaticControl.SourceDragGridView = null;
}
}
private static bool HasRegistration<TKey>(
Dictionary<TKey, List<GridDragGrid>> registrations,
GridView gridView)
where TKey : class
{
if (registrations == null || gridView == null)
return false;
foreach (KeyValuePair<TKey, List<GridDragGrid>> entry in registrations)
{
List<GridDragGrid> items = entry.Value;
if (items == null)
continue;
foreach (GridDragGrid item in items)
if (item != null && !item._disposed && item.References(gridView))
return true;
}
return false;
}
private static void RemoveRegistration<TKey>(
Dictionary<TKey, List<GridDragGrid>> registrations,
TKey key,
@@ -237,12 +339,23 @@ namespace Lskj.Control.Model
return;
}
if (registrations == null)
{
return;
}
List<GridDragGrid> registrationsForView;
if (!registrations.TryGetValue(key, out registrationsForView))
{
return;
}
if (registrationsForView == null)
{
registrations.Remove(key);
return;
}
registrationsForView.Remove(registration);
if (registrationsForView.Count == 0)
{
@@ -289,7 +402,6 @@ namespace Lskj.Control.Model
DragHander.Clear();
}
}
/// <summary>
/// <para>说明:获取表格选中行数据</para>
/// <para>创建人:龚宇超</para>
@@ -552,6 +664,7 @@ namespace Lskj.Control.Model
}
}
}
/// <summary>
/// 焦点行改变时
/// </summary>
+5 -1
View File
@@ -622,6 +622,8 @@ namespace Lskj.Control.Model
}
GridColumnModel model = col.Tag as GridColumnModel;
// 操作列是运行时创建的界面列,不参与个性化保存。
if (model == null) continue;
DataRow a = customTable.Rows.Cast<DataRow>().FirstOrDefault(x => col.Name.Equals(x["fieldName"] + "", StringComparison.OrdinalIgnoreCase));
string tempSql = a == null ? string.Format(@"insert into {8}(formkey,fieldname,username,orderid,isvisible,operatorid,operatorName,operatedate,fieldWidth,IfFixColumn,FieldText {11}) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}',getdate(),'{7}','{9}','{10}' {12});",
key, col.FieldName, col.Caption, col.VisibleIndex, Convert.ToInt32(col.Visible), ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, col.Width, ResourceKeys.SettingTableName, col.OwnerBand != null ? col.OwnerBand.Fixed == DevExpress.XtraGrid.Columns.FixedStyle.Left ? 1 : 0 : 0, model.FieldText, saveFieldName, fieldValue) : string.Format(@"update {6} set orderid='{0}',fieldWidth='{1}',isvisible={2},IfFixColumn='{7}' {8} where formkey='{3}' and fieldname='{4}' and operatorid='{5}';",
@@ -1146,6 +1148,8 @@ namespace Lskj.Control.Model
gridControl.gridViewRightMenu = rightMenu;
rightMenu.InitRightMenus(gridControl, table, model, control, menu);
rightMenu.SetRightCallback(handler);
// 右键菜单创建完成后再生成多表头操作列,确保按钮数据完整。
gridControl.SetRightMenuButtonTable(table);
}
/// <summary>
/// <para>说明:设置图标右键菜单</para>
@@ -4126,7 +4130,7 @@ namespace Lskj.Control.Model
// 添加内容
if (i == 0)
{
string guid = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string guid = ERPInfo.Instance.CurrentModulePage.Tag + "";
DllModule model = ERPInfo.Instance.ModuleForms[guid];
cell.SetCellValue(model.Name);
}
@@ -31,6 +31,9 @@ using Lskj.Business;
public static class LabPicUrlPreview
{
private static readonly object AttachedViewsSync = new object();
private static readonly List<WeakReference> AttachedViews = new List<WeakReference>();
// ====== 对外:初始化图片列(创建 RepositoryItemPictureEdit、设为 Unbound ======
public static void InitPicColumn(GridControl gridControl, GridColumn gridColumn, GridColumnModel model)
{
@@ -61,6 +64,7 @@ public static class LabPicUrlPreview
if (view == null) return;
view.CustomUnboundColumnData -= OnCustomUnboundColumnData;
view.CustomUnboundColumnData += OnCustomUnboundColumnData;
TrackAttachedView(view);
}
// ====== 对外:绑定“双击大图预览”的事件(只需调用一次) ======
@@ -69,6 +73,54 @@ public static class LabPicUrlPreview
if (view == null) return;
view.DoubleClick -= OnViewDoubleClick;
view.DoubleClick += OnViewDoubleClick;
TrackAttachedView(view);
}
public static void Detach(ColumnView view)
{
if (view == null) return;
view.CustomUnboundColumnData -= OnCustomUnboundColumnData;
view.DoubleClick -= OnViewDoubleClick;
if (UntrackAttachedView(view))
{
ImageCache.Clear();
}
}
private static void TrackAttachedView(ColumnView view)
{
lock (AttachedViewsSync)
{
for (int i = AttachedViews.Count - 1; i >= 0; i--)
{
object target = AttachedViews[i].Target;
if (target == null)
{
AttachedViews.RemoveAt(i);
}
else if (ReferenceEquals(target, view))
{
return;
}
}
AttachedViews.Add(new WeakReference(view));
}
}
private static bool UntrackAttachedView(ColumnView view)
{
lock (AttachedViewsSync)
{
for (int i = AttachedViews.Count - 1; i >= 0; i--)
{
object target = AttachedViews[i].Target;
if (target == null || ReferenceEquals(target, view))
{
AttachedViews.RemoveAt(i);
}
}
return AttachedViews.Count == 0;
}
}
// ===================== 缩略图事件实现 =====================
@@ -292,6 +344,12 @@ public static class LabPicUrlPreview
// ====== 图片缓存(缩略图 & 原图)—— WebClient + Dictionary + SemaphoreC# 7.3 兼容 ======
private static class ImageCache
{
public static void Clear()
{
ThumbCache.Clear();
FullCache.Clear();
}
// —— 公共接口(缩略图) ——
public static bool TryGetThumb(string url, int targetHeight, out Image img)
{
@@ -326,6 +384,7 @@ public static class LabPicUrlPreview
new Dictionary<string, CacheEntry>(StringComparer.OrdinalIgnoreCase);
private static readonly Dictionary<string, Task<Image>> _tasks =
new Dictionary<string, Task<Image>>(StringComparer.OrdinalIgnoreCase);
private static int _generation;
private static readonly Semaphore _throttle = new Semaphore(4, 4); // 并发 4
private const int Capacity = 300;
@@ -377,6 +436,7 @@ public static class LabPicUrlPreview
return;
}
int generation = _generation;
Task<Image> task = Task.Factory.StartNew<Image>(delegate
{
_throttle.WaitOne();
@@ -394,15 +454,21 @@ public static class LabPicUrlPreview
}, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).ContinueWith<Image>(delegate (Task<Image> t)
{
Image result = t.Result;
bool keepResult = false;
lock (_lock)
{
_tasks.Remove(key);
if (result != null)
if (result != null && generation == _generation)
{
_cache[key] = new CacheEntry { Image = result, LastHitUtc = DateTime.UtcNow };
TrimIfNeededUnsafe();
keepResult = true;
}
}
if (!keepResult && result != null)
{
try { result.Dispose(); } catch { }
}
return result;
}, TaskScheduler.Default);
@@ -431,6 +497,27 @@ public static class LabPicUrlPreview
}
}
}
public static void Clear()
{
lock (_lock)
{
_generation++;
foreach (CacheEntry entry in _cache.Values)
{
try
{
if (entry != null && entry.Image != null)
entry.Image.Dispose();
}
catch { }
}
_cache.Clear();
// Drop task references immediately. In-flight continuations use
// the generation check and dispose stale images when they finish.
_tasks.Clear();
}
}
}
// ===== 原图缓存实现(容量更小) =====
@@ -447,6 +534,7 @@ public static class LabPicUrlPreview
new Dictionary<string, CacheEntry>(StringComparer.OrdinalIgnoreCase);
private static readonly Dictionary<string, Task<Image>> _tasks =
new Dictionary<string, Task<Image>>(StringComparer.OrdinalIgnoreCase);
private static int _generation;
private static readonly Semaphore _throttle = new Semaphore(2, 2); // 原图并发更小
private const int Capacity = 50;
@@ -491,6 +579,7 @@ public static class LabPicUrlPreview
return;
}
int generation = _generation;
Task<Image> task = Task.Factory.StartNew<Image>(delegate
{
_throttle.WaitOne();
@@ -509,15 +598,21 @@ public static class LabPicUrlPreview
}, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).ContinueWith<Image>(delegate (Task<Image> t)
{
Image result = t.Result;
bool keepResult = false;
lock (_lock)
{
_tasks.Remove(url);
if (result != null)
if (result != null && generation == _generation)
{
_cache[url] = new CacheEntry { Image = result, LastHitUtc = DateTime.UtcNow };
TrimIfNeededUnsafe();
keepResult = true;
}
}
if (!keepResult && result != null)
{
try { result.Dispose(); } catch { }
}
return result;
}, TaskScheduler.Default);
@@ -546,6 +641,27 @@ public static class LabPicUrlPreview
}
}
}
public static void Clear()
{
lock (_lock)
{
_generation++;
foreach (CacheEntry entry in _cache.Values)
{
try
{
if (entry != null && entry.Image != null)
entry.Image.Dispose();
}
catch { }
}
_cache.Clear();
// Drop task references immediately. In-flight continuations use
// the generation check and dispose stale images when they finish.
_tasks.Clear();
}
}
}
// ===== 共享底层工具 =====
@@ -209,6 +209,26 @@ namespace Lskj.Control.Model
this.OnRightCallback = handler;
}
internal virtual void ReleaseResourcesForDispose()
{
OnRightCallback = null;
OnBeforeHandleParamsCallback = null;
if (MenuStrip != null)
{
MenuStrip.Opening -= MenuStripOpening;
MenuStrip.Dispose();
MenuStrip = null;
}
RightMenuItems.Clear();
RightMenuBtnEdits.Clear();
RightMenuMrpBtnEdits.Clear();
BaseGridView = null;
ControlObj = null;
Model = null;
MenuTable = null;
AccountItem = null;
}
/// <summary>
/// <para>说明:右键菜单执行前调用</para>
/// <para>创建人:龚宇超</para>
@@ -500,10 +520,9 @@ namespace Lskj.Control.Model
{
// 只执行一次,则后续不再执行.
if (execOnlyOne && i > 0) continue;
LogUtil.WriteDebug(model.MenuTabName, "执行右键", model.MenuName, "右键id" + model.Id);
DataRow rowData = rows[i];
if (!string.IsNullOrWhiteSpace(model.BeforeMsg) && tipOnlyOne)
{
tipOnlyOne = false;
@@ -541,6 +560,33 @@ namespace Lskj.Control.Model
}
paramList = this.HandleRightMenuParams(paramListEx, rowData, model.Mergeexec ? rows : null, model.ActionType);
string parameterText = string.Empty;//"{0}_{1}_{2}_{3}_{4}_{5}_{6}_{7}_{8}_{9}_{10}_{11}_{12}_{13}";
if (model.ActionType == 0 || model.ActionType == 1)
{
string newSql = string.Empty;
if (model.ActionType == 0)
{
newSql = !string.IsNullOrEmpty(actionSql) ? actionSql : model.Action;
newSql=ReplaceHelper.ReplaceRowParam(rowData, newSql);
}
if (model.ActionType == 1)
{
List<string> procParams = ReplaceHelper.GetParamFields(model.Action);
newSql = model.Action.Replace(procParams[0], "").Trim();
}
parameterText += newSql;
foreach (string item in paramList)
{
parameterText += "_" + item;
}
}
string LogText = string.Format("【{0}】执行模块【{1}】的右键【{2}】参数:{3}", ERPInfo.Instance.UserName, model.MenuTabName, model.MenuName, parameterText);
LogUtil.WriteDebug(model.MenuTabName, "执行右键", "右键id" + model.Id, LogText);
string maintabFocusedRowJson = "";
if (rowData != null)
{
@@ -1182,7 +1228,7 @@ namespace Lskj.Control.Model
paramList[12],
paramList[13]//固定添加行数据json字符串
};
XtraTabPage xtraTab = ERPInfo.Instance.PageControl != null ? ERPInfo.Instance.PageControl.SelectedTabPage : null;
XtraTabPage xtraTab = ERPInfo.Instance.CurrentModulePage != null ? ERPInfo.Instance.CurrentModulePage : null;
DllModule module = new DllModule
{
DllName = ReplaceDllFileName(dllName),
@@ -1194,12 +1240,12 @@ namespace Lskj.Control.Model
{
if (SystemInfo.Instance.SoftOpenMode)
{
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Text == model.MenuName)
{
MessageUtil.Show("已设置不能打开多个相同模块!");
ERPInfo.Instance.PageControl.SelectedTabPage = tablepage;
ERPInfo.Instance.CurrentModulePage = tablepage;
return false;
}
}
@@ -1284,14 +1330,45 @@ namespace Lskj.Control.Model
SmartX1Api.SmartX1Close(keyHandle);
}
}
IForm form = FormHelper.LoadDllForm(dllName, str);
string guid = isAddPage ? Guid.NewGuid().ToString() : null;
StaticControl.ModuleResourceScope moduleScope = null;
XtraTabPage modulePage = null;
if (isAddPage)
{
modulePage = new XtraTabPage();
modulePage.Tag = guid;
moduleScope = new StaticControl.ModuleResourceScope(guid);
StaticControl.AttachModuleScope(modulePage, moduleScope);
moduleScope.Register(modulePage, () =>
{
if (!modulePage.IsDisposed)
modulePage.Dispose();
});
}
IForm form;
if (moduleScope == null)
{
form = FormHelper.LoadDllForm(dllName, str);
}
else
{
using (StaticControl.PushModuleScope(moduleScope))
{
form = FormHelper.LoadDllForm(dllName, str);
}
}
if (form == null)
{
if (moduleScope != null)
moduleScope.Dispose();
MessageUtil.Show(ResourceKeys.DyncmicDllNotFount);
return false;
}
if (form.SubForm == null)
{
if (moduleScope != null)
moduleScope.Dispose();
MessageUtil.Show(ResourceKeys.DyncmicDllInitFault);
return false;
}
@@ -1310,7 +1387,7 @@ namespace Lskj.Control.Model
form.SubForm.Text = model.MenuName;
if (isPrivateDll)
{
StaticControl.DogVerifyNoPageForms.Add(form);
StaticControl.RegisterProtectedForm(form);
}
if (form.SubForm is BaseForm)//dllName.Equals("Lskj.BaseAccraditation.dll", StringComparison.OrdinalIgnoreCase)
{
@@ -1338,8 +1415,7 @@ namespace Lskj.Control.Model
}
else
{
string guid = Guid.NewGuid().ToString();
XtraTabPage tp = new XtraTabPage();
XtraTabPage tp = modulePage;
tp.Text = model.MenuName;
if (!string.IsNullOrWhiteSpace(model.PageName))
@@ -1357,22 +1433,26 @@ namespace Lskj.Control.Model
tp.Controls.Add(form.SubForm);
tp.ShowCloseButton = DefaultBoolean.True;
tp.Dock = DockStyle.Fill;
StaticControl.RegisterModulePage(module, tp, form.SubForm);
//配置了右键刷新的情况下,在当前页签关闭时触发刷新
if (model.Refresh && this.OnRightCallback != null)
{
tp.Disposed += new EventHandler(OnTp_Disposed);
}
ERPInfo.Instance.PageControl.TabPages.Add(tp);
ERPInfo.Instance.PageControl.SelectedTabPage = tp;
ERPInfo.Instance.AddModulePage(tp);
ERPInfo.Instance.CurrentModulePage = tp;
if (isPrivateDll)
{
StaticControl.DogVerifyModuleForms.Add(tp);
StaticControl.RegisterProtectedPage(tp);
}
if (form.SubForm is BaseForm)
{
(form.SubForm as BaseForm).ParentView = this.BaseGridView;
}
using (StaticControl.PushModuleScope(moduleScope))
{
form.SubForm.Show();
}
ERPInfo.Instance.ModuleForms.Add(guid, module);
//直接页签打开模块会直接向后面运行,默认返回false避免外面执行右键刷新
return false;
@@ -21,6 +21,7 @@ namespace Lskj.Control.Model
public class GridViewMenuStrip : BaseRightMenu
{
private int[] _oldSelectRows;
private HashSet<object> _oldSelectPrimaryValues;
private DataRow _oldDataRow;
private int _oldRowHandler;
private GridView _gridView;
@@ -38,6 +39,19 @@ namespace Lskj.Control.Model
}
}
internal override void ReleaseResourcesForDispose()
{
if (GridControlObj != null && GridControlObj.gridControl != null &&
ReferenceEquals(GridControlObj.gridControl.ContextMenuStrip, MenuStrip))
{
GridControlObj.gridControl.ContextMenuStrip = null;
}
GridControlObj = null;
_gridView = null;
_control = null;
base.ReleaseResourcesForDispose();
}
protected override void MenuStripOpening(object sender, System.ComponentModel.CancelEventArgs e)
{
int[] mSelectRows = this._gridView.GetSelectedRows() ?? new int[0];
@@ -231,8 +245,82 @@ namespace Lskj.Control.Model
this._oldSelectRows = this._gridView.GetSelectedRows();
this._oldDataRow = this._gridView.GetFocusedDataRow();
this._oldRowHandler = this._gridView.FocusedRowHandle;
// 复选框模式下保存选中行的主键值,避免刷新后行号对应到其他数据。
this._oldSelectPrimaryValues = null;
string primaryKey = this.GridControlObj == null ? string.Empty : this.GridControlObj.MultiplePrimary;
bool isCheckBoxRowSelect = this._gridView.OptionsSelection.MultiSelect == true
&& this._gridView.OptionsSelection.EnableAppearanceFocusedCell == false
&& this._gridView.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CheckBoxRowSelect;
if (isCheckBoxRowSelect && !string.IsNullOrWhiteSpace(primaryKey) && this._oldSelectRows != null)
{
foreach (int rowHandle in this._oldSelectRows)
{
DataRow row = this._gridView.GetDataRow(rowHandle);
if (row == null || !row.Table.Columns.Contains(primaryKey) || row.IsNull(primaryKey))
continue;
object primaryValue = row[primaryKey];
if (string.IsNullOrWhiteSpace(primaryValue + ""))
continue;
if (this._oldSelectPrimaryValues == null)
this._oldSelectPrimaryValues = new HashSet<object>();
this._oldSelectPrimaryValues.Add(primaryValue);
}
}
}
protected override void MenuStripClickAfter(ToolStripMenuItem item, GridRightMenuModel model)
{
string ParmaryKey = string.Empty;
if(this.GridControlObj!=null) ParmaryKey = GridControlObj.MultiplePrimary;
bool isCheckBoxRowSelect = this._gridView.OptionsSelection.MultiSelect == true&& this._gridView.OptionsSelection.EnableAppearanceFocusedCell == false && this._gridView.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CheckBoxRowSelect;
DataTable currentDataTable = this.GridControlObj == null ? null : this.GridControlObj.GridControl.DataSourceTable();
if (isCheckBoxRowSelect&& !string.IsNullOrWhiteSpace(ParmaryKey) && this._oldSelectPrimaryValues != null&& this._oldSelectPrimaryValues.Count > 0&& currentDataTable != null&& currentDataTable.Columns.Contains(ParmaryKey))
{
//2026-08-17添加,如果是复选框模式,并且有主键,右键后选中之前的行用主键值判断
// 只恢复刷新后仍存在的主键,已删除的数据不再按原行号选中。
this._gridView.ClearSelection();
if (!model.RefreshCheckState)
{
DataColumn[] tablePrimaryKey = currentDataTable.PrimaryKey;
bool canFindByPrimaryKey = this.GridControlObj.GridControl.DataSource is DataTable
&& tablePrimaryKey != null
&& tablePrimaryKey.Length == 1
&& tablePrimaryKey[0].ColumnName.Equals(ParmaryKey, StringComparison.OrdinalIgnoreCase);
if (canFindByPrimaryKey)
{
// DataTable设置了PrimaryKey时,使用其内部索引直接查找。
foreach (object primaryValue in this._oldSelectPrimaryValues)
{
DataRow row = currentDataTable.Rows.Find(primaryValue);
if (row == null)
continue;
int rowHandle = this._gridView.GetRowHandle(currentDataTable.Rows.IndexOf(row));
if (rowHandle >= 0)
this._gridView.SelectRow(rowHandle);
}
}
else
{
// MultiplePrimary只是字段配置时没有数据索引,单次扫描比逐个LocateByValue更稳定。
HashSet<object> remainingPrimaryValues = new HashSet<object>(this._oldSelectPrimaryValues);
for (int rowHandle = 0; rowHandle < this._gridView.DataRowCount && remainingPrimaryValues.Count > 0; rowHandle++)
{
DataRow row = this._gridView.GetDataRow(rowHandle);
if (row == null || !row.Table.Columns.Contains(ParmaryKey) || row.IsNull(ParmaryKey))
continue;
if (remainingPrimaryValues.Remove(row[ParmaryKey]))
this._gridView.SelectRow(rowHandle);
}
}
}
}
else
{
DataTable dataTable = this.GridControlObj.GridView.GetGridViewFilteredAndSortedDataToDataTable() as DataTable;
List<DataRow> rows = new List<DataRow>() { this._oldDataRow };
@@ -268,6 +356,7 @@ namespace Lskj.Control.Model
this._gridView.SelectRowHandler(this._oldRowHandler);
}
}
}
protected override List<string> HandleRightMenuParams(List<string> paramList, DataRow rowData, DataRow[] rowDatas = null, int actionType = 0)
{
List<string> handleParamList = base.HandleRightMenuParams(paramList, rowData, rowDatas, actionType);
+66 -24
View File
@@ -15,6 +15,7 @@ using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
@@ -34,6 +35,13 @@ namespace Lskj.Control.Model
/// </summary>
public class MyControl : IDisposable
{
// Runtime menus and managers are owned by this model instance.
private readonly IContainer _components = new Container();
/// <summary>
/// Raised once when this non-visual control model releases its owned
/// resources. Static runtime references use it to clear exact owners.
/// </summary>
public event EventHandler Disposed;
private const long UserSearchCooldownTicks =
TimeSpan.TicksPerMillisecond * 350;
private string _searchSql;
@@ -54,6 +62,10 @@ namespace Lskj.Control.Model
private bool mUserSearchInProgress;
private long mLastUserSearchCompletedTicks;
private int mAcceptedUserSearchCount;
public bool IsDisposed
{
get { return mDisposed; }
}
/// <summary>
/// 计算字段
/// </summary>
@@ -112,7 +124,7 @@ namespace Lskj.Control.Model
/// </summary>
public string RefreshControl;
protected bool mLoading = false;
protected Timer mTimer = new Timer();
protected Timer mTimer;
/// <summary>
/// 查询按钮
/// </summary>
@@ -304,7 +316,8 @@ namespace Lskj.Control.Model
/// </summary>
public MyControl()
{
mTimer = new Timer(_components);
StaticControl.RegisterModuleResource(this, Dispose);
}
/// <summary>
/// Initializes a new instance of the <see cref="MyControl"/> class.
@@ -315,12 +328,14 @@ namespace Lskj.Control.Model
/// <param name="treeView">The tree view.</param>
public MyControl(string searchSql, GridControlEx mainGridEx, TreeViewEx treeView = null, GridControlEx gridLeft = null, MyControl leftSearch = null)
{
mTimer = new Timer(_components);
this._searchSql = searchSql;
this._mainGridEx = mainGridEx;
if (this._mainGridEx != null) this._gridControl = _mainGridEx.GridControl;
this._tvLeft = treeView;
this._gridLeft = gridLeft;
this._leftSearch = leftSearch;
StaticControl.RegisterModuleResource(this, mainGridEx, Dispose);
}
/// <summary>
/// <para>说明:设置GridControlEx</para>
@@ -336,6 +351,7 @@ namespace Lskj.Control.Model
{
this._mainGridEx = mainGridEx;
if (this._mainGridEx != null) this._gridControl = _mainGridEx.GridControl;
StaticControl.RegisterModuleResource(this, mainGridEx, Dispose);
}
/// <summary>
/// <para>说明:设置GridLeft</para>
@@ -435,10 +451,7 @@ namespace Lskj.Control.Model
{
BaseUserControl baseControl = control as BaseUserControl;
baseControl.Location = model.Location;
System.Threading.SynchronizationContext.Current.Post(SetProperty, null);
void SetProperty(object state)
{
//放到外面避免线程问题
// 控件创建、属性设置和挂载必须保持在同一条 UI 线程上,避免 WPF 宿主下 Timer 先执行。
baseControl.Model = model;
baseControl.FontSize = model.FontSize;
baseControl.Name = "txt_" + model.FieldName;
@@ -455,7 +468,6 @@ namespace Lskj.Control.Model
baseControl.Required = model.IsEmpty;
baseControl.Tag = model;
baseControl.TabIndex = model.TabOrder;
}
for (int i = 0; i < startLocktion.Count; i++)
{
@@ -1043,7 +1055,7 @@ namespace Lskj.Control.Model
{
if (_popupMenu == null)
{
_popupMenu = new PopupMenu();
_popupMenu = new PopupMenu(_components);
}
_dropDown = new DropDownButton();
_dropDown.DropDownArrowStyle = DropDownArrowStyle.Show;
@@ -1056,7 +1068,7 @@ namespace Lskj.Control.Model
_dropDown.Leave += new EventHandler(OnDropDownLeave);
width = _dropDown.Location.X + _dropDown.Width;
BarManager barManager1 = new BarManager();
BarManager barManager1 = new BarManager(_components);
_popupMenu.Manager = barManager1;
_popupMenu.Name = "pm_search";
CreateSearchScheme();
@@ -1238,7 +1250,7 @@ namespace Lskj.Control.Model
{
if (_popupMenu == null)
{
_popupMenu = new PopupMenu();
_popupMenu = new PopupMenu(_components);
}
_dropDown = new DropDownButton();
_dropDown.DropDownArrowStyle = DropDownArrowStyle.Show;
@@ -1251,7 +1263,7 @@ namespace Lskj.Control.Model
_dropDown.Leave += new EventHandler(OnDropDownLeave);
width = _dropDown.Location.X + _dropDown.Width;
BarManager barManager1 = new BarManager();
BarManager barManager1 = new BarManager(_components);
_popupMenu.Manager = barManager1;
_popupMenu.Name = "pm_search";
CreateSearchScheme();
@@ -1782,6 +1794,7 @@ namespace Lskj.Control.Model
{
timer.Tick -= mTimerTick;
timer.Stop();
_components.Remove(timer);
timer.Dispose();
}
}
@@ -2095,8 +2108,6 @@ namespace Lskj.Control.Model
case ControlType.LabDate:
case ControlType.LabDateTime:
case ControlType.LabDateTimeShort:
case ControlType.LabTime:
case ControlType.LabShortTime:
// 日期控件
LabelDateEdit dateEdit = ctr as LabelDateEdit;
if (string.IsNullOrWhiteSpace(dateEdit.FormatType))
@@ -2109,6 +2120,12 @@ namespace Lskj.Control.Model
}
//value = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.EditValue.ToString();
break;
case ControlType.LabTime:
case ControlType.LabShortTime:
// 时间控件只返回时分秒部分,不附带日期。
LabelTimeEdit timeEdit = ctr as LabelTimeEdit;
value = timeEdit == null ? string.Empty : timeEdit.EditText;
break;
case ControlType.LabDateHalfDay:
// 日期半天控件
LabelDateHalfDayEdit dateHalfDayEdit = ctr as LabelDateHalfDayEdit;
@@ -3294,7 +3311,7 @@ namespace Lskj.Control.Model
//menu.ApplyBefore += new CommonToolApplyEventHandler(OnMenuApplyBefore);
//menu.DynamicLinkAfter += new CommonToolAfterDynamicLinkEventHandler(OnDynamicLinkAfter);
//StaticControl.RightMenuGridView = MainGridEx.GridView;
StaticControl.RightMenuMyControl = this;
StaticControl.SetRightMenuMyControl(this);
menu.Apply(menuRow);
if (!menu.issuccess)
{
@@ -4519,11 +4536,20 @@ namespace Lskj.Control.Model
Font mRowFont = new Font("Microsoft YaHei UI", 12);
switch (model.FieldType)
{
case ControlType.LabTime:
case ControlType.LabShortTime:
// 时间控件使用 TimeEdit,避免 DateEdit 显示日期日历。
LabelTimeEdit timeEdit = new LabelTimeEdit();
timeEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown);
timeEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged);
// 时间类型固定使用时分或时分秒,避免旧的日期格式配置覆盖为年月日。
timeEdit.TimeFormat(DateFormat.Format(model.FieldType));
if (!isLoadBorder) timeEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
baseControl = timeEdit;
break;
case ControlType.LabDate:
case ControlType.LabDateTime:
case ControlType.LabDateTimeShort:
case ControlType.LabTime:
case ControlType.LabShortTime:
case ControlType.LabShortDate:
// 日期控件
LabelDateEdit dateEdit = new LabelDateEdit();
@@ -6699,6 +6725,10 @@ namespace Lskj.Control.Model
LabelDateEdit dateEdit = controlObj as LabelDateEdit;
value = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.DateTime.ToString("yyyy-MM-dd");
}
else if (controlObj is LabelTimeEdit)
{
value = ((LabelTimeEdit)controlObj).EditText;
}
else if (controlObj is LabelCheckEdit)
{
LabelCheckEdit checkEdit = controlObj as LabelCheckEdit;
@@ -6820,6 +6850,20 @@ namespace Lskj.Control.Model
mDisposed = true;
mUserSearchInProgress = false;
EventHandler disposed = Disposed;
Disposed = null;
if (disposed != null)
{
try
{
disposed(this, EventArgs.Empty);
}
catch
{
// Reference cleanup must not interrupt disposal.
}
}
Timer timer = mTimer;
mTimer = null;
if (timer != null)
@@ -6828,6 +6872,7 @@ namespace Lskj.Control.Model
{
timer.Tick -= mTimerTick;
timer.Stop();
_components.Remove(timer);
timer.Dispose();
}
catch
@@ -6869,17 +6914,10 @@ namespace Lskj.Control.Model
}
}
BarManager searchSchemeManager =
_popupMenu == null ? null : _popupMenu.Manager;
if (_popupMenu != null)
{
_popupMenu.Manager = null;
_popupMenu.ItemLinks.Clear();
_popupMenu.Dispose();
}
if (searchSchemeManager != null)
{
searchSchemeManager.Dispose();
}
if (_mainGridEx != null &&
@@ -6892,7 +6930,7 @@ namespace Lskj.Control.Model
{
if (Model != null && Model.DataCaches != null)
{
Model.DataCaches.Remove(this);
Model.DataCaches.RemoveCache(this);
}
}
catch
@@ -6924,6 +6962,10 @@ namespace Lskj.Control.Model
ModuleResultDic.Clear();
ParaContrlsDic.Clear();
// PopupMenu, BarManager and any future non-visual components are
// disposed together with this MyControl instance.
_components.Dispose();
_controls = null;
_schemes = null;
_fixField = null;
+59 -5
View File
@@ -20,6 +20,9 @@ namespace Lskj.Control.Model
public static class SplashForm
{
private static SplashScreenManager _loadForm;
private static readonly object _syncRoot = new object();
// FrmSplashScreen 继承 SplashScreen,创建 SplashScreenManager 时会自动显示。
private static bool _isShown;
/// <summary>
/// 等待窗口对象
@@ -27,6 +30,8 @@ namespace Lskj.Control.Model
public static SplashScreenManager LoadForm
{
get
{
lock (_syncRoot)
{
if (_loadForm == null)
{
@@ -36,6 +41,7 @@ namespace Lskj.Control.Model
return _loadForm;
}
}
}
/// <summary>
/// <para>说明:显示等待窗体</para>
/// <para>创建人:龚宇超</para>
@@ -47,10 +53,24 @@ namespace Lskj.Control.Model
/// </summary>
public static void ShowForm()
{
bool flag = !LoadForm.IsSplashFormVisible;
if (flag)
try
{
_loadForm.ShowWaitForm();
lock (_syncRoot)
{
if (!_isShown || _loadForm == null)
{
SplashScreenManager manager = LoadForm;
_isShown = manager != null;
}
}
}
catch (Exception)
{
lock (_syncRoot)
{
_isShown = false;
}
throw;
}
}
/// <summary>
@@ -64,10 +84,44 @@ namespace Lskj.Control.Model
/// </summary>
public static void HideForm()
{
bool isSplashFormVisible = LoadForm.IsSplashFormVisible;
if (isSplashFormVisible)
try
{
lock (_syncRoot)
{
if (_loadForm == null || !_isShown)
{
return;
}
_loadForm.CloseWaitForm();
_loadForm.WaitForSplashFormClose();
_isShown = false;
}
}
catch (Exception ex)
{
lock (_syncRoot)
{
_isShown = false;
}
}
finally
{
lock (_syncRoot)
{
SplashScreenManager manager = _loadForm;
_loadForm = null;
if (manager != null)
{
try
{
manager.Dispose();
}
catch (Exception)
{
}
}
}
}
}
}
@@ -1,127 +1,55 @@
using DevExpress.XtraGrid.Views.BandedGrid;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraTab;
using Lskj.Control.ZKFinger;
using Lskj.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WinFormsControl = System.Windows.Forms.Control;
using Lskj.Util;
using DevExpress.XtraTab;
namespace Lskj.Control.Model
{
/// <summary>
/// Static registries for banded-grid drag helpers. The helpers unregister
/// themselves from these dictionaries when their GridView is disposed;
/// module closing therefore does not need to scan a control tree.
/// </summary>
public static class StaticBandedControl
{
public static void ReleaseModuleReferences(WinFormsControl moduleRoot, XtraTabPage modulePage, string moduleCode)
{
try
{
List<BandedGridView> bandedViews = CollectBandedGridViews(moduleRoot);
List<GridView> targetViews = CollectTargetGridViews(moduleRoot);
foreach (BandedGridView view in bandedViews)
BandedGridDragGrid.DisposeRegistrations(
BandedGridViewDragGridDic,
BandedTargetViewDragGridDic,
view,
null);
foreach (GridView view in targetViews)
BandedGridDragGrid.DisposeRegistrations(
BandedGridViewDragGridDic,
BandedTargetViewDragGridDic,
null,
view);
if (SourceDragBandedGridView != null &&
(bandedViews.Contains(SourceDragBandedGridView) ||
(SourceDragBandedGridView.GridControl != null && SourceDragBandedGridView.GridControl.IsDisposed)))
SourceDragBandedGridView = null;
RemoveConditionPanels(moduleCode);
while (modulePage != null && DogVerifyModuleForms.Remove(modulePage))
{
}
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine("释放旧 Banded 模块引用失败:" + exception);
}
}
private static List<BandedGridView> CollectBandedGridViews(WinFormsControl root)
{
List<BandedGridView> result = new List<BandedGridView>();
if (root == null)
return result;
foreach (WinFormsControl control in EnumerateControls(root))
{
DevExpress.XtraGrid.GridControl grid = control as DevExpress.XtraGrid.GridControl;
BandedGridView view = grid == null ? null : grid.MainView as BandedGridView;
if (view != null && !result.Contains(view))
result.Add(view);
}
return result;
}
private static List<GridView> CollectTargetGridViews(WinFormsControl root)
{
List<GridView> result = new List<GridView>();
if (root == null)
return result;
foreach (WinFormsControl control in EnumerateControls(root))
{
DevExpress.XtraGrid.GridControl grid = control as DevExpress.XtraGrid.GridControl;
GridView view = grid == null ? null : grid.MainView as GridView;
if (view != null && !result.Contains(view))
result.Add(view);
}
return result;
}
private static IEnumerable<WinFormsControl> EnumerateControls(WinFormsControl root)
{
yield return root;
foreach (WinFormsControl child in root.Controls)
foreach (WinFormsControl nested in EnumerateControls(child))
yield return nested;
}
private static void RemoveConditionPanels(string moduleCode)
{
foreach (string key in ConditionsPanelDic.Keys.ToList())
{
ModuleConditionsPanelEx panel;
if (string.Equals(key, moduleCode, StringComparison.OrdinalIgnoreCase) ||
!ConditionsPanelDic.TryGetValue(key, out panel) || panel == null || panel.IsDisposed)
ConditionsPanelDic.Remove(key);
}
}
/// <summary>
/// 记录当前U盾权限窗口
/// </summary>
public static List<XtraTabPage> DogVerifyModuleForms = new List<XtraTabPage>();
public static List<IForm> DogVerifyNoPageForms = new List<IForm>();
/// <summary>
///模块打开时的条件界面
/// </summary>
public static Dictionary<string, ModuleConditionsPanelEx> ConditionsPanelDic = new Dictionary<string, ModuleConditionsPanelEx>();
// Keep the old public fields as aliases so already deployed plug-ins
// loaded from lib do not fail with MissingFieldException.
[System.Obsolete("请使用 StaticControl.DogVerifyModuleForms")]
public static List<XtraTabPage> DogVerifyModuleForms =
StaticControl.DogVerifyModuleForms;
[System.Obsolete("请使用 StaticControl.DogVerifyNoPageForms")]
public static List<IForm> DogVerifyNoPageForms =
StaticControl.DogVerifyNoPageForms;
[System.Obsolete("请使用 StaticControl.ConditionsPanelDic")]
public static Dictionary<string, ModuleConditionsPanelEx> ConditionsPanelDic =
StaticControl.ConditionsPanelDic;
/// <summary>
/// 表格拖拽类,key值为源表,多表格
/// </summary>
public static Dictionary<BandedGridView, List<BandedGridDragGrid>> BandedGridViewDragGridDic = new Dictionary<BandedGridView, List<BandedGridDragGrid>>();
public static Dictionary<BandedGridView, List<BandedGridDragGrid>>
BandedGridViewDragGridDic =
new Dictionary<BandedGridView, List<BandedGridDragGrid>>();
/// <summary>
/// 表格拖拽类,key值为目标表
/// </summary>
public static Dictionary<GridView, List<BandedGridDragGrid>> BandedTargetViewDragGridDic = new Dictionary<GridView, List<BandedGridDragGrid>>();
public static Dictionary<GridView, List<BandedGridDragGrid>>
BandedTargetViewDragGridDic =
new Dictionary<GridView, List<BandedGridDragGrid>>();
/// <summary>
/// 当前拖拽源表格
/// </summary>
public static BandedGridView SourceDragBandedGridView;
/// <summary>
/// 指纹识别模块
/// </summary>
public static FingerHelper fingerHelper;
/// <summary>
/// 进度条
/// </summary>
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -261,7 +261,7 @@ namespace Lskj.Control
{
if (Model != null && Model.DataCaches != null)
{
Model.DataCaches.Remove(this);
Model.DataCaches.RemoveCache(this);
}
}
catch
+11 -1
View File
@@ -193,7 +193,7 @@ namespace Lskj.Control
{
if (Model != null && Model.DataCaches != null)
{
Model.DataCaches.Remove(this);
Model.DataCaches.RemoveCache(this);
}
}
catch
@@ -358,6 +358,11 @@ namespace Lskj.Control
tcButtom.OnDetailRightCallback += OnGridViewRightCallBack;
}
if (this.SysModel.RefreshTheInterface)
{
}
this.tcButtom.Model = this.Model;
this.tcButtom.DrgaParentPrimaryKey = this.SysModel.ParmaryKey;
this.tcButtom.IsDragDetail = this.IsDragDetail;
@@ -387,6 +392,11 @@ namespace Lskj.Control
tcButtom.OnDetailRightCallback += OnGridViewRightCallBack;
}
if (this.SysModel.RefreshTheInterface)
{
}
this.tcButtom.Model = this.Model;
this.tcButtom.DrgaParentPrimaryKey = this.SysModel.ParmaryKey;
this.tcButtom.IsDragDetail = this.IsDragDetail;
+8 -8
View File
@@ -343,7 +343,7 @@
this.btnFixSearch.Name = "btnFixSearch";
this.btnFixSearch.Size = new System.Drawing.Size(63, 24);
this.btnFixSearch.TabIndex = 33;
this.btnFixSearch.Text = "查询(&Q)";
this.btnFixSearch.Text = "查询(Q)";
//
// txtFixKey
//
@@ -439,7 +439,7 @@
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(72, 26);
this.btnSave.TabIndex = 37;
this.btnSave.Text = "保存(&S)";
this.btnSave.Text = "保存(S)";
this.btnSave.Click += new System.EventHandler(this.OnSaveClick);
//
// btnUpdate
@@ -451,7 +451,7 @@
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(72, 26);
this.btnUpdate.TabIndex = 38;
this.btnUpdate.Text = "修改(&U)";
this.btnUpdate.Text = "修改(U)";
this.btnUpdate.Visible = false;
this.btnUpdate.Click += new System.EventHandler(this.OnUpdateClick);
//
@@ -464,7 +464,7 @@
this.btnPrint.Name = "btnPrint";
this.btnPrint.Size = new System.Drawing.Size(72, 26);
this.btnPrint.TabIndex = 37;
this.btnPrint.Text = "打印(&P)";
this.btnPrint.Text = "打印(P)";
this.btnPrint.Visible = false;
this.btnPrint.Click += new System.EventHandler(this.OnPrintClick);
//
@@ -477,7 +477,7 @@
this.btnExport.Name = "btnExport";
this.btnExport.Size = new System.Drawing.Size(72, 26);
this.btnExport.TabIndex = 37;
this.btnExport.Text = "导出(&E)";
this.btnExport.Text = "导出(E)";
this.btnExport.Visible = false;
this.btnExport.Click += new System.EventHandler(this.OnExportClick);
//
@@ -490,7 +490,7 @@
this.btnImport.Name = "btnImport";
this.btnImport.Size = new System.Drawing.Size(72, 26);
this.btnImport.TabIndex = 37;
this.btnImport.Text = "导入(&I)";
this.btnImport.Text = "导入(I)";
this.btnImport.Visible = false;
this.btnImport.Click += new System.EventHandler(this.OnImportClick);
//
@@ -503,7 +503,7 @@
this.btnDel.Name = "btnDel";
this.btnDel.Size = new System.Drawing.Size(72, 26);
this.btnDel.TabIndex = 36;
this.btnDel.Text = "删除(&D)";
this.btnDel.Text = "删除(D)";
this.btnDel.Click += new System.EventHandler(this.OnDelClick);
//
// btnAdd
@@ -515,7 +515,7 @@
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(72, 26);
this.btnAdd.TabIndex = 35;
this.btnAdd.Text = "增加(&A)";
this.btnAdd.Text = "增加(A)";
this.btnAdd.Click += new System.EventHandler(this.OnAddClick);
//
// ModuleGridEx
+207 -32
View File
@@ -53,6 +53,9 @@ namespace Lskj.Control
/// </summary>
public partial class ModuleGridEx : UserControl
{
private readonly AltButtonShortcutManager mAltButtonShortcuts =
new AltButtonShortcutManager();
#region private property
/// <summary>
@@ -162,6 +165,9 @@ namespace Lskj.Control
/// 按钮形式展示的右键
/// </summary>
private List<SimpleButton> RightButtons = new List<SimpleButton>();
// Fonts assigned to dynamic controls are not reliably reclaimed by the
// DevExpress/WinForms control tree, so keep ownership explicit.
private readonly List<Font> _ownedFonts = new List<Font>();
/// <summary>
/// 附加右键菜单集合
/// </summary>
@@ -429,6 +435,9 @@ namespace Lskj.Control
/// </summary>
public MyControl SearchObj { get; private set; }
private bool mModuleResourcesReleased;
// GridControlObj 可能由其他控件传入(例如左右明细表)。只有本控件
// 自己创建的表格才属于本控件,外部表格的生命周期仍由其父容器负责。
private bool _ownsGridControl = true;
/// <summary>
/// 左查询条件
/// </summary>
@@ -440,7 +449,52 @@ namespace Lskj.Control
public GridControlEx GridControlObj
{
get { return this.gcMain; }
set { this.gcMain = value; }
set { AssignGridControl(value, false); }
}
private void AssignGridControl(GridControlEx value, bool ownsGridControl)
{
GridControlEx previous = this.gcMain;
bool previousOwned = _ownsGridControl;
if (ReferenceEquals(previous, value))
{
_ownsGridControl = ownsGridControl;
return;
}
this.gcMain = value;
_ownsGridControl = ownsGridControl;
// 旧表格可能已经因为 Controls.Clear() 脱离父容器,此时 Parent 为空,
// 但它仍然属于本模块,不能仅靠解除父引用等待回收。只释放本控件
// 自己创建的实例,外部传入的表格仍由其真实拥有者负责生命周期。
if (previous != null && previousOwned)
{
try
{
if (previous.Parent != null)
{
previous.Parent.Controls.Remove(previous);
}
}
catch
{
// 父容器可能已进入 Dispose,继续释放旧表格本身。
}
try
{
if (!previous.IsDisposed)
{
previous.Dispose();
}
}
catch
{
// 控件处于部分销毁状态时不能阻止新表格完成替换。
}
}
}
/// <summary>
/// 底部多标签控件
@@ -541,6 +595,7 @@ namespace Lskj.Control
out this.MrpClickMenus);
}
this.SearchObj = searchObj;
StaticControl.RegisterModuleSearchControl(this, searchObj);
// 搜索区域复用当前模块配置,MyControl 内部会校验模块号,不一致时仍按原逻辑查询。
this.SearchObj.SystemModel = this.SysModel;
this.SearchObj.MrpClickMenus = this.MrpClickMenus;
@@ -1012,7 +1067,9 @@ namespace Lskj.Control
{
// 创建 多表头,树表格
this.panelControl1.Controls.Clear();
this.gcMain = new TreeBandedGridControlEx() { Expansion = SysModel.TreeTableExpand };
AssignGridControl(
new TreeBandedGridControlEx() { Expansion = SysModel.TreeTableExpand },
true);
this.gcMain.Model = this.Model;
this.gcMain.SysModel = this.SysModel;
(this.gcMain as TreeBandedGridControlEx).moduleModel = this.SysModel;
@@ -1039,11 +1096,15 @@ namespace Lskj.Control
if (this.gcMain.gridControl.Tag is PanelControl) panel = this.gcMain.gridControl.Tag as PanelControl;
this.panelControl1.Controls.Clear();
this.gcMain = new BandedGridControlEx();
AssignGridControl(new BandedGridControlEx(), true);
(this.gcMain as BandedGridControlEx).moduleModel = this.SysModel;
this.gcMain.Model = this.Model;
this.gcMain.SysModel = this.SysModel;
this.gcMain.Dock = DockStyle.Fill;
if (this.SysModel.GridObjIsCheck == 1)//主表加载复选框
{
GridDragGrid.GridAddCheckBox((this.gcMain as BandedGridControlEx).GridView);
}
this.panelControl1.Controls.Add(this.gcMain);
if (this.SysModel.LoadFilter) (this.gcMain as BandedGridControlEx).GridView.OptionsView.ShowAutoFilterRow = true;
(this.gcMain as BandedGridControlEx).gridControl.Tag = panel;
@@ -1052,7 +1113,9 @@ namespace Lskj.Control
{
// 创建树表格
this.panelControl1.Controls.Clear();
this.gcMain = new TreeGridControlEx() { Expansion = SysModel.TreeTableExpand };
AssignGridControl(
new TreeGridControlEx() { Expansion = SysModel.TreeTableExpand },
true);
this.gcMain.Model = this.Model;
this.gcMain.SysModel = this.SysModel;
this.gcMain.Dock = DockStyle.Fill;
@@ -1295,7 +1358,9 @@ namespace Lskj.Control
if (FontSize > 0)
{
//this.gcMain.GridView.Appearance.Row.Font = new Font("微软雅黑", FontSize);
this.gcMain.GridView.Appearance.Row.Font = new Font(this.gcMain.GridView.Appearance.Row.Font.FontFamily, FontSize);
Font rowFont = new Font(this.gcMain.GridView.Appearance.Row.Font.FontFamily, FontSize);
this.gcMain.GridView.Appearance.Row.Font = rowFont;
_ownedFonts.Add(rowFont);
}
if (SysModel.RowHeight > 0)
{
@@ -2346,7 +2411,7 @@ namespace Lskj.Control
/// </summary>
private void AddPanelViewRecord()
{
StaticControl.AddParentGrid = new KeyValuePair<string, GridControlEx>(Model.ModuleCode, gcMain);
StaticControl.SetAddParentGrid(new KeyValuePair<string, GridControlEx>(Model.ModuleCode, gcMain));
string mLeftFieldId = string.Empty;
string mLeftFieldName = string.Empty;
string mLeftTreeData = string.Empty;
@@ -3311,7 +3376,7 @@ namespace Lskj.Control
{
try
{
StaticControl.AddParentGrid = new KeyValuePair<string, GridControlEx>(Model.ModuleCode, gcMain);
StaticControl.SetAddParentGrid(new KeyValuePair<string, GridControlEx>(Model.ModuleCode, gcMain));
if (!string.IsNullOrWhiteSpace(this.SysModel.MenuAddName))
{
string modifyCond = this.SysModel.ModifyCond;
@@ -3339,8 +3404,11 @@ namespace Lskj.Control
string[] menuArgs = new string[] { "", "", url };
string[] args = defaultArgs.Concat(menuArgs).ToArray();
IForm form = FormHelper.LoadDllForm(ResourceDynamic.PubBrower, args);
form.SubForm.WindowState = FormWindowState.Maximized;
DialogResult result = form.SubForm.ShowDialog();
using (Form subForm = form.SubForm)
{
subForm.WindowState = FormWindowState.Maximized;
subForm.ShowDialog();
}
}
else
{
@@ -3349,7 +3417,9 @@ namespace Lskj.Control
string[] menuArgs = { "", canUpdate ? "0" : "1", selectRow[_parmaryKey] + "" };
string[] args = defaultArgs.Concat(menuArgs).ToArray();
IForm form = FormHelper.LoadDllForm(ResourceDynamic.PubAdd, args);
DialogResult result = form.SubForm.ShowDialog();
using (Form subForm = form.SubForm)
{
DialogResult result = subForm.ShowDialog();
//RefreshColumn();
if (result == DialogResult.OK)
{
@@ -3359,6 +3429,7 @@ namespace Lskj.Control
this.OnSaveGridCallBack(null, null);
}
}
}
}
@@ -3550,10 +3621,24 @@ namespace Lskj.Control
if (!string.IsNullOrWhiteSpace(this.SysModel.afterimportSql))
{
try
{
WaitForm.ShowForm();
string sql = this.SearchObj.ReplaceControlValue(this.SysModel.afterimportSql);
string newResult = SqlHelper.ExecuteScalar(sql) + "";
//if (!string.IsNullOrEmpty(newResult)) MessageUtil.Show(newResult);
}
catch (Exception e)
{
string Message = ErrorMessage.PromptErrorMessage(e);
MessageUtil.Show("基础档案导入后执行sql错误!" + Message);
}
finally
{
WaitForm.HideForm();
}
}
// 刷新数据
if (ImportReturnName.Count > 0)
@@ -3702,10 +3787,31 @@ namespace Lskj.Control
public ModuleGridEx()
{
InitializeComponent();
StaticControl.RegisterOwnedControl(this);
InitializeAltButtonShortcuts();
this.OperShortMode = true;
this.Disposed += OnModuleGridExDisposed;
}
private void InitializeAltButtonShortcuts()
{
mAltButtonShortcuts.Register(btnFixSearch, Keys.Q);
mAltButtonShortcuts.Register(btnSave, Keys.S);
mAltButtonShortcuts.Register(btnUpdate, Keys.U);
mAltButtonShortcuts.Register(btnPrint, Keys.P);
mAltButtonShortcuts.Register(btnExport, Keys.E);
mAltButtonShortcuts.Register(btnImport, Keys.I);
mAltButtonShortcuts.Register(btnDel, Keys.D);
mAltButtonShortcuts.Register(btnAdd, Keys.A);
}
protected override bool ProcessCmdKey(
ref System.Windows.Forms.Message msg, Keys keyData)
{
return mAltButtonShortcuts.ProcessKey(keyData) ||
base.ProcessCmdKey(ref msg, keyData);
}
/// <summary>
/// 清理公共事件和全局右键引用,避免模块关闭后仍保留当前表格。
/// </summary>
@@ -3734,53 +3840,86 @@ namespace Lskj.Control
searchObj.OnDataSourceBindCallBack -= OnMainSearchDataSourceBindCallBack;
if (ReferenceEquals(StaticControl.RightMenuMyControl, searchObj))
{
StaticControl.RightMenuMyControl = null;
StaticControl.SetRightMenuMyControl(null);
}
searchObj.Dispose();
}
GridControlEx grid = gcMain;
try
{
if (gcMain != null)
if (grid != null)
{
if (ReferenceEquals(StaticControl.RightMenuGridView, gcMain.GridView))
if (ReferenceEquals(StaticControl.RightMenuGridView, grid.GridView))
{
StaticControl.RightMenuGridView = null;
}
if (gcMain.GridView != null)
if (grid.GridView != null)
{
gcMain.GridView.FocusedRowObjectChanged -= OnGridViewFocusedRowObjectChanged;
gcMain.GridView.ShowingEditor -= OnGridViewShowingEditor;
gcMain.GridView.DoubleClick -= OnGridViewDoubleClick;
gcMain.GridView.MouseDown -= OnGridViewMouseDown;
gcMain.GridView.MouseDown -= OnGridMouseDown;
gcMain.GridView.MouseMove -= OnGridMouseMove;
gcMain.GridView.MouseUp -= OnGridMouseUp;
grid.GridView.FocusedRowObjectChanged -= OnGridViewFocusedRowObjectChanged;
grid.GridView.ShowingEditor -= OnGridViewShowingEditor;
grid.GridView.DoubleClick -= OnGridViewDoubleClick;
grid.GridView.MouseDown -= OnGridViewMouseDown;
grid.GridView.MouseDown -= OnGridMouseDown;
grid.GridView.MouseMove -= OnGridMouseMove;
grid.GridView.MouseUp -= OnGridMouseUp;
}
if (gcMain.CustomGroupBandEx != null)
if (grid.CustomGroupBandEx != null)
{
gcMain.CustomGroupBandEx.GridView.FocusedRowObjectChanged -= OnGridViewFocusedRowObjectChanged;
gcMain.CustomGroupBandEx.GridView.ShowingEditor -= OnGridViewShowingEditor;
grid.CustomGroupBandEx.GridView.FocusedRowObjectChanged -= OnGridViewFocusedRowObjectChanged;
grid.CustomGroupBandEx.GridView.ShowingEditor -= OnGridViewShowingEditor;
}
if (gcMain.ParentControl != null &&
ReferenceEquals(gcMain.ParentControl, searchObj))
if (grid.ParentControl != null &&
ReferenceEquals(grid.ParentControl, searchObj))
{
gcMain.ParentControl = null;
grid.ParentControl = null;
}
gcMain.Model = null;
gcMain.SysModel = null;
}
}
catch
{
// A partially disposed DevExpress view must not stop module cleanup.
}
finally
{
// 自有表格的生命周期由本模块负责。先从父容器移除,再显式释放,
// 防止调用方此前执行 Controls.Clear() 后留下孤立 GridControlEx。
bool ownsGrid = _ownsGridControl;
gcMain = null;
_ownsGridControl = false;
if (ownsGrid && grid != null)
{
try
{
if (grid.Parent != null)
{
grid.Parent.Controls.Remove(grid);
}
}
catch
{
// 父容器可能已进入 Dispose,继续释放表格本身。
}
try
{
if (!grid.IsDisposed)
{
grid.Dispose();
}
}
catch
{
// 部分销毁的 DevExpress 控件不能阻止模块其余资源清理。
}
}
}
try
{
if (Model != null && Model.DataCaches != null)
{
Model.DataCaches.Remove(this);
Model.DataCaches.RemoveCache(this);
}
}
catch
@@ -3803,8 +3942,9 @@ namespace Lskj.Control
m_dragRowShadow.Dispose();
m_dragRowShadow = null;
}
DisposeDynamicRightButtons();
DisposeOwnedFonts();
ButtonModeRightMenus.Clear();
RightButtons.Clear();
itemCommonList.Clear();
LineStatus.Clear();
_leftGridSearchObj = null;
@@ -4030,6 +4170,39 @@ namespace Lskj.Control
}
}
private void DisposeDynamicRightButtons()
{
foreach (SimpleButton button in RightButtons.ToList())
{
try
{
button.Click -= OnModuleClick;
button.Dispose();
}
catch
{
// Cleanup must continue for the remaining controls.
}
}
RightButtons.Clear();
}
private void DisposeOwnedFonts()
{
foreach (Font font in _ownedFonts.ToList())
{
try
{
font.Dispose();
}
catch
{
// A partially disposed font must not stop module cleanup.
}
}
_ownedFonts.Clear();
}
private void Txt_SweepCode_KeyDown(object sender, KeyEventArgs e)
{
try
@@ -5762,7 +5935,9 @@ namespace Lskj.Control
{
GridRightMenuModel menuModel = new GridRightMenuModel(item);
SimpleButton button = new SimpleButton();
button.Font = new Font("宋体", 9);
Font buttonFont = new Font("宋体", 9);
button.Font = buttonFont;
_ownedFonts.Add(buttonFont);
button.Text = menuModel.MenuName;
button.Height = 24;
//按钮最小大小
+10 -9
View File
@@ -34,14 +34,15 @@ namespace Lskj.Control
/// </summary>
private void InitializeComponent()
{
this.pm_print = new DevExpress.XtraBars.PopupMenu();
this.barManager1 = new DevExpress.XtraBars.BarManager();
this.components = new System.ComponentModel.Container();
this.pm_print = new DevExpress.XtraBars.PopupMenu(this.components);
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
this.barDockControlRight = new DevExpress.XtraBars.BarDockControl();
this.pm_common = new DevExpress.XtraBars.PopupMenu();
this.pm_oper = new DevExpress.XtraBars.PopupMenu();
this.pm_common = new DevExpress.XtraBars.PopupMenu(this.components);
this.pm_oper = new DevExpress.XtraBars.PopupMenu(this.components);
this.panel1 = new System.Windows.Forms.Panel();
this.scc_container = new DevExpress.XtraEditors.SplitContainerControl();
this.panel_Main = new System.Windows.Forms.Panel();
@@ -310,7 +311,7 @@ namespace Lskj.Control
this.btnAttach.Size = new System.Drawing.Size(80, 28);
this.btnAttach.TabIndex = 6;
this.btnAttach.TabStop = false;
this.btnAttach.Text = "附件管理(&F)";
this.btnAttach.Text = "附件管理(F)";
//
// btnUpdate
//
@@ -321,7 +322,7 @@ namespace Lskj.Control
this.btnUpdate.Size = new System.Drawing.Size(80, 28);
this.btnUpdate.TabIndex = 4;
this.btnUpdate.TabStop = false;
this.btnUpdate.Text = "修改保存(&E)";
this.btnUpdate.Text = "修改保存(E)";
//
// ddb_common
//
@@ -342,7 +343,7 @@ namespace Lskj.Control
this.btnApply.Name = "btnApply";
this.btnApply.Size = new System.Drawing.Size(80, 28);
this.btnApply.TabIndex = 5;
this.btnApply.Text = "提交审核(&R)";
this.btnApply.Text = "提交审核(R)";
//
// btnAdd
//
@@ -353,7 +354,7 @@ namespace Lskj.Control
this.btnAdd.Size = new System.Drawing.Size(80, 28);
this.btnAdd.TabIndex = 3;
this.btnAdd.TabStop = false;
this.btnAdd.Text = "添加保存(&A)";
this.btnAdd.Text = "添加保存(A)";
//
// btnClose
//
@@ -364,7 +365,7 @@ namespace Lskj.Control
this.btnClose.Size = new System.Drawing.Size(80, 28);
this.btnClose.TabIndex = 10;
this.btnClose.TabStop = false;
this.btnClose.Text = "退出(&C)";
this.btnClose.Text = "退出(C)";
//
// simpleButton1
//
+28 -3
View File
@@ -47,6 +47,9 @@ namespace Lskj.Control
/// </summary>
public partial class ModulePanelEx : UserControl
{
private readonly AltButtonShortcutManager mAltButtonShortcuts =
new AltButtonShortcutManager();
public LabelTextEdit ScanEdit { get { return this._scanEdit; } }
#region private property
@@ -228,6 +231,7 @@ namespace Lskj.Control
{
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.Selectable | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
InitializeComponent();
InitializeAltButtonShortcuts();
this.scc_container.PanelVisibility = SplitPanelVisibility.Panel1;
this.simpleButton1.Click += simpleButton1_Click;
this.btnClear.Click += OnBtnClearClick;
@@ -241,6 +245,22 @@ namespace Lskj.Control
this.BtnMesClose.Click += OnBtnMesCloseClick;
}
private void InitializeAltButtonShortcuts()
{
mAltButtonShortcuts.Register(btnAttach, Keys.F);
mAltButtonShortcuts.Register(btnUpdate, Keys.E);
mAltButtonShortcuts.Register(btnApply, Keys.R);
mAltButtonShortcuts.Register(btnAdd, Keys.A);
mAltButtonShortcuts.Register(btnClose, Keys.C);
}
protected override bool ProcessCmdKey(
ref System.Windows.Forms.Message msg, Keys keyData)
{
return mAltButtonShortcuts.ProcessKey(keyData) ||
base.ProcessCmdKey(ref msg, keyData);
}
#region private method
/// <summary>
/// <para>说明:控制滚动条是否存在横向的</para>
@@ -360,9 +380,9 @@ namespace Lskj.Control
this.btnUpdate.Location = this.btnApply.Location;
}
// 设置文本
btnAdd.Text = !string.IsNullOrWhiteSpace(this.SysModel.AddCaption) ? this.SysModel.AddCaption : "添加保存(&A)";
btnUpdate.Text = !string.IsNullOrWhiteSpace(this.SysModel.ModifyCaption) ? this.SysModel.ModifyCaption : "修改保存(&E)";
btnApply.Text = !string.IsNullOrWhiteSpace(this.SysModel.ApplyCaption) ? this.SysModel.ApplyCaption : "提交审核(&R)";
btnAdd.Text = !string.IsNullOrWhiteSpace(this.SysModel.AddCaption) ? this.SysModel.AddCaption : "添加保存(A)";
btnUpdate.Text = !string.IsNullOrWhiteSpace(this.SysModel.ModifyCaption) ? this.SysModel.ModifyCaption : "修改保存(E)";
btnApply.Text = !string.IsNullOrWhiteSpace(this.SysModel.ApplyCaption) ? this.SysModel.ApplyCaption : "提交审核(R)";
//隐藏帮助文档按钮
if (SystemInfo.Instance.HideHelpDocument) this.simpleButton1.Visible = false;
@@ -766,6 +786,7 @@ namespace Lskj.Control
{
try
{
//this.pl_main.Visible = false;
if (sysModel != null && dyncModel != null)
{
this.SysModel = sysModel;
@@ -1423,6 +1444,10 @@ namespace Lskj.Control
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
finally
{
//this.pl_main.Visible = true;
}
}
/// <summary>
@@ -13,6 +13,10 @@
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing)
{
DisposeDragResources();
}
if (disposing && (components != null))
{
components.Dispose();
@@ -174,6 +174,10 @@ namespace Lskj.Control.MultiModelLookUp
public bool ReturnCollection;
#endregion
private GridDragGrid _dragGrid;
private GridDragGrid _backDragGrid;
private bool _dragResourcesDisposed;
public FrmModelLookUp2(string ModuleCodel)
{
InitializeComponent();
@@ -184,16 +188,20 @@ namespace Lskj.Control.MultiModelLookUp
this.gcMain.GridControl.ContextMenuStrip = contextMenuStrip1;
this.gcMain.GridView.DoubleClick += new EventHandler(OnRowCellClick);
this.gcDetail.GridView.DoubleClick += new EventHandler(OnDoubleClick);
GridDragGrid dragGrid = new GridDragGrid(this.gcMain.GridView, this.gcDetail.GridView);
GridDragGrid backdragGrid = new GridDragGrid(this.gcDetail.GridView, this.gcMain.GridView);
_dragGrid = new GridDragGrid(this.gcMain.GridView, this.gcDetail.GridView);
_backDragGrid = new GridDragGrid(this.gcDetail.GridView, this.gcMain.GridView);
//设置关联模块
bool result = SetAssociatedModules();
this.pl_top.Height = 0;
this.gcDetail.GridView.OptionsSelection.EnableAppearanceFocusedCell = false;
this.Resize += new System.EventHandler(maximization);
this.splitMain_Right.SplitterMoved += new EventHandler(PositionChange);
this.gcDetail.GridView.OptionsView.ColumnAutoWidth = true;
this.gcMain.GridView.OptionsView.ColumnAutoWidth = true;
//this.gcDetail.GridView.OptionsView.ColumnAutoWidth = true;
//this.gcMain.GridView.OptionsView.ColumnAutoWidth = true;
this.gcDetail.GridView.OptionsView.ColumnAutoWidth = false;
this.gcDetail.GridView.HorzScrollVisibility = DevExpress.XtraGrid.Views.Base.ScrollVisibility.Auto;
this.gcMain.GridView.OptionsView.ColumnAutoWidth = false;
this.gcMain.GridView.HorzScrollVisibility =DevExpress.XtraGrid.Views.Base.ScrollVisibility.Auto;
}
//关联模块号;是否为单选模式
@@ -206,8 +214,8 @@ namespace Lskj.Control.MultiModelLookUp
this.gcMain.GridView.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.MouseDown;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing);
this.gcMain.GridControl.ContextMenuStrip = contextMenuStrip1;
GridDragGrid dragGrid = new GridDragGrid(this.gcMain.GridView, this.gcDetail.GridView);
GridDragGrid backdragGrid = new GridDragGrid(this.gcDetail.GridView, this.gcMain.GridView);
_dragGrid = new GridDragGrid(this.gcMain.GridView, this.gcDetail.GridView);
_backDragGrid = new GridDragGrid(this.gcDetail.GridView, this.gcMain.GridView);
//设置关联模块
bool result = SetAssociatedModules();
@@ -243,8 +251,12 @@ namespace Lskj.Control.MultiModelLookUp
this.SourceSQL = this.SysModel.MenuSql;
this.gcDetail.GridView.OptionsSelection.EnableAppearanceFocusedCell = false;
this.gcDetail.GridView.OptionsView.ColumnAutoWidth = true;
this.gcMain.GridView.OptionsView.ColumnAutoWidth = true;
//this.gcDetail.GridView.OptionsView.ColumnAutoWidth = true;
//this.gcMain.GridView.OptionsView.ColumnAutoWidth = true;
this.gcDetail.GridView.OptionsView.ColumnAutoWidth = false;
this.gcDetail.GridView.HorzScrollVisibility =DevExpress.XtraGrid.Views.Base.ScrollVisibility.Auto;
this.gcMain.GridView.OptionsView.ColumnAutoWidth = false;
this.gcMain.GridView.HorzScrollVisibility =DevExpress.XtraGrid.Views.Base.ScrollVisibility.Auto;
}
@@ -1100,13 +1112,50 @@ namespace Lskj.Control.MultiModelLookUp
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
private void DisposeDragResources()
{
if (_dragResourcesDisposed)
{
return;
}
_dragResourcesDisposed = true;
GridDragGrid dragGrid = _dragGrid;
_dragGrid = null;
if (dragGrid != null)
{
try
{
dragGrid.Dispose();
}
catch
{
// Continue releasing the reverse registration.
}
}
GridDragGrid backDragGrid = _backDragGrid;
_backDragGrid = null;
if (backDragGrid != null)
{
try
{
backDragGrid.Dispose();
}
catch
{
// Drag cleanup must not block form disposal.
}
}
}
private void OnFrmModelLookUp_Disposed(object sender, EventArgs e)
{
DisposeDragResources();
if (this.DataSource != null)
{
this.DataSource = null;
}
GC.Collect();
}
#endregion
@@ -121,7 +121,7 @@ namespace Lskj.Control
{
if (Model != null && Model.DataCaches != null)
{
Model.DataCaches.Remove(this);
Model.DataCaches.RemoveCache(this);
}
}
catch
+146 -13
View File
@@ -142,6 +142,13 @@ namespace Lskj.Control
/// </summary>
public event EventHandler BillDetailRightGridCallBack;
/// <summary>
/// 新版左右结构下,左侧或者右侧的表格数据改变后,刷新主表数据(主表刷新后会刷新当前明细或者全部明细)
/// </summary>
/// <param name="sender">The sender.</param>
public event EventHandler OnDataChangeExecution;
/// <summary>
/// 明细页签与主模块对应关系
/// </summary>
@@ -160,6 +167,19 @@ namespace Lskj.Control
/// </summary>
private readonly HashSet<GridControlEx> _rightTabRefreshRegisteredGrids = new HashSet<GridControlEx>();
/// <summary>
/// 右侧联动事件委托。必须保存委托实例,Dispose 时才能从 GridView 正确解绑。
/// 匿名 lambda 如果不保存实例,会把 TabControlEx 通过事件闭包继续挂在已关闭的表格上。
/// </summary>
private readonly Dictionary<GridControlEx, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler> _rightTabRefreshHandlers =
new Dictionary<GridControlEx, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler>();
/// <summary>
/// 保存注册事件时的 GridView 实例。GridControlEx 在 Dispose 过程中可能
/// 清空或替换 GridView 属性;解绑时必须使用当初注册事件的同一个实例,
/// 不能再次通过 GridControlEx.GridView 取值。
/// </summary>
private readonly Dictionary<GridControlEx, GridView> _rightTabRefreshHandlerViews =
new Dictionary<GridControlEx, GridView>();
/// <summary>
/// 左右结构中的右侧页签集合。
/// 只有这些页签会根据数据行数禁用 ModuleGridEx 底部操作栏。
/// </summary>
@@ -168,9 +188,13 @@ namespace Lskj.Control
/// 页签名(判断是否有重复的左右结构)
/// </summary>
public string DetaiName = string.Empty;
public TabControlEx()
{
InitializeComponent();
StaticControl.RegisterOwnedControl(this);
this.Disposed += OnTabControlExDisposed;
}
#region
@@ -242,9 +266,10 @@ namespace Lskj.Control
/// <summary>
/// 设置当前页签内 ModuleGridEx 底部操作栏是否可交互。
/// 只处理左右结构右侧页签里直接承载的 ModuleGridEx,不影响普通页签和左侧表。
/// 左右结构中,右侧明细是否允许操作由左侧主表是否有数据决定,
/// 不能使用右侧明细查询结果判断,否则右侧为空时无法新增第一行。
/// </summary>
private void SetModuleGridBottomPanelEnabled(XtraTabPage tabPage, bool enabled)
private void SetModuleGridBottomPanelEnabled(XtraTabPage tabPage, GridControlEx leftGrid)
{
if (tabPage == null) return;
if (!_rightSideTabPages.Contains(tabPage)) return;
@@ -252,7 +277,7 @@ namespace Lskj.Control
ModuleGridEx moduleGrid = tabPage.Controls.OfType<ModuleGridEx>().FirstOrDefault();
if (moduleGrid != null && moduleGrid.ObjPanel != null)
{
moduleGrid.ObjPanel.Enabled = enabled;
moduleGrid.ObjPanel.Enabled = leftGrid != null && leftGrid.DataRowCount() > 0;
}
}
#endregion
@@ -273,7 +298,7 @@ namespace Lskj.Control
if (model == null)
{
BindTableToPage(tabPage, new DataTable());
SetModuleGridBottomPanelEnabled(tabPage, false);
SetModuleGridBottomPanelEnabled(tabPage, leftGrid);
return;
}
@@ -298,12 +323,12 @@ namespace Lskj.Control
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue);
DataTable dt = MainImpl.GetDataTableResult(sqlValue);
BindTableToPage(tabPage, dt);
SetModuleGridBottomPanelEnabled(tabPage, dt != null && dt.Rows.Count > 0);
SetModuleGridBottomPanelEnabled(tabPage, leftGrid);
}
else
{
BindTableToPage(tabPage, new DataTable());
SetModuleGridBottomPanelEnabled(tabPage, false);
SetModuleGridBottomPanelEnabled(tabPage, leftGrid);
}
return;
}
@@ -322,7 +347,7 @@ namespace Lskj.Control
if (!visible)
{
BindTableToPage(tabPage, new DataTable());
SetModuleGridBottomPanelEnabled(tabPage, false);
SetModuleGridBottomPanelEnabled(tabPage, leftGrid);
return;
}
}
@@ -405,7 +430,7 @@ namespace Lskj.Control
DataTable table = MainImpl.GetDataTableResult(finalSql);
BindTableToPage(tabPage, table, finalSql);
SetModuleGridBottomPanelEnabled(tabPage, table != null && table.Rows.Count > 0);
SetModuleGridBottomPanelEnabled(tabPage, leftGrid);
tabPage.Text = $"{model.DetailName}({table.Rows.Count}条)";
tabPage.Appearance.Header.ForeColor = table.Rows.Count > 0 ? Color.Red : Color.FromArgb(0, 0, 0);
// 首次加载自动查询
@@ -435,9 +460,14 @@ namespace Lskj.Control
if (leftGrid == null || rightTab == null) return;
_rightTabsByLeftGrid[leftGrid] = rightTab;
if (!_rightTabRefreshRegisteredGrids.Contains(leftGrid))
GridView leftView = leftGrid.GridView;
if (!_rightTabRefreshRegisteredGrids.Contains(leftGrid) && leftView != null)
{
leftGrid.GridView.FocusedRowObjectChanged += (s, e) => RefreshRightTabAfterLeftBind(leftGrid);
DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler handler =
(s, e) => RefreshRightTabAfterLeftBind(leftGrid);
leftView.FocusedRowObjectChanged += handler;
_rightTabRefreshHandlers[leftGrid] = handler;
_rightTabRefreshHandlerViews[leftGrid] = leftView;
_rightTabRefreshRegisteredGrids.Add(leftGrid);
}
RefreshRightTab(rightTab, leftGrid);// 首次加载
@@ -480,18 +510,30 @@ namespace Lskj.Control
{
if (ParentGridEx != null && ParentGridEx.CustomGroupBandEx != null)
{
ParentGridEx.CustomGroupBandEx.BandedView.LeftCoordChanged -= OnBandedViewLeftCoordChanged;
ParentGridEx.CustomGroupBandEx.BandedView.ColumnWidthChanged -= OnBandedViewColumnWidthChanged;
ParentGridEx.OnBuildGroupedColumnCallBack -= OnBandedViewColumnWidthChanged;
ParentGridEx.CustomGroupBandEx.BandedView.LeftCoordChanged += OnBandedViewLeftCoordChanged;
ParentGridEx.CustomGroupBandEx.BandedView.ColumnWidthChanged += OnBandedViewColumnWidthChanged;
ParentGridEx.OnBuildGroupedColumnCallBack += OnBandedViewColumnWidthChanged;
}
if (ParentGridEx != null && ParentGridEx.CustomGroupTreeBandEx != null)
{
ParentGridEx.CustomGroupTreeBandEx.TreeListObj.LeftCoordChanged -= OnBandedViewLeftCoordChanged;
ParentGridEx.CustomGroupTreeBandEx.TreeListObj.ColumnWidthChanged -= OnBandedViewColumnWidthChanged;
ParentGridEx.OnBuildGroupedColumnCallBack -= OnBandedViewColumnWidthChanged;
ParentGridEx.CustomGroupTreeBandEx.TreeListObj.LeftCoordChanged += OnBandedViewLeftCoordChanged; ;
ParentGridEx.CustomGroupTreeBandEx.TreeListObj.ColumnWidthChanged += OnBandedViewColumnWidthChanged;
ParentGridEx.OnBuildGroupedColumnCallBack += OnBandedViewColumnWidthChanged;
}
this._gridDetail = gridDetail;
if (!isAddPages) this.xtc_container.TabPages.Clear();
if (!isAddPages)
{
// 重建明细页签前先解除旧左右联动关系。仅清空 TabPages 不会移除
// GridView 上的事件,因此旧页签仍可能通过事件闭包存活。
DetachRightTabRefreshHandlers();
this.xtc_container.TabPages.Clear();
}
// 1️⃣ 预分组:Rightdockid > 0 的明细
var rightGroups = gridDetail
@@ -549,7 +591,12 @@ namespace Lskj.Control
rightTab.ShowTabHeader = DevExpress.Utils.DefaultBoolean.False;
GridControlEx leftControl = new GridControlEx();
// Only reuse an existing grid from the left detail. The
// previous unconditional `new GridControlEx()` created an
// orphan control whenever leftCtrl was a non-grid control;
// it was never added to the visual tree or disposed, and
// its GridView event handlers kept the whole wrapper alive.
GridControlEx leftControl = null;
if (leftCtrl is GridControlEx left1)
{
leftControl = left1;
@@ -646,6 +693,7 @@ namespace Lskj.Control
this._gridDetail = gridDetail;
if (!isAddPages)
{
DetachRightTabRefreshHandlers();
this.xtc_container.TabPages.Clear();
}
string DetaiName = string.Empty;
@@ -1769,7 +1817,7 @@ namespace Lskj.Control
Task<DataTable> sourceColumnByDatabaseTask = cachesDic.AddTask(gridEx, "CustomColumnByDatabase", new Task<DataTable>(() =>
{
string customColumKey = model.GridCustomColumnKey;
return gridEx.GridView.GetCustomColumnByDatabase(customColumKey);
return GridExtend.GetCustomColumnByDatabase(customColumKey);
}));
Task<DataTable> baseGridRightMenusTask = cachesDic.AddTask(gridEx, "BaseGridRightMenus", new Task<DataTable>(() =>
{
@@ -1865,6 +1913,7 @@ namespace Lskj.Control
public void InitTabPages(List<GridDetailModel> gridDetail, string parentValue)
{
this._gridDetail = gridDetail;
DetachRightTabRefreshHandlers();
this.xtc_container.TabPages.Clear();
bool ProcessExists = (Lskj.Data.Caches.CacheSYSConfig.Instance().JudgeProcessExists() && SystemInfo.Instance.isExecload);
@@ -2685,8 +2734,92 @@ namespace Lskj.Control
/// <param name="e"></param>
private void OnTabControlExDisposed(object sender, EventArgs e)
{
ReleaseRuntimeReferences();
}
/// <summary>
/// 在模块关闭但控件尚未进入 WinForms Dispose 流程时,主动解除
/// TabControlEx 持有的运行时引用。这里只解除事件和清空本控件的
/// 映射,不销毁共享的 GridControl/GridView。
/// </summary>
internal void ReleaseRuntimeReferences()
{
DetachRightTabRefreshHandlers();
DetachParentGridHandlers();
PageControlsDic?.Clear();
DetailTabPagesDic?.Clear();
_gridDetail?.Clear();
_gridIntoDetail?.Clear();
ParentGridEx = null;
MrpParentGridEx = null;
MrpDetailGridEx = null;
ParentControlEx = null;
ModuleGridObj = null;
ReplaceControlEx = null;
}
/// <summary>
/// 解除左右联动刷新事件。事件委托由字典保存,保证能够与注册时使用同一个实例。
/// </summary>
private void DetachRightTabRefreshHandlers()
{
foreach (KeyValuePair<GridControlEx, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler> item in
_rightTabRefreshHandlers.ToArray())
{
try
{
GridView registeredView;
if (_rightTabRefreshHandlerViews.TryGetValue(item.Key, out registeredView) &&
registeredView != null && item.Value != null)
{
registeredView.FocusedRowObjectChanged -= item.Value;
}
}
catch
{
// 表格可能已先于 TabControlEx 进入 Dispose,解绑失败不应阻断剩余清理。
}
}
_rightTabRefreshHandlers.Clear();
_rightTabRefreshHandlerViews.Clear();
_rightTabsByLeftGrid.Clear();
_rightTabRefreshRegisteredGrids.Clear();
_rightSideTabPages.Clear();
}
/// <summary>
/// 解除父表聚合视图的滚动/列宽事件,避免父表事件链反向持有当前 TabControlEx。
/// </summary>
private void DetachParentGridHandlers()
{
GridControlEx parentGrid = ParentGridEx;
try
{
if (parentGrid != null && parentGrid.CustomGroupBandEx != null)
{
if (parentGrid.CustomGroupBandEx.BandedView != null)
{
parentGrid.CustomGroupBandEx.BandedView.LeftCoordChanged -= OnBandedViewLeftCoordChanged;
parentGrid.CustomGroupBandEx.BandedView.ColumnWidthChanged -= OnBandedViewColumnWidthChanged;
}
parentGrid.OnBuildGroupedColumnCallBack -= OnBandedViewColumnWidthChanged;
}
if (parentGrid != null && parentGrid.CustomGroupTreeBandEx != null)
{
if (parentGrid.CustomGroupTreeBandEx.TreeListObj != null)
{
parentGrid.CustomGroupTreeBandEx.TreeListObj.LeftCoordChanged -= OnBandedViewLeftCoordChanged;
parentGrid.CustomGroupTreeBandEx.TreeListObj.ColumnWidthChanged -= OnBandedViewColumnWidthChanged;
}
parentGrid.OnBuildGroupedColumnCallBack -= OnBandedViewColumnWidthChanged;
}
}
catch
{
// 父表可能已经释放,事件清理应保持 best-effort。
}
}
/// <summary>
/// 水平滚动条改变时
+3 -1
View File
@@ -402,6 +402,7 @@ namespace Lskj.Core
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
public bool CreateConnection(string Connection = "", ConnectionType connectionType = ConnectionType.SqlServer)
{
InitialParamCache.Clear();
bool isConnect = false;
try
{
@@ -431,7 +432,7 @@ namespace Lskj.Core
}
if (connectionType == ConnectionType.SqlServer)
{
connStr = EnableSqlServerIdleConnectionResilience(connStr);
//connStr = EnableSqlServerIdleConnectionResilience(connStr);
}
SqlHelper.dbFactory = DbProviderFactories.GetFactory(providerName);
if (SqlHelper._connection != null)
@@ -460,6 +461,7 @@ namespace Lskj.Core
}
catch (Exception ex)
{
LogHelper.Instance.WriteLog(ex.Message);
Console.WriteLine(ex.Message);
}
return isConnect;
+4 -3
View File
@@ -28,13 +28,14 @@
/// </summary>
private void InitializeComponent()
{
this.pm_print = new DevExpress.XtraBars.PopupMenu();
this.barManager1 = new DevExpress.XtraBars.BarManager();
this.components = new System.ComponentModel.Container();
this.pm_print = new DevExpress.XtraBars.PopupMenu(this.components);
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
this.barDockControlRight = new DevExpress.XtraBars.BarDockControl();
this.pm_oper = new DevExpress.XtraBars.PopupMenu();
this.pm_oper = new DevExpress.XtraBars.PopupMenu(this.components);
this.panelControl1 = new DevExpress.XtraEditors.PanelControl();
this.gcMain = new Lskj.Control.GridControlEx();
this.btnDownLoad = new DevExpress.XtraEditors.SimpleButton();
@@ -260,6 +260,16 @@ namespace Lskj.Main.Control
{
try
{
// Bind the real WinForms page surface before any menu or
// startup callback can open a module. The WPF host never
// constructs this panel; the explicit shell check keeps its
// ModulePageHost untouched if a shared AppDomain is used.
if (Manager.ExternalMainShell == null)
{
ERPInfo.Instance.ModulePageHost = null;
ERPInfo.Instance.PageControl = this.tabMain;
Manager.TabMain = this.tabMain;
}
WaitForm.ShowForm();
ContextMenuStrip headMenuStrip = new ContextMenuStrip();
@@ -366,7 +376,6 @@ namespace Lskj.Main.Control
new Thread(MainImpl.DnsHostEntry).Start();
this.mark_timer.Start();
ERPInfo.Instance.PageControl = this.tabMain;
ERPInfo.Instance.ModuleForms = Manager.ModuleForms;
if ((!this._allMenus.Columns.Contains("menuposition") || (!SystemInfo.Instance.IsOpenWork && !SystemInfo.Instance.ShowGallerysFromMenu)) && (!SystemInfo.Instance.HideGallerys || SystemInfo.Instance.DesktopFormatShowGallerys))
{
@@ -3236,8 +3245,11 @@ namespace Lskj.Main.Control
if (Manager.ModuleForms.ContainsKey(guid))
{
DllModule m = Manager.ModuleForms[guid];
Manager.ModuleCloseSnapshot closeSnapshot =
Manager.PrepareModuleClose(m, item);
tabMain.TabPages.Remove(item);
Manager.ModuleForms.Remove(m.Tag + "");
Manager.ModuleForms.Remove(guid);
Manager.CompleteModuleClose(closeSnapshot);
}
}
}
@@ -3812,10 +3824,12 @@ namespace Lskj.Main.Control
string guid = tabPage.Tag + "";
if (!string.IsNullOrWhiteSpace(guid))
{
DllModule m = Manager.ModuleForms[guid];
if (Manager.ModuleForms.ContainsKey(guid))
DllModule m;
if (Manager.ModuleForms.TryGetValue(guid, out m) && m != null)
{
Form form = m.ModuleForm as Form;
Manager.ModuleCloseSnapshot closeSnapshot =
Manager.PrepareModuleClose(m, tabPage);
if (form != null)
{
form.Close();
@@ -3841,7 +3855,8 @@ namespace Lskj.Main.Control
{
if (this.PreviousTab != null) this.tabMain.SelectedTabPage = this.PreviousTab;
tabMain.TabPages.Remove(tabPage);
Manager.ModuleForms.Remove(m.Tag + "");
Manager.ModuleForms.Remove(guid);
Manager.CompleteModuleClose(closeSnapshot);
LogUtil.WriteDebug(m.Code, "关闭模块", m.Name, m.Name, m.Id);
}
@@ -3850,12 +3865,12 @@ namespace Lskj.Main.Control
XtraTabPage beforePage = m.BeforePage;
if (beforePage != null)
{
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage == beforePage)
{
ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
ERPInfo.Instance.CurrentModulePage = beforePage;
if (isclose) tabPage.Dispose();
}
}
@@ -3947,10 +3962,12 @@ namespace Lskj.Main.Control
string guid = page.Tag + "";
if (!string.IsNullOrWhiteSpace(guid))
{
DllModule m = Manager.ModuleForms[guid];
if (Manager.ModuleForms.ContainsKey(guid))
DllModule m;
if (Manager.ModuleForms.TryGetValue(guid, out m) && m != null)
{
Form form = m.ModuleForm as Form;
Manager.ModuleCloseSnapshot closeSnapshot =
Manager.PrepareModuleClose(m, page);
if (form != null) form.Close();
bool isclose = true;
@@ -3966,7 +3983,8 @@ namespace Lskj.Main.Control
{
if (this.PreviousTab != null) this.tabMain.SelectedTabPage = this.PreviousTab;
tabMain.TabPages.Remove(page);
Manager.ModuleForms.Remove(m.Tag + "");
Manager.ModuleForms.Remove(guid);
Manager.CompleteModuleClose(closeSnapshot);
LogUtil.WriteDebug(m.Code, "关闭模块", m.Name, m.Name, m.Id);
}
}
@@ -4563,6 +4581,29 @@ namespace Lskj.Main.Control
return false;
}
//切换账套后,直接进入程序界面,去设置对应的子菜单,暂不开放
//if (!SystemInfo.Instance.IsChangeZTReturnMainForm)
//{
// DataTable MainTable = MainImpl.EnableSubSystem();
// ERPInfo.Instance.SubMenuCount = MainTable.Rows.Count;
// DataRow[] subrows = MainTable.Select(string.Format("SubSysId={0}", ERPInfo.Instance.SubSysId));
// if (subrows != null && subrows.Length > 0)
// {
// ERPInfo.Instance.SubSysId = subrows[0]["SubSysId"] + "";
// ERPInfo.Instance.SubSysName = subrows[0]["SubSysName"] + "";
// }
// else
// {
// if (MainTable.Rows.Count >0)
// {
// ERPInfo.Instance.SubSysId = MainTable.Rows[0]["SubSysId"] + "";
// ERPInfo.Instance.SubSysName = MainTable.Rows[0]["SubSysName"] + "";
// }
// }
//}
Manager.ReStartMain(!SystemInfo.Instance.IsChangeZTReturnMainForm);
return true;
}
@@ -4922,6 +4963,7 @@ namespace Lskj.Main.Control
try
{
XtraTabPage tabPage = this.tabMain.SelectedTabPage;
ERPInfo.Instance.NotifyModulePageSelected(tabPage);
string guid = tabPage.Tag + "";
if (!string.IsNullOrWhiteSpace(guid) && Manager.ModuleForms.ContainsKey(guid))
{
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,112 @@
using System;
using System.ComponentModel;
using System.Windows.Forms;
using DevExpress.XtraTab;
using Lskj.Business;
using Lskj.Model;
namespace Lskj.Main.Control
{
/// <summary>新版 WPF 主界面的 WinForms 过渡版。</summary>
public partial class MainPanelControlEx2 : UserControl
{
private ToolStripMenuItem _selectedTopMenu;
private bool _styleUpdatePending;
private bool _shortcutRedrawSuppressed;
private bool _shortcutChannelDisabled;
private bool _enforcingShortcutHidden;
private string _styledSubSysId;
private string _styledSubSysName;
public MainPanelControlEx2()
{
InitializeComponent();
// 运行时必须等旧控件 OnLoad 完成后再改菜单布局;否则旧逻辑会按
// 构造阶段的默认宽度计算“更多”,导致一级目录全部被收进去。
// 设计器不会触发业务 OnLoad,因此仅在设计时直接套用预览样式。
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
ApplyWpfShellStyle();
}
public float DpiX { get { return _legacyPanel.DpiX; } set { _legacyPanel.DpiX = value; } }
public float DpiY { get { return _legacyPanel.DpiY; } set { _legacyPanel.DpiY = value; } }
public int plTopHeight { get { return _legacyPanel.plTopHeight; } }
public FormWindowState State { get { return _legacyPanel.State; } set { _legacyPanel.State = value; } }
public XtraTabControl TabMain { get { return _legacyPanel.TabMain; } }
public Panel MainPanel { get { return _legacyPanel.MainPanel; } }
public AwaitScreenControl AwaitControl { get { return _legacyPanel.AwaitControl; } }
public PictureBox pic_search { get { return _legacyPanel.pic_search; } }
public event EventHandler OnMaxButtonCallBack { add { _legacyPanel.OnMaxButtonCallBack += value; } remove { _legacyPanel.OnMaxButtonCallBack -= value; } }
public event EventHandler OnMinButtonCallBack { add { _legacyPanel.OnMinButtonCallBack += value; } remove { _legacyPanel.OnMinButtonCallBack -= value; } }
public event EventHandler OnCloseButtonCallBack { add { _legacyPanel.OnCloseButtonCallBack += value; } remove { _legacyPanel.OnCloseButtonCallBack -= value; } }
public event EventHandler OnTopPanelMouseDoubleClickCallBack { add { _legacyPanel.OnTopPanelMouseDoubleClickCallBack += value; } remove { _legacyPanel.OnTopPanelMouseDoubleClickCallBack -= value; } }
public event MouseEventHandler OnTopMouseDownCallback { add { _legacyPanel.OnTopMouseDownCallback += value; } remove { _legacyPanel.OnTopMouseDownCallback -= value; } }
public event MouseEventHandler OnTopMouseUpCallBack { add { _legacyPanel.OnTopMouseUpCallBack += value; } remove { _legacyPanel.OnTopMouseUpCallBack -= value; } }
public event MouseEventHandler OnTopMouseMoveCallBack { add { _legacyPanel.OnTopMouseMoveCallBack += value; } remove { _legacyPanel.OnTopMouseMoveCallBack -= value; } }
/// <summary>保持旧 FrmMain 的 OnLoad 调用契约,在菜单绑定完成后应用新版样式。</summary>
public void OnLoad()
{
// 新版主界面不显示旧版右侧快捷通道。先启用旧控件已有的隐藏开关,
// 使后续目录切换不再继续创建按菜单位置生成的快捷项。
_shortcutChannelDisabled = true;
SystemInfo.Instance.HideGallerys = true;
_legacyPanel.OnLoad();
DisableShortcutChannel();
ApplyWpfShellStyle();
}
private void TopMenuItem_Click(object sender, EventArgs e)
{
SelectTopMenu(sender as ToolStripMenuItem);
ResetBrandArea();
// 切换一级目录时旧逻辑会重建左侧菜单,下一帧重新套用新版布局。
if (IsNavigationChangedSinceLastStyle())
RequestApplyWpfShellStyle();
}
private static bool IsGroupedSidebarMode()
{
// 设计器预览不能访问数据库;预览时直接采用新版分组侧栏样式。
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
return true;
// 与旧主界面使用同一份系统参数,避免新版界面出现目录不一致。
return "1".Equals((SystemInfo.Instance.MainLeftShowMode ?? string.Empty).Trim());
}
private bool IsNavigationChangedSinceLastStyle()
{
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) return false;
string id = (ERPInfo.Instance.SubSysId ?? string.Empty).Trim();
string name = (ERPInfo.Instance.SubSysName ?? string.Empty).Trim();
return !string.Equals(id, _styledSubSysId, StringComparison.OrdinalIgnoreCase)
|| !string.Equals(name, _styledSubSysName, StringComparison.OrdinalIgnoreCase);
}
private void RememberStyledNavigation()
{
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) return;
_styledSubSysId = (ERPInfo.Instance.SubSysId ?? string.Empty).Trim();
_styledSubSysName = (ERPInfo.Instance.SubSysName ?? string.Empty).Trim();
}
/// <summary>
/// 合并同一消息循环内由顶部菜单点击、下拉框关闭等事件发起的重复重绘。
/// 旧版切换目录本身已经重建快捷通道,重复套用样式会造成右侧闪烁。
/// </summary>
private void RequestApplyWpfShellStyle()
{
if (!IsHandleCreated || _styleUpdatePending) return;
_styleUpdatePending = true;
BeginInvoke((MethodInvoker)(() =>
{
_styleUpdatePending = false;
if (!IsDisposed)
{
ApplyWpfShellStyle();
if (_shortcutRedrawSuppressed) SetShortcutRedraw(true);
}
}));
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+76 -21
View File
@@ -42,6 +42,9 @@ namespace Lskj.Main
/// </summary>
public partial class FrmMain : Form
{
// 设计器仍保留旧控件字段;运行时通过配置决定实际使用的主界面。
private dynamic _activeMainPanel;
private dynamic ActiveMainPanel { get { return _activeMainPanel ?? (dynamic)this.mainPanelControlEx; } }
/// <summary>
/// 屏幕dpix、dpiy
/// </summary>
@@ -62,15 +65,57 @@ namespace Lskj.Main
/// 水印层
/// </summary>
private FrmWatermark watermarkForm;
public FrmMain()
{
Graphics graphics = this.CreateGraphics();
_dpiX = graphics.DpiX;
_dpiY = graphics.DpiY;
InitializeComponent();
InitializeMainPanelVariant();
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
}
private void InitializeMainPanelVariant()
{
_activeMainPanel = this.mainPanelControlEx;
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) return;
if (!SystemInfo.Instance.NewMain) return;
System.Windows.Forms.Control oldPanel = this.mainPanelControlEx;
System.Windows.Forms.Control parent = oldPanel.Parent;
if (parent == null) return;
int childIndex = parent.Controls.GetChildIndex(oldPanel);
MainPanelControlEx2 newPanel = null;
try
{
// 先创建新版控件,只有创建成功后才移除旧控件,避免异常时主界面为空。
newPanel = new MainPanelControlEx2
{
Dock = DockStyle.Fill,
Location = Point.Empty,
Name = "mainPanelControlEx2"
};
parent.Controls.Add(newPanel);
parent.Controls.SetChildIndex(newPanel, childIndex);
parent.Controls.Remove(oldPanel);
oldPanel.Dispose();
_activeMainPanel = newPanel;
}
catch (Exception ex)
{
if (newPanel != null)
{
parent.Controls.Remove(newPanel);
newPanel.Dispose();
}
_activeMainPanel = oldPanel;
LogHelper.Instance.WriteError(ex);
}
}
#region
[DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
@@ -113,25 +158,26 @@ namespace Lskj.Main
{
ERPInfo.Instance.MainControl = this;
this.Text = SystemInfo.Instance.ClientName + "ERP系统:" + ERPInfo.Instance.UserName;
this.mainPanelControlEx.Hide();
this.ActiveMainPanel.Hide();
//FrmAutoSqlLoad frm = new FrmAutoSqlLoad();
//frm.ShowDialog();
this.KeyPreview = true;//主窗体允许使用事件
this.mainPanelControlEx.DpiX = _dpiX;
this.mainPanelControlEx.DpiY = _dpiY;
this.mainPanelControlEx.OnLoad();
this.mainPanelControlEx.OnCloseButtonCallBack += new EventHandler(OnCloseButtonCallBack);
this.mainPanelControlEx.OnMaxButtonCallBack += new EventHandler(OnTopPanelMouseDoubleClickCallBack);
this.mainPanelControlEx.OnMinButtonCallBack += new EventHandler(OnMinButtonCallBack);
this.mainPanelControlEx.OnTopMouseDownCallback += new MouseEventHandler(OnTopMouseDownCallback);
this.mainPanelControlEx.OnTopMouseMoveCallBack += new MouseEventHandler(OnTopMouseMoveCallBack);
this.mainPanelControlEx.OnTopMouseUpCallBack += new MouseEventHandler(OnTopMouseUpCallBack);
this.mainPanelControlEx.OnTopPanelMouseDoubleClickCallBack += new EventHandler(OnTopPanelMouseDoubleClickCallBack);
this.ActiveMainPanel.DpiX = _dpiX;
this.ActiveMainPanel.DpiY = _dpiY;
this.ActiveMainPanel.OnLoad();
this.ActiveMainPanel.OnCloseButtonCallBack += new EventHandler(OnCloseButtonCallBack);
this.ActiveMainPanel.OnMaxButtonCallBack += new EventHandler(OnTopPanelMouseDoubleClickCallBack);
this.ActiveMainPanel.OnMinButtonCallBack += new EventHandler(OnMinButtonCallBack);
this.ActiveMainPanel.OnTopMouseDownCallback += new MouseEventHandler(OnTopMouseDownCallback);
this.ActiveMainPanel.OnTopMouseMoveCallBack += new MouseEventHandler(OnTopMouseMoveCallBack);
this.ActiveMainPanel.OnTopMouseUpCallBack += new MouseEventHandler(OnTopMouseUpCallBack);
this.ActiveMainPanel.OnTopPanelMouseDoubleClickCallBack += new EventHandler(OnTopPanelMouseDoubleClickCallBack);
if (SystemInfo.Instance.DetectionMemory)
{
this.TheMemoryTest.Start();
}
this.mainPanelControlEx.State = this.WindowState;
this.ActiveMainPanel.State = this.WindowState;
this.MouseMove += OnFrmMainMouseMove;
this.MouseLeave += OnFrmMainMouseLeave;
@@ -159,7 +205,7 @@ namespace Lskj.Main
}
finally
{
this.mainPanelControlEx.Show();
this.ActiveMainPanel.Show();
}
}
@@ -292,17 +338,24 @@ namespace Lskj.Main
int closeCount = 0;
if (StaticControl.DogVerifyModuleForms.Count > 0)
{
foreach (DevExpress.XtraTab.XtraTabPage page in StaticControl.DogVerifyModuleForms)
foreach (DevExpress.XtraTab.XtraTabPage page in
new List<DevExpress.XtraTab.XtraTabPage>(StaticControl.DogVerifyModuleForms))
{
this.mainPanelControlEx.TabMain.Invoke(new Action(() =>
this.ActiveMainPanel.TabMain.Invoke(new Action(() =>
{
try
{
if (this.mainPanelControlEx.TabMain.TabPages.Contains(page))
string moduleId = Convert.ToString(page.Tag);
DllModule module;
Manager.ModuleForms.TryGetValue(moduleId, out module);
Manager.ModuleCloseSnapshot closeSnapshot =
Manager.PrepareModuleClose(module, page);
if (this.ActiveMainPanel.TabMain.TabPages.Contains(page))
{
this.mainPanelControlEx.TabMain.TabPages.Remove(page);
page.Dispose();
this.ActiveMainPanel.TabMain.TabPages.Remove(page);
}
Manager.ModuleForms.Remove(moduleId);
Manager.CompleteModuleClose(closeSnapshot);
}
catch (Exception)
{
@@ -314,7 +367,8 @@ namespace Lskj.Main
}
if (StaticControl.DogVerifyNoPageForms.Count > 0)
{
foreach (IForm iForm in StaticControl.DogVerifyNoPageForms)
foreach (IForm iForm in
new List<IForm>(StaticControl.DogVerifyNoPageForms))
{
try
{
@@ -484,7 +538,7 @@ namespace Lskj.Main
{
this.Padding = new Padding(0, 0, 3, 3);
}
this.mainPanelControlEx.State = this.WindowState;
this.ActiveMainPanel.State = this.WindowState;
this.StartPosition = FormStartPosition.CenterScreen;
this.ResetFormState();
}
@@ -534,6 +588,7 @@ namespace Lskj.Main
try
{
CloseWatermarkForm();
Manager.CompleteAllModuleCloses();
Manager.ModuleForms.Clear();
}
catch (Exception ex)
@@ -618,7 +673,7 @@ namespace Lskj.Main
{
EnsureFormInCurrentScreen();
}
this.mainPanelControlEx.pic_search.Focus();//点击界面失去焦点
this.ActiveMainPanel.pic_search.Focus();//点击界面失去焦点
}
catch (Exception ex)
{
+171
View File
@@ -0,0 +1,171 @@
using System.Drawing;
using System.Windows.Forms;
namespace Lskj.Main
{
partial class FrmPersonalSetting
{
private System.ComponentModel.IContainer components;
private Panel pnlHeader, pnlNavigation, pnlContent, pnlAppearance, pnlFonts;
private Button navAppearance, navFonts, btnSave, btnCancel, btnReset;
private TextBox txtTopColor, txtLeftColor, txtLeftSelectColor;
private Panel pnlTopPreview, pnlLeftPreview, pnlLeftSelectPreview;
private Button btnTopColor, btnLeftColor, btnLeftSelectColor;
private NumericUpDown numTopFont, numLeftFont;
protected override void Dispose(bool disposing)
{
if (disposing && components != null) components.Dispose();
base.Dispose(disposing);
}
// Keep this method limited to straightforward assignments so the WinForms
// designer can parse it reliably.
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
Text = "个性化";
StartPosition = FormStartPosition.CenterParent;
FormBorderStyle = FormBorderStyle.FixedSingle;
MaximizeBox = false;
MinimizeBox = false;
ClientSize = new Size(780, 582);
BackColor = Color.White;
Font = new Font("Microsoft YaHei", 9F);
pnlHeader = new Panel();
pnlNavigation = new Panel();
pnlContent = new Panel();
pnlAppearance = new Panel();
pnlFonts = new Panel();
pnlHeader.Dock = DockStyle.Top;
pnlHeader.Height = 36;
pnlHeader.BackColor = Color.FromArgb(7, 95, 166);
pnlNavigation.Dock = DockStyle.Left;
pnlNavigation.Width = 176;
pnlNavigation.BackColor = Color.FromArgb(247, 249, 252);
pnlNavigation.Padding = new Padding(8, 8, 8, 0);
pnlContent.Dock = DockStyle.Fill;
pnlContent.BackColor = Color.White;
pnlContent.Padding = new Padding(18, 0, 18, 0);
Controls.Add(pnlContent);
Controls.Add(pnlNavigation);
Controls.Add(pnlHeader);
}
// Build the remaining controls outside InitializeComponent. This is invoked
// by the form constructor for both runtime and Visual Studio design-time.
private void BuildDesignerControls()
{
Label title = new Label { Text = "● 个性化", ForeColor = Color.White, AutoSize = true, Location = new Point(12, 9), Font = new Font("Microsoft YaHei", 10F) };
Button close = new Button { Text = "×", FlatStyle = FlatStyle.Flat, ForeColor = Color.White, BackColor = Color.Transparent, Size = new Size(32, 30), Anchor = AnchorStyles.Top | AnchorStyles.Right, Location = new Point(740, 3) };
close.FlatAppearance.BorderSize = 0;
close.Click += delegate { Close(); };
pnlHeader.Controls.Add(title);
pnlHeader.Controls.Add(close);
navAppearance = MakeNavButton("外观", 8);
navFonts = MakeNavButton("字体与字号", 48);
navAppearance.Click += navAppearance_Click;
navFonts.Click += navFonts_Click;
pnlNavigation.Controls.Add(navFonts);
pnlNavigation.Controls.Add(navAppearance);
pnlAppearance = MakePage();
pnlFonts = MakePage();
pnlFonts.Visible = false;
pnlContent.Controls.Add(pnlFonts);
pnlContent.Controls.Add(pnlAppearance);
BuildAppearancePage();
BuildFontsPage();
Panel footer = new Panel { Dock = DockStyle.Bottom, Height = 48, BackColor = Color.White, BorderStyle = BorderStyle.FixedSingle };
btnReset = MakeFooterButton("恢复默认", 12);
btnCancel = MakeFooterButton("取消", 610);
btnSave = MakeFooterButton("保存", 690);
btnReset.Click += btnReset_Click;
btnCancel.Click += btnCancel_Click;
btnSave.Click += btnSave_Click;
footer.Controls.Add(btnReset);
footer.Controls.Add(btnCancel);
footer.Controls.Add(btnSave);
Controls.Add(footer);
ShowPage(pnlAppearance);
}
private Button MakeNavButton(string text, int top)
{
return new Button { Text = text, TextAlign = ContentAlignment.MiddleLeft, Padding = new Padding(14, 0, 0, 0), FlatStyle = FlatStyle.Flat, ForeColor = Color.FromArgb(50, 70, 95), BackColor = Color.Transparent, Size = new Size(160, 36), Location = new Point(8, top) };
}
private Button MakeFooterButton(string text, int left)
{
return new Button { Text = text, FlatStyle = FlatStyle.Flat, BackColor = Color.White, ForeColor = Color.FromArgb(65, 85, 110), Size = new Size(70, 30), Location = new Point(left, 8), Anchor = AnchorStyles.Right | AnchorStyles.Top };
}
private Panel MakePage() { return new Panel { Dock = DockStyle.Fill, BackColor = Color.White }; }
private Label MakeLabel(string text, int top)
{
return new Label { Text = text, AutoSize = true, Location = new Point(2, top + 7), ForeColor = Color.FromArgb(35, 48, 65), Font = new Font("Microsoft YaHei", 9F) };
}
private void AddRow(Panel page, Label label, System.Windows.Forms.Control editor, int top)
{
Panel row = new Panel { Height = 64, Width = 560, Location = new Point(0, top), Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right, BorderStyle = BorderStyle.FixedSingle, BackColor = Color.White };
label.Location = new Point(20, 22);
row.Controls.Add(label);
editor.Location = new Point(318, 16);
row.Controls.Add(editor);
page.Controls.Add(row);
row.BringToFront();
}
private void BuildAppearancePage()
{
Label heading = new Label { Text = "外观", Dock = DockStyle.Top, Height = 38, Padding = new Padding(2, 11, 0, 0), ForeColor = Color.FromArgb(45, 65, 90) };
pnlAppearance.Controls.Add(heading);
txtTopColor = MakeColorText(); pnlTopPreview = MakePreview(); btnTopColor = MakeChooseButton();
AddRow(pnlAppearance, MakeLabel("顶部菜单背景色", 0), MakeColorEditor(txtTopColor, pnlTopPreview, btnTopColor), 38);
btnTopColor.Click += btnTopColor_Click; txtTopColor.TextChanged += txtColor_TextChanged;
txtLeftColor = MakeColorText(); pnlLeftPreview = MakePreview(); btnLeftColor = MakeChooseButton();
AddRow(pnlAppearance, MakeLabel("左侧菜单背景色", 0), MakeColorEditor(txtLeftColor, pnlLeftPreview, btnLeftColor), 102);
btnLeftColor.Click += btnLeftColor_Click; txtLeftColor.TextChanged += txtColor_TextChanged;
txtLeftSelectColor = MakeColorText(); pnlLeftSelectPreview = MakePreview(); btnLeftSelectColor = MakeChooseButton();
AddRow(pnlAppearance, MakeLabel("左侧菜单选中背景色", 0), MakeColorEditor(txtLeftSelectColor, pnlLeftSelectPreview, btnLeftSelectColor), 166);
btnLeftSelectColor.Click += btnLeftSelectColor_Click; txtLeftSelectColor.TextChanged += txtColor_TextChanged;
}
private void BuildFontsPage()
{
Label heading = new Label { Text = "字体与字号", Dock = DockStyle.Top, Height = 38, Padding = new Padding(2, 11, 0, 0), ForeColor = Color.FromArgb(45, 65, 90) };
pnlFonts.Controls.Add(heading);
numTopFont = MakeNumber(); numLeftFont = MakeNumber();
AddRow(pnlFonts, MakeLabel("顶部菜单字号", 0), numTopFont, 38);
AddRow(pnlFonts, MakeLabel("左侧菜单字号", 0), numLeftFont, 102);
}
private TextBox MakeColorText() { return new TextBox { Width = 130, Height = 24, BorderStyle = BorderStyle.FixedSingle }; }
private Panel MakePreview() { return new Panel { Width = 24, Height = 22, BorderStyle = BorderStyle.FixedSingle }; }
private Button MakeChooseButton() { return new Button { Text = "选择", Width = 52, Height = 24, FlatStyle = FlatStyle.Flat }; }
private Panel MakeColorEditor(TextBox text, Panel preview, Button choose)
{
Panel p = new Panel { Width = 260, Height = 28 };
text.Location = new Point(0, 1); preview.Location = new Point(136, 1); choose.Location = new Point(166, 0);
p.Controls.Add(text); p.Controls.Add(preview); p.Controls.Add(choose); return p;
}
private NumericUpDown MakeNumber() { return new NumericUpDown { Width = 220, Minimum = 8, Maximum = 24, Value = 12, BorderStyle = BorderStyle.FixedSingle }; }
private void ShowPage(System.Windows.Forms.Control page)
{
if (pnlAppearance == null || pnlFonts == null) return;
pnlAppearance.Visible = page == pnlAppearance;
pnlFonts.Visible = page == pnlFonts;
if (navAppearance != null) navAppearance.BackColor = pnlAppearance.Visible ? Color.FromArgb(229, 239, 250) : Color.Transparent;
if (navFonts != null) navFonts.BackColor = pnlFonts.Visible ? Color.FromArgb(229, 239, 250) : Color.Transparent;
}
}
}
+251
View File
@@ -0,0 +1,251 @@
using Lskj.Control;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace Lskj.Main
{
public partial class FrmPersonalSetting : BaseForm
{
private MainAppearanceSettings _settings;
public FrmPersonalSetting()
{
InitializeComponent();
BuildDesignerControls();
// 设计器只需要静态控件,不访问本地配置文件或运行时状态。
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) return;
_settings = MainAppearanceSettingsStore.Load();
LoadSettingsToControls();
}
private void LoadSettingsToControls()
{
txtTopColor.Text = _settings.TopMenuBackground;
txtLeftColor.Text = _settings.SidebarBackground;
txtLeftSelectColor.Text = _settings.SidebarSelectedBackground;
numTopFont.Value = Clamp(_settings.TopMenuFontSize, numTopFont.Minimum, numTopFont.Maximum);
numLeftFont.Value = Clamp(_settings.LeftMenuFontSize, numLeftFont.Minimum, numLeftFont.Maximum);
// An empty value means "use the program default". Keep the editor
// visually empty while MainPanelControlEx2 still uses its fallback.
if (!_settings.TopMenuFontConfigured) numTopFont.Text = string.Empty;
if (!_settings.LeftMenuFontConfigured) numLeftFont.Text = string.Empty;
UpdateColorPreview(txtTopColor, pnlTopPreview);
UpdateColorPreview(txtLeftColor, pnlLeftPreview);
UpdateColorPreview(txtLeftSelectColor, pnlLeftSelectPreview);
}
private void SaveSettings()
{
int ignoredTopFont;
int ignoredLeftFont;
MainAppearanceSettingsStore.Save(new MainAppearanceSettings
{
TopMenuBackground = MainAppearanceSettingsStore.NormalizeColor(txtTopColor.Text, _settings.TopMenuBackground),
SidebarBackground = MainAppearanceSettingsStore.NormalizeColor(txtLeftColor.Text, _settings.SidebarBackground),
SidebarSelectedBackground = MainAppearanceSettingsStore.NormalizeColor(txtLeftSelectColor.Text, _settings.SidebarSelectedBackground),
TopMenuFontSize = ParseFontEditorValue(numTopFont, MainAppearanceSettingsStore.DefaultTopMenuFontSize),
LeftMenuFontSize = ParseFontEditorValue(numLeftFont, MainAppearanceSettingsStore.DefaultLeftMenuFontSize),
TopMenuFontConfigured = TryParseFontEditorValue(numTopFont, out ignoredTopFont),
LeftMenuFontConfigured = TryParseFontEditorValue(numLeftFont, out ignoredLeftFont)
});
DialogResult = DialogResult.OK;
Close();
}
private void ChooseColor(TextBox textBox, Panel preview)
{
Color current = MainAppearanceSettingsStore.ParseColor(textBox.Text, Color.White);
using (ColorDialog dialog = new ColorDialog { Color = current, FullOpen = true })
{
if (dialog.ShowDialog(this) != DialogResult.OK) return;
textBox.Text = MainAppearanceSettingsStore.FormatColor(dialog.Color);
UpdateColorPreview(textBox, preview);
}
}
private static void UpdateColorPreview(TextBox textBox, Panel preview)
{
if (preview != null) preview.BackColor = MainAppearanceSettingsStore.ParseColor(textBox.Text, Color.White);
}
private static decimal Clamp(int value, decimal min, decimal max)
{
return Math.Min(max, Math.Max(min, value));
}
private static bool TryParseFontEditorValue(NumericUpDown editor, out int value)
{
value = 0;
int parsed;
if (!int.TryParse((editor == null ? string.Empty : editor.Text ?? string.Empty).Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out parsed)) return false;
if (parsed < MainAppearanceSettingsStore.MinimumFontSize || parsed > MainAppearanceSettingsStore.MaximumFontSize) return false;
value = parsed;
return true;
}
private static int ParseFontEditorValue(NumericUpDown editor, int fallback)
{
int value;
return TryParseFontEditorValue(editor, out value) ? value : fallback;
}
private void txtColor_TextChanged(object sender, EventArgs e)
{
if (sender == txtTopColor) UpdateColorPreview(txtTopColor, pnlTopPreview);
else if (sender == txtLeftColor) UpdateColorPreview(txtLeftColor, pnlLeftPreview);
else if (sender == txtLeftSelectColor) UpdateColorPreview(txtLeftSelectColor, pnlLeftSelectPreview);
}
private void btnTopColor_Click(object sender, EventArgs e) { ChooseColor(txtTopColor, pnlTopPreview); }
private void btnLeftColor_Click(object sender, EventArgs e) { ChooseColor(txtLeftColor, pnlLeftPreview); }
private void btnLeftSelectColor_Click(object sender, EventArgs e) { ChooseColor(txtLeftSelectColor, pnlLeftSelectPreview); }
private void btnSave_Click(object sender, EventArgs e) { SaveSettings(); }
private void btnCancel_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; Close(); }
private void btnReset_Click(object sender, EventArgs e) { _settings = MainAppearanceSettingsStore.Defaults(); LoadSettingsToControls(); }
private void navAppearance_Click(object sender, EventArgs e) { ShowPage(pnlAppearance); }
private void navFonts_Click(object sender, EventArgs e) { ShowPage(pnlFonts); }
}
internal sealed class MainAppearanceSettings
{
public string TopMenuBackground;
public string SidebarBackground;
public string SidebarSelectedBackground;
public int TopMenuFontSize;
public int LeftMenuFontSize;
public bool TopMenuFontConfigured;
public bool LeftMenuFontConfigured;
}
internal static class MainAppearanceSettingsStore
{
internal const int DefaultTopMenuFontSize = 9;
internal const int DefaultLeftMenuFontSize = 12;
internal const int MinimumFontSize = 8;
internal const int MaximumFontSize = 24;
// WinForms uses a separate file so changing the WPF shell settings does not
// unexpectedly alter the transitional WinForms main panel.
private const string FileName = "WinFromShellAppearance.ini";
private const string TopColorKey = "TopMenuBackground=";
private const string LeftColorKey = "SidebarBackground=";
private const string LeftSelectedColorKey = "SidebarSelectedBackground=";
private const string TopFontKey = "TopMenuFontSize=";
private const string LeftFontKey = "LeftMenuFontSize=";
public static MainAppearanceSettings Defaults()
{
return new MainAppearanceSettings
{
TopMenuBackground = "#1F4B99",
SidebarBackground = "#272D51",
SidebarSelectedBackground = "#348ED8",
TopMenuFontSize = DefaultTopMenuFontSize,
LeftMenuFontSize = DefaultLeftMenuFontSize,
TopMenuFontConfigured = false,
LeftMenuFontConfigured = false
};
}
public static MainAppearanceSettings Load()
{
MainAppearanceSettings result = Defaults();
try
{
string path = GetPath();
if (!File.Exists(path))
{
// Create the WinForms-specific file on first run so the active
// values are visible and editable from the Debug\Config folder.
Save(result);
return result;
}
foreach (string raw in File.ReadAllLines(path))
{
string line = (raw ?? string.Empty).Trim();
if (line.StartsWith(TopColorKey, StringComparison.OrdinalIgnoreCase)) result.TopMenuBackground = NormalizeColor(line.Substring(TopColorKey.Length), result.TopMenuBackground);
else if (line.StartsWith(LeftColorKey, StringComparison.OrdinalIgnoreCase)) result.SidebarBackground = NormalizeColor(line.Substring(LeftColorKey.Length), result.SidebarBackground);
else if (line.StartsWith(LeftSelectedColorKey, StringComparison.OrdinalIgnoreCase)) result.SidebarSelectedBackground = NormalizeColor(line.Substring(LeftSelectedColorKey.Length), result.SidebarSelectedBackground);
else if (line.StartsWith(TopFontKey, StringComparison.OrdinalIgnoreCase))
{
int value;
if (TryParseFont(line.Substring(TopFontKey.Length), out value)) { result.TopMenuFontSize = value; result.TopMenuFontConfigured = true; }
}
else if (line.StartsWith(LeftFontKey, StringComparison.OrdinalIgnoreCase))
{
int value;
if (TryParseFont(line.Substring(LeftFontKey.Length), out value)) { result.LeftMenuFontSize = value; result.LeftMenuFontConfigured = true; }
}
}
}
catch (Exception) { }
return result;
}
public static void Save(MainAppearanceSettings settings)
{
if (settings == null) return;
string path = GetPath();
string[] oldLines = new string[0];
try { if (File.Exists(path)) oldLines = File.ReadAllLines(path); } catch (Exception) { }
string[] replacements =
{
TopColorKey + NormalizeColor(settings.TopMenuBackground, "#1F4B99"),
LeftColorKey + NormalizeColor(settings.SidebarBackground, "#272D51"),
LeftSelectedColorKey + NormalizeColor(settings.SidebarSelectedBackground, "#348ED8"),
TopFontKey + (settings.TopMenuFontConfigured ? settings.TopMenuFontSize.ToString(CultureInfo.InvariantCulture) : string.Empty),
LeftFontKey + (settings.LeftMenuFontConfigured ? settings.LeftMenuFontSize.ToString(CultureInfo.InvariantCulture) : string.Empty)
};
string[] keys = { TopColorKey, LeftColorKey, LeftSelectedColorKey, TopFontKey, LeftFontKey };
var output = oldLines.ToList();
for (int i = 0; i < keys.Length; i++)
{
int index = output.FindIndex(x => (x ?? string.Empty).Trim().StartsWith(keys[i], StringComparison.OrdinalIgnoreCase));
if (index >= 0) output[index] = replacements[i]; else output.Add(replacements[i]);
}
try
{
string dir = Path.GetDirectoryName(path);
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
File.WriteAllLines(path, output.ToArray());
}
catch (Exception) { }
}
public static string NormalizeColor(string value, string fallback)
{
return FormatColor(ParseColor(value, ParseColor(fallback, Color.Black)));
}
public static Color ParseColor(string value, Color fallback)
{
if (string.IsNullOrWhiteSpace(value)) return fallback;
string text = value.Trim();
if (!text.StartsWith("#", StringComparison.Ordinal) || text.Length != 7) return fallback;
byte r, g, b;
if (!byte.TryParse(text.Substring(1, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out r) || !byte.TryParse(text.Substring(3, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out g) || !byte.TryParse(text.Substring(5, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out b)) return fallback;
return Color.FromArgb(r, g, b);
}
public static string FormatColor(Color color)
{
return string.Format(CultureInfo.InvariantCulture, "#{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B);
}
private static bool TryParseFont(string value, out int result)
{
result = 0;
return int.TryParse((value ?? string.Empty).Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out result)
&& result >= MinimumFontSize && result <= MaximumFontSize;
}
private static string GetPath()
{
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config", FileName);
}
}
}
@@ -61,6 +61,17 @@ namespace Lskj.Main.Hosting
Manager.ExternalMainShell = externalMainShell;
try
{
// A standalone Ls_ERP process must always start in the
// original WinForms page mode. Clear any stale host
// references before FrmMain is created so Manager.OpenModule
// cannot accidentally route pages to a previous WPF shell
// when the legacy runtime is reused in-process.
if (externalMainShell == null)
{
ERPInfo.Instance.ModulePageHost = null;
ERPInfo.Instance.PageControl = null;
Manager.TabMain = null;
}
Program.InitializeMainProcess();
_mainProcessInitialized = true;
}
+15
View File
@@ -132,6 +132,12 @@
<Compile Include="Control\MainPanelControlEx.Designer.cs">
<DependentUpon>MainPanelControlEx.cs</DependentUpon>
</Compile>
<Compile Include="Control\MainPanelControlEx2.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Control\MainPanelControlEx2.Designer.cs">
<DependentUpon>MainPanelControlEx2.cs</DependentUpon>
</Compile>
<Compile Include="Control\MenuBar.cs">
<SubType>UserControl</SubType>
</Compile>
@@ -240,6 +246,12 @@
<Compile Include="FrmPassword.Designer.cs">
<DependentUpon>FrmPassword.cs</DependentUpon>
</Compile>
<Compile Include="FrmPersonalSetting.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmPersonalSetting.Designer.cs">
<DependentUpon>FrmPersonalSetting.cs</DependentUpon>
</Compile>
<Compile Include="FrmSkins.cs">
<SubType>Form</SubType>
</Compile>
@@ -299,6 +311,9 @@
<EmbeddedResource Include="Control\MainPanelControlEx.resx">
<DependentUpon>MainPanelControlEx.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Control\MainPanelControlEx2.resx">
<DependentUpon>MainPanelControlEx2.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Control\MenuBar.resx">
<DependentUpon>MenuBar.cs</DependentUpon>
</EmbeddedResource>
+343 -16
View File
@@ -40,6 +40,182 @@ namespace Lskj.Main.Model
/// </summary>
public sealed class Manager
{
/// <summary>
/// Controls when a managed WinForms module is shown. The classic
/// shell keeps the original immediate behavior; the WPF compatibility
/// host can create the page first, attach it to WindowsFormsHost, and
/// show the form after the native host is ready.
/// </summary>
public enum ModuleOpenMode
{
Immediate,
DeferredForWpf
}
/// <summary>
/// WinForms-owned module lifetime token. Resources are registered while
/// the module is opened and released from this scope on close.
/// </summary>
public sealed class ModuleCloseSnapshot
{
internal readonly string ModuleId;
internal readonly XtraTabPage Page;
internal readonly Form Form;
internal readonly StaticControl.ModuleResourceScope Scope;
internal ModuleCloseSnapshot(
string moduleId,
XtraTabPage page,
Form form,
StaticControl.ModuleResourceScope scope)
{
ModuleId = moduleId ?? string.Empty;
Page = page;
Form = form;
Scope = scope;
}
}
/// <summary>
/// Prepares a close token without inspecting the hosted control tree.
/// The module scope has already registered its resources during open;
/// the fallback registration only covers legacy callers that create a
/// page outside AddModuleToTab.
/// </summary>
public static ModuleCloseSnapshot PrepareModuleClose(
DllModule module,
XtraTabPage page)
{
Form form = module == null ? null : module.ModuleForm as Form;
string moduleId = module == null
? Convert.ToString(page == null ? null : page.Tag)
: Convert.ToString(module.Tag);
// Legacy callers historically set only XtraTabPage.Tag. Prefer the
// page key when the module object has not been assigned its GUID so
// each close operation resolves its own scope and dictionary entry.
if (string.IsNullOrWhiteSpace(moduleId))
moduleId = Convert.ToString(page == null ? null : page.Tag);
moduleId = moduleId ?? string.Empty;
if (module != null && !string.IsNullOrWhiteSpace(moduleId))
module.Tag = moduleId;
StaticControl.ModuleResourceScope scope;
bool created = false;
lock (ModuleScopesSync)
{
if (!ModuleScopes.TryGetValue(moduleId, out scope) || scope == null)
{
scope = StaticControl.FindAttachedModuleScope(form) ??
StaticControl.FindAttachedModuleScope(page);
if (scope == null)
{
scope = new StaticControl.ModuleResourceScope(moduleId);
created = true;
}
ModuleScopes[moduleId] = scope;
}
}
if (created)
{
StaticControl.AttachModuleScope(form, scope);
StaticControl.AttachModuleScope(page, scope);
RegisterOwnedModuleObjects(scope, form, page);
}
return new ModuleCloseSnapshot(moduleId, page, form, scope);
}
/// <summary>
/// Completes a previously prepared module close by disposing its
/// registration scope. No control-tree traversal is performed here.
/// </summary>
public static void CompleteModuleClose(ModuleCloseSnapshot snapshot)
{
if (snapshot == null)
return;
try
{
if (snapshot.Scope != null)
snapshot.Scope.Dispose();
}
catch (Exception exception)
{
LogHelper.Instance.WriteError(exception);
}
lock (ModuleScopesSync)
{
StaticControl.ModuleResourceScope current;
if (ModuleScopes.TryGetValue(snapshot.ModuleId ?? string.Empty, out current) &&
ReferenceEquals(current, snapshot.Scope))
{
ModuleScopes.Remove(snapshot.ModuleId ?? string.Empty);
}
}
}
public static void CompleteAllModuleCloses()
{
List<StaticControl.ModuleResourceScope> scopes;
lock (ModuleScopesSync)
{
scopes = ModuleScopes.Values.Where(scope => scope != null).Distinct().ToList();
ModuleScopes.Clear();
}
foreach (StaticControl.ModuleResourceScope scope in scopes)
{
try
{
scope.Dispose();
}
catch (Exception exception)
{
LogHelper.Instance.WriteError(exception);
}
}
// Legacy page-open paths create scopes directly and therefore do
// not enter ModuleScopes. Release those scopes during the global
// shutdown pass as well.
StaticControl.CompleteAllModuleResourceScopes();
}
private static void RegisterOwnedModuleObjects(
StaticControl.ModuleResourceScope scope,
Form form,
XtraTabPage page)
{
if (scope == null)
return;
if (form != null)
{
scope.Register(form, () =>
{
if (!form.IsDisposed)
form.Dispose();
});
}
if (page != null)
{
scope.Register(page, () =>
{
if (!page.IsDisposed)
page.Dispose();
});
}
}
/// <summary>
/// Finds the search control registered by the module during creation.
/// The lookup is direct and does not inspect the WinForms control tree.
/// </summary>
public static MyControl FindModuleSearchControl(string moduleId)
{
if (string.IsNullOrWhiteSpace(moduleId))
return null;
return StaticControl.FindModuleSearchControl(moduleId);
}
/// <summary>
/// 主程序
/// </summary>
@@ -79,6 +255,12 @@ namespace Lskj.Main.Model
/// </summary>
public static Dictionary<string, DllModule> ModuleForms = new Dictionary<string, DllModule>();
/// <summary>
/// 每个已打开模块的资源登记作用域。键与 ModuleForms 中的页签标识一致。
/// </summary>
private static readonly Dictionary<string, StaticControl.ModuleResourceScope> ModuleScopes =
new Dictionary<string, StaticControl.ModuleResourceScope>(StringComparer.OrdinalIgnoreCase);
private static readonly object ModuleScopesSync = new object();
/// <summary>
/// 记录F4配置快速菜单模块
/// </summary>
public static Form QuickMenuForm = null;
@@ -287,6 +469,29 @@ namespace Lskj.Main.Model
/// <param name="
/// Params">The URL parameters.</param>
public static void OpenModule(string menuId, string menuName, string dllName, string modelFlag, string urlParams)
{
OpenModule(
menuId,
menuName,
dllName,
modelFlag,
urlParams,
ModuleOpenMode.Immediate);
}
/// <summary>
/// Opens a managed WinForms module with an explicit show policy.
/// DeferredForWpf creates and registers the native page without
/// running Form.Show; the WPF compatibility layer must later call
/// ShowDeferredModule after attaching the page to its host.
/// </summary>
public static void OpenModule(
string menuId,
string menuName,
string dllName,
string modelFlag,
string urlParams,
ModuleOpenMode openMode)
{
string openingModuleKey = null;
bool ownsOpeningGate = false;
@@ -356,12 +561,12 @@ namespace Lskj.Main.Model
dllName = MainImpl.GetDefaultValue(dllName);
if (SystemInfo.Instance.SoftOpenMode || SingleOpenMode)
{
foreach (XtraTabPage tablepage in TabMain.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Text == menuName)
{
MessageUtil.Show("已设置不能打开多个相同模块!");
TabMain.SelectedTabPage = tablepage;
ERPInfo.Instance.SelectModulePage(tablepage);
return;
}
}
@@ -414,8 +619,8 @@ namespace Lskj.Main.Model
tp.Dock = DockStyle.Fill;
module.Tag = guid;
module.ModuleInPtr = exeMainHandle;
TabMain.TabPages.Add(tp);
TabMain.SelectedTabPage = tp;
ERPInfo.Instance.AddModulePage(tp);
ERPInfo.Instance.SelectModulePage(tp);
ModuleForms.Add(guid, module);
}
else//直接打开exe模块
@@ -440,7 +645,7 @@ namespace Lskj.Main.Model
else
{
// 打开module程序
AddModuleToTab(module, args);
AddModuleToTab(module, args, openMode);
}
}
}
@@ -459,10 +664,69 @@ namespace Lskj.Main.Model
}
/// <summary>
/// Shows a module that was opened with DeferredForWpf. The page and
/// form must already have been registered by AddModuleToTab; this
/// method only owns the activation step and then selects the page.
/// </summary>
public static bool ShowDeferredModule(string moduleId)
{
if (string.IsNullOrWhiteSpace(moduleId))
return false;
DllModule module;
if (!ModuleForms.TryGetValue(moduleId, out module) || module == null)
return false;
Form form = module.ModuleForm as Form;
if (form == null || form.IsDisposed)
return false;
if (!form.Visible)
{
StaticControl.ModuleResourceScope scope;
lock (ModuleScopesSync)
{
ModuleScopes.TryGetValue(moduleId, out scope);
}
if (scope != null && scope.IsDisposed)
return false;
// DeferredForWpf returns before Form.OnLoad. Re-establish the
// module scope for activation so MyControl and its Timer are
// registered even though the original open call has returned.
if (scope == null)
{
form.Show();
}
else
{
using (StaticControl.PushModuleScope(scope))
{
form.Show();
}
}
}
if (form.IsDisposed)
return false;
XtraTabPage page = ERPInfo.Instance.ModulePages.FirstOrDefault(
item => item != null &&
string.Equals(
Convert.ToString(item.Tag),
moduleId,
StringComparison.OrdinalIgnoreCase));
if (page != null)
ERPInfo.Instance.SelectModulePage(page);
return true;
}
private static string BuildBsMenuUrl(string dllName, string dllCoid)
{
return string.Format(
"pages/app/app.html?xtype={0}&dllcoid={1}&username={2}&password={3}",
"pages/app/app.html?xtype={0}&dllcoid={1}&username={2}&password={3}&f=1",
dllName,
dllCoid,
ERPInfo.Instance.UserName,
@@ -518,10 +782,20 @@ namespace Lskj.Main.Model
/// <param name="module">The module.</param>
/// <param name="args">The arguments.</param>
public static void AddModuleToTab(DllModule module, string[] args)
{
AddModuleToTab(module, args, ModuleOpenMode.Immediate);
}
private static void AddModuleToTab(
DllModule module,
string[] args,
ModuleOpenMode openMode)
{
string guid = null;
XtraTabPage tp = null;
Form form = null;
StaticControl.ModuleResourceScope moduleScope = null;
IDisposable moduleScopeContext = null;
bool trackDogVerifiedModule = false;
try
{
@@ -622,10 +896,22 @@ namespace Lskj.Main.Model
}
guid = Guid.NewGuid().ToString();
moduleScope = new StaticControl.ModuleResourceScope(guid);
lock (ModuleScopesSync)
{
ModuleScopes[guid] = moduleScope;
}
moduleScopeContext = StaticControl.PushModuleScope(moduleScope);
tp = new XtraTabPage();
StaticControl.AttachModuleScope(tp, moduleScope);
moduleScope.Register(tp, () =>
{
if (!tp.IsDisposed)
tp.Dispose();
});
if (trackDogVerifiedModule)
{
StaticControl.DogVerifyModuleForms.Add(tp);
StaticControl.RegisterProtectedPage(tp);
}
ERPInfo.Instance.selectFormModleId = module.Id;
@@ -636,12 +922,22 @@ namespace Lskj.Main.Model
//iform.SubForm.WindowState = _frmMain.WindowState;
iform.SubForm.WindowState = FormWindowState.Normal; ;
form = iform.SubForm; // 表示组成应用程序的用户界面的窗口或对话框。
StaticControl.AttachModuleScope(form, moduleScope);
moduleScope.Register(form, () =>
{
if (!form.IsDisposed)
form.Dispose();
});
form.Tag = guid;
// 这个必须有不然会提示:"不能向tabControl中添加顶级控件"
form.TopLevel = isQuickLoad;
//form.Location = new Point(0, 0);
form.Dock = DockStyle.Fill;//客户需要缩放
form.AutoSize = true;
// A WPF WindowsFormsHost supplies the size. Letting the
// native Form participate in content-driven AutoSize causes
// a measure/reparent cycle to collapse split containers while
// the host is still being attached.
form.AutoSize = openMode != ModuleOpenMode.DeferredForWpf;
//form.Width = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
//form.Height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - MinusTheHeight;
form.FormBorderStyle = FormBorderStyle.None;
@@ -666,7 +962,10 @@ namespace Lskj.Main.Model
//module.Tag = "1";
module.Tag = guid;
module.ModuleForm = form;
if (openMode != ModuleOpenMode.DeferredForWpf)
{
form.Show();
}
if (args != null && !string.IsNullOrEmpty(args[4] + ""))
{
//2026-08-08 pz说把SearchCondFormModuleCode判断去掉,不要这个功能
@@ -688,21 +987,40 @@ namespace Lskj.Main.Model
//}
}
TabMain.TabPages.Add(tp);
TabMain.SelectedTabPage = tp;
ERPInfo.Instance.AddModulePage(tp);
if (openMode == ModuleOpenMode.DeferredForWpf)
{
// Register before returning so a WPF dispatcher callback
// can activate the form after the Host has been attached.
ModuleForms.Add(guid, module);
}
else
{
ERPInfo.Instance.SelectModulePage(tp);
ModuleForms.Add(guid, module);
}
//LastModuleForm.Add(module);
//Lskj.Main.Model.AutoSizeChange.ControllInitializeSize(form);//调整控件大小
}
catch (Exception ex)
{
if (moduleScopeContext != null)
{
moduleScopeContext.Dispose();
moduleScopeContext = null;
}
CleanupFailedModuleOpen(guid, tp, form);
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
LogHelper.Instance.WriteError(ex);
//LogUtil.WriteError("打开" + module.Name + "模块失败!", ex);
}
finally
{
if (moduleScopeContext != null)
moduleScopeContext.Dispose();
}
}
private static void CleanupFailedModuleOpen(
@@ -717,22 +1035,31 @@ namespace Lskj.Main.Model
ModuleForms.Remove(guid);
}
StaticControl.ModuleResourceScope moduleScope = null;
if (!string.IsNullOrWhiteSpace(guid))
{
lock (ModuleScopesSync)
{
if (ModuleScopes.TryGetValue(guid, out moduleScope))
ModuleScopes.Remove(guid);
}
if (moduleScope != null)
moduleScope.Dispose();
}
if (tabPage != null)
{
StaticControl.DogVerifyModuleForms.Remove(tabPage);
if (TabMain != null && TabMain.TabPages.Contains(tabPage))
{
TabMain.TabPages.Remove(tabPage);
}
ERPInfo.Instance.RemoveModulePage(tabPage);
}
if (form != null && !form.IsDisposed)
if (moduleScope == null && form != null && !form.IsDisposed)
{
form.Close();
form.Dispose();
}
if (tabPage != null && !tabPage.IsDisposed)
if (moduleScope == null && tabPage != null && !tabPage.IsDisposed)
{
tabPage.Dispose();
}
-11
View File
@@ -184,19 +184,8 @@ namespace Lskj.Main
finally
{
if (_cefInitialized)
{
bool browsersClosed =
CefBrowserRuntimeLifetime.CloseAllBrowsersAndWait(5000);
if (browsersClosed)
{
CefRuntime.Shutdown();
}
else
{
LogHelper.Instance.WriteLog(
"[CEF_LIFECYCLE] CefRuntime.Shutdown skipped " +
"because browser close callbacks are incomplete.");
}
_cefInitialized = false;
}
_mainProcessInitialized = false;
@@ -194,6 +194,7 @@ namespace Lskj.Main3.Control
// 解析dns
new Thread(MainImpl.DnsHostEntry).Start();
this.mark_timer.Start();
if (ERPInfo.Instance.ModulePageHost == null)
ERPInfo.Instance.PageControl = this.tabMain;
ERPInfo.Instance.ModuleForms = Manager.ModuleForms;
}
@@ -1976,12 +1977,12 @@ namespace Lskj.Main3.Control
XtraTabPage beforePage = m.BeforePage;
if (beforePage != null)
{
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage == beforePage)
{
ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
ERPInfo.Instance.CurrentModulePage = beforePage;
}
}
}
@@ -2584,6 +2585,7 @@ namespace Lskj.Main3.Control
if (!SystemInfo.Instance.RefreshNotify)
{
XtraTabPage tabPage = this.tabMain.SelectedTabPage;
ERPInfo.Instance.NotifyModulePageSelected(tabPage);
if (tabPage.TabIndex == 0)
{
Thread thread = new Thread(SetNotifys);
@@ -1,4 +1,4 @@
/***********************
/***********************
*
*
*
@@ -238,6 +238,7 @@ namespace Lskj.Main4.Control
// 解析dns
new Thread(MainImpl.DnsHostEntry).Start();
this.mark_timer.Start();
if (ERPInfo.Instance.ModulePageHost == null)
ERPInfo.Instance.PageControl = this.tabMain;
ERPInfo.Instance.ModuleForms = Manager.ModuleForms;
@@ -2099,12 +2100,12 @@ namespace Lskj.Main4.Control
XtraTabPage beforePage = m.BeforePage;
if (beforePage != null)
{
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage == beforePage)
{
ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
ERPInfo.Instance.CurrentModulePage = beforePage;
}
}
}
@@ -2872,6 +2873,7 @@ namespace Lskj.Main4.Control
if (!SystemInfo.Instance.RefreshNotify)
{
XtraTabPage tabPage = this.tabMain.SelectedTabPage;
ERPInfo.Instance.NotifyModulePageSelected(tabPage);
if (tabPage.TabIndex == 0)
{
Thread thread = new Thread(SetNotifys);
+305
View File
@@ -88,6 +88,311 @@ namespace Lskj.Model
/// 主界面page界面
/// </summary>
public XtraTabControl PageControl;
private readonly object _modulePageCallbackSync = new object();
private readonly List<Action<string>> _modulePageSelectedCallbacks =
new List<Action<string>>();
/// <summary>
/// 顶层页面生命周期服务。旧 WinForms 主程序保持为空并继续使用
/// PageControlWPF 主程序注入自己的页面宿主实现。
/// </summary>
public IModulePageHost ModulePageHost;
public XtraTabPage CurrentModulePage
{
get
{
if (ModulePageHost != null)
return ModulePageHost.SelectedPage;
return PageControl == null ? null : PageControl.SelectedTabPage;
}
set
{
// Keep the original assignment-based API working for legacy
// modules. In the classic WinForms shell this forwards to
// the real PageControl; when WPF injects ModulePageHost it
// selects the page through that host instead of creating a
// second XtraTabControl.
SelectModulePage(value);
}
}
public IEnumerable<XtraTabPage> ModulePages
{
get
{
if (ModulePageHost != null)
return ModulePageHost.Pages;
if (PageControl == null)
return new XtraTabPage[0];
return PageControl.TabPages.Cast<XtraTabPage>();
}
}
/// <summary>
/// Indicates whether a top-level module page surface has been
/// initialized. The classic shell exposes its XtraTabControl while
/// WPF exposes IModulePageHost; callers can use this without reaching
/// into either visual implementation.
/// </summary>
public bool HasModulePageSurface
{
get { return ModulePageHost != null || PageControl != null; }
}
public void AddModulePage(XtraTabPage page)
{
if (page == null)
return;
if (ModulePageHost != null)
{
ModulePageHost.AddPage(page);
return;
}
if (PageControl != null && !PageControl.TabPages.Contains(page))
PageControl.TabPages.Add(page);
}
public bool RemoveModulePage(XtraTabPage page)
{
if (page == null)
return false;
if (ModulePageHost != null)
return ModulePageHost.RemovePage(page);
if (PageControl == null || !PageControl.TabPages.Contains(page))
return false;
PageControl.TabPages.Remove(page);
return true;
}
public bool SelectModulePage(XtraTabPage page)
{
if (page == null)
return false;
if (ModulePageHost != null)
return ModulePageHost.SelectPage(page);
if (PageControl == null || !PageControl.TabPages.Contains(page))
return false;
PageControl.SelectedTabPage = page;
return true;
}
public bool ContainsModulePage(XtraTabPage page)
{
if (page == null)
return false;
if (ModulePageHost != null)
return ModulePageHost.ContainsPage(page);
return PageControl != null && PageControl.TabPages.Contains(page);
}
/// <summary>
/// Returns the stable logical identifier used to bind a legacy page to
/// its WPF tab. The existing Tag value is retained whenever the old
/// module already assigned one; a generated value is written only for
/// an otherwise unidentified page.
/// </summary>
public string GetModulePageId(XtraTabPage page)
{
if (page == null)
return string.Empty;
string pageId = Convert.ToString(page.Tag);
if (string.IsNullOrWhiteSpace(pageId))
{
pageId = "legacy-module-" + Guid.NewGuid().ToString("N");
page.Tag = pageId;
}
return pageId;
}
/// <summary>
/// Gets the logical identifier of the selected top-level page without
/// exposing the shell's visual tab-control implementation.
/// </summary>
public string CurrentModulePageId
{
get { return GetModulePageId(CurrentModulePage); }
}
/// <summary>
/// Enumerates top-level page identifiers for modules that only need to
/// compare or select pages and should not reach PageControl.TabPages.
/// </summary>
public IEnumerable<string> GetModulePageIds()
{
return ModulePages.Select(GetModulePageId).ToArray();
}
/// <summary>
/// Selects a top-level page by its logical identifier. Both the WPF
/// host and the classic WinForms PageControl use the same fallback
/// path as the original XtraTabPage-based API.
/// </summary>
public bool SelectModulePage(string pageId)
{
XtraTabPage page = FindModulePage(pageId);
return page != null && SelectModulePage(page);
}
/// <summary>
/// Removes a top-level page by its logical identifier.
/// </summary>
public bool RemoveModulePage(string pageId)
{
XtraTabPage page = FindModulePage(pageId);
return page != null && RemoveModulePage(page);
}
/// <summary>
/// Indicates whether the supplied logical identifier belongs to a
/// top-level module page. This replaces checks based on
/// page.Parent as XtraTabControl in migrated module code.
/// </summary>
public bool IsTopLevelModulePage(string pageId)
{
return FindModulePage(pageId) != null;
}
/// <summary>
/// Registers a logical page-selection callback. This is intentionally
/// a page-service callback rather than a subscription to a concrete
/// WinForms or WPF tab-control event. Dispose the returned token when
/// the module closes so the callback cannot retain the module.
/// </summary>
public IDisposable RegisterModulePageSelected(Action<string> callback)
{
if (callback == null)
throw new ArgumentNullException("callback");
lock (_modulePageCallbackSync)
{
_modulePageSelectedCallbacks.Add(callback);
}
return new ModulePageCallbackRegistration(this, callback);
}
/// <summary>
/// Registers a callback for one logical module page. This overload is
/// the source-compatible replacement for code that used to subscribe
/// to the top-level PageControl.SelectedPageChanged event and then
/// filter by the selected page. The callback receives no WinForms
/// event arguments, so the same module code works when the WPF shell
/// owns the visible tab while the direct WinForms shell still uses its
/// original XtraTabControl.
/// </summary>
public IDisposable RegisterModulePageSelected(
string modulePageId,
Action callback)
{
if (callback == null)
throw new ArgumentNullException("callback");
string expectedPageId = (modulePageId ?? string.Empty).Trim();
if (string.IsNullOrWhiteSpace(expectedPageId))
throw new ArgumentException(
"模块页面标识不能为空。",
"modulePageId");
return RegisterModulePageSelected(
selectedPageId =>
{
if (string.Equals(
selectedPageId,
expectedPageId,
StringComparison.Ordinal))
{
callback();
}
});
}
/// <summary>
/// Notifies logical page-selection subscribers. The WPF page host
/// calls this after its own selection state is updated; the classic
/// MainPanelControlEx calls it from its existing SelectedPageChanged
/// handler. No visual control event is introduced in the WPF path.
/// </summary>
public void NotifyModulePageSelected(XtraTabPage page)
{
if (page == null)
return;
string pageId = GetModulePageId(page);
Action<string>[] callbacks;
lock (_modulePageCallbackSync)
{
callbacks = _modulePageSelectedCallbacks.ToArray();
}
foreach (Action<string> callback in callbacks)
{
try
{
callback(pageId);
}
catch (Exception exception)
{
System.Diagnostics.Trace.WriteLine(
"旧模块页面回调执行失败:" + exception);
}
}
}
private XtraTabPage FindModulePage(string pageId)
{
if (string.IsNullOrWhiteSpace(pageId))
return null;
foreach (XtraTabPage page in ModulePages)
{
if (string.Equals(
GetModulePageId(page),
pageId,
StringComparison.Ordinal))
{
return page;
}
}
return null;
}
private void UnregisterModulePageSelected(Action<string> callback)
{
if (callback == null)
return;
lock (_modulePageCallbackSync)
{
_modulePageSelectedCallbacks.Remove(callback);
}
}
private sealed class ModulePageCallbackRegistration : IDisposable
{
private ERPInfo _owner;
private readonly Action<string> _callback;
public ModulePageCallbackRegistration(
ERPInfo owner,
Action<string> callback)
{
_owner = owner;
_callback = callback;
}
public void Dispose()
{
ERPInfo owner = _owner;
if (owner == null)
return;
_owner = null;
owner.UnregisterModulePageSelected(_callback);
}
}
/// <summary>
/// 主界面page界面字典
/// </summary>
+1
View File
@@ -35,6 +35,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<Compile Include="ModulePageHost.cs" />
<Reference Include="DevExpress.Utils.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Debug\DevExpress.Utils.v15.2.dll</HintPath>
+38
View File
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using DevExpress.XtraTab;
namespace Lskj.Model
{
/// <summary>
/// Provides the top-level module page lifecycle without coupling module
/// code to a particular visual tab control. The WPF shell supplies an
/// implementation backed by DXTabItem instances; the classic WinForms
/// shell leaves this interface unset and ERPInfo falls back to its real
/// XtraTabControl/PageControl.
/// </summary>
public interface IModulePageHost
{
event EventHandler<ModulePageEventArgs> PageAdded;
event EventHandler<ModulePageEventArgs> PageRemoved;
event EventHandler<ModulePageEventArgs> PageSelected;
XtraTabPage SelectedPage { get; }
IEnumerable<XtraTabPage> Pages { get; }
void AddPage(XtraTabPage page);
bool RemovePage(XtraTabPage page);
bool SelectPage(XtraTabPage page);
bool ContainsPage(XtraTabPage page);
}
public sealed class ModulePageEventArgs : EventArgs
{
public ModulePageEventArgs(XtraTabPage page)
{
Page = page;
}
public XtraTabPage Page { get; private set; }
}
}
+11 -10
View File
@@ -32,13 +32,14 @@
/// </summary>
private void InitializeComponent()
{
this.pMenu = new DevExpress.XtraBars.PopupMenu();
this.barManager1 = new DevExpress.XtraBars.BarManager();
this.components = new System.ComponentModel.Container();
this.pMenu = new DevExpress.XtraBars.PopupMenu(this.components);
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
this.barDockControlRight = new DevExpress.XtraBars.BarDockControl();
this.pMprint = new DevExpress.XtraBars.PopupMenu();
this.pMprint = new DevExpress.XtraBars.PopupMenu(this.components);
this.pl_right_top = new DevExpress.XtraEditors.PanelControl();
this.gridFlow = new Lskj.Control.GridControlEx();
this.label_flow = new DevExpress.XtraEditors.LabelControl();
@@ -75,8 +76,8 @@
this.label_managerAudit = new Lskj.Control.LabelTextEdit();
this.CheckSuggestion = new Lskj.Control.LabelComboxEdit();
this.dbpFP = new DevExpress.XtraEditors.DropDownButton();
this.pmFP = new DevExpress.XtraBars.PopupMenu();
this.barManager2 = new DevExpress.XtraBars.BarManager();
this.pmFP = new DevExpress.XtraBars.PopupMenu(this.components);
this.barManager2 = new DevExpress.XtraBars.BarManager(this.components);
this.barDockControl1 = new DevExpress.XtraBars.BarDockControl();
this.barDockControl2 = new DevExpress.XtraBars.BarDockControl();
this.barDockControl3 = new DevExpress.XtraBars.BarDockControl();
@@ -432,7 +433,7 @@
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(67, 23);
this.btnSave.TabIndex = 17;
this.btnSave.Text = "保存(&S)";
this.btnSave.Text = "保存(S)";
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// dpb_Tools
@@ -481,7 +482,7 @@
this.btnSpare.Name = "btnSpare";
this.btnSpare.Size = new System.Drawing.Size(67, 23);
this.btnSpare.TabIndex = 19;
this.btnSpare.Text = "分单(&P)";
this.btnSpare.Text = "分单(P)";
this.btnSpare.Click += new System.EventHandler(this.btnSpare_Click);
//
// btnPrint
@@ -508,7 +509,7 @@
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 23);
this.btnClose.TabIndex = 5;
this.btnClose.Text = "关闭(&Q)";
this.btnClose.Text = "关闭(Q)";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnRemindBack
@@ -533,7 +534,7 @@
this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(75, 23);
this.btnBack.TabIndex = 4;
this.btnBack.Text = "返退(&N)";
this.btnBack.Text = "返退(N)";
this.btnBack.Click += new System.EventHandler(this.btnReturn_Click);
//
// btnRemindAccradit
@@ -558,7 +559,7 @@
this.btnAccradit.Name = "btnAccradit";
this.btnAccradit.Size = new System.Drawing.Size(75, 23);
this.btnAccradit.TabIndex = 3;
this.btnAccradit.Text = "审核(&Y)";
this.btnAccradit.Text = "审核(Y)";
this.btnAccradit.Click += new System.EventHandler(this.btnAccradit_Click);
//
// label_date
@@ -44,9 +44,29 @@ namespace Lskj.PubAccraditation
/// </summary>
public partial class FrmAccraditation : BaseForm
{
private readonly AltButtonShortcutManager mAltButtonShortcuts =
new AltButtonShortcutManager();
public FrmAccraditation()
{
InitializeComponent();
InitializeAltButtonShortcuts();
}
private void InitializeAltButtonShortcuts()
{
mAltButtonShortcuts.Register(btnSave, Keys.S);
mAltButtonShortcuts.Register(btnSpare, Keys.P);
mAltButtonShortcuts.Register(btnClose, Keys.Q);
mAltButtonShortcuts.Register(btnBack, Keys.N);
mAltButtonShortcuts.Register(btnAccradit, Keys.Y);
}
protected override bool ProcessCmdKey(
ref System.Windows.Forms.Message msg, Keys keyData)
{
return mAltButtonShortcuts.ProcessKey(keyData) ||
base.ProcessCmdKey(ref msg, keyData);
}
private void ReleaseResourcesForDispose()
@@ -89,7 +109,7 @@ namespace Lskj.PubAccraditation
}
if (SysModel != null && SysModel.DataCaches != null)
{
SysModel.DataCaches.Remove(this);
SysModel.DataCaches.RemoveCache(this);
}
}
catch
@@ -429,7 +449,8 @@ namespace Lskj.PubAccraditation
}));
cachesDic.AddTask(tab_basicInfo, "DynamicModel", dynamicModelTask);
cachesDic.AddTask(tab_basicInfo, "Details", detailTask);
tab_basicInfo.GetDataCaches(cachesDic);
// TabControlEx.GetDataCaches 会创建明细页中的 WinForms/DevExpress
// 控件,不能在此后台预加载阶段调用;BindTab 在 UI 线程补充创建。
//BindBill
Task<DataTable> controlLocationTask = cachesDic.AddTask(this, "ControlLocation", new Task<DataTable>(() =>
{
@@ -955,6 +976,12 @@ namespace Lskj.PubAccraditation
{
this.tab_basicInfo.OnDetailSaveGridCallBack += Tab_basicInfo_OnDetailSaveGridCallBack;
}
if (dataCaches != null &&
dataCaches.GetTask<DynamicModel>(tab_basicInfo, "DynamicModel") != null &&
dataCaches.GetTask<List<GridDetailModel>>(tab_basicInfo, "Details") != null)
{
tab_basicInfo.GetDataCaches(dataCaches);
}
if (!dataCaches.GetValue(tab_basicInfo, "Details", out List<GridDetailModel> details))
{
details = GetTabDetails();
@@ -2203,8 +2230,8 @@ namespace Lskj.PubAccraditation
{
this.btnAccradit.Enabled = true;
this.btnRemindAccradit.Visible = this.btnRemindBack.Visible = this.btnSave.Visible = this.btnClose.Visible = this.btnSpare.Visible = this.btnBack.Visible = false;
this.btnAccradit.Text = "确认(&Y)";
this.btnAccradit.Text = "确认(&Y)";
this.btnAccradit.Text = "确认(Y)";
this.btnAccradit.Text = "确认(Y)";
this.label_auditPerson.Text = "确认意见";
this.label_date.EditText = "会签人";
this.txtRemark.Text = "确认";
@@ -2607,27 +2634,27 @@ namespace Lskj.PubAccraditation
this.DialogResult = DialogResult.OK;
if (refreshThePage != null)
{
refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -2674,14 +2701,14 @@ namespace Lskj.PubAccraditation
this.DialogResult = DialogResult.OK;
if (refreshThePage != null)
{
refreshThePage("审核成功", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("审核成功", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
@@ -2689,13 +2716,13 @@ namespace Lskj.PubAccraditation
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -2753,27 +2780,27 @@ namespace Lskj.PubAccraditation
//this.Close();
if (refreshThePage != null)
{
refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -2859,14 +2886,14 @@ namespace Lskj.PubAccraditation
this.DialogResult = DialogResult.OK;
if (refreshThePage != null)
{
refreshThePage("审核成功", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("审核成功", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
@@ -2874,13 +2901,13 @@ namespace Lskj.PubAccraditation
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -3198,27 +3225,27 @@ namespace Lskj.PubAccraditation
this.DialogResult = DialogResult.OK;
if (refreshThePage != null)
{
refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -3258,27 +3285,27 @@ namespace Lskj.PubAccraditation
this.DialogResult = DialogResult.OK;
if (refreshThePage != null)
{
refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -3332,27 +3359,27 @@ namespace Lskj.PubAccraditation
this.DialogResult = DialogResult.OK;
if (refreshThePage != null)
{
refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -3412,27 +3439,27 @@ namespace Lskj.PubAccraditation
this.DialogResult = DialogResult.OK;
if (refreshThePage != null)
{
refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
@@ -3497,27 +3524,27 @@ namespace Lskj.PubAccraditation
this.DialogResult = DialogResult.OK;
if (refreshThePage != null)
{
refreshThePage("", ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "");
refreshThePage("", ERPInfo.Instance.CurrentModulePage.Tag + "");
}
else
{
//上一次点开page 当前打开page删除后要选中的page
if (ERPInfo.Instance.PageControl != null)
if (ERPInfo.Instance.HasModulePageSurface)
{
string id = ERPInfo.Instance.PageControl.SelectedTabPage.Tag + "";
string id = ERPInfo.Instance.CurrentModulePage.Tag + "";
XtraTabPage beforePage = ERPInfo.Instance.ModuleForms[id].BeforePage;
if (beforePage != null)
{
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
removePage.Dispose();
}
}
+23 -13
View File
@@ -259,7 +259,7 @@ namespace Lskj.PubAccraditation
if (SystemInfo.Instance.PageOpen)
{
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
int interceptionLocation = tablepage.Text.Length - frm.SysModel.BillDocumentId.Length - 1;
if (interceptionLocation > 0 && tablepage.Text.Length > frm.SysModel.BillDocumentId.Length)
@@ -269,7 +269,7 @@ namespace Lskj.PubAccraditation
if (documentNo.Equals(frm.SysModel.BillDocumentId))
{
MessageUtil.Show("已设置不能打开多个相同模块!");
ERPInfo.Instance.PageControl.SelectedTabPage = tablepage;
ERPInfo.Instance.CurrentModulePage = tablepage;
return;
}
}
@@ -279,7 +279,7 @@ namespace Lskj.PubAccraditation
DllName = "",
Id = SysModel.ModuleId + "",
Name = SysModel.FormText,
BeforePage = ERPInfo.Instance.PageControl.SelectedTabPage,
BeforePage = ERPInfo.Instance.CurrentModulePage,
ModuleForm = frm
};
frm.refreshThePage += new FrmAccraditation.RefreshThePage(refreshThePage);
@@ -295,9 +295,14 @@ namespace Lskj.PubAccraditation
tp.Controls.Add(frm);
tp.ShowCloseButton = DefaultBoolean.True;
tp.Dock = DockStyle.Fill;
ERPInfo.Instance.PageControl.TabPages.Add(tp);
ERPInfo.Instance.PageControl.SelectedTabPage = tp;
StaticControl.ModuleResourceScope moduleScope =
StaticControl.RegisterModulePage(module, tp, frm);
ERPInfo.Instance.AddModulePage(tp);
ERPInfo.Instance.CurrentModulePage = tp;
using (StaticControl.PushModuleScope(moduleScope))
{
frm.Show();
}
tp.Text = frm.Text;
ERPInfo.Instance.ModuleForms.Add(guid, module);
}
@@ -345,7 +350,7 @@ namespace Lskj.PubAccraditation
if (SystemInfo.Instance.PageOpen)
{
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
int interceptionLocation = tablepage.Text.Length - frm.SysModel.BillDocumentId.Length - 1;
if (interceptionLocation > 0 && tablepage.Text.Length > frm.SysModel.BillDocumentId.Length)
@@ -355,7 +360,7 @@ namespace Lskj.PubAccraditation
if (documentNo.Equals(frm.SysModel.BillDocumentId))
{
MessageUtil.Show("已设置不能打开多个相同模块!");
ERPInfo.Instance.PageControl.SelectedTabPage = tablepage;
ERPInfo.Instance.CurrentModulePage = tablepage;
return;
}
}
@@ -365,7 +370,7 @@ namespace Lskj.PubAccraditation
DllName = "",
Id = SysModel.ModuleId + "",
Name = SysModel.FormText,
BeforePage = ERPInfo.Instance.PageControl.SelectedTabPage,
BeforePage = ERPInfo.Instance.CurrentModulePage,
ModuleForm = frm
};
frm.refreshThePage += new FrmAccraditation.RefreshThePage(refreshThePage);
@@ -382,9 +387,14 @@ namespace Lskj.PubAccraditation
tp.Controls.Add(frm);
tp.ShowCloseButton = DefaultBoolean.True;
tp.Dock = DockStyle.Fill;
ERPInfo.Instance.PageControl.TabPages.Add(tp);
ERPInfo.Instance.PageControl.SelectedTabPage = tp;
StaticControl.ModuleResourceScope moduleScope =
StaticControl.RegisterModulePage(module, tp, frm);
ERPInfo.Instance.AddModulePage(tp);
ERPInfo.Instance.CurrentModulePage = tp;
using (StaticControl.PushModuleScope(moduleScope))
{
frm.Show();
}
tp.Text = frm.Text;
ERPInfo.Instance.ModuleForms.Add(guid, module);
@@ -422,13 +432,13 @@ namespace Lskj.PubAccraditation
//要删除的page
XtraTabPage removePage = new XtraTabPage();
ERPInfo.Instance.ModuleForms.Remove(id);
foreach (XtraTabPage tablepage in ERPInfo.Instance.PageControl.TabPages)
foreach (XtraTabPage tablepage in ERPInfo.Instance.ModulePages)
{
if (tablepage.Tag == null) continue;
if (tablepage.Tag.ToString().Equals(id)) removePage = tablepage;
if (tablepage == beforePage) ERPInfo.Instance.PageControl.SelectedTabPage = beforePage;
if (tablepage == beforePage) ERPInfo.Instance.CurrentModulePage = beforePage;
}
ERPInfo.Instance.PageControl.TabPages.Remove(removePage);
ERPInfo.Instance.RemoveModulePage(removePage);
}
}
@@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.splitMain = new DevExpress.XtraEditors.SplitContainerControl();
this.TabControl = new DevExpress.XtraTab.XtraTabControl();
this.MainTab = new DevExpress.XtraTab.XtraTabPage();
@@ -54,12 +55,12 @@
this.btnExport = new DevExpress.XtraEditors.SimpleButton();
this.btnSpare = new DevExpress.XtraEditors.SimpleButton();
this.btnPrint = new DevExpress.XtraEditors.DropDownButton();
this.pMprint = new DevExpress.XtraBars.PopupMenu();
this.barManager1 = new DevExpress.XtraBars.BarManager();
this.pMprint = new DevExpress.XtraBars.PopupMenu(this.components);
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.btnSave = new DevExpress.XtraEditors.SimpleButton();
this.btnAttach = new DevExpress.XtraEditors.SimpleButton();
this.dpb_Tools = new DevExpress.XtraEditors.DropDownButton();
this.pMenu = new DevExpress.XtraBars.PopupMenu();
this.pMenu = new DevExpress.XtraBars.PopupMenu(this.components);
this.btnClose = new DevExpress.XtraEditors.SimpleButton();
this.btnBack = new DevExpress.XtraEditors.SimpleButton();
this.btnAccradit = new DevExpress.XtraEditors.SimpleButton();
+7 -6
View File
@@ -28,16 +28,17 @@
/// </summary>
private void InitializeComponent()
{
this.barManager1 = new DevExpress.XtraBars.BarManager();
this.components = new System.ComponentModel.Container();
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
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.pmFP = new DevExpress.XtraBars.PopupMenu(this.components);
this.pmBillExp = new DevExpress.XtraBars.PopupMenu(this.components);
this.pmBill = new DevExpress.XtraBars.PopupMenu(this.components);
this.pMprint = new DevExpress.XtraBars.PopupMenu(this.components);
this.pMenu = new DevExpress.XtraBars.PopupMenu(this.components);
this.tb_buttom = new Lskj.Control.TabControlEx();
this.ssc_main_top = new DevExpress.XtraEditors.SplitContainerControl();
this.pl_left = new DevExpress.XtraEditors.PanelControl();
File diff suppressed because it is too large Load Diff
+17 -6
View File
@@ -13,10 +13,20 @@
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
if (disposing)
{
if (cellHelper != null)
{
cellHelper.Dispose();
cellHelper = null;
}
class2_0 = null;
class2_1 = null;
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
@@ -28,15 +38,16 @@
/// </summary>
private void InitializeComponent()
{
this.barManager1 = new DevExpress.XtraBars.BarManager();
this.components = new System.ComponentModel.Container();
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
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.pmBillExp = new DevExpress.XtraBars.PopupMenu();
this.pmBill = new DevExpress.XtraBars.PopupMenu();
this.pMprint = new DevExpress.XtraBars.PopupMenu();
this.pMenu = new DevExpress.XtraBars.PopupMenu();
this.pmBillExp = new DevExpress.XtraBars.PopupMenu(this.components);
this.pmBill = new DevExpress.XtraBars.PopupMenu(this.components);
this.pMprint = new DevExpress.XtraBars.PopupMenu(this.components);
this.pMenu = new DevExpress.XtraBars.PopupMenu(this.components);
this.ssc_main_top = new DevExpress.XtraEditors.SplitContainerControl();
this.pl_left = new DevExpress.XtraEditors.PanelControl();
this.xtc_left_container = new DevExpress.XtraTab.XtraTabControl();
+7 -6
View File
@@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.ssc_main = new DevExpress.XtraEditors.SplitContainerControl();
this.ssc_main_top = new DevExpress.XtraEditors.SplitContainerControl();
this.pl_left = new DevExpress.XtraEditors.PanelControl();
@@ -39,7 +40,7 @@
this.pl_treeview_detault_search = new DevExpress.XtraEditors.PanelControl();
this.panelControl4 = new DevExpress.XtraEditors.PanelControl();
this.textEdit1 = new DevExpress.XtraEditors.TextEdit();
this.barManager1 = new DevExpress.XtraBars.BarManager();
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.barDockControl1 = new DevExpress.XtraBars.BarDockControl();
this.barDockControl2 = new DevExpress.XtraBars.BarDockControl();
this.barDockControl3 = new DevExpress.XtraBars.BarDockControl();
@@ -49,7 +50,7 @@
this.btnTreeSearch = new DevExpress.XtraEditors.SimpleButton();
this.pl_main_bottom = new DevExpress.XtraEditors.PanelControl();
this.dbpFP = new DevExpress.XtraEditors.DropDownButton();
this.pmFP = new DevExpress.XtraBars.PopupMenu();
this.pmFP = new DevExpress.XtraBars.PopupMenu(this.components);
this.btnRefresh = new DevExpress.XtraEditors.SimpleButton();
this.btnHiding = new DevExpress.XtraEditors.SimpleButton();
this.btnHelp = new DevExpress.XtraEditors.SimpleButton();
@@ -62,15 +63,15 @@
this.labelControl2 = new DevExpress.XtraEditors.LabelControl();
this.btn_input = new DevExpress.XtraEditors.SimpleButton();
this.dpbImport = new DevExpress.XtraEditors.DropDownButton();
this.pmBillExp = new DevExpress.XtraBars.PopupMenu();
this.pmBillExp = new DevExpress.XtraBars.PopupMenu(this.components);
this.btnBillAdd = new DevExpress.XtraEditors.SimpleButton();
this.btnBillApply = new DevExpress.XtraEditors.SimpleButton();
this.dpCopyBill = new DevExpress.XtraEditors.DropDownButton();
this.pmBill = new DevExpress.XtraBars.PopupMenu();
this.pmBill = new DevExpress.XtraBars.PopupMenu(this.components);
this.btnPrint = new DevExpress.XtraEditors.DropDownButton();
this.pMprint = new DevExpress.XtraBars.PopupMenu();
this.pMprint = new DevExpress.XtraBars.PopupMenu(this.components);
this.dpbTools = new DevExpress.XtraEditors.DropDownButton();
this.pMenu = new DevExpress.XtraBars.PopupMenu();
this.pMenu = new DevExpress.XtraBars.PopupMenu(this.components);
this.btnDelete = new DevExpress.XtraEditors.SimpleButton();
this.btnBillSave = new DevExpress.XtraEditors.SimpleButton();
this.pl_main_top = new DevExpress.XtraEditors.PanelControl();
+236 -140
View File
@@ -204,6 +204,8 @@ namespace Lskj.PubBillConcise
/// 单据来源控件集合
/// </summary>
public Dictionary<DataRow, BillModuleModel> BillModuleModelDic = new Dictionary<DataRow, BillModuleModel>();
private volatile bool _moduleDisposed;
private readonly object _billModuleModelSync = new object();
/// <summary>
/// 主表动态生成的日期列
/// </summary>
@@ -232,6 +234,36 @@ namespace Lskj.PubBillConcise
public BillModule()
{
InitializeComponent();
this.Disposed += BillModule_Disposed;
}
private void BillModule_Disposed(object sender, EventArgs e)
{
_moduleDisposed = true;
// The preloading graph keeps delegates pointing at this module.
// Remove this owner from the cache as soon as the visual root is
// disposed so later lookups cannot resurrect a closed module.
try
{
if (SysModel != null && SysModel.DataCaches != null)
SysModel.DataCaches.RemoveCache(this);
}
catch
{
// Disposal must remain best-effort.
}
lock (_billModuleModelSync)
{
BillModuleModelDic.Clear();
}
DateColumnList.Clear();
RemoveRowitem.Clear();
ToWithdrawRows.Clear();
ChangeColorRow.Clear();
SysModel = null;
BillModel = null;
ControlObj = null;
}
#region
@@ -250,6 +282,8 @@ namespace Lskj.PubBillConcise
try
{
this.SysModel = Model;// 单据动态链接库参数,入口参数
if (this.SysModel != null && this.SysModel.DataCaches == null)
this.SysModel.DataCaches = new Dictionary<object, Hashtable>();
this._isInitFinish = false;// 是否为初始化创建
this.ssc_main.Visible = false; //获取或设置一个值,该值指示是否显示该控件及其所有子控件。
//this.ProcessExists = (Lskj.Data.Caches.CacheSYSConfig.Instance().JudgeProcessExists() && SystemInfo.Instance.isExecload);
@@ -263,8 +297,13 @@ namespace Lskj.PubBillConcise
}
Dictionary<object, Hashtable> dataCaches = Model != null ? Model.DataCaches : null;
if (dataCaches != null)
dataCaches.GetValue(this, "DataCaches", out bool _);//等待缓存数据加载完成
if (this.IsDisposed || Model == null)
return;
this.InitializeSetting();//初始化系统配置
if (this.IsDisposed || this.BillModel == null)
return;
this.InitializeControl();//初始化控件
this.InitlizeSpiltLocation();
@@ -302,31 +341,62 @@ namespace Lskj.PubBillConcise
finally
{
this._isInitFinish = true;
if (!this.IsDisposed && !this.Disposing)
{
this.ssc_main.Visible = true;
if (this.BillModel.MainVerticalScroll || this.BillModel.MainHorizontalScrolling)
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;//隐藏横向滚动条
}
}
}
}
private static void AttachCachedTask<T>(
Dictionary<object, Hashtable> cachesDic,
object cacheOwner,
string cacheKey,
object control,
string controlKey)
{
if (cachesDic == null || cacheOwner == null || control == null ||
cachesDic.GetTask<T>(control, controlKey) != null)
{
return;
}
Task<T> task = cachesDic.GetTask<T>(cacheOwner, cacheKey);
if (task != null)
{
cachesDic.AddTask(control, controlKey, task);
}
}
/// <summary>
/// 获取数据源缓存
/// </summary>
/// <param name="cachesDic"></param>
public void GetDataCaches(Dictionary<object, Hashtable> cachesDic)
{
if (cachesDic == null)
return;
//获取通用数据
Task<ModuleModel> sysModelTask = cachesDic.GetTask<ModuleModel>(this, "SysModel");
Task<DataRow> systemDllRowTask = cachesDic.GetTask<DataRow>(this, "SystemDllRow");
Task<DynamicModel> dynamicModelTask = cachesDic.GetTask<DynamicModel>(this, "DynamicModel");
if (dynamicModelTask == null)
return;
Task<bool> getDataCachesTask = cachesDic.AddTask(this, "DataCaches", new Task<bool>(() =>
{
DynamicBillModel dynamicModel = (DynamicBillModel)dynamicModelTask.Result;
if (dynamicModel == null)
return false;
#region InitializeSetting初始化系统配置
Task<DataRow> billInfoRowTask = cachesDic.AddTask(this, "BillInfo", new Task<DataRow>(() =>
{
@@ -342,6 +412,8 @@ namespace Lskj.PubBillConcise
return model;
}));
BillModel billModel = billModelTask.Result;
if (billModel == null)
return false;
if (billModel != null)
{
Task<string> masterPreFixTask = cachesDic.AddTask(this, "MasterPreFix", new Task<string>(() =>
@@ -357,19 +429,26 @@ namespace Lskj.PubBillConcise
{
DataRow dataRow = BaseImpl.GetMenuConfigTab(dynamicModel.ModuleId);
if (dataRow != null)
{
if (billModel != 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("<<"))
if (!string.IsNullOrEmpty(billModel.PrintSql) &&
billModel.PrintSql.Contains("<<"))
{
string[] strs = billModel.PrintSql.Split(new[] { ">>" }, 2, StringSplitOptions.None);
_mainPrintSql = strs[1];
_printModeCond = strs[0].Replace("<<", "");
int printEnd = billModel.PrintSql.IndexOf(">>", StringComparison.Ordinal);
if (printEnd > 1 && printEnd + 2 < billModel.PrintSql.Length)
{
_printModeCond = billModel.PrintSql.Substring(2, printEnd - 2);
_mainPrintSql = billModel.PrintSql.Substring(printEnd + 2);
}
}
if (!string.IsNullOrEmpty(_printModeCond) && _printModeCond.IndexOf(';') > 0)
{
@@ -435,15 +514,8 @@ namespace Lskj.PubBillConcise
{
return BaseModuleImpl.GetControlLocation(billModel.FormKey, dynamicModel.ModuleCode);
}));
Task<MyControl> controlObjTask = cachesDic.AddTask(this, "ControlObj", new Task<MyControl>(() =>
{
MyControl myControl = new MyControl() { Model = dynamicModel };
myControl.OtherParams = dynamicModel.OtherParams();
cachesDic.AddTask(myControl, "DynamicModel", dynamicModelTask);
cachesDic.AddTask(myControl, "ControlsTable", controlLocationTask);
myControl.GetControlDataCaches(cachesDic);
return myControl;//主表控件
}));
// MyControl 持有 WinForms Timer。后台预加载只取得控件配置数据,
// MyControl 及其实际编辑控件统一在真正的 UI 线程创建。
Task<DataTable> addGroupDataTask = cachesDic.AddTask(this, "AddGroupData", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetAddGroupData(billModel.FormKey);//获取主信息分组数据
@@ -500,14 +572,21 @@ namespace Lskj.PubBillConcise
}));
cachesDic.AddTask(tb_buttom, "DynamicModel", dynamicModelTask);
cachesDic.AddTask(tb_buttom, "Details", detailTask);
tb_buttom.GetDataCaches(cachesDic);
// TabControlEx.GetDataCaches 会创建 Grid、ModuleGrid、浏览器等
// WinForms/DevExpress 控件。这里只预取来源数据,实际控件在
// InitializeBillSource 的 UI 线程阶段创建。
Task<bool> initSourcesTask = cachesDic.AddTask(this, "InitSourcesTask", new Task<bool>(() =>
{
if (_moduleDisposed)
return false;
Hashtable htTable = sourcesTask.Result;
DataTable masterTable = htTable["master"] as DataTable;
DataTable detailTable = htTable["detail"] as DataTable;
if (masterTable == null)
return false;
for (int i = 0; i < masterTable.Rows.Count; i++)
{
if (_moduleDisposed)
return false;
DataRow sourceModelRow = masterTable.Rows[i];
BillModuleModel billModuleModel = new BillModuleModel();
BillSourceModel model = new BillSourceModel(sourceModelRow);
@@ -516,137 +595,78 @@ namespace Lskj.PubBillConcise
{
return BaseModuleImpl.GetCustomQueryFields(model.FormKey);
}));
#region
GridControlEx gridControl = null;
TreeViewEx treeView = null;
// 后台阶段只加载数据,不构造任何 WinForms/DevExpress
// 对象。缓存以 BillModuleModel 为所有者,UI 创建实际控件
// 后再把需要的任务绑定到该控件。
if (model.SourceType == 1)
{
// 来源为树类型
treeView = new TreeViewEx();
billModuleModel.SourceControl = treeView;
Task<DataTable> bindTreeTableTask = cachesDic.AddTask(treeView, "BindTreeTable", new Task<DataTable>(() =>
cachesDic.AddTask(billModuleModel, "BindTreeTable", new Task<DataTable>(() =>
{
return BaseImpl.GetDataTableResult(model.SourceSql);
}));
}
else if (model.SourceType == 5)
else
{
if (model.SourceType == 5)
model.ChangeSourceType(2);//单据来源显示条数
}
else if (model.SourceType == 3 || model.SourceType == 4)
{
gridControl = new TreeGridControlEx();
billModuleModel.SourceControl = gridControl;
Task<DataTable> sourceColumnsTask = cachesDic.AddTask(gridControl, "SourceColumns", new Task<DataTable>(() =>
{
return BillImpl.GetSourceColumns(model.Id);
}));
Task<DataTable> sourceGridRowColorsTask = cachesDic.AddTask(gridControl, "BaseGridRowColors", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey);
}));
Task<DataTable> sourceGridRightMenusTask = cachesDic.AddTask(gridControl, "BaseGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey);
}));
}
else
{
// 来源为表格类型
gridControl = new GridControlEx();
billModuleModel.SourceControl = gridControl;
Task<DataTable> sourceColumnsTask = cachesDic.AddTask(gridControl, "SourceColumns", new Task<DataTable>(() =>
{
return BillImpl.GetSourceColumns(model.Id);
}));
//创建表格列
cachesDic.AddTask(gridControl, "DynamicModel", dynamicModelTask);
gridControl.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceGridView + model.FormKey);
Task<DataTable> sourceGridRowColorsTask = cachesDic.AddTask(gridControl, "BaseGridRowColors", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey);
}));
Task<DataTable> sourceGridRightMenusTask = cachesDic.AddTask(gridControl, "BaseGridRightMenus", new Task<DataTable>(() =>
{
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<DataTable> detailGridRowColorsTask = cachesDic.AddTask(gridDetail, "BaseGridRowColors", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey);
}));
Task<DataTable> detailGridRightMenusTask = cachesDic.AddTask(gridDetail, "BaseGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey);
}));
}
else
cachesDic.AddTask(billModuleModel, "SourceColumns", new Task<DataTable>(() =>
{
gridDetail = new GridControlEx();
billModuleModel.SourceDetailControl = gridDetail;
//创建表格列
cachesDic.AddTask(gridDetail, "DynamicModel", dynamicModelTask);
gridDetail.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey);
Task<DataTable> detailGridRowColorsTask = cachesDic.AddTask(gridDetail, "BaseGridRowColors", new Task<DataTable>(() =>
return BillImpl.GetSourceColumns(model.Id);
}));
cachesDic.AddTask(billModuleModel, "SourceCustomColumnByDatabase", new Task<DataTable>(() =>
{
return GridExtend.GetCustomColumnByDatabase(
GridCustomColumnStruct.BillSourceGridView + model.FormKey);
}));
cachesDic.AddTask(billModuleModel, "SourceBaseGridRowColors", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey);
}));
cachesDic.AddTask(billModuleModel, "SourceBaseGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey);
}));
}
if (string.IsNullOrWhiteSpace(model.DetailModeCode))
{
cachesDic.AddTask(billModuleModel, "SourceDetailCustomColumnByDatabase", new Task<DataTable>(() =>
{
return GridExtend.GetCustomColumnByDatabase(
GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey);
}));
cachesDic.AddTask(billModuleModel, "SourceDetailBaseGridRowColors", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey);
}));
Task<DataTable> detailGridRightMenusTask = cachesDic.AddTask(gridDetail, "BaseGridRightMenus", new Task<DataTable>(() =>
cachesDic.AddTask(billModuleModel, "SourceDetailBaseGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey);
}));
//明细的明细(明细分成左右2个)
if (!string.IsNullOrEmpty(model.SourceDetailsDetailsSql))
{
GridControlEx gridDetail_Details = new GridControlEx();
billModuleModel.SourceDetailDetailControl = gridDetail_Details;
//创建只读列
Task<DataTable> detailDetailsTask = cachesDic.AddTask(gridDetail_Details, "DetailDetails", new Task<DataTable>(() =>
cachesDic.AddTask(billModuleModel, "DetailDetails", new Task<DataTable>(() =>
{
return BaseModuleImpl.getDetail_Details(model.FormKey);
}));
//创建表格列
cachesDic.AddTask(gridDetail_Details, "DynamicModel", dynamicModelTask);
gridDetail_Details.GetDataCaches(cachesDic);
Task<DataTable> detailDetailsGridRightMenusTask = cachesDic.AddTask(gridDetail_Details, "BaseGridRightMenus", new Task<DataTable>(() =>
cachesDic.AddTask(billModuleModel, "SourceDetailDetailsCustomColumnByDatabase", new Task<DataTable>(() =>
{
return GridExtend.GetCustomColumnByDatabase(string.Empty);
}));
cachesDic.AddTask(billModuleModel, "SourceDetailDetailsBaseGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDTX_" + model.FormKey);
}));
}
}
#endregion
BillModuleModelDic.Add(sourceModelRow, billModuleModel);
#region
Task<MyControl> searchControlTask = cachesDic.AddTask(sourceModelRow, "SearchControl", new Task<MyControl>(() =>
lock (_billModuleModelSync)
{
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);
if (_moduleDisposed)
return false;
BillModuleModelDic[sourceModelRow] = billModuleModel;
}
return searchControl;
}));
#endregion
}
return true;
}));
@@ -715,6 +735,10 @@ namespace Lskj.PubBillConcise
private void InitializeSetting()
{
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
if (this.SysModel == null)
return;
if (dataCaches == null)
dataCaches = new Dictionary<object, Hashtable>();
if (!dataCaches.GetValue(this, "BillInfo", out DataRow modelRow))
{
modelRow = BillImpl.GetBillInfo(this.SysModel.ModuleCode);//获取单个模块信息
@@ -1040,6 +1064,10 @@ namespace Lskj.PubBillConcise
private void InitializeBillInfo()
{
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
if (this.BillModel == null || this.SysModel == null)
return;
if (dataCaches == null)
dataCaches = new Dictionary<object, Hashtable>();
if (!dataCaches.GetValue(this, "ControlLocation", out DataTable controls))
{
controls = BaseModuleImpl.GetControlLocation(this.BillModel.FormKey, this.SysModel.ModuleCode);
@@ -1653,6 +1681,18 @@ namespace Lskj.PubBillConcise
this.xtc_left_container.TabPages.Clear();
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
if (this.BillModel == null || this.SysModel == null)
return;
if (dataCaches == null)
dataCaches = new Dictionary<object, Hashtable>();
if (tb_buttom != null && dataCaches != null &&
dataCaches.GetTask<DynamicModel>(tb_buttom, "DynamicModel") != null &&
dataCaches.GetTask<List<GridDetailModel>>(tb_buttom, "Details") != null)
{
// TabControlEx.GetDataCaches 会创建来源明细页中的控件,必须在
// 当前 WinForms UI 线程执行;其内部的数据任务仍可并行准备。
tb_buttom.GetDataCaches(dataCaches);
}
if (!dataCaches.GetValue(this, "Details", out List<GridDetailModel> attachModels))
{
attachModels = GetAttachTabs();
@@ -1666,8 +1706,13 @@ namespace Lskj.PubBillConcise
}
htTable = BillImpl.GetSources(this.SysModel.ModuleCode, SourceIds);//获取单据来源
}
if (htTable == null)
return;
DataTable masterTable = htTable["master"] as DataTable;
DataTable detailTable = htTable["detail"] as DataTable;
if (masterTable == null)
return;
DataTable detailTable = htTable["detail"] as DataTable ?? new DataTable();
/*
* 1. ,()+,.
@@ -1700,7 +1745,13 @@ namespace Lskj.PubBillConcise
for (int i = 0; i < masterTable.Rows.Count; i++)
{
DataRow sourceModelRow = masterTable.Rows[i];
BillModuleModel billModuleModel = BillModuleModelDic.ContainsKey(sourceModelRow) ? BillModuleModelDic[sourceModelRow] : new BillModuleModel();
BillModuleModel billModuleModel;
lock (_billModuleModelSync)
{
BillModuleModelDic.TryGetValue(sourceModelRow, out billModuleModel);
}
if (billModuleModel == null)
billModuleModel = 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;
@@ -1743,7 +1794,7 @@ namespace Lskj.PubBillConcise
treeView.Dock = DockStyle.Fill;
treeView.TreeNodeKeyField = model.SourceKeyField;
treeView.TreeNodeTextField = model.SourceResult;
if (!dataCaches.GetValue(treeView, "BindTreeTable", out DataTable bindTreeTable))
if (!dataCaches.GetValue(billModuleModel, "BindTreeTable", out DataTable bindTreeTable))
{
bindTreeTable = BaseImpl.GetDataTableResult(model.SourceSql);
}
@@ -1765,15 +1816,15 @@ namespace Lskj.PubBillConcise
gridControl.BorderStyle = System.Windows.Forms.BorderStyle.None;
gridControl.Model = this.SysModel;
if (!dataCaches.GetValue(gridControl, "SourceColumns", out DataTable dtSourceColumns))
if (!dataCaches.GetValue(billModuleModel, "SourceColumns", out DataTable dtSourceColumns))
{
dtSourceColumns = BillImpl.GetSourceColumns(model.Id);
}
if (!dataCaches.GetValue(gridControl, "BaseGridRowColors", out DataTable dtBaseGridRowColors))
if (!dataCaches.GetValue(billModuleModel, "SourceBaseGridRowColors", out DataTable dtBaseGridRowColors))
{
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey);
}
if (!dataCaches.GetValue(gridControl, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus))
if (!dataCaches.GetValue(billModuleModel, "SourceBaseGridRightMenus", out DataTable dtBaseGridRightMenus))
{
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey);
}
@@ -1783,6 +1834,9 @@ namespace Lskj.PubBillConcise
//父节点编号
if (!string.IsNullOrWhiteSpace(model.SourceParentFieldName)) (gridControl as TreeGridControlEx).TreeListObj.ParentFieldName = model.SourceParentFieldName;
AttachCachedTask<DataTable>(dataCaches, billModuleModel,
"SourceCustomColumnByDatabase", gridControl,
"CustomColumnByDatabase");
gridControl.SetReadOnlyColumns(dtSourceColumns, GridCustomColumnStruct.BillSourceGridView + model.FormKey);
gridControl.SetGridRowColors(dtBaseGridRowColors);
//gridControl.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback);
@@ -1829,18 +1883,21 @@ namespace Lskj.PubBillConcise
{
gridControl.GridView.OptionsView.ShowAutoFilterRow = true;
}
if (!dataCaches.GetValue(gridControl, "SourceColumns", out DataTable dtSourceColumns))
if (!dataCaches.GetValue(billModuleModel, "SourceColumns", out DataTable dtSourceColumns))
{
dtSourceColumns = BillImpl.GetSourceColumns(model.Id);
}
if (!dataCaches.GetValue(gridControl, "BaseGridRowColors", out DataTable dtBaseGridRowColors))
if (!dataCaches.GetValue(billModuleModel, "SourceBaseGridRowColors", out DataTable dtBaseGridRowColors))
{
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey);
}
if (!dataCaches.GetValue(gridControl, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus))
if (!dataCaches.GetValue(billModuleModel, "SourceBaseGridRightMenus", out DataTable dtBaseGridRightMenus))
{
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey);
}
AttachCachedTask<DataTable>(dataCaches, billModuleModel,
"SourceCustomColumnByDatabase", gridControl,
"CustomColumnByDatabase");
gridControl.SetReadOnlyColumns(dtSourceColumns, GridCustomColumnStruct.BillSourceGridView + model.FormKey);
gridControl.SetGridRowColors(dtBaseGridRowColors);
gridControl.SetGridRightMenus(dtBaseGridRightMenus, this.SysModel, OnGridControlRightCallback);
@@ -1893,8 +1950,9 @@ namespace Lskj.PubBillConcise
DataRow[] detailColumns = detailTable.Select("sourceId=" + model.Id);
//明细为表格
GridControlEx gridDetail = new GridControlEx();
// 明细控件由下面的分支按实际类型创建,避免先构造一个
// 随即被替换、且无法进入父容器 Dispose 链的临时 GridControlEx。
GridControlEx gridDetail = null;
if (model.sourceDetailType.Equals("1"))
@@ -1903,12 +1961,15 @@ namespace Lskj.PubBillConcise
gridDetail = sourceDetailControl != null ? (TreeGridControlEx)sourceDetailControl : new TreeGridControlEx();
gridDetail.Model = this.SysModel;
gridDetail.Dock = DockStyle.Fill;
AttachCachedTask<DataTable>(dataCaches, billModuleModel,
"SourceDetailCustomColumnByDatabase", gridDetail,
"CustomColumnByDatabase");
gridDetail.SetReadOnlyColumns(detailColumns == null || detailColumns.Length == 0 ? new DataTable() : detailColumns.CopyToDataTable(), GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey);
if (!dataCaches.GetValue(gridDetail, "BaseGridRowColors", out DataTable dtBaseGridRowColors))
if (!dataCaches.GetValue(billModuleModel, "SourceDetailBaseGridRowColors", out DataTable dtBaseGridRowColors))
{
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey);
}
if (!dataCaches.GetValue(gridDetail, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus))
if (!dataCaches.GetValue(billModuleModel, "SourceDetailBaseGridRightMenus", out DataTable dtBaseGridRightMenus))
{
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey);
}
@@ -1940,17 +2001,20 @@ namespace Lskj.PubBillConcise
gridDetail = sourceDetailControl != null ? (GridControlEx)sourceDetailControl : new GridControlEx();
gridDetail.Model = this.SysModel;
gridDetail.Dock = DockStyle.Fill;
AttachCachedTask<DataTable>(dataCaches, billModuleModel,
"SourceDetailCustomColumnByDatabase", gridDetail,
"CustomColumnByDatabase");
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))
if (!dataCaches.GetValue(billModuleModel, "SourceDetailBaseGridRowColors", out DataTable dtBaseGridRowColors))
{
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey);
}
if (!dataCaches.GetValue(gridDetail, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus))
if (!dataCaches.GetValue(billModuleModel, "SourceDetailBaseGridRightMenus", out DataTable dtBaseGridRightMenus))
{
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey);
}
@@ -1966,14 +2030,17 @@ namespace Lskj.PubBillConcise
GridControlEx gridDetail_Details = sourceDetailDetailControl != null ? (GridControlEx)sourceDetailDetailControl : new GridControlEx();
gridDetail_Details.Model = this.SysModel;
gridDetail_Details.Dock = DockStyle.Fill;
AttachCachedTask<DataTable>(dataCaches, billModuleModel,
"SourceDetailDetailsCustomColumnByDatabase", gridDetail_Details,
"CustomColumnByDatabase");
//创建只读列
if (!dataCaches.GetValue(gridDetail_Details, "Detail_Details", out DataTable dataTable))
if (!dataCaches.GetValue(billModuleModel, "DetailDetails", out DataTable dataTable))
{
dataTable = BaseModuleImpl.getDetail_Details(model.FormKey);
}
gridDetail_Details.SetReadOnlyColumns(dataTable);
//设置右键
if (!dataCaches.GetValue(gridDetail_Details, "BaseGridRightMenus", out DataTable dttBaseGridRightMenus))
if (!dataCaches.GetValue(billModuleModel, "SourceDetailDetailsBaseGridRightMenus", out DataTable dttBaseGridRightMenus))
{
dttBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDTX_" + model.FormKey);
}
@@ -2092,9 +2159,23 @@ namespace Lskj.PubBillConcise
string searchSql = model.SourceType == 1 ? Regex.Replace(model.DetailSql, "{speciesno}", "", RegexOptions.IgnoreCase) : model.SourceSql;
//searchSql = ReplaceHelper.ReplaceParam(searchSql);
PanelControl searchPanel = new PanelControl();
if (!dataCaches.GetValue(sourceModelRow, "SearchControl", out MyControl searchControl))
MyControl searchControl = new MyControl(
searchSql,
gridControl == null ? gridDetail : gridControl,
treeView)
{
searchControl = new MyControl(searchSql, gridControl == null ? gridDetail : gridControl, treeView);
Model = this.SysModel,
OtherParams = this.SysModel.OtherParams()
};
if (dataCaches != null)
{
dataCaches.AddTask(searchControl, "DynamicModel",
new Task<DynamicModel>(() => this.SysModel));
dataCaches.AddTask(searchControl, "ControlsTable",
new Task<DataTable>(() => controls));
// 查询条件模型和默认值可以后台准备,编辑控件由
// InitSearchControl 在当前 UI 线程创建。
searchControl.GetSearchDataCaches(dataCaches);
}
searchControl.OnSearchBeforeCallBack += new SearchEventHandler(OnSearchBefore);
searchControl.OnSearchAfterCallBack += new EventHandler(OnSearchAfterd);
@@ -2132,6 +2213,21 @@ namespace Lskj.PubBillConcise
}
// Keep the actual UI-owned controls on the per-source record.
// This preserves reuse on a later source rebuild and gives
// disposal/debugging code an exact ownership list without
// traversing the visual tree.
billModuleModel.SourceModel = model;
billModuleModel.SourceControl = treeView ?? (object)gridControl;
billModuleModel.SourceDetailControl = gridDetail;
billModuleModel.SourceDetailDetailControl =
unionModel.GridDetailDetailControlObj;
lock (_billModuleModelSync)
{
if (!_moduleDisposed)
BillModuleModelDic[sourceModelRow] = billModuleModel;
}
unionModel.ModelObj = model;
@@ -3215,7 +3311,7 @@ namespace Lskj.PubBillConcise
if (pageControl.Tag is GridDetailModel detailModel && (detailModel.Orderid + "").Equals(movepage))
{
this.tb_buttom.TabControlObj.SelectedTabPage = xtraTabPage;
StaticControl.BomUnionPage = xtraTabPage;
StaticControl.SetBomUnionPage(xtraTabPage);
if (xtraTabPage.Tag is GridControlEx)
{
DataRow dataRow = this.gcMain.GetViewFocusedDataRow();
@@ -5157,7 +5253,7 @@ namespace Lskj.PubBillConcise
menu.ApplyBefore += new CommonToolApplyEventHandler(OnMenuApplyBefore);
menu.DynamicLinkAfter += new CommonToolAfterDynamicLinkEventHandler(OnDynamicLinkAfter);
StaticControl.RightMenuGridView = gcMain.GridView;
StaticControl.RightMenuMyControl = ControlObj;
StaticControl.SetRightMenuMyControl(ControlObj);
menu.Apply(menuRow);
if (!menu.issuccess)
{
+4 -3
View File
@@ -28,11 +28,12 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.txt_billDocumentId = new Lskj.Control.LabelTextEdit();
this.pl_right_bottom = new DevExpress.XtraEditors.PanelControl();
this.dpb_Tools = new DevExpress.XtraEditors.DropDownButton();
this.pMenu = new DevExpress.XtraBars.PopupMenu();
this.barManager1 = new DevExpress.XtraBars.BarManager();
this.pMenu = new DevExpress.XtraBars.PopupMenu(this.components);
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.barDockControlTop = new DevExpress.XtraBars.BarDockControl();
this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl();
this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl();
@@ -41,7 +42,7 @@
this.btnHelp = new DevExpress.XtraEditors.SimpleButton();
this.btnAtt = new DevExpress.XtraEditors.SimpleButton();
this.btnPrint = new DevExpress.XtraEditors.DropDownButton();
this.pMprint = new DevExpress.XtraBars.PopupMenu();
this.pMprint = new DevExpress.XtraBars.PopupMenu(this.components);
this.pl_right = new DevExpress.XtraEditors.PanelControl();
this.gridFlow = new Lskj.Control.GridControlEx();
this.label_flowRecord = new DevExpress.XtraEditors.LabelControl();
+7 -6
View File
@@ -28,16 +28,17 @@
/// </summary>
private void InitializeComponent()
{
this.barManager1 = new DevExpress.XtraBars.BarManager();
this.components = new System.ComponentModel.Container();
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
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.pmFP = new DevExpress.XtraBars.PopupMenu(this.components);
this.pmBillExp = new DevExpress.XtraBars.PopupMenu(this.components);
this.pmBill = new DevExpress.XtraBars.PopupMenu(this.components);
this.pMprint = new DevExpress.XtraBars.PopupMenu(this.components);
this.pMenu = new DevExpress.XtraBars.PopupMenu(this.components);
this.tb_buttom = new Lskj.Control.TabControlEx();
this.pl_Main = new DevExpress.XtraEditors.PanelControl();
this.xtc_main_container = new DevExpress.XtraTab.XtraTabControl();
+108 -111
View File
@@ -40,6 +40,24 @@ namespace Lskj.PubBillManagement
{
public partial class BillModule : UserControl
{
private static void AttachCachedTask<T>(
Dictionary<object, Hashtable> cachesDic,
object cacheOwner,
string cacheKey,
object control,
string controlKey)
{
if (cachesDic == null || cacheOwner == null || control == null ||
cachesDic.GetTask<T>(control, controlKey) != null)
{
return;
}
Task<T> task = cachesDic.GetTask<T>(cacheOwner, cacheKey);
if (task != null)
cachesDic.AddTask(control, controlKey, task);
}
/// <summary>
/// 是否为初始化创建
/// </summary>
@@ -418,12 +436,13 @@ namespace Lskj.PubBillManagement
}));
cachesDic.AddTask(tb_buttom, "DynamicModel", dynamicModelTask);
cachesDic.AddTask(tb_buttom, "Details", detailTask);
tb_buttom.GetDataCaches(cachesDic);
// TabControlEx.GetDataCaches 会创建 Grid、ModuleGrid、浏览器等
// WinForms/DevExpress 控件,延后到 InitializeBillSource
// 在 UI 线程执行。
Task<bool> initSourcesTask = cachesDic.AddTask(this, "InitSourcesTask", new Task<bool>(() =>
{
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];
@@ -434,137 +453,75 @@ namespace Lskj.PubBillManagement
{
return BaseModuleImpl.GetCustomQueryFields(model.FormKey);
}));
#region
GridControlEx gridControl = null;
TreeViewEx treeView = null;
// 后台阶段只加载数据,不构造任何 WinForms/DevExpress
// 对象。缓存以 BillModuleModel 为所有者,UI 创建实际
// 控件后再绑定需要的任务。
if (model.SourceType == 1)
{
// 来源为树类型
treeView = new TreeViewEx();
billModuleModel.SourceControl = treeView;
Task<DataTable> bindTreeTableTask = cachesDic.AddTask(treeView, "BindTreeTable", new Task<DataTable>(() =>
cachesDic.AddTask(billModuleModel, "BindTreeTable", new Task<DataTable>(() =>
{
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<DataTable> sourceColumnsTask = cachesDic.AddTask(gridControl, "SourceColumns", new Task<DataTable>(() =>
{
return BillImpl.GetSourceColumns(model.Id);
}));
Task<DataTable> sourceGridRowColorsTask = cachesDic.AddTask(gridControl, "BaseGridRowColors", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey);
}));
Task<DataTable> sourceGridRightMenusTask = cachesDic.AddTask(gridControl, "BaseGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey);
}));
}
else
{
// 来源为表格类型
gridControl = new GridControlEx();
billModuleModel.SourceControl = gridControl;
Task<DataTable> sourceColumnsTask = cachesDic.AddTask(gridControl, "SourceColumns", new Task<DataTable>(() =>
if (model.SourceType == 5)
model.ChangeSourceType(2);//单据来源显示条数
cachesDic.AddTask(billModuleModel, "SourceColumns", new Task<DataTable>(() =>
{
return BillImpl.GetSourceColumns(model.Id);
}));
//创建表格列
cachesDic.AddTask(gridControl, "DynamicModel", dynamicModelTask);
gridControl.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceGridView + model.FormKey);
Task<DataTable> sourceGridRowColorsTask = cachesDic.AddTask(gridControl, "BaseGridRowColors", new Task<DataTable>(() =>
cachesDic.AddTask(billModuleModel, "SourceCustomColumnByDatabase", new Task<DataTable>(() =>
{
return GridExtend.GetCustomColumnByDatabase(
GridCustomColumnStruct.BillSourceGridView + model.FormKey);
}));
cachesDic.AddTask(billModuleModel, "SourceBaseGridRowColors", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey);
}));
Task<DataTable> sourceGridRightMenusTask = cachesDic.AddTask(gridControl, "BaseGridRightMenus", new Task<DataTable>(() =>
cachesDic.AddTask(billModuleModel, "SourceBaseGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey);
}));
}
#endregion
#region
GridControlEx gridDetail = new GridControlEx();
if (model.sourceDetailType.Equals("1"))
if (string.IsNullOrWhiteSpace(model.DetailMenuCode))
{
//明细为树表格
gridDetail = new TreeGridControlEx();
billModuleModel.SourceDetailControl = gridDetail;
//创建表格列
cachesDic.AddTask(gridDetail, "DynamicModel", dynamicModelTask);
gridDetail.GetDataCaches(cachesDic, GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey);
Task<DataTable> detailGridRowColorsTask = cachesDic.AddTask(gridDetail, "BaseGridRowColors", new Task<DataTable>(() =>
cachesDic.AddTask(billModuleModel, "SourceDetailCustomColumnByDatabase", new Task<DataTable>(() =>
{
return GridExtend.GetCustomColumnByDatabase(
GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey);
}));
cachesDic.AddTask(billModuleModel, "SourceDetailBaseGridRowColors", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey);
}));
Task<DataTable> detailGridRightMenusTask = cachesDic.AddTask(gridDetail, "BaseGridRightMenus", new Task<DataTable>(() =>
cachesDic.AddTask(billModuleModel, "SourceDetailBaseGridRightMenus", new Task<DataTable>(() =>
{
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<DataTable> detailGridRowColorsTask = cachesDic.AddTask(gridDetail, "BaseGridRowColors", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey);
}));
Task<DataTable> detailGridRightMenusTask = cachesDic.AddTask(gridDetail, "BaseGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey);
}));
//明细的明细(明细分成左右2个)
if (!string.IsNullOrEmpty(model.SourceDetailsDetailsSql))
{
GridControlEx gridDetail_Details = new GridControlEx();
billModuleModel.SourceDetailDetailControl = gridDetail_Details;
//创建只读列
Task<DataTable> detailDetailsTask = cachesDic.AddTask(gridDetail_Details, "DetailDetails", new Task<DataTable>(() =>
cachesDic.AddTask(billModuleModel, "DetailDetails", new Task<DataTable>(() =>
{
return BaseModuleImpl.getDetail_Details(model.FormKey);
}));
//创建表格列
cachesDic.AddTask(gridDetail_Details, "DynamicModel", dynamicModelTask);
gridDetail_Details.GetDataCaches(cachesDic);
Task<DataTable> detailDetailsGridRightMenusTask = cachesDic.AddTask(gridDetail_Details, "BaseGridRightMenus", new Task<DataTable>(() =>
cachesDic.AddTask(billModuleModel, "SourceDetailDetailsCustomColumnByDatabase", new Task<DataTable>(() =>
{
return GridExtend.GetCustomColumnByDatabase(string.Empty);
}));
cachesDic.AddTask(billModuleModel, "SourceDetailDetailsBaseGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDTX_" + model.FormKey);
}));
}
}
#endregion
BillModuleModelDic.Add(sourceModelRow, billModuleModel);
#region
Task<MyControl> searchControlTask = cachesDic.AddTask(sourceModelRow, "SearchControl", new Task<MyControl>(() =>
{
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;
}));
@@ -713,6 +670,13 @@ namespace Lskj.PubBillManagement
this.xtc_main_container.TabPages.Clear();
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
if (dataCaches != null &&
dataCaches.GetTask<DynamicModel>(tb_buttom, "DynamicModel") != null &&
dataCaches.GetTask<List<GridDetailModel>>(tb_buttom, "Details") != null)
{
// 该方法会预创建附加页控件,必须在 UI 线程执行。
tb_buttom.GetDataCaches(dataCaches);
}
if (!dataCaches.GetValue(this, "Details", out List<GridDetailModel> attachModels))
{
attachModels = GetAttachTabs();
@@ -790,7 +754,7 @@ namespace Lskj.PubBillManagement
treeView.Dock = DockStyle.Fill;
treeView.TreeNodeKeyField = model.SourceKeyField;
treeView.TreeNodeTextField = model.SourceResult;
if (!dataCaches.GetValue(treeView, "BindTreeTable", out DataTable bindTreeTable))
if (!dataCaches.GetValue(billModuleModel, "BindTreeTable", out DataTable bindTreeTable))
{
bindTreeTable = BaseImpl.GetDataTableResult(model.SourceSql);
}
@@ -814,15 +778,18 @@ namespace Lskj.PubBillManagement
gridControl.BorderStyle = System.Windows.Forms.BorderStyle.None;
gridControl.Model = this.SysModel;
if (!dataCaches.GetValue(gridControl, "SourceColumns", out DataTable dtSourceColumns))
AttachCachedTask<DataTable>(dataCaches, billModuleModel,
"SourceCustomColumnByDatabase", gridControl,
"CustomColumnByDatabase");
if (!dataCaches.GetValue(billModuleModel, "SourceColumns", out DataTable dtSourceColumns))
{
dtSourceColumns = BillImpl.GetSourceColumns(model.Id);
}
if (!dataCaches.GetValue(gridControl, "BaseGridRowColors", out DataTable dtBaseGridRowColors))
if (!dataCaches.GetValue(billModuleModel, "SourceBaseGridRowColors", out DataTable dtBaseGridRowColors))
{
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey);
}
if (!dataCaches.GetValue(gridControl, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus))
if (!dataCaches.GetValue(billModuleModel, "SourceBaseGridRightMenus", out DataTable dtBaseGridRightMenus))
{
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey);
}
@@ -855,19 +822,22 @@ namespace Lskj.PubBillManagement
gridControl.Dock = DockStyle.Fill;
gridControl.ExportPermission = this.BillModel.ExportPermission;
AttachCachedTask<DataTable>(dataCaches, billModuleModel,
"SourceCustomColumnByDatabase", gridControl,
"CustomColumnByDatabase");
if (model.LoadFilter)
{
gridControl.GridView.OptionsView.ShowAutoFilterRow = true;
}
if (!dataCaches.GetValue(gridControl, "SourceColumns", out DataTable dtSourceColumns))
if (!dataCaches.GetValue(billModuleModel, "SourceColumns", out DataTable dtSourceColumns))
{
dtSourceColumns = BillImpl.GetSourceColumns(model.Id);
}
if (!dataCaches.GetValue(gridControl, "BaseGridRowColors", out DataTable dtBaseGridRowColors))
if (!dataCaches.GetValue(billModuleModel, "SourceBaseGridRowColors", out DataTable dtBaseGridRowColors))
{
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("BILLSOURCE_" + model.FormKey);
}
if (!dataCaches.GetValue(gridControl, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus))
if (!dataCaches.GetValue(billModuleModel, "SourceBaseGridRightMenus", out DataTable dtBaseGridRightMenus))
{
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCE_" + model.FormKey);
}
@@ -979,12 +949,15 @@ namespace Lskj.PubBillManagement
gridDetail = sourceDetailControl != null ? (TreeGridControlEx)sourceDetailControl : new TreeGridControlEx();
gridDetail.Model = this.SysModel;
gridDetail.Dock = DockStyle.Fill;
AttachCachedTask<DataTable>(dataCaches, billModuleModel,
"SourceDetailCustomColumnByDatabase", gridDetail,
"CustomColumnByDatabase");
gridDetail.SetReadOnlyColumns(detailColumns == null || detailColumns.Length == 0 ? new DataTable() : detailColumns.CopyToDataTable(), GridCustomColumnStruct.BillSourceDetailGridView + model.FormKey);
if (!dataCaches.GetValue(gridDetail, "BaseGridRowColors", out DataTable dtBaseGridRowColors))
if (!dataCaches.GetValue(billModuleModel, "SourceDetailBaseGridRowColors", out DataTable dtBaseGridRowColors))
{
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey);
}
if (!dataCaches.GetValue(gridDetail, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus))
if (!dataCaches.GetValue(billModuleModel, "SourceDetailBaseGridRightMenus", out DataTable dtBaseGridRightMenus))
{
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey);
}
@@ -1012,17 +985,20 @@ namespace Lskj.PubBillManagement
gridDetail = sourceDetailControl != null ? (GridControlEx)sourceDetailControl : new GridControlEx();
gridDetail.Model = this.SysModel;
gridDetail.Dock = DockStyle.Fill;
AttachCachedTask<DataTable>(dataCaches, billModuleModel,
"SourceDetailCustomColumnByDatabase", gridDetail,
"CustomColumnByDatabase");
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))
if (!dataCaches.GetValue(billModuleModel, "SourceDetailBaseGridRowColors", out DataTable dtBaseGridRowColors))
{
dtBaseGridRowColors = BaseModuleImpl.GetBaseGridRowColors("SOURCEDETAIL_" + model.FormKey);
}
if (!dataCaches.GetValue(gridDetail, "BaseGridRightMenus", out DataTable dtBaseGridRightMenus))
if (!dataCaches.GetValue(billModuleModel, "SourceDetailBaseGridRightMenus", out DataTable dtBaseGridRightMenus))
{
dtBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDT_" + model.FormKey);
}
@@ -1036,13 +1012,16 @@ namespace Lskj.PubBillManagement
gridDetail_Details.Model = this.SysModel;
gridDetail_Details.Dock = DockStyle.Fill;
//创建只读列
if (!dataCaches.GetValue(gridDetail_Details, "Detail_Details", out DataTable dataTable))
if (!dataCaches.GetValue(billModuleModel, "DetailDetails", out DataTable dataTable))
{
dataTable = BaseModuleImpl.getDetail_Details(model.FormKey);
}
AttachCachedTask<DataTable>(dataCaches, billModuleModel,
"SourceDetailDetailsCustomColumnByDatabase",
gridDetail_Details, "CustomColumnByDatabase");
gridDetail_Details.SetReadOnlyColumns(dataTable);
//设置右键
if (!dataCaches.GetValue(gridDetail_Details, "BaseGridRightMenus", out DataTable dttBaseGridRightMenus))
if (!dataCaches.GetValue(billModuleModel, "SourceDetailDetailsBaseGridRightMenus", out DataTable dttBaseGridRightMenus))
{
dttBaseGridRightMenus = BaseModuleImpl.GetBaseGridRightMenus("BILLSOURCEDTX_" + model.FormKey);
}
@@ -1073,6 +1052,7 @@ namespace Lskj.PubBillManagement
splitContainerControl.Parent = tabDetail;
unionModel.GridDetailDetailControlObj = gridDetail_Details;
billModuleModel.SourceDetailDetailControl = gridDetail_Details;
}
else
{
@@ -1103,6 +1083,11 @@ namespace Lskj.PubBillManagement
#endregion
billModuleModel.SourceControl =
treeView != null ? (object)treeView : gridControl;
billModuleModel.SourceDetailControl = gridDetail;
BillModuleModelDic[sourceModelRow] = billModuleModel;
#region
if (model.SourceType == 1 && (controls == null || controls.Rows.Count == 0))
{
@@ -1123,9 +1108,21 @@ namespace Lskj.PubBillManagement
// 创建自定义条件
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))
MyControl searchControl =
new MyControl(searchSql,
gridControl == null ? gridDetail : gridControl,
treeView)
{
searchControl = new MyControl(searchSql, gridControl == null ? gridDetail : gridControl, treeView);
Model = this.SysModel,
OtherParams = this.SysModel.OtherParams()
};
if (dataCaches != null)
{
dataCaches.AddTask(searchControl, "DynamicModel",
new Task<DynamicModel>(() => this.SysModel));
dataCaches.AddTask(searchControl, "ControlsTable",
new Task<DataTable>(() => controls));
searchControl.GetSearchDataCaches(dataCaches);
}
searchControl.OnSearchBeforeCallBack += new SearchEventHandler(OnSearchBefore);
searchControl.OnSearchAfterCallBack += new EventHandler(OnSearchAfterd);
+1 -1
View File
@@ -3529,7 +3529,7 @@ namespace Lskj.PubBillManagement
menu.DynamicLinkAfter += new CommonToolAfterDynamicLinkEventHandler(OnDynamicLinkAfter);
StaticControl.RightMenuGridView = gcMain.GridView;
StaticControl.Comprefix = this.BillModel.DetailPreFix;
StaticControl.RightMenuMyControl = ControlObj;
StaticControl.SetRightMenuMyControl(ControlObj);
menu.Apply(menuRow);
if (!menu.issuccess)
{
+6 -5
View File
@@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.ssc_main = new DevExpress.XtraEditors.SplitContainerControl();
this.ssc_main_top = new DevExpress.XtraEditors.SplitContainerControl();
this.pl_left = new DevExpress.XtraEditors.PanelControl();
@@ -40,7 +41,7 @@
this.pl_treeview_detault_search = new DevExpress.XtraEditors.PanelControl();
this.panelControl4 = new DevExpress.XtraEditors.PanelControl();
this.textEdit1 = new DevExpress.XtraEditors.TextEdit();
this.barManager1 = new DevExpress.XtraBars.BarManager();
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.barDockControl1 = new DevExpress.XtraBars.BarDockControl();
this.barDockControl2 = new DevExpress.XtraBars.BarDockControl();
this.barDockControl3 = new DevExpress.XtraBars.BarDockControl();
@@ -60,15 +61,15 @@
this.labelControl2 = new DevExpress.XtraEditors.LabelControl();
this.btn_input = new DevExpress.XtraEditors.SimpleButton();
this.dpbImport = new DevExpress.XtraEditors.DropDownButton();
this.pmBillExp = new DevExpress.XtraBars.PopupMenu();
this.pmBillExp = new DevExpress.XtraBars.PopupMenu(this.components);
this.btnBillAdd = new DevExpress.XtraEditors.SimpleButton();
this.btnBillApply = new DevExpress.XtraEditors.SimpleButton();
this.dpCopyBill = new DevExpress.XtraEditors.DropDownButton();
this.pmBill = new DevExpress.XtraBars.PopupMenu();
this.pmBill = new DevExpress.XtraBars.PopupMenu(this.components);
this.btnPrint = new DevExpress.XtraEditors.DropDownButton();
this.pMprint = new DevExpress.XtraBars.PopupMenu();
this.pMprint = new DevExpress.XtraBars.PopupMenu(this.components);
this.dpbTools = new DevExpress.XtraEditors.DropDownButton();
this.pMenu = new DevExpress.XtraBars.PopupMenu();
this.pMenu = new DevExpress.XtraBars.PopupMenu(this.components);
this.btnDelete = new DevExpress.XtraEditors.SimpleButton();
this.btnBillSave = new DevExpress.XtraEditors.SimpleButton();
this.pl_main_top = new DevExpress.XtraEditors.PanelControl();
+7 -6
View File
@@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.ssc_main = new DevExpress.XtraEditors.SplitContainerControl();
this.ssc_main_top = new DevExpress.XtraEditors.SplitContainerControl();
this.pl_main = new DevExpress.XtraEditors.PanelControl();
@@ -40,7 +41,7 @@
this.pl_treeview_detault_search = new DevExpress.XtraEditors.PanelControl();
this.panelControl4 = new DevExpress.XtraEditors.PanelControl();
this.textEdit1 = new DevExpress.XtraEditors.TextEdit();
this.barManager1 = new DevExpress.XtraBars.BarManager();
this.barManager1 = new DevExpress.XtraBars.BarManager(this.components);
this.barDockControl1 = new DevExpress.XtraBars.BarDockControl();
this.barDockControl2 = new DevExpress.XtraBars.BarDockControl();
this.barDockControl3 = new DevExpress.XtraBars.BarDockControl();
@@ -74,11 +75,11 @@
this.rdRed = new System.Windows.Forms.RadioButton();
this.pl_blue = new DevExpress.XtraEditors.PanelControl();
this.rdBlue = new System.Windows.Forms.RadioButton();
this.pMprint = new DevExpress.XtraBars.PopupMenu();
this.pmFP = new DevExpress.XtraBars.PopupMenu();
this.pmBillExp = new DevExpress.XtraBars.PopupMenu();
this.pmBill = new DevExpress.XtraBars.PopupMenu();
this.pMenu = new DevExpress.XtraBars.PopupMenu();
this.pMprint = new DevExpress.XtraBars.PopupMenu(this.components);
this.pmFP = new DevExpress.XtraBars.PopupMenu(this.components);
this.pmBillExp = new DevExpress.XtraBars.PopupMenu(this.components);
this.pmBill = new DevExpress.XtraBars.PopupMenu(this.components);
this.pMenu = new DevExpress.XtraBars.PopupMenu(this.components);
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.backgroundWorker2 = new System.ComponentModel.BackgroundWorker();
((System.ComponentModel.ISupportInitialize)(this.ssc_main)).BeginInit();
+12 -10
View File
@@ -431,15 +431,8 @@ namespace Lskj.PubBillSpecial
//if (billModel.CenterMain) dataTable = this.SetControlMargins(dataTable);
return dataTable;
}));
Task<MyControl> controlObjTask = cachesDic.AddTask(this, "ControlObj", new Task<MyControl>(() =>
{
MyControl myControl = new MyControl() { Model = dynamicModel };
myControl.OtherParams = dynamicModel.OtherParams();
cachesDic.AddTask(myControl, "DynamicModel", dynamicModelTask);
cachesDic.AddTask(myControl, "ControlsTable", controlLocationTask);
myControl.GetControlDataCaches(cachesDic);
return myControl;//主表控件
}));
// MyControl 持有 WinForms Timer。后台阶段只加载控件配置,
// 实际 MyControl 及编辑控件由 InitializeBillInfo 在 UI 线程创建。
Task<DataTable> addGroupDataTask = cachesDic.AddTask(this, "AddGroupData", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetAddGroupData(billModel.FormKey);//获取主信息分组数据
@@ -940,6 +933,15 @@ namespace Lskj.PubBillSpecial
if (!dataCaches.GetValue(this, "ControlObj", out ControlObj))
{
this.ControlObj = new MyControl() { Model = SysModel };//主表控件
this.ControlObj.OtherParams = this.SysModel.OtherParams();
if (dataCaches != null)
{
dataCaches.AddTask(this.ControlObj, "DynamicModel",
new Task<DynamicModel>(() => this.SysModel));
dataCaches.AddTask(this.ControlObj, "ControlsTable",
new Task<DataTable>(() => controls));
this.ControlObj.GetControlDataCaches(dataCaches);
}
}
@@ -3849,7 +3851,7 @@ namespace Lskj.PubBillSpecial
menu.ApplyBefore += new CommonToolApplyEventHandler(OnMenuApplyBefore);
menu.DynamicLinkAfter += new CommonToolAfterDynamicLinkEventHandler(OnDynamicLinkAfter);
StaticControl.RightMenuGridView = gcMain.GridView;
StaticControl.RightMenuMyControl = ControlObj;
StaticControl.SetRightMenuMyControl(ControlObj);
menu.Apply(menuRow);
if (!menu.issuccess)
{
-23
View File
@@ -33,31 +33,8 @@ namespace Lskj.PubBrower
this.SubForm = main;
this.SubForm.Text = moduleModel.FormText;
main.PubBrowerModel = moduleModel;
// CEF must be created after the caller has established the final
// WinForms owner/parent hierarchy and the form HWND exists.
if (moduleModel.downLoadFlag == 1)
{
main.OnLoad();
}
else
{
EventHandler shown = null;
shown = delegate
{
main.Shown -= shown;
try
{
main.OnLoad();
}
catch (Exception ex)
{
LogUtil.WriteError("Lskj.PubBrower.dll--初始化错误-->" + obj.ToString(), ex);
}
};
main.Shown += shown;
}
}
catch (Exception ex)
{
LogUtil.WriteError("Lskj.PubBrower.dll--参数错误-->" + obj.ToString(), ex);

Some files were not shown because too many files have changed in this diff Show More