• 大小: 854KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-10
  • 语言: 其他
  • 标签: asp.net  

资源简介

城市公交线路添加查询城市公交线路添加查询

资源截图

代码片段和文件信息

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 add : System.Web.UI.Page
{
    protected void Page_Load(object sender EventArgs e)
    {
        if (!IsPostBack)
        {
 
        }

    }
    protected void but_Click(object sender EventArgs e)
    {
        string busno = this.name.Text;
        string origin = this.beg.Text;
        string terminal = this.end.Text;
        try
        {
            SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings[“bus“]);
            conn.Open();
            SqlCommand com = new SqlCommand(“select count(*) from businfo where busno=‘“ + busno + “‘“ conn);
            int count = Convert.ToInt32(com.ExecuteScalar());
            if (count != 1)
            {
                com.CommandText = “insert into businfo(busnooriginterminal)values(@busno@origin@terminal)“;
                SqlParameter para = new SqlParameter(“@busno“ SqlDbType.VarChar 10);
                para.Value = busno;
                com.Parameters.Add(para);

                para = new SqlParameter(“@origin“ SqlDbType.VarChar 20);
                para.Value = origin;
                com.Parameters.Add(para);

                para = new SqlParameter(“@terminal“ SqlDbType.VarChar 20);
                para.Value = terminal;
                com.Parameters.Add(para);

                com.ExecuteNonQuery();
                this.mes.Text = “此路线添加成功!!“;
                this.name.Text = ““;
                this.beg.Text = ““;
                this.end.Text = ““;
            }
            else
            {
                this.mes.Text = “此路线已经存在!请重新添加!!“;
                this.name.Text = ““;
                this.beg.Text = ““;
                this.end.Text = ““;
            }
          
            conn.Close();
        
        }
        catch(Exception ex)
        {
            ex.ToString();
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     目录          0  2008-12-12 08:48  Bus\App_Data

     文件     573440  2008-12-12 10:36  Bus\db\businfoDB_log.LDF

     文件    2293760  2008-12-12 10:36  Bus\db\businfoDB.mdf

     目录          0  2008-12-12 10:36  Bus\db

     文件       2280  2008-12-12 09:48  Bus\add.aspx.cs

     文件       1870  2008-12-12 09:49  Bus\add.aspx

     文件       2433  2008-12-12 09:09  Bus\Web.config

     文件       2030  2008-12-12 09:22  Bus\index.aspx.cs

     文件       1495  2008-12-12 09:23  Bus\index.aspx

     目录          0  2008-12-12 08:48  Bus

----------- ---------  ---------- -----  ----

              2877308                    10


评论

共有 条评论