

<script language="javascript" type="text/javascript">
<!--
function disableOtherSubmit()

{ //var obj = event.srcElement;
var objs = document.getElementsByTagName('input');
for(var i=0; i<objs.length; i++)

{
nms=objs[i].type.toLowerCase();
if((nms == 'submit')||(nms == 'reset')||(nms == 'button'))

{
objs[i].disabled = true;
}
}
}
//-->
</script>
<script language="javascript" type="text/javascript">
<!--

function moveOption(e1, e2)
{

try
{
var flag=0;//1表示已经有了这个选项

for(var h=0;h<e2.options.length;h++)
{
if(e1.value==e2.options[h].value)

{
flag=1
return false;
}
}
for(var i=0;i<e1.options.length;i++)

{
if(e1.options[i].selected)

{
var e = e1.options[i];
if(flag==0)
e2.options.add(new Option(e.text, e.value));
e1.remove(i);
i=i-1
}
}
document.getElementById('city').value=getvalue(document.getElementById('list2'));
}

catch(e)
{}
}

function DelOption(e1, e2)
{

try
{

for(var i=0;i<e1.options.length;i++)
{

if(e1.options[i].selected)
{
var e = e1.options[i];
e2.options.add(new Option(e.text, e.value));
e1.remove(i);
i=i-1
}
}
document.getElementById('city').value=getvalue(document.getElementById('list2'));
}

catch(e)
{}
}

function getvalue(geto)
{
var allvalue = "";

for(var i=0;i<geto.options.length;i++)
{
allvalue +=geto.options[i].value + ",";
}
return allvalue;
}
function changepos(obj,index)

{

if(index==-1)
{

if (obj.selectedIndex>0)
{
obj.options(obj.selectedIndex).swapNode(obj.options(obj.selectedIndex-1))
}
}

else if(index==1)
{

if (obj.selectedIndex<obj.options.length-1)
{
obj.options(obj.selectedIndex).swapNode(obj.options(obj.selectedIndex+1))
}
}
}
//以XML求取DropDownList2的数据
function XmlPost2(obj)

{
var svalue = obj.value;
var webFileUrl = "?conid=" + svalue;
var result = "";
var xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
xmlHttp.open("POST", webFileUrl, false);
xmlHttp.send("");
result = xmlHttp.responseText;
if(result != "")

{
document.all("ddlviseDept").length=0;
var piArray = result.split(",");
document.all("ddlviseDept").options[0]=new Option('请选择部门','0');
for(var i=0;i<piArray.length;i++)

{
var ary1 = piArray[i].toString().split("|");
document.all("ddlviseDept").options.add(new Option(ary1[1].toString(),ary1[0].toString()));
}
}
else

{
alert(result);
}
}
//以XML求取DropDownList3的数据
function XmlPost3(obj)

{
var svalue = obj.value;
var webFileUrl = "?deptid=" + svalue;
var result = "";
var xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
xmlHttp.open("POST", webFileUrl, false);
xmlHttp.send("");
result = xmlHttp.responseText;
if(result != "")

{
document.all("list1").length=0;
var piArray = result.split(",");
for(var i=0;i<piArray.length;i++)

{
var ary1 = piArray[i].toString().split("|");
document.all("list1").options.add(new Option(ary1[1].toString(),ary1[0].toString()));
}
}
else

{
alert(result);
}
}
//-->
</script>


<asp:DropDownList ID="ddlconames" runat="server" AppendDataBoundItems="True">
<asp:ListItem>请选择厂别</asp:ListItem>
</asp:DropDownList>
</td>
<td width="10%" valign="top" style="height: 195px">
<asp:DropDownList ID="ddlviseDept" runat="server" AppendDataBoundItems="True">
<asp:ListItem Value="">请选择部门</asp:ListItem>
</asp:DropDownList>
</td>
<td valign="top" style="height: 195px">
<table width="80%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="15%" valign="top">
<asp:ListBox ID="list1" SelectionMode="Multiple" ondblclick="moveOption(document.getElementById('list1'),document.getElementById('list2'))" runat="server" Width="90px" Rows="10"/></td>
<td width="9%" align="center" valign="middle">
<input type="button" value="添加" onClick="moveOption(document.getElementById('list1'),document.getElementById('list2'))"/><br/><br/>
<input type="button" value="删除" onClick="DelOption(document.getElementById('list2'),document.getElementById('list1'))"/><br/><br/>
<input id="Button3" onClick="changepos(list2,-1)" type="button" value="上移" /><br/><br/>
<input id="Button4" onClick="changepos(list2,1)" type="button" value="下移" />
</td>
<td width="76%" valign="top">
<asp:ListBox ID="list2" SelectionMode="Multiple" ondblclick="DelOption(document.getElementById('list2'),document.getElementById('list1'))" runat="server" Width="90px" Rows="10"/></td>
</tr>
</table>
<asp:HiddenField ID="city" runat="server" />
</td>
</tr>
</table>


protected void Page_Load(object sender, EventArgs e)

{
this.GetPostBackEventReference(this.btnSubmit);
if (!IsPostBack)

{
InitTree();
DisBtn();
BinPTNameList();
BinData();
this.ddlconames.Attributes.Add("onchange", "XmlPost2(this);");
this.ddlviseDept.Attributes.Add("onchange", "XmlPost3(this);");
}
if (conid != "")

{
this.DeptViseList(conid);
}
if (deptid != "")

{
this.UserViseList(deptid);
}
}
-----------------------------------------------
private void DeptViseList(string strconid)//部门

{
string mystr = "";
WebClass.UserList tmp = new WebClass.UserList();
DataTable dt=tmp.ListConDept(strconid);

if (dt.Rows.Count != 0)

{
for (int i = 0; i < dt.Rows.Count; i++)

{
mystr += "," + dt.Rows[i][0].ToString() + "|" + dt.Rows[i][1].ToString();
}
mystr = mystr.Substring(1);
}
this.Response.Write(mystr);
this.Response.End();
}
private void UserViseList(string strdeptid)//用户

{
string mystr = "";
WebClass.UserList tmp = new WebClass.UserList();
DataTable dt = tmp.ListDeptUsers(strdeptid);

if (dt.Rows.Count != 0)

{
for (int i = 0; i < dt.Rows.Count; i++)

{
mystr += "," + dt.Rows[i][0].ToString() + "|" + dt.Rows[i][1].ToString();
}
mystr = mystr.Substring(1);
}
this.Response.Write(mystr);
this.Response.End();
}
private string conid

{
get

{
if (ViewState["conid"] != null && ViewState["conid"].ToString() != "")

{
return ViewState["conid"].ToString();
}
else

{
if (Request["conid"] != null && Request["conid"].ToString() != "")

{
return Request["conid"];
}
else

{
return "";
}
}
}
set

{
ViewState["conid"] = value;
}
}
private string deptid

{
get

{
if (ViewState["deptid"] != null && ViewState["deptid"].ToString() != "")

{
return ViewState["deptid"].ToString();
}
else

{
if (Request["deptid"] != null && Request["deptid"].ToString() != "")

{
return Request["deptid"];
}
else

{
return "";
}
}
}
set

{
ViewState["deptid"] = value;
}
}
-----------------------------------------------
private void DeptData(string strdir_id, string strdept_id,string strUserID, string strcon_id)

{
WebClass.UserList tmp = new WebClass.UserList();
this.ddldept.DataSource = tmp.ListConDept(strcon_id);
//this.ddlusers.Items.Clear();
//this.ddldirect_users.Items.Clear();
this.ddldept.DataTextField = "deptname";
this.ddldept.DataValueField = "id";
this.ddldept.DataBind();
ListItem le = new ListItem();
le.Value = "";
le.Text = "请选择单位";
//le.Selected = true;
this.ddldept.Items.Insert(0, le);
WebOne.SetSelectedItem(this.ddldept, strdept_id);

this.ddlusers.DataSource = tmp.ListConDeptUsers(strcon_id,strdept_id);
//this.ddldirect_users.Items.Clear();
this.ddlusers.DataTextField = "username";
this.ddlusers.DataValueField = "id";
this.ddlusers.DataBind();
ListItem le1 = new ListItem();
le1.Value = "";
le1.Text = "请选择产品工程师";
//le1.Selected = true;
this.ddlusers.Items.Insert(0, le1);
WebOne.SetSelectedItem(this.ddlusers, strUserID);

//ListItem le1 = new ListItem();
//le1.Value = "";
//le1.Text = "请选择产品工程师";

/**/////le1.Selected = true;
//this.ddlusers.Items.Insert(0, le1);

//厂别
this.ddlconames.DataSource = tmp.ListComps();
this.ddlconames.DataTextField = "names";
this.ddlconames.DataValueField = "id";
this.ddlconames.DataBind();
}
//private void SeleData()
//{
// WebClass.ECRApprove tmp = new WebClass.ECRApprove();
// gvdeptusers.DataSource = tmp.ShowDeptUser();
// gvdeptusers.DataBind();
// WebOne.GroupRows(gvdeptusers, 0);
// WebOne.GroupRows(gvdeptusers, 1);
//}
protected void ddldept_SelectedIndexChanged(object sender, EventArgs e)

{
string strdept=this.ddldept.SelectedValue;
if (strdept == "")

{
Response.Write("请选择单位");
Response.End();
return;
}
WebClass.UserList tmp = new WebClass.UserList();
this.ddlusers.DataSource = tmp.ShowDeptUsers(strdept);
//this.ddldirect_users.Items.Clear();
this.ddlusers.DataTextField = "username";
this.ddlusers.DataValueField = "id";
this.ddlusers.DataBind();
ListItem le1 = new ListItem();
le1.Value = "";
le1.Text = "请选择产品工程师";
//le1.Selected = true;
this.ddlusers.Items.Insert(0, le1);
}