⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setfield.cs

📁 本软件是为南开大学体育部开发的,作为跆拳道比赛分组,分级别的小工具.在程序中导入Excel格式的文件,文件中是比赛运动员的相关信息.按设置场地要求自动生成比赛对阵图(word格式)和对阵表(Excel
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Match
{
    public partial class SetField : Form
    {
        string[] Fields = new string[8];
        bool OnOk = false;
        public SetField()
        {
            InitializeComponent();
        }

        public void SetData(int[] NumPlayers,int NumField) 
        {
           

            for (int i = 0; i < NumPlayers.Length; i++)
            {
                ComboBox cb=new ComboBox();
                switch (i)
                {
                    case 0:
                        textBox16.Text = NumPlayers[i].ToString();
                        cb = comboBox1;
                        break;
                    case 1:
                        textBox15.Text = NumPlayers[i].ToString();
                        cb = comboBox2;
                        break;
                    case 2:
                        textBox14.Text = NumPlayers[i].ToString();
                        cb = comboBox3;
                        break;
                    case 3:
                        textBox13.Text = NumPlayers[i].ToString();
                        cb = comboBox4;
                        break;
                    case 4:
                        textBox12.Text = NumPlayers[i].ToString();
                        cb = comboBox5;
                        break;
                    case 5:
                        textBox11.Text = NumPlayers[i].ToString();
                        cb = comboBox6;
                        break;
                    case 6:
                        textBox10.Text = NumPlayers[i].ToString();
                        cb = comboBox7;
                        break;
                    case 7:
                        textBox9.Text = NumPlayers[i].ToString();
                        cb = comboBox8;
                        break;

                }
                if (NumPlayers[i] > 0)
                {
                    for (int j = 0; j < NumField; j++)
                    {
                        object Field = (char)(j + 65);
                        cb.Items.Add(Field);
                    }
                }
                else
                {
                    cb.Enabled = false;
                }
            
            }
            
        }
        public void SetFields(string[] Field)
        {
            for (int i = 0; i < Field.Length; i++)
            {
                switch (i)
                {
                    case 0: comboBox1.Text = Field[i];
                        break;
                    case 1: comboBox2.Text = Field[i];
                        break;
                    case 2: comboBox3.Text = Field[i];
                        break;
                    case 3: comboBox4.Text = Field[i];
                        break;
                    case 4: comboBox5.Text = Field[i];
                        break;
                    case 5: comboBox6.Text = Field[i];
                        break;
                    case 6: comboBox7.Text = Field[i];
                        break;
                    case 7: comboBox8.Text = Field[i];
                        break;
                
                }
            }
        
        }
        private void button_OK_Click(object sender, EventArgs e)
        {
            if (!Check()) {
                MessageBox.Show("有的组没有设置场地!");
                return;
            }
            OnOk = true;
            this.Close();
        }
        private bool Check()
        {
            for (int i = 0; i < 8; i++)
            {
                switch (i)
                {
                    case 0: if (textBox16.Text != "0" && comboBox1.Text == "") return false;
                        break;
                    case 1: if (textBox15.Text != "0" && comboBox2.Text == "") return false;
                        break;
                    case 2: if (textBox14.Text != "0" && comboBox3.Text == "") return false;
                        break;
                    case 3: if (textBox13.Text != "0" && comboBox4.Text == "") return false;
                        break;
                    case 4: if (textBox12.Text != "0" && comboBox5.Text == "") return false;
                        break;
                    case 5: if (textBox11.Text != "0" && comboBox6.Text == "") return false;
                        break;
                    case 6: if (textBox10.Text != "0" && comboBox7.Text == "") return false;
                        break;
                    case 7: if (textBox9.Text != "0" && comboBox8.Text == "") return false;
                        break;
                }
            }
            return true;
        
        }
        public bool GetReturn()
        {
            return OnOk;
        }
        public string[] GetField()
        {
            
            return Fields;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Fields[0] = comboBox1.Text;
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            Fields[1] = comboBox2.Text;
        }

        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            Fields[2] = comboBox3.Text;
        }

        private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            Fields[3] = comboBox4.Text;
        }

        private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
        {
            Fields[4] = comboBox5.Text;
        }

        private void comboBox6_SelectedIndexChanged(object sender, EventArgs e)
        {
            Fields[5] = comboBox6.Text;
        }

        private void comboBox7_SelectedIndexChanged(object sender, EventArgs e)
        {
            Fields[6] = comboBox7.Text;
        }

        private void comboBox8_SelectedIndexChanged(object sender, EventArgs e)
        {
            Fields[7] = comboBox8.Text;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OnOk = false;
            this.Close();
        }

        
    }
}

⌨️ 快捷键说明

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