protected void btnGetBingoNum_Click(object sender, EventArgs e)
{
ArrayList list = new ArrayList();
DataSet ds = bll_cou.GetAllCoupon();
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
list.Add(ds.Tables[0].Rows[i]["Code"].ToString());
}
//list 是一堆 已经生成的 随机码
if (txtCoupon1.Text != "") //txtCoupon1.Text 为在那堆随机码里生成多少个有效的
{
int count = int.Parse(txtCoupon1.Text.Trim());
if (count < list.Count)
{
for (int i = 0; i < count; i++)
{
Random rand = new Random();
int index = rand.Next(0,list.Count);
ProcessGetBingo(list, index, ds);
list.Remove(list[index]);
}
}
}
}
BindGv();
txtCoupon1.Text = "";
} protected void ProcessGetBingo(ArrayList list,int index,DataSet ds)
{
if (IsExistCode(list[index].ToString()))
{
DataSet ds_c = bll_cou.GetCouponByCode(list[index].ToString());
if (ds_c != null && ds_c.Tables.Count > 0 && ds_c.Tables[0].Rows.Count > 0)
{
if (ds_c.Tables[0].Rows[0]["IsBingo"].ToString() == "0")
{
UpdateBingoNum(ds_c); //更新
}
else
{
index = new Random().Next(0,list.Count);
ProcessGetBingo(list, index, ds);
}
}
}
}总感觉生成后的随机码出现的位置会挤在一起,就是分布位置不太均匀
解决方案 »
- Web.config的里面的内容能不能分成两个文件写?
- |M| 一段Ajax问题 发送到某页面,如何来传参 谢谢 急
- 请问在asp.net中,Session可以存储对象吗?
- 关于 Session
- 怎样在多个WEB页上均可以调用公用的过程或函数?
- asp.net如何刷新页面,如何获得IE地址栏中的网址
- IE7与IE6的不兼容问题::IE7下做的aspx页,套用了在IE6下写的CSS/html布局,在IE7下能正常运行,但在IE6下却不能,网站都做好了,怎么办????
- asp.net操作WORD填充数据的问题
- 当SQL SERVER的表记录上万时,前台网页上显示就很慢?
- (在线等;100分奉送)Word文档无法在浏览器中打开?怎么办?
- 有谁用过jquery uploadify(在ASP.NET下)。多文件上传的问题
- asp.net发邮件问题
上面代码的 list 已经是一堆已经生成好的随机码,我要从中拿出一定量的出来。