zoukankan      html  css  js  c++  java
  • 确认收到信息,asp.net c#

    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    /// <summary>
    /// 更新确认数据
    /// </summary>
    private void gxdata()
    {
    int res;
    string c1 = "确认收到";
    string dw = this.DropDownList1.SelectedValue;
    string commstr = @"update data set c1='" + c1 + "'" + @"where dw='" + dw + "'";
    //"insert into data(c1) values('" + c1 + "')"
    OleDbConnection conn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=|datadirectory|data.mdb;");
    if (conn.State == ConnectionState.Closed)
    {
    conn.Open();
    }
    OleDbCommand cmd = new OleDbCommand(commstr, conn);

    try
    {
    res = cmd.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
    throw new Exception("error", ex);
    }
    finally
    {
    if (conn.State == ConnectionState.Open)
    {
    conn.Close();
    }
    }

    if (res > 0)
    {
    Response.Write("确认收到,谢谢支持!");

    }
    else
    {
    Response.Write("确认失败");
    }
    }

    /// <summary>
    /// 显示数据库中所有内容
    /// </summary>

    private void binddata()
    {
    string commstr = @"select dw,c1 from data";
    DataTable dt = new DataTable();
    OleDbConnection conn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=|datadirectory|data.mdb;");
    if (conn.State == ConnectionState.Closed)
    {
    conn.Open();
    }
    OleDbCommand comm = new OleDbCommand(commstr, conn);
    using (OleDbDataReader sdr = comm.ExecuteReader(CommandBehavior.CloseConnection))
    {
    dt.Load(sdr);
    }

    this.GridView1.DataSource = dt;
    this.GridView1.DataBind();
    }


    /// <summary>
    /// 输出数据库
    /// </summary>
    /// <param name="dw"></param>
    /// <param name="pass"></param>
    /// <returns></returns>
    private static DataTable outdata(string dw, string pass)
    {
    string commstr = @"select * from pass where dw='" + dw + "'" + @"and pass='" + pass + "'";
    DataTable dt = new DataTable();
    OleDbConnection conn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=|datadirectory|data.mdb;");
    if (conn.State == ConnectionState.Closed)
    {
    conn.Open();
    }
    OleDbCommand comm = new OleDbCommand(commstr, conn);
    using (OleDbDataReader sdr = comm.ExecuteReader(CommandBehavior.CloseConnection))
    {
    dt.Load(sdr);
    }
    return dt;
    }

    /// <summary>
    /// 调用数据输出,调用更新数据库
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button2_Click(object sender, EventArgs e)
    {
    if (this.DropDownList1.SelectedIndex > 0)
    {
    string dw = this.DropDownList1.SelectedValue;
    string pass = this.TextBox1.Text.ToString();
    DataTable dt = outdata(dw, pass);
    if (dt.Rows.Count > 0)
    {
    Response.Write("确认码正确!");
    gxdata();
    }
    else
    {
    Response.Write("确认码不正确");
    }
    }
    else
    {
    Response.Write("请选择单位!");
    return;
    }

    }

    /// <summary>
    /// 查看数据
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
    binddata();
    }
    }

    天道酬勤,厚积薄发。 君子之行,静以修身,俭以养德。 非淡泊无以明志,非宁静无以致远。 如有恒,何须三更起,半夜眠;最怕莫,三天打鱼两天晒网,竹篮打水一场空。
  • 相关阅读:
    Python with语句和过程抽取思想
    HTML DOM 学习
    暴力破解( Hydra | Medusa)
    CSRF漏洞原理浅谈
    文件包含漏洞原理浅探
    JavaScript BOM学习
    PHP命令执行漏洞初探
    一段思考
    文件上传解析漏洞
    谈谈Javascript的this关键字(this is not this)
  • 原文地址:https://www.cnblogs.com/houweidong/p/12285847.html
Copyright © 2011-2022 走看看