asp.net综合类B2B市场的设计与实现 第7页

综合类B2B市场的设计与实现部分源代码
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>无标题页</title>
    <style type="text/css">
.biankuang{
border-top:3px solid #c0c0c0;
border-bottom:3px solid #c0c0c0;
border-left:3px solid #c0c0c0;
border-right:3px solid #c0c0c0;
}
#thisform {
  font-family: Georgia, serif;
  font-size: 14px;
  color: #111111;
  } 
#thisform label {
  font-family: Verdana, sans-serif;
  font-weight: bold;
  color: #111111;
  }
    </style>  
</head>
<body>
    <form id="thisform" runat="server">
   <div>
   <center>
       <asp:Panel ID="Panel1" runat="server" Height="500px" Width="800px">
        <asp:Table ID="Table1" runat="server">
        <asp:TableRow>
        <asp:TableCell>
        <asp:Panel ID="Panel2" runat="server" Height="150px"></asp:Panel>
        </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
        <asp:TableCell>
        <asp:Label ID="Label1" runat="server"
          Text="注意:1.如果已经注册,只需填入账户和密码,点击登录即可。2.如果尚未注册,阅读免责声明后注册,注册时请填入正确信息!"
          CssClass="biankuang" Height="230px" Width="200px"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <asp:Panel ID="Panel3" runat="server" Height="200px" Width="20px">
            </asp:Panel>
        </asp:TableCell>
        <asp:TableCell>
        <asp:Table ID="Table2" runat="server" BackColor="Silver" CellSpacing="10" CellPadding="2"
         Height="230px">     
        <asp:TableRow>
        <asp:TableCell>企业名称</asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="username" runat="server" Width="150" Text=""></asp:TextBox></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
        <asp:TableCell>登录密码</asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="password1" runat="server" TextMode="Password" Width="150" Text=""></asp:TextBox></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
        <asp:TableCell>验证密码</asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="password2" runat="server" TextMode="Password" Width="150" Text=""></asp:TextBox></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
        <asp:TableCell>企业邮箱</asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="TextBox4" runat="server" Width="150" Text=""></asp:TextBox></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
        <asp:TableCell>未知</asp:TableCell>
        <asp:TableCell>
            <asp:TextBox ID="TextBox5" runat="server" Width="150"></asp:TextBox></asp:TableCell>
        </asp:TableRow>
        <asp:TableRow>
        <asp:TableCell>
            <asp:Button ID="btnLogin" runat="server" Text="登录/注册" OnClick="btnLogin_Click" /></asp:TableCell>
            <asp:TableCell><asp:HyperLink ID="hyperlink1" runat="server" NavigateUrl="~/Explain.htm">确认您已阅读免责声明</asp:HyperLink>
            </asp:TableCell>
        </asp:TableRow>
        </asp:Table>
        </asp:TableCell>
        </asp:TableRow>
        </asp:Table>
       </asp:Panel>
    </center>
    </div>
    </form>
</body>
</html>
using System;
using System.Text;
using System.Data;
using System.Configuration;
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 _Default : System.Web.UI.Page
{
    protected System.Data.SqlClient.SqlDataReader Dr1;
    protected System.Data.SqlClient.SqlDataReader Dr2;
    protected void Page_Load(object sender, EventArgs e)
    {      
        if (Page.IsPostBack)
        {
            DataBind();
        }
    }
    public void btnLogin_Click(object sender, EventArgs e)
    {
        SqlConnection myConn;
        string myConnString = "server=.\\SQLEXPRESS;database=151;user id=sa;password=tmdjsj";
        myConn = new SqlConnection(myConnString);
        myConn.Open();
        if (username.Text != "")
        {
            SqlCommand cmd=new SqlCommand("select comName from companylist where 
www.751com.cn
                    SqlConnection myConn1;
                    myConn1 = new SqlConnection(myConnString);
                    myConn1.Open();
                    SqlCommand cmd1 = new SqlCommand("select comPassword from companylist where comName='" + username.Text + "' and comPassword='"+password1.Text+"'", myConn1);
                    Dr2 = cmd1.ExecuteReader();                  
                    if (Dr2.Read())
                    {
                        string comPassword = Dr2["comPassword"].ToString();
                        Session["comName"] = comName;
                        Dr2.Close();
                        Response.Redirect("Default2.aspx");          //登录
                    }
                    else
                    {
                        Label1.Text = "该账号已经注册,但是密码错误";
                    }
                    Dr2.Close();
                    myConn1.Close();
                }
                else
                {
                    Label1.Text = "登录密码不能为空";
                }             
            }
            else                          //注册
            {               
                if (password2.Text != ""&&password1.Text!="")
                {
                        if (password1.Text == password2.Text)
                        {
                            if (TextBox4.Text != "")
                            {
                                SqlConnection myConn2 = new SqlConnection(myConnString);
                                myConn2.Open();
                                SqlCommand mycmd = new SqlCommand();
                                mycmd.Connection = myConn2;
                                mycmd.CommandType = CommandType.StoredProcedure;
                                mycmd.CommandText = "InsertComUSER";
                                mycmd.Parameters.Add("@comName", SqlDbType.NVarChar).Value = username.Text;
                                mycmd.Parameters.Add("@comPassword", SqlDbType.NVarChar).Value = password1.Text;

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... 下一页  >> 

Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有