diff --git a/Correlator.sln b/Correlator.sln
index 687debd..02122b1 100644
--- a/Correlator.sln
+++ b/Correlator.sln
@@ -5,7 +5,7 @@
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Correlator", "Correlator\Correlator.csproj", "{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}"
EndProject
-Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "相关仪", "..\..\..\..\Setup Project\相关仪\相关仪.vdproj", "{13A08909-E201-42D6-B44E-2FFD8A900B79}"
+Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "相关仪", "..\..\..\..\Setup Project\相关仪\相关仪.vdproj", "{6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -23,10 +23,10 @@
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|Any CPU.Build.0 = Release|Any CPU
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.ActiveCfg = Release|x64
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.Build.0 = Release|x64
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Debug|Any CPU.ActiveCfg = Debug
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Debug|x64.ActiveCfg = Debug
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Release|Any CPU.ActiveCfg = Release
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Release|x64.ActiveCfg = Release
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Debug|Any CPU.ActiveCfg = Debug
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Debug|x64.ActiveCfg = Debug
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Release|Any CPU.ActiveCfg = Release
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Release|x64.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Correlator.sln b/Correlator.sln
index 687debd..02122b1 100644
--- a/Correlator.sln
+++ b/Correlator.sln
@@ -5,7 +5,7 @@
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Correlator", "Correlator\Correlator.csproj", "{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}"
EndProject
-Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "相关仪", "..\..\..\..\Setup Project\相关仪\相关仪.vdproj", "{13A08909-E201-42D6-B44E-2FFD8A900B79}"
+Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "相关仪", "..\..\..\..\Setup Project\相关仪\相关仪.vdproj", "{6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -23,10 +23,10 @@
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|Any CPU.Build.0 = Release|Any CPU
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.ActiveCfg = Release|x64
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.Build.0 = Release|x64
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Debug|Any CPU.ActiveCfg = Debug
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Debug|x64.ActiveCfg = Debug
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Release|Any CPU.ActiveCfg = Release
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Release|x64.ActiveCfg = Release
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Debug|Any CPU.ActiveCfg = Debug
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Debug|x64.ActiveCfg = Debug
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Release|Any CPU.ActiveCfg = Release
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Release|x64.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Correlator/Service/ISoundSpeedDataService.cs b/Correlator/Service/ISoundSpeedDataService.cs
index d2320ac..38408cf 100644
--- a/Correlator/Service/ISoundSpeedDataService.cs
+++ b/Correlator/Service/ISoundSpeedDataService.cs
@@ -15,5 +15,9 @@
///
///
void UpdatePipeMaterial(string materialName, MaterialVelocity velocity);
+
+ void InsertVelocity(string materialName, string minDiameter, string maxDiameter, string soundSpeed);
+
+ void UpdateVelocity(MaterialVelocity velocity, string minDiameter, string maxDiameter, string soundSpeed);
}
}
\ No newline at end of file
diff --git a/Correlator.sln b/Correlator.sln
index 687debd..02122b1 100644
--- a/Correlator.sln
+++ b/Correlator.sln
@@ -5,7 +5,7 @@
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Correlator", "Correlator\Correlator.csproj", "{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}"
EndProject
-Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "相关仪", "..\..\..\..\Setup Project\相关仪\相关仪.vdproj", "{13A08909-E201-42D6-B44E-2FFD8A900B79}"
+Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "相关仪", "..\..\..\..\Setup Project\相关仪\相关仪.vdproj", "{6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -23,10 +23,10 @@
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|Any CPU.Build.0 = Release|Any CPU
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.ActiveCfg = Release|x64
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.Build.0 = Release|x64
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Debug|Any CPU.ActiveCfg = Debug
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Debug|x64.ActiveCfg = Debug
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Release|Any CPU.ActiveCfg = Release
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Release|x64.ActiveCfg = Release
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Debug|Any CPU.ActiveCfg = Debug
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Debug|x64.ActiveCfg = Debug
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Release|Any CPU.ActiveCfg = Release
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Release|x64.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Correlator/Service/ISoundSpeedDataService.cs b/Correlator/Service/ISoundSpeedDataService.cs
index d2320ac..38408cf 100644
--- a/Correlator/Service/ISoundSpeedDataService.cs
+++ b/Correlator/Service/ISoundSpeedDataService.cs
@@ -15,5 +15,9 @@
///
///
void UpdatePipeMaterial(string materialName, MaterialVelocity velocity);
+
+ void InsertVelocity(string materialName, string minDiameter, string maxDiameter, string soundSpeed);
+
+ void UpdateVelocity(MaterialVelocity velocity, string minDiameter, string maxDiameter, string soundSpeed);
}
}
\ No newline at end of file
diff --git a/Correlator/ServiceImpl/SoundSpeedDataService.cs b/Correlator/ServiceImpl/SoundSpeedDataService.cs
index 671c2d9..1d79b46 100644
--- a/Correlator/ServiceImpl/SoundSpeedDataService.cs
+++ b/Correlator/ServiceImpl/SoundSpeedDataService.cs
@@ -1,8 +1,12 @@
-using System.Collections.ObjectModel;
+using System;
+using System.Collections.ObjectModel;
+using System.Text.RegularExpressions;
+using System.Windows;
using Correlator.Model;
using Correlator.Service;
using Correlator.Util;
using Newtonsoft.Json;
+using MessageBox = HandyControl.Controls.MessageBox;
namespace Correlator.ServiceImpl
{
@@ -49,5 +53,97 @@
manager.Update(materialModel);
}
}
+
+ public void InsertVelocity(string materialName, string minDiameter, string maxDiameter, string soundSpeed)
+ {
+ if (string.IsNullOrEmpty(minDiameter) || string.IsNullOrEmpty(maxDiameter) ||
+ string.IsNullOrEmpty(soundSpeed))
+ {
+ MessageBox.Show("不允许为空", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(minDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("管径输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(maxDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("管径输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (int.Parse(minDiameter) > int.Parse(maxDiameter))
+ {
+ MessageBox.Show("管径下限不能大于管径上限", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(soundSpeed, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("速度输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ using (var manager = new DataBaseManager())
+ {
+ var velocity = new MaterialVelocity
+ {
+ MaterialName = materialName,
+ LowDiameter = Convert.ToInt32(minDiameter),
+ HighDiameter = Convert.ToInt32(maxDiameter),
+ Velocity = Convert.ToInt32(soundSpeed)
+ };
+ manager.Insert(velocity);
+ }
+ }
+
+ public void UpdateVelocity(MaterialVelocity velocity, string minDiameter, string maxDiameter, string soundSpeed)
+ {
+ if (string.IsNullOrEmpty(minDiameter) || string.IsNullOrEmpty(maxDiameter) ||
+ string.IsNullOrEmpty(soundSpeed))
+ {
+ MessageBox.Show("不允许为空", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(minDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("管径输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(maxDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("管径输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (int.Parse(minDiameter) > int.Parse(maxDiameter))
+ {
+ MessageBox.Show("管径下限不能大于管径上限", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(soundSpeed, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("速度输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ using (var manager = new DataBaseManager())
+ {
+ velocity.LowDiameter = Convert.ToInt32(minDiameter);
+ velocity.HighDiameter = Convert.ToInt32(maxDiameter);
+ velocity.Velocity = Convert.ToInt32(soundSpeed);
+
+ LogWithConsole.WriteLine("正在修改的管材是:" + JsonConvert.SerializeObject(velocity),
+ "SoundSpeedDataService");
+
+ manager.Update(velocity);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Correlator.sln b/Correlator.sln
index 687debd..02122b1 100644
--- a/Correlator.sln
+++ b/Correlator.sln
@@ -5,7 +5,7 @@
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Correlator", "Correlator\Correlator.csproj", "{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}"
EndProject
-Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "相关仪", "..\..\..\..\Setup Project\相关仪\相关仪.vdproj", "{13A08909-E201-42D6-B44E-2FFD8A900B79}"
+Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "相关仪", "..\..\..\..\Setup Project\相关仪\相关仪.vdproj", "{6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -23,10 +23,10 @@
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|Any CPU.Build.0 = Release|Any CPU
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.ActiveCfg = Release|x64
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.Build.0 = Release|x64
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Debug|Any CPU.ActiveCfg = Debug
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Debug|x64.ActiveCfg = Debug
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Release|Any CPU.ActiveCfg = Release
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Release|x64.ActiveCfg = Release
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Debug|Any CPU.ActiveCfg = Debug
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Debug|x64.ActiveCfg = Debug
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Release|Any CPU.ActiveCfg = Release
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Release|x64.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Correlator/Service/ISoundSpeedDataService.cs b/Correlator/Service/ISoundSpeedDataService.cs
index d2320ac..38408cf 100644
--- a/Correlator/Service/ISoundSpeedDataService.cs
+++ b/Correlator/Service/ISoundSpeedDataService.cs
@@ -15,5 +15,9 @@
///
///
void UpdatePipeMaterial(string materialName, MaterialVelocity velocity);
+
+ void InsertVelocity(string materialName, string minDiameter, string maxDiameter, string soundSpeed);
+
+ void UpdateVelocity(MaterialVelocity velocity, string minDiameter, string maxDiameter, string soundSpeed);
}
}
\ No newline at end of file
diff --git a/Correlator/ServiceImpl/SoundSpeedDataService.cs b/Correlator/ServiceImpl/SoundSpeedDataService.cs
index 671c2d9..1d79b46 100644
--- a/Correlator/ServiceImpl/SoundSpeedDataService.cs
+++ b/Correlator/ServiceImpl/SoundSpeedDataService.cs
@@ -1,8 +1,12 @@
-using System.Collections.ObjectModel;
+using System;
+using System.Collections.ObjectModel;
+using System.Text.RegularExpressions;
+using System.Windows;
using Correlator.Model;
using Correlator.Service;
using Correlator.Util;
using Newtonsoft.Json;
+using MessageBox = HandyControl.Controls.MessageBox;
namespace Correlator.ServiceImpl
{
@@ -49,5 +53,97 @@
manager.Update(materialModel);
}
}
+
+ public void InsertVelocity(string materialName, string minDiameter, string maxDiameter, string soundSpeed)
+ {
+ if (string.IsNullOrEmpty(minDiameter) || string.IsNullOrEmpty(maxDiameter) ||
+ string.IsNullOrEmpty(soundSpeed))
+ {
+ MessageBox.Show("不允许为空", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(minDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("管径输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(maxDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("管径输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (int.Parse(minDiameter) > int.Parse(maxDiameter))
+ {
+ MessageBox.Show("管径下限不能大于管径上限", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(soundSpeed, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("速度输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ using (var manager = new DataBaseManager())
+ {
+ var velocity = new MaterialVelocity
+ {
+ MaterialName = materialName,
+ LowDiameter = Convert.ToInt32(minDiameter),
+ HighDiameter = Convert.ToInt32(maxDiameter),
+ Velocity = Convert.ToInt32(soundSpeed)
+ };
+ manager.Insert(velocity);
+ }
+ }
+
+ public void UpdateVelocity(MaterialVelocity velocity, string minDiameter, string maxDiameter, string soundSpeed)
+ {
+ if (string.IsNullOrEmpty(minDiameter) || string.IsNullOrEmpty(maxDiameter) ||
+ string.IsNullOrEmpty(soundSpeed))
+ {
+ MessageBox.Show("不允许为空", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(minDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("管径输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(maxDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("管径输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (int.Parse(minDiameter) > int.Parse(maxDiameter))
+ {
+ MessageBox.Show("管径下限不能大于管径上限", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(soundSpeed, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("速度输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ using (var manager = new DataBaseManager())
+ {
+ velocity.LowDiameter = Convert.ToInt32(minDiameter);
+ velocity.HighDiameter = Convert.ToInt32(maxDiameter);
+ velocity.Velocity = Convert.ToInt32(soundSpeed);
+
+ LogWithConsole.WriteLine("正在修改的管材是:" + JsonConvert.SerializeObject(velocity),
+ "SoundSpeedDataService");
+
+ manager.Update(velocity);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Correlator/ViewModel/AddSoundSpeedViewModel.cs b/Correlator/ViewModel/AddSoundSpeedViewModel.cs
index 34037b1..eed497d 100644
--- a/Correlator/ViewModel/AddSoundSpeedViewModel.cs
+++ b/Correlator/ViewModel/AddSoundSpeedViewModel.cs
@@ -1,18 +1,15 @@
-using System;
-using System.Text.RegularExpressions;
-using System.Windows;
-using Correlator.Dialog;
-using Correlator.Model;
+using Correlator.Dialog;
+using Correlator.Service;
using Correlator.Util;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
-using MessageBox = HandyControl.Controls.MessageBox;
namespace Correlator.ViewModel
{
public class AddSoundSpeedViewModel : ViewModelBase
{
+ private readonly ISoundSpeedDataService _dataService;
private string _materialName;
private string _minDiameter;
@@ -53,8 +50,9 @@
public RelayCommand DetermineParamCommand { get; set; }
- public AddSoundSpeedViewModel()
+ public AddSoundSpeedViewModel(ISoundSpeedDataService dataService)
{
+ _dataService = dataService;
Messenger.Default.Register(this, MessengerToken.AddSoundSpeedMessage, it =>
{
_materialName = it;
@@ -64,62 +62,18 @@
SoundSpeed = "";
});
- DetermineParamCommand = new RelayCommand(it =>
- {
- if (string.IsNullOrEmpty(_minDiameter) || string.IsNullOrEmpty(_maxDiameter)
- || string.IsNullOrEmpty(_soundSpeed))
- {
- MessageBox.Show("不允许为空",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
+ DetermineParamCommand = new RelayCommand(AddSoundSpeed);
+ }
- if (!Regex.IsMatch(_minDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
- {
- MessageBox.Show("管径输入错误",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
+ private void AddSoundSpeed(AddSoundSpeedDialog it)
+ {
+ _dataService.InsertVelocity(_materialName, _minDiameter, _maxDiameter, _soundSpeed);
- if (!Regex.IsMatch(_maxDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
- {
- MessageBox.Show("管径输入错误",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
+ //更新界面数据
+ Messenger.Default.Send("", MessengerToken.UpdateSoundSpeed);
- if (int.Parse(_minDiameter) > int.Parse(_maxDiameter))
- {
- MessageBox.Show("管径下限不能大于管径上限",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
-
- if (!Regex.IsMatch(_soundSpeed, "^(([1-9]\\d{0,3})|10000|0)$"))
- {
- MessageBox.Show("速度输入错误",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
-
- using (var manager = new DataBaseManager())
- {
- var velocity = new MaterialVelocity
- {
- MaterialName = _materialName,
- LowDiameter = Convert.ToInt32(_minDiameter),
- HighDiameter = Convert.ToInt32(_maxDiameter),
- Velocity = Convert.ToInt32(_soundSpeed)
- };
- manager.Insert(velocity);
- }
-
- //更新界面数据
- Messenger.Default.Send("", MessengerToken.UpdateSoundSpeed);
-
- //返回选择材质界面
- it.Close();
- });
+ //返回选择材质界面
+ it.Close();
}
}
}
\ No newline at end of file
diff --git a/Correlator.sln b/Correlator.sln
index 687debd..02122b1 100644
--- a/Correlator.sln
+++ b/Correlator.sln
@@ -5,7 +5,7 @@
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Correlator", "Correlator\Correlator.csproj", "{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}"
EndProject
-Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "相关仪", "..\..\..\..\Setup Project\相关仪\相关仪.vdproj", "{13A08909-E201-42D6-B44E-2FFD8A900B79}"
+Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "相关仪", "..\..\..\..\Setup Project\相关仪\相关仪.vdproj", "{6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -23,10 +23,10 @@
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|Any CPU.Build.0 = Release|Any CPU
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.ActiveCfg = Release|x64
{BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.Build.0 = Release|x64
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Debug|Any CPU.ActiveCfg = Debug
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Debug|x64.ActiveCfg = Debug
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Release|Any CPU.ActiveCfg = Release
- {13A08909-E201-42D6-B44E-2FFD8A900B79}.Release|x64.ActiveCfg = Release
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Debug|Any CPU.ActiveCfg = Debug
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Debug|x64.ActiveCfg = Debug
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Release|Any CPU.ActiveCfg = Release
+ {6B97EEFC-3704-4C51-9B89-A5C0C6C2C2ED}.Release|x64.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Correlator/Service/ISoundSpeedDataService.cs b/Correlator/Service/ISoundSpeedDataService.cs
index d2320ac..38408cf 100644
--- a/Correlator/Service/ISoundSpeedDataService.cs
+++ b/Correlator/Service/ISoundSpeedDataService.cs
@@ -15,5 +15,9 @@
///
///
void UpdatePipeMaterial(string materialName, MaterialVelocity velocity);
+
+ void InsertVelocity(string materialName, string minDiameter, string maxDiameter, string soundSpeed);
+
+ void UpdateVelocity(MaterialVelocity velocity, string minDiameter, string maxDiameter, string soundSpeed);
}
}
\ No newline at end of file
diff --git a/Correlator/ServiceImpl/SoundSpeedDataService.cs b/Correlator/ServiceImpl/SoundSpeedDataService.cs
index 671c2d9..1d79b46 100644
--- a/Correlator/ServiceImpl/SoundSpeedDataService.cs
+++ b/Correlator/ServiceImpl/SoundSpeedDataService.cs
@@ -1,8 +1,12 @@
-using System.Collections.ObjectModel;
+using System;
+using System.Collections.ObjectModel;
+using System.Text.RegularExpressions;
+using System.Windows;
using Correlator.Model;
using Correlator.Service;
using Correlator.Util;
using Newtonsoft.Json;
+using MessageBox = HandyControl.Controls.MessageBox;
namespace Correlator.ServiceImpl
{
@@ -49,5 +53,97 @@
manager.Update(materialModel);
}
}
+
+ public void InsertVelocity(string materialName, string minDiameter, string maxDiameter, string soundSpeed)
+ {
+ if (string.IsNullOrEmpty(minDiameter) || string.IsNullOrEmpty(maxDiameter) ||
+ string.IsNullOrEmpty(soundSpeed))
+ {
+ MessageBox.Show("不允许为空", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(minDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("管径输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(maxDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("管径输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (int.Parse(minDiameter) > int.Parse(maxDiameter))
+ {
+ MessageBox.Show("管径下限不能大于管径上限", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(soundSpeed, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("速度输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ using (var manager = new DataBaseManager())
+ {
+ var velocity = new MaterialVelocity
+ {
+ MaterialName = materialName,
+ LowDiameter = Convert.ToInt32(minDiameter),
+ HighDiameter = Convert.ToInt32(maxDiameter),
+ Velocity = Convert.ToInt32(soundSpeed)
+ };
+ manager.Insert(velocity);
+ }
+ }
+
+ public void UpdateVelocity(MaterialVelocity velocity, string minDiameter, string maxDiameter, string soundSpeed)
+ {
+ if (string.IsNullOrEmpty(minDiameter) || string.IsNullOrEmpty(maxDiameter) ||
+ string.IsNullOrEmpty(soundSpeed))
+ {
+ MessageBox.Show("不允许为空", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(minDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("管径输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(maxDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("管径输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (int.Parse(minDiameter) > int.Parse(maxDiameter))
+ {
+ MessageBox.Show("管径下限不能大于管径上限", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!Regex.IsMatch(soundSpeed, "^(([1-9]\\d{0,3})|10000|0)$"))
+ {
+ MessageBox.Show("速度输入错误", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ using (var manager = new DataBaseManager())
+ {
+ velocity.LowDiameter = Convert.ToInt32(minDiameter);
+ velocity.HighDiameter = Convert.ToInt32(maxDiameter);
+ velocity.Velocity = Convert.ToInt32(soundSpeed);
+
+ LogWithConsole.WriteLine("正在修改的管材是:" + JsonConvert.SerializeObject(velocity),
+ "SoundSpeedDataService");
+
+ manager.Update(velocity);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Correlator/ViewModel/AddSoundSpeedViewModel.cs b/Correlator/ViewModel/AddSoundSpeedViewModel.cs
index 34037b1..eed497d 100644
--- a/Correlator/ViewModel/AddSoundSpeedViewModel.cs
+++ b/Correlator/ViewModel/AddSoundSpeedViewModel.cs
@@ -1,18 +1,15 @@
-using System;
-using System.Text.RegularExpressions;
-using System.Windows;
-using Correlator.Dialog;
-using Correlator.Model;
+using Correlator.Dialog;
+using Correlator.Service;
using Correlator.Util;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
-using MessageBox = HandyControl.Controls.MessageBox;
namespace Correlator.ViewModel
{
public class AddSoundSpeedViewModel : ViewModelBase
{
+ private readonly ISoundSpeedDataService _dataService;
private string _materialName;
private string _minDiameter;
@@ -53,8 +50,9 @@
public RelayCommand DetermineParamCommand { get; set; }
- public AddSoundSpeedViewModel()
+ public AddSoundSpeedViewModel(ISoundSpeedDataService dataService)
{
+ _dataService = dataService;
Messenger.Default.Register(this, MessengerToken.AddSoundSpeedMessage, it =>
{
_materialName = it;
@@ -64,62 +62,18 @@
SoundSpeed = "";
});
- DetermineParamCommand = new RelayCommand(it =>
- {
- if (string.IsNullOrEmpty(_minDiameter) || string.IsNullOrEmpty(_maxDiameter)
- || string.IsNullOrEmpty(_soundSpeed))
- {
- MessageBox.Show("不允许为空",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
+ DetermineParamCommand = new RelayCommand(AddSoundSpeed);
+ }
- if (!Regex.IsMatch(_minDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
- {
- MessageBox.Show("管径输入错误",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
+ private void AddSoundSpeed(AddSoundSpeedDialog it)
+ {
+ _dataService.InsertVelocity(_materialName, _minDiameter, _maxDiameter, _soundSpeed);
- if (!Regex.IsMatch(_maxDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
- {
- MessageBox.Show("管径输入错误",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
+ //更新界面数据
+ Messenger.Default.Send("", MessengerToken.UpdateSoundSpeed);
- if (int.Parse(_minDiameter) > int.Parse(_maxDiameter))
- {
- MessageBox.Show("管径下限不能大于管径上限",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
-
- if (!Regex.IsMatch(_soundSpeed, "^(([1-9]\\d{0,3})|10000|0)$"))
- {
- MessageBox.Show("速度输入错误",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
-
- using (var manager = new DataBaseManager())
- {
- var velocity = new MaterialVelocity
- {
- MaterialName = _materialName,
- LowDiameter = Convert.ToInt32(_minDiameter),
- HighDiameter = Convert.ToInt32(_maxDiameter),
- Velocity = Convert.ToInt32(_soundSpeed)
- };
- manager.Insert(velocity);
- }
-
- //更新界面数据
- Messenger.Default.Send("", MessengerToken.UpdateSoundSpeed);
-
- //返回选择材质界面
- it.Close();
- });
+ //返回选择材质界面
+ it.Close();
}
}
}
\ No newline at end of file
diff --git a/Correlator/ViewModel/EditSoundSpeedViewModel.cs b/Correlator/ViewModel/EditSoundSpeedViewModel.cs
index 548bbbb..48747db 100644
--- a/Correlator/ViewModel/EditSoundSpeedViewModel.cs
+++ b/Correlator/ViewModel/EditSoundSpeedViewModel.cs
@@ -1,19 +1,16 @@
-using System;
-using System.Text.RegularExpressions;
-using System.Windows;
-using Correlator.Dialog;
+using Correlator.Dialog;
using Correlator.Model;
+using Correlator.Service;
using Correlator.Util;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
-using Newtonsoft.Json;
-using MessageBox = HandyControl.Controls.MessageBox;
namespace Correlator.ViewModel
{
public class EditSoundSpeedViewModel : ViewModelBase
{
+ private readonly ISoundSpeedDataService _dataService;
private MaterialVelocity _materialVelocity;
private string _minDiameter;
@@ -54,8 +51,9 @@
public RelayCommand DetermineParamCommand { get; set; }
- public EditSoundSpeedViewModel()
+ public EditSoundSpeedViewModel(ISoundSpeedDataService dataService)
{
+ _dataService = dataService;
Messenger.Default.Register(this, MessengerToken.EditSoundSpeedMessage, it =>
{
_materialVelocity = it;
@@ -65,62 +63,18 @@
SoundSpeed = _materialVelocity.Velocity.ToString();
});
- DetermineParamCommand = new RelayCommand(it =>
- {
- if (string.IsNullOrEmpty(_minDiameter) || string.IsNullOrEmpty(_maxDiameter)
- || string.IsNullOrEmpty(_soundSpeed))
- {
- MessageBox.Show("不允许为空",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
+ DetermineParamCommand = new RelayCommand(EditSoundSpeed);
+ }
- if (!Regex.IsMatch(_minDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
- {
- MessageBox.Show("管径输入错误",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
+ private void EditSoundSpeed(EditSoundSpeedDialog it)
+ {
+ _dataService.UpdateVelocity(_materialVelocity, _minDiameter, _maxDiameter, _soundSpeed);
- if (!Regex.IsMatch(_maxDiameter, "^(([1-9]\\d{0,3})|10000|0)$"))
- {
- MessageBox.Show("管径输入错误",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
+ //更新界面数据
+ Messenger.Default.Send("", MessengerToken.UpdateSoundSpeed);
- if (int.Parse(_minDiameter) > int.Parse(_maxDiameter))
- {
- MessageBox.Show("管径下限不能大于管径上限",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
-
- if (!Regex.IsMatch(_soundSpeed, "^(([1-9]\\d{0,3})|10000|0)$"))
- {
- MessageBox.Show("速度输入错误",
- "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
-
- using (var manager = new DataBaseManager())
- {
- _materialVelocity.LowDiameter = Convert.ToInt32(_minDiameter);
- _materialVelocity.HighDiameter = Convert.ToInt32(_maxDiameter);
- _materialVelocity.Velocity = Convert.ToInt32(_soundSpeed);
-
- LogWithConsole.WriteLine("正在修改的管材是:" + JsonConvert.SerializeObject(_materialVelocity),
- "EditSoundSpeedViewModel");
-
- manager.Update(_materialVelocity);
- }
-
- //更新界面数据
- Messenger.Default.Send("", MessengerToken.UpdateSoundSpeed);
-
- //返回选择材质界面
- it.Close();
- });
+ //返回选择材质界面
+ it.Close();
}
}
}
\ No newline at end of file