protected void DeReactiveProjects(object sender, EventArgs e) { if (dd_user.Items.Count > 0 && dd_user.SelectedItem != null) { String UserID = dd_user.SelectedItem.Value; int NumReactivated = 0; bool Reactivating = btn_dereactivate_projects.Text.Contains("Reactivate"); foreach (GridDataItem item in rg_user_projects.Items) { if (((CheckBox)item["Selected"].FindControl("cb_selected")).Checked) { String ProjectID = item["ProjectID"].Text; LeadsUtil.ReactivateOrDeactivateProject(ProjectID, UserID, Reactivating); NumReactivated++; } } BindProjectList(null, null); String Action = "Reactivated"; if (!Reactivating) { Action = "Deactivated"; } if (NumReactivated == 0) { Util.PageMessageAlertify(this, "No Projects selected, select some using the checkboxes to the right of the Project list!", "No Projects Selected", ram); } else { Util.PageMessageSuccess(this, "Project(s) " + Action + "!", Action + "!"); } } }
protected void DeactivateProject(object sender, EventArgs e) { if ((dd_del_move_bucket.Items.Count > 0 && dd_del_move_bucket.SelectedItem != null && dd_del_move_bucket.SelectedItem.Value != String.Empty) || dd_del_move_project.SelectedItem.Value == "-1") { if (User.Identity.IsAuthenticated) { // If we're chosing to move any existing leads to another project.. String ParentProjectID = LeadsUtil.GetProjectParentIDFromID(hf_project_id.Value); if (dd_del_move_project.SelectedItem.Value != "-1") // move leads { String new_project_id = dd_del_move_bucket.SelectedItem.Value; String[] pn = new String[] { "@NewProjectID", "@OldProjectID", "@OldParentProjectID" }; Object[] pv = new Object[] { new_project_id, hf_project_id.Value, ParentProjectID }; String uqry = "UPDATE dbl_lead SET ProjectID=@NewProjectID WHERE (ProjectID=@OldProjectID OR ProjectID=@OldParentProjectID) OR ProjectID IN (SELECT ProjectID FROM dbl_project WHERE ParentProjectID=@OldParentProjectID)"; SQL.Update(uqry, pn, pv); } else // else de-activate old leads { String uqry = "UPDATE dbl_lead SET Active=0, DateUpdated=CURRENT_TIMESTAMP WHERE Active=1 AND ProjectID=@ProjectID OR ProjectID IN (SELECT ProjectID FROM dbl_project WHERE ParentProjectID=@ProjectID)"; SQL.Update(uqry, "@ProjectID", ParentProjectID); } String action = "Project deactivated"; if (dd_del_move_project.Items.Count > 0) { if (dd_del_move_project.SelectedIndex == 0) { action += ", all remaining active Leads were marked inactive (removed)."; } else { action += ", all remaining active Leads were moved to the " + dd_del_move_project.SelectedItem.Text + " Project."; } } // Deactivate and log LeadsUtil.ReactivateOrDeactivateProject(hf_project_id.Value, hf_user_id.Value, false, action); } Util.SetRebindOnWindowClose(this, true); Util.CloseRadWindowFromUpdatePanel(this, String.Empty, false); } else { Util.PageMessageAlertify(this, "No Client List selected!", "Oops"); } }