<%@ page language="C#" autoeventwireup="true" inherits="general_Contract_ContractEdit, CrmCommand" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>修改合同</title>
    <base target=_self></base>
     <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 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
      {
        return true;
      }
    }
    
       function add()
    {
		//将数据插入表格数
	    	var Types=document.getElementById("DropProName");
		    var index=Types.selectedIndex;
		   document.getElementById("ProductName").value=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>

	<style type="text/css">
.style1 {
	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 align="center" cellpadding="5" cellspacing="0" style="width: 780px" class="style1">
							<tr>
								<td colspan="2" style="height: 75px">
								<fieldset name="Group1">
								<legend class="style1">基本信息</legend>
								<table cellpadding="0" cellspacing="0" style="width: 100%; height: 65px">
									<tr>
										<td style="width: 98px" class="style1">合同类型</td>
										<td>
										<asp:Label ID="LblType" runat="server" Font-Size="X-Small"></asp:Label>
										</td>
									</tr>
									<tr>
										<td style="width: 98px" class="style1">合同编号:</td>
										<td>
										<asp:Label ID="TxtContractNo" runat="server" Text="" Font-Size="X-Small"></asp:Label>
										</td>
									</tr>
									<tr>
										<td style="width: 98px" class="style1">合同状态:</td>
										<td>
										<asp:Label ID="Label1" runat="server" Text="" Font-Size="X-Small"></asp:Label>
										</td>
									</tr>
									<tr>
										<td style="width: 98px" class="style1">签约日期:</td>
										<td>
										<table style="width: 100%" cellspacing="0" cellpadding="0">
											<tr>
												<td style="width: 91px" class="style1">
												<input id="TxtCheckInData" runat="server" readonly style="border: 1px solid #C0C0C0; width: 90px" type="text" /></td>
												<td class="style1">
												<img onclick="popUpCalendar(document.getElementById(&quot;TxtCheckInData&quot;), document.getElementById(&quot;TxtCheckInData&quot;), &quot;yyyy-mm-dd&quot;)" src="../../App_Themes/Green/images/Calendar.gif" /></td>
											</tr>
										</table>
										</td>
									</tr>
									<tr>
										<td style="width: 98px; height: 20px;" class="style1">付款方式:</td>
										<td style="height: 20px">
										<asp:DropDownList ID="DropPayMethod" runat="server" CssClass="BigInput" 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>
										<span class="style1">&nbsp;</span></td>
									</tr>
								</table>
								</fieldset><span class="style1"> </span> </td>
							</tr>
							<tr>
								<td style="width: 404px; height: 145px" valign="top">
								<fieldset name="Group1">
								<legend class="style1">买方(乙方)</legend>
								<table cellpadding="0" cellspacing="0">
									<tr>
										<td style="width: 80px" class="style1">公司名称</td>
										<td>
										<asp:TextBox ID="TxtClientName" runat="server" CssClass="BigInput" Width="280px" Font-Size="X-Small"></asp:TextBox>
										</td>
									</tr>
									<tr>
										<td style="width: 72px" class="style1">公司地址</td>
										<td>
										<asp:TextBox ID="TxtAddr" runat="server" CssClass="BigInput" Width="280px" Font-Size="X-Small"></asp:TextBox>
										</td>
									</tr>
									<tr>
										<td style="width: 72px" class="style1">联系电话</td>
										<td>
										<asp:TextBox ID="TxtClientComTel" runat="server" CssClass="BigInput" Width="174px" Font-Size="X-Small">
										</asp:TextBox>
										</td>
									</tr>
									<tr>
										<td style="width: 72px" class="style1">公司传真</td>
										<td>
										<asp:TextBox ID="TxtClientFax" runat="server" CssClass="BigInput" Width="174px" Font-Size="X-Small">
										</asp:TextBox>
										</td>
									</tr>
									<tr>
										<td style="width: 72px" class="style1">联系人</td>
										<td>
										<asp:TextBox ID="TxtClientContact" runat="server" CssClass="BigInput" Width="174px" Font-Size="X-Small">
										</asp:TextBox>
										</td>
									</tr>
									<tr>
										<td style="width: 72px" class="style1">签约人</td>
										<td>
										<asp:TextBox ID="TxtBuyCheckPeo" runat="server" CssClass="BigInput" Width="174px" Font-Size="X-Small">
										</asp:TextBox>
										</td>
									</tr>
									<tr>
										<td style="width: 72px" class="style1">联系手机</td>
										<td>
										<asp:TextBox ID="TxtClientMobile" runat="server" CssClass="BigInput" Width="174px" Font-Size="X-Small">
										</asp:TextBox>
										</td>
									</tr>
								</table>
								</fieldset><span class="style1"> </span> </td>
								<td style="height: 145px; width: 413px;" valign="top">
								<fieldset name="Group1">
								<legend class="style1">卖方(甲方)</legend>
								<table cellpadding="0" cellspacing="0">
									<tr>
										<td style="width: 80px" class="style1">公司名称</td>
										<td>
										<asp:TextBox ID="TxtMyComName" runat="server" CssClass="BigInput" Width="280px" Font-Size="X-Small"></asp:TextBox>
										</td>
									</tr>
									<tr>
										<td style="width: 72px" class="style1">公司地址</td>
										<td>
										<asp:TextBox ID="TxtMyAddr0" runat="server" CssClass="BigInput" Width="280px" Font-Size="X-Small"></asp:TextBox>
										</td>
									</tr>
									<tr>
										<td style="width: 72px" class="style1">联系电话</td>
										<td>
										<asp:TextBox ID="TxtMyTel" runat="server" CssClass="BigInput" Width="174px" Font-Size="X-Small">
										</asp:TextBox>
										</td>
									</tr>
									<tr>
										<td style="width: 72px" class="style1">公司传真</td>
										<td>
										<asp:TextBox ID="MyClientFax0" runat="server" CssClass="BigInput" Width="174px" Font-Size="X-Small">
										</asp:TextBox>
										</td>
									</tr>
									<tr>
										<td style="width: 72px" class="style1">联系人</td>
										<td>
										<asp:TextBox ID="TxtMyPeople" runat="server" CssClass="BigInput" Width="174px" Font-Size="X-Small">
										</asp:TextBox>
										</td>
									</tr>
									<tr>
										<td style="width: 72px" class="style1">签约人</td>
										<td>
										<asp:TextBox ID="TxtMyCheckIn" runat="server" CssClass="BigInput" Width="174px" Font-Size="X-Small">
										</asp:TextBox>
										</td>
									</tr>
									<tr>
										<td style="width: 72px" class="style1">联系手机</td>
										<td>
										<asp:TextBox ID="TxtMyMobile" runat="server" CssClass="BigInput" Width="174px" Font-Size="X-Small">
										</asp:TextBox>
										</td>
									</tr>
								</table>
								</fieldset><span class="style1"> </span> </td>
							</tr>
							<tr>
								<td colspan="2" class="TableData" valign="top">
								<fieldset>
								<legend class="style1">合同产品信息 </legend>
								<table style="border: 1px solid #C0C0C0; width: 750px" cellspacing="0" cellpadding="0" align="center">
									<tr>
										<td align="center">
								<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" DataKeyNames="Contract_ID" OnRowDeleting="GridView1_RowDeleting" Width="730px" Font-Size="X-Small" OnRowDataBound="GridView1_RowDataBound">
											<Columns>
												<asp:templatefield HeaderText="名称">
													<ItemStyle Width="100px" HorizontalAlign="Center" />
													<HeaderStyle Font-Size="Small" />
													<ItemTemplate>
														<%#Eval("Product_Name").ToString()%>
													</ItemTemplate>
												</asp:templatefield>
												<asp:templatefield HeaderText="单价">
													<EditItemTemplate>
														<asp:TextBox Text='<%#Eval("Product_SinglePrice").ToString()%>' runat="server" ID="txtsingel" Width="30px">
														</asp:TextBox>
													</EditItemTemplate>
													<ItemStyle Width="70px" HorizontalAlign="Center" />
													<HeaderStyle Font-Size="Small" />
													<ItemTemplate>
														<%#Eval("Product_SinglePrice").ToString()%>
													</ItemTemplate>
												</asp:templatefield>
													<asp:boundfield DataField="Product_BeginTime" HeaderText="开始时间" DataFormatString="{0:yyyy-MM-dd}">
												<ItemStyle HorizontalAlign="Center" />
												<HeaderStyle Font-Size="Small" />
											</asp:boundfield>
											<asp:boundfield DataField="Product_EndTime" HeaderText="结束时间" DataFormatString="{0:yyyy-MM-dd}">
												<ItemStyle HorizontalAlign="Center" />
												<HeaderStyle Font-Size="Small" />
											</asp:boundfield>
												<asp:templatefield HeaderText="数量">
													<EditItemTemplate>
														<asp:TextBox Text='<%#Eval("Product_Num").ToString()%>' runat="server" ID="txtnum" Width="30px">
														</asp:TextBox>
													</EditItemTemplate>
													<ItemStyle Width="70px" HorizontalAlign="Center" />
													<HeaderStyle Font-Size="Small" />
													<ItemTemplate>
														<%#Eval("Product_Num").ToString()%>
													</ItemTemplate>
												</asp:templatefield>
												<asp:templatefield HeaderText="总价">
													<EditItemTemplate>
														<asp:TextBox Text='<%#Eval("Product_TotalPrice").ToString()%>' runat="server" ID="txtTotal" Width="40px">
														</asp:TextBox>
													</EditItemTemplate>
													<ItemStyle Width="70px" HorizontalAlign="Center" />
													<HeaderStyle Font-Size="Small" />
													<ItemTemplate>
														<%#Eval("Product_TotalPrice").ToString()%>
													</ItemTemplate>
												</asp:templatefield>
												<asp:templatefield HeaderText="备注">
													<EditItemTemplate>
														<asp:TextBox Text='<%#Eval("Product_Remark").ToString()%>' runat="server" ID="txtRemark" Width="150px">
														</asp:TextBox>
													</EditItemTemplate>
													<ItemStyle Width="150px" HorizontalAlign="Center" />
													<HeaderStyle Font-Size="Small" />
													<ItemTemplate>
														<%#Eval("Product_Remark").ToString()%>
													</ItemTemplate>
												</asp:templatefield>
												<asp:commandfield ShowDeleteButton="True" HeaderText="删除">
													<HeaderStyle Font-Size="Small" />
													<ItemStyle Width="50px" />
												</asp:commandfield>
											</Columns>
										</asp:GridView>
										<span class="style1">
										<br>
										</br></span></td>
									</tr>
								</table>
								<span class="style1">
								<br>
								</br></span></fieldset><span class="style1">
								</span> </td>
							</tr>
							<tr>
								<td colspan="2" valign="top"><fieldset>
								<legend class="style1">附加及其他</legend>
								<table cellpadding="0" cellspacing="0">
									<tr>
										<td style="width: 72px" class="style1">付款日期</td>
										<td>
										<table style="width: 100%" cellspacing="0" cellpadding="0">
											<tr>
												<td style="width: 93px" class="style1">
												<input id="TxtCPaydata" runat="server" readonly style="border: 1px solid #C0C0C0; width: 90px" type="text" /></td>
												<td class="style1">
												<img onclick="popUpCalendar(document.getElementById(&quot;TxtCPaydata&quot;), document.getElementById(&quot;TxtCPaydata&quot;), &quot;yyyy-mm-dd&quot;)" src="../../App_Themes/Green/images/Calendar.gif" /></td>
											</tr>
										</table>
										</td>
									</tr>
									<tr>
										<td style="width: 72px" class="style1">发票</td>
										<td>
										<asp:DropDownList ID="DropCIsBill" runat="server" CssClass="BigInput" Font-Size="X-Small">
											<asp:ListItem Value="1">有
											</asp:ListItem>
											<asp:ListItem Value="0">无
											</asp:ListItem>
										</asp:DropDownList>
										</td>
										<td class="style1">&nbsp;</td>
										<td class="style1">&nbsp;</td>
									</tr>
									<tr>
										<td style="width: 72px; height: 152px;" class="style1">其他说明</td>
										<td style="height: 152px">
										<asp:TextBox ID="TxtCremark" runat="server" Height="145px" TextMode="MultiLine" Width="532px" BorderColor="Silver" BorderWidth="1px" BorderStyle="Solid" Font-Size="X-Small">
										</asp:TextBox>
										</td>
										<td style="height: 152px"></td>
										<td style="height: 152px"></td>
									</tr>
								</table>
								</fieldset><span class="style1"> </span> </td>
							</tr>
							<tr>
								<td align="center" colspan="2" valign="top" height="20px">
								<asp:Button ID="Button1" runat="server" class="SmallButton" Text="确认无误" OnClientClick="return RLtrim()" OnClick="Button1_Click" Font-Size="X-Small" />
								</td>
							</tr>
						</table>
					</div>
					 <asp:TextBox ID="ProductName" runat="server" Width="0" ></asp:TextBox>
				</ContentTemplate>
            </asp:UpdatePanel>  
             <div id="ShowJs" runat="Server"> </div>
    </form>
</body>
</html>
