<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="Aspx1.Install" %>

<%@ Page Inherits="Aspx1.Install.SetupPage" %>

<head>
    <style type="text/css">
        .style1
        {
            width: 25%;
        }
        .style2
        {
            width: 25%;
            height: 70px;
        }
        .style3
        {
            width: 372px;
            height: 70px;
        }
    </style>
</head>

<script runat="server">

    protected void ClearDBInfo_Click(object sender, EventArgs e)
    {
        Aspx1.Config.SiteConfigInfo sci = Aspx1.Config.SiteConfig.Instance.ConfigInfo;
        sci.SiteUrl = txtSiteUrl.Text;
        sci.SiteName = txtSiteName.Text;
        Aspx1.Config.SiteConfig.Instance.Save();

        Aspx1.BLL.Admin bll = new Aspx1.BLL.Admin();
        bll.DeleteAll();
        Aspx1.Model.Admin model = new Aspx1.Model.Admin();
        string pass = Aspx1.Common.DEncrypt.DEncrypt.Encrypt(txtPass.Text);
        model.Password = pass;
        model.UserName = txtAdmin.Text.Trim();
        bll.Add(model);

        Session["SystemAdminName"] = txtAdmin.Text.Trim();
        Session["SystemAdminPws"] = txtPass.Text;

        
        Response.Redirect("step4.aspx");
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        txtSiteUrl.Text  = "http://" + Request.ServerVariables["SERVER_NAME"].ToString() + ":" + Request.ServerVariables["SERVER_PORT"].ToString();
    }
</script>

<html>
<%=header%>
<body>
    <form id="Form1" method="post" runat="server">
    <table cellspacing="1" cellpadding="0" width="700" align="center" bgcolor="#666666"
        border="0">
        <tr>
            <td bgcolor="#ffffff">
                <table cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
                    <tr>
                        <td bgcolor="#333" colspan="2">
                            <table cellspacing="0" cellpadding="8" width="100%" border="0">
                                <tr>
                                    <td>
                                        <font color="#ffffff">初始化</font>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td width="180" valign="middle" align="center">
                            <%=SetupPage.logo%>
                        </td>
                        <td valign="top" width="520">
                            <br>
                            <table cellspacing="0" cellpadding="8" width="100%" border="0">
                                <tr>
                                    <td>
                                        <p>
                                        </p>
                                        <table cellspacing="0" cellpadding="8" width="100%" border="0">
                                            <tr>
                                                <td class="style1">
                                                    安装路径:
                                                </td>
                                                <td style="width: 372px">
                                                    <asp:TextBox ID="txtSiteUrl" runat="server"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtSiteUrl"
                                                        ErrorMessage="不能为空！"></asp:RequiredFieldValidator>
                                                    <br />
                                                    填写您的真实安装路径，否则某些功能不能正常！
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="style1">
                                                    网站的名称:
                                                </td>
                                                <td style="width: 372px">
                                                    <asp:TextBox ID="txtSiteName" runat="server" Text="12ym源码交易系统"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtSiteName"
                                                        ErrorMessage="不能为空！"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="style1">
                                                    管理员名称:
                                                </td>
                                                <td style="width: 372px">
                                                    <asp:TextBox ID="txtAdmin" runat="server"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtAdmin"
                                                        ErrorMessage="不能为空！"></asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="style2">
                                                    管理员密码:<br />
                                                    (不得少于6位)
                                                </td>
                                                <td class="style3">
                                                    <asp:TextBox ID="txtPass" runat="server" TextMode="Password"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtPass"
                                                        ErrorMessage="不能为空！"></asp:RequiredFieldValidator>
                                                    <br />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="style1">
                                                    确认密码:
                                                </td>
                                                <td style="width: 372px">
                                                    <asp:TextBox ID="txtPass2" runat="server" TextMode="Password"></asp:TextBox>
                                                    <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtPass"
                                                        ControlToValidate="txtPass2" ErrorMessage="两次输入的密码不一致！"></asp:CompareValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="style1">
                                                    &nbsp;
                                                </td>
                                                <td style="width: 372px">
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            <table cellspacing="0" cellpadding="8" width="60%" border="0">
                                <tr>
                                    <td align="right">
                                        <asp:Button ID="ClearDBInfo" runat="server" Text="开始安装" OnClick="ClearDBInfo_Click">
                                        </asp:Button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <%=Footer%>
    </form>
</body>
</html>
