登录页面(如何使用其他方法) [英] Login page(How to do in different method)

查看:74
本文介绍了登录页面(如何使用其他方法)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="Login" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Inventory Management System</title>
    <link type="text/css" rel="Stylesheet" href="css/MasterStyle.css" />
    <style type="text/css">
        .col1
        {
            width: 91px;
            padding:5px;
        }
        .col2
        {
            width: 180px;
            padding:5px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <center>
    <fieldset style="width:420px; margin-top:10%;">
    <legend align="left" class="ui-corner-all"><h2>Login Information</h2></legend>
    <table align="center" style="margin:55px 0 55px 0;">
        <tr>
            <td class="col1"><asp:Label CssClass="fright bold" ID="lbluname" Text="User Name :" runat="server"></asp:Label>
               </td>
            <td class="col2"><asp:TextBox CssClass="inputtxt" ID="txtuname" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td class="col1"><asp:Label CssClass="fright bold" ID="lblpwd" Text="Password :" runat="server"></asp:Label>
                </td>
            <td class="col2"><asp:TextBox CssClass="inputtxt" ID="txtpwd" runat="server" TextMode="Password"></asp:TextBox></td>
        </tr>
        <tr>
            <td class="col1">&nbsp;</td>
            <td class="col2"><asp:ImageButton CssClass="fleft"  ID="imglogin" runat="server"

                    ImageUrl="~/images/login.jpg" ToolTip="Login" Width="80px" Height="30px"

                    onclick="imglogin_Click" />
                <asp:ImageButton ID="imgcancel" runat="server" CssClass="fright"

                    ImageUrl="~/images/cancel.bmp" ToolTip="Cancel" Width="80px" Height="30px"

                    onclick="imgcancel_Click" /></td>
            <td><asp:Label id="lbldisplay" runat="server"></asp:Label></td>
        </tr>
        <tr>
             <td class="style1"></td>
            <td class="col2"><asp:LinkButton CssClass="fright" ID="lnkbtnforgotpwd" Text="Forgot Password" runat="server" onclick="lnkbtnforgotpwd_Click"></asp:LinkButton>
            <%--<asp:LinkButton ID="lnkbtnchangepwd" Text="Change Password" runat="server"
                    onclick="lnkbtnchangepwd_Click" ></asp:LinkButton>--%></td>
        </tr>
    </table>
    </fieldset>
    </center>
    </div>
     <div id="footer">
        <p class="copyright">Copyright &copy; <strong>Prayog Labs Pvt. Ltd.</strong> 2011. All Rights Reserved.</p>
     </div>
    </form>
</body>
</html>


  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Data;
  using System.Data.SqlClient;
  using System.Configuration;

/**
 * Author : Anil
 * Created Date : 27-Jun-2011
 * Parameter : NO
 * Return : 
 * Description : It is used to load total default.aspx page default.aspx is for  loginpage
 * Last Modified By : Anil
 * Last Modified Date : 27-Jun-2011
 */


public partial class Login : System.Web.UI.Page
    {
  // con is used for sqlConnection it get the Connection from connectionString class
   SqlConnection con = new SqlConnection(IMS.ConnectionString.getValue());
   protected void Page_Load(object sender, EventArgs e)
    {
     
      
          
      
    }
   protected void lnkbtnforgotpwd_Click(object sender, EventArgs e)
    {
       // Redirect to changepassword
     Response.Redirect("change password.aspx?U="+ txtuname.Text);
    }
    protected void lnkbtnchangepwd_Click(object sender, EventArgs e)
    {
        //Redirect to forgot password
     Response.Redirect("forgot password.aspx?U=" + txtuname.Text);
    }
    protected void imglogin_Click(object sender, ImageClickEventArgs e)
    {
     string s = "select User_Id,User_Type_Id,User_Name from UserTable where User_UserId='" + txtuname.Text + "' and User_Password='" + txtpwd.Text + "'";
     SqlDataAdapter da = new SqlDataAdapter(s, con);
     //ds is to store data
        DataSet ds = new DataSet();
        //it store data fetched from Dataset in dataset(ds)'s table(User)
        da.Fill(ds, "User");
     if (ds.Tables["User"].Rows.Count == 0)
        {
         lbldisplay.Text = "Invalid User";
        }
        else if (ds.Tables["User"].Rows.Count == 1)
        {
            lbldisplay.Text = "successfully submitted";
        
            Session["UI"] = ds.Tables["User"].Rows[0]["User_Id"].ToString();
            Session ["UTI"] = ds.Tables["User"].Rows[0]["User_Type_Id"].ToString();
            
            
            Session ["UN"] = ds.Tables["User"].Rows[0]["User_Name"].ToString();
            if (Request.QueryString["U"] == "RE")
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "k", "parent.location.reload(true);", true);
                
            }
            else if (Session["UTI"].ToString() != "UT107")
            {
                Response.Redirect("home.aspx");
            }
            else if (Session["UTI"].ToString() == "UT107" && Request.QueryString["U"] != "RE")
            {
                 da = new SqlDataAdapter("select count(*) from Supplier where Supp_Id='" + Session["UI"].ToString() + "'", con);
                 DataSet dsSup = new DataSet();
                 da.Fill(dsSup, "Supplier");
                 if (Convert.ToInt64( dsSup.Tables["Supplier"].Rows[0][0].ToString()) == 0)
                 {
                     Response.Redirect("SupplierRegister.aspx");
                 }
                 else  {
                      SqlDataAdapter daUser = new SqlDataAdapter("select count(*) from Bom B,Quotation Q where Q.Bom_id=B.Bom_id and Q.Supplier_Id='" + Session["UI"].ToString() + "' and B.LastConformDate>getdate() and Isrespond='false'", con);
                     dsSup = new DataSet();
                    daUser.Fill(dsSup, "Quotation");
                    if (Convert.ToInt64(dsSup.Tables["QuOtation"].Rows[0][0].ToString()) > 0)
                    {
                        Response.Redirect("Bomsgrid.aspx");
                    }
                    
                 }
                      }
         
        }
     else if (ds.Tables["User"].Rows.Count > 1)
     {
         lbldisplay.Text = "contact Admin";
     }
     else
     {
         Response.Redirect("home.aspx");
         
     }
    }
    protected void imgcancel_Click(object sender, ImageClickEventArgs e)
    {
        txtuname.Text = txtpwd.Text = "";
    }
}

推荐答案

这是另一种方法.
以同样的方式,您可以在asp.net中进行此操作.

It is an another method.
In same way you can do this in asp.net.

<pre lang="c#">string cmd="select *from Admin where ID=''"+txtFilenO.Text+"'' and Password=''"+textBox1.Text+"'' ";<br />
            SqlCommand cmd1 = new SqlCommand(cmd,Db.GetConnection());<br />
            SqlDataReader dr = cmd1.ExecuteReader();<br />
            if (dr.Read())<br />
            {<br />
                AdminMenu n = new AdminMenu();<br />
                n.lblsser.Text = dr[0].ToString();<br />
                n.Show();<br />
                this.Dispose();<br />
                this.Close();<br />
                cmd1.Connection.Close();<br />
               <br />
            }<br />
            else<br />
            {<br />
                cmd1.Connection.Close();<br />
                MessageBox.Show("ID/Password is not valid");<br />
            }<br />
<br />
</pre><br />


这篇关于登录页面(如何使用其他方法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆