|
- using StuMgmLib.MyNameSpace;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
-
- namespace StuMgmClient
- {
- public partial class TeacherForm : Form
- {
- //状态int值转换初始dic
- Dictionary<int, string> dic = new Dictionary<int, string>();
- Dictionary<int, string> dic2 = new Dictionary<int, string>();
- DataSet ds = new DataSet();
- //登陆身份缓存数据
- DataSet userSet = null;
- //StudentMysql sms = new StudentMysql();
- public TeacherForm(short job_id, int token)
- {
- //if (SystemCtrl.RefreshAllUserCourseInfo(job_id, token) != ErrCode.Success)
- // throw new Exception("获取用户信息异常,请重新启动");
- InitializeComponent();
- // userSet = ds;
- //datagrdaview表格初始数据格式化
- //dic.Add(0, "未开始"); dic.Add(1, "进行中"); dic.Add(2, "待验收"); dic.Add(3, "等待验收中"); dic.Add(4, "验收中"); dic.Add(5, "验收完成"); dic.Add(6, "超时"); dic.Add(7, "预习");
- }
- //学员详情_修改按钮方法
- private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex == 3 && e.RowIndex != -1)
- {
- DataRow drViews = ds.Tables[0].Rows[e.RowIndex];
- SetForm set = new SetForm(drViews);
- set.ShowDialog();
- if (set.DialogResult == DialogResult.Yes)
- //ds = sms.SelectMissionState();
- ShowData(ds);
- }
- }
- //学员详情_将状态int值格式转换string
- private void DataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
- {
- //if (e.ColumnIndex == 1)
- //{
- // e.Value = dic2[Convert.ToInt32(e.Value)];
- //}
- //if (e.ColumnIndex == 2)
- //{
- // e.Value = dic[Convert.ToInt32(e.Value)];
- //}
- }
- //学员详情_自动生成编号列
- private void DataGridView1_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);
- }
- //学员详情_根据学员名字模糊查询
- private void BtnSelectStudent_Click(object sender, EventArgs e)
- {
- string text = txtStudent.Text;
- //ds = sms.SelectNameState(text);
- //ShowData(ds);
- }
- //任务管理_编辑任务
- private void BtnEditMTxt_Click(object sender, EventArgs e)
- {
- rtxMission.Enabled = true;
- }
- //任务管理_下拉框选择
- private void CboMission_SelectedIndexChanged(object sender, EventArgs e)
- {
- //DataSet dsManagement = sms.SelectMissionOne(this.cboMission.SelectedIndex);
- // string mContent = dsManagement.Tables["mission"].Rows[0]["Content"].ToString();
- // rtxMission.Text = mContent;
- rtxMission.Enabled = false;
- }
- //任务管理_保存修改的内容
- private void BtnSavaTxt_Click(object sender, EventArgs e)
- {
- if (rtxMission.Enabled == true)
- {
- int mission = cboMission.SelectedIndex;
- string text = rtxMission.Text;
- //// int result = sms.UpdateContent(mission, text);
- // if (result > 0)
- // {
- // MessageBox.Show("保存成功", "提示");
- // }
- // else
- // {
- // MessageBox.Show("保存失败", "提示");
- // }
- }
- }
- //个人信息_数据回显
- private void PanUserInfo_Paint(object sender, PaintEventArgs e)
- {
- lblUserNameV.Text = userSet.Tables["user"].Rows[0]["Name"].ToString();
- int powerNum = Convert.ToInt32(userSet.Tables["user"].Rows[0]["Power"]);
- string s = powerNum == 1 ? "学生" : powerNum == 2 ? "教师" : "管理员";
- lblUsershenfenV.Text = s;
- }
- //切换账号_切换
- private void BtnSwAccount_Click(object sender, EventArgs e)
- {
- DialogResult result = MessageBox.Show("是否切换账号", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (result == DialogResult.OK)
- {
- this.Dispose();
- //LoginForm.login.Show();
- }
- }
- //左侧导航栏_切换到学员详情
- private void BtnStudent_Click(object sender, EventArgs e)
- {
- panStudent.Visible = true;
- panStudent.BringToFront();//将pan置顶
- }
- //左侧导航栏_切换到任务管理
- private void BtnFile_Click(object sender, EventArgs e)
- {
- cboMission.SelectedIndex = 0;//设置显示的item索引
- panManagement.Enabled = true;
- panManagement.Visible = true;
- panManagement.BringToFront();
- }
- //左侧导航栏_切换到个人信息
- private void BtnUserInfo_Click(object sender, EventArgs e)
- {
- panUserInfo.Enabled = true;
- panUserInfo.Visible = true;
- panUserInfo.BringToFront();
- }
- //窗体加载初始化数据
- private void TeacherForm_Load(object sender, EventArgs e)
- {
- // ds = sms.SelectMissionState();
- // ShowData(ds);
- }
- //初始化数据公用方法
- private void ShowData(DataSet ds)
- {
- DataTable dtb = ds.Tables[0];
- dgvStudent.AutoGenerateColumns = false;
- dgvStudent.AllowUserToAddRows = false;
- dgvStudent.DataSource = dtb;
- }
- }
- }
|