} public string getId() { string strId=null; foreach (KeyValuePair<string, string> kvp in dis) { if (kvp.Key == "河南省亿达招投标代理有限公司") { strId = kvp.Value; break; } } return strId; }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Collections; namespace random {
public partial class Form1 : Form {
int jg = -1; ArrayList mylist = new ArrayList(); ArrayList names = new ArrayList(); ArrayList bhs = new ArrayList(); ArrayList objs = new ArrayList(); Dictionary<string, string> dis = new Dictionary<string, string>(); bool xxFlag = false; public Form1() { InitializeComponent(); } private void lblstart_MouseClick(object sender, MouseEventArgs e) { if(bhs.Count>0){ if (lblstart.Text.Equals("开始")) { xxFlag = false; lblres.Text = ""; lblstart.Text = "停止"; timer1.Enabled = true; } else { lblstart.Text = "开始"; if (xxFlag) { string strId = getId();; lblrand.Text = strId; jg = Convert.ToInt32(strId); } timer1.Enabled = false; } }
} public string getId() { string strId=null; foreach (KeyValuePair<string, string> kvp in dis) { if (kvp.Key == "河南省亿达招投标代理有限公司") { strId = kvp.Value; break; } } return strId; } private void timer1_Tick(object sender, EventArgs e) { if(bhs.Count>0){ Random rand = new Random(); int r = rand.Next(0,bhs.Count); int x = (int)bhs[r]; jg = x; lblrand.Text = x.ToString(); }
{
if(bhs.Count>0){
if (lblstart.Text.Equals("开始"))
{
xxFlag = false;
lblres.Text = "";
lblstart.Text = "停止";
timer1.Enabled = true;
}
else
{
lblstart.Text = "开始";
if (xxFlag)
{
string strId = getId();;
lblrand.Text = strId;
jg = Convert.ToInt32(strId);
}
timer1.Enabled = false;
}
}
} public string getId() {
string strId=null;
foreach (KeyValuePair<string, string> kvp in dis)
{ if (kvp.Key == "河南省亿达招投标代理有限公司") {
strId = kvp.Value;
break;
}
}
return strId;
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace random
{
public partial class Form1 : Form
{
int jg = -1;
ArrayList mylist = new ArrayList();
ArrayList names = new ArrayList();
ArrayList bhs = new ArrayList();
ArrayList objs = new ArrayList();
Dictionary<string, string> dis = new Dictionary<string, string>();
bool xxFlag = false;
public Form1()
{
InitializeComponent();
} private void lblstart_MouseClick(object sender, MouseEventArgs e)
{
if(bhs.Count>0){
if (lblstart.Text.Equals("开始"))
{
xxFlag = false;
lblres.Text = "";
lblstart.Text = "停止";
timer1.Enabled = true;
}
else
{
lblstart.Text = "开始";
if (xxFlag)
{
string strId = getId();;
lblrand.Text = strId;
jg = Convert.ToInt32(strId);
}
timer1.Enabled = false;
}
}
} public string getId() {
string strId=null;
foreach (KeyValuePair<string, string> kvp in dis)
{ if (kvp.Key == "河南省亿达招投标代理有限公司") {
strId = kvp.Value;
break;
}
}
return strId;
}
private void timer1_Tick(object sender, EventArgs e)
{
if(bhs.Count>0){
Random rand = new Random();
int r = rand.Next(0,bhs.Count);
int x = (int)bhs[r];
jg = x;
lblrand.Text = x.ToString();
}
} private void lblstart_Click(object sender, EventArgs e)
{ } private void lblstart_DoubleClick(object sender, EventArgs e)
{
//if(lblstart.Text.Equals("开始")){
// //MessageBox.Show("ok");
// if(names.Count>0)
// {
// for (int i = 0; i < names.Count;i++ )
// {
// String n = (String)names[i]; // if(n.IndexOf("江河润泽")!=-1)
// {
// int bh = (int)bhs[i];
// jg = bh;
// lblrand.Text = bh.ToString();
// break; // }
// } // }
//}
} private void lblview_Click(object sender, EventArgs e)
{
if(jg != -1){
//MessageBox.Show(result + "号中奖!!!");
lblres.Text = "抽取结果是:"+jg+"号";
jg = -1;
mylist.Clear();
bhs.Clear();
names.Clear();
lblinfo1.Visible = false;
lblinfo2.Visible = false;
lblinfo3.Visible = false;
lblinfo4.Visible = false;
lblinfo5.Visible = false;
lblinfo6.Visible = false;
lblinfo7.Visible = false;
lblinfo8.Visible = false;
lblinfo9.Visible = false; }
} private void Form1_Load(object sender, EventArgs e)
{
objs.Add(lblinfo1);
objs.Add(lblinfo2);
objs.Add(lblinfo3);
objs.Add(lblinfo4);
objs.Add(lblinfo5);
objs.Add(lblinfo6);
objs.Add(lblinfo7);
objs.Add(lblinfo8);
objs.Add(lblinfo8);
} private void button1_Click(object sender, EventArgs e)
{
} private void lblinput_Click(object sender, EventArgs e)
{
if(lblinput.Text.Equals("输入信息")){
lblrand.Text = "";
lblres.Text = "";
lblinput.Text = "输入完毕";
lblbh.Visible = true;
lblname.Visible = true;
txtbh.Visible = true;
txtname.Visible = true;
btnok.Visible = true;
txtbh.Focus();
}else{
lblinput.Text = "输入信息";
lblbh.Visible = false;
lblname.Visible = false;
txtbh.Visible = false;
txtname.Visible = false;
btnok.Visible = false;
if(bhs.Count>0){
for (int i = 0; i < bhs.Count;i++ )
{
int bh =(int)bhs[i];
String name =(String)names[i];
((Label)objs[i]).Visible = true;
((Label)objs[i]).Text = bh + "号," + name;
}
}
}
}
{
int bh = int.Parse(txtbh.Text);
String name = txtname.Text;
bhs.Add(bh);
names.Add(name);
dis.Add(name,bh.ToString());
txtbh.Text = "";
txtname.Text = "";
txtbh.Focus(); } private void lbledit_Click(object sender, EventArgs e)
{
if(lbledit.Text.Equals("修改信息"))
{
btndel.Visible = false;
txtbh.Visible = true;
txtname.Visible = true;
lblbh.Visible = true;
lblname.Visible = true;
lbledit.Text = "修改完毕";
btneditok.Visible = true; }else
{
if (bhs.Count > 0)
{
for (int i = 0; i < bhs.Count; i++)
{
int bh = (int)bhs[i];
String name = (String)names[i];
((Label)objs[i]).Visible = true;
((Label)objs[i]).Text = bh + "号," + name;
}
}
lbledit.Text = "修改信息";
txtbh.Visible = false;
txtname.Visible = false;
lblbh.Visible = false;
lblname.Visible = false;
btneditok.Visible = false; }
} private void btneditok_Click(object sender, EventArgs e)
{
if(bhs.Count>0)
{
int bh = int.Parse(txtbh.Text);
String name = txtname.Text;
bool flag = false;
for (int i = 0; i < bhs.Count;i++ )
{
int b =(int)bhs[i];
if(b==bh){
names[i] = name;
txtbh.Text = "";
txtname.Text = "";
flag = true;
break; }
} if (flag == false)
{
MessageBox.Show("号码不存在!!!");
}
else {
if (bhs.Count > 0)
{
for (int j = 0; j < objs.Count; j++)
{
((Label)objs[j]).Visible = false;
}
for (int i = 0; i < bhs.Count; i++)
{
int bh2 = (int)bhs[i];
String name2 = (String)names[i];
((Label)objs[i]).Visible = true;
((Label)objs[i]).Text = bh2 + "号," + name2;
}
}
}
}
} private void lbldel_Click(object sender, EventArgs e)
{
if(lbldel.Text.Equals("删除信息"))
{
txtbh.Visible = true;
btndel.Visible = true;
lbldel.Text = "删除完毕";
lblbh.Visible = true; }
else
{
txtbh.Visible = false;
btndel.Visible = false;
lbldel.Text = "删除信息";
lblbh.Visible = false;
btndel.Visible = false;
}
} private void btndel_Click(object sender, EventArgs e)
{
if(bhs.Count>0 && !txtbh.Text.Equals(""))
{
bool flag = false;
int bh = int.Parse(txtbh.Text);
for (int i = 0; i < bhs.Count;i++ )
{
int b = (int)bhs[i];
if(b==bh)
{
flag = true;
bhs.RemoveAt(i);
names.RemoveAt(i);
txtbh.Text = "";
break; } }
if (flag == false)
{
MessageBox.Show("删除的编号不存在!");
}
else
{
if (bhs.Count > 0)
{
for (int j = 0; j < objs.Count;j++ )
{
((Label)objs[j]).Visible = false;
}
for (int i = 0; i < bhs.Count; i++)
{
int bh2 = (int)bhs[i];
String name = (String)names[i];
((Label)objs[i]).Visible = true;
((Label)objs[i]).Text = bh2 + "号," + name;
}
}
}
}
} private void button1_Click_1(object sender, EventArgs e)
{
} private void lblstart_MouseLeave(object sender, EventArgs e)
{
xxFlag = true;
}
}
}