<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Edit.aspx.cs" MasterPageFile="Admin.Master" Inherits="Aspx1.Admin.Edit" ValidateRequest="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="tableBorder" border="0" cellpadding="0" cellspacing="1">
  <tr>
            <th colspan="5" class="ym12_bti">
                添加源码数据</th>
        </tr>
        <tr>
            <td width="100" class="td2">
                商品名称：</td>
            <td colspan="3" class="td1" style="padding-left: 10px">
                <asp:TextBox ID="txtTitle" runat="server" CssClass="ym12_input"></asp:TextBox>
                *
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txttitle"
                    ErrorMessage="商品名称怎么可能为空！"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="td2">
                所属类别：</td>
      <td colspan="3" class="td1" style="padding-left: 10px">
                <asp:DropDownList ID="ddlCategory" runat="server" DataSourceID="ObjectDataSource1"
                    DataTextField="CategoryName" DataValueField="CategoryID">
                </asp:DropDownList>
                *
            </td>
        </tr>
        <tr>
            <td class="td2">
                商品属性：</td>
      <td colspan="3" class="td1" style="padding-left: 10px">
                <asp:RadioButtonList ID="rblIsAsk" runat="server" RepeatDirection="Horizontal">
                    <asp:ListItem Value="0" Text=" 出售 " Selected="True"></asp:ListItem>
                    <asp:ListItem Value="1" Text=" 求购 "></asp:ListItem>
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr>
            <td class="td2">
                演示地址：</td>
      <td colspan="3" class="td1" style="padding-left: 10px">
                <asp:TextBox ID="txtURL" runat="server" Width="250px">http://</asp:TextBox>
                *
            </td>
        </tr>
        <%if (isAdd)
          { %>
        <tr>
            <td class="td2">
                系统标签：</td>
      <td colspan="3" class="td1" style="padding-left: 10px">
                <asp:Label ID="lblSysTags" runat="server" Text=" "></asp:Label>
            </td>
        </tr>
        <%} %>
        <tr>
            <td class="td2">
                标签：</td>
      <td colspan="3" class="td1" style="padding-left: 10px">
                <asp:TextBox ID="txtTags" runat="server" Width="250px"></asp:TextBox>&nbsp; (多个标签之间请用空格分隔，每个标签最长8个字符，最多4个标签)
            </td>
        </tr>
        <tr>
            <td class="td2">
                源码截图：</td>
      <td colspan="3" class="td1" style="padding-left: 10px">
                <%if (!isAdd)
                  { %>
                <asp:TextBox ID="txtImgURL" runat="server" ReadOnly="true" Width="444px"></asp:TextBox>
                <asp:TextBox ID="txtImgDesc" runat="server" ReadOnly="true" Width="444px" Style="display: none;"></asp:TextBox><br/>
        <%} %>
                注：截图只支持：jpg,gif,png,bmp四种格式）
                        <div id="myFile">
<div id="attach1"><span id="attach_s1"></span><input type="file" name="file_1" id="file_1" onchange="attach_change();" />描述:<input type="text" name="filedesc_1" id="filedesc_1" /></div>
                        </div>

                        <script type="text/javascript">
var aid = 0;
var id = 1;
function attach_change()
{
if(aid >5) {alert('最多只能上传5个附件！');return ;} 
var extensions = 'jpg,gif,png,bmp';  
var obj = $('file_'+id);
var path = obj .value;
var ext = path.lastIndexOf('.') == -1 ? '' : path.substr(path.lastIndexOf('.') + 1, path.length).toLowerCase();
var re = new RegExp("(^|\\s|,)" + ext + "($|\\s|,)", "ig");
if(path ==''){return;} 
if(extensions != '' && (re.exec(extensions) == null || ext == '')) 
{
obj.value="";
alert('对不起，不支持上传此类扩展名的附件。');
return;
}
var newNode = $("attach"+id).cloneNode(true);

obj.style.display="none";
obj = document.createElement("a");
obj.href = "javascript:attach_del(" +id+ ")";
obj.innerHTML = "[删除]";
$("attach"+id).appendChild(obj);
$("attach_s"+id).innerHTML="源码截图："+path.substr(path.lastIndexOf("\\")+1);

id++;
newNode.id = "attach" + id;
newNode.childNodes[0].id="attach_s"+id
newNode.childNodes[1].name = "file_" +id;
newNode.childNodes[1].id = "file_" +id;
newNode.lastChild.name = "filedesc_"+id;

$('myFile').appendChild(newNode);
aid++;
}
function attach_del(id){
var theNode = $('attach'+id);   
$('myFile').removeChild(theNode);
aid--;
}
                        </script>
            </td>
        </tr>
        <tr>
            <td class="td2">
                价格：</td>
      <td width="250" class="td1" style="padding-left: 10px;" colspan="3">
                <asp:TextBox ID="txtPrice" runat="server" Width="61px" onKeyUp="isNumber(this);" Text="1"></asp:TextBox>
                &nbsp;元 *
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtprice"
                    ErrorMessage="不填写价格，准备白送？"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="td2">
                联系QQ：</td>
      <td colspan="3" class="td1" style="padding-left: 10px">
                <asp:TextBox ID="txtQQ" runat="server" Width="250px" onKeyUp="isNumber(this);"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="td2">
                邮箱：</td>
      <td colspan="3" class="td1" style="padding-left: 10px">
                <asp:TextBox ID="txtMail" runat="server" Width="250px"></asp:TextBox>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="邮箱格式不正确！"
                    ControlToValidate="txtMail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td class="td2">
                联系电话：</td>
      <td colspan="3" class="td1" style="padding-left: 10px">
                <asp:TextBox ID="txtTel" runat="server" Width="250px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="td2">
                源码介绍：</td>
      <td colspan="3" class="td1" style="padding-left: 10px; height: 240px">
                <input type="hidden" name="description" id="description" value="<%=Server.HtmlEncode(model.Description)%>" />
                <iframe id="myiframe" src="../Images/Editor/editor.htm?id=description&ReadCookie=0"
                    frameborder="0" scrolling="no" width="650px" height="460px"></iframe>
            </td>
        </tr>
        <tr>
            <td class="td2">
                状态：</td>
      <td colspan="3" class="td1">
                <asp:DropDownList ID="ddlStatus" runat="server">
                    <asp:ListItem Text="已审核" Value="0"></asp:ListItem>
                    <asp:ListItem Text="文字推荐" Value="1"></asp:ListItem>
                    <asp:ListItem Text="图片推荐" Value="2"></asp:ListItem>
                    <asp:ListItem Text="未审核" Value="-1"></asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="td2">
                出售方式：</td>
      <td colspan="3" class="td1">
                <asp:RadioButtonList ID="rblSellType" runat="server" RepeatDirection="Horizontal">
                    <asp:ListItem Value="0" Text="手动发货" onclick="$('autoSell').style.display=(this.checked?'none':'')"></asp:ListItem>
                    <asp:ListItem Value="1" Text="自动发货" Selected="True" onclick="$('autoSell').style.display=(this.checked?'':'none')"></asp:ListItem>
                </asp:RadioButtonList>
                <div id="autoSell">
                    <b>上传源码:</b><br />
                    <input type="text" value="<%=model.DownURL %>" id="txtDownURL" name="txtDownURL" style="width: 250px" />
                    <br />
                    <iframe src="/Upload.aspx" marginheight="0" marginwidth="0" frameborder="0" height="50px" width="500px" scrolling="no"></iframe>
                    <br />
                    <b>是否参与积分兑换活动</b>：
                    <asp:RadioButtonList ID="rblIsFree" runat="server" RepeatDirection="Horizontal">
                        <asp:ListItem Value="0" Text="不参与"></asp:ListItem>
                        <asp:ListItem Value="1" Text="参与" Selected="True"></asp:ListItem>
                    </asp:RadioButtonList>
                </div>
            </td>
        </tr>
        <tr>
            <td class="td2">            </td>
      <td colspan="3" class="td1" style="text-align: center">
                <asp:Button ID="btnAdd" runat="server" Text="· 提交 ·" OnClick="btnAdd_Click" class="button2">
                </asp:Button>
                <input type="reset" value="· 重填 ·" class="button2" />
            </td>
        </tr>
    </table>
  <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetAllList"
        TypeName="Aspx1.BLL.ProductCategory"></asp:ObjectDataSource>
</asp:Content>
