This commit is contained in:
sc committed 2025-07-07 00:14:27 +08:00
commit 3c3b608bfb
10 files changed
+141 -333

No files matched your search

+41 -37
View File
@@ -460,50 +460,54 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}
public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new()
{
Type t = typeof(T);
PropertyInfo[] propertys = t.GetProperties();
ObservableCollection<T> lst = new ObservableCollection<T>();
string typeName = string.Empty;
foreach (DataRow dr in dt.Rows)
try
{
T entity = new T();
foreach (PropertyInfo pi in propertys)
Type t = typeof(T);
PropertyInfo[] propertys = t.GetProperties();
ObservableCollection<T> lst = new ObservableCollection<T>();
string typeName = string.Empty;
foreach (DataRow dr in dt.Rows)
{
typeName = pi.Name;
if (dt.Columns.Contains(typeName))
T entity = new T();
foreach (PropertyInfo pi in propertys)
{
if (!pi.CanWrite) continue;
object value = dr[typeName];
if (value == DBNull.Value) continue;
if (pi.PropertyType == typeof(string))
typeName = pi.Name;
if (dt.Columns.Contains(typeName))
{
pi.SetValue(entity, value.ToString(), null);
}
else if (pi.PropertyType == typeof(int) || pi.PropertyType == typeof(int?))
{
pi.SetValue(entity, int.Parse(value.ToString()), null);
}
else if (pi.PropertyType == typeof(DateTime?) || pi.PropertyType == typeof(DateTime))
{
pi.SetValue(entity, DateTime.Parse(value.ToString()), null);
}
else if (pi.PropertyType == typeof(float))
{
pi.SetValue(entity, float.Parse(value.ToString()), null);
}
else if (pi.PropertyType == typeof(double))
{
pi.SetValue(entity, double.Parse(value.ToString()), null);
}
else
{
pi.SetValue(entity, value, null);
if (!pi.CanWrite) continue;
object value = dr[typeName];
if (value == DBNull.Value) continue;
if (pi.PropertyType == typeof(string))
{
pi.SetValue(entity, value.ToString(), null);
}
else if (pi.PropertyType == typeof(int) || pi.PropertyType == typeof(int?))
{
pi.SetValue(entity, int.Parse(value.ToString()), null);
}
else if (pi.PropertyType == typeof(DateTime?) || pi.PropertyType == typeof(DateTime))
{
pi.SetValue(entity, DateTime.Parse(value.ToString()), null);
}
else if (pi.PropertyType == typeof(float))
{
pi.SetValue(entity, float.Parse(value.ToString()), null);
}
else if (pi.PropertyType == typeof(double))
{
pi.SetValue(entity, double.Parse(value.ToString()), null);
}
else
{
pi.SetValue(entity, value, null);
}
}
}
lst.Add(entity);
}
lst.Add(entity);
return lst;
}
return lst;
}
catch (Exception) { return null; }
}
}
}
+50 -43
View File
@@ -119,7 +119,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
else
{
MessageBox.Show(Properties.Resources.TMNR, "800", MessageBoxButton.OK, MessageBoxImage.Information); //
}
}
@@ -226,15 +225,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
dat_821.Clear();
if (mode != "TRUE")
if (mode != "True")
{
dat_821.Add("LOCK", "TRUE");
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "TRUE");
}
dat_821.Add("LOCK", "True");
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "True");
}
else
{
dat_821.Add("LOCK", "FALSE");
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "FALSE");
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "False");
}
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
@@ -245,6 +244,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
});
if (mode != "True") { MessageBox.Show(machine + Properties.Resources.user_lock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
} else {
MessageBox.Show(machine + Properties.Resources.user_unlock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
}
}//锁定
private void ListViewItem_Curve(object sender, MouseButtonEventArgs e)
{
@@ -599,7 +602,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
catch (Exception) { }
try
{
if (MainWindowViewModel.dt_TP.Rows.Count >= 0)
if (MainWindowViewModel.dt_TP.Rows.Count > 0)
{
if (TechnologicalProcess_bool)
{
@@ -665,50 +668,54 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new()
{
Type t = typeof(T);
PropertyInfo[] propertys = t.GetProperties();
ObservableCollection<T> lst = new ObservableCollection<T>();
string typeName = string.Empty;
foreach (DataRow dr in dt.Rows)
try
{
T entity = new T();
foreach (PropertyInfo pi in propertys)
Type t = typeof(T);
PropertyInfo[] propertys = t.GetProperties();
ObservableCollection<T> lst = new ObservableCollection<T>();
string typeName = string.Empty;
foreach (DataRow dr in dt.Rows)
{
typeName = pi.Name;
if (dt.Columns.Contains(typeName))
T entity = new T();
foreach (PropertyInfo pi in propertys)
{
if (!pi.CanWrite) continue;
object value = dr[typeName];
if (value == DBNull.Value) continue;
if (pi.PropertyType == typeof(string))
typeName = pi.Name;
if (dt.Columns.Contains(typeName))
{
pi.SetValue(entity, value.ToString(), null);
}
else if (pi.PropertyType == typeof(int) || pi.PropertyType == typeof(int?))
{
pi.SetValue(entity, int.Parse(value.ToString()), null);
}
else if (pi.PropertyType == typeof(DateTime?) || pi.PropertyType == typeof(DateTime))
{
pi.SetValue(entity, DateTime.Parse(value.ToString()), null);
}
else if (pi.PropertyType == typeof(float))
{
pi.SetValue(entity, float.Parse(value.ToString()), null);
}
else if (pi.PropertyType == typeof(double))
{
pi.SetValue(entity, double.Parse(value.ToString()), null);
}
else
{
pi.SetValue(entity, value, null);
if (!pi.CanWrite) continue;
object value = dr[typeName];
if (value == DBNull.Value) continue;
if (pi.PropertyType == typeof(string))
{
pi.SetValue(entity, value.ToString(), null);
}
else if (pi.PropertyType == typeof(int) || pi.PropertyType == typeof(int?))
{
pi.SetValue(entity, int.Parse(value.ToString()), null);
}
else if (pi.PropertyType == typeof(DateTime?) || pi.PropertyType == typeof(DateTime))
{
pi.SetValue(entity, DateTime.Parse(value.ToString()), null);
}
else if (pi.PropertyType == typeof(float))
{
pi.SetValue(entity, float.Parse(value.ToString()), null);
}
else if (pi.PropertyType == typeof(double))
{
pi.SetValue(entity, double.Parse(value.ToString()), null);
}
else
{
pi.SetValue(entity, value, null);
}
}
}
lst.Add(entity);
}
lst.Add(entity);
return lst;
}
return lst;
catch (Exception) { return null; }
}
}