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

jerry C# 2016年03月10日 收藏

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

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Drawing.Imaging;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using System.Data.SqlClient;
  12. using System.Collections;
  13. using System.IO;
  14. namespace Check_Ticket
  15. {
  16. public partial class Btn_UpLoadFile : Form
  17. {
  18. string conn = "server=WIN-OUDREHCH;database=Xtf;uid=sa;pwd=";
  19. string sql = "";
  20. int CurNum = ;//奖项人数
  21. int second = ;//防止二次被抽取
  22. Hashtable hashtable = new Hashtable();//存储编号
  23. Hashtable hashtable = new Hashtable();//存储获奖名单
  24. Hashtable hashtable = new Hashtable();//避免二次抽奖
  25. Dictionary<int, string> dict = new Dictionary<int, string>();//词典存储所有参赛者
  26. Random rd = new Random();
  27. int time = ;
  28. Label[] label = new Label[];
  29. int index = ;//词典key键值
  30. int total = ;//label个数
  31. int num = ;//获奖总数
  32. string s = "";
  33. int End = ;//抽奖结束
  34. public Btn_UpLoadFile()
  35. {
  36. InitializeComponent();
  37. }
  38. private void Form_Load(object sender, EventArgs e)
  39. {
  40. dataGridView.ForeColor = Color.Blue;
  41. menu.Visible = false;
  42. comboBox.SelectedIndex = ;
  43. this.timer.Interval = ;
  44. this.timer.Interval = ;
  45. this.timer.Enabled = true;
  46. this.WindowState = FormWindowState.Maximized;
  47. }
  48. private void getNumber(string s)
  49. {
  50. SqlConnection myconn = new SqlConnection(conn);
  51. myconn.Open();
  52. sql = "select *from SumPrize";
  53. SqlDataAdapter da = new SqlDataAdapter(sql, myconn);
  54. DataSet ds = new DataSet();
  55. da.Fill(ds);
  56. switch (s)
  57. {
  58. case "一等奖":
  59. second = ;
  60. CurNum = Convert.ToInt(ds.Tables[].Rows[]["PrizeNum"].ToString());
  61. break;
  62. case "二等奖":
  63. second = ;
  64. CurNum = Convert.ToInt(ds.Tables[].Rows[]["PrizeNum"].ToString());
  65. break;
  66. case "三等奖":
  67. second = ;
  68. CurNum = Convert.ToInt(ds.Tables[].Rows[]["PrizeNum"].ToString());
  69. break;
  70. case "四等奖":
  71. second = ;
  72. CurNum = Convert.ToInt(ds.Tables[].Rows[]["PrizeNum"].ToString());
  73. break;
  74. case "五等奖":
  75. second = ;
  76. CurNum = Convert.ToInt(ds.Tables[].Rows[]["PrizeNum"].ToString());
  77. break;
  78. case "六等奖":
  79. second = ;
  80. CurNum = Convert.ToInt(ds.Tables[].Rows[]["PrizeNum"].ToString());
  81. break;
  82. case "请选择":
  83. CurNum = ;
  84. break;
  85. default:
  86. break;
  87. }
  88. }
  89. private void button_Click(object sender, EventArgs e)
  90. {
  91. SqlConnection myconn = new SqlConnection(conn);
  92. myconn.Open();
  93. //未选择抽奖项
  94. if (CurNum == )
  95. {
  96. MessageBox.Show("未设置该奖项或未选择奖项,抽奖没有意义!!!");
  97. return;
  98. }
  99. //处理已经被抽奖项
  100. if (!hashtable.ContainsValue(second))
  101. {
  102. comboBox.Enabled = true;
  103. hashtable.Add(second, second);
  104. }
  105. else
  106. {
  107. MessageBox.Show("此奖项已经被抽过,换个奖项吧?");
  108. return;
  109. }
  110. string prize = comboBox.Text.ToString();
  111. string sqlCount = "Select sum(PrizeNum) as num from SumPrize";
  112. SqlDataAdapter sda = new SqlDataAdapter(sqlCount, myconn);
  113. DataSet ds = new DataSet();
  114. sda.Fill(ds);
  115. //设置有奖总人数
  116. num = Convert.ToInt(ds.Tables[].Rows[]["num"].ToString());
  117. for (int i = ; i < dataGridView.RowCount-; i++)
  118. {
  119. dict.Add(index, dataGridView.Rows[i].Cells["WorkerID"].Value.ToString() + " " + dataGridView.Rows[i].Cells["Name"].Value.ToString());
  120. index++;
  121. }
  122. myconn.Close();
  123. timer.Start();
  124. clearLabel();
  125. bornLabel();
  126. timer.Enabled = true;
  127. comboBox.Enabled = false;
  128. }
  129. private void button_Click(object sender, EventArgs e)
  130. {
  131. End = ;
  132. menu.Text = "";
  133. hashtable.Clear();
  134. clearLabel();
  135. button.Enabled = true;
  136. button.Enabled = true;
  137. button.Enabled = false;
  138. menu.Visible = false;
  139. btnAdd.Visible = false;
  140. tbNum.Visible = false;
  141. ge.Visible = false;
  142. addEnd.Visible = false;
  143. lab.Text = "中奖名单";
  144. dataGridView.Visible = false;
  145. string sqlChecked = "delete from Checked";
  146. sql = "select *from Ticket";
  147. SqlConnection myconn = new SqlConnection(conn);
  148. myconn.Open();
  149. SqlDataAdapter sda = new SqlDataAdapter(sql, myconn);
  150. DataSet ds = new DataSet();
  151. sda.Fill(ds, "Ticket");
  152. dataGridView.DataSource = ds;
  153. dataGridView.DataMember = "Ticket";
  154. SqlCommand mycomm = new SqlCommand(sqlChecked, myconn);
  155. mycomm.ExecuteNonQuery();
  156. myconn.Close();
  157. }
  158. private void button_Click(object sender, EventArgs e)
  159. {
  160. menu.Visible = false;
  161. clearLabel();
  162. sql = "select WorkerIDAndName,Prize from Checked order by PrizeID";
  163. SqlConnection myconn = new SqlConnection(conn);
  164. myconn.Open();
  165. SqlDataAdapter sda = new SqlDataAdapter(sql, myconn);
  166. DataSet ds = new DataSet();
  167. sda.Fill(ds, "Checked");
  168. dataGridView.DataSource = ds;
  169. dataGridView.DataMember = "Checked";
  170. dataGridView.Visible = true;
  171. menu.Text += "恭喜:\n";
  172. for(int i=;i<dataGridView.RowCount-;i++)
  173. {
  174. menu.Text += dataGridView.Rows[i].Cells["WorkerIDAndName"].Value.ToString() +" 获得"+ dataGridView.Rows[i].Cells["Prize"].Value.ToString() + "\n";
  175. }
  176. menu.Visible = true;
  177. timer.Start();
  178. myconn.Close();
  179. }
  180. private void button_Click(object sender, EventArgs e)
  181. {
  182. new SetPeople().ShowDialog();
  183. }
  184. private void comboBox_SelectedValueChanged(object sender, EventArgs e)
  185. {
  186. getNumber(comboBox.Text.ToString());
  187. }
  188. private void timer_Tick(object sender, EventArgs e)
  189. {
  190. lab.Left = lab.Left - ;
  191. if (lab.Right < )
  192. {
  193. lab.Left = this.Width;
  194. }
  195. }
  196. //创建labels
  197. private void bornLabel()
  198. {
  199. int i = ;
  200. for (i = ; i < CurNum; i++)
  201. {
  202. label[i] = new Label();
  203. label[i].ForeColor = Color.Blue;
  204. label[i].Location = new System.Drawing.Point(, + (i * ));
  205. label[i].Size = new System.Drawing.Size(, );
  206. label[i].BackColor = Color.Transparent;
  207. label[i].Anchor = (AnchorStyles.Top);
  208. label[i].Font = new System.Drawing.Font("SimSun", , FontStyle.Bold);
  209. this.Controls.Add(label[i]);
  210. }
  211. total = i;
  212. }
  213. //清除labels
  214. private void clearLabel()
  215. {
  216. for (int i = ; i < total; i++)
  217. {
  218. this.Controls.Remove(label[i]);
  219. }
  220. }
  221. private void timer_Tick(object sender, EventArgs e)
  222. {
  223. hashtable.Clear();
  224. hashtable.Clear();
  225. SqlConnection con = new SqlConnection(conn);
  226. string sql = "select count(*) from Ticket";
  227. SqlCommand com = new SqlCommand(sql, con);
  228. con.Open();
  229. int emcount = Convert.ToInt(com.ExecuteScalar());
  230. con.Close();
  231. timer.Enabled = true;
  232. timer.Interval = time;
  233. int i;
  234. for (i = ; i < CurNum; i++)
  235. {
  236. int random = Convert.ToInt(rd.Next(, emcount));
  237. if (dataGridView.Rows[random].Cells["Checked"].Value.ToString().Trim()==""
  238. && !hashtable.ContainsValue(dict[random]))
  239. {
  240. hashtable.Add(random,random);
  241. hashtable.Add(dict[random], dict[random]);
  242. label[i].Text = dict[random];
  243. }
  244. else
  245. {
  246. i--;
  247. }
  248. }
  249. }
  250. private void button_Click(object sender, EventArgs e)
  251. {
  252. comboBox.Enabled = true;
  253. SqlConnection con = new SqlConnection(conn);
  254. con.Open();
  255. string sql = "";
  256. s = "";
  257. timer.Stop();
  258. foreach (DictionaryEntry de in hashtable)
  259. {
  260. sql = string.Format("insert into Checked(WorkerIDAndName,Prize,PrizeID) values('{}','{}','{}')", de.Value.ToString(), comboBox.Text.ToString(),second.ToString());
  261. SqlCommand com = new SqlCommand(sql, con);
  262. com.ExecuteNonQuery();
  263. s += de.Value.ToString() +" ";
  264. }
  265. foreach (DictionaryEntry de in hashtable)
  266. {
  267. dataGridView.Rows[Convert.ToInt(de.Key)].Cells["Checked"].Value = "";
  268. }
  269. lab.Text = "恭喜: " + s + "获得" + comboBox.Text.ToString();
  270. //判断抽奖结束
  271. End = End + CurNum;
  272. if (End == num)
  273. {
  274. button.Enabled = false;
  275. //button.Enabled = false;
  276. button.Enabled = true;
  277. if (MessageBox.Show("抽奖结束,是否进行补抽,点击确定进行补抽,取消结束此次抽奖!", "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  278. {
  279. btnAdd.Visible = true;
  280. tbNum.Visible = true;
  281. ge.Visible = true;
  282. addEnd.Visible = true;
  283. }
  284. }
  285. }
  286. private void timer_Tick(object sender, EventArgs e)
  287. {
  288. menu.Top = menu.Top - ;
  289. if (menu.Bottom < )
  290. {
  291. menu.Top = this.Height-;
  292. }
  293. }
  294. private void 关闭窗口ToolStripMenuItem_Click(object sender, EventArgs e)
  295. {
  296. this.Close();
  297. }
  298. private void btnAdd_Click(object sender, EventArgs e)
  299. {
  300. CurNum = Convert.ToInt(tbNum.Text.ToString());
  301. if (CurNum == )
  302. {
  303. MessageBox.Show("请输入补抽个数!!!", "温馨提示");
  304. return;
  305. }
  306. End = End + CurNum;
  307. if (End > Convert.ToInt(dataGridView.RowCount))
  308. {
  309. button.Enabled = false;
  310. MessageBox.Show("抽奖超过参与人数无法进行补抽!","温馨提示");
  311. return;
  312. }
  313. timer.Start();
  314. clearLabel();
  315. bornLabel();
  316. }
  317. private void addEnd_Click(object sender, EventArgs e)
  318. {
  319. btnAdd.Visible = false;
  320. addEnd.Visible = false;
  321. tbNum.Visible = false;
  322. ge.Visible = false;
  323. menu.Visible = false;
  324. clearLabel();
  325. sql = "select WorkerIDAndName,Prize from Checked order by PrizeID";
  326. SqlConnection myconn = new SqlConnection(conn);
  327. myconn.Open();
  328. SqlDataAdapter sda = new SqlDataAdapter(sql, myconn);
  329. DataSet ds = new DataSet();
  330. sda.Fill(ds, "Checked");
  331. dataGridView.DataSource = ds;
  332. dataGridView.DataMember = "Checked";
  333. menu.Text += "恭喜:\n";
  334. for (int i = ; i < dataGridView.RowCount - ; i++)
  335. {
  336. menu.Text += dataGridView.Rows[i].Cells["WorkerIDAndName"].Value.ToString() + " 获得" + dataGridView.Rows[i].Cells["Prize"].Value.ToString() + "\n";
  337. }
  338. menu.Visible = true;
  339. timer.Start();
  340. myconn.Close();
  341. }
  342. //先导入到dataSet
  343. public DataSet getXSLData(string filepath)
  344. {
  345. string strCon = "Provider=Microsoft.ACE.OLEDB..;Data Source=" + filepath + ";Extended Properties=\"Excel .;HDR=YES;\"";
  346. System.Data.OleDb.OleDbConnection Conn = new System.Data.OleDb.OleDbConnection(strCon);
  347. string strCom = "SELECT * FROM [Sheet$]";
  348. Conn.Open();
  349. System.Data.OleDb.OleDbDataAdapter myCommand = new System.Data.OleDb.OleDbDataAdapter(strCom, Conn);
  350. DataSet ds = new DataSet();
  351. myCommand.Fill(ds, "[Sheet$]");
  352. Conn.Close();
  353. return ds;
  354. }
  355. public static int errorcount = ;//记录错误信息条数
  356. public static int insertcount = ;//记录插入成功条数
  357. public static int updatecount = ;//记录更新信息条数
  358. public bool ImportXSL(string home)
  359. {
  360. try
  361. {
  362. DataSet ds = new DataSet();
  363. //取得数据集
  364. //调用上面的函数
  365. ds = getXSLData(@home);
  366. SqlConnection con = new SqlConnection(conn);
  367. con.Open();
  368. for (int i = ; i < ds.Tables[].Rows.Count; i++)
  369. {
  370. string WorkerID = ds.Tables[].Rows[i][].ToString();
  371. string Name = ds.Tables[].Rows[i][].ToString();
  372. string Checked = ds.Tables[].Rows[i][].ToString();
  373. if (WorkerID != "" && Name != "")
  374. {
  375. string sq = string.Format("select * from Ticket where WorkerID='{}' and Name='{}'", WorkerID, Name);
  376. SqlCommand selectcom = new SqlCommand(sq, con);
  377. int count = Convert.ToInt(selectcom.ExecuteScalar());
  378. if (count > )
  379. {
  380. updatecount++;
  381. }
  382. else
  383. {
  384. string s = string.Format("insert into Ticket(WorkerID,Name,Checked) values('{}','{}','{}')", WorkerID, Name,Checked);
  385. SqlCommand insertcom = new SqlCommand(s, con);
  386. int result = insertcom.ExecuteNonQuery();
  387. insertcount++;
  388. }
  389. }
  390. }
  391. if (updatecount + insertcount == ds.Tables[].Rows.Count)
  392. {
  393. return true;
  394. }
  395. else
  396. {
  397. return false;
  398. }
  399. }
  400. catch (Exception e)
  401. {
  402. return false;
  403. }
  404. }
  405. //导入excle
  406. private void button_Click(object sender, EventArgs e)
  407. {
  408. OpenFileDialog ofd = new OpenFileDialog();
  409. ofd.Filter = "Microsoft Excel files(*.xls)|*.xls;*.xlsx";//过滤一下,只要表格格式的
  410. ofd.RestoreDirectory = true;
  411. ofd.FilterIndex = ;
  412. ofd.AddExtension = true;
  413. ofd.CheckFileExists = true;
  414. ofd.CheckPathExists = true;
  415. ofd.ShowHelp = true;//是否显示帮助按钮
  416. if (ofd.ShowDialog() == DialogResult.OK)
  417. {
  418. this.textBox.Text = ofd.FileName;
  419. }
  420. }
  421. //导入excle表格
  422. private void button_Click(object sender, EventArgs e)
  423. {
  424. SqlConnection con = new SqlConnection(conn);
  425. con.Open();
  426. //清空主键信息,标识自增从开始
  427. string sqlstr = "truncate table Ticket";
  428. SqlCommand comm = new SqlCommand(sqlstr,con);
  429. comm.ExecuteNonQuery();
  430. con.Close();
  431. if (textBox.Text == "")
  432. {
  433. MessageBox.Show("请选择一张表格!!!", "温馨提示");
  434. return;
  435. }
  436. if (ImportXSL(textBox.Text.ToString()))
  437. {
  438. MessageBox.Show(insertcount + "条数据导入成功!" + updatecount + "条数据重复!");
  439. }
  440. textBox.Text = "";
  441. }
  442. namespace Check_Ticket
  443. {
  444. partial class Btn_UpLoadFile
  445. {
  446. /// <summary>
  447. /// 必需的设计器变量。
  448. /// </summary>
  449. private System.ComponentModel.IContainer components = null;
  450. /// <summary>
  451. /// 清理所有正在使用的资源。
  452. /// </summary>
  453. /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
  454. protected override void Dispose(bool disposing)
  455. {
  456. if (disposing && (components != null))
  457. {
  458. components.Dispose();
  459. }
  460. base.Dispose(disposing);
  461. }
  462. #region Windows 窗体设计器生成的代码
  463. /// <summary>
  464. /// 设计器支持所需的方法 - 不要
  465. /// 使用代码编辑器修改此方法的内容。
  466. /// </summary>
  467. private void InitializeComponent()
  468. {
  469. this.components = new System.ComponentModel.Container();
  470. this.lab = new System.Windows.Forms.Label();
  471. this.comboBox = new System.Windows.Forms.ComboBox();
  472. this.button = new System.Windows.Forms.Button();
  473. this.dataGridView = new System.Windows.Forms.DataGridView();
  474. this.button = new System.Windows.Forms.Button();
  475. this.button = new System.Windows.Forms.Button();
  476. this.dataGridView = new System.Windows.Forms.DataGridView();
  477. this.button = new System.Windows.Forms.Button();
  478. this.lab = new System.Windows.Forms.Label();
  479. this.timer = new System.Windows.Forms.Timer(this.components);
  480. this.timer = new System.Windows.Forms.Timer(this.components);
  481. this.button = new System.Windows.Forms.Button();
  482. this.lab = new System.Windows.Forms.Label();
  483. this.timer = new System.Windows.Forms.Timer(this.components);
  484. this.menu = new System.Windows.Forms.Label();
  485. this.menuStrip = new System.Windows.Forms.MenuStrip();
  486. this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  487. this.附加功能ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  488. this.label = new System.Windows.Forms.Label();
  489. this.btnAdd = new System.Windows.Forms.Button();
  490. this.tbNum = new System.Windows.Forms.TextBox();
  491. this.ge = new System.Windows.Forms.Label();
  492. this.补抽ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
  493. this.addEnd = new System.Windows.Forms.Button();
  494. this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
  495. this.button = new System.Windows.Forms.Button();
  496. this.textBox = new System.Windows.Forms.TextBox();
  497. this.button = new System.Windows.Forms.Button();
  498. ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
  499. ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
  500. this.menuStrip.SuspendLayout();
  501. this.SuspendLayout();
  502. //
  503. // lab
  504. //
  505. this.lab.AutoSize = true;
  506. this.lab.BackColor = System.Drawing.Color.Blue;
  507. this.lab.Font = new System.Drawing.Font("微软雅黑", .F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)()));
  508. this.lab.ForeColor = System.Drawing.Color.Red;
  509. this.lab.Location = new System.Drawing.Point(, );
  510. this.lab.Name = "lab";
  511. this.lab.Size = new System.Drawing.Size(, );
  512. this.lab.TabIndex = ;
  513. this.lab.Text = "奖项名称:";
  514. //
  515. // comboBox
  516. //
  517. this.comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  518. this.comboBox.ForeColor = System.Drawing.Color.Red;
  519. this.comboBox.FormattingEnabled = true;
  520. this.comboBox.Items.AddRange(new object[] {
  521. "请选择",
  522. "一等奖",
  523. "二等奖",
  524. "三等奖",
  525. "四等奖",
  526. "五等奖",
  527. "六等奖"});
  528. this.comboBox.Location = new System.Drawing.Point(, );
  529. this.comboBox.Name = "comboBox";
  530. this.comboBox.Size = new System.Drawing.Size(, );
  531. this.comboBox.TabIndex = ;
  532. this.comboBox.SelectedValueChanged += new System.EventHandler(this.comboBox_SelectedValueChanged);
  533. //
  534. // button
  535. //
  536. this.button.Enabled = false;
  537. this.button.Font = new System.Drawing.Font("宋体", F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)()));
  538. this.button.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
  539. this.button.Location = new System.Drawing.Point(, );
  540. this.button.Name = "button";
  541. this.button.Size = new System.Drawing.Size(, );
  542. this.button.TabIndex = ;
  543. this.button.Text = "开始抽奖";
  544. this.button.UseVisualStyleBackColor = true;
  545. this.button.Click += new System.EventHandler(this.button_Click);
  546. //
  547. // dataGridView
  548. //
  549. this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  550. this.dataGridView.Location = new System.Drawing.Point(, );
  551. this.dataGridView.Name = "dataGridView";
  552. this.dataGridView.RowTemplate.Height = ;
  553. this.dataGridView.Size = new System.Drawing.Size(, );
  554. this.dataGridView.TabIndex = ;
  555. this.dataGridView.Visible = false;
  556. //
  557. // button
  558. //
  559. this.button.Enabled = false;
  560. this.button.Font = new System.Drawing.Font("宋体", F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)()));
  561. this.button.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
  562. this.button.Location = new System.Drawing.Point(, );
  563. this.button.Name = "button";
  564. this.button.Size = new System.Drawing.Size(, );
  565. this.button.TabIndex = ;
  566. this.button.Text = "查看获奖名单";
  567. this.button.UseVisualStyleBackColor = true;
  568. this.button.Click += new System.EventHandler(this.button_Click);
  569. //
  570. // button
  571. //
  572. this.button.Font = new System.Drawing.Font("宋体", F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)()));
  573. this.button.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
  574. this.button.Location = new System.Drawing.Point(, );
  575. this.button.Name = "button";
  576. this.button.Size = new System.Drawing.Size(, );
  577. this.button.TabIndex = ;
  578. this.button.Text = "人员加载";
  579. this.button.UseVisualStyleBackColor = true;
  580. this.button.Click += new System.EventHandler(this.button_Click);
  581. //
  582. // dataGridView
  583. //
  584. this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
  585. this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  586. this.dataGridView.GridColor = System.Drawing.Color.Black;
  587. this.dataGridView.Location = new System.Drawing.Point(, );
  588. this.dataGridView.Name = "dataGridView";
  589. this.dataGridView.RowHeadersVisible = false;
  590. this.dataGridView.RowTemplate.Height = ;
  591. this.dataGridView.Size = new System.Drawing.Size(, );
  592. this.dataGridView.TabIndex = ;
  593. this.dataGridView.Visible = false;
  594. //
  595. // button
  596. //
  597. this.button.Font = new System.Drawing.Font("宋体", F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)()));
  598. this.button.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
  599. this.button.Location = new System.Drawing.Point(, );
  600. this.button.Name = "button";
  601. this.button.Size = new System.Drawing.Size(, );
  602. this.button.TabIndex = ;
  603. this.button.Text = "设置奖项对应人数";
  604. this.button.UseVisualStyleBackColor = true;
  605. this.button.Click += new System.EventHandler(this.button_Click);
  606. //
  607. // lab
  608. //
  609. this.lab.AutoSize = true;
  610. this.lab.BackColor = System.Drawing.Color.Transparent;
  611. this.lab.Font = new System.Drawing.Font("宋体", F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)()));
  612. this.lab.ForeColor = System.Drawing.Color.Blue;
  613. this.lab.Location = new System.Drawing.Point(, );
  614. this.lab.Name = "lab";
  615. this.lab.Size = new System.Drawing.Size(, );
  616. this.lab.TabIndex = ;
  617. this.lab.Text = "获奖名单";
  618. //
  619. // timer
  620. //
  621. this.timer.Tick += new System.EventHandler(this.timer_Tick);
  622. //
  623. // timer
  624. //
  625. this.timer.Tick += new System.EventHandler(this.timer_Tick);
  626. //
  627. // button
  628. //
  629. this.button.Enabled = false;
  630. this.button.ForeColor = System.Drawing.Color.Red;
  631. this.button.Location = new System.Drawing.Point(, );
  632. this.button.Name = "button";
  633. this.button.Size = new System.Drawing.Size(, );
  634. this.button.TabIndex = ;
  635. this.button.Text = "停止抽奖";
  636. this.button.UseVisualStyleBackColor = true;
  637. this.button.Click += new System.EventHandler(this.button_Click);
  638. //
  639. // lab
  640. //
  641. this.lab.Anchor = System.Windows.Forms.AnchorStyles.Top;
  642. this.lab.AutoSize = true;
  643. this.lab.BackColor = System.Drawing.Color.Transparent;
  644. this.lab.Font = new System.Drawing.Font("华文新魏", F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)()));
  645. this.lab.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
  646. this.lab.Location = new System.Drawing.Point(, );
  647. this.lab.Name = "lab";
  648. this.lab.Size = new System.Drawing.Size(, );
  649. this.lab.TabIndex = ;
  650. this.lab.Text = "善林商务年会抽奖活动";
  651. //
  652. // timer
  653. //
  654. this.timer.Tick += new System.EventHandler(this.timer_Tick);
  655. //
  656. // menu
  657. //
  658. this.menu.AutoSize = true;
  659. this.menu.BackColor = System.Drawing.Color.Transparent;
  660. this.menu.Font = new System.Drawing.Font("宋体", F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)()));
  661. this.menu.ForeColor = System.Drawing.Color.Blue;
  662. this.menu.Location = new System.Drawing.Point(, );
  663. this.menu.Name = "menu";
  664. this.menu.Size = new System.Drawing.Size(, );
  665. this.menu.TabIndex = ;
  666. //
  667. // menuStrip
  668. //
  669. this.menuStrip.BackColor = System.Drawing.Color.Transparent;
  670. this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
  671. this.ToolStripMenuItem,
  672. this.附加功能ToolStripMenuItem});
  673. this.menuStrip.Location = new System.Drawing.Point(, );
  674. this.menuStrip.Name = "menuStrip";
  675. this.menuStrip.Size = new System.Drawing.Size(, );
  676. this.menuStrip.TabIndex = ;
  677. this.menuStrip.Text = "menuStrip";
  678. //
  679. // ToolStripMenuItem
  680. //
  681. this.ToolStripMenuItem.BackColor = System.Drawing.Color.Transparent;
  682. this.ToolStripMenuItem.ForeColor = System.Drawing.Color.Blue;
  683. this.ToolStripMenuItem.Name = "ToolStripMenuItem";
  684. this.ToolStripMenuItem.Size = new System.Drawing.Size(, );
  685. this.ToolStripMenuItem.Text = "关闭窗口";
  686. this.ToolStripMenuItem.Click += new System.EventHandler(this.关闭窗口ToolStripMenuItem_Click);
  687. //
  688. // 附加功能ToolStripMenuItem
  689. //
  690. this.附加功能ToolStripMenuItem.Name = "附加功能ToolStripMenuItem";
  691. this.附加功能ToolStripMenuItem.Size = new System.Drawing.Size(, );
  692. //
  693. // label
  694. //
  695. this.label.Anchor = System.Windows.Forms.AnchorStyles.Top;
  696. this.label.AutoSize = true;
  697. this.label.ForeColor = System.Drawing.Color.Yellow;
  698. this.label.Location = new System.Drawing.Point(, );
  699. this.label.Name = "label";
  700. this.label.Size = new System.Drawing.Size(, );
  701. this.label.TabIndex = ;
  702. this.label.Text = "---------------------------------------------------------------------------------" +
  703. "------";
  704. //
  705. // btnAdd
  706. //
  707. this.btnAdd.ForeColor = System.Drawing.Color.Indigo;
  708. this.btnAdd.Location = new System.Drawing.Point(, );
  709. this.btnAdd.Name = "btnAdd";
  710. this.btnAdd.Size = new System.Drawing.Size(, );
  711. this.btnAdd.TabIndex = ;
  712. this.btnAdd.Text = "补抽";
  713. this.btnAdd.UseVisualStyleBackColor = true;
  714. this.btnAdd.Visible = false;
  715. this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
  716. //
  717. // tbNum
  718. //
  719. this.tbNum.Location = new System.Drawing.Point(, );
  720. this.tbNum.Name = "tbNum";
  721. this.tbNum.Size = new System.Drawing.Size(, );
  722. this.tbNum.TabIndex = ;
  723. this.tbNum.Text = "";
  724. this.tbNum.Visible = false;
  725. //
  726. // ge
  727. //
  728. this.ge.AutoSize = true;
  729. this.ge.Font = new System.Drawing.Font("宋体", .F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)()));
  730. this.ge.Location = new System.Drawing.Point(, );
  731. this.ge.Name = "ge";
  732. this.ge.Size = new System.Drawing.Size(, );
  733. this.ge.TabIndex = ;
  734. this.ge.Text = "个";
  735. this.ge.Visible = false;
  736. //
  737. // 补抽ToolStripMenuItem
  738. //
  739. this.补抽ToolStripMenuItem.Name = "补抽ToolStripMenuItem";
  740. this.补抽ToolStripMenuItem.Size = new System.Drawing.Size(, );
  741. //
  742. // addEnd
  743. //
  744. this.addEnd.Location = new System.Drawing.Point(, );
  745. this.addEnd.Name = "addEnd";
  746. this.addEnd.Size = new System.Drawing.Size(, );
  747. this.addEnd.TabIndex = ;
  748. this.addEnd.Text = "补抽结束";
  749. this.addEnd.UseVisualStyleBackColor = true;
  750. this.addEnd.Visible = false;
  751. this.addEnd.Click += new System.EventHandler(this.addEnd_Click);
  752. //
  753. // openFileDialog
  754. //
  755. this.openFileDialog.FileName = "openFileDialog";
  756. //
  757. // button
  758. //
  759. this.button.Location = new System.Drawing.Point(, );
  760. this.button.Name = "button";
  761. this.button.Size = new System.Drawing.Size(, );
  762. this.button.TabIndex = ;
  763. this.button.Text = "选择文件";
  764. this.button.UseVisualStyleBackColor = true;
  765. this.button.Click += new System.EventHandler(this.button_Click);
  766. //
  767. // textBox
  768. //
  769. this.textBox.Location = new System.Drawing.Point(, );
  770. this.textBox.Name = "textBox";
  771. this.textBox.Size = new System.Drawing.Size(, );
  772. this.textBox.TabIndex = ;
  773. //
  774. // button
  775. //
  776. this.button.Location = new System.Drawing.Point(, );
  777. this.button.Name = "button";
  778. this.button.Size = new System.Drawing.Size(, );
  779. this.button.TabIndex = ;
  780. this.button.Text = "上传文件";
  781. this.button.UseVisualStyleBackColor = true;
  782. this.button.Click += new System.EventHandler(this.button_Click);
  783. //
  784. // Btn_UpLoadFile
  785. //
  786. this.AutoScaleDimensions = new System.Drawing.SizeF(F, F);
  787. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  788. this.BackColor = System.Drawing.Color.Red;
  789. this.ClientSize = new System.Drawing.Size(, );
  790. this.Controls.Add(this.button);
  791. this.Controls.Add(this.textBox);
  792. this.Controls.Add(this.button);
  793. this.Controls.Add(this.addEnd);
  794. this.Controls.Add(this.ge);
  795. this.Controls.Add(this.tbNum);
  796. this.Controls.Add(this.btnAdd);
  797. this.Controls.Add(this.label);
  798. this.Controls.Add(this.menu);
  799. this.Controls.Add(this.lab);
  800. this.Controls.Add(this.button);
  801. this.Controls.Add(this.lab);
  802. this.Controls.Add(this.button);
  803. this.Controls.Add(this.dataGridView);
  804. this.Controls.Add(this.button);
  805. this.Controls.Add(this.button);
  806. this.Controls.Add(this.comboBox);
  807. this.Controls.Add(this.dataGridView);
  808. this.Controls.Add(this.button);
  809. this.Controls.Add(this.lab);
  810. this.Controls.Add(this.menuStrip);
  811. this.DoubleBuffered = true;
  812. this.Font = new System.Drawing.Font("宋体", F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)()));
  813. this.ForeColor = System.Drawing.Color.Purple;
  814. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
  815. this.MainMenuStrip = this.menuStrip;
  816. this.MaximumSize = new System.Drawing.Size(, );
  817. this.MinimumSize = new System.Drawing.Size(, );
  818. this.Name = "Btn_UpLoadFile";
  819. this.ShowIcon = false;
  820. this.Text = "抽奖界面";
  821. this.Load += new System.EventHandler(this.Form_Load);
  822. ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
  823. ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
  824. this.menuStrip.ResumeLayout(false);
  825. this.menuStrip.PerformLayout();
  826. this.ResumeLayout(false);
  827. this.PerformLayout();
  828. }
  829. #endregion
  830. private System.Windows.Forms.Label lab;
  831. private System.Windows.Forms.ComboBox comboBox;
  832. private System.Windows.Forms.Button button;
  833. private System.Windows.Forms.DataGridView dataGridView;
  834. private System.Windows.Forms.Button button;
  835. private System.Windows.Forms.Button button;
  836. private System.Windows.Forms.DataGridView dataGridView;
  837. private System.Windows.Forms.Button button;
  838. private System.Windows.Forms.Label lab;
  839. private System.Windows.Forms.Timer timer;
  840. private System.Windows.Forms.Timer timer;
  841. private System.Windows.Forms.Button button;
  842. private System.Windows.Forms.Label lab;
  843. private System.Windows.Forms.Timer timer;
  844. private System.Windows.Forms.Label menu;
  845. private System.Windows.Forms.MenuStrip menuStrip;
  846. private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
  847. private System.Windows.Forms.Label label;
  848. private System.Windows.Forms.Button btnAdd;
  849. private System.Windows.Forms.TextBox tbNum;
  850. private System.Windows.Forms.Label ge;
  851. private System.Windows.Forms.ToolStripMenuItem 附加功能ToolStripMenuItem;
  852. private System.Windows.Forms.ToolStripMenuItem 补抽ToolStripMenuItem;
  853. private System.Windows.Forms.Button addEnd;
  854. private System.Windows.Forms.OpenFileDialog openFileDialog;
  855. private System.Windows.Forms.Button button;
  856. private System.Windows.Forms.TextBox textBox;
  857. private System.Windows.Forms.Button button;
  858. }
  859. }
  860. }
  861. }

数据库设计


界面

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