您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

154 行
6.2 KiB

  1. using StuMgmLib.MyNameSpace;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace StuMgmClient
  10. {
  11. public partial class TeacherForm : Form
  12. {
  13. //状态int值转换初始dic
  14. Dictionary<int, string> dic = new Dictionary<int, string>();
  15. Dictionary<int, string> dic2 = new Dictionary<int, string>();
  16. DataSet ds = new DataSet();
  17. //登陆身份缓存数据
  18. DataSet userSet = null;
  19. //StudentMysql sms = new StudentMysql();
  20. public TeacherForm(short job_id, int token)
  21. {
  22. //if (SystemCtrl.RefreshAllUserCourseInfo(job_id, token) != ErrCode.Success)
  23. // throw new Exception("获取用户信息异常,请重新启动");
  24. InitializeComponent();
  25. // userSet = ds;
  26. //datagrdaview表格初始数据格式化
  27. //dic.Add(0, "未开始"); dic.Add(1, "进行中"); dic.Add(2, "待验收"); dic.Add(3, "等待验收中"); dic.Add(4, "验收中"); dic.Add(5, "验收完成"); dic.Add(6, "超时"); dic.Add(7, "预习");
  28. }
  29. //学员详情_修改按钮方法
  30. private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  31. {
  32. if (e.ColumnIndex == 3 && e.RowIndex != -1)
  33. {
  34. DataRow drViews = ds.Tables[0].Rows[e.RowIndex];
  35. SetForm set = new SetForm(drViews);
  36. set.ShowDialog();
  37. if (set.DialogResult == DialogResult.Yes)
  38. //ds = sms.SelectMissionState();
  39. ShowData(ds);
  40. }
  41. }
  42. //学员详情_将状态int值格式转换string
  43. private void DataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
  44. {
  45. //if (e.ColumnIndex == 1)
  46. //{
  47. // e.Value = dic2[Convert.ToInt32(e.Value)];
  48. //}
  49. //if (e.ColumnIndex == 2)
  50. //{
  51. // e.Value = dic[Convert.ToInt32(e.Value)];
  52. //}
  53. }
  54. //学员详情_自动生成编号列
  55. private void DataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
  56. {
  57. Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgvStudent.RowHeadersWidth - 4, e.RowBounds.Height);
  58. TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), dgvStudent.RowHeadersDefaultCellStyle.Font, rectangle, dgvStudent.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
  59. }
  60. //学员详情_根据学员名字模糊查询
  61. private void BtnSelectStudent_Click(object sender, EventArgs e)
  62. {
  63. string text = txtStudent.Text;
  64. //ds = sms.SelectNameState(text);
  65. //ShowData(ds);
  66. }
  67. //任务管理_编辑任务
  68. private void BtnEditMTxt_Click(object sender, EventArgs e)
  69. {
  70. rtxMission.Enabled = true;
  71. }
  72. //任务管理_下拉框选择
  73. private void CboMission_SelectedIndexChanged(object sender, EventArgs e)
  74. {
  75. //DataSet dsManagement = sms.SelectMissionOne(this.cboMission.SelectedIndex);
  76. // string mContent = dsManagement.Tables["mission"].Rows[0]["Content"].ToString();
  77. // rtxMission.Text = mContent;
  78. rtxMission.Enabled = false;
  79. }
  80. //任务管理_保存修改的内容
  81. private void BtnSavaTxt_Click(object sender, EventArgs e)
  82. {
  83. if (rtxMission.Enabled == true)
  84. {
  85. int mission = cboMission.SelectedIndex;
  86. string text = rtxMission.Text;
  87. //// int result = sms.UpdateContent(mission, text);
  88. // if (result > 0)
  89. // {
  90. // MessageBox.Show("保存成功", "提示");
  91. // }
  92. // else
  93. // {
  94. // MessageBox.Show("保存失败", "提示");
  95. // }
  96. }
  97. }
  98. //个人信息_数据回显
  99. private void PanUserInfo_Paint(object sender, PaintEventArgs e)
  100. {
  101. lblUserNameV.Text = userSet.Tables["user"].Rows[0]["Name"].ToString();
  102. int powerNum = Convert.ToInt32(userSet.Tables["user"].Rows[0]["Power"]);
  103. string s = powerNum == 1 ? "学生" : powerNum == 2 ? "教师" : "管理员";
  104. lblUsershenfenV.Text = s;
  105. }
  106. //切换账号_切换
  107. private void BtnSwAccount_Click(object sender, EventArgs e)
  108. {
  109. DialogResult result = MessageBox.Show("是否切换账号", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  110. if (result == DialogResult.OK)
  111. {
  112. this.Dispose();
  113. //LoginForm.login.Show();
  114. }
  115. }
  116. //左侧导航栏_切换到学员详情
  117. private void BtnStudent_Click(object sender, EventArgs e)
  118. {
  119. panStudent.Visible = true;
  120. panStudent.BringToFront();//将pan置顶
  121. }
  122. //左侧导航栏_切换到任务管理
  123. private void BtnFile_Click(object sender, EventArgs e)
  124. {
  125. cboMission.SelectedIndex = 0;//设置显示的item索引
  126. panManagement.Enabled = true;
  127. panManagement.Visible = true;
  128. panManagement.BringToFront();
  129. }
  130. //左侧导航栏_切换到个人信息
  131. private void BtnUserInfo_Click(object sender, EventArgs e)
  132. {
  133. panUserInfo.Enabled = true;
  134. panUserInfo.Visible = true;
  135. panUserInfo.BringToFront();
  136. }
  137. //窗体加载初始化数据
  138. private void TeacherForm_Load(object sender, EventArgs e)
  139. {
  140. // ds = sms.SelectMissionState();
  141. // ShowData(ds);
  142. }
  143. //初始化数据公用方法
  144. private void ShowData(DataSet ds)
  145. {
  146. DataTable dtb = ds.Tables[0];
  147. dgvStudent.AutoGenerateColumns = false;
  148. dgvStudent.AllowUserToAddRows = false;
  149. dgvStudent.DataSource = dtb;
  150. }
  151. }
  152. }