protected void CancelOrRestoreLead() { var statuses = DataManager.GetAllStatuses(); if (statuses == null) throw new ApplicationException("Statuses are empty"); Note note; switch (Action) { case ActionCancel: note = new Note { Created = DateTime.Now, Title = LeadStatusConstants.Canceled, Text = txtComments.Text }; _lead.Notes.Add(note); _lead.LeadStatus = statuses.Single(x => x.Status == LeadStatusConstants.Canceled); var lId=DataManager.SaveLead(_lead); DataManager.LeadModified(lId); break; case ActionRestore: note = new Note { Created = DateTime.Now, Title = LeadStatusConstants.Restored, Text = txtComments.Text }; _lead.Notes.Add(note); _lead.LeadStatus = statuses.Single(x => x.Status == LeadStatusConstants.Restored); var id = DataManager.SaveLead(_lead); DataManager.LeadModified(id); break; default: throw new ApplicationException("Undefined action"); } }
protected void SaveNote(int activityID) { if (!Page.IsValid) { return; } if (string.IsNullOrWhiteSpace(txtNewNote.Text)) { return; } //hfSelectedTab.Value = _tabNotes; Note newNote = new Note() { Created = DateTime.Now, Text = txtNewNote.Text }; Activity activity = DataManager.GetActivityById(activityID); activity.Notes.Add(newNote); try { DataManager.SaveActivity(activity); } catch (ApplicationException) { Response.Redirect(PageConstants.ErrorPage); } lvNotes.DataSource = activity.Notes; lvNotes.DataBind(); txtNewNote.Text = string.Empty; }
protected void btnAddNote_Click(object sender, EventArgs e) { if (Request.QueryString[PageConstants.LeadIDParam] != null) { if (!Page.IsValid) { return; } hfSelectedTab.Value = _tabNotes; string note = string.Empty; note = breakNote(txtNewNote.Text); Note newNote = new Note() { Created = DateTime.Now, Text = note }; int id = int.Parse(Request.QueryString[PageConstants.LeadIDParam]); Lead lead = DataManager.GetLeadById(id); lead.Notes.Add(newNote); DataManager.SaveLead(lead); DataManager.LeadModified(id); lead.Notes.Reverse(); lvNotes.DataSource = lead.Notes; lvNotes.DataBind(); txtNewNote.Text = string.Empty; } }
//private Address GetAddress(string country, string state, string city, string street, string zipCode) //{ // if (country == String.Empty && state == String.Empty && city == String.Empty && street == String.Empty && zipCode == String.Empty) // { // return null; // } // Address address = new Address // { // Country = new Country(){ Name=country}, // State = state, // City = city, // Street = street, // ZipCode = zipCode // }; // return address; //} protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtBusinessPhone.Text) && string.IsNullOrEmpty(txtHomePhone.Text) && string.IsNullOrEmpty(txtMobilePhone.Text) && string.IsNullOrEmpty(txtEmail.Text) && string.IsNullOrEmpty(txtSkype.Text) && string.IsNullOrEmpty(txtFax.Text)) { txtContactsValidation.Text = "At least one Contact information field is required."; return; } else { txtContactsValidation.Text = ""; } LeadStatus leadStatus = DataManager.GetLeadStatusByID(int.Parse(ddlStatus.SelectedValue)); LeadSource leadSource = null; var sId = int.Parse(ddlSource.SelectedValue); if (sId != -1) { leadSource = DataManager.GetLeadSourceByID(sId); } MembershipUser user = Membership.GetUser(ddlOwner.SelectedValue); Guid owner = (Guid)user.ProviderUserKey; if (Request.QueryString[PageConstants.LeadIDParam] != null) { int id = int.Parse(Request.QueryString[PageConstants.LeadIDParam]); var currentLead = DataManager.GetLeadById(id); if (currentLead.Owner != owner) { var path = VirtualPathUtility.ToAbsolute("~/"); NotificationManager.AssignNotify(owner, currentLead.Owner, id, path); } } int? leadId = null; if (Request.QueryString[PageConstants.LeadIDParam] != null) { leadId = int.Parse(Request.QueryString[PageConstants.LeadIDParam]); } int salutId = int.Parse(ddlSalutation.SelectedValue); string salutName = null; if (salutId != -1) { salutName = DataManager.GetSalutationNameById(salutId); } Lead lead = new Lead { Topic = txtTopic.Text, CreatedOn = DateTime.Now, BusinessPhone = txtBusinessPhone.Text, MobilePhone = txtMobilePhone.Text, CompanyAddress = ucZipCompany.Address, CompanyName = txtCompanyName.Text, Email = txtEmail.Text, FirstName = txtFirstName.Text, HomeAddress = ucZipHome.Address, HomePhone = txtHomePhone.Text, Honorific = salutName, JobTitle = txtJobTitle.Text, LastName = txtLastName.Text, WorkAddress = ucZipWork.Address, LeadStatus = leadStatus, LeadSource = leadSource, Owner = owner, LeadID = leadId, Fax = txtFax.Text, Skype = txtSkype.Text, SSN = txtSSN.Text, SubjectPropertyAddress = ucZipSPA.Address, AddrVal = (int)StatusValidation.NoInformation, ExlList = (int)StatusValidation.NoInformation, OFAC = (int)StatusValidation.NoInformation, Contact = new ContactPreferences { IsAllowBusinessPhone = SaveRadioSelect(rblBusinessPhone.SelectedValue), IsAllowEmail = SaveRadioSelect(rblEmail.SelectedValue), IsAllowFax = SaveRadioSelect(rblFax.SelectedValue), IsAllowHomePhone = SaveRadioSelect(rblHomePhone.SelectedValue), IsAllowMobilePhone = SaveRadioSelect(rblMobilePhone.SelectedValue), IsAllowSkype = SaveRadioSelect(rblSkype.SelectedValue), PreferredContact = ddlPreferred.SelectedValue } }; if (!string.IsNullOrWhiteSpace(txtNewNote.Text)) { Note newNote = new Note() { Created = DateTime.Now, Text = txtNewNote.Text }; lead.Notes = new System.Collections.Generic.List<Note>(); lead.Notes.Add(newNote); } lead.LeadID = DataManager.SaveLead(lead); DataManager.LeadModified(lead.LeadID.Value); if (Request.QueryString[PageConstants.LeadIDParam] == null) { var path = VirtualPathUtility.ToAbsolute("~/"); NotificationManager.AssignNotify(owner, null, Convert.ToInt32(lead.LeadID), path); } //add logic to create important date if (txtAddDate.Text.Length != 0) { ImportantDate impDate = new ImportantDate(); impDate.Note = txtDateNote.Text; impDate.Reason = txtReason.Text; DateTime dtResult = new DateTime(); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); if (DateTime.TryParse(txtAddDate.Text, out dtResult)) { impDate.Date = dtResult; DataManager.SaveImportantDate(impDate, (int)lead.LeadID); } } // //tcEditLead.Visible = false; btnSave.Visible = false; Response.Redirect(PageConstants.LeadPipeLinePage); }
private int SaveNote(Note entity, int activityID) { using (var dc = new EngageCCTDataClassesDataContext()) { T_Note tNote; T_ActivityNote tActivityNote; if (!entity.NoteID.HasValue) { tNote = new T_Note(); tActivityNote = new T_ActivityNote(); } else { tNote = dc.T_Notes.SingleOrDefault(n => n.NoteID == entity.NoteID); tActivityNote = dc.T_ActivityNotes.SingleOrDefault(n => n.NoteID == entity.NoteID); if (tNote == null || tActivityNote == null) { throw new ApplicationException("Note not found"); } } tNote.ntCreated = entity.Created; tNote.ntEdited = entity.Edited; tNote.ntText = entity.Text; tNote.ntTitle = entity.Title; dc.T_Notes.InsertOnSubmit(tNote); if (!entity.NoteID.HasValue) { dc.SubmitChanges(); } tActivityNote.NoteID = tNote.NoteID; tActivityNote.ActivityID = activityID; dc.T_ActivityNotes.InsertOnSubmit(tActivityNote); dc.SubmitChanges(); return tNote.NoteID; } }
internal Note GetNoteEntity(T_Note tNote) { Note note = new Note(); note.NoteID = tNote.NoteID; note.Created = tNote.ntCreated; note.Edited = tNote.ntEdited; note.Text = tNote.ntText; return note; }