Пример #1
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            if (Body.IsQueryExists("Delete") && Body.IsQueryExists("DepartmentIDCollection"))
            {
                var departmentIdArrayList = TranslateUtils.StringCollectionToIntList(Body.GetQueryString("DepartmentIDCollection"));
                foreach (var departmentId in departmentIdArrayList)
                {
                    BaiRongDataProvider.DepartmentDao.Delete(departmentId);
                }
                SuccessMessage("成功删除所选部门");
            }
            else if (Body.IsQueryExists("DepartmentID") && (Body.IsQueryExists("Subtract") || Body.IsQueryExists("Add")))
            {
                var departmentId = Body.GetQueryInt("DepartmentID");
                var isSubtract   = Body.IsQueryExists("Subtract");
                BaiRongDataProvider.DepartmentDao.UpdateTaxis(departmentId, isSubtract);

                PageUtils.Redirect(GetRedirectUrl(departmentId));
                return;
            }

            if (!IsPostBack)
            {
                BreadCrumbAdmin(AppManager.Admin.LeftMenu.AdminConfiguration, "所属部门管理", AppManager.Admin.Permission.AdminConfiguration);

                ClientScriptRegisterClientScriptBlock("NodeTreeScript", DepartmentTreeItem.GetScript(EDepartmentLoadingType.ContentList, null));

                if (Body.IsQueryExists("CurrentDepartmentID"))
                {
                    _currentDepartmentId = Body.GetQueryInt("CurrentDepartmentID");
                    var onLoadScript = GetScriptOnLoad(_currentDepartmentId);
                    if (!string.IsNullOrEmpty(onLoadScript))
                    {
                        ClientScriptRegisterClientScriptBlock("NodeTreeScriptOnLoad", onLoadScript);
                    }
                }

                AddChannel.Attributes.Add("onclick", ModalDepartmentAdd.GetOpenWindowStringToAdd(GetRedirectUrl(0)));

                Delete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(PageUtils.GetAdminUrl(nameof(PageDepartment), new NameValueCollection
                {
                    { "Delete", "True" }
                }), "DepartmentIDCollection", "DepartmentIDCollection", "请选择需要删除的部门!", "此操作将删除对应部门以及所有下级部门,确认删除吗?"));

                BindGrid();
            }
        }
Пример #2
0
        public static string GetDepartmentRowHtml(DepartmentInfo departmentInfo, EDepartmentLoadingType loadingType, NameValueCollection additional)
        {
            var treeItem = DepartmentTreeItem.CreateInstance(departmentInfo);
            var title    = treeItem.GetItemHtml(loadingType, additional, false);

            var rowHtml = string.Empty;

            if (loadingType == EDepartmentLoadingType.AdministratorTree || loadingType == EDepartmentLoadingType.DepartmentSelect || loadingType == EDepartmentLoadingType.ContentTree)
            {
                rowHtml = $@"
<tr treeItemLevel=""{departmentInfo.ParentsCount + 1}"">
	<td nowrap>{title}</td>
</tr>
";
            }
            else if (loadingType == EDepartmentLoadingType.ContentList)
            {
                string editUrl = $@"<a href=""javascript:;"" onclick=""{ModalDepartmentAdd.GetOpenWindowStringToEdit(
                    departmentInfo.DepartmentId, GetRedirectUrl(departmentInfo.DepartmentId))}"">编辑</a>";

                var urlUp = PageUtils.GetAdminUrl(nameof(PageDepartment), new NameValueCollection
                {
                    { "Subtract", "True" },
                    { "DepartmentID", departmentInfo.DepartmentId.ToString() }
                });
                string upLink = $@"<a href=""{urlUp}""><img src=""../Pic/icon/up.gif"" border=""0"" alt=""上升"" /></a>";

                var urlDown = PageUtils.GetAdminUrl(nameof(PageDepartment), new NameValueCollection
                {
                    { "Add", "True" },
                    { "DepartmentID", departmentInfo.DepartmentId.ToString() }
                });
                string downLink = $@"<a href=""{urlDown}""><img src=""../Pic/icon/down.gif"" border=""0"" alt=""下降"" /></a>";

                string checkBoxHtml = $"<input type='checkbox' name='DepartmentIDCollection' value='{departmentInfo.DepartmentId}' />";

                rowHtml = $@"
<tr treeItemLevel=""{departmentInfo.ParentsCount + 1}"">
    <td>{title}</td>
    <td>&nbsp;{departmentInfo.Code}</td>
    <td class=""center"">{departmentInfo.CountOfAdmin}</td>
    <td class=""center"">{upLink}</td>
    <td class=""center"">{downLink}</td>
    <td class=""center"">{editUrl}</td>
    <td class=""center"">{checkBoxHtml}</td>
</tr>
";
            }
            else if (loadingType == EDepartmentLoadingType.GovPublicDepartment)
            {
                var publishmentSystemId = TranslateUtils.ToInt(additional["PublishmentSystemID"]);

                var returnUrl = PageGovPublicDepartment.GetRedirectUrl(publishmentSystemId, departmentInfo.DepartmentId);

                string editUrl = $@"<a href=""javascript:;"" onclick=""{ModalDepartmentAdd.GetOpenWindowStringToEdit(
                    departmentInfo.DepartmentId, returnUrl)}"">编辑</a>";

                var urlUp = PageUtils.GetWcmUrl(nameof(PageGovPublicDepartment), new NameValueCollection
                {
                    { "PublishmentSystemID", publishmentSystemId.ToString() },
                    { "DepartmentID", departmentInfo.DepartmentId.ToString() },
                    { "Subtract", true.ToString() }
                });
                string upLink = $@"<a href=""{urlUp}""><img src=""../Pic/icon/up.gif"" border=""0"" alt=""上升"" /></a>";

                var urlDown = PageUtils.GetWcmUrl(nameof(PageGovPublicDepartment), new NameValueCollection
                {
                    { "PublishmentSystemID", publishmentSystemId.ToString() },
                    { "DepartmentID", departmentInfo.DepartmentId.ToString() },
                    { "Add", true.ToString() }
                });
                string downLink = $@"<a href=""{urlDown}""><img src=""../Pic/icon/down.gif"" border=""0"" alt=""下降"" /></a>";

                string checkBoxHtml = $"<input type='checkbox' name='DepartmentIDCollection' value='{departmentInfo.DepartmentId}' />";

                rowHtml = $@"
<tr treeItemLevel=""{departmentInfo.ParentsCount + 1}"">
    <td>{title}</td>
    <td>&nbsp;{departmentInfo.Code}</td>
    <td class=""center"">{upLink}</td>
    <td class=""center"">{downLink}</td>
    <td class=""center"">{editUrl}</td>
    <td class=""center"">{checkBoxHtml}</td>
</tr>
";
            }
            return(rowHtml);
        }