Esempio n. 1
0
        private void txtNumPlayer_KeyDown(object sender, KeyEventArgs e)
        {
            Keys k = e.KeyCode;

            if (k == Keys.Tab || k == Keys.Enter)
            {
                txtId.Focus();
                try
                {
                    if (k == Keys.Enter)
                    {
                        Form_home form_home = (Form_home)this.Owner;
                        form_home.getNumPlayer(Convert.ToInt32(txtNumPlayer.Text));
                        form_home.player = new Players[Convert.ToInt32(txtNumPlayer.Text)];
                        form_home.flag   = true;
                        txtId.Enabled    = true;
                        txtName.Enabled  = true;
                        txtId.Focus();
                    }
                }
                catch (Exception)
                {
                    DialogResult resulet = MessageBox.Show(this, "请输入正确数字");
                    txtNumPlayer.Text = "";
                    txtNumPlayer.Focus();
                }
            }
        }
Esempio n. 2
0
File: Form4.cs Progetto: 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();
        }
Esempio n. 3
0
        private void txtNumRater_KeyDown(object sender, KeyEventArgs e)//按下回车或者按下TAB自动切换到下一个文本框
        {
            Keys k = e.KeyCode;

            if (k == Keys.Tab || k == Keys.Enter)
            {
                txtNumPlayer.Focus();
                if (k == Keys.Enter)
                {
                    try{//捕获输入数字字符外的异常
                        Form_home form_home = (Form_home)this.Owner;
                        if (Convert.ToInt32(txtNumRater.Text) > 2)
                        {
                            form_home.getNumRater(Convert.ToInt32(txtNumRater.Text));
                        }
                        else
                        {
                            DialogResult resulet = MessageBox.Show(this, "评委数至少三人");  //保持评委人数至少三个;
                            txtNumRater.Text = "";
                            txtNumRater.Focus();
                        }
                    }
                    catch (Exception) {
                        DialogResult resulet = MessageBox.Show(this, "请输入正确数字");
                        txtNumRater.Text = "";
                        txtNumRater.Focus();
                    }
                }
            }
        }
Esempio n. 4
0
        private void btSearch_Click(object sender, EventArgs e)
        {
            Form_home   form_home   = (Form_home)this.Owner;
            Form_search form_search = new Form_search();

            form_search.ShowDialog(form_home);
        }
Esempio n. 5
0
File: Form3.cs Progetto: ccxiao5/C-
        private void btModify_Click(object sender, EventArgs e)
        {
            int       i;
            Form_home form_home = (Form_home)this.Owner;

            if (btModify.Text == "修改")
            {
                txtName.Enabled = true;
                btNext.Enabled  = false;
                btModify.Text   = "保存";
            }
            else if (btModify.Text == "保存")
            {
                txtName.Enabled = false;
                btModify.Text   = "修改";
                for (i = 0; i < form_home.total; i++)
                {
                    if (txtId.Text == form_home.player[i].getId())
                    {
                        form_home.player[i].setName(txtName.Text);
                        break;
                    }
                }
                btNext.Enabled = true;
            }
        }
Esempio n. 6
0
File: Form3.cs Progetto: ccxiao5/C-
        private void Form3_Load(object sender, EventArgs e)
        {
            Form_home form_home = (Form_home)this.Owner;

            txtId.Text   = form_home.player[0].getId();
            txtName.Text = form_home.player[0].getName();
        }
Esempio n. 7
0
File: Form4.cs Progetto: ccxiao5/C-
        private void bt_list_Click(object sender, EventArgs e)
        {
            Form_home form_home = (Form_home)this.Owner;
            Form_show form_show = new Form_show();

            form_show.ShowDialog(form_home);
        }
Esempio n. 8
0
        private void btQuit_Click(object sender, EventArgs e)
        {
            this.Close();
            Form_home form_home = (Form_home)this.Owner;

            if (form_home.flag)
            {
                form_home.getBtWork.Enabled = true;
            }
            form_home.Show();
        }
Esempio n. 9
0
File: Form3.cs Progetto: ccxiao5/C-
        private void btNext_Click(object sender, EventArgs e)
        {
            int       i;
            Form_home form_home = (Form_home)this.Owner;

            for (i = 0; i < form_home.total; i++)
            {
                if (txtId.Text == form_home.player[i].getId())
                {
                    break;
                }
            }
            txtId.Text   = form_home.player[(i + 1) % form_home.total].getId();
            txtName.Text = form_home.player[(i + 1) % form_home.total].getName();
        }
Esempio n. 10
0
File: Form4.cs Progetto: ccxiao5/C-
        private void comboRater_SelectedIndexChanged(object sender, EventArgs e)
        {
            int       id        = comboPlayer.SelectedIndex;//获取第几位选手
            Form_home form_home = (Form_home)this.Owner;

            if (form_home.player[id].getFinalGoal() > 0)
            {
                txtGoal.Text = form_home.player[id].outputGoal(comboRater.SelectedIndex).ToString();
            }
            else
            {
                btModify.Enabled = false;
                txtGoal.Enabled  = true;
                txtGoal.Text     = "";
            }
        }
Esempio n. 11
0
File: Form4.cs Progetto: ccxiao5/C-
 private void btModify_Click(object sender, EventArgs e)
 {
     if (btModify.Text == "修改")
     {
         btModify.Text   = "保存";
         txtGoal.Text    = "";
         txtGoal.Enabled = true;
     }
     else
     {
         int       id        = comboPlayer.SelectedIndex;//获取第几位选手
         Form_home form_home = (Form_home)this.Owner;
         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();
     }
 }
Esempio n. 12
0
        private void btSave_Click(object sender, EventArgs e)
        {
            if (txtName.Text == "" || txtId.Text == "")
            {
                DialogResult resulet = MessageBox.Show(this, "请输入完整信息");//保证录入数据的完整性
                return;
            }
            Form_home form_home = (Form_home)this.Owner;
            int       i;

            for (i = 0; i < form_home.total; i++)
            {
                if (form_home.player[i].getId() == txtId.Text)
                {
                    DialogResult resulet = MessageBox.Show(this, "不能输入重复的编号");  //保持主键唯一
                    txtName.Text = "";
                    txtId.Text   = "";
                    txtId.Focus();
                    break;
                }
            }
            if (i == form_home.total)
            {
                Players p = new Players(txtName.Text, txtId.Text);
                form_home.getPlayer(p);
                if (form_home.total >= Convert.ToInt32(txtNumPlayer.Text))
                {
                    btSave.Enabled  = false;
                    txtName.Enabled = false;
                    txtId.Enabled   = false;
                    btSearch.Focus();
                }
                txtName.Text = "";
                txtId.Text   = "";
                txtId.Focus();
            }
        }
Esempio n. 13
0
        private void txtName_KeyDown(object sender, KeyEventArgs e)
        {
            Keys k = e.KeyCode;

            if (k == Keys.Enter)
            {
                Form_home form_home = (Form_home)this.Owner;
                int       i;
                for (i = 0; i < form_home.total; i++)
                {
                    if (form_home.player[i].getId() == txtId.Text)
                    {
                        DialogResult resulet = MessageBox.Show(this, "不能输入重复的编号");  //保持主键唯一
                        txtName.Text = "";
                        txtId.Text   = "";
                        txtId.Focus();
                        break;
                    }
                }
                if (i == form_home.total)
                {
                    Players p = new Players(txtName.Text, txtId.Text);
                    form_home.getPlayer(p);
                    if (form_home.total >= Convert.ToInt32(txtNumPlayer.Text))
                    {
                        btSave.Enabled  = false;
                        txtName.Enabled = false;
                        txtId.Enabled   = false;
                        btSearch.Focus();
                    }
                    txtName.Text = "";
                    txtId.Text   = "";
                    txtId.Focus();
                }
            }
        }
Esempio n. 14
0
File: Form5.cs Progetto: ccxiao5/C-
        private void Form_show_Load(object sender, EventArgs e)
        {
            txtGoal.Text += "";
            Form_home form_home = (Form_home)this.Owner;
            Players   temp;

            for (int i = 0; i < form_home.inputNumPlayer() - 1; i++)
            {
                for (int j = 0; j < form_home.inputNumPlayer() - 1 - i; j++)
                {
                    if (form_home.player[j].getFinalGoal() < form_home.player[j + 1].getFinalGoal())
                    {
                        temp = form_home.player[j];
                        form_home.player[j]     = form_home.player[j + 1];
                        form_home.player[j + 1] = temp;
                    }
                }
            }
            for (int i = 0; i < form_home.inputNumPlayer(); i++)
            {
                txtGoal.Text += (i + 1).ToString() + ". " + "选手编号:  " + form_home.player[i].getId() + "\t" + "选手姓名:  " + form_home.player[i].getName() + "\t" + "选手成绩:  " + form_home.player[i].getFinalGoal() + "\r\n";
            }
            txtGoal.Select(0, 0);//取消自动选中
        }
Esempio n. 15
0
File: Form4.cs Progetto: 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();
                }
            }
        }