admin/atypeadd.aspx.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
public partial class atypeadd : System.Web.UI.Page
{
protected void Page_Load(Object Src, EventArgs E)
{
if (!IsPostBack) BindGrid();
}
// 处理添加事件
public void Add_Click(Object sender, EventArgs E)
{
if (txtp_type.Text == "")
{
label1.Text = "请输入品牌名称!";
label1.Style["color"] = "red";
}
else
{
string myCnn = ConfigurationSettings.AppSettings["Con"];
SqlConnection Conn = new SqlConnection(myCnn);
// 构造SQL语句
String strSQL = "insert into 手机类型表(品牌名称,品牌编号) values (@品牌名称,@品牌编号)";
// 创建Command对象
SqlCommand Comm = new SqlCommand(strSQL, Conn);
// 添加并设置参数的值
Comm.Parameters.Add(new SqlParameter("@品牌名称", SqlDbType.Char));
Comm.Parameters["@品牌名称"].Value = txtp_type.Text;
Comm.Parameters.Add(new SqlParameter("@品牌编号", SqlDbType.Char));
Comm.Parameters["@品牌编号"].Value = bh.Text;
// 打开连接
Comm.Connection.Open();
try
{
Comm.ExecuteNonQuery();
label1.Text = "添加成功";
}
catch (SqlException)
{
label1.Text = "添加失败";
label1.Style["color"] = "red";
}
// 关闭连接
Comm.Connection.Close();
// 在DataGrid控件中显示学生列表
BindGrid();
txtp_type.Text = "";
}
}
// BindGrid()执行数据绑定
public void BindGrid()
后面还有 10 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。