📄 addleibie.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 Addleibie : System.Web.UI.Page
{
//连接数据库
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["news_manageConnectionString"].ConnectionString);
clsLeibie leibie;
protected void Page_Load(object sender, EventArgs e)
{
leibie = new clsLeibie();
}
//判断类别是否存在,如果存在,弹出对话框
public bool check()
{
string str = "select count(*) from t_class where classname='" + this.txtName.Text+ "' ";
conn.Open();
SqlCommand com = new SqlCommand(str, conn);
int i = Convert.ToInt32(com.ExecuteScalar());
conn.Close();
if (i > 0)
{
return true;
}
else
{
return false;
}
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
//保存按钮
protected void btnSave_Click(object sender, EventArgs e)
{
bool bb=check();
if (bb)
{
Response.Write("<script language=javascript> window.alert('类别名称已经存在,请重新输入!')</script>");
}
else
{
string name = this.DropDownList1.Text;
string str = "select itemID from t_item where itemName='" + name + "'";
SqlCommand com = new SqlCommand(str, conn);
conn.Open();
int i = Convert.ToInt32(com.ExecuteScalar());
conn.Close();
string classname = this.txtName.Text;
string miaoshu = this.txtMiaoshu.Text;
int j = Convert.ToInt32(this.txtScort.Text);
bool b;
b = false;
b = leibie.insert(classname, miaoshu, j, i);
if (b)
{
Response.Write("<script language=javascript> window.alert('恭喜你,添加成功!')</script>");
}
else
{
Response.Write("<script language=javascript> window.alert('抱歉,您添加失败!')</script>");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -