@@ -9,7 +9,7 @@ | |||||
<AppDesignerFolder>Properties</AppDesignerFolder> | <AppDesignerFolder>Properties</AppDesignerFolder> | ||||
<RootNamespace>StuMgmLib</RootNamespace> | <RootNamespace>StuMgmLib</RootNamespace> | ||||
<AssemblyName>StuMgmClient</AssemblyName> | <AssemblyName>StuMgmClient</AssemblyName> | ||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion> | |||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | |||||
<FileAlignment>512</FileAlignment> | <FileAlignment>512</FileAlignment> | ||||
<TargetFrameworkProfile /> | <TargetFrameworkProfile /> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
@@ -9,10 +9,10 @@ namespace StuMgmClient | |||||
int m_token; | int m_token; | ||||
public StudentForm(short job_id, int token) | public StudentForm(short job_id, int token) | ||||
{ | { | ||||
InitializeComponent(); | |||||
m_token = token; | m_token = token; | ||||
if (SystemCtrl.RefreshUserCourseInfo(job_id, token) != ErrCode.Success) | if (SystemCtrl.RefreshUserCourseInfo(job_id, token) != ErrCode.Success) | ||||
throw new Exception("获取用户信息异常,请重新启动"); | throw new Exception("获取用户信息异常,请重新启动"); | ||||
InitializeComponent(); | |||||
} | } | ||||
@@ -14,6 +14,8 @@ namespace StuMgmClient | |||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
} | } | ||||
DataTable db = null; | |||||
////个人信息 | ////个人信息 | ||||
//private DataSet ds = null; | //private DataSet ds = null; | ||||
//public DataSet Ds | //public DataSet Ds | ||||
@@ -26,52 +28,51 @@ namespace StuMgmClient | |||||
////dataRows转化成的table | ////dataRows转化成的table | ||||
//DataTable tableClone = null; | //DataTable tableClone = null; | ||||
//Data da = new Data(); | //Data da = new Data(); | ||||
//private void StudentTree_Load(object sender, EventArgs e) | |||||
//{ | |||||
// dgvStudent.Visible = false; | |||||
// BindRoot(); | |||||
// //da.GetNodesDic(table); | |||||
//} | |||||
private void StudentTree_Load(object sender, EventArgs e) { } | |||||
private void StudentTree_Load(object sender, EventArgs e) | |||||
{ | |||||
db = SystemCtrl.GetStreeTable(); | |||||
dgvStudent.Visible = false; | |||||
BindRoot(); | |||||
//da.GetNodesDic(table); | |||||
} | |||||
////添加父节点的方法 | ////添加父节点的方法 | ||||
//private void BindRoot() | |||||
//{ | |||||
// //ClientMysql cm = new ClientMysql(); | |||||
// // DataSet ds = cm.SelectNode(); | |||||
// table = Ds.Tables["course_info"]; | |||||
// //把父节点的数据帅选出来 | |||||
// DataRow[] rows = table.Select("pid=0");//取根 | |||||
// foreach (DataRow dRow in rows) | |||||
// { | |||||
// TreeNode rootNode = new TreeNode(); | |||||
// rootNode.Tag = dRow; | |||||
// rootNode.Text = dRow["name"].ToString(); | |||||
// //把此节点放入树中 | |||||
// StudenTree.Nodes.Add(rootNode); | |||||
// //绑定子节点 | |||||
// BindChildAreas(rootNode);//调用添加子节点的方法 | |||||
// } | |||||
//} | |||||
private void BindRoot() | |||||
{ | |||||
//ClientMysql cm = new ClientMysql(); | |||||
// DataSet ds = cm.SelectNode(); | |||||
//table = Ds.Tables["course_info"]; | |||||
DataRow[] rows = db.Select("FirstNode=0");//取根 | |||||
foreach (DataRow dRow in rows) | |||||
{ | |||||
TreeNode rootNode = new TreeNode(); | |||||
rootNode.Tag = dRow; | |||||
rootNode.Text = dRow["Name"].ToString(); | |||||
//把此节点放入树中 | |||||
StudenTree.Nodes.Add(rootNode); | |||||
//绑定子节点 | |||||
BindChildAreas(rootNode);//调用添加子节点的方法 | |||||
} | |||||
} | |||||
////添加子节点的方法、递归绑定子区域 | ////添加子节点的方法、递归绑定子区域 | ||||
//private void BindChildAreas(TreeNode fNode) | |||||
//{ | |||||
// DataRow dr = (DataRow)fNode.Tag;//父节点数据关联的数据行 | |||||
// int fAreaId = Convert.ToInt32(dr["id"]); //父节点ID | |||||
// DataRow[] rows1 = table.Select("pid =" + fAreaId);//子区域 | |||||
// if (rows1.Length == 0) //递归终止,区域不包含子区域时 | |||||
// { | |||||
// return; | |||||
// } | |||||
// foreach (DataRow dRow in rows1) | |||||
// { | |||||
// TreeNode node = new TreeNode(); | |||||
// node.Tag = dRow; | |||||
// node.Text = dRow["name"].ToString(); | |||||
// //添加子节点 | |||||
// fNode.Nodes.Add(node); | |||||
// } | |||||
//} | |||||
private void BindChildAreas(TreeNode fNode) | |||||
{ | |||||
DataRow dr = (DataRow)fNode.Tag;//父节点数据关联的数据行 | |||||
int fAreaId = Convert.ToInt32(dr["Id"]); //父节点ID | |||||
DataRow[] rows1 = db.Select("SecondNode =" + fAreaId);//子区域 | |||||
if (rows1.Length == 0) //递归终止,区域不包含子区域时 | |||||
{ | |||||
return; | |||||
} | |||||
foreach (DataRow dRow in rows1) | |||||
{ | |||||
TreeNode node = new TreeNode(); | |||||
node.Tag = dRow; | |||||
node.Text = dRow["Name"].ToString(); | |||||
//添加子节点 | |||||
fNode.Nodes.Add(node); | |||||
} | |||||
} | |||||
////子节点单击显示内容 | ////子节点单击显示内容 | ||||
//private void StudentTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) | //private void StudentTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) | ||||
private void StudentTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { } | private void StudentTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { } | ||||
@@ -4,6 +4,7 @@ using System.Text; | |||||
using StuMgmClient; | using StuMgmClient; | ||||
using StuMgmLib.MyNameSpace; | using StuMgmLib.MyNameSpace; | ||||
using System.Diagnostics; | using System.Diagnostics; | ||||
using System.Data; | |||||
namespace StuMgmClient | namespace StuMgmClient | ||||
{ | { | ||||
@@ -44,7 +45,7 @@ namespace StuMgmClient | |||||
if (!(o.Object is List<CourseInfo>)) | if (!(o.Object is List<CourseInfo>)) | ||||
return ErrCode.ErrData; | return ErrCode.ErrData; | ||||
//courseInfo = (List<CourseInfo>)o; | |||||
courseInfo = (List<CourseInfo>)o.Object; | |||||
return ErrCode.Success; | return ErrCode.Success; | ||||
} | } | ||||
@@ -85,11 +86,9 @@ namespace StuMgmClient | |||||
return ErrCode.Success; | return ErrCode.Success; | ||||
} | } | ||||
internal static DataTable GetStreeTable() | |||||
{ | |||||
return SystemData.StreeTable(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -2,13 +2,18 @@ | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Text; | using System.Text; | ||||
using StuMgmLib.MyNameSpace; | using StuMgmLib.MyNameSpace; | ||||
using System.Linq; | |||||
using System.Data; | |||||
using System.ComponentModel; | |||||
using System.Collections; | |||||
using System.Reflection; | |||||
namespace StuMgmClient | namespace StuMgmClient | ||||
{ | { | ||||
class SystemData | class SystemData | ||||
{ | { | ||||
static Dictionary<short, CourseInfo> allCourseInfo; | static Dictionary<short, CourseInfo> allCourseInfo; | ||||
static Dictionary<short,CourseStatusEnum> allCourseStatus; | static Dictionary<short,CourseStatusEnum> allCourseStatus; | ||||
static List<StreeDatas> allStreeDatas; | |||||
internal static ErrCode InitSystemData() | internal static ErrCode InitSystemData() | ||||
{ | { | ||||
ErrCode err; | ErrCode err; | ||||
@@ -25,17 +30,18 @@ namespace StuMgmClient | |||||
if (err != ErrCode.Success) | if (err != ErrCode.Success) | ||||
return err; | return err; | ||||
//将List<CourseInfo>转为Dictionary<short, CourseInfo> | //将List<CourseInfo>转为Dictionary<short, CourseInfo> | ||||
//allCourseInfo = courseInfo.ToDictionary(key => key.Id, value => value); | |||||
allCourseInfo = courseInfo.ToDictionary(key => key.Id, value => value); | |||||
return ErrCode.Success; | return ErrCode.Success; | ||||
} | } | ||||
internal static ErrCode RefreshUserCourseInfo(UserCourseInfo info) | internal static ErrCode RefreshUserCourseInfo(UserCourseInfo info) | ||||
{ | { | ||||
//将UserCourseInfo转为Dictionary<short,CourseStatusEnum> | //将UserCourseInfo转为Dictionary<short,CourseStatusEnum> | ||||
allCourseStatus = new Dictionary<short, CourseStatusEnum>(); | |||||
int num = 0; | int num = 0; | ||||
short oldTem = 0; | short oldTem = 0; | ||||
//切割字符串 | //切割字符串 | ||||
string[] sArray = info.Details.Split(new char[2] { ':', ';' }); | |||||
string[] sArray = info.Status.Split(new char[2] { ':', ';' }); | |||||
foreach (string i in sArray) | foreach (string i in sArray) | ||||
{ | { | ||||
if (i.Equals("")) { break; } | if (i.Equals("")) { break; } | ||||
@@ -54,6 +60,55 @@ namespace StuMgmClient | |||||
return ErrCode.Success; | return ErrCode.Success; | ||||
} | } | ||||
static void StreeList() | |||||
{ | |||||
allStreeDatas = new List<StreeDatas>(); | |||||
StreeDatas sd=null; | |||||
foreach (var item in allCourseStatus) | |||||
{ | |||||
sd = new StreeDatas(); | |||||
CourseInfo infoTwo = allCourseInfo[item.Key];//找到状态对应的课程表信息 | |||||
sd.SecondNode = infoTwo.Pid;//二级节点9 | |||||
CourseInfo infoOne = allCourseInfo[infoTwo.Pid]; | |||||
CourseInfo infoThree = allCourseInfo[infoOne.Pid]; | |||||
sd.FirstNode = infoThree.Pid; | |||||
sd.Id = infoTwo.Id; | |||||
sd.Name = infoTwo.Name; | |||||
sd.Pid = infoTwo.Pid; | |||||
sd.Statu = (int)item.Value; | |||||
sd.Content = infoTwo.Content; | |||||
allStreeDatas.Add(sd); | |||||
} | |||||
} | |||||
static DataTable ListToDb(List<StreeDatas> list) | |||||
{ | |||||
DataTable dt = new DataTable(); | |||||
dt.Columns.Add("Id", typeof(int)); | |||||
dt.Columns.Add("Name", typeof(string)); | |||||
dt.Columns.Add("Pid", typeof(int)); | |||||
dt.Columns.Add("Content", typeof(string)); | |||||
dt.Columns.Add("Statu", typeof(int)); | |||||
dt.Columns.Add("FirstNode", typeof(int)); | |||||
dt.Columns.Add("SecondNode", typeof(int)); | |||||
for (int i = 0; i < list.Count; i++) | |||||
{ | |||||
DataRow dr = dt.NewRow(); | |||||
dr[0] = list[i].Id; | |||||
dr[1] = list[i].Name; | |||||
dr[2] = list[i].Pid; | |||||
dr[3] = list[i].Content; | |||||
dr[4] = list[i].Statu; | |||||
dr[5] = list[i].FirstNode; | |||||
dr[6] = list[i].SecondNode; | |||||
dt.Rows.Add(dr); | |||||
} | |||||
return dt; | |||||
} | |||||
internal static DataTable StreeTable() | |||||
{ | |||||
StreeList(); | |||||
return ListToDb(allStreeDatas); | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,3 +1,3 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||
<configuration> | <configuration> | ||||
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration> | |||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> |
@@ -83,6 +83,7 @@ namespace StuMgmLib.MyNameSpace | |||||
{ | { | ||||
public short JobId;//工号 | public short JobId;//工号 | ||||
public string Name;//姓名 | public string Name;//姓名 | ||||
public string Status; // 课程状态 | |||||
public string Details;//信息描述 | public string Details;//信息描述 | ||||
} | } | ||||
@@ -99,8 +100,15 @@ namespace StuMgmLib.MyNameSpace | |||||
Object = obj; | Object = obj; | ||||
} | } | ||||
} | } | ||||
public class StreeDatas | |||||
{ | |||||
public int Id; | |||||
public string Name; | |||||
public int Pid; | |||||
public string Content; | |||||
public int Statu; | |||||
public int FirstNode; | |||||
public int SecondNode; | |||||
} | |||||
} | } | ||||