コード例 #1
0
    protected void changepass_Click(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataView dv    = SqlDataSourceAdmin.Select(DataSourceSelectArguments.Empty) as DataView;
            bool     Exist = false;

            if (dv != null)
            {
                for (int i = 0; i < dv.Table.Rows.Count; i++)
                {
                    if (username.Text == dv.Table.Rows[i]["Username"].ToString() && oldpass.Text == dv.Table.Rows[i]["Password"].ToString())
                    {
                        Exist = true;
                        break;
                    }
                }
            }

            if (Exist)
            {
                SqlDataSourceAdmin.Update();
                msg.Text     = "password changed successfully";
                msg.CssClass = "text success";
            }
            else
            {
                msg.Text     = "enter valid Username or Password";
                msg.CssClass = "text-danger";
            }
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "$('#myModal').modal('hide');$('body').removeClass('modal-open');$('.modal-backdrop').remove();$('#myModal').modal('show');", true);
        }
    }
コード例 #2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        DataView dv = SqlDataSourceAdmin.Select(DataSourceSelectArguments.Empty) as DataView;

        if (dv != null)
        {
            for (int i = 0; i < dv.Table.Rows.Count; i++)
            {
                if (password.Text == dv.Table.Rows[i]["Password"].ToString())
                {
                    SqlDataSourceAdmin.Update();
                    msg.Text = "done";
                    Response.Redirect("ViewAdmin.aspx");
                }
                else
                {
                    msg.Text     = "incorrect password";
                    msg.CssClass = "text-danger";
                }
            }
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "$('#myModal').modal('hide');$('body').removeClass('modal-open');$('.modal-backdrop').remove();$('#myModal').modal('show');", true);
        }
        //SqlDataSourceAdmin.Update();
        //Response.Redirect("ViewAdmin.aspx");
    }