6 changed files with 159 additions and 3 deletions
@ -0,0 +1,20 @@ |
|||||
|
[2025-07-24 21:48:12];[Error] || |
||||
|
|
||||
|
[2025-07-24 21:48:12];[Error source] ||.Net SqlClient Data Provider |
||||
|
|
||||
|
[2025-07-24 21:48:12];[Error message] ||在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: Named Pipes Provider, error: 40 - 无法打开到 SQL Server 的连接) |
||||
|
|
||||
|
[2025-07-24 21:48:12];[Error area] || 在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) |
||||
|
在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) |
||||
|
在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) |
||||
|
在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) |
||||
|
在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) |
||||
|
在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) |
||||
|
在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) |
||||
|
在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) |
||||
|
在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) |
||||
|
在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) |
||||
|
在 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) |
||||
|
在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) |
||||
|
在 System.Data.SqlClient.SqlConnection.Open() |
||||
|
在 SunlightCentralizedControlManagement_SCCM_.ViewModel.ManualDyelotModel..ctor() 位置 C:\Users\Administrator\source\repos\SunlightCentralizedControlManagement(SCCM)\ViewModel\ManualDyelotModel.cs:行号 35 |
@ -0,0 +1,68 @@ |
|||||
|
<Window x:Class="SunlightCentralizedControlManagement_SCCM_.WindowsView.UserInformation" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
|
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_" |
||||
|
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties" |
||||
|
mc:Ignorable="d" |
||||
|
Title="UserInformation" Height="450" Width="800"> |
||||
|
<Grid> |
||||
|
<DataGrid x:Name="Griddata" AlternationCount="2" IsReadOnly="True" |
||||
|
d:ItemsSource="{d:SampleData ItemCount=30}" AutoGenerateColumns="False" MinColumnWidth="30" |
||||
|
Background="White" GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" |
||||
|
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False" |
||||
|
CanUserDeleteRows="False" SelectionMode="Single" FontSize="15" Focusable="True" > |
||||
|
<DataGrid.RowStyle > |
||||
|
<Style TargetType="{x:Type DataGridRow}"> |
||||
|
<Setter Property="Height" Value="30" /> |
||||
|
<Setter Property="FontSize" Value="25" /> |
||||
|
<Setter Property="VerticalAlignment" Value="Center"/> |
||||
|
<Style.Triggers> |
||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="0"> |
||||
|
<Setter Property="Background" Value="#FFFFFFFF" /> |
||||
|
</Trigger> |
||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="1"> |
||||
|
<Setter Property="Background" Value="#FFF0F0F0" /> |
||||
|
</Trigger> |
||||
|
</Style.Triggers> |
||||
|
</Style> |
||||
|
</DataGrid.RowStyle> |
||||
|
<DataGrid.CellStyle> |
||||
|
<Style TargetType="DataGridCell"> |
||||
|
<Setter Property="BorderThickness" Value="0"/> |
||||
|
<Setter Property="MinWidth" Value="20"/> |
||||
|
<Setter Property="VerticalAlignment" Value="Center"/> |
||||
|
<Style.Triggers> |
||||
|
<Trigger Property="IsSelected" Value="True"> |
||||
|
<Setter Property="Background" Value="#FFC0C0C0"/> |
||||
|
<Setter Property="BorderBrush" Value="#FFC0C0C0"/> |
||||
|
<Setter Property="Foreground" Value="Black"/> |
||||
|
</Trigger> |
||||
|
</Style.Triggers> |
||||
|
</Style> |
||||
|
</DataGrid.CellStyle> |
||||
|
<DataGrid.Resources> |
||||
|
<Style x:Key="CellStyle" TargetType="{x:Type DataGridCell}"> |
||||
|
<Setter Property="Focusable" Value="False"/> |
||||
|
<Setter Property="Background" Value="#FFFFFFFF"/> |
||||
|
<Setter Property="BorderBrush" Value="#FFFFFFFF"/> |
||||
|
<Setter Property="Foreground" Value="#000000"/> |
||||
|
</Style> |
||||
|
<DataTemplate x:Key="btnCell"> |
||||
|
<!--注意此处的设置方式--> |
||||
|
<Button Content="{x:Static lang:Resources.Confirm}" Click="Button_Click" Tag="{Binding}"/> |
||||
|
</DataTemplate> |
||||
|
</DataGrid.Resources> |
||||
|
<DataGrid.Columns> |
||||
|
<!--列信息绑定--> |
||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.Machine}" Binding="{Binding Machine}" Width="150" IsReadOnly="True"/> |
||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.Information}" Binding="{Binding Code}" MaxWidth="0" IsReadOnly="True"/> |
||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.Information}" Binding="{Binding ID}" MaxWidth="0" IsReadOnly="True"/> |
||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.Information}" Binding="{Binding inf}" Width="*" IsReadOnly="True"/> |
||||
|
<DataGridTemplateColumn Width="100" CellTemplate="{StaticResource btnCell}" /> |
||||
|
</DataGrid.Columns> |
||||
|
</DataGrid> |
||||
|
|
||||
|
</Grid> |
||||
|
</Window> |
@ -0,0 +1,57 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Data; |
||||
|
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
using System.Windows.Data; |
||||
|
using System.Windows.Documents; |
||||
|
using System.Windows.Input; |
||||
|
using System.Windows.Media; |
||||
|
using System.Windows.Media.Imaging; |
||||
|
using System.Windows.Shapes; |
||||
|
|
||||
|
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// UserInformation.xaml 的交互逻辑
|
||||
|
/// </summary>
|
||||
|
public partial class UserInformation : Window |
||||
|
{ |
||||
|
DataTable dataTable = new DataTable(); |
||||
|
public UserInformation() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
|
||||
|
//DataTable dataTable = new DataTable();
|
||||
|
dataTable.Columns.Add("Machine",Type.GetType("System.String")); |
||||
|
dataTable.Columns.Add("Information", Type.GetType("System.String")); |
||||
|
dataTable.Columns.Add("Code", Type.GetType("System.String")); |
||||
|
dataTable.Columns.Add("ID", Type.GetType("System.Int32")); |
||||
|
dataTable.Rows.Add(new object[] { "1", "a","423","12"}); |
||||
|
dataTable.Rows.Add(new object[] { "2", "b" ,"345","122"}); |
||||
|
dataTable.Rows.Add(new object[] { "3", "c" ,"345","32"}); |
||||
|
dataTable.Rows.Add(new object[] { "1", "a", "423", "1232" }); |
||||
|
dataTable.Rows.Add(new object[] { "2", "b", "345", "1222" }); |
||||
|
dataTable.Rows.Add(new object[] { "3", "c", "345", "325" }); |
||||
|
|
||||
|
Griddata.ItemsSource = dataTable.DefaultView; |
||||
|
} |
||||
|
|
||||
|
private void Button_Click(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
var button = sender as Button; |
||||
|
DataRowView datarow = (DataRowView)button.Tag; |
||||
|
var y= datarow.Row.Field<int>("ID"); |
||||
|
DataRow erwqer = dataTable.Select("ID='" + y + "'").First(); |
||||
|
|
||||
|
erwqer.Delete(); |
||||
|
Griddata.ItemsSource = dataTable.DefaultView; |
||||
|
|
||||
|
if (dataTable.Rows.Count == 0) { this.Close(); } |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue