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 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)
        {
            InitializeComponent();
            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);
        }
        //数据回显
        public void ShowData(DataRow dr)
        {
            
            txtMsg.Text = dr["Content"].ToString();
            label2.Text =dr["name"].ToString();
            lblState.Text = dic[stateN];
            //try
            //{
            //    lblTime.Text = Convert.ToDateTime(dr["Time"]).ToString("yyyy-MM-dd");
            //}
            //catch 
            //{
            //    lblTime.Text = "";
            //}
        }
        //提交事件
        private void btnSumit_Click(object sender, EventArgs e)
        {

            DialogResult result = MessageBox.Show("是否确定提交", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (result == DialogResult.OK)
            {
                int userNameId = Convert.ToInt32(dr["NameId"]);
                int nowMssionId = Convert.ToInt32(dr["MissionId"]);
                int newMssionId = nowMssionId+1;
             //   sms.UpdateState(userNameId, nowMssionId, newMssionId);
                MessageBox.Show("提交成功，可预习下一阶段内容", "提示");
                btnSumit.Visible = false;
                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;
            }
        } 
    }
}
