📄 manage.aspx.cs
字号:
//-----------------------------------------------------------------------------
//
// WebExpert.NET 1.0
//
// (c) 2003, www.AspCool.com. All rights reserved.
// ASP酷技术网版权所有
//
// 该源码下载自:http://www.51aspx.com
// 邮箱:tim@aspcool.com
//
// 版权声明:本程序仅供学习使用,你也可以修改后在网站上使用,但使用时必
// 须保留ASP酷技术网(www.AspCool.com)的版权信息和链接。本程序随《ASP.NET
// 网站建设专家》一书赠送,未经作者同意,不得随意修改、传播。
//
// 描述:
// 此文件包含下面的类:
// Manage
//
// 作者: 王保健
// 时间: 2003/09/15
//
//-----------------------------------------------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
namespace vote
{
/// <summary>
/// Summary description for Manage.
/// </summary>
public class Manage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.TextBox txtQuestionID;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox txtAnswer;
protected System.Web.UI.WebControls.Button btnSubmit;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.TextBox txtPWD;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.RadioButtonList rblMulti;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.TextBox txtSubject;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnSubmit_Click(object sender, System.EventArgs e)
{
string[] a;
string strSQL;
string strAnSQL;
string b;
SqlCommand AnComm;
//判断用户权限
if(txtPWD.Text==ConfigurationSettings.AppSettings["aspcoolPassword"])
{
strSQL= "insert into Questions(Question_ID,Question_Subject,Multi) values('"+txtQuestionID.Text +"','"+txtSubject.Text+"','"+rblMulti.SelectedItem.Value +"')";
SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
conn.Open();
try
{
//增加问题开始
SqlCommand comm=new SqlCommand(strSQL,conn);
comm.ExecuteNonQuery();
//增加问题结束
//下面是增加答案的程序
a = txtAnswer.Text.Split(Convert.ToChar(13));
for(int i=0;i<=a.Length-1;i++)
{
b=a[i].Trim();
if (!(b==""))
{
strAnSQL="insert into Answers(Question_ID,Answer)values('"+txtQuestionID.Text+"','"+b+"')";
AnComm=new SqlCommand(strAnSQL,conn);
AnComm.ExecuteNonQuery();
}
}
//增加答案
Response.Write("你的数据已经录入,请点击<a href=vote.aspx?ID="+txtQuestionID.Text +">此处</a>查看你的调查系统。");
}
catch (Exception ex)
{
Response.Write(ex);
}
conn.Close();
Response.End();
}
else
{
Response.Write("<font color=red>你的密码输入错误!</font>");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -