模板列传值到子窗体中,子窗体中多选gridview中checkbox保存数据多项到数据库中

时间:2023-03-08 21:09:05
模板列传值到子窗体中,子窗体中多选gridview中checkbox保存数据多项到数据库中
 <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title> <script src="../../../Scripts/jquery.js" type="text/javascript" language="javascript"></script> <script src="../../../Scripts/jquery.foe.common.js" type="text/javascript"></script> <script src="../../../Scripts/jquery.foe.utils.js" type="text/javascript"></script> <script type="text/javascript" language="javascript">
function openpage(GroupID) {
OpenPage('Sys_UserGroupPermissionEmployeeInfo.aspx?GroupID=' + GroupID + '', '人员管理', '','');
}
function openwin(groupID) {
OpenPage('Sys_UserGroupPermissionInfo.aspx?GroupID=' + groupID + '', '权限管理', '', '');
}
</script> </head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="scriptManager" runat="server">
</telerik:RadScriptManager>
<table class="TableStyle">
<tr>
<th>
用户组名称:
</th>
<td>
<asp:TextBox ID="txtGroupName" runat="server" CssClass="Input">
</asp:TextBox>
</td>
<th>
用户组编码:
</th>
<td>
<asp:TextBox ID="txtGroupCode" runat="server" CssClass="Input"></asp:TextBox>
</td>
</tr>
</table>
<telerik:RadToolBar ID="toolBar" runat="server" Width="100%" OnButtonClick="toolBar_ButtonClick"
Height="22px">
<Items>
<telerik:RadToolBarButton Text="查询" ImageUrl="../../../Common/images/ToolBarIcons/search.png">
</telerik:RadToolBarButton>
</Items>
</telerik:RadToolBar>
<telerik:RadGrid AlternatingItemStyle-CssClass="AlterLine" ID="dgGroups" runat="server"
AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" PagerStyle-AlwaysVisible="true"
AllowCustomPaging="true" PagerStyle-Mode="NextPrevAndNumeric" OnNeedDataSource="dgGroups_NeedDataSource"
PageSize="">
<MasterTableView DataKeyNames="GroupID" ClientDataKeyNames="GroupID">
<Columns>
<telerik:GridBoundColumn HeaderText="用户组名称" DataField="GroupName">
<HeaderStyle Width="200px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="用户组编码" DataField="GroupCode">
<HeaderStyle Width="200px" />
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn>
<HeaderTemplate>
人员
</HeaderTemplate>
<ItemTemplate>
<a href="#" onclick='openpage(<%#Eval("GroupID") %>)'>点击查看</a>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn>
<HeaderTemplate>
权限
</HeaderTemplate>
<ItemTemplate>
<a href="#" onclick='openwin(<%#Eval("GroupID") %>)'>点击查看</a>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView> </telerik:RadGrid>
<asp:HiddenField ID="hfGroupID" runat="server" />
</form>
</body>
</html>
  private Org_UserGroupBLL bll = new Org_UserGroupBLL();

         protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["groupName"] = string.Empty;
ViewState["groupCode"] = string.Empty;
} SetPager(this.dgGroups);
} protected void toolBar_ButtonClick(object sender, RadToolBarEventArgs e)
{
this.dgGroups.CurrentPageIndex = ;
ViewState["groupName"] = this.txtGroupName.Text;
ViewState["groupCode"] = this.txtGroupCode.Text;
this.dgGroups.Rebind();
} protected void dgGroups_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
int count = ;
this.dgGroups.DataSource = bll.GetGroups(this.dgGroups.CurrentPageIndex * this.dgGroups.PageSize, this.dgGroups.PageSize, ref count, (string)ViewState["groupName"], (string)ViewState["groupCode"]);
this.dgGroups.VirtualItemCount = count;
this.hfGroupID.Value = string.Empty;
}

后台代码

 <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title> <script src="../../../Scripts/jquery.js" type="text/javascript"></script> </head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadGrid AlternatingItemStyle-CssClass="AlterLine" ID="dgRoleUsers" runat="server"
AutoGenerateColumns="false" PageSize="" OnNeedDataSource="dgRoleUsers_NeedDataSource"
AllowPaging="true" AllowMultiRowSelection="true" AllowCustomPaging="true" PagerStyle-AlwaysVisible="true"
PagerStyle-Mode="NextPrevAndNumeric" Width="100%">
<MasterTableView ClientDataKeyNames="RelationID" DataKeyNames="RelationID">
<Columns>
<telerik:GridTemplateColumn HeaderText="部门" ItemStyle-Width="450px">
<ItemTemplate>
<%# GetDeparementFullName(Convert.ToInt32(Eval("UserID"))) %>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn HeaderText="姓名" DataField="UserName">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="true" />
</ClientSettings>
</telerik:RadGrid>
<asp:HiddenField ID="hfRoleID" runat="server" />
</form>
</body>
</html>

列表-前台页面

  private Org_Relation_UserToGroupBLL bll = new Org_Relation_UserToGroupBLL();

         protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.hfRoleID.Value = Convert.ToInt32(Request.QueryString["GroupID"]).ToString();
} int UserDepID = ;
if (CurrentUser.Project != null)
{
UserDepID = CurrentUser.Project.DepID;
}
else if (CurrentUser.SubCompany != null)
{
UserDepID = CurrentUser.SubCompany.DepID;
}
else
{
UserDepID = ;
} SetPager(this.dgRoleUsers);
}
protected void dgRoleUsers_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
Foe.Common.HelperClass.Pagination pa = new Foe.Common.HelperClass.Pagination();
pa.PageSize = this.dgRoleUsers.PageSize;
pa.PageIndex = dgRoleUsers.CurrentPageIndex + ; Foe.Model.Organization.Org_Relation_UserToGroup model = new Foe.Model.Organization.Org_Relation_UserToGroup();
model.GroupID = Convert.ToInt32(this.hfRoleID.Value); int UserDepID = ; if (CurrentUser.Project != null)
{
UserDepID = CurrentUser.Project.DepID;
}
else if (CurrentUser.SubCompany != null)
{
UserDepID = CurrentUser.SubCompany.DepID;
}
this.dgRoleUsers.DataSource = bll.GetListByPage(model, pa, UserDepID);
this.dgRoleUsers.VirtualItemCount = pa.TotalRecord;
} /// <summary>
/// 初始化用户部门全路径
/// </summary>
public string GetDeparementFullName(int userID)
{
Foe.BLL.Organization.Org Organizationll = new Foe.BLL.Organization.Org(); return Organizationll.GetFullPathByEmpID(userID); }

列表-后台代码

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title> <script src="../../../Scripts/jquery.js" type="text/javascript"></script> <script src="../../../Scripts/jquery.foe.common.js" type="text/javascript"></script> <script src="../../../Scripts/jquery.foe.utils.js" type="text/javascript"></script> <script type="text/javascript" language="javascript">
$(document).ready(function() {
$('#btnSave').click(function() {
var GroupId = $("#hidGroupId").val();
var check = $("input[type='checkbox']");
check.each(function() {
if ($(this).is(':checked')) {
var flowid = $(this).next('input:hidden[id*=hidID]').val();
if (flowid != "" && flowid != "undefined") {
SaveFlowInfo(GroupId, flowid);
}
else
{ return false; }
}
});
alert('保存成功');
opener.location.reload();
window.close();
});
}); function SaveFlowInfo(GroupId, flowid) {
$.ajax({
type: "post",
url: "Sys_UserGroupPermissionSaveFlowInfo.ashx?GroupId=" + escape(GroupId) + "&&FixedFlowID=" + escape(flowid),
dataType: "json",
contentType: "application/x-www-form-urlencoded; charset=utf-8",
success: function(data) {
if (data != null) {
return true; }
else {
return false;
}
}, error: function(XMLHttpRequest, textStatus, errorThrown) { return false; } }); } </script> </head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<div>
<telerik:RadGrid AlternatingItemStyle-CssClass="AlterLine" ID="dgManage" runat="server"
AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" PagerStyle-AlwaysVisible="true"
AllowMultiRowSelection="true" AllowCustomPaging="true" PagerStyle-Mode="NextPrevAndNumeric"
OnNeedDataSource="dgManage_NeedDataSource" PageSize="">
<MasterTableView DataKeyNames="FixedFlowID,FixedFlowTypeFullName" ClientDataKeyNames="FixedFlowID,FixedFlowTypeFullName">
<Columns>
<%--<telerik:GridClientSelectColumn UniqueName="FixedFlowID" />
--%>
<telerik:GridTemplateColumn HeaderText="选择" ItemStyle-Width="50px" HeaderStyle-Width="50px">
<ItemTemplate>
<input type="checkbox" id="ckhItem" runat="server" />
<asp:HiddenField ID="hidID" runat="server" Value='<%#Eval("FixedFlowID") %>' />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="50px" />
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn HeaderText="编号" DataField="FixedFlowID" Visible="false"
HeaderStyle-Width="80px" ItemStyle-Width="80px">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="流程名称" DataField="FixdeFlowName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="类别" DataField="FixedFlowTypeFullName">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="true" />
<Resizing AllowColumnResize="true" ResizeGridOnColumnResize="true" />
</ClientSettings>
<PagerStyle Mode="NextPrevAndNumeric" />
</telerik:RadGrid>
</div>
<div style="margin: 5px auto; width: 100%; text-align: center">
<input type="button" id="btnSave" value="保存" class="btn" />&nbsp;<input type="button"
value="关闭" class="btn" onclick="window.close()" />
</div>
<asp:HiddenField ID="hidFixedFlowID" runat="server" />
<asp:HiddenField ID="hidGroupId" runat="server" />
</form>
</body>
</html>

新增多项前台页面代码

 Foe._2B2C.Model.ModelTempTableFlow mode = new Foe._2B2C.Model.ModelTempTableFlow();

         protected void Page_Load(object sender, EventArgs e)
{
this.hidGroupId.Value = Request.QueryString["GroupID"];
if (!IsPostBack)
{
BindDataSource();
}
SetPager(this.dgManage);
} protected void dgManage_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
BindDataSource();
} protected void BindDataSource()
{
var pi = new Foe.Common.HelperClass.Pagination()
{
PageIndex = this.dgManage.CurrentPageIndex +
}; this.dgManage.DataSource = new Foe._2B2C.BLL.BLLTempTableFlow().GetList(mode, pi);
this.dgManage.VirtualItemCount = pi.TotalRecord;
}

新增后台代码