📄 class_jchshch.aspx.cs
字号:
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;
namespace free
{
/// <summary>
/// Summary description for class_jchshch.
/// </summary>
public class class_jchshch : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlInputButton Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.TextBox mingcheng;
protected System.Web.UI.WebControls.DropDownList zhuanjia;
protected System.Web.UI.WebControls.TextBox shixian;
protected System.Web.UI.WebControls.TextBox xuefei;
protected System.Web.UI.WebControls.TextBox jieshao ;
protected System.Web.UI.WebControls.Button Button4;
protected System.Web.UI.WebControls.Button Button3;
protected System.Data.SqlClient.SqlConnection myconn;
protected System.Web.UI.WebControls.Label tishi;
protected System.Data.SqlClient.SqlCommand mycomm;
private void Page_Load(object sender, System.EventArgs e)
{
try
{
if(Session["free_quanxian"].ToString()!="0")
{
Response.Write("<script>alert('您无权使用!!')</script>");
Response.Redirect("../admin/default.aspx");
}
}
catch
{
Response.Write("<script>alert('您无权使用!!')</script>");
Response.Redirect("../admin/default.aspx");
}
myconn=new SqlConnection(Session["str_connection"].ToString());
string sqlstr="select xingming from class_zhuanjia ";
myconn.Open();
if(!IsPostBack)
{
SqlDataAdapter mydata1=new SqlDataAdapter(sqlstr,myconn);
DataTable mytable;
mytable=new DataTable();
mydata1.Fill(mytable);
mytable.TableName="zhuanjia";
if(mytable.Rows.Count>0)
{
for(int i=0;i<=mytable.Rows.Count-1;i++)
{
zhuanjia.Items.Add(mytable.Rows[i]["xingming"].ToString());
}
myconn.Close();
}
else
{
tishi.Text="";
myconn.Close();
}
}
else myconn.Close();
}
#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.Button4.Click += new System.EventHandler(this.Button4_Click);
this.Button3.Click += new System.EventHandler(this.Button3_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Button1.ServerClick += new System.EventHandler(this.Button1_ServerClick);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button2_Click(object sender, System.EventArgs e)
{
Response.Redirect("class_guanli.aspx");
}
private void Button3_Click(object sender, System.EventArgs e)
{
Response.Redirect("class_jchshch1.aspx");
}
private void Button1_ServerClick(object sender, System.EventArgs e)
{
// string sqlcmd="select max(id) as id from class_jiaocheng";
// myconn.Open();
// mycomm=new SqlCommand(sqlcmd,myconn);
// string id;
// if(mycomm.ExecuteScalar()!=null)
// {
// id=mycomm.ExecuteScalar().ToString();
// myconn.Close();
// }
// else
// {
// id="0";
// myconn.Close();
// }
// int xuhao=0;
// xuhao=Convert.ToInt32(id);
// xuhao=xuhao+1;
// sqlcmd=null;
string sqlcmd="Insert into class_jiaocheng(shuming,zhuanjia_xingming,shichang,xuefei,jieshao) values('"+mingcheng.Text.Trim()+"','"+zhuanjia.SelectedValue.Trim()+"','"+shixian.Text.Trim()+"','"+xuefei.Text.Trim()+"','"+jieshao.Text.Trim()+"')";
myconn.Open();
mycomm=new SqlCommand(sqlcmd,myconn);
if(mycomm.ExecuteNonQuery()>0)
{
tishi.Text="书名录入成功!";
myconn.Close();
}
else
{
tishi.Text="操作有误";
myconn.Close();
}
}
private void Button4_Click(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -