public static int SaveImportantDate(ImportantDate entity, int leadID) { return _dataProvider.SaveImportantDate(entity, leadID); }
protected void btnAddImpDate_Click(object sender, EventArgs e) { //Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); CultureInfo provider = CultureInfo.InvariantCulture; DateTime dt = DateTime.ParseExact(txtAddDate.Text, "d", provider); ImportantDate impdate = new ImportantDate(); impdate.Date = dt; impdate.Reason = txtReason.Text; impdate.Note = txtDateNote.Text; int id = GetLeadID(); if (id > 0) { DataManager.SaveImportantDate(impdate, id); DataManager.LeadModified(id); } txtReason.Text = string.Empty; txtDateNote.Text = string.Empty; txtAddDate.Text = string.Empty; lvDates.DataBind(); hfSelectedTab.Value = "4"; }
internal ImportantDate GetImportantDateEntity(T_ImportantDate tDate) { ImportantDate imDate = new ImportantDate(); imDate.DateID = tDate.DateID; imDate.Date = tDate.idtDate; imDate.Note = tDate.idtNote; imDate.Reason = tDate.idtReason; return imDate; }
//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); }
public int SaveImportantDate(ImportantDate entity, int leadID) { using (var dc = new EngageCCTDataClassesDataContext()) { T_ImportantDate tDate; T_LeadImportantDate tLeadDate; if (!entity.DateID.HasValue) { tDate = new T_ImportantDate(); tLeadDate = new T_LeadImportantDate(); } else { tDate = dc.T_ImportantDates.SingleOrDefault(d => d.DateID == entity.DateID); tLeadDate = dc.T_LeadImportantDates.SingleOrDefault(d => d.DateID == entity.DateID); if (tDate == null || tLeadDate == null) { throw new ApplicationException("Date not found"); } } tDate.idtNote = entity.Note; tDate.idtReason = entity.Reason; tDate.idtDate = entity.Date; dc.T_ImportantDates.InsertOnSubmit(tDate); if (!entity.DateID.HasValue) dc.SubmitChanges(); tLeadDate.LeadID = leadID; tLeadDate.DateID = tDate.DateID; dc.T_LeadImportantDates.InsertOnSubmit(tLeadDate); dc.SubmitChanges(); return tDate.DateID; } }