protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LeadsUtil.BindProjects(dd_project, dd_buckets, LeadsUtil.GetProjectParentIDFromID(LeadsUtil.GetLastViewedProjectID()), null, false); } }
private void BindTemplate() { String qry = "SELECT dbl_lead.*, db_company.*, db_contact.ctc_id " + "FROM dbl_lead, db_contact, db_company " + "WHERE dbl_lead.ContactID = db_contact.ctc_id " + "AND db_contact.new_cpy_id = db_company.cpy_id " + "AND dbl_lead.LeadID=@LeadID;"; DataTable dt_lead = SQL.SelectDataTable(qry, "@LeadID", hf_lead_id.Value); if (dt_lead.Rows.Count > 0) { String cpy_id = dt_lead.Rows[0]["cpy_id"].ToString(); String ctc_id = dt_lead.Rows[0]["ctc_id"].ToString(); String project_id = dt_lead.Rows[0]["ProjectID"].ToString(); hf_project_id.Value = project_id; hf_parent_project_id.Value = LeadsUtil.GetProjectParentIDFromID(hf_project_id.Value); hf_cpy_id.Value = cpy_id; hf_ctc_id.Value = ctc_id; // Bind Company and Contacts CompanyManager.BindCompany(cpy_id); ContactManager.BindContact(ctc_id); // Bind Notes and Next Action ContactNotesManager.LeadID = hf_lead_id.Value; ContactNotesManager.Bind(ctc_id); // Bind Other Contacts BindOtherContacts(null, null); // Bind destination projects LeadsUtil.BindProjects(dd_projects, dd_buckets, hf_parent_project_id.Value, hf_project_id.Value, true); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Util.SetRebindOnWindowClose(this, false); if (Request.QueryString["proj_id"] != null && !String.IsNullOrEmpty(Request.QueryString["proj_id"])) { hf_project_id.Value = Request.QueryString["proj_id"]; hf_parent_project_id.Value = LeadsUtil.GetProjectParentIDFromID(hf_project_id.Value); hf_user_id.Value = Util.GetUserId(); // Delete any temp created companies for this user String temp_cpy_source = "db_templead_" + Util.GetUserId(); String dqry = "DELETE FROM db_contact WHERE CompanyID IN (SELECT CompanyID FROM db_company WHERE Source=@Source); DELETE FROM db_company WHERE Source=@Source;"; // remove all temp contacts/companies for this user SQL.Delete(dqry, "@Source", temp_cpy_source); // Bind destination projects LeadsUtil.BindProjects(dd_projects, dd_buckets, hf_parent_project_id.Value, hf_project_id.Value, true); } else { Util.PageMessageAlertify(this, LeadsUtil.LeadsGenericError, "Error"); } } }
private void BindDestinationProjects() { LeadsUtil.BindProjects(dd_move_projects, dd_move_buckets, hf_parent_project_id.Value, hf_project_id.Value, true); LeadsUtil.BindProjects(dd_del_projects, dd_del_buckets, hf_parent_project_id.Value, hf_project_id.Value, true, false); dd_del_buckets.Items.Insert(0, new Telerik.Web.UI.DropDownListItem("Delete all remaining Leads", "-1")); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["lead_ids"] != null && !String.IsNullOrEmpty(Request.QueryString["lead_ids"]) && Request.QueryString["project_id"] != null && !String.IsNullOrEmpty(Request.QueryString["project_id"])) { hf_lead_ids.Value = Request.QueryString["lead_ids"]; if (Request.QueryString["project_id"].ToString() == "search") // when moving from search, rather than from another project { hf_from_search.Value = "1"; lbl_title.Text = "Add your selected contacts to a <b>Project</b> as <b>Leads</b>.."; btn_move_leads.Text = "Add Selected Contacts to Project"; } else { hf_bucket_id.Value = Request.QueryString["project_id"]; hf_project_id.Value = LeadsUtil.GetProjectParentIDFromID(hf_bucket_id.Value); } LeadsUtil.BindProjects(dd_projects, dd_buckets, hf_project_id.Value, hf_bucket_id.Value, true); } else { Util.PageMessageAlertify(this, LeadsUtil.LeadsGenericError, "Error"); } } }
private void SetFormMode() { String mode = hf_mode.Value; if (mode == "new") { btn_modify_project.Text = "Add this Project"; lbl_title.Text = "Add a new <b>Project</b>.."; } else if (mode == "edit") { btn_modify_project.Text = "Update Project"; tbl_delete_project.Visible = true; tbl_move_leads.Visible = true; BindExistingProject(); // Bind destination projects LeadsUtil.BindProjects(dd_projects, dd_buckets, hf_parent_project_id.Value, hf_project_id.Value, false); } }
protected void rb_save_dest_proj_Click(object sender, EventArgs e) { RadButton rb = (RadButton)sender; String TempLeadID = rb.CommandArgument; String SelectedBucketID = rb.CommandName; RadDropDownList dd_project = (RadDropDownList)rb.Parent.FindControl("dd_project_" + TempLeadID); RadDropDownList dd_bucket = (RadDropDownList)rb.Parent.FindControl("dd_bucket_" + TempLeadID); if (dd_project.Items.Count > 0 && dd_project.SelectedItem != null && dd_bucket.Items.Count > 0 && dd_bucket.SelectedItem != null) { String DestinationProjectID = SelectedBucketID; if (DestinationProjectID == String.Empty) { DestinationProjectID = null; } String uqry = "UPDATE dbl_temp_leads SET DestinationProjectID=@DestProjectID WHERE TempLeadID=@TempLeadID"; SQL.Update(uqry, new String[] { "@DestProjectID", "@TempLeadID" }, new Object[] { DestinationProjectID, TempLeadID }); // Rebind, as dropdowns will have been bound by BuildNotesTooltip being called by AjaxUpdate automatically prior to saving of the DestinationID String SelectedProjectID = String.Empty; if (SelectedBucketID != null) { SelectedProjectID = LeadsUtil.GetProjectParentIDFromID(SelectedBucketID); // Bind projects & select if possible LeadsUtil.BindProjects(dd_project, dd_bucket, SelectedProjectID, SelectedBucketID, true, true); dd_project.Items.Insert(0, new DropDownListItem(String.Empty, String.Empty)); dd_bucket.Items.Insert(0, new DropDownListItem(String.Empty, String.Empty)); } else { dd_project.SelectedIndex = 0; dd_bucket.SelectedIndex = 0; } } Util.PageMessageSuccess(this, "Destination Project Saved!"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Util.SetRebindOnWindowClose(this, false); bool error = false; if (Request.QueryString["cpy_id"] != null && !String.IsNullOrEmpty(Request.QueryString["cpy_id"])) { hf_cpy_id.Value = Request.QueryString["cpy_id"]; } else if (Request.QueryString["ctc_id"] != null && !String.IsNullOrEmpty(Request.QueryString["ctc_id"])) { hf_ctc_id.Value = Request.QueryString["ctc_id"]; String qry = "SELECT CompanyID FROM db_contact WHERE ContactID=@ContactID"; hf_cpy_id.Value = SQL.SelectString(qry, "CompanyID", "@ContactID", hf_ctc_id.Value); } else { Util.PageMessageAlertify(this, LeadsUtil.LeadsGenericError, "Error"); error = true; } // Disable adding to Leads system/selecting contacts when add_leads=false bool InLeadsMode = true; if (Request.QueryString["add_leads"] != null && Request.QueryString["add_leads"].ToString() == "false") { div_add_leads.Visible = lbl_pad.Visible = false; InLeadsMode = false; ContactManager.SelectableContacts = false; } if (!error) { if (hf_ctc_id.Value != String.Empty) { ContactManager.FocusContactID = hf_ctc_id.Value; } String[] ForcedSelectedContactIDs = null; if (hf_ctc_id.Value != String.Empty) { ForcedSelectedContactIDs = new String[] { hf_ctc_id.Value } } ; CompanyManager.BindCompany(hf_cpy_id.Value); ContactManager.BindContacts(hf_cpy_id.Value, ForcedSelectedContactIDs); if (InLeadsMode) { // Allow adding Leads to projects if this user has projects (or has used Leads system) hf_project_id.Value = LeadsUtil.GetLastViewedProjectID(); if (hf_project_id.Value != String.Empty) { div_add_leads.Visible = true; hf_parent_project_id.Value = LeadsUtil.GetProjectParentIDFromID(hf_project_id.Value); // Bind destination projects LeadsUtil.BindProjects(dd_projects, dd_buckets, hf_parent_project_id.Value, hf_project_id.Value, true); } // Otherwise disable adding Leads and allow updates to CTC/CPY only else { ContactManager.SelectableContacts = false; } } } } Util.ResizeRadWindow(this); }
// Notes & Destination Project Picker protected void BuildNotesTooltip(object sender, Telerik.Web.UI.ToolTipUpdateEventArgs args) { String TempLeadID = args.Value; // Find destination note box RadTextBox rtb_dest_note = new RadTextBox(); foreach (GridDataItem item in rg_leads.Items) { String ThisRowTempLeadID = item["TempLeadID"].Text; if (TempLeadID == ThisRowTempLeadID) { rtb_dest_note = (RadTextBox)item["Notes"].FindControl("tb_notes"); break; } } Panel p = new Panel(); Label lbl_notes_title = new Label(); lbl_notes_title.CssClass = "MediumTitle"; lbl_notes_title.Text = "Lead Notes and Actions"; lbl_notes_title.Attributes.Add("style", "font-weight:500; margin-top:0px; margin-bottom:6px; position:relative; top:-3px;"); RadTextBox rtb_note = new RadTextBox(); rtb_note.ID = "rtb_note_" + TempLeadID; rtb_note.Height = 140; rtb_note.Width = 590; rtb_note.TextMode = InputMode.MultiLine; rtb_note.Text = rtb_dest_note.Text; RadButton rb_clear_note = new RadButton(); rb_clear_note.ID = "rb_clear_note_" + TempLeadID; rb_clear_note.Attributes.Add("style", "float:left; margin:4px 4px 4px 1px;"); rb_clear_note.Skin = "Bootstrap"; rb_clear_note.Text = "Clear Notes"; rb_clear_note.Click += rb_clear_note_Click; rb_clear_note.CommandArgument = TempLeadID; RadButton rb_clear_all_notes = new RadButton(); rb_clear_all_notes.ID = "rb_clear_all_notes_" + TempLeadID; rb_clear_all_notes.Attributes.Add("style", "float:left; margin:4px 0px 4px 1px;"); rb_clear_all_notes.Skin = "Bootstrap"; rb_clear_all_notes.Text = "Clear All Notes"; rb_clear_all_notes.Click += rb_clear_note_Click; rb_clear_all_notes.CommandArgument = TempLeadID; RadButton rb_add_note = new RadButton(); rb_add_note.ID = "rb_add_note_" + TempLeadID; rb_add_note.Attributes.Add("style", "float:right; margin:4px 1px 4px 4px;"); rb_add_note.Skin = "Bootstrap"; rb_add_note.Text = "Save Note/Next Action"; rb_add_note.Click += rb_add_note_Click; rb_add_note.CommandArgument = TempLeadID; RadButton rb_add_note_to_all = new RadButton(); rb_add_note_to_all.ID = "rb_add_note_to_all_" + TempLeadID; rb_add_note_to_all.Attributes.Add("style", "float:right; margin:4px 1px 4px 4px;"); rb_add_note_to_all.Skin = "Bootstrap"; rb_add_note_to_all.Text = "Save Note/Next Action to All"; rb_add_note_to_all.Click += rb_add_note_Click; rb_add_note_to_all.CommandArgument = TempLeadID; // Next Action stuff Panel p_next_action = new Panel(); p_next_action.CssClass = "NextActionContainer"; p_next_action.Attributes.Add("style", "margin-top:50px; padding-top:10px;"); Label lbl_next_action = new Label(); lbl_next_action.Text = "Next Action:"; lbl_next_action.CssClass = "SmallTitle"; lbl_next_action.Attributes.Add("style", "float:left; padding:5px 5px 0px 5px;"); RadDropDownList dd_next_action_type = new RadDropDownList(); // needs binding dd_next_action_type.ID = "dd_next_action_type_" + TempLeadID; dd_next_action_type.Width = 100; dd_next_action_type.Height = 30; dd_next_action_type.Attributes.Add("style", "margin-right:5px; position:relative; top:-2px;"); dd_next_action_type.ZIndex = 99999999; dd_next_action_type.ExpandDirection = DropDownListExpandDirection.Up; dd_next_action_type.Skin = "Bootstrap"; String qry = "SELECT * FROM dbl_action_type ORDER BY ActionType"; dd_next_action_type.DataSource = SQL.SelectDataTable(qry, null, null); dd_next_action_type.DataTextField = "ActionType"; dd_next_action_type.DataValueField = "ActionTypeID"; dd_next_action_type.DataBind(); RadDateTimePicker rdp_next_action = new RadDateTimePicker(); rdp_next_action.ID = "rd_next_action_" + TempLeadID; rdp_next_action.Skin = "Bootstrap"; rdp_next_action.ZIndex = 99999999; rdp_next_action.Width = 200; rdp_next_action.PopupDirection = DatePickerPopupDirection.TopLeft; RadButton rb_remove_all_next_action = new RadButton(); rb_remove_all_next_action.ID = "rb_remove_all_next_action_" + TempLeadID; rb_remove_all_next_action.Attributes.Add("style", "float:right;"); rb_remove_all_next_action.Skin = "Bootstrap"; rb_remove_all_next_action.Text = "Remove All Next Actions"; rb_remove_all_next_action.Click += rb_clear_note_Click; rb_remove_all_next_action.CommandArgument = TempLeadID; // Attempt to set a previously set next action/destination project HiddenField hf_nat = new HiddenField() { ID = "hf_nat_" + TempLeadID }; HiddenField hf_nad = new HiddenField() { ID = "hf_nad_" + TempLeadID }; String DestinationProjectID = String.Empty; qry = "SELECT DestinationProjectID, NextActionTypeID, NextActionDate FROM dbl_temp_leads WHERE TempLeadID=@TempLeadID"; DataTable dt_next_action = SQL.SelectDataTable(qry, "@TempLeadID", TempLeadID); if (dt_next_action.Rows.Count > 0) { DestinationProjectID = dt_next_action.Rows[0]["DestinationProjectID"].ToString(); DateTime d = new DateTime(); if (DateTime.TryParse(dt_next_action.Rows[0]["NextActionDate"].ToString(), out d)) { rdp_next_action.SelectedDate = d; hf_nad.Value = d.ToString(); } String app_type = dt_next_action.Rows[0]["NextActionTypeID"].ToString(); if (dd_next_action_type.FindItemByValue(app_type) != null) { dd_next_action_type.SelectedIndex = dd_next_action_type.FindItemByValue(app_type).Index; hf_nat.Value = dd_next_action_type.SelectedItem.Value; } } p_next_action.Controls.Add(lbl_next_action); p_next_action.Controls.Add(dd_next_action_type); p_next_action.Controls.Add(rdp_next_action); p_next_action.Controls.Add(rb_remove_all_next_action); p_next_action.Controls.Add(hf_nat); p_next_action.Controls.Add(hf_nad); // Destination Project stuff Panel p_dest_project = new Panel(); p_dest_project.Attributes.Add("style", "margin-top:24px;"); Label lbl_dest_title = new Label(); lbl_dest_title.CssClass = "MediumTitle"; lbl_dest_title.Text = "Pick a Project/Bucket for this Lead (optional, overrides target on import)..."; lbl_dest_title.Attributes.Add("style", "font-weight:500; margin-top:0px; margin-bottom:6px; position:relative; top:-3px;"); RadDropDownList dd_project = new RadDropDownList(); dd_project.ID = "dd_project_" + TempLeadID; dd_project.Width = 200; dd_project.Height = 30; dd_project.Attributes.Add("style", "margin-right:5px;"); dd_project.ZIndex = 99999999; dd_project.ExpandDirection = DropDownListExpandDirection.Up; dd_project.Skin = "Bootstrap"; dd_project.AutoPostBack = true; dd_project.SelectedIndexChanged += dd_project_SelectedIndexChanged; RadDropDownList dd_bucket = new RadDropDownList(); dd_bucket.ID = "dd_bucket_" + TempLeadID; dd_bucket.Width = 200; dd_bucket.Height = 30; dd_bucket.Attributes.Add("style", "margin-right:5px;"); dd_bucket.ZIndex = 99999999; dd_bucket.ExpandDirection = DropDownListExpandDirection.Up; dd_bucket.Skin = "Bootstrap"; RadButton rb_save_dest_proj = new RadButton(); rb_save_dest_proj.ID = "btn_save_proj_" + TempLeadID; rb_save_dest_proj.Attributes.Add("style", "float:right; position:relative; top:-1px;"); rb_save_dest_proj.Skin = "Bootstrap"; rb_save_dest_proj.Text = "Save Destination Project"; rb_save_dest_proj.Click += rb_save_dest_proj_Click; rb_save_dest_proj.CommandArgument = TempLeadID; rb_save_dest_proj.CausesValidation = false; // Set CommandName to the currently selected bucketID on save rb_save_dest_proj.OnClientClicking = "function(button, args){ var dd = $find('ctl00_Body_" + dd_bucket.ClientID + "'); $find('ctl00_Body_" + rb_save_dest_proj.ClientID + "').set_commandName(dd.get_selectedItem().get_value()); }"; String SelectedProjectID = String.Empty; String SelectedBucketID = String.Empty; if (DestinationProjectID != String.Empty) { SelectedProjectID = LeadsUtil.GetProjectParentIDFromID(DestinationProjectID); SelectedBucketID = DestinationProjectID; } // Bind projects & select if possible LeadsUtil.BindProjects(dd_project, dd_bucket, SelectedProjectID, SelectedBucketID, true, true); dd_project.Items.Insert(0, new DropDownListItem(String.Empty, String.Empty)); dd_bucket.Items.Insert(0, new DropDownListItem(String.Empty, String.Empty)); if (DestinationProjectID == String.Empty) { dd_project.SelectedIndex = 0; dd_bucket.SelectedIndex = 0; } p_dest_project.Controls.Add(lbl_dest_title); p_dest_project.Controls.Add(dd_project); p_dest_project.Controls.Add(dd_bucket); p_dest_project.Controls.Add(rb_save_dest_proj); p.Controls.Add(lbl_notes_title); p.Controls.Add(rtb_note); p.Controls.Add(new Label() { Text = "<br/>" }); p.Controls.Add(rb_clear_note); p.Controls.Add(rb_clear_all_notes); p.Controls.Add(rb_add_note); p.Controls.Add(rb_add_note_to_all); p.Controls.Add(p_next_action); p.Controls.Add(p_dest_project); args.UpdatePanel.ContentTemplateContainer.Controls.Add(p); args.UpdatePanel.ChildrenAsTriggers = true; }