<%@ Page Language="C#" %>

<%
    string _Title = (Chukeh.Current.Querys.ContainsKey("Id", true) == String.Empty ? "添加新记录" : "修改记录信息");
    string _Command = (Chukeh.Current.Querys.ContainsKey("Id", true) == String.Empty ? "Add" : "Edit");
    this.Title = _Title;
    Chukeh.Data.IHash _Detail = new Chukeh.Data.IHash();
    Chukeh.Data.IResult _RecordExists = new Chukeh.Data.IResult(0, "");
    if (Chukeh.Current.Querys.ContainsKey("Id", true) != String.Empty)
    {
        Chukeh.Data.OleProvider _Provider = new Chukeh.Data.OleProvider("Data Source=~App_Data\\Data.mdb;Provider=Microsoft.Jet.OLEDB.4.0");
        _RecordExists = _Provider.RunExists("DB_TABLE", Chukeh.Current.Querys);
        _Detail = _Provider.RunRecord("DB_TABLE", Chukeh.Current.Querys);
        _Provider.Dispose();
    }
%>

<!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>
    <link href="Style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <h3><a href="index.htm">Chukeh.Data 小诸葛</a> - Access 数据库操作示例</h3>
    <div>
        <fieldset>
            <legend><% Chukeh.Current.Put(_Title); %></legend>
            <form id="Form1" method="post" action="Handler.ashx">
                <input type="hidden" id="Command" name="Command" value="<% Chukeh.Current.Put(_Command); %>" />
                <input type="hidden" id="Id" name="Id" value="<% Chukeh.Current.PutQuerys("Id"); %>" />
                <table border="0" cellspacing="2" cellpadding="3">
                    <tr>
                        <th>查询：</th>
                        <td><% Chukeh.Current.Put(_RecordExists.Message); %></td>
                    </tr>
                    <tr>
                        <th>名称：</th>
                        <td><input type="text" id="Name" name="Name" size="28" title="名称" class="text" value="<% Chukeh.Current.PutHash(_Detail, "Name"); %>" /></td>
                    </tr>
                    <tr>
                        <th>备注：</th>
                        <td>
                            <textarea id="Remark" name="Remark" cols="36" rows="5" title="备注" class="textarea"><% Chukeh.Current.PutHash(_Detail, "Remark"); %></textarea>
                        </td>
                    </tr>
                    <tr>
                        <th>价格：</th>
                        <td><input type="text" id="Price" name="Price" size="28" title="价格" class="text" value="<% Chukeh.Current.PutHash(_Detail, "Price"); %>" /></td>
                    </tr>
                    <tr>
                        <th>状态：</th>
                        <td><input type="radio" id="State1" name="State" value="true" <% Chukeh.Current.Put(_Detail.GetBool("State")?"Checked":""); %> /><label for="State1">正常</label>
                            <input type="radio" id="State2" name="State" value="false" <% Chukeh.Current.Put(_Detail.GetBool("State")?"":"Checked"); %> /><label for="State2">停用</label></td>
                    </tr>
                    <tr>
                        <th>日期：</th>
                        <td><input type="text" id="Date" name="Date" size="28" title="日期" class="text" value="<% Chukeh.Current.PutHash(_Detail, "Date"); %>" /></td>
                    </tr>
                    <tr>
                        <th></th>
                        <td>
                            <input type="submit" id="Entry" name="Entry" value="确 定" class="submit" />
                            <input type="button" id="Cancel" name="Cancel" value="取 消" class="button" onclick="javascript:window.location='List.aspx';" />
                        </td>
                        <td></td>
                    </tr>
                </table>
            </form>
        </fieldset>
    </div>
</body>
</html>