public AddSubDataCreator(SettingConfig config) { this.config = config; }
private void button1_Click(object sender, EventArgs e) { this.dgv.DataSource = null; this.isUp = this.radioButton1.Checked ? 0 : (this.radioButton2.Checked ? 1 : 2); //0混合 1进位 2不进位 int totalNum = this.toInt(this.txtTotalNum.Text); //总体题数 int addNum = (totalNum * this.toInt(this.txtAddNum.Text)) / 100; //加法数量 int subNum = (totalNum * this.toInt(this.txtSubNum.Text)) / 100; //减法数量 foreach (RadioButton button in this.groupBox3.Controls) { if (button.Checked) { switch (button.Name) { case "radioButton6": this.maxnum = 100; break; case "radioButton7": this.maxnum = 90; break; case "radioButton8": this.maxnum = 80; break; case "radioButton9": this.maxnum = 70; break; case "radioButton10": this.maxnum = 60; break; case "radioButton11": this.maxnum = 50; break; case "radioButton12": this.maxnum = 40; break; case "radioButton13": this.maxnum = 30; break; case "radioButton14": this.maxnum = 20; break; case "radioButton15": this.maxnum = 10; break; } break; } } int itemtype = 0; foreach (RadioButton button in this.groupBox2.Controls) { if (button.Checked) { switch (button.Name) { case "radioButton4": itemtype = 0; break; case "radioButton5": itemtype = 1; break; case "radioButton17": itemtype = 2; break; default: break; } break; } } SettingConfig config = new SettingConfig { AdavanceType = isUp, AddPercent = addNum / 100m, SubPercent = subNum / 100m, TotalNum = this.toInt(this.txtTotalNum.Text), MaxNum = this.maxnum, ItemType = itemtype, MixedPercent = toInt(txtMixed.Text) / 100m }; this.dgv.DataSource = new AddSubDataCreator(config).CreatData(); }