@@ -11,7 +11,6 @@ namespace StuMgmClient | |||
public partial class SelectFrom : Form | |||
{ | |||
Dictionary<int, string> dic = new Dictionary<int, string>(); | |||
Dictionary<int, string> dic2 = new Dictionary<int, string>(); | |||
DataRow dr = null; | |||
int stateN = 0; | |||
public SelectFrom(DataRow drView,int state) | |||
@@ -20,11 +19,9 @@ namespace StuMgmClient | |||
dr=drView; | |||
stateN = state; | |||
dic.Add(0, "未开始"); dic.Add(1, "进行中"); dic.Add(2, "待验收"); dic.Add(3, "等待验收中"); dic.Add(4, "验收中"); dic.Add(5, "验收完成"); dic.Add(6, "超时"); dic.Add(7, "预习"); | |||
dic2.Add(0, "基础学习(一阶段)"); dic2.Add(1, "四则运算(一阶段)"); dic2.Add(2, "算法题(一阶段)"); dic2.Add(3, "Modbus(一阶段)"); dic2.Add(4, "待定(二阶段)"); dic2.Add(5, "待定(二阶段)"); | |||
} | |||
private void SelectFrom_Load(object sender, EventArgs e) | |||
{ | |||
//MssionPower(); | |||
ShowData(dr); | |||
} | |||
//数据回显 | |||
@@ -59,34 +56,34 @@ namespace StuMgmClient | |||
this.Dispose(); | |||
} | |||
} | |||
//状态值改变控件 | |||
public void MssionPower() | |||
{ | |||
//任务权限 | |||
int stateNum = Convert.ToInt32(dr["State"]); | |||
switch (stateNum) | |||
{ | |||
case 0: | |||
dr["Content"] = "当前不可查看"; | |||
lblTime.Visible = false; | |||
lblState.Visible = false; | |||
btnSumit.Visible = false; | |||
break; | |||
case 1: | |||
btnSumit.Visible = true; | |||
break; | |||
case 2: | |||
case 3: | |||
case 4: | |||
case 5: | |||
case 6: | |||
btnSumit.Visible = false; | |||
break; | |||
case 7: | |||
lblTime.Visible = false; | |||
btnSumit.Visible = false; | |||
break; | |||
} | |||
} | |||
////状态值改变控件 | |||
//public void MssionPower() | |||
//{ | |||
// //任务权限 | |||
// int stateNum = Convert.ToInt32(dr["State"]); | |||
// switch (stateNum) | |||
// { | |||
// case 0: | |||
// dr["Content"] = "当前不可查看"; | |||
// lblTime.Visible = false; | |||
// lblState.Visible = false; | |||
// btnSumit.Visible = false; | |||
// break; | |||
// case 1: | |||
// btnSumit.Visible = true; | |||
// break; | |||
// case 2: | |||
// case 3: | |||
// case 4: | |||
// case 5: | |||
// case 6: | |||
// btnSumit.Visible = false; | |||
// break; | |||
// case 7: | |||
// lblTime.Visible = false; | |||
// btnSumit.Visible = false; | |||
// break; | |||
// } | |||
//} | |||
} | |||
} |
@@ -7,6 +7,7 @@ namespace StuMgmClient | |||
public partial class StudentForm : Form | |||
{ | |||
int m_token; | |||
int m_jobId; | |||
public StudentForm(short job_id, int token) | |||
{ | |||
m_token = token; | |||
@@ -5,6 +5,7 @@ using System.Drawing; | |||
using System.Data; | |||
using System.Text; | |||
using System.Windows.Forms; | |||
using StuMgmLib.MyNameSpace; | |||
namespace StuMgmClient | |||
{ | |||
@@ -15,33 +16,23 @@ namespace StuMgmClient | |||
InitializeComponent(); | |||
} | |||
DataTable db = null; | |||
////个人信息 | |||
//private DataSet ds = null; | |||
//public DataSet Ds | |||
//{ | |||
// get { return ds; } | |||
// set { ds = value; } | |||
//} | |||
////节点table | |||
//DataTable table = null; | |||
////dataRows转化成的table | |||
//DataTable tableClone = null; | |||
Dictionary<short, CourseStatusEnum> allCourseStatus = null; | |||
//dataRows转化成的table | |||
DataTable tableClone = null; | |||
//Data da = new Data(); | |||
private void StudentTree_Load(object sender, EventArgs e) | |||
{ | |||
db = SystemCtrl.GetStreeTable(); | |||
db = SystemCtrl.GetTable(); | |||
allCourseStatus= SystemData.StreeCourseStatus(); | |||
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 = db.Select("FirstNode=0");//取根 | |||
//把父节点的数据帅选出来 | |||
DataRow[] rows = db.Select("Pid=0");//取根 | |||
foreach (DataRow dRow in rows) | |||
{ | |||
TreeNode rootNode = new TreeNode(); | |||
@@ -54,12 +45,12 @@ namespace StuMgmClient | |||
} | |||
} | |||
////添加子节点的方法、递归绑定子区域 | |||
//添加子节点的方法、递归绑定子区域 | |||
private void BindChildAreas(TreeNode fNode) | |||
{ | |||
DataRow dr = (DataRow)fNode.Tag;//父节点数据关联的数据行 | |||
int fAreaId = Convert.ToInt32(dr["Id"]); //父节点ID | |||
DataRow[] rows1 = db.Select("SecondNode =" + fAreaId);//子区域 | |||
DataRow[] rows1 = db.Select("Pid =" + fAreaId);//子区域 | |||
if (rows1.Length == 0) //递归终止,区域不包含子区域时 | |||
{ | |||
return; | |||
@@ -73,48 +64,42 @@ namespace StuMgmClient | |||
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) | |||
{ } | |||
//子节点单击显示内容 | |||
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 = db.Select("pid =" + fAreaId);//取根 | |||
tableClone = db.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) | |||
{ | |||
DataRow drViews = tableClone.Rows[e.RowIndex]; | |||
short idState = Convert.ToInt16((drViews["id"])); | |||
int state=(int)allCourseStatus[idState]; | |||
SelectFrom sf = new SelectFrom(drViews, state); | |||
//string test = da.DicParsing(stateDic); | |||
sf.ShowDialog(); | |||
} | |||
} | |||
} | |||
} |
@@ -86,9 +86,10 @@ namespace StuMgmClient | |||
return ErrCode.Success; | |||
} | |||
internal static DataTable GetStreeTable() | |||
internal static DataTable GetTable() | |||
{ | |||
return SystemData.StreeTable(); | |||
return SystemData.StreeTable(); | |||
} | |||
} | |||
} |
@@ -13,7 +13,7 @@ namespace StuMgmClient | |||
{ | |||
static Dictionary<short, CourseInfo> allCourseInfo; | |||
static Dictionary<short,CourseStatusEnum> allCourseStatus; | |||
static List<StreeDatas> allStreeDatas; | |||
static List<CourseInfo> courseInfo; | |||
internal static ErrCode InitSystemData() | |||
{ | |||
ErrCode err; | |||
@@ -25,7 +25,8 @@ namespace StuMgmClient | |||
static ErrCode InitCourseInfo() | |||
{ | |||
ErrCode err; | |||
List<CourseInfo> courseInfo; | |||
//List<CourseInfo> | |||
courseInfo = new List<CourseInfo>(); ; | |||
err = SystemCtrl.GetCourseInfo(out courseInfo); | |||
if (err != ErrCode.Success) | |||
return err; | |||
@@ -60,27 +61,71 @@ namespace StuMgmClient | |||
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) | |||
//internal static void StreeList() | |||
//{ | |||
// allStreeDatas = new Dictionary<short,UserCourseDetail>(); | |||
// foreach (var item in allCourseStatus) | |||
// { | |||
// UserCourseDetail courseDetail = new UserCourseDetail(); | |||
// CourseInfo info = allCourseInfo[item.Key];//找到状态对应的课程表信息 | |||
// courseDetail.Id = info.Id; | |||
// courseDetail.Name = info.Name; | |||
// courseDetail.Status = (int)item.Value; | |||
// courseDetail.Content = info.Content; | |||
// allStreeDatas.Add(info.Pid,courseDetail); | |||
// } | |||
//} | |||
//internal static UserCourseDetail r(CourseInfo info, ref Dictionary<short, UserCourseDetail> allCourseStatus) | |||
//{ | |||
// UserCourseDetail sel; | |||
// if (allCourseStatus.TryGetValue(info.Id, out sel)) | |||
// return sel; | |||
// UserCourseDetail m = new UserCourseDetail(); | |||
// //info->m | |||
// allCourseStatus.Add(info.Id, m); | |||
// if (info.Pid != 0) | |||
// { | |||
// UserCourseDetail father = r(allCourseInfo[info.Pid], ref allCourseStatus); | |||
// father.Children.Add(m); | |||
// } | |||
// return m; | |||
//} | |||
//internal static void rr(UserCourseDetail u, TreeNode n) | |||
//{ | |||
// foreach(UserCourseDetail child in u.Children) | |||
// { | |||
// TreeNode node = new TreeNode(child); | |||
// n.add(node); | |||
// rr(child, node); | |||
// } | |||
//} | |||
//internal static void aa (List<string> keys,List<string> values) | |||
//{ | |||
// Dictionary<short, UserCourseDetail> allCourseStatus=new Dictionary<short,UserCourseDetail>(); | |||
// for (short i = 0; i < keys.Count; i++) | |||
// r(allCourseInfo[i], ref allCourseStatus); | |||
// List<UserCourseDetail> lst = new List<UserCourseDetail>(); | |||
// // | |||
// //TreeNode all; | |||
// List<TreeNode> all; | |||
// foreach(UserCourseDetail u in lst) | |||
// { | |||
// TreeNode n = new TreeNode(); | |||
// rr(u, n); | |||
// all.add(n); | |||
// } | |||
//} | |||
static DataTable ListToDb(List<CourseInfo> list) | |||
{ | |||
DataTable dt = new DataTable(); | |||
dt.Columns.Add("Id", typeof(int)); | |||
@@ -97,18 +142,17 @@ namespace StuMgmClient | |||
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); | |||
return ListToDb(courseInfo); | |||
} | |||
internal static Dictionary<short, CourseStatusEnum> StreeCourseStatus() | |||
{ | |||
return allCourseStatus; | |||
} | |||
} | |||
} |
@@ -1,4 +1,5 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
@@ -70,7 +71,8 @@ namespace StuMgmLib.MyNameSpace | |||
[Serializable] | |||
public enum CourseStatusEnum | |||
{ | |||
NoStart = 0, | |||
Null = 0, | |||
NoStart, | |||
Begin, | |||
WaitCheckig, | |||
CheckigSuccess, | |||
@@ -100,15 +102,15 @@ namespace StuMgmLib.MyNameSpace | |||
Object = obj; | |||
} | |||
} | |||
public class StreeDatas | |||
public class UserCourseDetail | |||
{ | |||
public int Id; | |||
public short Id; | |||
public string Name; | |||
public int Pid; | |||
public string Content; | |||
public int Statu; | |||
public int FirstNode; | |||
public int SecondNode; | |||
public int Time; | |||
public int Status; | |||
public List<UserCourseDetail> Children; | |||
} | |||
} | |||