<%@ page language="C#" autoeventwireup="true" inherits="general_SystemManage_ProductInfo, CrmCommand" %>
<%@ Register TagPrefix="C1WebGrid" Namespace="C1.Web.C1WebGrid" Assembly="C1.Web.C1WebGrid.2" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>产品信息</title>
    <script src="../../Javascript/CheckALL.js" type="text/javascript"></script>
    <script language=javascript type="text/javascript">
   function OpenWin(str)
   {
      var id=document.getElementById("Hidden1").value;
      var url=str+"&Product_id="+id;
      if(str.indexOf("edit")>-1)
      {
         if(id=="0" || id=="")
         {
           alert('请您选择需要修改的产品类型！');
         }
         else
         {
              var R=  window.showModalDialog(url,"水平","dialogWidth=460px;dialogHeight=290px");
              if(R != null)
              {
                  var keys = R.split('|');
                  if(keys[0] == "ok")
                  {
                    parent.proleft.location.reload();
                     location.href = 'ProductInfo.aspx?Type_Id='+keys[1];
                   
                  }
              }
         }
     }
    else
    {
       var R=window.showModalDialog(url,"水平","dialogWidth=460px;dialogHeight=290px");
        if(R != null)
              {
           var keys = R.split('|');
            if(keys[0] == "ok")
                  {
                     //alert(keys[1]);
                     parent.proleft.location.reload();
                     location.href = 'ProductInfo.aspx?Type_Id='+keys[1];
                  }
              }
     }
   }
  
function ok()
{
 var id=document.getElementById("Hidden1").value;
 if(id=="0" || id=="")
 {
   
   alert('请您选择要删除的产品类型！');
   return false;
 }
 else
 {
     if(confirm('真的要删除此产品类型吗!'))
     {
       
       return true;
     }
     else
     {
      return false;
     }
 }
}

function OpenPro(str)
   {
      var id=document.getElementById("Hidden1").value;
    
       var url=str+"&Product_id="+id;
     
      if(id != "0")
      {
       var R=window.showModalDialog(url,"水平","dialogWidth=460px;dialogHeight=260px");
     
       if(R == "ok")
       {
            location.reload();
       }
       
       else if(R != null)
       {
          alert('你必须选择一个类别!');
        
       }
      }
  
   }
function CheckPro(formName,chkName,str)
{
    var i=0;
    var pronameid;
    var objForm = document.forms[formName];
    var objLen = objForm.length;
    for (var iCount = 0; iCount < objLen; iCount++)
    {
		if (objForm.elements[iCount].type == "checkbox")
		{
		     
		     if((objForm.elements[iCount].name.indexOf(chkName)>-1))
		     {
		          if( objForm.elements[iCount].checked )
		          {
		             i=i+1;
		             pronameid=objForm.elements[iCount].value;
		          }

			 }
		}
		
    }
    if(i>0)
    {
        if(i>1)
        {
          alert('只允许选择一条产品信息来进行编辑！');
        }
        else
        {
          var url=str+"&ProName_id="+pronameid;
          var R=window.showModalDialog(url,"水平","dialogWidth=460px;dialogHeight=260px");
            if(R == "ok")
           {
                location.reload();
           }
        }
    }
    else
    {
     alert('必须选择一条数据进行编辑！');
    }
}
function ChkOk(formName,chkName)
{
    var i=0;
    var objForm = document.forms[formName];
    var objLen = objForm.length;
    for (var iCount = 0; iCount < objLen; iCount++)
    {
		if (objForm.elements[iCount].type == "checkbox")
		{
		     
		     if((objForm.elements[iCount].name.indexOf(chkName)>-1))
		     {
		          if( objForm.elements[iCount].checked )
		          {
		             i=i+1;
		            
		          }

			 }
		}
		
    }
    if(i>0)
    {
       return confirm('确定删除选定的产品吗？');
      
    }
    else
    {
      alert('必须选择一条数据删除！');
      return false;
    }
}
function Valion()
{
  var pro=document.getElementById("TxtName").value;
  if(pro=="")
  {
  
    alert('产品名称不能为空');
    return false;
  }
  else
  {
   return true;
  }
}
function OpenOther(url)
{
  var R=window.showModalDialog(url,"水平","dialogWidth=460px;dialogHeight=260px");
    if(R == "ok")
           {
                location.reload();
           }
}
    </script>
    
</head>
<body class="bodycolor" leftmargin="0" topmargin="0">
    <form id="form1" runat="server">
    <div>
    	<TABLE class="small" cellSpacing="1" width="650" align="center" bgColor="#000000"
					border="0">
            <tr>
                <td class="TableHeader" colspan="3"><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
				
				   <tr>
				   <td align=center noWrap class="TableData" valign=top colspan=3> <C1WebGrid:C1WebGrid ID="C1WebGrid1" runat="server" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" CallbackOptions="Sorting,Selection" 
            DataKeyField="Produc_Id"  OnItemCreated="C1WebGrid1_ItemCreated"
            OnPageIndexChanging="C1WebGrid1_PageIndexChanging" OnSortingCommand="C1WebGrid1_SortingCommand"
            PageSize="10" SkinID="gridviewSkin"  width="640px"  >
            <Columns>
                <C1WebGrid:C1TemplateColumn ><HeaderTemplate>
                    <input id="all" type="checkbox"  value="全选" onclick="CheckAll('form1','item','all')" /></HeaderTemplate> <ItemTemplate > <input id="item" type="checkbox" runat=server value='<%#Eval("Produc_Id") %>'  /></ItemTemplate></C1WebGrid:C1TemplateColumn>
                <C1WebGrid:C1BoundColumn DataField="Produc_Id"  HeaderText="产品序号" SortExpression="Produc_Id">
                </C1WebGrid:C1BoundColumn>
                <C1WebGrid:C1BoundColumn DataField="Exp1"  HeaderText="产品类型名称" SortExpression="Exp1">
                </C1WebGrid:C1BoundColumn>
                <C1WebGrid:C1TemplateColumn SortExpression="ProducTypet_Name" HeaderText="产品名称"><ItemTemplate><A href="#" onclick="OpenOther('ProductADD.aspx?Method=edit&ProName_id=<%#Eval("Produc_Id") %>')"><%#Eval("ProducTypet_Name")%></A></ItemTemplate></C1WebGrid:C1TemplateColumn>
                <C1WebGrid:C1BoundColumn DataField="Product_Price" HeaderText="产品价格" DataFormatString="{0:C}" SortExpression="Product_Price">
                </C1WebGrid:C1BoundColumn>
               
                <C1WebGrid:C1TemplateColumn HeaderText="产品说明" SortExpression="Product_Remark"><ItemTemplate> <asp:Label     ID="Lkb" Text='<%# Server.HtmlDecode(Eval

("Product_Remark").ToString()).Length > 11 ? Server.HtmlDecode(Eval

("Product_Remark").ToString()).Substring(0, 10) + "..." : Server.HtmlDecode

(Eval("Product_Remark").ToString())%>'  ToolTip='<%# Server.HtmlDecode(Eval

("Product_Remark").ToString())%>' runat="server"></asp:Label></ItemTemplate><ItemStyle HorizontalAlign="Center" Wrap="True" />
                    <HeaderStyle HorizontalAlign="Center" /></C1WebGrid:C1TemplateColumn>
            		</Columns>
        </C1WebGrid:C1WebGrid>
                      </td>
				   </tr>
				   <tr>
				   <td class="TableData" colspan="3" align="center">
				    <!--<input id="Button4" type="button"  class="BigButton" value="新建产品" onclick="OpenPro('ProductADD.aspx?Method=add')" />-->
                       <asp:Button ID="Button8"  CssClass="BigButton" OnClientClick="OpenPro('ProductADD.aspx?Method=add');return false;"  runat="server" Text="新建产品"  />
                       <input id="Button5" type="button"   class="BigButton" value="编辑产品" onclick="CheckPro('form1','item','ProductADD.aspx?Method=edit')" />
                       <asp:Button ID="Button6" runat="server" CssClass="BigButton" OnClientClick="return ChkOk('form1','item')"  Text="删除产品" OnClick="Button6_Click" />
				   </td> 
				   </tr>
				</TABLE>
        <input id="Hidden1" type="hidden" runat=server />
 
       
    </div>
        
    
    </form>
</body>
</html>