<%@ page language="C#" enableeventvalidation="false" autoeventwireup="true" inherits="general_Contract_ContractInfo, CrmCommand" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>新增合同</title>
    <script  src="../../Javascript/Trim.js" type="text/javascript"> </script>
    <script src="../../Javascript/canlendar.js" type="text/javascript"></script>
    <script src="../../Javascript/formCheck.js" type="text/javascript"></script>
     <script src="../../DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
    var  j=0;
    var k=-1;
    var ncount=0;
    var n=0;
    
    function PriceResult()
    {
		    var Types=document.getElementById("DropProName");
		    var index=Types.selectedIndex;
		    var productprice = Types.options[index].value;
		   
		    PageMethods.ProductSingPrice(productprice,callback);
    }
function callback(result)
    {
          document.getElementById("TxtSingPrice").innerText=result;
        //  var price=document.getElementById("TxtSingPrice").value;//单价
        //  var Types=document.getElementById("DropPeriod");
        //  var index=Types.selectedIndex;
         // var period = Types.options[index].value;//年限
         // var Nummber=document.getElementById("DropNum").options[document.getElementById("DropNum").selectedIndex].value;
        
        // PageMethods.ProductTotals(price,period,Nummber,CallBackTotals);
    }


function total()
    {
         var price=document.getElementById("TxtSingPrice").value;//单价
          var Types=document.getElementById("DropPeriod");
          var index=Types.selectedIndex;
          var period = Types.options[index].value;//年限
          var Nummber=document.getElementById("DropNum").options[document.getElementById("DropNum").selectedIndex].value;
         if(!isMath(TrimStr(price)))
    	    {
    	        alert('您输入的单价必须是数字!');   
    	    }
    	    else
    	      {
               PageMethods.ProductTotals(price,period,Nummber,CallBackTotals);
              }
    }
    function RLtrim()
    {
      var ClientName=document.getElementById("TxtClientName").value;
      var ClientContact=document.getElementById("TxtClientContact").value;
      var TxtCheckInData=document.getElementById("TxtCheckInData").value;
      var TxtClientComTel=document.getElementById("TxtClientComTel").value;
      var price=document.getElementById("TxtSingPrice").value;//单价
	  var prices=document.getElementById("TxtSmallPrice").value;//总价
      if(!Trim(ClientName))
      {
        alert('客户名称不能为空!');
         return false;
      }
      else if(!Trim(ClientContact))
      {
        alert('客户联系人不能为空!');
         return false;
        
      }
      else if(!Trim(TxtCheckInData))
      {
        alert("签约日期不能为空!");
         return false;
      }
      else if(!Trim(TxtClientComTel))
      {
        alert('公司联系电话不能为空!');
         return false;
      }
       else if(!isMath(TrimStr(price)))
        {
            
            alert('您输入的单价必须是数字!'); 
            return false;
           
        }
        else if(!isMath(TrimStr(prices)))
        {
            alert('您输入的总价必须是数字!'); 
            return false;
           
        }
      else
      {
        return true;
      }
    }
    function Totals()
    {
    	var price=document.getElementById("TxtSingPrice").value;//数量
    	if(!isMath(TrimStr(price)))
    	{
    	    alert('您输入的单价必须是数字!'); 
    	    return false;
    	}
    	else
    	{
          var price=document.getElementById("TxtSingPrice").value;//单价
          //var Types=document.getElementById("DropPeriod");
          //var index=Types.selectedIndex;
          //var period = Types.options[index].value;//年限
          //var Nummber=document.getElementById("DropNum").options[document.getElementById("DropNum").selectedIndex].value;
          // var Total=parseFloat(price.value)*parseInt(period)*parseInt(Nummber.value);
          // PageMethods.ProductTotals(price,period,Nummber,CallBackTotals);
          //document.getElementById("TxtSmallPrice").innerText=Total;
	       
    	  }  
    	
    
	    
    }
    function CallBackTotals(Result)
    {
      document.getElementById("TxtSmallPrice").innerText=Result;
    }
    function add()
    {
		//将数据插入表格数
		   var Types=document.getElementById("DropProName");
		   var index=Types.selectedIndex;
		   document.getElementById("ProductName").value=Types.options[index].innerText;
		 //  alert(document.getElementById("ProductName"));
		 //  alert(Types.options[index].innerText);
		if(confirm('你确认要把产品加入合同列表中去!'))
		{
		  
		     
		        var price=document.getElementById("TxtSingPrice").value;//单价
		        var prices=document.getElementById("TxtSmallPrice").value;//总价
    	        if(!isMath(TrimStr(price)))
    	        {
    	            alert('您输入的单价必须是数字!'); 
    	           return false;
    	        }
    	        else if(!isMath(TrimStr(prices)))
	            {
	                alert('您输入的总价必须是数字!'); 
	                return false;
	            }
    	        else
    	        {
		            return true;
		        }
		        
		}
                else
                   {
                        return false;
                   }
	}

</script>

    <base target=_self></base>
	<style type="text/css">
.style1 {
	color: #FF0000;
	font-size: x-small;
}
.style2 {
	font-size: x-small;
}
</style>
</head>
<body class ="bodycolor" leftmargin="0" topmargin="0" >
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
        </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" >
            <ContentTemplate>
				<div id="First">
					<table class="small" style="width: 760px; height: 94%" align="center" cellspacing="0" cellpadding="5">
						<tr>
							<td colspan="2" style="height: 75px">
							<fieldset name="Group1">
							<legend class="style1">基本信息</legend>
							<table style="width: 100%; height: 65px" cellspacing="0" cellpadding="0">
								<tr>
									<td style="width: 98px" class="style2">合同类型:</td>
									<td colspan="2">
									<asp:DropDownList ID="DropType" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropType_SelectedIndexChanged" Font-Size="X-Small">
									</asp:DropDownList>
									</td>
								</tr>
								<tr>
									<td style="width: 98px" class="style2">合同编号:</td>
									<td colspan="2">
									<asp:DropDownList ID="DropContractNum" runat="server" Font-Size="X-Small">
									</asp:DropDownList>
									</td>
								</tr>
								<tr>
									<td style="width: 98px; height: 30px;" class="style2">签约日期:</td>
									<td style="height: 30px;" class="style2" colspan="2">
									<table style="width: 100%" cellpadding="0" cellspacing="0">
										<tr>
											<td style="width: 110px">
											<input id="TxtCheckInData" runat="server" type="text" readonly style="border: 1px #C0C0C0 solid; width: 110px; height: 22;" /></td>
											<td>
											<img src="../../App_Themes/Green/images/Calendar.gif" onclick="popUpCalendar(document.getElementById(&quot;TxtCheckInData&quot;), document.getElementById(&quot;TxtCheckInData&quot;), &quot;yyyy-mm-dd&quot;)" /></td>
										</tr>
									</table>
									</td>
								</tr>
								<tr>
									<td style="width: 98px" class="style2">付款方式:</td>
									<td style="width: 115px">
									<asp:DropDownList ID="DropPayMethod" CssClass="BigInput" runat="server" Font-Size="X-Small">
										<asp:ListItem>现金</asp:ListItem>
										<asp:ListItem>支票</asp:ListItem>
										<asp:ListItem>贷记凭证</asp:ListItem>
										<asp:ListItem>电汇</asp:ListItem>
										<asp:ListItem>汇票</asp:ListItem>
										<asp:ListItem>信用卡</asp:ListItem>
										<asp:ListItem>网上支付</asp:ListItem>
									</asp:DropDownList>
									</td>
									<td></td>
								</tr>
							</table>
							</fieldset><span class="style2"> </span></td>
						</tr>
						<tr>
							<td style="width: 404px; height: 145px;" valign="top">
							<fieldset name="Group1">
							<legend class="style1">买方(乙方)</legend>
							<table cellspacing="0" cellpadding="0" style="width: 370px">
								<tr>
									<td style="width: 72px" class="style2">公司名称</td>
									<td>
									<asp:TextBox ID="TxtClientName" CssClass="BigInput" runat="server" Width="277px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
								<tr>
									<td style="width: 72px" class="style2">公司地址</td>
									<td>
									<asp:TextBox ID="TxtAddr" CssClass="BigInput" runat="server" Width="277px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
								<tr>
									<td style="width: 72px" class="style2">联系电话</td>
									<td>
									<asp:TextBox ID="TxtClientComTel" CssClass="BigInput" runat="server" Width="174px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
								<tr>
									<td style="width: 72px" class="style2">公司传真</td>
									<td>
									<asp:TextBox ID="TxtClientFax" CssClass="BigInput" runat="server" Width="174px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
								<tr>
									<td style="width: 72px" class="style2">联系人</td>
									<td>
									<asp:TextBox ID="TxtClientContact" CssClass="BigInput" runat="server" Width="174px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
								<tr>
									<td style="width: 72px" class="style2">签约人</td>
									<td>
									<asp:TextBox ID="TxtBuyCheckPeo" CssClass="BigInput" runat="server" Width="174px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
								<tr>
									<td style="width: 72px" class="style2">联系手机</td>
									<td>
									<asp:TextBox ID="TxtClientMobile" CssClass="BigInput" runat="server" Width="174px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
							</table>
							</fieldset></td>
							<td valign="top" style="height: 145px; width: 400px;">
							<fieldset name="Group1">
							<legend class="style1">卖方(甲方)</legend>
							<table cellspacing="0" cellpadding="0" style="width: 370px">
								<tr>
									<td style="width: 72px" class="style2">公司名称</td>
									<td>
									<asp:TextBox ID="TxtMyComName" CssClass="BigInput" runat="server" Width="277px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
								<tr>
									<td style="width: 72px" class="style2">公司地址</td>
									<td>
									<asp:TextBox ID="TxtMyAddr0" CssClass="BigInput" runat="server" Width="277px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
								<tr>
									<td style="width: 72px" class="style2">联系电话</td>
									<td>
									<asp:TextBox ID="TxtMyTel" CssClass="BigInput" runat="server" Width="174px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
								<tr>
									<td style="width: 72px;" class="style2">公司传真</td>
									<td>
									<asp:TextBox ID="MyClientFax0" CssClass="BigInput" runat="server" Width="174px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
								<tr>
									<td style="width: 72px" class="style2">联系人</td>
									<td>
									<asp:TextBox ID="TxtMyPeople" CssClass="BigInput" runat="server" Width="174px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
								<tr>
									<td style="width: 72px" class="style2">签约人</td>
									<td>
									<asp:TextBox ID="TxtMyCheckIn" CssClass="BigInput" runat="server" Width="174px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
								<tr>
									<td style="width: 72px" class="style2">联系手机</td>
									<td>
									<asp:TextBox ID="TxtMyMobile" CssClass="BigInput" runat="server" Width="174px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
								</tr>
							</table>
							</fieldset></td>
						</tr>
						<tr>
							<td colspan="2" class="TableData" valign="top">
							<fieldset name="Group1">
							<legend class="style1">合同产品信息 </legend>
							<table style="width: 750px" cellspacing="0" cellpadding="0">
								<tr>
									<td>
										<table style="width: 750px" cellspacing="0" cellpadding="0">
                  <tr>
                    <td class="style2"colspan="4"><table width="750" border="0">
                      <tr>
                        <td class="style2"width="144">产品名称：</td>
                        <td class="style2"width="596"><asp:DropDownList ID="DropProName" runat="server" CssClass="BigInput" onclick="PriceResult()" Font-Size="X-Small"> </asp:DropDownList></td>
                      </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td class="style2"width="20%">产品单价：</td>
                    <td class="style2"width="30%"><asp:TextBox CssClass="BigInput" ID="TxtSingPrice" runat="server" Width="110px"  Font-Size="X-Small"></asp:TextBox></td>
                    <td class="style2"width="25%">产品数量：</td>
                    <td class="style2"width="25%"><asp:DropDownList ID="DropNum" runat="server" Font-Size="X-Small">
                      <asp:ListItem>1</asp:ListItem>
                      <asp:ListItem>2</asp:ListItem>
                      <asp:ListItem>3</asp:ListItem>
                      <asp:ListItem>4</asp:ListItem>
                      <asp:ListItem>5</asp:ListItem>
                      <asp:ListItem>6</asp:ListItem>
                      <asp:ListItem>7</asp:ListItem>
                      <asp:ListItem>8</asp:ListItem>
                      <asp:ListItem>9</asp:ListItem>
                      <asp:ListItem>10</asp:ListItem>
                    </asp:DropDownList></td>
                  </tr>
                   <tr>
                    <td class="style2">产品总价：</td>
                    <td class="style2"><asp:TextBox CssClass="BigInput" ID="TxtSmallPrice" runat="server" Width="110px"  Font-Size="X-Small"></asp:TextBox></td>
                    <td class="style2">
                        是否需要续费：</td>
                    <td class="style2">&nbsp;<asp:CheckBox ID="CheckBox1" runat="server" Text="无需续费" OnCheckedChanged="CheckBox1_CheckedChanged" AutoPostBack="True" /></td>
                  </tr>
                  <div id="ShowRQ" runat="server">
                  <tr>
                    <td class="style2">开始日期：</td>
                    <td class="style2"><asp:TextBox CssClass="BigInput" ID="TxtTimeStart" runat="server" Width="110px" onfocus="WdatePicker({isShowWeek:true})" Font-Size="X-Small"></asp:TextBox></td>
                    <td class="style2">结束日期：</td>
                    <td class="style2"><asp:TextBox CssClass="BigInput" ID="TxtTimeEnd" runat="server" Width="110px" onfocus="WdatePicker({isShowWeek:true})" Font-Size="X-Small"></asp:TextBox></td>
                  </tr>
                 </div>
                  <tr>
                    <td class="style2">产品备注：</td>
                    <td class="style2"colspan="3"><asp:TextBox CssClass="BigInput" ID="TxtRemark" runat="server" Width="524px"  Font-Size="X-Small"></asp:TextBox></td>
                  </tr>
                  <tr>
                    <td class="style2"colspan="4" align="center"><asp:Button ID="Button2" runat="server" CssClass="SmallButton" OnClick="Button1_Click1" Text="添加产品" OnClientClick="return add()" Font-Size="X-Small" /></td>
                  </tr>
                </table>
									</td>
								</tr>
								
								<tr>
									<td align="center">
									<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="770px" OnRowDeleting="GridView1_RowDeleting" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" Font-Size="X-Small">
										<Columns>
											<asp:boundfield DataField="a" HeaderText="名称">
												<ItemStyle HorizontalAlign="Center" />
												<HeaderStyle Font-Size="Small" />
											</asp:boundfield>
											<asp:boundfield DataField="b" HeaderText="单价">
												<ItemStyle HorizontalAlign="Center" />
												<HeaderStyle Font-Size="Small" />
											</asp:boundfield>
											<asp:boundfield DataField="start" HeaderText="开始时间">
												<ItemStyle HorizontalAlign="Center" />
												<HeaderStyle Font-Size="Small" />
											</asp:boundfield>
											<asp:boundfield DataField="end" HeaderText="结束时间">
												<ItemStyle HorizontalAlign="Center" />
												<HeaderStyle Font-Size="Small" />
											</asp:boundfield>
											<asp:boundfield DataField="d" HeaderText="数量">
												<ItemStyle HorizontalAlign="Center" />
												<HeaderStyle Font-Size="Small" />
											</asp:boundfield>
											<asp:boundfield DataField="e" HeaderText="总价">
												<ItemStyle HorizontalAlign="Center" />
												<HeaderStyle Font-Size="Small" />
											</asp:boundfield>
											<asp:boundfield DataField="f" HeaderText="备注">
												<ItemStyle HorizontalAlign="Center" />
												<HeaderStyle Font-Size="Small" />
											</asp:boundfield>
											<asp:commandfield HeaderText="删除" ShowDeleteButton="True">
												<HeaderStyle Font-Size="Small" />
												<ItemStyle HorizontalAlign="Center" />
											</asp:commandfield>
										</Columns>
										<FooterStyle BackColor="White" ForeColor="#000066" />
										<RowStyle ForeColor="#000066" />
										<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
										<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
										<HeaderStyle ForeColor="#3A6EA5" />
									</asp:GridView>
									</td>
								</tr>
							</table>
							</fieldset> <span class="style2">
							<input id="HidCode" runat="server" type="hidden" />
							</span></td>
						</tr>
						<tr>
							<td colspan="2" style="height: 195px">
							<fieldset name="Group1">
							<legend class="style1">附加及其他</legend>
							<table style=" width: 100%; height: 100%" cellspacing="0" cellpadding="0">
								<tr>
									<td style="height: 7px" class="style2">付款日期</td>
									<td style="height: 7px">
									<table style="width: 20%; height: 21px;" cellspacing="0" cellpadding="0">
										<tr>
											<td style="width: 123px; height: 26px;" class="style2">
											<input id="TxtCPaydata" runat="server" type="text" readonly style="border: 1px #C0C0C0 solid; width: 126px; height: 22;" /></td>
											<td style="height: 26px" class="style2">
											<img src="../../App_Themes/Green/images/Calendar.gif" onclick="popUpCalendar(document.getElementById(&quot;TxtCPaydata&quot;), document.getElementById(&quot;TxtCPaydata&quot;), &quot;yyyy-mm-dd&quot;)" /></td>
										</tr>
									</table>
									</td>
									<td style="height: 7px" class="style2">&nbsp;</td>
									<td style="width: 6px; height: 7px;" class="style2">&nbsp;</td>
								</tr>
								<tr>
									<td class="style2">发票</td>
									<td>
									<asp:DropDownList ID="DropCIsBill" CssClass="BigInput" runat="server" Font-Size="X-Small">
										<asp:ListItem Value="1">有</asp:ListItem>
										<asp:ListItem Value="0">无</asp:ListItem>
									</asp:DropDownList>
									</td>
									<td class="style2">&nbsp;</td>
									<td style="width: 6px" class="style2">&nbsp;</td>
								</tr>
								<tr>
									<td class="style2">其他说明</td>
									<td>
									<asp:TextBox ID="TxtCremark" runat="server" TextMode="MultiLine" Width="532px" Height="145px" BorderColor="Silver" BorderWidth="1px" Font-Size="X-Small">
									</asp:TextBox>
									</td>
									<td class="style2">&nbsp;</td>
									<td style="width: 6px" class="style2">&nbsp;</td>
								</tr>
								<tr>
									<td class="style2">&nbsp;</td>
									<td class="style2">&nbsp;</td>
									<td class="style2">&nbsp;</td>
									<td style="width: 6px" class="style2">&nbsp;</td>
								</tr>
							</table>
							</fieldset><span class="style2"> </span></td>
						</tr>
						<tr>
							<td colspan="2" align="center">
							<asp:Button ID="Button4" runat="server" OnClientClick="return RLtrim()" class="SmallButton" OnClick="Button1_Click" Text="确认无误" Font-Size="X-Small" />
							</td>
						</tr>
					</table>
				</div>
				<span class="style2">
				<input id="HidConNum" runat="server" type="hidden" />
				<input id="Hidnum" type="hidden" value="0" />
                <asp:TextBox ID="ProductName" runat="server" Width="0" ></asp:TextBox></span> 
			</ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Button4" EventName="Click" />
          </Triggers>
            </asp:UpdatePanel>
            <div id="ShowJs" runat="Server"> </div>
             </form>
</body>
</html>
