예제 #1
0
 private void PickDataNumber(AllRandomPickData allRandomPickData)
 {
     if (allRandomPickData != null)
     {
         try
         {
             new AllRandomPick().GetRandomNumber(allRandomPickData);
             new PersonNumberDataSet();
             if ((allRandomPickData != null) && (allRandomPickData.PickNumber != null))
             {
                 int num = 0;
                 num = 0;
                 while (num < allRandomPickData.PickNumber.Count)
                 {
                     if (this.poolNO == allRandomPickData.PickNumber[num])
                     {
                         MessageBox.Show("按输入的参数计算,摇号基数序号" + this.poolNO.ToString() + "摇中!");
                         break;
                     }
                     num++;
                 }
                 if (num >= allRandomPickData.PickNumber.Count)
                 {
                     MessageBox.Show("按输入的参数计算,摇号基数序号" + this.poolNO.ToString() + "没有摇中!");
                 }
             }
         }
         catch
         {
             MessageBox.Show("使用输入的值,运算超时,请选用合适的参数!");
         }
     }
 }
예제 #2
0
 private void PickNumberButton_Click(object sender, EventArgs e)
 {
     if (this.TotalNumberTextBox.Text == string.Empty)
     {
         MessageBox.Show("没输入本期有效申请编码总数,请输入正整数!");
         this.TotalNumberTextBox.Focus();
     }
     else if (this.QuotaNumberTextBox.Text == string.Empty)
     {
         MessageBox.Show("没输入本期配置指标总数,请输入正整数!");
         this.QuotaNumberTextBox.Focus();
     }
     else if (this.SeedNumericTextBox.Text == string.Empty)
     {
         MessageBox.Show("没输入种子数,请输入数字!");
         this.SeedNumericTextBox.Focus();
     }
     else if (this.PoolNOTextBox.Text == string.Empty)
     {
         MessageBox.Show("没输入我的摇号基数序号,请输入正整数!");
         this.PoolNOTextBox.Focus();
     }
     else
     {
         this.totalNumber = Convert.ToInt32(this.TotalNumberTextBox.Text);
         this.quotaNumber = Convert.ToInt32(this.QuotaNumberTextBox.Text);
         if (this.totalNumber <= this.quotaNumber)
         {
             MessageBox.Show("本期有效申请编码总数不大于本期配置指标总数,可以全部配置,不需要摇号!");
             this.TotalNumberTextBox.Focus();
         }
         else
         {
             this.poolNO = Convert.ToInt32(this.PoolNOTextBox.Text);
             if (this.poolNO == 0)
             {
                 MessageBox.Show("输入摇号基数序号不应该等于零,请重输!");
                 this.PoolNOTextBox.Focus();
             }
             else if (this.totalNumber < this.poolNO)
             {
                 MessageBox.Show("输入摇号基数序号已经大于有效申请编码总数,请重输!");
                 this.PoolNOTextBox.Focus();
             }
             else
             {
                 AllRandomPickData allRandomPickData = new AllRandomPickData {
                     TotalNumber = this.totalNumber,
                     QuotaNumber = this.quotaNumber,
                     Seed        = Convert.ToInt32(this.SeedNumericTextBox.Text)
                 };
                 this.PickDataNumber(allRandomPickData);
             }
         }
     }
 }
예제 #3
0
 private void PickDataNumber(AllRandomPickData allRandomPickData)
 {
     if (allRandomPickData != null)
     {
         try
         {
             AllRandomPick pick = new AllRandomPick();
             pick.GetRandomNumber(allRandomPickData);
             PickNumberDataSet pickNumberDataSet = new PickNumberDataSet();
             pick.SetPickNumberDataSet(allRandomPickData.PickNumber, pickNumberDataSet);
             this.ShowDataSet(pickNumberDataSet.DataSet);
         }
         catch
         {
             MessageBox.Show("使用输入的值,运算超时,请选用合适的参数!");
         }
     }
 }
예제 #4
0
        public void GetRandomNumber(AllRandomPickData allRandomPickData)
        {
            Predicate <int> match = null;
            int             pickNumber;

            if ((allRandomPickData != null) && (allRandomPickData.QuotaNumber < allRandomPickData.TotalNumber))
            {
                int        num    = (Convert.ToInt64((int)(allRandomPickData.TotalNumber * 10)) >= 0x100000000L) ? allRandomPickData.TotalNumber : (allRandomPickData.TotalNumber * 10);
                Random     random = new Random(allRandomPickData.Seed);
                List <int> list   = new List <int>();
                allRandomPickData.PickNumber.Clear();
                if (allRandomPickData.QuotaNumber > 0)
                {
                    int num2 = 0;
                    while (num2 < num)
                    {
                        pickNumber = random.Next(allRandomPickData.TotalNumber);
                        if (match == null)
                        {
                            match = p => p == pickNumber;
                        }
                        if (!list.Exists(match))
                        {
                            allRandomPickData.PickNumber.Add(pickNumber + 1);
                            list.Add(pickNumber);
                        }
                        if (allRandomPickData.PickNumber.Count >= allRandomPickData.QuotaNumber)
                        {
                            break;
                        }
                        num2++;
                    }
                    if (num2 == num)
                    {
                        throw new Exception("运算超时!");
                    }
                }
            }
        }