コード例 #1
0
ファイル: Form4.cs プロジェクト: ccxiao5/C-
        private void form_work_Load(object sender, EventArgs e)
        {
            //初始化comboBox
            Form_home form_home = (Form_home)this.Owner;

            comboPlayer.Text = form_home.player[0].getName();
            for (int i = 0; i < form_home.inputNumPlayer(); i++)
            {
                Object obj = form_home.player[i].getName();
                comboPlayer.Items.Add(obj);
            }
            comboRater.Text = "第1位评委";
            for (int i = 1; i <= form_home.inputNumRater(); i++)
            {
                String temp = "第" + i.ToString() + "位评委";
                Object obj  = temp;
                comboRater.Items.Add(obj);
            }
            if (comboPlayer.Items.Count > 0)   //这句不能删掉,原因没有找到
            {
                comboPlayer.SelectedIndex = 0; //默认选择第一条
            }
            if (comboRater.Items.Count > 0)
            {
                comboRater.SelectedIndex = 0;  //默认选择第一条
            }
            txtGoal.Focus();
        }
コード例 #2
0
ファイル: Form4.cs プロジェクト: ccxiao5/C-
        private void txtGoal_KeyDown(object sender, KeyEventArgs e)
        {
            Keys      k         = e.KeyCode;
            int       id        = comboPlayer.SelectedIndex; //获取第几位选手
            int       location  = comboRater.SelectedIndex;  //标记第几个评委
            Form_home form_home = (Form_home)this.Owner;

            if (k == Keys.Enter)
            {
                if (!btModify.Enabled)//通过修改按钮是否可用判断是录分还是保存,没有启用说明还在录分
                {
                    form_home.goal[location++] = Convert.ToDouble(txtGoal.Text);
                    if (location < form_home.inputNumRater())//避免越界
                    {
                        comboRater.SelectedIndex = location;
                        comboRater.Text          = comboRater.Items[location].ToString();
                    }
                    else
                    {
                        form_home.player[id].getGoal(form_home.goal);
                        labMaxGoal.Visible = true;
                        labMaxGoal.Text    = form_home.player[id].getMaxGoal().ToString();
                        labMinGoal.Visible = true;
                        labMinGoal.Text    = form_home.player[id].getMinGoal().ToString();
                        labGoal.Visible    = true;
                        labGoal.Text       = form_home.player[id].getFinalGoal().ToString();
                        comboPlayer.Focus();
                        txtGoal.Enabled  = false;
                        btModify.Enabled = true;

                        /***
                         *
                         *判断是否能打印成绩表
                         *
                         ***/
                        int i;
                        for (i = 0; i < form_home.inputNumPlayer(); i++)
                        {
                            if (form_home.player[i].getFinalGoal() == 0)
                            {
                                break;
                            }
                        }
                        if (i == form_home.inputNumPlayer())//判断是否所有成员有成绩
                        {
                            bt_list.Enabled = true;
                        }
                        return;
                    }
                    txtGoal.Text = "";
                }
                else
                {
                    form_home.player[id].resetGoal(comboRater.SelectedIndex, Convert.ToDouble(txtGoal.Text));
                    form_home.player[id].getGoal(form_home.player[id].showGoal());
                    txtGoal.Enabled = false;
                    btModify.Text   = "修改";
                    labMaxGoal.Text = form_home.player[id].getMaxGoal().ToString();
                    labMinGoal.Text = form_home.player[id].getMinGoal().ToString();
                    labGoal.Text    = form_home.player[id].getFinalGoal().ToString();
                }
            }
        }