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

📄 mainform.cs

📁 根据输入的课程及成绩
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace GUI学分绩点计算器
{
    public partial class MainForm : Form
    {
        TextBox[] TBSet1;
        TextBox[] TBSet2;
        private int noursenums = 0;

        public int CourseNums
        {
            get { return noursenums; }
            set { noursenums = value; }
        }

        public MainForm()
        {
            InitializeComponent();
            skinEngine.SkinFile = "DeepCyan.ssk";
            //this.Controls.Add(new Button());
           // BuildUI();
        }

        public void BuildUI()
        {
            TBSet1=new TextBox[CourseNums];
            TBSet2 = new TextBox[CourseNums];

            Label currentL = label4;
            TextBox currentTB1=textBox1;
            TextBox currentTB2=textBox2;
            for (int i = 1; i <= CourseNums-1; i++)
            {
                Label la = new Label();

                la.AutoSize = true;
                la.Location = new Point(currentL.Location.X,currentL.Location.Y+30);          
                la.Size = new System.Drawing.Size(71, 12);
                //la.Name = "labelN";
                //la.TabIndex = 5;
                la.Text ="第"+(i+1)+"门课程:";

                Controls.Add(la);

                currentL = la;
                //---------------------------------
                TextBox tb1 = new TextBox();
                tb1.Location = new System.Drawing.Point(89,currentTB1.Location.Y+30);
                //tb.Name = "textBox1";
                tb1.Size = new System.Drawing.Size(45, 21);
                //this.textBox1.TabIndex = 4;
                Controls.Add(tb1);
                currentTB1 = tb1;
                //------------------------------------
                TextBox tb2 = new TextBox();
                tb2.Location = new System.Drawing.Point(158, currentTB2.Location.Y + 30);
                //tb.Name = "textBox1";
                tb2.Size = new System.Drawing.Size(45, 21);
                //this.textBox1.TabIndex = 4;
                Controls.Add(tb2);
                currentTB2 = tb2;
                //------------------------------
                TBSet1[0] = textBox1;
                TBSet2[0] = textBox2;

                TBSet1[i] = tb1;
                TBSet2[i] = tb2;
            }

           // this.Size.Height += 30;
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Term thisTerm = new Term();

                for (int i = 1; i <= CourseNums; i++)
                {
                    double Credit = double.Parse(TBSet1[i - 1].Text);
                    double Score = double.Parse(TBSet2[i - 1].Text);

                    thisTerm.AddOneCourse(new Course(Credit, Score));
                    //thisTerm.GetFinalJIDIAN();


                }
                button1.Text = thisTerm.GetFinalJIDIAN().ToString();
            }
            catch (Exception ex)
            {

                MessageBox.Show("您的输入有误!");
            }
            
        }
    }
}

⌨️ 快捷键说明

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