?? addclass.aspx.cs
字號:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
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.Configuration;
namespace sms
{
/// <summary>
/// addclass 的摘要說明。
/// </summary>
public partial class addclass : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁面
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:該調用是 ASP.NET Web 窗體設計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.Cv_id.ServerValidate += new System.Web.UI.WebControls.ServerValidateEventHandler(this.Cv_id_ServerValidate);
}
#endregion
private void Cv_id_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
string strsql = "select * from class where Class_id='"+Tbx_id.Text+"'";
DataAccess DataAs = new DataAccess();
DataTable DT = DataAs.CreateDatatable(strsql);
if (DT.Rows.Count > 0)
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
protected void Btn_add_Click(object sender, System.EventArgs e)
{
string strsql = "insert into class(Class_id,teacher_id,Class_name,Class_department,Class_college,Class_teacherid) values('" + Tbx_id.Text + "','" + Tbx_teacher.Text + "','" + Tbx_name.Text +
"','" + Tbx_department.Text + "','" + Ddl_college.SelectedItem.Text + "','" + Tbx_teacher.Text + "')";
DataAccess DataAs = new DataAccess();
bool Result = DataAs.ExecSql(strsql);
if (Result)
{
Response.Redirect("classes.aspx");
}
else
{
Lbl_note.Text = "添加失敗";
Lbl_note.Style["color"] = "red";
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -