<%@ page language="C#" masterpagefile="AdminIndexMaster.master" autoeventwireup="true" inherits="HL_Admin_Admin_ShopIndexArticleAdd, HoWaveVGO" title="首页添加文章" validaterequest="false" enableviewstate="false" enableEventValidation="false" %>
<%@ Register TagPrefix="fckeditorv2" Namespace="FredCK.FCKeditorV2" Assembly="FredCK.FCKeditorV2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/javascript">
   function  selectArtitleType()
   {    
      var SelectObj=document.getElementById("ctl00_ContentPlaceHolder1_IndexArticle_ArticleType");
      var UploadPicObj=document.getElementById("UploadPic");      
      if(SelectObj.value=="Text")
      {
         UploadPicObj.style.display="none";
      }
      else
      {
          UploadPicObj.style.display="";
      }
   }
   
   function selectLinkType()
   {
      
      var SelectLinkTypeObj1=document.getElementById("ctl00_ContentPlaceHolder1_IndexArticle_LinkType_0");
      var SelectLinkTypeObj2=document.getElementById("ctl00_ContentPlaceHolder1_IndexArticle_LinkType_1");
      var LinkType_1Obj=document.getElementById("LinkType_1");
      var LinkType_2Obj=document.getElementById("LinkType_2");
      if(SelectLinkTypeObj1.checked)
      {
         LinkType_1Obj.style.display="none";
         LinkType_2Obj.style.display="";
      }
      else
      {
         LinkType_1Obj.style.display="";
         LinkType_2Obj.style.display="none";
      }
   }
    function addheight(action){
        var change=30;
        var obj=document.getElementById("ctl00_ContentPlaceHolder1_IndexArticle_Content___Frame");       
        var newheight;
        if(action=="add"){
          newheight = parseInt(obj.style.height, 10) + change;
        }
        else if(action=="sub") {	//大于最小高度100时才执行
          newheight = parseInt(obj.style.height, 10);
          if(newheight>70){
           newheight=newheight-change;
          }		  
		}
        obj.style.height = newheight + 'px';
   } 
   

function OpenFileList(boj){
    
    window.open("Admin_PageFileList.aspx?obj=ctl00_ContentPlaceHolder1_IndexArticle_"+boj,"","width=500px; height=350px; help=no; scroll=no; status=no; edge=sunken;");
}
   </script>
<table class="adminheading">
   <tr>
      <th valign="middle" class="menus" align="left">文章管理</th>
      <td align="right">
        <div style="width:50px"><asp:HyperLink ID="ReturnBack" runat="server" Text="返回"  NavigateUrl="Admin_ShopIndexArticle.aspx"/>
        </div>
      </td>
      
   </tr>
</table>

   <asp:FormView ID="IndexArticle" runat="server"  DefaultMode="Insert" Width="100%" DataSourceID="ObjectDataSource1" style="background-color:#FFFFFF;" 
      OnItemUpdating="IndexArticle_Updating"  OnItemInserting="IndexArticle_Insertting" OnItemInserted="IndexArticle_Updated" 
      OnItemUpdated="IndexArticle_Updated" OnItemCreated="IndexArticel_ItemCreated">
     <InsertItemTemplate>
        <table class="nick">
           <tr><td colspan="2" class="tit">新建文章</td></tr>
           <tr>
              <td class="ltd"><div style="width:90px;">所属模块</div></td>
              <td class="rtd">
                 <asp:DropDownList ID="Channel" runat="server" SelectedValue='<%# Bind("ChannelID") %>' AppendDataBoundItems="True" DataSourceID="Obchannel2" DataTextField="Name" DataValueField="id"  　/>
                
              </td>
           </tr>
            <tr>
              <td class="ltd">文章标题</td>
              <td class="rtd">
                 <span style="background-color:#e0eef5">短 标 题:</span>
                 <asp:TextBox ID="ShortTitle1" runat="server" Width="140px"  Text='<%# Bind("ShortTitle") %>'  MaxLength="13" /><br />               
                 <span style="background-color:#e0eef5">长 标 题:</span>
                 <asp:TextBox ID="LongTitle1" runat="server" Width="250px" Text='<%# Bind("LognTitle") %>' MaxLength="25"/><br /></td>
           </tr>
           
           <tr  style="display:none;">
              <td class="ltd">标题类型</td>
              <td class="rtd">
                 <asp:DropDownList ID="TitleType" runat="server"  SelectedValue='<%# Bind("TitleType") %>'>
                    <asp:ListItem Text="顶部标题" Value="1" />
                    <asp:ListItem Text="列表标题" Value="2" />
                 </asp:DropDownList>
              </td>
           </tr>
            <tr>
              <td class="ltd">文章类型</td>
              <td class="rtd">
                 <asp:DropDownList ID="ArticleType" runat="server" SelectedValue='<%# Bind("ArticleType") %>' >
                    <asp:ListItem  Text="图片" Value="IMG" />
                    <asp:ListItem  Text="文字" Value="Text" /> 
                    <asp:ListItem  Text="图文" Value="IMGText" />                       
                 </asp:DropDownList>
              </td>
           </tr>
           <tr id="UploadPic">
              <td class="ltd">上传图片</td>
              <td class="rtd">
                 <div style="float:left">
                 <asp:FileUpload ID="FileUpload" runat="server" />
                 </div>
                 <div id="previewImage" style="float:left; margin-left:15px; border:solid 1px white; height:120px; width:120px; text-align:center;">
                   缩微图
                  
                 </div>
              </td>
           </tr>
           <tr>
              <td class="ltd">是否高亮显示</td>
              <td class="rtd">
                 <asp:RadioButtonList ID="IsHighDisplay" runat="server"  SelectedValue='<%# Bind("IsHighDisplay") %>' RepeatLayout="Flow" RepeatDirection="Horizontal">
                    <asp:ListItem Text="否" Value="0" Selected="True" />
                    <asp:ListItem Text="是" Value="1" />
                 </asp:RadioButtonList>
              </td>
           </tr>
           <tr>
              <td class="ltd">所属商品分类</td>
              <td class="rtd">
                 <asp:DropDownList ID="ClassID" runat="server" SelectedValue='<%# Bind("ClassID") %>' AppendDataBoundItems="True" DataSourceID="obclass2" DataTextField="ClassName" DataValueField="ClassID" >
                    <asp:ListItem Text="不属于任何分类" Value="-1" />
                 </asp:DropDownList>
                 
              </td>
           </tr>    
           <tr>
              <td class="ltd">是否转向链接</td>
              <td class="rtd">
                 <asp:RadioButtonList ID="LinkType" runat="server"  SelectedValue='<%# Bind("LinkType") %>' RepeatLayout="Flow" RepeatDirection="Horizontal">
                    <asp:ListItem Text="否" Value="0"  Selected="True"/>
                    <asp:ListItem Text="是" Value="1" />
                 </asp:RadioButtonList>
              </td>
           </tr>
          <tr id="LinkType_1" style=" display:none;">
              <td class="ltd">转向链接URL</td>
              <td class="rtd"><asp:TextBox ID="LinkUrl" runat="server" Width="300px" Text='<%# Bind("LinkUrl") %>'/>
                  <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="LinkUrl"
                      ErrorMessage="地址不能为空"></asp:RequiredFieldValidator></td>
           </tr>
           <tr id="LinkType_2">
              <td class="ltd">文章内容</td>
              <td class="rtd">
                 <fckeditorv2:FCKeditor ID="Content" runat="server" Value='<%# Bind("ArticleContent") %>'  AutoDetectLanguage="true" BasePath="../FCKEditor/" ></fckeditorv2:FCKeditor>                           
              
              </td>
           </tr>      
           
            <tr>
              <td class="ltd">文章状态</td>
              <td class="rtd">
                 <asp:RadioButtonList ID="Status" runat="server" RepeatDirection="Horizontal" SelectedValue='<%# Bind("Status") %>'>
                    <asp:ListItem Text="草稿" Value="1" />
                    <asp:ListItem Text="待审核" Value="-1" />
                    <asp:ListItem Text="通过" Value="3"  Selected="True"/>
                 </asp:RadioButtonList></td>
           </tr>   
              <tr>
              <td class="ltd">所属专题</td>
              <td class="rtd">
                <asp:DropDownList ID="SpecialID" runat="server" SelectedValue='<%# Bind("SpecialID") %>' AppendDataBoundItems="True" DataSourceID="obSpecial" DataTextField="SpecialName" DataValueField="SpecialID">
                   <asp:ListItem Text="首页" Value="-1" />
                </asp:DropDownList>
                <asp:ObjectDataSource ID="obSpecial" runat="server" SelectMethod="GetSpecialByChannel"
                    TypeName="SpecialBll" OldValuesParameterFormatString="original_{0}" >
                    <SelectParameters>
                        <asp:Parameter DefaultValue="-1" Name="ChannelID" Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>
              </td>
           </tr>       
            <tr>
              <td class="ltd">文章属性</td>
              <td class="rtd">
                 <asp:DropDownList ID="IsTop" SelectedValue='<%# Bind("OnTop") %>' runat="server">                  
                    <asp:ListItem Text="置顶" Value="1" />
                    <asp:ListItem Text="取消置顶" Value="0" />
                 </asp:DropDownList>
                  <asp:DropDownList ID="IsElite" SelectedValue='<%# Bind("Elite") %>' runat="server">                  
                    <asp:ListItem Text="推荐" Value="1" />
                    <asp:ListItem Text="取消推荐" Value="0" />
                 </asp:DropDownList>
              </td>
           </tr>
            <tr>
              <td class="ltd">录入者</td>
              <td class="rtd"><asp:TextBox ID="Editor" runat="server" Text='<%# Bind("Editor") %>'/></td>
           </tr>
            <tr>
              <td class="ltd">起始点击数</td>
              <td class="rtd"><asp:TextBox ID="Hits" runat="server" Text='<%# Bind("Hits") %>'/></td>
           </tr>
           <tr>
              <td class="ltd">录入时间</td>
              <td class="rtd"><asp:TextBox ID="InputTime" runat="server" Text='<%# Bind("InputTime") %>'/></td>
           </tr>
           <tr>
              <td class="ltd">文章有效期</td>
              <td class="rtd"><asp:TextBox ID="Validay" runat="server" Text='<%# Bind("Validay") %>'/>天</td>
           </tr>
           <tr>
              <td class="ltd">文章模板</td>
              <td class="rtd"><asp:TextBox ID="TemplatePath" runat="server" Width="200" Text='<%# Bind("TemplatePath") %>'/>
              <input value="浏览" type="button" name="ll" onclick="return OpenFileList('TemplatePath')" />
              （留空则显示默认）
              </td>
           </tr>
          </table>
          <div class="div_btm"><asp:Button ID="Add" CommandName="Insert" Text="添加"  runat="server"/>
          </div>        
     
     </InsertItemTemplate>
     <EditItemTemplate>
        <table class="nick">
           <tr><td colspan="2" class="tit">设置文章</td></tr>
            <tr>
              <td class="ltd">文章编号</td>
              <td class="rtd">
                <asp:Literal ID="ArticleID" runat="server" Text='<%# Bind("ArticleID") %>' />
              </td>
            </tr>
           <tr>
              <td class="ltd">所属栏目</td>
              <td class="rtd">
                <asp:DropDownList ID="Channel" runat="server" SelectedValue='<%# Bind("ChannelID") %>' AppendDataBoundItems="True" DataSourceID="Obchannel2" DataTextField="Name" DataValueField="id" 　/>
                  
                
                 
              </td>
           </tr>
            <tr>
              <td class="ltd">文章标题</td>
              <td class="rtd">
                短标题 <asp:TextBox ID="ShortTitle" runat="server" Width="140px"  Text='<%# Bind("ShortTitle") %>'/><br />             
                长标题<asp:TextBox ID="LongTitle" runat="server" Width="250px" Text='<%# Bind("LognTitle") %>'/><br /></td>
           </tr>
           
           <tr>
              <td class="ltd">标题类型</td>
              <td class="rtd">
                 <asp:DropDownList ID="TitleType" runat="server"  SelectedValue='<%# Bind("TitleType") %>'>
                    <asp:ListItem Text="顶部标题" Value="1" />
                    <asp:ListItem Text="列表标题" Value="2" />
                 </asp:DropDownList>
              </td>
           </tr>
            <tr>
              <td class="ltd">显示类型</td>
              <td class="rtd">
                 <asp:DropDownList ID="ArticleType" runat="server" SelectedValue='<%# Bind("ArticleType") %>' >
                    <asp:ListItem  Text="图片" Value="IMG" />
                    <asp:ListItem  Text="文字" Value="Text" />   
                    <asp:ListItem  Text="图文" Value="IMGText" />                                    
                 </asp:DropDownList>
                 
              </td>
           </tr>
           <tr id="UploadPic">
              <td class="ltd">上传图片</td>
              <td class="rtd">
                 <div style="float:left">
                 <asp:FileUpload ID="FileUpload" runat="server" />
                 </div>
                 <div id="previewImage" style="float:left; margin-left:15px; border:solid 1px white; height:120px; width:120px; text-align:center;">
                  <div>缩微图</div>
                  <asp:Image runat="server" ID="IndxeImg" Width="100px" Height="100px" ImageUrl='<%#"../Shop/"+Eval("UploadPicUrl") %>' /> 
               </div>
              </td>
           </tr>
           <tr>
              <td class="ltd">是否高亮显示</td>
              <td class="rtd">
                 <asp:RadioButtonList ID="IsHighDisplay" runat="server"  SelectedValue='<%# Bind("IsHighDisplay") %>' RepeatLayout="Flow" RepeatDirection="Horizontal">
                    <asp:ListItem Text="否" Value="0"  Selected="True"/>
                    <asp:ListItem Text="是" Value="1" />
                 </asp:RadioButtonList>
              </td>
           </tr>
           <tr>
              <td class="ltd">所属商品分类</td>
              <td class="rtd">
                 <asp:DropDownList ID="ClassID" runat="server" SelectedValue='<%# Bind("ClassID") %>' AppendDataBoundItems="True" DataSourceID="ODClass" DataTextField="ClassName" DataValueField="ClassID" >
                    <asp:ListItem Text="不属于任何分类" Value="-1" />
                 </asp:DropDownList>
                 <asp:ObjectDataSource ID="ODClass" runat="server" SelectMethod="GetAllClass" TypeName="Shop_Class"/>
              </td>
           </tr>
           <tr>
              <td class="ltd">是否转向链接</td>
              <td class="rtd">
                 <asp:RadioButtonList ID="LinkType" runat="server"  SelectedValue='<%# Bind("LinkType") %>' RepeatLayout="Flow" RepeatDirection="Horizontal">
                    <asp:ListItem Text="否" Value="0"  Selected="True"/>
                    <asp:ListItem Text="是" Value="1" />
                 </asp:RadioButtonList>
              </td>
           </tr>             
           <tr id="LinkType_1">
              <td class="ltd">转向链接URL</td>
              <td class="rtd"><asp:TextBox ID="LinkUrl" runat="server" Width="300px" Text='<%# Bind("LinkUrl") %>'/>
                  <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="LinkUrl"
                      ErrorMessage="地址不能为空"></asp:RequiredFieldValidator></td>
           </tr>
            <tr id="LinkType_2">
              <td class="ltd">文章内容 <a href="javascript:void(0)" onclick="addheight('add')" >+</a>&nbsp;<a href="javascript:void(0)" onclick="addheight('sub')" >-</a></td>
              <td class="rtd">
                 <fckeditorv2:FCKeditor ID="Content" runat="server" Value='<%# Bind("ArticleContent") %>'  AutoDetectLanguage="true" BasePath="../FCKEditor/" ></fckeditorv2:FCKeditor>
               </td>
           </tr>
            <tr>
              <td class="ltd">文章状态</td>
              <td class="rtd">
                 <asp:RadioButtonList ID="Status" runat="server" RepeatDirection="Horizontal" SelectedValue='<%# Bind("Status") %>'>
                    <asp:ListItem Text="草稿" Value="1" />
                    <asp:ListItem Text="待审核" Value="-1" />
                    <asp:ListItem Text="通过" Value="3" />
                 </asp:RadioButtonList></td>
           </tr>
           <tr>
              <td class="ltd">所属专题</td>
              <td class="rtd">
                <asp:DropDownList ID="SpecialID" runat="server" SelectedValue='<%# Bind("SpecialID") %>' AppendDataBoundItems="True" DataSourceID="obSpecial" DataTextField="SpecialName" DataValueField="SpecialID">
                   <asp:ListItem Text="首页" Value="-1" />
                </asp:DropDownList>
                <asp:ObjectDataSource ID="obSpecial" runat="server" SelectMethod="GetSpecialByChannel"
                    TypeName="SpecialBll" OldValuesParameterFormatString="original_{0}" >
                    <SelectParameters>
                        <asp:Parameter DefaultValue="-1" Name="ChannelID" Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>
              </td>
           </tr>
            <tr>
              <td class="ltd">文章属性</td>
              <td class="rtd">
                 <asp:DropDownList ID="IsTop" SelectedValue='<%# Bind("OnTop") %>' runat="server">
                    <asp:ListItem Text="置顶" Value="1" />
                    <asp:ListItem Text="取消置顶" Value="0" />
                 </asp:DropDownList>
                  <asp:DropDownList ID="IsElite" SelectedValue='<%# Bind("Elite") %>' runat="server">
                    <asp:ListItem Text="推荐" Value="1" />
                    <asp:ListItem Text="取消推荐" Value="0" />
                 </asp:DropDownList>
              </td>
           </tr>
            <tr>
              <td class="ltd">录入者</td>
              <td class="rtd"><asp:TextBox ID="Editor" runat="server" Text='<%# Bind("Editor") %>'/></td>
           </tr>
            <tr>
              <td class="ltd">起始点击数</td>
              <td class="rtd"><asp:TextBox ID="Hits" runat="server" Text='<%# Bind("Hits") %>'/></td>
           </tr>
           <tr>
              <td class="ltd">录入时间</td>
              <td class="rtd"><asp:TextBox ID="InputTime" runat="server" Text='<%# Bind("InputTime") %>'/></td>
           </tr>
           <tr>
              <td class="ltd">文章有效期</td>
              <td class="rtd"><asp:TextBox ID="Validay" runat="server" Text='<%# Bind("Validay") %>'/>天</td>
           </tr>
           <tr>
              <td class="ltd">文章模板</td>
              <td class="rtd"><asp:TextBox ID="TemplatePath" runat="server" Width="200" Text='<%# Bind("TemplatePath") %>'/>
              <input value="浏览" type="button" name="ll" onclick="return OpenFileList('TemplatePath')" />
              （留空则显示默认）
              </td>
           </tr>
          </table>
          <div class="div_btm">
              <asp:Button ID="Update" CommandName="Update" Text="保存"  runat="server" />
          </div>
        
         <script type="text/javascript">
           selectLinkType();
           selectArtitleType();           
         </script>
     </EditItemTemplate>
   
   </asp:FormView>
   

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" InsertMethod="AddNewArticle" SelectMethod="GetArticleByArticleID" TypeName="Shop_Article" UpdateMethod="UpdateArticle" OldValuesParameterFormatString="original_{0}">
        <InsertParameters>
            <asp:Parameter Name="ChannelID" Type="Int32" />
            <asp:Parameter Name="ClassID" Type="Int32" />
            <asp:Parameter Name="ArticleType" Type="String" />
            <asp:Parameter Name="TitleType" Type="Int32" />
            <asp:Parameter Name="ShortTitle" Type="String" />
            <asp:Parameter Name="LognTitle" Type="String" />
            <asp:Parameter Name="ArticleContent" Type="String" />
            <asp:Parameter Name="LinkUrl" Type="String" />
            <asp:Parameter Name="TitleLength" Type="Int32" />
            <asp:Parameter Name="PicUrl" Type="String" />
            <asp:Parameter Name="InputTime" Type="DateTime" />           
            <asp:Parameter Name="Hits" Type="Int32" />
            <asp:Parameter Name="Editor" Type="String" />
            <asp:Parameter Name="OnTop" Type="Int32" />
            <asp:Parameter Name="Elite" Type="Int32" />
            <asp:Parameter Name="Validay" Type="Int32" />
            <asp:Parameter Name="Status" Type="Int32" />
            <asp:Parameter Name="SpecialID" Type="Int32" />
            <asp:Parameter Name="UploadPicUrl" Type="String" />
            <asp:Parameter Name="IsHighDisplay" Type="Int32" />
            <asp:Parameter Name="LinkType" Type="Int32" />
            <asp:Parameter Name="TemplatePath" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:QueryStringParameter Name="ArticleID" QueryStringField="ArticleID" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="ArticleID" Type="Int32" />
            <asp:Parameter Name="ChannelID" Type="Int32" />
            <asp:Parameter Name="ClassID" Type="Int32" />
            <asp:Parameter Name="ArticleType" Type="String" />
            <asp:Parameter Name="TitleType" Type="Int32" />
            <asp:Parameter Name="ShortTitle" Type="String" />
            <asp:Parameter Name="LognTitle" Type="String" />
            <asp:Parameter Name="ArticleContent" Type="String" />
            <asp:Parameter Name="LinkUrl" Type="String" />
            <asp:Parameter Name="TitleLength" Type="Int32" />
            <asp:Parameter Name="PicUrl" Type="String" />
            <asp:Parameter Name="Hits" Type="Int32" />
            <asp:Parameter Name="Editor" Type="String" />
            <asp:Parameter Name="OnTop" Type="Int32" />
            <asp:Parameter Name="Elite" Type="Int32" />
            <asp:Parameter Name="Validay" Type="Int32" />
            <asp:Parameter Name="Status" Type="Int32" />
            <asp:Parameter Name="SpecialID" Type="Int32" />
            <asp:Parameter Name="InputTime" Type="DateTime" />
            <asp:Parameter Name="UploadPicUrl" Type="String" />
            <asp:Parameter Name="IsHighDisplay" Type="Int32" />
            <asp:Parameter Name="LinkType" Type="Int32" />
            <asp:Parameter Name="TemplatePath" Type="String" />
        </UpdateParameters>
    </asp:ObjectDataSource>
   <asp:ObjectDataSource ID="Obchannel2" runat="server" SelectMethod="GetAllModule"  TypeName="Shop_Module"/>
   <asp:ObjectDataSource ID="obclass2" runat="server" SelectMethod="GetAllClass"    TypeName="Shop_Class"/>

</asp:Content>

