<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnSiteData.Asp" -->
<!--#include file="../CheckAdmin.Asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../Images/Admin_style.css">
<script language="javascript" src="../JavaScript/Admin.js"></script>
<script language="javascript" src="../JavaScript/select_date.js"></script>

<%
'If InStr(session("GroupPurview"), "|2,") = 0 Then
    'response.Write ("<br /><br /><div align=""center""><font style=""color:red; font-size:9pt; "")>您没有管理该模块的权限！</font></div>")
    'response.End
'End If
Dim Result
Result = request.QueryString("Result")
Dim ID,showid,mMemName,mRealName,mCo_Serialnumber,mCo_name,mCo_Legalperson,mCo_Capital,mCo_ren,mCo_bumen,mCo_pxzg,mCo_jszg,mCo_tel,mCo_fax,mCo_email,mCo_url,mCo_address,mCo_zipcode,mCo_Demo
Dim kattribute1
ID = request.QueryString("ID")
showid=request.QueryString("showid")
 response.Write "<script language='javascript' for='window' event='onload'>ShowTabs("&showid&");</script>"
 '生成公司编号
 Y=year(now())
 M=month(now())
 D=Day(now())
 H=hour(now())
 mi=minute(now())
 s=second(now())
 if M<10 then M="0"&M
 if D<10 then D="0"&D
 if H<10 then H="0"&H
 if mi<10 then mi="0"&mi
 if s<10 then s="0"&s
 '生成1-100随机数 
 Randomize() 
 n=Int((100-1+1)*Rnd(now())+1)
 mCo_Serialnumber=Y&M&D&H&mi&s&n
 '生成公司编号结束
 mCo_bumen=0
Call MyKehuEdit()
%>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  <form name="editForm" method="post" action="My_Companies_KehuEdit.Asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>&showid=<%=showid%>" onSubmit="return CheckKehuEdit()">
    <tr>
      <th height="22" sytle="line-height:150%">【<%If Result = "Add" then%>添加<%ElseIf Result = "Modify" then%>修改<%End If%>公司<%if Result = "Add" Then%> <font color="#999999">或者</font> <a href="My_people_KehuEdit.Asp?Result=Add&showid=0"><font color="#4579b9">添加联系人</font></a>
      <%end if%>】</th>
    </tr>
	<tr>
      <td class="forumRowHighlight">
	  <script language="javascript">
var tID=0;
function ShowTabs(ID){
  if(ID!=tID){
    TabTitle[tID].className="title5";
    TabTitle[ID].className="title6";
    Tabs[tID].style.display="none";
    Tabs[ID].style.display="";
    tID=ID;
  }
}
</script>
	  <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
        <tr align="center">
            <td id="TabTitle" class="title6" onclick="ShowTabs(0)">基本信息</td>
			<td id="TabTitle" class="title5" onclick="ShowTabs(1)">其它</td>
            
            
           
            <td>&nbsp;</td>
        </tr>
</table>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="1" class="border"><tr class="tdbg"><td valign="top">
  <table width="100%" align="center" cellpadding="2" cellspacing="1">
  <tbody id="Tabs" style="display:">
  <tr>
      <td width="20%" align="right" class="forumRow"></td>
      <td width="80%" class="forumRowHighlight"><input name="MemName" type="hidden" id="MemName" style="width: 120;background-color:#EBF2F9" value="<%=session("UserName")%>" maxlength="16" <%response.write ("readonly")%>>
	  <input name="RealName" type="hidden" id="RealName" style="width: 120;background-color:#EBF2F9" value="<%=genjinText(session("UserName"))%>" maxlength="16" <%response.write ("readonly")%>>
	 <!--公司编号-->
     <input name="Co_Serialnumber" type="hidden" id="Co_Serialnumber" style="width: 120" value="<%=mCo_Serialnumber%>" maxlength="18" readonly="readonly"> 
     
	  </td>
    </tr>
	<tr>
      <td align="right" class="forumRow">公司名称：</td>
      <td class="forumRowHighlight"><input name="Co_name" type="text" id="Co_name" style="width: 280" value="<%=mCo_name%>" maxlength="249">
        <font class="redy">*</font> 
	  &nbsp;</td>
	</tr>
    <tr>
      <td align="right" class="forumRow">法人代表：</td>
      <td class="forumRowHighlight"><input name="Co_Legalperson" type="text" id="Co_Legalperson" style="width: 120" value="<%=mCo_Legalperson%>" maxlength="50"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">注册资金：</td>
      <td class="forumRowHighlight"><input name="Co_Capital" type="text" id="Co_Capital" style="width: 120" value="<%=mCo_Capital%>" maxlength="50"> (如：100万)</td>
    </tr>
    <tr>
      <td align="right" class="forumRow">人 数：</td>
      <td class="forumRowHighlight"><input name="Co_ren" type="text" id="Co_ren" style="width: 120" value="<%=mCo_ren%>" maxlength="50"> (如：20-30人或30人)</td>
    </tr>
    <tr>
      <td align="right" class="forumRow">部门数量：</td>
      <td class="forumRowHighlight"><input name="Co_bumen" type="text" id="Co_bumen" style="width: 120" value="<%=mCo_bumen%>" maxlength="50"> (请输入数字)</td>
    </tr>
    <tr>
      <td align="right" class="forumRow">培训主管：</td>
      <td class="forumRowHighlight"><input name="Co_pxzg" type="text" id="Co_pxzg" style="width: 120" value="<%=mCo_pxzg%>" maxlength="50"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">技术主管：</td>
      <td class="forumRowHighlight"><input name="Co_jszg" type="text" id="Co_jszg" style="width: 120" value="<%=mCo_jszg%>" maxlength="50"></td>
    </tr>
        <tr>
      <td align="right" class="forumRow">电话(总机)：</td>
      <td class="forumRowHighlight"><input name="Co_tel" type="text" id="Co_tel" style="width: 120" value="<%=mCo_tel%>" maxlength="50"></td>
    </tr>
	
    <tr>
      <td align="right" class="forumRow">传真号码：</td>
      <td class="forumRowHighlight"><input name="Co_fax" type="text" id="Co_fax" style="width: 120" value="<%=mCo_fax%>" maxlength="16"></td>
    </tr>
	<tr>
      <td align="right" class="forumRow">电子信箱：</td>
      <td class="forumRowHighlight"><input name="Co_email" type="text" id="Co_email" style="width: 280" value="<%=mCo_email%>" maxlength="50"></td>
    </tr>
	
	<tr>
      <td align="right" class="forumRow">地 址：</td>
      <td class="forumRowHighlight"><input name="Co_address" type="text" id="Co_address" style="width: 280" value="<%=mCo_address%>" maxlength="100"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">邮政编码：</td>
      <td class="forumRowHighlight"><input name="Co_zipcode" type="text" id="Co_zipcode" style="width: 120" value="<%=mCo_zipcode%>" maxlength="16"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">网 址：</td>
      <td class="forumRowHighlight"><input name="Co_url" type="text" id="Co_url" style="width: 280" value="<%=mCo_url%>" maxlength="50"></td>
    </tr>
	
	
    
    <tr>
      <td align="right" class="forumRow">背景信息：<br />简介，如何认识的等。 </td>
      <td class="forumRowHighlight">
	    <textarea name="Co_Demo" cols="50" rows="8" id="Co_Demo" style="width: 280"><%=mCo_Demo%></textarea></td>
    </tr>
    
  </tbody>
  <tbody id="Tabs" style="display:none">
    <tr>
      <td width="20%" align="right" class="forumRow">&nbsp;</td>
      <td width="80%" class="forumRowHighlight">&nbsp;</td>
    </tr>
    <tr>
      <td width="20%" align="right" class="forumRow">&nbsp;</td>
      <td width="80%" class="forumRowHighlight">&nbsp;</td>
    </tr>
  </tbody>
  
  
  <tbody id="Tabs" style="display:none">
    <tr>
      <td width="20%" align="right" class="forumRow">&nbsp;</td>
      <td width="80%" class="forumRowHighlight">&nbsp;</td>
    </tr>
  </tbody>

  </table>
</td>
</tr>
</table>
	  </td>
    </tr>
    	
    <tr>
      <td class="forumRowHighlight" align="center"><input name="submitSaveEdit" type="submit" id="submitSaveEdit" value="保存"> <input type="button" value="返回上一页" onclick="history.back(-1)"></td>
    </tr>
  </form>
</table>

<%
Sub MyKehuEdit()
    Dim Action, rs, sql
    Action = request.QueryString("Action")
    If Action = "SaveEdit" Then
        Set rs = server.CreateObject("adodb.recordset")
        If Result = "Add" Then
		    If Trim(Request.Form("Co_Serialnumber"))<>"" Then
			   If Not conn.Execute("select * from Zqj_Company where Co_Serialnumber='" & Trim(Request.Form("Co_Serialnumber")) & "'").EOF Then
			    response.Write "<script language='javascript'>alert('添加失败！');history.back(-1);</script>"
				response.End
			   end if
			else
			    response.Write "<script language='javascript'>alert('编号生成失败！');history.back(-1);</script>"
				response.End
			end if
            If Not conn.Execute("select * from Zqj_Company where Co_name='" & Trim(Request.Form("Co_name")) & "' and MemName='"&session("UserName")&"'").EOF Then
                response.Write "<script language='javascript'>alert('公司[" & Trim(Request.Form("Co_name")) & "]已经存在！');history.back(-1);</script>"
                response.End
            End If
            sql = "select * from Zqj_Company"
            rs.Open sql, conn, 1, 3
            rs.addnew
            rs("MemName") = Trim(Request.Form("MemName"))
            rs("RealName") = Trim(Request.Form("RealName"))
			rs("Co_Serialnumber")=Trim(Request.Form("Co_Serialnumber"))
            rs("Co_name") = StrReplace(Trim(Request.Form("Co_name")))
			rs("Co_Legalperson")=StrReplace(Trim(Request.Form("Co_Legalperson")))
			rs("Co_Capital")=StrReplace(Trim(Request.Form("Co_Capital")))
			rs("Co_ren")=StrReplace(Trim(Request.Form("Co_ren")))
			rs("Co_bumen")=StrReplace(Trim(Request.Form("Co_bumen")))
			rs("Co_pxzg")=StrReplace(Trim(Request.Form("Co_pxzg")))
			rs("Co_jszg")=StrReplace(Trim(Request.Form("Co_jszg")))
			rs("Co_tel")=Trim(Request.Form("Co_tel"))
			rs("Co_fax") = StrReplace(Trim(Request.Form("Co_fax")))
			rs("Co_email") = Trim(Request.Form("Co_email"))
            rs("Co_address") = StrReplace(Trim(Request.Form("Co_address")))
            rs("Co_zipcode") = StrReplace(Trim(Request.Form("Co_zipcode")))
			rs("Co_url") = StrReplace(Trim(Request.Form("Co_url")))
			rs("Co_Demo")=Trim(Request.Form("Co_Demo"))
			rs("Co_AddTime")=now()
			rs("Co_Updatime")=now()
            rs.update
            rs.Close
            Set rs = Nothing
            response.Write "<script language='javascript'>alert('设置成功！');location.replace('My_Companies_KehuList.Asp');</script>"          
        End If
        If Result = "Modify" Then
            sql = "select * from Zqj_Company where Co_ID="&ID
            rs.Open sql, conn, 1, 3
            rs("RealName") = StrReplace(Trim(Request.Form("RealName")))
            rs("Co_name") = StrReplace(Trim(Request.Form("Co_name")))
			rs("Co_Legalperson")=StrReplace(Trim(Request.Form("Co_Legalperson")))
			rs("Co_Capital")=StrReplace(Trim(Request.Form("Co_Capital")))
			rs("Co_ren")=StrReplace(Trim(Request.Form("Co_ren")))
			rs("Co_bumen")=StrReplace(Trim(Request.Form("Co_bumen")))
			rs("Co_pxzg")=StrReplace(Trim(Request.Form("Co_pxzg")))
			rs("Co_jszg")=StrReplace(Trim(Request.Form("Co_jszg")))
			rs("Co_tel") = StrReplace(Trim(Request.Form("Co_tel")))
			rs("Co_fax") = StrReplace(Trim(Request.Form("Co_fax")))
			rs("Co_email") = Trim(Request.Form("Co_email"))
			rs("Co_url") = StrReplace(Trim(Request.Form("Co_url")))
			rs("Co_address") = StrReplace(Trim(Request.Form("Co_address")))
			rs("Co_zipcode") = StrReplace(Trim(Request.Form("Co_zipcode")))
			rs("Co_Demo")=Trim(Request.Form("Co_Demo"))
			rs("Co_Updatime")=now()
            rs.update
            rs.Close
           Set rs = Nothing
		   response.Redirect("My_Companies_KehuView.Asp?Result=Modify&ID="&ID&"&showid="&showid)
           			
        End If

    Else
        If Result = "Modify" Then
            Set rs = server.CreateObject("adodb.recordset")
            sql = "select * from Zqj_Company where MemName='"&session("UserName")&"' and Co_ID="& ID
            rs.Open sql, conn, 1, 1
			if rs.bof and rs.eof then
			response.Write "<script language='javascript'>alert('参数错误！');history.back(-1);</script>"
			response.End
			else
            mMemName = rs("MemName")
            mRealName = rs("RealName")
			mCo_Serialnumber=rs("Co_Serialnumber")
            mCo_name = rs("Co_name")
			mCo_Legalperson=rs("Co_Legalperson")
			mCo_Capital=rs("Co_Capital")
			mCo_ren=rs("Co_ren")
			mCo_bumen=rs("Co_bumen")
			mCo_pxzg=rs("Co_pxzg")
			mCo_jszg=rs("Co_jszg")
            mCo_tel = rs("Co_tel")
            mCo_fax = rs("Co_fax")
			mCo_email=rs("Co_email")
            mCo_url = rs("Co_url")
            mCo_address = rs("Co_address")
            mCo_zipcode = rs("Co_zipcode")
            mCo_Demo = rs("Co_Demo")
            mCo_AddTime = rs("Co_AddTime")
			end if
            rs.Close
            Set rs = Nothing
        End If
    End If
End Sub

Sub SelectGroup()
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select GroupID,GroupName from Zqj_MemGroup order by ID DESC"
    rs.Open sql, conn, 1, 1
    If rs.bof And rs.EOF Then
        response.Write("未设组别")
    End If
    While Not rs.EOF
        response.Write("<option value='"&rs("GroupID")&"┎╂┚"&rs("GroupName")&"'")
        If mGroupID = rs("GroupID") Then response.Write ("selected")
        response.Write(">"&rs("GroupName")&"</option>")
        rs.movenext
    Wend
    rs.Close
    Set rs = Nothing
End Sub

Function SortText(ID)
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From Zqj_KehuSort where ID="& ID
    rs.Open sql, conn, 1, 1
	if rs.bof and rs.eof then
	SortText="未分类"
	else
    SortText = rs("SortName")
	end if
    rs.Close
    Set rs = Nothing
End Function

Function genjinText(MemName)
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From Zqj_Members where MemName='"&MemName&"'"
    rs.Open sql, conn, 1, 1
	if rs.bof and rs.eof then
	genjinText="无跟进人"
	else
    genjinText = rs("RealName")
	end if
    rs.Close
    Set rs = Nothing
End Function
%>