Sfoglia il codice sorgente

初步完成分层

Client
WIN-G7N5C0B818G\Administrator 4 anni fa
parent
commit
ab11871c5e
11 ha cambiato i file con 460 aggiunte e 274 eliminazioni
  1. +163
    -69
      StuMgmClient/Data.cs
  2. +33
    -59
      StuMgmClient/LoginForm.cs
  3. +0
    -1
      StuMgmClient/LoginForm.designer.cs
  4. +3
    -7
      StuMgmClient/StuMgmClient.csproj
  5. +0
    -6
      StuMgmClient/StuMgmClient.sln
  6. +0
    -1
      StuMgmClient/StudentForm.Designer.cs
  7. +10
    -8
      StuMgmClient/StudentForm.cs
  8. +97
    -93
      StuMgmClient/StudentTree.cs
  9. +26
    -30
      StuMgmClient/SystemComm.cs
  10. +88
    -0
      StuMgmClient/SystemCtrl.cs
  11. +40
    -0
      StuMgmClient/SystemData.cs

+ 163
- 69
StuMgmClient/Data.cs Vedi File

@@ -6,16 +6,24 @@ using System.Data;

namespace StuMgmClient
{

enum ErrCode
{
Success,
FailSerial,
FailDeserial,
FailConnect,
FailSend,
FailReceive,
ErrData,
}

public enum FuncCode
{
VerifLogin = 1,
GetCourseInfo,
GetUserCourseInfo,
}
public enum Roles
{
NotFound = -1,
@@ -25,11 +33,24 @@ namespace StuMgmClient
Student = 3,
}

[Serializable]
public class ClientRequest
{
public FuncCode Func;
public object Object;
public ClientRequest(FuncCode func, object obj)
{
Func = func;
Object = obj;
}
}

[Serializable]
public class UserInfo
{
public string Account;
public string Password;
public string Token;
public Roles UserRole;
public UserInfo(string account, string password)
{
@@ -38,16 +59,89 @@ namespace StuMgmClient
}
}

public class CourseInfo
{
public short Id;
public short Pid;
public int Time;
public string Name;
public string Content;
}



[Serializable]
public enum CourseStatusEnum
{
lll,
...//
}

[Serializable]
public class ServerSend
public class UserCourseInfo
{
public short JobId;//工号
public string Name;//姓名
public string InfoDescribe;//信息描述
}























/*


#region 学生题目信息一览
#endregion

#region 学生单题详细信息
public class HistoryInfo
{
DateTime Time;
string Describe;
}
public class DetailInfo
{
public short permission { get; set; }
public DataSet ds { get; set; }
public short CourseId;
public short JobId;
List<HistoryInfo> Describes;
}
#endregion

*/







//[Serializable]
//public class ServerSend
//{
// public short permission { get; set; }
// public DataSet ds { get; set; }
//}


}
@@ -56,71 +150,71 @@ namespace StuMgmClient
namespace StuMgmClient
{

class Data
{
//状态值字符串转字典
public Dictionary<int, int> StateParsing(DataTable table)
{
Dictionary<int, int> myDictionary = new Dictionary<int, int>();
ClientMysql cm = new ClientMysql();
DataSet ds = cm.SelectState();
DataRow dr = ds.Tables["user_info"].Rows[0];
string state = dr["course_status"].ToString();
int num = 0;
int oldTem = 0;
//切割字符串
string[] sArray = state.Split(new char[2] { ':', ';' });
foreach (string i in sArray)
{
if (i.Equals("")) { break; }
int tem = Convert.ToInt32(i);
num++;
if (num % 2 != 0)
{
myDictionary.Add(tem, 0);
oldTem = tem;
}
else
{
myDictionary[oldTem] = tem;
}
}
return myDictionary;
}
//字典转字符串
public string DicParsing(Dictionary<int, int> dic)
{
string stateText = "";
foreach (var item in dic)
{
stateText = stateText + item.Key + ":" + item.Value + ";";
}
return stateText;
}
//查询所有子节点
public void GetAllNodes(string id, DataTable table, ref Dictionary<int, int> nodesDic)
{
//把父节点的数据筛选出来
DataRow[] rows = table.Select("pid =" + id);//取根
if (rows.Length <= 0)
{
nodesDic.Add(Convert.ToInt32(id), 0);
return;
}
foreach (DataRow dr in rows)
{
GetAllNodes(dr["id"].ToString(), table, ref nodesDic);
}
//class Data
//{
// //状态值字符串转字典
// public Dictionary<int, int> StateParsing(DataTable table)
// {
// Dictionary<int, int> myDictionary = new Dictionary<int, int>();
// ClientMysql cm = new ClientMysql();
// DataSet ds = cm.SelectState();
// DataRow dr = ds.Tables["user_info"].Rows[0];
// string state = dr["course_status"].ToString();
// int num = 0;
// int oldTem = 0;
// //切割字符串
// string[] sArray = state.Split(new char[2] { ':', ';' });
// foreach (string i in sArray)
// {
// if (i.Equals("")) { break; }
// int tem = Convert.ToInt32(i);
// num++;
// if (num % 2 != 0)
// {
// myDictionary.Add(tem, 0);
// oldTem = tem;
// }
// else
// {
// myDictionary[oldTem] = tem;
// }
// }
// return myDictionary;
// }
// //字典转字符串
// public string DicParsing(Dictionary<int, int> dic)
// {
// string stateText = "";
// foreach (var item in dic)
// {
// stateText = stateText + item.Key + ":" + item.Value + ";";
// }
// return stateText;
// }
// //查询所有子节点
// public void GetAllNodes(string id, DataTable table, ref Dictionary<int, int> nodesDic)
// {
// //把父节点的数据筛选出来
// DataRow[] rows = table.Select("pid =" + id);//取根
// if (rows.Length <= 0)
// {
// nodesDic.Add(Convert.ToInt32(id), 0);
// return;
// }
// foreach (DataRow dr in rows)
// {
// GetAllNodes(dr["id"].ToString(), table, ref nodesDic);
// }
}
//获取所有子节点Dictionary
public Dictionary<int, int> GetNodesDic(DataTable table)
{
Dictionary<int, int> nodesDic = new Dictionary<int, int>();
GetAllNodes("0", table, ref nodesDic);
return nodesDic;
}
}
// }
// //获取所有子节点Dictionary
// public Dictionary<int, int> GetNodesDic(DataTable table)
// {
// Dictionary<int, int> nodesDic = new Dictionary<int, int>();
// GetAllNodes("0", table, ref nodesDic);
// return nodesDic;
// }
//}
}

+ 33
- 59
StuMgmClient/LoginForm.cs Vedi File

@@ -1,22 +1,19 @@
using System;
using System.Data;
using System.Net.Sockets;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using StuMgmLib.MyNameSpace;

namespace StuMgmClient
{
public partial class LoginForm : Form
{
const string deaultIp = "10.10.0.44";
const int deaultPort = 502;
public LoginForm()
{
InitializeComponent();
SystemComm.Init(deaultIp, deaultPort);
if(SystemData.InitSystemData()!= ErrCode.Success)
throw new Exception("初始化异常,请重新启动");
}

//DataSet ds = null;

////账号密码正则校验
//public bool RegexUser(string u, string p)
@@ -47,63 +44,40 @@ namespace StuMgmClient
{

}
private void btnSubmit_Click(object sender, EventArgs e)
{
Login();
Roles userRole;
string token;

if (VerifLogin(out userRole, out token) != ErrCode.Success)
return;

switch (userRole)
{
case Roles.Student:
ShowStudentForm(token);
break;
default:
MessageBox.Show(userRole.ToString());
break;
}
}

//登陆方法
public void Login()
ErrCode VerifLogin(out Roles userRole, out string token)
{
string userName = txtUserName.Text;
string pawssword = txtPassWord.Text;
Info.ServerSend ss = ConnectServer();

ErrCode errcode = SystemCtrl.VerifLogin(txtUserName.Text, txtPassWord.Text, out userRole, out token);
if (errcode != ErrCode.Success)
MessageBox.Show(errcode.ToString());
return errcode;
}

////权限管理
// int powerNum = (int)ss.permission;
// ds = ss.ds;
// switch (powerNum)
// {
// case (int)Roles.Student:
// StudentForm stu = new StudentForm(ds);
// stu.Show();
// login.Hide();
// break;
// case (int)Roles.Teacher:
// TeacherForm tf = new TeacherForm(ds);
// tf.Show();
// login.Hide();
// break;
// case (int)Roles.Admin:
// AdminForm af = new AdminForm();
// af.Show();
// login.Hide();
// break;
// case (Int32)Roles.NotFound:
// MessageBox.Show("账号或用户名错误", "提示");
// break;
// }


////登陆连接服务器
//public Info.ServerSend ConnectServer()
//{
// Socket client= ClientConnect.Connect("10.10.0.44", 502);
// if (client== null)
// {
// MessageBox.Show("连接失败", "提示");
// return null;
// }
// else
// {
// ClientConnect.Send(client);
// Info.ServerSend ss = ClientConnect.Receive(client);
// return ss;
// }
//}
void ShowStudentForm(string token)
{
this.Hide();
StudentForm stu = new StudentForm(token);
stu.ShowDialog();
this.Show();
}
}
}

+ 0
- 1
StuMgmClient/LoginForm.designer.cs Vedi File

@@ -275,7 +275,6 @@
this.Name = "LoginForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "信捷电气学员管理系统";
this.Load += new System.EventHandler(this.LoginForm_Load);
this.tableLayoutPanel2.ResumeLayout(false);
this.tableLayoutPanel2.PerformLayout();
this.tableLayoutPanel1.ResumeLayout(false);


+ 3
- 7
StuMgmClient/StuMgmClient.csproj Vedi File

@@ -55,7 +55,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ClientConnect.cs">
<Compile Include="SystemComm.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Data.cs" />
@@ -91,6 +91,8 @@
<Compile Include="StudentNavigation.Designer.cs">
<DependentUpon>StudentNavigation.cs</DependentUpon>
</Compile>
<Compile Include="SystemCtrl.cs" />
<Compile Include="SystemData.cs" />
<Compile Include="Utility.cs" />
<EmbeddedResource Include="SelectFrom.resx">
<DependentUpon>SelectFrom.cs</DependentUpon>
@@ -128,12 +130,6 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StuMgmLib\StuMgmLib.csproj">
<Project>{34ad3363-1b1c-4f4a-898c-c1a1f215fddd}</Project>
<Name>StuMgmLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.


+ 0
- 6
StuMgmClient/StuMgmClient.sln Vedi File

@@ -5,8 +5,6 @@ VisualStudioVersion = 12.0.30501.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StuMgmClient", "StuMgmClient.csproj", "{95FDEE92-6C6E-41F1-A1C3-2FCDB1413781}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StuMgmLib", "..\StuMgmLib\StuMgmLib.csproj", "{34AD3363-1B1C-4F4A-898C-C1A1F215FDDD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -17,10 +15,6 @@ Global
{95FDEE92-6C6E-41F1-A1C3-2FCDB1413781}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95FDEE92-6C6E-41F1-A1C3-2FCDB1413781}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95FDEE92-6C6E-41F1-A1C3-2FCDB1413781}.Release|Any CPU.Build.0 = Release|Any CPU
{34AD3363-1B1C-4F4A-898C-C1A1F215FDDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34AD3363-1B1C-4F4A-898C-C1A1F215FDDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34AD3363-1B1C-4F4A-898C-C1A1F215FDDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34AD3363-1B1C-4F4A-898C-C1A1F215FDDD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE


+ 0
- 1
StuMgmClient/StudentForm.Designer.cs Vedi File

@@ -75,7 +75,6 @@ namespace StuMgmClient
this.Controls.Add(this.tlpIndex);
this.Name = "StudentForm";
this.Text = "学员信息";
this.Load += new System.EventHandler(this.StudentForm_Load);
this.tlpIndex.ResumeLayout(false);
this.ResumeLayout(false);



+ 10
- 8
StuMgmClient/StudentForm.cs Vedi File

@@ -10,19 +10,21 @@ namespace StuMgmClient
{
public partial class StudentForm : Form
{
public StudentForm(DataSet ds)
string m_token;
public StudentForm(string token)
{
InitializeComponent();
//登陆身份缓存数据
studentTree.Ds= ds;
m_token = token;
if (SystemCtrl.RefreshUserCourseInfo(token) != ErrCode.Success)
throw new Exception("获取用户信息异常,请重新启动");
}

private void StudentForm_Load(object sender, EventArgs e)
void GetStudentData()
{
}

}
}

+ 97
- 93
StuMgmClient/StudentTree.cs Vedi File

@@ -14,102 +14,106 @@ namespace StuMgmClient
{
InitializeComponent();
}
//个人信息
private DataSet ds = null;
public DataSet Ds
{
get { return ds; }
set { ds = value; }
}
//节点table
DataTable table = null;
//dataRows转化成的table
DataTable tableClone = null;
Data da = new Data();
private void StudentTree_Load(object sender, EventArgs e)
{
dgvStudent.Visible = false;
BindRoot();
//da.GetNodesDic(table);
}
////个人信息
//private DataSet ds = null;
//public DataSet Ds
//{
// get { return ds; }
// set { ds = value; }
//}
////节点table
//DataTable table = null;
////dataRows转化成的table
//DataTable tableClone = null;
//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 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 = 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 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 StudentTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left) //单击鼠标左键才响应
{
if (e.Node.Level == 1) //判断子节点才响应
{
dgvStudent.Visible = true;
DataRow dr = (DataRow)e.Node.Tag;
int fAreaId = Convert.ToInt32(dr["id"]); //子节点ID
DataRow[] drows = table.Select("pid =" + fAreaId);//取根
tableClone = table.Clone();//克隆表结构
foreach (DataRow drr in drows)
{
tableClone.ImportRow(drr);
}
dgvStudent.AutoGenerateColumns = false;
dgvStudent.AllowUserToAddRows = false;
dgvStudent.DataSource = tableClone;
}
}
}
////添加子节点的方法、递归绑定子区域
//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 StudentTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
private void StudentTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { }

//我的任务_查看按钮方法
//{
// if (e.Button == System.Windows.Forms.MouseButtons.Left) //单击鼠标左键才响应
// {
// if (e.Node.Level == 1) //判断子节点才响应
// {
// dgvStudent.Visible = true;
// DataRow dr = (DataRow)e.Node.Tag;
// int fAreaId = Convert.ToInt32(dr["id"]); //子节点ID
// DataRow[] drows = table.Select("pid =" + fAreaId);//取根
// tableClone = table.Clone();//克隆表结构
// foreach (DataRow drr in drows)
// {
// tableClone.ImportRow(drr);
// }
// dgvStudent.AutoGenerateColumns = false;
// dgvStudent.AllowUserToAddRows = false;
// dgvStudent.DataSource = tableClone;
// }
// }
//}
private void DgvStudent_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 1 && e.RowIndex != -1)
{
//Dictionary<int, int> stateDic = da.StateParsing(table);
Dictionary<int, int> stateDic = da.GetNodesDic(table);
// string s=da.DicParsing(stateDic);
DataRow drViews = tableClone.Rows[e.RowIndex];
int state = stateDic[Convert.ToInt32((drViews["id"]))];
SelectFrom sf = new SelectFrom(drViews, state);
//string test = da.DicParsing(stateDic);
sf.ShowDialog();
// ShowData();
}
}
{ }
////我的任务_查看按钮方法
//private void DgvStudent_CellContentClick(object sender, DataGridViewCellEventArgs e)
//{
// if (e.ColumnIndex == 1 && e.RowIndex != -1)
// {
// //Dictionary<int, int> stateDic = da.StateParsing(table);
// Dictionary<int, int> stateDic = da.GetNodesDic(table);
// // string s=da.DicParsing(stateDic);
// DataRow drViews = tableClone.Rows[e.RowIndex];
// int state = stateDic[Convert.ToInt32((drViews["id"]))];
// SelectFrom sf = new SelectFrom(drViews, state);
// //string test = da.DicParsing(stateDic);
// sf.ShowDialog();
// // ShowData();
// }
//}

}
}

StuMgmClient/ClientConnect.cs → StuMgmClient/SystemComm.cs Vedi File

@@ -1,37 +1,40 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;

namespace StuMgmClient
{
class Comm
class SystemComm
{
#region 基本函数
const int bufSize = 1024 * 1024;
static IPEndPoint m_ipEndpoint;
static Socket m_socket;
static byte[] m_buf;
void Init(string ip,int port)
internal static void Init(string ip, int port)
{
IPAddress ipAdress = IPAddress.Parse(ip);
m_ipEndpoint = new IPEndPoint(ipAdress, port);
m_buf = new byte[bufSize];
}
void Connect()
static bool Connect()
{
try
{
m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
m_socket.Connect(m_ipEndpoint);
return m_socket.Connected;
}
catch (Exception ex)
{
Debug.Print(ex.Message);
return false;
}
}
bool Send(byte[] data)
static bool Send(byte[] data)
{
try
{
@@ -44,7 +47,7 @@ namespace StuMgmClient
return false;
}
}
bool Receive()
static bool Receive()
{
try
{
@@ -58,42 +61,35 @@ namespace StuMgmClient
return false;
}
}
void DisConnect()
static void DisConnect()
{
client.Close();
m_socket.Close();
}
#endregion

internal ErrCode VerifLogin(string userName,string pawssword,out Roles role)
internal static ErrCode GetData(ClientRequest req,out object o)
{
role = Roles.Error;
Connect();
UserInfo cs = new UserInfo(userName,pawssword);
o = null;

if (!Connect())
return ErrCode.FailConnect;

byte[] sendBuf;
if(Utility.BinSerialize(cs,out sendBuf ))
if (!Utility.BinSerialize(req, out sendBuf))
return ErrCode.FailSerial;
if (Send(sendBuf))

if (!Send(sendBuf))
return ErrCode.FailSend;
if (Receive())

if (!Receive())
return ErrCode.FailReceive;
object o;
if (Utility.BinDeserialize(m_buf, out o))
return ErrCode.FailDeserial;
if (!(o is UserInfo))
return ErrCode.ErrData;

DisConnect();
role = ((UserInfo)o).UserRole;

if (!Utility.BinDeserialize(m_buf, out o))
return ErrCode.FailDeserial;
return ErrCode.Success;
}








}
}


+ 88
- 0
StuMgmClient/SystemCtrl.cs Vedi File

@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace StuMgmClient
{
class SystemCtrl
{
internal static ErrCode VerifLogin(string userName, string pawssword, out Roles role, out string token)
{
role = Roles.Error;
token = string.Empty;

UserInfo cs = new UserInfo(userName, pawssword);
ClientRequest req = new ClientRequest(FuncCode.VerifLogin, cs);

object o;
ErrCode err = SystemComm.GetData(req, out o);
if (err != ErrCode.Success)
return err;

if (!(o is UserInfo))
return ErrCode.ErrData;

role = ((UserInfo)o).UserRole;
token = ((UserInfo)o).Token;
return ErrCode.Success;
}

internal static ErrCode GetCourseInfo(out List<CourseInfo> courseInfo)
{
courseInfo = null;

ClientRequest req = new ClientRequest(FuncCode.VerifLogin, null);

object o;
ErrCode err = SystemComm.GetData(req, out o);
if (err != ErrCode.Success)
return err;

if (!(o is List<CourseInfo>))
return ErrCode.ErrData;

courseInfo = (List<CourseInfo>)o;
return ErrCode.Success;
}
internal static ErrCode RefreshUserCourseInfo(string token)
{
UserCourseInfo info;
ErrCode err;

err = GetUserCourseInfo(token, out info);
if (err != ErrCode.Success)
return err;

err = SystemData.RefreshUserCourseInfo(info);
if (err != ErrCode.Success)
return err;

return ErrCode.Success;
}
static ErrCode GetUserCourseInfo(string token ,out UserCourseInfo info)
{
info = null;
ClientRequest req = new ClientRequest(FuncCode.GetUserCourseInfo, token);

object o;
ErrCode err = SystemComm.GetData(req, out o);
if (err != ErrCode.Success)
return err;

if (!(o is UserCourseInfo))
return ErrCode.ErrData;

info = (UserCourseInfo)o;
return ErrCode.Success;
}







}
}

+ 40
- 0
StuMgmClient/SystemData.cs Vedi File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace StuMgmClient
{
class SystemData
{
static Dictionary<short, CourseInfo> allCourseInfo;
static Dictionary<short,CourseStatusEnum> allCourseStatus;


internal static ErrCode InitSystemData()
{
ErrCode err;
err = InitCourseInfo();
if (err != ErrCode.Success)
return err;
return ErrCode.Success;
}
static ErrCode InitCourseInfo()
{
ErrCode err;
List<CourseInfo> courseInfo;
err = SystemCtrl.GetCourseInfo(out courseInfo);
if (err != ErrCode.Success)
return err;
...//将List<CourseInfo>转为Dictionary<short, CourseInfo>
return ErrCode.Success;
}

internal static ErrCode RefreshUserCourseInfo(UserCourseInfo info)
{
...//将UserCourseInfo转为Dictionary<short,CourseStatusEnum>
return ErrCode.Success;
}


}
}

Caricamento…
Annulla
Salva