📄 noticedel.aspx.cs
字号:
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Kind", System.Data.SqlDbType.VarChar, 10, "Info_Kind"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Text", System.Data.SqlDbType.VarChar, 1000, "Info_Text"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Date", System.Data.SqlDbType.NVarChar, 10, "Info_Date"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT Info_ID, Info_Writer, Info_Main, Info_Kind, Info_Text, Info_Date FROM Info" +
"";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE Info SET Info_ID = @Info_ID, Info_Writer = @Info_Writer, Info_Main = @Info_Main, Info_Kind = @Info_Kind, Info_Text = @Info_Text, Info_Date = @Info_Date WHERE (Info_ID = @Original_Info_ID) AND (Info_Date = @Original_Info_Date) AND (Info_Kind = @Original_Info_Kind) AND (Info_Main = @Original_Info_Main) AND (Info_Text = @Original_Info_Text) AND (Info_Writer = @Original_Info_Writer); SELECT Info_ID, Info_Writer, Info_Main, Info_Kind, Info_Text, Info_Date FROM Info WHERE (Info_ID = @Info_ID)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_ID", System.Data.SqlDbType.BigInt, 8, "Info_ID"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Writer", System.Data.SqlDbType.VarChar, 20, "Info_Writer"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Main", System.Data.SqlDbType.VarChar, 40, "Info_Main"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Kind", System.Data.SqlDbType.VarChar, 10, "Info_Kind"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Text", System.Data.SqlDbType.VarChar, 1000, "Info_Text"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Date", System.Data.SqlDbType.NVarChar, 10, "Info_Date"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_ID", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_ID", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Date", System.Data.SqlDbType.NVarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Date", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Kind", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Kind", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Main", System.Data.SqlDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Main", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Text", System.Data.SqlDbType.VarChar, 1000, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Text", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Writer", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Writer", System.Data.DataRowVersion.Original, null));
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Search_Click(object sender, System.EventArgs e)
{
this.DataGrid1.CurrentPageIndex=0;
myConn=ConfigurationSettings.AppSettings["mySql"];
string s;
s=this.DropDownList1.SelectedValue.ToString()+"="+"'"+this.TextBox1.Text+"'";
try
{
if(this.TextBox1.Text!="")
{
cmdText="select * from Info where ";
cmdText=cmdText+s;
this.sqlConnection1=new System.Data.SqlClient.SqlConnection(myConn);
this.sqlConnection1.Open();
this.sqlDataAdapter1=new System.Data.SqlClient.SqlDataAdapter(cmdText,this.sqlConnection1);
this.dataSet11=new DataSet1();
this.sqlDataAdapter1.Fill(this.dataSet11,"Info");
this.DataGrid1.DataSource=this.dataSet11;
this.DataGrid1.DataBind();
this.sqlConnection1.Close();
}
else
{
Response.Write("<script>alert('请输入查询条件!')</script>");
Data_Bind();
}
}
catch(Exception ex)
{
Response.Write("<script>alert('"+ex.Message+"查询条件格式错误!')</script>");
Data_Bind();
}
}
private void DelAll_Click(object sender, System.EventArgs e)
{
string s;
this.myConn=ConfigurationSettings.AppSettings["mySql"];
this.conn=new System.Data.SqlClient.SqlConnection(myConn);
cmdText="delete from Info where ";
s=this.DropDownList1.SelectedValue.ToString()+"="+"'"+this.TextBox1.Text+"'";
try
{
if(this.TextBox1.Text!="")
{
cmdText=cmdText+s;
conn.Open();
cmd=new System.Data.SqlClient.SqlCommand(cmdText,conn);
cmd.ExecuteNonQuery();
Response.Write("<script>alert('删除成功!')</script>");
Data_Bind();
}
else
{
Response.Write("<script>alert('请输入查询条件查询后删除!')</script>");
Data_Bind();
}
}
catch(Exception ex)
{
Response.Write("<script>alert('"+ex.Message+"查询条件格式错误!')</script>");
Data_Bind();
}
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
if(this.TextBox1.Text!="")
Grid_Bind();
else if(this.TextBox1.Text=="")
Data_Bind();
}
private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
try
{
if(DataGrid1.Items.Count==0)
{
if(DataGrid1.CurrentPageIndex!=0)
{
DataGrid1.CurrentPageIndex=DataGrid1.CurrentPageIndex-1;
}
}
else
{
string SqlStr="delete Info where Info_ID='"+e.Item.Cells[0].Text+"'";
myConn=System.Configuration.ConfigurationSettings.AppSettings["mySql"];
conn=new System.Data.SqlClient.SqlConnection(myConn);
conn.Open();
cmd=new System.Data.SqlClient.SqlCommand(SqlStr,conn);
cmd.ExecuteNonQuery();;
conn.Close();
Response.Write("<script>alert('删除成功!')</script>");
if(this.TextBox1.Text!="")
Grid_Bind();
else if(this.TextBox1.Text=="")
Data_Bind();
}
}
catch(Exception ex)
{
Response.Write(ex.Message);
Data_Bind();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -