欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C#实例代码之抽奖升级版可以经表格数据导入数据库,抽奖设置,补抽

程序员文章站 2022-04-29 10:41:52
我写代码一直是这个风格,废话不多,直接给大家贴代码,现在还是老规矩,具体代码如下所示: using system; using system.collectio...

我写代码一直是这个风格,废话不多,直接给大家贴代码,现在还是老规矩,具体代码如下所示:

using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.drawing.imaging;
using system.linq;
using system.text;
using system.threading.tasks;
using system.windows.forms;
using system.data.sqlclient;
using system.collections;
using system.io;
namespace check_ticket
{
public partial class btn_uploadfile : form
{
string conn = "server=win-oudrehch;database=xtf;uid=sa;pwd=";
string sql = "";
int curnum = ;//奖项人数
int second = ;//防止二次被抽取
hashtable hashtable = new hashtable();//存储编号
hashtable hashtable = new hashtable();//存储获奖名单
hashtable hashtable = new hashtable();//避免二次抽奖
dictionary<int, string> dict = new dictionary<int, string>();//词典存储所有参赛者
random rd = new random();
int time = ;
label[] label = new label[];
int index = ;//词典key键值
int total = ;//label个数
int num = ;//获奖总数
string s = "";
int end = ;//抽奖结束
public btn_uploadfile()
{
initializecomponent();
}
private void form_load(object sender, eventargs e)
{
datagridview.forecolor = color.blue;
menu.visible = false;
combobox.selectedindex = ;
this.timer.interval = ;
this.timer.interval = ;
this.timer.enabled = true;
this.windowstate = formwindowstate.maximized;
}
private void getnumber(string s)
{
sqlconnection myconn = new sqlconnection(conn);
myconn.open();
sql = "select *from sumprize";
sqldataadapter da = new sqldataadapter(sql, myconn);
dataset ds = new dataset();
da.fill(ds);
switch (s)
{
case "一等奖":
second = ;
curnum = convert.toint(ds.tables[].rows[]["prizenum"].tostring());
break;
case "二等奖":
second = ;
curnum = convert.toint(ds.tables[].rows[]["prizenum"].tostring());
break;
case "三等奖":
second = ;
curnum = convert.toint(ds.tables[].rows[]["prizenum"].tostring());
break;
case "四等奖":
second = ;
curnum = convert.toint(ds.tables[].rows[]["prizenum"].tostring());
break;
case "五等奖":
second = ;
curnum = convert.toint(ds.tables[].rows[]["prizenum"].tostring());
break;
case "六等奖":
second = ;
curnum = convert.toint(ds.tables[].rows[]["prizenum"].tostring());
break;
case "请选择":
curnum = ;
break;
default:
break;
}
}
private void button_click(object sender, eventargs e)
{
sqlconnection myconn = new sqlconnection(conn);
myconn.open();
//未选择抽奖项
if (curnum == )
{
messagebox.show("未设置该奖项或未选择奖项,抽奖没有意义!!!");
return;
}
//处理已经被抽奖项
if (!hashtable.containsvalue(second))
{
combobox.enabled = true;
hashtable.add(second, second);
}
else
{
messagebox.show("此奖项已经被抽过,换个奖项吧?");
return;
}
string prize = combobox.text.tostring();
string sqlcount = "select sum(prizenum) as num from sumprize";
sqldataadapter sda = new sqldataadapter(sqlcount, myconn);
dataset ds = new dataset();
sda.fill(ds);
//设置有奖总人数
num = convert.toint(ds.tables[].rows[]["num"].tostring());
for (int i = ; i < datagridview.rowcount-; i++)
{
dict.add(index, datagridview.rows[i].cells["workerid"].value.tostring() + " " + datagridview.rows[i].cells["name"].value.tostring());
index++;
}
myconn.close();
timer.start();
clearlabel();
bornlabel();
timer.enabled = true;
combobox.enabled = false;
}
private void button_click(object sender, eventargs e)
{
end = ;
menu.text = "";
hashtable.clear();
clearlabel();
button.enabled = true;
button.enabled = true;
button.enabled = false;
menu.visible = false;
btnadd.visible = false;
tbnum.visible = false;
ge.visible = false;
addend.visible = false;
lab.text = "中奖名单";
datagridview.visible = false;
string sqlchecked = "delete from checked";
sql = "select *from ticket";
sqlconnection myconn = new sqlconnection(conn);
myconn.open();
sqldataadapter sda = new sqldataadapter(sql, myconn);
dataset ds = new dataset();
sda.fill(ds, "ticket");
datagridview.datasource = ds;
datagridview.datamember = "ticket";
sqlcommand mycomm = new sqlcommand(sqlchecked, myconn);
mycomm.executenonquery();
myconn.close();
}
private void button_click(object sender, eventargs e)
{
menu.visible = false;
clearlabel();
sql = "select workeridandname,prize from checked order by prizeid";
sqlconnection myconn = new sqlconnection(conn);
myconn.open();
sqldataadapter sda = new sqldataadapter(sql, myconn);
dataset ds = new dataset();
sda.fill(ds, "checked");
datagridview.datasource = ds;
datagridview.datamember = "checked";
datagridview.visible = true;
menu.text += "恭喜:\n";
for(int i=;i<datagridview.rowcount-;i++)
{
menu.text += datagridview.rows[i].cells["workeridandname"].value.tostring() +" 获得"+ datagridview.rows[i].cells["prize"].value.tostring() + "\n";
}
menu.visible = true;
timer.start();
myconn.close();
}
private void button_click(object sender, eventargs e)
{
new setpeople().showdialog();
}
private void combobox_selectedvaluechanged(object sender, eventargs e)
{
getnumber(combobox.text.tostring());
}
private void timer_tick(object sender, eventargs e)
{
lab.left = lab.left - ;
if (lab.right < )
{
lab.left = this.width;
}
}
//创建labels
private void bornlabel()
{
int i = ;
for (i = ; i < curnum; i++)
{
label[i] = new label();
label[i].forecolor = color.blue;
label[i].location = new system.drawing.point(, + (i * ));
label[i].size = new system.drawing.size(, );
label[i].backcolor = color.transparent;
label[i].anchor = (anchorstyles.top);
label[i].font = new system.drawing.font("simsun", , fontstyle.bold);
this.controls.add(label[i]);
}
total = i;
}
//清除labels
private void clearlabel()
{
for (int i = ; i < total; i++)
{
this.controls.remove(label[i]);
}
}
private void timer_tick(object sender, eventargs e)
{
hashtable.clear();
hashtable.clear();
sqlconnection con = new sqlconnection(conn);
string sql = "select count(*) from ticket";
sqlcommand com = new sqlcommand(sql, con);
con.open();
int emcount = convert.toint(com.executescalar());
con.close();
timer.enabled = true;
timer.interval = time;
int i;
for (i = ; i < curnum; i++)
{
int random = convert.toint(rd.next(, emcount));
if (datagridview.rows[random].cells["checked"].value.tostring().trim()=="" 
&& !hashtable.containsvalue(dict[random]))
{
hashtable.add(random,random);
hashtable.add(dict[random], dict[random]);
label[i].text = dict[random];
}
else
{
i--;
}
}
}
private void button_click(object sender, eventargs e)
{
combobox.enabled = true;
sqlconnection con = new sqlconnection(conn);
con.open();
string sql = "";
s = "";
timer.stop();
foreach (dictionaryentry de in hashtable)
{
sql = string.format("insert into checked(workeridandname,prize,prizeid) values('{}','{}','{}')", de.value.tostring(), combobox.text.tostring(),second.tostring());
sqlcommand com = new sqlcommand(sql, con);
com.executenonquery(); 
s += de.value.tostring() +" "; 
}
foreach (dictionaryentry de in hashtable)
{
datagridview.rows[convert.toint(de.key)].cells["checked"].value = "";
}
lab.text = "恭喜: " + s + "获得" + combobox.text.tostring();
//判断抽奖结束
end = end + curnum;
if (end == num)
{
button.enabled = false;
//button.enabled = false;
button.enabled = true;
if (messagebox.show("抽奖结束,是否进行补抽,点击确定进行补抽,取消结束此次抽奖!", "温馨提示", messageboxbuttons.yesno, messageboxicon.question) == dialogresult.yes)
{
btnadd.visible = true;
tbnum.visible = true;
ge.visible = true;
addend.visible = true;
}
}
}
private void timer_tick(object sender, eventargs e)
{
menu.top = menu.top - ;
if (menu.bottom < )
{
menu.top = this.height-;
}
}
private void 关闭窗口toolstripmenuitem_click(object sender, eventargs e)
{
this.close();
}
private void btnadd_click(object sender, eventargs e)
{
curnum = convert.toint(tbnum.text.tostring());
if (curnum == )
{
messagebox.show("请输入补抽个数!!!", "温馨提示");
return;
}
end = end + curnum;
if (end > convert.toint(datagridview.rowcount))
{
button.enabled = false;
messagebox.show("抽奖超过参与人数无法进行补抽!","温馨提示");
return;
}
timer.start();
clearlabel();
bornlabel();
}
private void addend_click(object sender, eventargs e)
{
btnadd.visible = false;
addend.visible = false;
tbnum.visible = false;
ge.visible = false;
menu.visible = false;
clearlabel();
sql = "select workeridandname,prize from checked order by prizeid";
sqlconnection myconn = new sqlconnection(conn);
myconn.open();
sqldataadapter sda = new sqldataadapter(sql, myconn);
dataset ds = new dataset();
sda.fill(ds, "checked");
datagridview.datasource = ds;
datagridview.datamember = "checked";
menu.text += "恭喜:\n";
for (int i = ; i < datagridview.rowcount - ; i++)
{
menu.text += datagridview.rows[i].cells["workeridandname"].value.tostring() + " 获得" + datagridview.rows[i].cells["prize"].value.tostring() + "\n";
}
menu.visible = true;
timer.start();
myconn.close();
}
//先导入到dataset
public dataset getxsldata(string filepath)
{
string strcon = "provider=microsoft.ace.oledb..;data source=" + filepath + ";extended properties=\"excel .;hdr=yes;\"";
system.data.oledb.oledbconnection conn = new system.data.oledb.oledbconnection(strcon);
string strcom = "select * from [sheet$]";
conn.open();
system.data.oledb.oledbdataadapter mycommand = new system.data.oledb.oledbdataadapter(strcom, conn);
dataset ds = new dataset();
mycommand.fill(ds, "[sheet$]");
conn.close();
return ds;
}
public static int errorcount = ;//记录错误信息条数
public static int insertcount = ;//记录插入成功条数
public static int updatecount = ;//记录更新信息条数
public bool importxsl(string home)
{
try
{
dataset ds = new dataset();
//取得数据集
//调用上面的函数
ds = getxsldata(@home);
sqlconnection con = new sqlconnection(conn);
con.open();
for (int i = ; i < ds.tables[].rows.count; i++)
{
string workerid = ds.tables[].rows[i][].tostring();
string name = ds.tables[].rows[i][].tostring();
string checked = ds.tables[].rows[i][].tostring();
if (workerid != "" && name != "")
{
string sq = string.format("select * from ticket where workerid='{}' and name='{}'", workerid, name);
sqlcommand selectcom = new sqlcommand(sq, con);
int count = convert.toint(selectcom.executescalar());
if (count > )
{
updatecount++;
}
else
{
string s = string.format("insert into ticket(workerid,name,checked) values('{}','{}','{}')", workerid, name,checked);
sqlcommand insertcom = new sqlcommand(s, con);
int result = insertcom.executenonquery();
insertcount++;
}
}
}
if (updatecount + insertcount == ds.tables[].rows.count)
{
return true;
}
else
{
return false;
}
}
catch (exception e)
{
return false;
}
}
//导入excle
private void button_click(object sender, eventargs e)
{
openfiledialog ofd = new openfiledialog();
ofd.filter = "microsoft excel files(*.xls)|*.xls;*.xlsx";//过滤一下,只要表格格式的
ofd.restoredirectory = true;
ofd.filterindex = ;
ofd.addextension = true;
ofd.checkfileexists = true;
ofd.checkpathexists = true;
ofd.showhelp = true;//是否显示帮助按钮
if (ofd.showdialog() == dialogresult.ok)
{
this.textbox.text = ofd.filename;
} 
}
//导入excle表格
private void button_click(object sender, eventargs e)
{
sqlconnection con = new sqlconnection(conn);
con.open();
//清空主键信息,标识自增从开始
string sqlstr = "truncate table ticket";
sqlcommand comm = new sqlcommand(sqlstr,con);
comm.executenonquery();
con.close();
if (textbox.text == "")
{
messagebox.show("请选择一张表格!!!", "温馨提示");
return;
} 
if (importxsl(textbox.text.tostring()))
{
messagebox.show(insertcount + "条数据导入成功!" + updatecount + "条数据重复!");
}
textbox.text = "";
} 
namespace check_ticket
{
partial class btn_uploadfile
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private system.componentmodel.icontainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void dispose(bool disposing)
{
if (disposing && (components != null))
{
components.dispose();
}
base.dispose(disposing);
}
#region windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void initializecomponent()
{
this.components = new system.componentmodel.container();
this.lab = new system.windows.forms.label();
this.combobox = new system.windows.forms.combobox();
this.button = new system.windows.forms.button();
this.datagridview = new system.windows.forms.datagridview();
this.button = new system.windows.forms.button();
this.button = new system.windows.forms.button();
this.datagridview = new system.windows.forms.datagridview();
this.button = new system.windows.forms.button();
this.lab = new system.windows.forms.label();
this.timer = new system.windows.forms.timer(this.components);
this.timer = new system.windows.forms.timer(this.components);
this.button = new system.windows.forms.button();
this.lab = new system.windows.forms.label();
this.timer = new system.windows.forms.timer(this.components);
this.menu = new system.windows.forms.label();
this.menustrip = new system.windows.forms.menustrip();
this.toolstripmenuitem = new system.windows.forms.toolstripmenuitem();
this.附加功能toolstripmenuitem = new system.windows.forms.toolstripmenuitem();
this.label = new system.windows.forms.label();
this.btnadd = new system.windows.forms.button();
this.tbnum = new system.windows.forms.textbox();
this.ge = new system.windows.forms.label();
this.补抽toolstripmenuitem = new system.windows.forms.toolstripmenuitem();
this.addend = new system.windows.forms.button();
this.openfiledialog = new system.windows.forms.openfiledialog();
this.button = new system.windows.forms.button();
this.textbox = new system.windows.forms.textbox();
this.button = new system.windows.forms.button();
((system.componentmodel.isupportinitialize)(this.datagridview)).begininit();
((system.componentmodel.isupportinitialize)(this.datagridview)).begininit();
this.menustrip.suspendlayout();
this.suspendlayout();
// 
// lab
// 
this.lab.autosize = true;
this.lab.backcolor = system.drawing.color.blue;
this.lab.font = new system.drawing.font("微软雅黑", .f, system.drawing.fontstyle.bold, system.drawing.graphicsunit.point, ((byte)()));
this.lab.forecolor = system.drawing.color.red;
this.lab.location = new system.drawing.point(, );
this.lab.name = "lab";
this.lab.size = new system.drawing.size(, );
this.lab.tabindex = ;
this.lab.text = "奖项名称:";
// 
// combobox
// 
this.combobox.dropdownstyle = system.windows.forms.comboboxstyle.dropdownlist;
this.combobox.forecolor = system.drawing.color.red;
this.combobox.formattingenabled = true;
this.combobox.items.addrange(new object[] {
"请选择",
"一等奖",
"二等奖",
"三等奖",
"四等奖",
"五等奖",
"六等奖"});
this.combobox.location = new system.drawing.point(, );
this.combobox.name = "combobox";
this.combobox.size = new system.drawing.size(, );
this.combobox.tabindex = ;
this.combobox.selectedvaluechanged += new system.eventhandler(this.combobox_selectedvaluechanged);
// 
// button
// 
this.button.enabled = false;
this.button.font = new system.drawing.font("宋体", f, system.drawing.fontstyle.bold, system.drawing.graphicsunit.point, ((byte)()));
this.button.forecolor = system.drawing.color.fromargb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.button.location = new system.drawing.point(, );
this.button.name = "button";
this.button.size = new system.drawing.size(, );
this.button.tabindex = ;
this.button.text = "开始抽奖";
this.button.usevisualstylebackcolor = true;
this.button.click += new system.eventhandler(this.button_click);
// 
// datagridview
// 
this.datagridview.columnheadersheightsizemode = system.windows.forms.datagridviewcolumnheadersheightsizemode.autosize;
this.datagridview.location = new system.drawing.point(, );
this.datagridview.name = "datagridview";
this.datagridview.rowtemplate.height = ;
this.datagridview.size = new system.drawing.size(, );
this.datagridview.tabindex = ;
this.datagridview.visible = false;
// 
// button
// 
this.button.enabled = false;
this.button.font = new system.drawing.font("宋体", f, system.drawing.fontstyle.bold, system.drawing.graphicsunit.point, ((byte)()));
this.button.forecolor = system.drawing.color.fromargb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.button.location = new system.drawing.point(, );
this.button.name = "button";
this.button.size = new system.drawing.size(, );
this.button.tabindex = ;
this.button.text = "查看获奖名单";
this.button.usevisualstylebackcolor = true;
this.button.click += new system.eventhandler(this.button_click);
// 
// button
// 
this.button.font = new system.drawing.font("宋体", f, system.drawing.fontstyle.bold, system.drawing.graphicsunit.point, ((byte)()));
this.button.forecolor = system.drawing.color.fromargb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.button.location = new system.drawing.point(, );
this.button.name = "button";
this.button.size = new system.drawing.size(, );
this.button.tabindex = ;
this.button.text = "人员加载";
this.button.usevisualstylebackcolor = true;
this.button.click += new system.eventhandler(this.button_click);
// 
// datagridview
// 
this.datagridview.autosizecolumnsmode = system.windows.forms.datagridviewautosizecolumnsmode.allcells;
this.datagridview.columnheadersheightsizemode = system.windows.forms.datagridviewcolumnheadersheightsizemode.autosize;
this.datagridview.gridcolor = system.drawing.color.black;
this.datagridview.location = new system.drawing.point(, );
this.datagridview.name = "datagridview";
this.datagridview.rowheadersvisible = false;
this.datagridview.rowtemplate.height = ;
this.datagridview.size = new system.drawing.size(, );
this.datagridview.tabindex = ;
this.datagridview.visible = false;
// 
// button
// 
this.button.font = new system.drawing.font("宋体", f, system.drawing.fontstyle.bold, system.drawing.graphicsunit.point, ((byte)()));
this.button.forecolor = system.drawing.color.fromargb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.button.location = new system.drawing.point(, );
this.button.name = "button";
this.button.size = new system.drawing.size(, );
this.button.tabindex = ;
this.button.text = "设置奖项对应人数";
this.button.usevisualstylebackcolor = true;
this.button.click += new system.eventhandler(this.button_click);
// 
// lab
// 
this.lab.autosize = true;
this.lab.backcolor = system.drawing.color.transparent;
this.lab.font = new system.drawing.font("宋体", f, system.drawing.fontstyle.regular, system.drawing.graphicsunit.point, ((byte)()));
this.lab.forecolor = system.drawing.color.blue;
this.lab.location = new system.drawing.point(, );
this.lab.name = "lab";
this.lab.size = new system.drawing.size(, );
this.lab.tabindex = ;
this.lab.text = "获奖名单";
// 
// timer
// 
this.timer.tick += new system.eventhandler(this.timer_tick);
// 
// timer
// 
this.timer.tick += new system.eventhandler(this.timer_tick);
// 
// button
// 
this.button.enabled = false;
this.button.forecolor = system.drawing.color.red;
this.button.location = new system.drawing.point(, );
this.button.name = "button";
this.button.size = new system.drawing.size(, );
this.button.tabindex = ;
this.button.text = "停止抽奖";
this.button.usevisualstylebackcolor = true;
this.button.click += new system.eventhandler(this.button_click);
// 
// lab
// 
this.lab.anchor = system.windows.forms.anchorstyles.top;
this.lab.autosize = true;
this.lab.backcolor = system.drawing.color.transparent;
this.lab.font = new system.drawing.font("华文新魏", f, system.drawing.fontstyle.bold, system.drawing.graphicsunit.point, ((byte)()));
this.lab.forecolor = system.drawing.color.fromargb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.lab.location = new system.drawing.point(, );
this.lab.name = "lab";
this.lab.size = new system.drawing.size(, );
this.lab.tabindex = ;
this.lab.text = "善林商务年会抽奖活动";
// 
// timer
// 
this.timer.tick += new system.eventhandler(this.timer_tick);
// 
// menu
// 
this.menu.autosize = true;
this.menu.backcolor = system.drawing.color.transparent;
this.menu.font = new system.drawing.font("宋体", f, system.drawing.fontstyle.regular, system.drawing.graphicsunit.point, ((byte)()));
this.menu.forecolor = system.drawing.color.blue;
this.menu.location = new system.drawing.point(, );
this.menu.name = "menu";
this.menu.size = new system.drawing.size(, );
this.menu.tabindex = ;
// 
// menustrip
// 
this.menustrip.backcolor = system.drawing.color.transparent;
this.menustrip.items.addrange(new system.windows.forms.toolstripitem[] {
this.toolstripmenuitem,
this.附加功能toolstripmenuitem});
this.menustrip.location = new system.drawing.point(, );
this.menustrip.name = "menustrip";
this.menustrip.size = new system.drawing.size(, );
this.menustrip.tabindex = ;
this.menustrip.text = "menustrip";
// 
// toolstripmenuitem
// 
this.toolstripmenuitem.backcolor = system.drawing.color.transparent;
this.toolstripmenuitem.forecolor = system.drawing.color.blue;
this.toolstripmenuitem.name = "toolstripmenuitem";
this.toolstripmenuitem.size = new system.drawing.size(, );
this.toolstripmenuitem.text = "关闭窗口";
this.toolstripmenuitem.click += new system.eventhandler(this.关闭窗口toolstripmenuitem_click);
// 
// 附加功能toolstripmenuitem
// 
this.附加功能toolstripmenuitem.name = "附加功能toolstripmenuitem";
this.附加功能toolstripmenuitem.size = new system.drawing.size(, );
// 
// label
// 
this.label.anchor = system.windows.forms.anchorstyles.top;
this.label.autosize = true;
this.label.forecolor = system.drawing.color.yellow;
this.label.location = new system.drawing.point(, );
this.label.name = "label";
this.label.size = new system.drawing.size(, );
this.label.tabindex = ;
this.label.text = "---------------------------------------------------------------------------------" +
"------";
// 
// btnadd
// 
this.btnadd.forecolor = system.drawing.color.indigo;
this.btnadd.location = new system.drawing.point(, );
this.btnadd.name = "btnadd";
this.btnadd.size = new system.drawing.size(, );
this.btnadd.tabindex = ;
this.btnadd.text = "补抽";
this.btnadd.usevisualstylebackcolor = true;
this.btnadd.visible = false;
this.btnadd.click += new system.eventhandler(this.btnadd_click);
// 
// tbnum
// 
this.tbnum.location = new system.drawing.point(, );
this.tbnum.name = "tbnum";
this.tbnum.size = new system.drawing.size(, );
this.tbnum.tabindex = ;
this.tbnum.text = "";
this.tbnum.visible = false;
// 
// ge
// 
this.ge.autosize = true;
this.ge.font = new system.drawing.font("宋体", .f, system.drawing.fontstyle.bold, system.drawing.graphicsunit.point, ((byte)()));
this.ge.location = new system.drawing.point(, );
this.ge.name = "ge";
this.ge.size = new system.drawing.size(, );
this.ge.tabindex = ;
this.ge.text = "个";
this.ge.visible = false;
// 
// 补抽toolstripmenuitem
// 
this.补抽toolstripmenuitem.name = "补抽toolstripmenuitem";
this.补抽toolstripmenuitem.size = new system.drawing.size(, );
// 
// addend
// 
this.addend.location = new system.drawing.point(, );
this.addend.name = "addend";
this.addend.size = new system.drawing.size(, );
this.addend.tabindex = ;
this.addend.text = "补抽结束";
this.addend.usevisualstylebackcolor = true;
this.addend.visible = false;
this.addend.click += new system.eventhandler(this.addend_click);
// 
// openfiledialog
// 
this.openfiledialog.filename = "openfiledialog";
// 
// button
// 
this.button.location = new system.drawing.point(, );
this.button.name = "button";
this.button.size = new system.drawing.size(, );
this.button.tabindex = ;
this.button.text = "选择文件";
this.button.usevisualstylebackcolor = true;
this.button.click += new system.eventhandler(this.button_click);
// 
// textbox
// 
this.textbox.location = new system.drawing.point(, );
this.textbox.name = "textbox";
this.textbox.size = new system.drawing.size(, );
this.textbox.tabindex = ;
// 
// button
// 
this.button.location = new system.drawing.point(, );
this.button.name = "button";
this.button.size = new system.drawing.size(, );
this.button.tabindex = ;
this.button.text = "上传文件";
this.button.usevisualstylebackcolor = true;
this.button.click += new system.eventhandler(this.button_click);
// 
// btn_uploadfile
// 
this.autoscaledimensions = new system.drawing.sizef(f, f);
this.autoscalemode = system.windows.forms.autoscalemode.font;
this.backcolor = system.drawing.color.red;
this.clientsize = new system.drawing.size(, );
this.controls.add(this.button);
this.controls.add(this.textbox);
this.controls.add(this.button);
this.controls.add(this.addend);
this.controls.add(this.ge);
this.controls.add(this.tbnum);
this.controls.add(this.btnadd);
this.controls.add(this.label);
this.controls.add(this.menu);
this.controls.add(this.lab);
this.controls.add(this.button);
this.controls.add(this.lab);
this.controls.add(this.button);
this.controls.add(this.datagridview);
this.controls.add(this.button);
this.controls.add(this.button);
this.controls.add(this.combobox);
this.controls.add(this.datagridview);
this.controls.add(this.button);
this.controls.add(this.lab);
this.controls.add(this.menustrip);
this.doublebuffered = true;
this.font = new system.drawing.font("宋体", f, system.drawing.fontstyle.bold, system.drawing.graphicsunit.point, ((byte)()));
this.forecolor = system.drawing.color.purple;
this.formborderstyle = system.windows.forms.formborderstyle.none;
this.mainmenustrip = this.menustrip;
this.maximumsize = new system.drawing.size(, );
this.minimumsize = new system.drawing.size(, );
this.name = "btn_uploadfile";
this.showicon = false;
this.text = "抽奖界面";
this.load += new system.eventhandler(this.form_load);
((system.componentmodel.isupportinitialize)(this.datagridview)).endinit();
((system.componentmodel.isupportinitialize)(this.datagridview)).endinit();
this.menustrip.resumelayout(false);
this.menustrip.performlayout();
this.resumelayout(false);
this.performlayout();
}
#endregion
private system.windows.forms.label lab;
private system.windows.forms.combobox combobox;
private system.windows.forms.button button;
private system.windows.forms.datagridview datagridview;
private system.windows.forms.button button;
private system.windows.forms.button button;
private system.windows.forms.datagridview datagridview;
private system.windows.forms.button button;
private system.windows.forms.label lab;
private system.windows.forms.timer timer;
private system.windows.forms.timer timer;
private system.windows.forms.button button;
private system.windows.forms.label lab;
private system.windows.forms.timer timer;
private system.windows.forms.label menu;
private system.windows.forms.menustrip menustrip;
private system.windows.forms.toolstripmenuitem toolstripmenuitem;
private system.windows.forms.label label;
private system.windows.forms.button btnadd;
private system.windows.forms.textbox tbnum;
private system.windows.forms.label ge;
private system.windows.forms.toolstripmenuitem 附加功能toolstripmenuitem;
private system.windows.forms.toolstripmenuitem 补抽toolstripmenuitem;
private system.windows.forms.button addend;
private system.windows.forms.openfiledialog openfiledialog;
private system.windows.forms.button button;
private system.windows.forms.textbox textbox;
private system.windows.forms.button button;
}
} 
}
}

数据库设计

C#实例代码之抽奖升级版可以经表格数据导入数据库,抽奖设置,补抽

C#实例代码之抽奖升级版可以经表格数据导入数据库,抽奖设置,补抽

C#实例代码之抽奖升级版可以经表格数据导入数据库,抽奖设置,补抽

界面

C#实例代码之抽奖升级版可以经表格数据导入数据库,抽奖设置,补抽

好了,本文就给大家介绍这么多,有需要的朋友可以参考下本代码,根据自己实际需求适当加入,同时感谢大家一直以来对网站的支持。