📄 petnews.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//随机生成 验证码
Random rnd = new Random();
TextBox4.Text = rnd.Next(1000, 8000).ToString();
//用户统计
TextBox5.Text = Application["currentuser"].ToString();
TextBox6.Text = Application["alluser"].ToString();
}
private void ShowMassage(string msg)
{
Response.Write("<script>window.alert('" + msg + "')</script>");
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection sqlcon = new SqlConnection("data source=localhost;uid=sa;pwd=;database=Ebusiness");
sqlcon.Open();
SqlCommand objsqlcomm = new SqlCommand();
objsqlcomm.Connection = sqlcon;
objsqlcomm.CommandText = "mp_verifyuser";
objsqlcomm.CommandType = CommandType.StoredProcedure;
SqlParameter par1 = new SqlParameter("@username", SqlDbType.VarChar, 50);
par1.Direction = ParameterDirection.Input;
SqlParameter par2 = new SqlParameter("@password", SqlDbType.VarChar, 50);
par2.Direction = ParameterDirection.Input;
objsqlcomm.Parameters.Add(par1);
objsqlcomm.Parameters.Add(par2);
par1.Value = TextBox1.Text;
par2.Value = TextBox2.Text;
SqlDataReader reader = objsqlcomm.ExecuteReader();
if (reader.Read())
{
int i, a;
i = reader.GetInt32(0);
a = reader.GetInt32(1);
if (i == 1 && a == 1)
{
ShowMassage("登陆成功...管理员,你好!");
reader.Close();
return;
}
else
{
if (i == 0 && a == 1)
{
ShowMassage("登陆成功...会员,你好!");
reader.Close();
return;
}
}
}
else
{
ShowMassage("登陆失败..您好!您的身份是游客。");
return;
}
sqlcon.Close();
objsqlcomm = null;
sqlcon = null;
TextBox1.Text = "";
TextBox3.Text = "";
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("zhuce.aspx");
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
int index = GridView1.SelectedIndex; ;
string v = GridView1.DataKeys[index].Value.ToString();
Label7.Text = v;
Session["content"] = v;
Response.Redirect("content.aspx");
}
protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
{
Session["content"]="";
int i = GridView2.SelectedIndex;
string con = GridView2.DataKeys[i].Value.ToString();
Label7.Text = con;
Session["content"] =con;
Response.Redirect("content.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -