首页 新闻 搜索 专区 学院

服务器控件treeview如何实现异步的节点移动,跪求

0
悬赏园豆:200 [已解决问题] 解决于 2015-04-02 17:25

情况是这样的,现在的节点移动是通过更改sqlser语句,然后再从新查询刷新一遍实现,能不能做成异步的?跪求,在线等!

问题补充:

是.NET

这是移动节点的代码:

Config cf = new Config();
Config cfGetTable = new Config();
string newPaixuCode = string.Empty;
string newDepartCode;
DepartInfo dinfo = new DepartInfo(departCode);
if (!dinfo.IsGetData)
{
throw new Exception("没有找到要移动的单位");
}

try
{

String d = VBFunction.Left(parentCode, 6);
if (VBFunction.IsNumeric(d) && VBFunction.Right(parentCode, 2) == "00")
{
throw new Exception("该单位下面不能够有单位");

}
if (departCode.Length <= parentCode.Length && departCode == VBFunction.Left(parentCode, departCode.Length))
{
throw new Exception("不能将单位移动到他的子单位下面");

}
//
int tempRecordcount = 1;
cf.TranBegin();

// '更新排序
DataTable rs1 =
cfGetTable.GetTable("select * from zb_DepartBasicInfo where left(单位代码,len(单位代码)-4)='" + parentCode +
"' and len(单位代码)=" +
(parentCode.Length + 4).ToString() + " order by 排序");
if (rs1.Rows.Count > 0)
{
for (int i = 0; i < rs1.Rows.Count; i++)
{
// rs1!排序 = rs1.AbsolutePosition
// rs1.Update()
UpdateSque(rs1.Rows[i]["单位代码"].ToString(), IntToCode(i), cf);
cf.TranRunSql("update ZB_DepartBasicInfo set 排序=" + i + " where 单位代码='" + rs1.Rows[i]["单位代码"] + "'");
// rs1.MoveNext()
}
tempRecordcount = rs1.Rows.Count;
}

// '获得新的单位代码
// ExtendCode = GetNewDepartCode(parentCode, "DepartBasicInfo");
newDepartCode = GetNewDepartCode(parentCode);
//
//
//获得新的排序码
DataTable rs;
if (parentCode.Length == 6)
rs = cfGetTable.GetTable("select 排序 from zb_code where 行政区划代码='" + parentCode + "'");
else
rs = cfGetTable.GetTable("select 整体排序 as 排序 from zb_DepartBasicInfo where 单位代码='" + parentCode + "'");

if (rs != null)
newPaixuCode = rs.Rows[0]["排序"] + IntToCode(tempRecordcount);

//
// //判断单位是否重复
// rs =
// cfGetTable.GetTable ("select count(*) from zb_DepartBasicInfo where 单位名称='" + dinfo.DepartName
// + "' and 单位代码!='" + departCode +
// "' and left(单位代码,6) ='" + VBFunction.Left(parentCode, 6) + "'");
// if (VBFunction .CInt (rs.Rows[0].ToString())> 0)
// throw new Exception("在该地区已经存在该单位");
//

// '开始修改单位信息
cf.TranRunSql("update zb_DepartBasicInfo set 单位代码='" + newDepartCode + "' + Right(单位代码,len(单位代码)-" +
departCode.Length +
"), 排序='" + tempRecordcount + "', 整体排序= '" + newPaixuCode + "' + Right(整体排序,len(整体排序)-" +
departCode.Length +
"-1) where left(单位代码,len('" + departCode + "'))='" + departCode + "'");
for (int i = 1; i <= 16; i++)
cf.TranRunSql("update zb_gj" + i + " set 单位代码='" + newDepartCode + "' + Right(单位代码,len(单位代码)-" +
departCode.Length + ") where left(单位代码,len('" + departCode + "'))='" + departCode + "'");

// cf.RunSql ("update codeinfo set 单位代码='" & newDepartCode & "' & Right(单位代码,len(单位代码)-" & Len(LblDepartCode) & ") where left(单位代码,len('" & LblDepartCode & "'))='" & LblDepartCode & "'")
// ChangeDepartCode = newDepartCode
// WriteGrid(getSql(newDepartCode))
//
// FrmBasicInfo.TreeVeiwRefreah()
// FrmExBasicInfo.TreeVeiwRefreah()
//
// FrameMove.Visible = False
// MsgBox "移动操作完成后,请确认单位基本信息是否需要修改。若需要修改请进入“修改单位信息”窗口,进行修改!"
// Exit Sub
//Errorend:
// MsgBox(err.Description)
cf.TranEnd();
}
catch (Exception ex)
{
cf.TranRollback();
throw (ex);
}

浮生丶若梦灬的主页 浮生丶若梦灬 | 初学一级 | 园豆:3
提问于:2015-04-01 16:23
< >
分享
最佳答案
1

把这个treeview 放进updatePanel控件里。

收获园豆:200
Firen | 大侠五级 |园豆:5483 | 2015-04-01 17:33

能稍微详细的说一下嘛?那这些后台的代码呢,不用动还是?

浮生丶若梦灬 | 园豆:3 (初学一级) | 2015-04-01 20:10

@浮生丶若梦灬: 如果你是webform页面。有个控件叫updatePanel.你把treeView外面套上updatePanel就行了。

Firen | 园豆:5483 (大侠五级) | 2015-04-01 21:05

@Firen: 恩恩,我在网上看教程了,但是我自己新建的页面有用,放到那个项目里边就没效果了。。你能帮我看一下那个代码吗?

浮生丶若梦灬 | 园豆:3 (初学一级) | 2015-04-01 21:07

@浮生丶若梦灬: 项目里的framework是什么版本的?

Firen | 园豆:5483 (大侠五级) | 2015-04-01 21:09

@Firen: IIS的framework也要设置到相应版本。

Firen | 园豆:5483 (大侠五级) | 2015-04-01 21:10

@Firen: 大哥,那个怎么看。。新手表示没找到。。

浮生丶若梦灬 | 园豆:3 (初学一级) | 2015-04-01 21:17

@Firen: 不过这个项目好像是05年左右的。。

浮生丶若梦灬 | 园豆:3 (初学一级) | 2015-04-01 21:17

@Firen: 大哥,还在吗?

浮生丶若梦灬 | 园豆:3 (初学一级) | 2015-04-01 21:38

@浮生丶若梦灬: 05年的时候应该是framework2.0 你只要升级到3.5以上就行了。

Firen | 园豆:5483 (大侠五级) | 2015-04-02 10:07

@Firen: 现在显示是4.0

浮生丶若梦灬 | 园豆:3 (初学一级) | 2015-04-02 10:36

@Firen: 

<div id="zhezhao">
<table id="Table4" WIDTH=1000 style=" BORDER-COLLAPSE: collapse; BORDER-TOP-STYLE: none; TABLE-LAYOUT: fixed"
cellSpacing="0" cellPadding="0" align="center" border="0">
<tr>
<td width="30%" valign="top" height="100%">
<table width="100%">
<tr>
<td width="100%">
<INPUT id="txtSearchStr" name="Text1"
onkeypress=" if(event.keyCode==13){event.keyCode=9; document.getElementById('btnSearch').click(); return;}"
runat="server"><INPUT id="btnSearch" type="button" value="查找单位" name="Button1" runat="server" onserverclick="btnSearch_ServerClick">
<DIV style="WIDTH:290px; ; HEIGHT:expression(document.getElementById('right')?document.getElementById('right').offsetHeight:0); OVERFLOW:scroll" id="divtop">
<asp:ScriptManager ID="ScriptManager1" runat="server" >
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Always" RenderMode="Block">
<ContentTemplate>
<asp:TreeView ID="TreeView1" runat="server" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" style="overflow:auto;" ForeColor="Black" ImageSet="Arrows" ShowLines="True" SelectedNodeStyle-Font-Bold="true" AllowDrop="True" >
</asp:TreeView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSaveMoveDepart" />
<asp:PostBackTrigger ControlID="btnCancelMoveDepart" />
</Triggers>
</asp:UpdatePanel>
</DIV>
</td>
</tr>
<tr>
<td><asp:hyperlink id="LinkDepartInfo" runat="server">该单位已经提交修改申请,详情请点击</asp:hyperlink></td>
</tr>
</table>
<input type="hidden" runat="server" id="divScrollValue" value="" />
<input type="hidden" runat="server" id="divScrollValue2" value="" />
</td>
<td style="width: 70%" valign=top>
<table width="99%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="height: 58px; width: 701px;">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" style="HEIGHT: 22px"><INPUT id="BtnAddNewDep" type="button" value="添加单位" name="Button1" runat="server" onserverclick="BtnAddNewDep_ServerClick"><INPUT id="BtnSave" onclick="return Check()" type="submit" value="确定" class="submit"
name="Submit1" runat="server" onserverclick="BtnSave_ServerClick"><INPUT id="BtnDel" onclick="return DelCheck()" type="submit" value="删除"
name="Submit1" runat="server" onserverclick="BtnDel_ServerClick"><INPUT style="Z-INDEX: 0" id="btnMoveDepart" value="移动单位" type="button"
name="Button1" runat="server" onserverclick="btnMoveDepart_ServerClick"><%--<input type="button" id="MoveUp" onserverclick="MoveUp_ServerClick" runat="server" value="上移单位" /><input type="button" id="MoveDown" onserverclick="MoveDown_ServerClick" value="下移单位" />--%><INPUT style="Z-INDEX: 0" id="btnGetBack" onclick="return RescueCheck();"
value="还原单位" type="submit" name="btnGetBack" runat="server" onserverclick="btnGetBack_ServerClick"><INPUT style="Z-INDEX: 0" id="mod" value="修改" type="button" runat="server" onserverclick="mod_ServerClick"><INPUT style="Z-INDEX: 0" id="btnGetDepartFromPS" value="从单机版导入单位" type="submit"
name="btnGetDepartFromPS" runat="server" onserverclick="btnGetDepartFromPS_ServerClick"></td>
</tr>
<TR>
<TD><asp:button id="tree" runat="server" style="DISPLAY:none" Text="导出单位树" onclick="tree_Click"></asp:button><INPUT id="Submit1" style="display:none;WIDTH: 88px; HEIGHT: 20px" onclick="return departin()"
type="submit" value="从上年导入单位" name="Submit1" runat="server" onserverclick="Submit1_ServerClick"><asp:button id="danwei" runat="server" Text="导出下级单位注册信息" Width="148px" onclick="danwei_Click"></asp:button><%--<input type="button" id="danwei" runat="server" value="导出下级菜单注册信息" style="width:148px;" onserverclick="danwei_Click" />--%>
<INPUT id="btnIn" style="WIDTH: 96px; HEIGHT: 20px" type="button" value="从Excel导入单位"
name="Button1" runat="server" onserverclick="btnIn_ServerClick">
<asp:label id="LblInfo" runat="server"></asp:label></TD>
</TR>
</table>
</td>
</tr>
<tr>
<td style="POSITION:relative; width: 701px;">
<div id="layMoveDepart" style="Z-INDEX:2000; POSITION:absolute; WIDTH:250px; HEIGHT:172px; TOP:155px; LEFT:32px"
runat="server">
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0" style="BORDER-BOTTOM: #3777c7 1px solid; BORDER-LEFT: #3777c7 1px solid; FONT-SIZE: 14px; BORDER-TOP: #3777c7 1px solid; FONT-WEIGHT: bold; BORDER-RIGHT: #3777c7 1px solid; TEXT-DECORATION: none">
<tr>
<td valign="top" background="images/beijing.jpg">
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="TABLE3" runat="server"
style="BORDER-BOTTOM: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; BORDER-RIGHT: #ffffff 1px solid">
<tr>
<td height="30" align="center" bgcolor="#71a0e8" style="COLOR: #ffffff;FONT-SIZE: 14px;FONT-WEIGHT: normal;TEXT-DECORATION: none">移动单位</td>
</tr>
<tr>
<td height="30" style="COLOR: #456fcf;FONT-SIZE: 12px;FONT-WEIGHT: normal;TEXT-DECORATION: none">需要移动的单位:<asp:label style="Z-INDEX: 0" id="lblMoveEd" ForeColor="#ff6666" runat="server"></asp:label></td>
</tr>
<tr>
<td height="30" style="COLOR: #456fcf;FONT-SIZE: 12px;FONT-WEIGHT: normal;TEXT-DECORATION: none">将单位移动到:<asp:label style="Z-INDEX: 0" id="lblMoveTo" ForeColor="#ff6666" runat="server">点击左侧单位树,选择单位</asp:label></td>
</tr>
<tr>
<td align="center"><asp:TextBox id="txtMoveTo" style="DISPLAY:none" runat="server"></asp:TextBox>
<INPUT style="Z-INDEX: 0" value="确定" type="button" id="btnSaveMoveDepart" runat="server"
onserverclick="btnSaveMoveDepart_ServerClick"> <INPUT style="Z-INDEX: 0" id="btnCancelMoveDepart" value="取消" type="button" name="Button1"
runat="server" onserverclick="btnCancelMoveDepart_ServerClick">
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>

 

麻烦看下,这段代码我加的updatapanel位置对吗?

浮生丶若梦灬 | 园豆:3 (初学一级) | 2015-04-02 10:38

@浮生丶若梦灬: 你调试下看看对不对不就行了…

Firen | 园豆:5483 (大侠五级) | 2015-04-02 11:12
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册