Пример #1
0
        private void uiButton3_Click(object sender, EventArgs e)
        {
            UCScore myuc = new UCScore(list_name)
            {
                Dock = DockStyle.Top
            };

            // UCScore myuc = new UCScore() { Dock = DockStyle.Top };

            p_score.Controls.Add(myuc);

            p_score.Controls.SetChildIndex(myuc, 1);
        }
Пример #2
0
        private void btn_jisuan_Click(object sender, EventArgs e)
        {
            dgv_result.Rows.Clear();
            //循环判断dgvscore中A,B 分别是 高分还是低分
            for (int i = p_score.Controls.Count - 1; i > 0; i--)
            {
                UCScore myrow = p_score.Controls[i] as UCScore;
                //获得A的personinfo
                PersonInfo pa = list_p.Find((PersonInfo pi) => pi._xingming == myrow.cbb_a.Text);
                PersonInfo pb = list_p.Find((PersonInfo pi) => pi._xingming == myrow.cbb_b.Text);
                //计算二者分差,获得加减分,加到每个人的当前积分中
                int      fencha = Math.Abs(pa._dangqianjifen - pb._dangqianjifen);
                RuleInfo ri     = null;
                for (int j = 0; j < list_ruleinfo.Count; j++)
                {
                    if (fencha == 0)
                    {
                        ri = list_ruleinfo[0];
                        break;
                    }
                    if (list_ruleinfo[j]._fencha >= fencha && list_ruleinfo[j - 1]._fencha < fencha)
                    {
                        ri = list_ruleinfo[j];
                        break;
                    }
                }
                //判断pa和pb的输赢
                int scorea = Convert.ToInt32(myrow.cbb_score.Text.Substring(0, 1));
                int scoreb = Convert.ToInt32(myrow.cbb_score.Text.Substring(2, 1));

                //如果A 输了,如果A是高分,如果A是低分
                if (scorea < scoreb)
                {
                    if (pa._dangqianjifen >= pb._dangqianjifen)
                    {
                        pa._dangqianjifen -= ri._gaobai;
                        pb._dangqianjifen += ri._gaobai;
                    }
                    else if (pa._dangqianjifen < pb._dangqianjifen)
                    {
                        pa._dangqianjifen -= ri._gaosheng;
                        pb._dangqianjifen += ri._gaosheng;
                    }
                }
                else//如果a胜
                {
                    if (pa._dangqianjifen >= pb._dangqianjifen)//A如果分数本来就高
                    {
                        pa._dangqianjifen += ri._gaosheng;
                        pb._dangqianjifen -= ri._gaosheng;
                    }
                    else if (pa._dangqianjifen < pb._dangqianjifen)
                    {
                        pa._dangqianjifen += ri._gaobai;
                        pb._dangqianjifen -= ri._gaobai;
                    }
                }
            }
            //计算之后在dgv_result中显示所有人的成绩
            int index = 0;

            for (int p = 0; p < list_p.Count; p++)
            {
                var pi = list_p[p];
                index = dgv_result.Rows.Add();
                dgv_result.Rows[index].Cells[0].Value = index + 1;
                dgv_result.Rows[index].Cells[1].Value = pi._xingming;
                dgv_result.Rows[index].Cells[2].Value = pi._chushijifen;

                dgv_result.Rows[index].Cells[3].Value = pi._dangqianjifen;
            }
        }