protected void Page_Load(object sender, EventArgs e) { if (fvOrganization.CurrentMode == FormViewMode.Insert) { if (hfInsert.Value == "-1") { ((HiddenField)fvOrganization.FindControl("hfParentId")).Value = Request.QueryString["id"]; } else { ((HiddenField)fvOrganization.FindControl("hfParentId")).Value = hfInsert.Value; } } string strDeleteID = Request.Form.Get("DeleteID"); if (strDeleteID != "" && strDeleteID != null) { OrganizationBLL objBll = new OrganizationBLL(); RailExam.Model.Organization organization = objBll.GetOrganization(Convert.ToInt32(strDeleteID)); int code = 0; string sqlStr = "select count(*) from item where org_id=" + strDeleteID; DataTable dt = new OracleAccess().RunSqlDataSet(sqlStr).Tables[0]; if (dt != null && Convert.ToInt32(dt.Rows[0][0]) > 0) { SessionSet.PageMessage = "该组织机构已被引用,不能删除!"; } else { objBll.DeleteOrganization(Convert.ToInt32(strDeleteID), ref code); if (code != 0) //code=2292 { SessionSet.PageMessage = "该组织机构已被引用,不能删除!"; } else { ClientScript.RegisterStartupScript(GetType(), "jsSelectFirstNode", @"window.parent.tvOrganizationChangeCallBack.callback(" + organization.ParentId + @", 'Delete'); if(window.parent.tvOrganization.get_nodes().get_length() > 0) { window.parent.tvOrganization.get_nodes().getNode(0).select(); }", true); } } } }
protected void OrganizationsRepeater_ItemCommand(object source, RepeaterCommandEventArgs e) { int organizationId = 0; try { organizationId = Convert.ToInt32(e.CommandArgument); } catch (Exception ex) { log.Error("Cannot convert e.CommandArgument to integer value", ex); } if (organizationId <= 0) { SystemMessages.DisplaySystemErrorMessage(Resources.Organization.MessageNoComplete); return; } if (e.CommandName == "ViewProjects") { Session["SEARCH_PARAMETER"] = "@organizationID " + organizationId.ToString(); Response.Redirect("~/Project/ProjectList.aspx"); return; } if (e.CommandName == "ViewActivities") { Session["SEARCH_PARAMETER"] = "@organizationID " + organizationId.ToString(); Response.Redirect("~/Activity/ActivitiesList.aspx"); return; } if (e.CommandName == "ViewKPIs") { Session["SEARCH_PARAMETER"] = "@organizationID " + organizationId.ToString(); Response.Redirect("~/Kpi/KpiList.aspx"); return; } if (e.CommandName == "ViewPersons") { Session["SEARCH_PARAMETER"] = "@organizationID " + organizationId.ToString(); Response.Redirect("~/Personas/ListaPersonas.aspx"); return; } if (e.CommandName == "DeleteOrganization") { try { OrganizationBLL.DeleteOrganization(organizationId); SystemMessages.DisplaySystemMessage(Resources.Organization.MessageDeleteOk); } catch (Exception ex) { SystemMessages.DisplaySystemErrorMessage(ex.Message); return; } BindOrganizations(); return; } if (e.CommandName == "EditOrganization") { Session["OrganizationId"] = organizationId; Response.Redirect("~/Organization/EditOrganization.aspx"); return; } if (e.CommandName == "ViewOrganization") { Session["OrganizationId"] = organizationId; Response.Redirect("~/Organization/OrganizationDetails.aspx"); } if (e.CommandName.Equals("ShareOrganization")) { Session["ORGANIZATIONID"] = organizationId; Response.Redirect("~/Organization/ShareOrganization.aspx"); } }