Click here to Skip to main content
15,921,295 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<%@ 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>

C#
  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 = "";
    }
}
Posted
Updated 23-Jul-11 2:31am
v2
Comments
Rakesh From Patna 23-Jul-11 8:54am    
whats your problem.

1 solution

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

C#
string cmd="select *from Admin where ID='"+txtFilenO.Text+"' and Password='"+textBox1.Text+"' ";
            SqlCommand cmd1 = new SqlCommand(cmd,Db.GetConnection());
            SqlDataReader dr = cmd1.ExecuteReader();
            if (dr.Read())
            {
                AdminMenu n = new AdminMenu();
                n.lblsser.Text = dr[0].ToString();
                n.Show();
                this.Dispose();
                this.Close();
                cmd1.Connection.Close();
               
            }
            else
            {
                cmd1.Connection.Close();
                MessageBox.Show("ID/Password is not valid");
            }
 
Share this answer
 
Comments
[no name] 26-Jul-11 6:21am    
Suggestion : dont use query like this "select *from Admin where ID='"+txtFilenO.Text+"' and Password='"+textBox1.Text+"" .Some One might hack this application.
kishore1215 26-Jul-11 7:00am    
wats ur problem,improve ur question..its very painfull

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900