diff --git a/插件库/Lskj.Main/FrmConfig.cs b/插件库/Lskj.Main/FrmConfig.cs
index 2493806..1edfe74 100644
--- a/插件库/Lskj.Main/FrmConfig.cs
+++ b/插件库/Lskj.Main/FrmConfig.cs
@@ -205,4 +205,6 @@ namespace Lskj.Main
{
if (DBConfig.Instance.CreateConnection())
{
- if (Del
\ No newline at end of file
+ if (!DBConfig.Instance.ServerType.Equals("达梦数据库"))
+ {
+ if (DelphiHelper.Delphi_Init(new StringBuilder(DBConfig.Instance.Get
\ No newline at end of file
diff --git a/插件库/Lskj.Main/FrmConfigLocal.cs b/插件库/Lskj.Main/FrmConfigLocal.cs
index e3b7bc8..7c7dca2 100644
--- a/插件库/Lskj.Main/FrmConfigLocal.cs
+++ b/插件库/Lskj.Main/FrmConfigLocal.cs
@@ -233,11 +233,15 @@ namespace Lskj.Main
DBConfig.Instance.Connection = Connection;
if (DBConfig.Instance.CreateConnection(Connection))
{
- if (DelphiHelper.Delphi_Init(new StringBuilder(DBConfig.Instance.GetDelphiConnection(DBConfig.Instance.dephiConnection))) == 0)
+ if (!DBConfig.Instance.ServerType.Equals("达梦数据库"))
{
- MessageUtil.Show(ResourceKeys.UnConnectServer + "[By Delphi]");
- return;
+ if (DelphiHelper.Delphi_Init(new StringBuilder(DBConfig.Instance.GetDelphiConnection(DBConfig.Instance.dephiConnection))) == 0)
+ {
+ MessageUtil.Show(ResourceKeys.UnConnectServer + "[By Delphi]");
+ return;
+ }
}
+
if (isSave)
{
if (!string.IsNullOrEmpty(this.txtZTName.Text))
@@ -251,34 +255,4 @@ namespace Lskj.Main
DBConfig.Instance.WriteConfig("LocalLastIP", this.txtIP.Text);
DBConfig.Instance.WriteConfig("LocalLastPort", this.txtPort.Text);
DBConfig.Instance.WriteConfig("LocalLastPortName", this.txtZTName.Text);
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else
- {
- MessageUtil.Show("请设置账套名!");
- }
- }
- else
- {
- MessageUtil.Show(ResourceKeys.ConnectSuccess);
- }
- }
- else
- {
- MessageUtil.Show(ResourceKeys.ConnectFault);
- }
- }
- else
- {
- MessageUtil.Show(ResourceKeys.ConnectFault);
- }
- //IniHelper.Write("SystemResources.ini", "FrmConfigFlag", "1");
- }
- catch (Exception)
- {
- MessageUtil.Show(ResourceKeys.ConnectFault);
- }
- }
- }
-}
+ t
\ No newline at end of file
diff --git a/插件库/Lskj.Main/FrmMain.cs b/插件库/Lskj.Main/FrmMain.cs
index d05e1e5..ef169d2 100644
--- a/插件库/Lskj.Main/FrmMain.cs
+++ b/插件库/Lskj.Main/FrmMain.cs
@@ -220,8 +220,10 @@ namespace Lskj.Main
///
private void FrmMain_LocationChanged(object sender, EventArgs e)
{
- ERPInfo.Instance.WatermarkForm.Size = this.ClientSize; // 设置水印窗体的大小与主窗体客户端区域相同
- ERPInfo.Instance.WatermarkForm.Location = this.PointToScreen(new Point(0, 0)); // 将水印窗体定位到主窗体的位置
+ if (!IsWatermarkAvailable()) return;
+
+ watermarkForm.Size = this.ClientSize; // 设置水印窗体的大小与主窗体客户端区域相同
+ watermarkForm.Location = this.PointToScreen(new Point(0, 0)); // 将水印窗体定位到主窗体的位置
}
///
@@ -233,6 +235,8 @@ namespace Lskj.Main
{
if (SystemInfo.Instance.DisplayWatermark)
{
+ if (!IsWatermarkAvailable()) return;
+
if (ERPInfo.Instance.MainControl.WindowState == FormWindowState.Minimized) watermarkForm.Visible = false;
if (ERPInfo.Instance.MainControl.WindowState != FormWindowState.Minimized)
@@ -244,6 +248,28 @@ namespace Lskj.Main
}
}
+
+ private bool IsWatermarkAvailable()
+ {
+ return watermarkForm != null && !watermarkForm.IsDisposed && !watermarkForm.Disposing;
+ }
+
+ private void CloseWatermarkForm()
+ {
+ this.SizeChanged -= FrmMain_SizeChanged;
+
+ if (IsWatermarkAvailable())
+ {
+ watermarkForm.SafeClose();
+ if (!watermarkForm.IsDisposed)
+ {
+ watermarkForm.Dispose();
+ }
+ }
+
+ watermarkForm = null;
+ ERPInfo.Instance.WatermarkForm = null;
+ }
///
/// U盾状态改变
///
@@ -427,11 +453,7 @@ namespace Lskj.Main
///
private void OnCloseButtonCallBack(object sender, EventArgs e)
{
- if (ERPInfo.Instance.WatermarkForm != null)
- {
- ERPInfo.Instance.WatermarkForm.Close();
- ERPInfo.Instance.WatermarkForm.Dispose();
- }
+ CloseWatermarkForm();
this.Close();
}
///
@@ -511,6 +533,7 @@ namespace Lskj.Main
{
try
{
+ CloseWatermarkForm();
Manager.ModuleForms.Clear();
}
catch (Exception ex)
@@ -732,4 +755,4 @@ namespace Lskj.Main
Screen screen = Screen.FromPoint(System.Windows.Forms.Control.MousePosition);
Rectangle workingArea = screen.WorkingArea;
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/插件库/Lskj.Main/FrmSubSystem.resx b/插件库/Lskj.Main/FrmSubSystem.resx
index 59c8e72..b728498 100644
--- a/插件库/Lskj.Main/FrmSubSystem.resx
+++ b/插件库/Lskj.Main/FrmSubSystem.resx
@@ -132,10 +132,31 @@
True
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
True
-
+
True
@@ -158,9 +179,6 @@
sQPqAAAAAElFTkSuQmCC
-
- True
-
True
diff --git a/插件库/Lskj.Main/FrmWatermark.cs b/插件库/Lskj.Main/FrmWatermark.cs
index 473f6fe..88d55ac 100644
--- a/插件库/Lskj.Main/FrmWatermark.cs
+++ b/插件库/Lskj.Main/FrmWatermark.cs
@@ -18,6 +18,7 @@ namespace Lskj.Main
{
// 保存主窗体引用,用于同步位置和大小
private Form _mainForm;
+ private bool _eventsDetached;
public FrmWatermark(Form mainForm)
{
@@ -35,6 +36,7 @@ namespace Lskj.Main
this.Opacity = 0.3;
//重绘界面,绘制水印
this.Paint += FrmWatermark_Paint;
+ this.Disposed += FrmWatermark_Disposed;
// 监听主窗体的移动和大小变化(关键修复)
@@ -54,18 +56,21 @@ namespace Lskj.Main
// 主窗体位置变化时同步水印位置
private void MainForm_LocationChanged(object sender, EventArgs e)
{
+ if (IsUnavailable()) return;
SyncPositionAndSize();
}
// 主窗体大小变化时同步水印大小和位置
private void MainForm_SizeChanged(object sender, EventArgs e)
{
+ if (IsUnavailable()) return;
SyncPositionAndSize();
}
// 主窗体显示状态变化时同步
private void MainForm_VisibleChanged(object sender, EventArgs e)
{
+ if (IsUnavailable()) return;
this.Visible = _mainForm.Visible;
if (_mainForm.Visible)
{
@@ -77,13 +82,13 @@ namespace Lskj.Main
// 主窗体关闭时同步关闭水印
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
- this.Close();
+ SafeClose();
}
// 同步水印窗体与主窗体的位置和大小
private void SyncPositionAndSize()
{
- if (_mainForm == null || _mainForm.IsDisposed) return;
+ if (IsUnavailable()) return;
// 关键修复:在多屏幕环境下正确计算位置
this.Size = _mainForm.ClientSize;
@@ -100,6 +105,45 @@ namespace Lskj.Main
this.Invalidate();
}
+ public void SafeClose()
+ {
+ if (this.IsDisposed || this.Disposing)
+ return;
+
+ DetachMainFormEvents();
+ this.Close();
+ }
+
+ private bool IsUnavailable()
+ {
+ return this.IsDisposed || this.Disposing || _mainForm == null || _mainForm.IsDisposed || _mainForm.Disposing;
+ }
+
+ private void DetachMainFormEvents()
+ {
+ if (_eventsDetached || _mainForm == null)
+ return;
+
+ _mainForm.LocationChanged -= MainForm_LocationChanged;
+ _mainForm.SizeChanged -= MainForm_SizeChanged;
+ _mainForm.VisibleChanged -= MainForm_VisibleChanged;
+ _mainForm.FormClosing -= MainForm_FormClosing;
+ _eventsDetached = true;
+ }
+
+ protected override void OnFormClosed(FormClosedEventArgs e)
+ {
+ DetachMainFormEvents();
+ _mainForm = null;
+ base.OnFormClosed(e);
+ }
+
+ private void FrmWatermark_Disposed(object sender, EventArgs e)
+ {
+ DetachMainFormEvents();
+ _mainForm = null;
+ }
+
private void FrmWatermark_Paint(object sender, PaintEventArgs e)
{
try
diff --git a/插件库/Lskj.Main/Lskj.Main.csproj b/插件库/Lskj.Main/Lskj.Main.csproj
index b64dd95..1bc8efc 100644
--- a/插件库/Lskj.Main/Lskj.Main.csproj
+++ b/插件库/Lskj.Main/Lskj.Main.csproj
@@ -14,6 +14,9 @@
512
+ false
+
+
发布\
true
Disk
@@ -26,11 +29,8 @@
true
0
1.0.0.%2a
- false
false
true
-
-
x86
@@ -77,9 +77,14 @@
False
..\..\引用DLL\libzkfpcsharp.dll
+
+ False
+ ..\..\引用DLL\Lskj.Web.Core.dll
+
+
@@ -100,6 +105,12 @@
AwaitScreenControl.cs
+
+ Component
+
+
+ BackgroundPanel.cs
+
UserControl
@@ -130,6 +141,12 @@
Menu_Item.cs
+
+ UserControl
+
+
+ Menu_ItemNew.cs
+
UserControl
@@ -264,6 +281,9 @@
AwaitScreenControl.cs
+
+ BackgroundPanel.cs
+
CornerLab.cs
@@ -279,6 +299,9 @@
Menu_Item.cs
+
+ Menu_ItemNew.cs
+
ResSelectForm.cs
@@ -345,19 +368,20 @@
ResXFileCodeGenerator
- Resources.Designer.cs
Designer
+ Resources.Designer.cs
-
- True
- Resources.resx
- True
-
+
SettingsSingleFileGenerator
Settings.Designer.cs
+
+ True
+ True
+ Resources.resx
+
True
Settings.settings
@@ -365,10 +389,16 @@
+
+ PreserveNewest
+
+
+
+
@@ -542,7 +572,7 @@
-
+