CursonQuestionsTable

This commit is contained in:
wangxiner55 2024-09-09 23:25:04 +08:00
parent 2633d93ee7
commit 16c224fa65
8 changed files with 83 additions and 6 deletions

View File

@ -1,5 +1,6 @@
using DryIoc.ImTools;
using MySql.Data.MySqlClient;
using Newtonsoft.Json;
using StudentManager.Common;
using StudentManager.Data;
using System;
@ -16,6 +17,7 @@ namespace StudentManager.Common
static public string UserTable { get; } = "users";
static public string QuesTable { get; } = "questions";
static public string UQTable { get; } = "user_data";
static public string CQTable { get; } = "curson_questions";
}
@ -35,7 +37,9 @@ namespace StudentManager.Common
(data as StudentData).Gender = reader[2].ToString();
(data as StudentData).Contact = reader[3].ToString();
(data as StudentData).Address = reader[4].ToString();
(data as StudentData).Grade = (int)reader[5];
(data as StudentData).Grade = (byte)reader[5];
(data as StudentData).TotalsQuestions = (UInt16)reader[6];
(data as StudentData).CorrectionCount = (UInt16)reader[7];
}
else if(typeof(T) == typeof(QuestionData))
{
@ -53,6 +57,15 @@ namespace StudentManager.Common
Enum.TryParse(reader[8].ToString(), true, out qStatus);
(data as QuestionData).Status = qStatus;
}
else if (typeof(T) == typeof(CursonQuestionsData))
{
(data as CursonQuestionsData).UID = (int)reader[0];
(data as CursonQuestionsData).ProblemIDS = JsonConvert.DeserializeObject<int[]>(reader[1].ToString());
(data as CursonQuestionsData).CorrectIDS = JsonConvert.DeserializeObject<int[]>(reader[2].ToString());
(data as CursonQuestionsData).lesson = (int)reader[3];
}
@ -87,7 +100,7 @@ namespace StudentManager.Common
List<T> result = new List<T>();
string idName = typeof(T) == typeof(StudentData) ? Tables.UserTable : Tables.QuesTable;
string idName = typeof(T) == typeof(StudentData) ? Tables.UserTable : typeof(T) == typeof(QuestionData) ? Tables.QuesTable : Tables.CQTable;
try
{
connection.Open();

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StudentManager.Data
{
public class CursonQuestionsData
{
public int UID { get; set; } = 0;
public int[] ProblemIDS { get; set; } = { };
public int[] CorrectIDS { get; set; } = { };
public int lesson = 0;
}
}

View File

@ -30,6 +30,7 @@ namespace StudentManager.Data
public string Category { get; set; } = string.Empty;
public string Tags { get; set; } = string.Empty;
public string Source { get; set; } = string.Empty;
public int Lesson { get; set; } = 0;
public QStatus Status { get; set; } = QStatus.published;

View File

@ -0,0 +1,12 @@
<UserControl x:Class="StudentManager.Editor.DetailView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StudentManager.Editor"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
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.Navigation;
using System.Windows.Shapes;
namespace StudentManager.Editor
{
/// <summary>
/// DetailView.xaml 的交互逻辑
/// </summary>
public partial class DetailView : UserControl
{
public DetailView()
{
InitializeComponent();
}
}
}

View File

@ -81,7 +81,6 @@ namespace StudentManager.Model
QueryAll();
Query();
}
private void RegionToStudents()
@ -101,8 +100,8 @@ namespace StudentManager.Model
studentDatas.Clear();
questionDatas.Clear();
SQLHelper.Query<StudentData>(Tables.UserTable).ForEach(x => studentDatas.Add(x));
SQLHelper.Query<QuestionData>(Tables.QuesTable).ForEach(x => questionDatas.Add(x));
//SQLHelper.UnionQuery<QuestionData>(1).ForEach(x => questionDatas.Add(x));
//SQLHelper.Query<QuestionData>(Tables.QuesTable).ForEach(x => questionDatas.Add(x));
SQLHelper.UnionQuery<QuestionData>(1).ForEach(x => questionDatas.Add(x));
}
}
}

View File

@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="MySql.Data" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Prism.DryIoc" Version="9.0.537" />
</ItemGroup>

View File

@ -7,6 +7,9 @@
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Compile Update="Editor\DetailView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Editor\MainEditor.xaml.cs">
<SubType>Code</SubType>
</Compile>
@ -18,6 +21,9 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Page Update="Editor\DetailView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Editor\MainEditor.xaml">
<SubType>Designer</SubType>
</Page>