Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     PublicMethods.title = textBoxTitle.Text.ToString();
     if (int.TryParse(textBoxStudentNum.Text.ToString(), out PublicMethods.stuCount) == false)
     {
         MessageBox.Show("学生人数不正确");
         return;
     }
     if (int.TryParse(textBoxTeacherNum.Text.ToString(), out PublicMethods.teacherCount) == false)
     {
         MessageBox.Show("老师人数不正确");
         return;
     }
     //PublicSettings.ifShowInTheSecdisplay = checkBox.Checked;
     PublicMethods.StoreSettings();
     Thread.Sleep(200);
     this.Close();
 }
Ejemplo n.º 2
0
 private void ClearData()
 {
     currTeacherName.Text = "";
     foreach (Control obj in panelTeacher.Controls)
     {
         if (obj is TextBox)
         {
             ((TextBox)obj).Text = "";
         }
     }
     foreach (Control obj in panelStudent.Controls)
     {
         if (obj is TextBox)
         {
             ((TextBox)obj).Text = "";
         }
     }
     PublicMethods.Init();
 }
Ejemplo n.º 3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (PublicMethods.LoadSettings() == false)
            {
                Settings settings = new Settings();
                settings.ShowDialog(this);
            }
            labelTitle.Text = PublicMethods.title;
            labelTitle.Left = (this.Width - labelTitle.Width) / 2;
            PaintForm();
            string path = Application.StartupPath + "\\image\\";

            if (Directory.Exists(path) == false)
            {
                Directory.CreateDirectory(path);
            }
            try
            {
                DataSet ds = PublicMethods.ExcelToDataSet(path + "Rank.xls");
                if (ds.Tables.Count < 1)
                {
                    return;
                }
                for (int i = 0; i < ds.Tables[0].Rows.Count - 1; i++)
                {
                    dataGridView1.Rows.Add(int.Parse(ds.Tables[0].Rows[i][0].ToString()), ds.Tables[0].Rows[i][1].ToString(), double.Parse(ds.Tables[0].Rows[i][2].ToString()));
                }
                dataGridView1.Sort(dataGridView1.Columns[2], ListSortDirection.Descending);
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    dataGridView1.Rows[i].Cells[0].Value = (i + 1).ToString();
                }
                //为了在由排名刷新的时候重新保存xls
                PublicMethods.ExportToExcel(path + "Rank.xls", dataGridView1);
                //MessageBox.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Ejemplo n.º 4
0
        private void submit_Click(object sender, EventArgs e)
        {
            ShowDetail showDetail = new ShowDetail();
            double     sumTeacher = 0, sumStudent = 0;

            if (currTeacherName.Text.ToString().Length < 1)
            {
                MessageBox.Show("请输入选手姓名");
                return;
            }
            int cnt = 0;

            foreach (Control obj in panelTeacher.Controls)
            {
                if (obj is TextBox)
                {
                    TextBox textBox = (TextBox)obj;
                    double  temp    = 0;
                    if (double.TryParse(textBox.Text.ToString(), out temp) == false)
                    {
                        MessageBox.Show(textBox.Name + " 输入有误");
                        return;
                    }
                    if (temp > 30)
                    {
                        MessageBox.Show(textBox.Name + " 输入有误");
                        return;
                    }
                    PublicMethods.maxTeacherScore = Math.Max(PublicMethods.maxTeacherScore, temp);
                    PublicMethods.minTeacherScore = Math.Min(PublicMethods.minTeacherScore, temp);
                    sumTeacher += temp;
                    Label label = new Label();
                    label.Name     = "teac" + cnt.ToString();
                    label.Font     = new Font("隶书", 20, FontStyle.Bold);
                    label.AutoSize = true;
                    label.Location = new Point(10 + (cnt % 5) * (showDetail.panelTeacher.Size.Width / 5), 10 + (cnt / 5) * 30);
                    label.Text     = temp.ToString().ToString().Substring(0, Math.Min(6, temp.ToString().Length));
                    showDetail.panelTeacher.Controls.Add(label);
                    cnt++;
                }
            }
            cnt = 0;
            foreach (Control obj in panelStudent.Controls)
            {
                if (obj is TextBox)
                {
                    TextBox textBox = (TextBox)obj;
                    double  temp    = 0;
                    if (double.TryParse(textBox.Text.ToString(), out temp) == false)
                    {
                        MessageBox.Show(textBox.Name + " 输入有误");
                        return;
                    }
                    if (temp > 30)
                    {
                        MessageBox.Show(textBox.Name + " 输入有误");
                        return;
                    }
                    PublicMethods.maxStudentScore = Math.Max(PublicMethods.maxStudentScore, temp);
                    PublicMethods.minStudentScore = Math.Min(PublicMethods.minStudentScore, temp);
                    sumStudent += temp;
                    Label label = new Label();
                    label.Name     = "teac" + cnt.ToString();
                    label.Font     = new Font("隶书", 20, FontStyle.Bold);
                    label.AutoSize = true;
                    label.Location = new Point(10 + (cnt % 5) * (showDetail.panelTeacher.Size.Width / 5), 10 + (cnt / 5) * 30);
                    label.Text     = temp.ToString().ToString().Substring(0, Math.Min(6, temp.ToString().Length));
                    showDetail.panelStudent.Controls.Add(label);
                    cnt++;
                }
            }
            sumTeacher                  -= PublicMethods.maxTeacherScore + PublicMethods.minTeacherScore;
            sumTeacher                  /= PublicMethods.teacherCount - 2;
            sumStudent                  -= PublicMethods.maxStudentScore + PublicMethods.minStudentScore;
            sumStudent                  /= PublicMethods.stuCount - 2;
            PublicMethods.argvStud       = sumStudent;
            PublicMethods.argvTeac       = sumTeacher;
            showDetail.teacMaxScore.Text = PublicMethods.maxTeacherScore.ToString();
            showDetail.teacMinScore.Text = PublicMethods.minTeacherScore.ToString();
            showDetail.studMaxScore.Text = PublicMethods.maxStudentScore.ToString();
            showDetail.studMinScore.Text = PublicMethods.minStudentScore.ToString();
            showDetail.teacArgv.Text     = Math.Round(PublicMethods.argvTeac, 2).ToString();
            showDetail.studArgv.Text     = Math.Round(PublicMethods.argvStud, 2).ToString();
            double score = sumTeacher * 0.7 + sumStudent * 0.3;

            // MessageBox.Show(score.ToString());
            object[] para = new object[3];
            para[0] = dataGridView1.Rows.Count;
            para[1] = currTeacherName.Text.ToString();
            para[2] = Math.Round(score, 2);
            dataGridView1.Rows.Add(para);
            dataGridView1.Sort(dataGridView1.Columns[2], ListSortDirection.Descending);
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                dataGridView1.Rows[i].Cells[0].Value = (i + 1).ToString();
            }
            //ShowInSecDisplay();
            showDetail.label1.Text     = currTeacherName.Text;
            showDetail.finalScore.Text = para[2].ToString();
            showDetail.Show();
            string path = Application.StartupPath + "\\image\\";

            if (Directory.Exists(path) == false)
            {
                Directory.CreateDirectory(path);
            }
            PublicMethods.ExportToExcel(path + "Rank.xls", dataGridView1);
            ClearData();
        }