?? admin_add.cs
字號:
?using System;
using System.Data;
using System.Configuration;
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;
/// <summary>
/// Admin_Add 的摘要說明
/// </summary>
public class Admin_Add
{
public Admin_Add()
{
//
// TODO: 在此處添加構(gòu)造函數(shù)邏輯
//
}
public static SqlConnection createConn()
{
return new SqlConnection("server=(local);database=Bus;Integrated Security=true");
}
public static bool findBus(string zdz)
{
SqlConnection conn = Admin_Add.createConn();
conn.Open();
SqlCommand cmd = new SqlCommand("select count(*) from StationMessage where 終點站='" + zdz + "'", conn);
int count = Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
return true;
else
return false;
conn.Close();
}
public static bool insertBus(StationMessage S)
{
try
{
SqlConnection conn = Admin_Add.createConn();
conn.Open();
SqlCommand cmd = new SqlCommand("insert into StationMessage values('" + S.zdz + "','" + S.fbsj + "','" + S.tjzd + "','" + S.zxdh + "','" + S.cx + "',cast('" + S.pj + "' as money),'" + S.lc + "','" + S.cygs + "','" + S.bz + "')", conn);
cmd.ExecuteNonQuery();
conn.Close();
return true;
}
catch (Exception e)
{
return false;
}
}
//將從數(shù)據(jù)庫里檢索出來的表返回
public static DataTable selectAll()
{
SqlConnection conn = Admin_Add.createConn();
SqlCommand cmd = new SqlCommand("select * from StationMessage", conn);
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
DataSet ds = new DataSet();
sda.Fill(ds, "StationMessage");
return ds.Tables["StationMessage"];
}
public static bool updateBus(string S)
{
try
{
SqlConnection conn = Admin_Add.createConn();
conn.Open();
//SqlCommand cmd = new SqlCommand("update StationMessage set 終點站='" + S.zdz + "',發(fā)班時間='" + S.fbsj + "',途徑站點='" + S.tjzd + "',咨詢電話='" + S.zxdh + "',車型='" + S.cx + "',票價='" + S.pj + "',里程='" + S.lc + "',承運公司='" + S.cygs + "',備注='" + S.bz + "' where 終點站='" + S.zdz + "'", conn);
SqlCommand cmd = new SqlCommand("update StationMessage set 終點站='" + S + "',發(fā)班時間='" + S + "',途徑站點='" + S + "',咨詢電話='" + S + "',車型='" + S + "',票價='" + S + "',里程='" + S + "',承運公司='" + S + "',備注='" + S + "' where 終點站='" + S + "'", conn);
cmd.ExecuteNonQuery();
conn.Close();
return true;
}
catch (Exception e)
{
return false;
}
}
public static bool deleteBus(string S)
{
try
{
SqlConnection conn = Admin_Add.createConn();
conn.Open();
SqlCommand cmd = new SqlCommand("delete from StationMessage where 終點站='" + S + "'", conn);
cmd.ExecuteNonQuery();
conn.Close();
return true;
}
catch (Exception e)
{
return false;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -