目前,我正在开发幸运抽奖系统。我的系统运行良好,但是我只想添加一个功能,那就是它可以同时在另一页的表上显示幸运抽奖结果。以前,当用户单击系统上的按钮绘制时,它将在页面上显示结果。那么,如何在用户单击按钮绘制时使结果同时显示在另一页的表上?
这是我的幸运抽奖代码:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
string constr = ConfigurationManager.ConnectionStrings["lucky"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
}
static List<string> list = new List<string>();
protected void Button1_Click(object sender, EventArgs e)
{
string query = "SELECT TOP 1[Emp_id]FROM Emp_Info WHERE[Attendance] = 'Present'ORDER BY NEWID()";
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand(query))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
if (dt.Rows.Count > 0)
{
if (list.Any(x => x.Equals(dt.Rows[0]["Emp_id"].ToString())))
{
//Label1.Text += "is duplicate";
}
else
{
list.Add(dt.Rows[0]["Emp_id"].ToString());
Label1.Text = dt.Rows[0]["Emp_id"].ToString();
}
}
else
{
Label1.Text += "Cannot draw! ";
温温酱
相关分类