码迷,mamicode.com
首页 > 其他好文 > 详细

lab5源代码

时间:2015-04-10 17:24:08      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:

//个人信息采集

private void button1_Click(object sender, EventArgs e)
        {
            
            textBox3.Text =
                  "你好,我是 "
                + textBox1.Text
                + " ,我的性别为 "
                + (radioButton1.Checked ? radioButton1.Text : "")
                + (radioButton2.Checked ? radioButton2.Text : "")
                + (radioButton3.Checked ? radioButton3.Text : "")
                + " ,今年 "
                + textBox2.Text
                + " 岁,具有 "
                + comboBox1.Text
                + " 学位,我爱好 "
                + (checkBox1.Checked ? checkBox1.Text : "")
                + (checkBox2.Checked ? checkBox2.Text : "")
                + (checkBox3.Checked ? checkBox3.Text : "")
                + (checkBox4.Checked ? checkBox4.Text : "")
                + "      that‘s all!";
        }

        private void textBox2_KeyUp(object sender, KeyEventArgs e)
        {
            string a0 = textBox2.Text;
            int a = -1;
            if (!int.TryParse(a0, out a) || (a < 0 || a > 200))
            {
                textBox3.Text = "请在年龄一格输入正确数字";
                textBox2.Text = "";
                e.Handled = true;
            }
            return;




//采购单
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
           button1.Enabled = comboBox1.Enabled = textBox1.Enabled = checkBox1.Checked;

        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar < 0 || e.KeyChar > 9) && e.KeyChar != 8)
            {
                textBox1.Text = "";
                e.Handled = true;
            }
            return;
        }

        private void button1_Click(object sender, EventArgs e)
        {
           listBox1.Items.Add(comboBox1.SelectedIndex==-1?"":comboBox1.SelectedItem);
           if(radioButton1.Checked||radioButton2.Checked)
               listBox1.Items.Add(radioButton1.Checked ? radioButton1.Text : radioButton2.Text);
           
            listBox1.Items.Add(textBox1.Text);
            listBox1.Items.Add("");
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            radioButton1.Enabled = radioButton2.Enabled = checkBox2.Checked;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
        }


//选课
        private void button4_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text = listBox1.Items.Count.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            listBox1.Items.Remove(listBox1.SelectedItem);
            button2.Enabled = Convert.ToBoolean(listBox1.Items.Count);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (listBox1.Items.Contains(textBox2.Text)) MessageBox.Show("课程<" + textBox2.Text + ">在课程列表中已存在", "重复错误!");
            else listBox1.Items.Add(textBox2.Text);
            textBox2.Text = "";
            button2.Enabled = Convert.ToBoolean(listBox1.Items.Count);
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            textBox2.Text = listBox1.SelectedItem==null? "":listBox1.SelectedItem.ToString();
        }

 

lab5源代码

标签:

原文地址:http://www.cnblogs.com/2014fhj/p/4414680.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!