diff --git a/StuMgmClient/SelectFrom.cs b/StuMgmClient/SelectFrom.cs index fbcf18b..d7fdc95 100644 --- a/StuMgmClient/SelectFrom.cs +++ b/StuMgmClient/SelectFrom.cs @@ -11,21 +11,16 @@ namespace StuMgmClient { public partial class SelectFrom : Form { - - Dictionary dic = new Dictionary(); DataRow dr = null; - Dictionary dicStatus; short t_job_id; int t_token; int stateNum; - public SelectFrom(DataRow drView, Dictionary allCourseStatus, short job_id, int toKen) + public SelectFrom(DataRow drView, short job_id, int toKen) { InitializeComponent(); dr=drView; - dicStatus = allCourseStatus; t_job_id = job_id; t_token = toKen; - dic.Add(0, "未开始"); dic.Add(1, "进行中"); dic.Add(2, "待验收"); dic.Add(3, "验收成功"); dic.Add(4, "验收失败"); } private void SelectFrom_Load(object sender, EventArgs e) { @@ -35,11 +30,11 @@ namespace StuMgmClient public void ShowData(DataRow dr) { short idState = Convert.ToInt16((dr["id"])); - stateNum= (int)dicStatus[idState]; + stateNum = (int)dr["Statu"]; MssionPower(stateNum); txtMsg.Text = dr["Content"].ToString(); label2.Text =dr["name"].ToString(); - lblState.Text = dic[stateNum]; + lblState.Text = Utility.InitState(stateNum); //try //{ @@ -58,17 +53,18 @@ namespace StuMgmClient if (result == DialogResult.OK) { short idState = Convert.ToInt16((dr["id"])); - dicStatus[idState]=(CourseStatusEnum)2; + SystemData.allCourseStatus[idState]=(CourseStatusEnum)2; UserCourseInfoOper o = new UserCourseInfoOper(); o.Job_Id = t_job_id; o.Token = t_token; - Utility.DicParsing(dicStatus); - o.Status = Utility.DicParsing(dicStatus); + Utility.DicParsing(SystemData.allCourseStatus); + o.Status = Utility.DicParsing(SystemData.allCourseStatus); if (SystemCtrl.SendUserCourseInfoOper(o) != ErrCode.Success) MessageBox.Show("提交失败,请联系管理员", "提示"); MessageBox.Show("提交成功,可预习下一阶段内容", "提示"); + lblState.Text = "待验收"; btnSumit.Visible = false; - this.Dispose(); + //this.Dispose(); } } @@ -81,8 +77,8 @@ namespace StuMgmClient { case 0: dr["Content"] = "当前不可查看"; - lblTime.Visible = false; - lblState.Visible = false; + lblTime.Text = "未开始"; + lblState.Text = "未开始"; btnSumit.Visible = false; break; case 1: diff --git a/StuMgmClient/StudentTree.Designer.cs b/StuMgmClient/StudentTree.Designer.cs index 9bcb90a..40f602a 100644 --- a/StuMgmClient/StudentTree.Designer.cs +++ b/StuMgmClient/StudentTree.Designer.cs @@ -30,13 +30,15 @@ { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.StudenTree = new System.Windows.Forms.TreeView(); this.dgvStudent = new System.Windows.Forms.DataGridView(); this.任务名称 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.任务状态 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.操作 = new System.Windows.Forms.DataGridViewButtonColumn(); this.tableLayoutPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgvStudent)).BeginInit(); @@ -70,6 +72,8 @@ // // dgvStudent // + this.dgvStudent.AllowUserToAddRows = false; + this.dgvStudent.AllowUserToDeleteRows = false; this.dgvStudent.AllowUserToResizeColumns = false; this.dgvStudent.AllowUserToResizeRows = false; dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; @@ -84,28 +88,34 @@ dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; this.dgvStudent.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; this.dgvStudent.ColumnHeadersHeight = 40; + this.dgvStudent.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dgvStudent.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.任务名称, + this.任务状态, this.操作}); this.dgvStudent.Dock = System.Windows.Forms.DockStyle.Fill; this.dgvStudent.EnableHeadersVisualStyles = false; this.dgvStudent.Location = new System.Drawing.Point(205, 3); this.dgvStudent.MultiSelect = false; this.dgvStudent.Name = "dgvStudent"; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.WhiteSmoke; - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.Black; - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.WhiteSmoke; - this.dgvStudent.RowsDefaultCellStyle = dataGridViewCellStyle5; + this.dgvStudent.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.WhiteSmoke; + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.WhiteSmoke; + this.dgvStudent.RowsDefaultCellStyle = dataGridViewCellStyle6; this.dgvStudent.RowTemplate.DefaultCellStyle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.dgvStudent.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.SystemColors.Highlight; this.dgvStudent.RowTemplate.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.WhiteSmoke; this.dgvStudent.RowTemplate.Height = 33; this.dgvStudent.RowTemplate.ReadOnly = true; this.dgvStudent.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.dgvStudent.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dgvStudent.Size = new System.Drawing.Size(466, 432); this.dgvStudent.TabIndex = 1; this.dgvStudent.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DgvStudent_CellContentClick); + this.dgvStudent.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.DgvStudent_CellFormatting); + this.dgvStudent.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.DgvStudent_RowPostPaint); // // 任务名称 // @@ -116,22 +126,32 @@ this.任务名称.DefaultCellStyle = dataGridViewCellStyle3; this.任务名称.HeaderText = "任务名称"; this.任务名称.Name = "任务名称"; + this.任务名称.ReadOnly = true; + // + // 任务状态 + // + this.任务状态.DataPropertyName = "Statu"; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 9F); + this.任务状态.DefaultCellStyle = dataGridViewCellStyle4; + this.任务状态.HeaderText = "任务状态"; + this.任务状态.Name = "任务状态"; + this.任务状态.ReadOnly = true; // // 操作 // this.操作.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.DarkSeaGreen; - dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle4.ForeColor = System.Drawing.Color.Transparent; - dataGridViewCellStyle4.NullValue = "查看详情"; - dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.Transparent; - dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.Transparent; - this.操作.DefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.DarkSeaGreen; + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle5.NullValue = "查看详情"; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.Transparent; + this.操作.DefaultCellStyle = dataGridViewCellStyle5; this.操作.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.操作.HeaderText = "操作"; this.操作.Name = "操作"; - this.操作.Resizable = System.Windows.Forms.DataGridViewTriState.True; this.操作.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; this.操作.Text = ""; // @@ -155,6 +175,7 @@ private System.Windows.Forms.TreeView StudenTree; private System.Windows.Forms.DataGridView dgvStudent; private System.Windows.Forms.DataGridViewTextBoxColumn 任务名称; + private System.Windows.Forms.DataGridViewTextBoxColumn 任务状态; private System.Windows.Forms.DataGridViewButtonColumn 操作; } } diff --git a/StuMgmClient/StudentTree.cs b/StuMgmClient/StudentTree.cs index 1571fed..b58a02e 100644 --- a/StuMgmClient/StudentTree.cs +++ b/StuMgmClient/StudentTree.cs @@ -17,17 +17,14 @@ namespace StuMgmClient internal short Job_id; internal int Token; DataTable db = null; - Dictionary allCourseStatus = null; //dataRows转化成的table DataTable tableClone = null; //Data da = new Data(); private void StudentTree_Load(object sender, EventArgs e) { db = SystemCtrl.GetTable(); - allCourseStatus= SystemData.StreeCourseStatus(); dgvStudent.Visible = false; BindRoot(); - //da.GetNodesDic(table); } //添加父节点的方法 private void BindRoot() @@ -73,6 +70,7 @@ namespace StuMgmClient { if (e.Node.Level == 1) //判断子节点才响应 { + SystemCtrl.RefreshUserCourseInfo(Job_id, Token); dgvStudent.Visible = true; DataRow dr = (DataRow)e.Node.Tag; int fAreaId = Convert.ToInt32(dr["id"]); //子节点ID @@ -88,18 +86,38 @@ namespace StuMgmClient } } } + + ////我的任务_查看按钮方法 private void DgvStudent_CellContentClick(object sender, DataGridViewCellEventArgs e) { - if (e.ColumnIndex == 1 && e.RowIndex != -1) + if (e.ColumnIndex == 2 && e.RowIndex != -1) { DataRow drViews = tableClone.Rows[e.RowIndex]; - SelectFrom sf = new SelectFrom(drViews, allCourseStatus, Job_id, Token); + SelectFrom sf = new SelectFrom(drViews,Job_id, Token); //string test = da.DicParsing(stateDic); sf.ShowDialog(); + db = SystemCtrl.GetTable(); + } } + + private void DgvStudent_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) + { + Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgvStudent.RowHeadersWidth - 4, e.RowBounds.Height); + TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), dgvStudent.RowHeadersDefaultCellStyle.Font, rectangle, dgvStudent.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right); + } + + + //我的任务_将状态int值格式转换string + private void DgvStudent_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) + { + if (e.ColumnIndex == 1) + { + e.Value = Utility.InitState((int)e.Value); + } + } } } diff --git a/StuMgmClient/StudentTree.resx b/StuMgmClient/StudentTree.resx index 7b6b4f6..87f933e 100644 --- a/StuMgmClient/StudentTree.resx +++ b/StuMgmClient/StudentTree.resx @@ -112,15 +112,21 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + True - + + True + + + True + + True \ No newline at end of file diff --git a/StuMgmClient/SystemData.cs b/StuMgmClient/SystemData.cs index caff967..5c237c1 100644 --- a/StuMgmClient/SystemData.cs +++ b/StuMgmClient/SystemData.cs @@ -12,7 +12,7 @@ namespace StuMgmClient class SystemData { static Dictionary allCourseInfo; - static Dictionary allCourseStatus; + internal static Dictionary allCourseStatus; static List courseInfo; internal static ErrCode InitSystemData() { @@ -140,6 +140,14 @@ namespace StuMgmClient dr[1] = list[i].Name; dr[2] = list[i].Pid; dr[3] = list[i].Content; + try + { + dr[4] = (int)allCourseStatus[(short)list[i].Id]; + } + catch + { + dr[4] = -1; + } dt.Rows.Add(dr); } return dt; diff --git a/StuMgmClient/Utility.cs b/StuMgmClient/Utility.cs index fc54979..bf93419 100644 --- a/StuMgmClient/Utility.cs +++ b/StuMgmClient/Utility.cs @@ -55,5 +55,12 @@ namespace StuMgmClient } return stateText; } + + internal static string InitState(int state) + { + Dictionary dic = new Dictionary(); + dic.Add(0, "未开始"); dic.Add(1, "进行中"); dic.Add(2, "待验收"); dic.Add(3, "验收成功"); dic.Add(4, "验收失败"); + return dic[state]; + } } }