frmclassname.cs

来自「实现课程表编排和打印功能,通过在候选列表中选择课程和教师(没有被排课且该教师教授」· CS 代码 · 共 81 行

CS
81
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace 课程安排
{
    public partial class frmClassName : Form
    {
        private string className = "";
        public string ClassName
        {
            get { return className; }
        }

        private DateTime classStartTime;
        public DateTime ClassStartTime
        {
            get { return classStartTime; }
        }

        public frmClassName(Grade grade)
        {
            InitializeComponent();
            this.textBox2.Enabled = true;
            this.textBox2.Text = DateTime.Today.Year.ToString();

            if (grade != null)
            {
                EditLevel el = Utility.GetEditLevel(grade.GradeName);
                DateTime dt = Utility.GetStartTime(grade.GradeName, el);
                this.textBox2.Text = dt.Year.ToString();
            }
        }

        public frmClassName(string oldName)
        {
            InitializeComponent();
            this.textBox1.Text = oldName;
            this.textBox2.Enabled = false;
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.className = this.textBox1.Text;
            if (GetDateTime() == false)
            {
                MessageBox.Show("所输入的年度错误,请重新输入,如'2008'", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.textBox2.Text = "";
                return;
            }
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.No;
            this.Close();
        }

        private bool GetDateTime()
        {
            bool b = false;
            if (textBox2.Enabled == false) return true;
            if (Utility.isYearString(this.textBox2.Text))
            {
                int year = Convert.ToInt32(this.textBox2.Text);
                DateTime dt = new DateTime(year, 9, 1);
                this.classStartTime = dt;
                b = true;
            }
            return b;
            //return Convert.ToDateTime(this.dateTimePicker1.Text);
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?