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 SetForm : Form
    {
        //StudentMysql sms = new StudentMysql();
        Dictionary<int, string> dic = new Dictionary<int, string>();
        Dictionary<int, string> dic2 = new Dictionary<int, string>();
        int id = 0;
        int missionId = 0;
        public SetForm(DataRow dr)
        {
            InitializeComponent();
            showData(dr);
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }
        //数据回显
        public void showData(DataRow dr)
        {
            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, "待定(二阶段)");
            lblName.Text = dr["Name"].ToString();
            id = Convert.ToInt32(dr["ID"]);
            missionId = Convert.ToInt32(dr["MissionId"]);
           lblMission.Text = dic2[missionId];
           int state = Convert.ToInt32(dr["State"]);
            comboBox2.SelectedIndex = state;//设置显示的item索引
            try
            {
                dateTimePicker1.Value = Convert.ToDateTime(dr["Time"]);
            }
            catch 
            {
                dateTimePicker1.Text = "";
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.No;
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Yes;
            DateTime dt= dateTimePicker1.Value;
            int st=comboBox2.SelectedIndex;
            //int s= sms.UpdateSet(id, missionId, dt, st);
            this.Close();
        }

        private void SetForm_Load(object sender, EventArgs e)
        {

        }
    }
}