📄 deviceadd.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.OracleClient;
using System.Drawing;
public partial class DeviceADD : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string conString=ConfigurationManager.AppSettings["ConnString"];
OracleConnection conn = new OracleConnection(conString);
OracleCommand cmd = new OracleCommand();
if (TextBox1.Text == "")
{
Label1.ForeColor = Color.FromName("red");
Label1.Text = "请输入装置编号";
}
else
{
cmd.CommandText = "select * from 设备信息表 where 装置编号='" + TextBox1.Text + "'";
cmd.Connection = conn;
conn.Open();
OracleDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Label1.ForeColor = Color.FromName("red");
Label1.Text = "该装置编号已存在";
//conn.Close();
}
else
{
if (TextBox3.Text == "")
{
Label1.ForeColor = Color.FromName("red");
Label1.Text = "请输入装置名称";
}
else
{
if (TextBox4.Text == "")
{
Label1.ForeColor = Color.FromName("red");
Label1.Text = "请输入装置型号";
}
else
{
Label1.Text = "";
if (TextBox5.Text == "")
{
if (TextBox6.Text == "")
{
cmd.CommandText = "insert into 设备信息表 values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox13.Text + "','" + DropDownList1.Text + "','" + TextBox9.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + TextBox12.Text + "')";
cmd.Connection = conn;
//conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Label1.ForeColor = Color.FromName("blue");
Label1.Text = "添加成功!";
}
else
{
cmd.CommandText = "insert into 设备信息表 values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "',date'" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox13.Text + "','" + DropDownList1.Text + "','" + TextBox9.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + TextBox12.Text + "')";
cmd.Connection = conn;
//conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Label1.ForeColor = Color.FromName("blue");
Label1.Text = "添加成功!";
}
}
else
{
if (TextBox6.Text == "")
{
cmd.CommandText = "insert into 设备信息表 values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "',date'" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox13.Text + "','" + DropDownList1.Text + "','" + TextBox9.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + TextBox12.Text + "')";
cmd.Connection = conn;
//conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Label1.ForeColor = Color.FromName("blue");
Label1.Text = "添加成功!";
}
else
{
cmd.CommandText = "insert into 设备信息表 values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "',date'" + TextBox5.Text + "',date'" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox13.Text + "','" + DropDownList1.Text + "','" + TextBox9.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + TextBox12.Text + "')";
cmd.Connection = conn;
//conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Label1.ForeColor = Color.FromName("blue");
Label1.Text = "添加成功!";
}
}
}
}
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox9.Text = "";
TextBox10.Text = "";
TextBox11.Text = "";
TextBox12.Text = "";
TextBox13.Text = "";
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.Redirect("DeviceSearch.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -