private void SaveContact() { // format phone no. CommonCode objCommonCode = new CommonCode(); //FranchisorService service = new FranchisorService(); EContact objContact = new EContact(); //objContact.Address = new HealthYes.Web.UI.FranchisorService.EAddress(); objContact.Address = new EAddress(); //Now Address is not saved in TblAddress if (ViewState["ContactID"] != null) { objContact.ContactID = Convert.ToInt32(ViewState["ContactID"].ToString()); } //Now Address is saved in TblContact only. No link with TblAddress objContact.Address.Address1 = txtAddress.Text; objContact.Address.City = txtCity.Text; objContact.Address.Country = "US"; objContact.Address.State = ddlState.SelectedIndex > 0 ? ddlState.SelectedItem.Text : ""; objContact.Address.Zip = txtZip.Text; objContact.EMail = txtEMail.Text; objContact.FirstName = txtFName.Text; objContact.MiddleName = txtMName.Text; objContact.LastName = txtLName.Text; objContact.OrganizationName = txtOrganisation.Text; objContact.WebSite = txtWebsite.Text; objContact.PhoneCell = objCommonCode.FormatPhoneNumber(txtPhoneCell.Text); objContact.PhoneHome = objCommonCode.FormatPhoneNumber(txtPhoneHome.Text); objContact.PhoneOffice = objCommonCode.FormatPhoneNumber(txtPhoneOffice.Text); objContact.Phone1Extension = txtExt.Text; objContact.Gender = rbtMale.Checked; objContact.DateOfBirth = txtBday.Text; objContact.DesignationTitle = txtJobtitle.Text; objContact.EmailWork = txtEmailOffice.Text; objContact.ContactType = Convert.ToInt32(ddlContactType.SelectedValue); objContact.Fax = objCommonCode.FormatPhoneNumber(txtFax.Text); objContact.Note = txtNotes.Text.Length > 0 ? txtNotes.Text : ""; objContact.Title = txtTitle.Text; int prospectid = 0; prospectid = this.ExtractProspectID(); if (prospectid > 0) { objContact.ArrayProspectIDs = new long[1]; objContact.ArrayProspectIDs[0] = prospectid; int arraylength = 0; for (int icount = 0; icount < chklistContactRole.Items.Count; icount++) { if (chklistContactRole.Items[icount].Selected) { arraylength++; } } if (arraylength > 0) { //int jcount = 0; //objContact.ListProspectContactRole = new EProspectContactRole[arraylength]; objContact.ListProspectContactRole = new List <EProspectContactRole>(); for (int icount = 0; icount < chklistContactRole.Items.Count; icount++) { if (chklistContactRole.Items[icount].Selected) { objContact.ListProspectContactRole.Add(new EProspectContactRole() { ProspectContactRoleID = Convert.ToInt16( chklistContactRole.Items[icount].Value), ProspectID = prospectid }); //objContact.ListProspectContactRole[jcount] = new EProspectContactRole(); //objContact.ListProspectContactRole[jcount].ProspectContactRoleID = Convert.ToInt16(chklistContactRole.Items[icount].Value); //objContact.ListProspectContactRole[jcount].ProspectID = prospectid; //jcount++; } } } } var currentsession = IoC.Resolve <ISessionContext>().UserSession; long tempResult; //bool tempResult1; if (ViewState["ContactID"] != null) { if (prospectid > 0) { //service.UpdateContactDetail(objContact, usershellmodulerole1, out tempResult, out tempResult1); tempResult = UpdateContactDetail(objContact, currentsession.UserId.ToString(), currentsession.CurrentOrganizationRole.OrganizationId.ToString(), currentsession.CurrentOrganizationRole.RoleId.ToString()); } else { FranchisorDAL franchisorDAL = new FranchisorDAL(); tempResult = franchisorDAL.SaveContact(objContact, Convert.ToInt32(EOperationMode.Update), Convert.ToInt32(currentsession.UserId.ToString())); //service.UpdateContact(objContact, usershellmodulerole1, out tempResult, out tempResult1); } } else { if (prospectid > 0) { //service.SaveProspectContact(objContact, usershellmodulerole1, out tempResult, out tempResult1); tempResult = SaveProspectContact(objContact, currentsession.UserId.ToString(), currentsession.CurrentOrganizationRole.OrganizationId.ToString(), currentsession.CurrentOrganizationRole.RoleId.ToString()); } else { FranchisorDAL franchisorDAL = new FranchisorDAL(); tempResult = franchisorDAL.SaveContact(objContact, Convert.ToInt32(EOperationMode.Insert), Convert.ToInt32(currentsession.UserId.ToString())); //service.SaveContact(objContact, usershellmodulerole1, out tempResult, out tempResult1); } } // Assign prospect to salesrep if (prospectid > 0) { if (currentsession.CurrentOrganizationRole.CheckRole((long)Roles.SalesRep)) { Int64 iProspectId = prospectid; FranchisorDAL franchisorDAL = new FranchisorDAL(); franchisorDAL.AssignProspect(1, iProspectId, Convert.ToInt64(currentsession.UserId)); //service.AssignProspect(iProspectId, true, Convert.ToInt64(usershellmodulerole1.UserID), true); } } if (ViewState["ReferedURL"].ToString().ToLower().IndexOf("/createeventwizard/step1.aspx") >= 0) { string strUpdateProspectHost = "/App/Common/CreateEventWizard/Step1.aspx"; if (Request.QueryString["EventId"] != null) { strUpdateProspectHost = strUpdateProspectHost + "?EventId=" + Request.QueryString["EventId"]; } if (Request.QueryString["Type"] != null) { if (strUpdateProspectHost.IndexOf("?") >= 0) { strUpdateProspectHost = strUpdateProspectHost + "&HostID=" + ViewState["ProspectID"] + "&Type=Selected"; } else { strUpdateProspectHost = strUpdateProspectHost + "?HostID=" + ViewState["ProspectID"] + "&Type=Selected"; } } Response.RedirectUser(strUpdateProspectHost); } else { Response.RedirectUser(ViewState["ReferedURL"].ToString()); } //Response.RedirectUser(ViewState["ReferedURL"].ToString()); }
private bool Savetask() { Int64 iProspectId = 0; var task = new ETask(); var currentSession = IoC.Resolve <ISessionContext>().UserSession; long tempResult; task.TaskPriorityType = new ETaskPriorityType(); task.TaskStatusType = new ETaskStatusType(); if (ViewState["TaskID"] != null) { task.TaskID = Convert.ToInt32(ViewState["TaskID"]); } task.Subject = txtSubject.Text; task.Notes = TxtNotes.Text; task.DueDate = txtduedate.Text; task.DueTime = txtStartTime.Text; task.TaskStatusType.TaskStatusTypeID = Convert.ToInt32(ddlStatus.SelectedValue); task.TaskPriorityType.TaskPriorityTypeID = Convert.ToInt32(ddlPriority.SelectedValue); task.CreatedBY = Convert.ToInt32(currentSession.CurrentOrganizationRole.OrganizationRoleUserId); task.ModifiedBY = Convert.ToInt32(currentSession.CurrentOrganizationRole.OrganizationRoleUserId); var role = new EUserShellModuleRole(); task.UserShellModule = role; if (!string.IsNullOrEmpty(Request["ProspectID"])) { iProspectId = Convert.ToInt64(Request["ProspectID"]); } task.ProspectID = iProspectId; var masterDal = new MasterDAL(); if (ViewState["TaskID"] != null) { if (ViewState["TaskID"].ToString() != string.Empty) { try { tempResult = masterDal.SaveTask(task, Convert.ToInt32(EOperationMode.Update), currentSession.UserId.ToString(), currentSession.CurrentOrganizationRole.OrganizationId.ToString(), currentSession.CurrentOrganizationRole.RoleId.ToString()); } catch (Exception) { tempResult = -1; } if (!(tempResult == 999999 || tempResult == -1)) { tempResult = 9999990; } //service.UpdateTask(task, usershellmodulerole1, out tempResult, out tempResult1); } } else { tempResult = masterDal.SaveTask(task, Convert.ToInt32(EOperationMode.Insert), currentSession.UserId.ToString(), currentSession.CurrentOrganizationRole.OrganizationId.ToString(), currentSession.CurrentOrganizationRole.RoleId.ToString()); if (tempResult == 0) { tempResult = 9999990; } } // Assign prospect to salesrep if (iProspectId > 0) { if (currentSession.CurrentOrganizationRole.CheckRole((long)Roles.SalesRep)) { var franchisorDal = new FranchisorDAL(); franchisorDal.AssignProspect(1, iProspectId, Convert.ToInt64(currentSession.UserId)); } } if (Request.QueryString["Referrer"] != null) { string strReferrer = Request.QueryString["Referrer"]; if ((strReferrer != string.Empty) && (strReferrer == "Calendar")) { Response.RedirectUser(ResolveUrl("~/App/Common/Calendar.aspx")); } } return(true); }
/// <summary> /// Add Task /// </summary> private void AddTask() { if ((!string.IsNullOrEmpty(Request["subject"])) || !string.IsNullOrEmpty(Request["duedate"]) || !string.IsNullOrEmpty(Request["duetime"])) { if (!string.IsNullOrEmpty(Request["prospectid"])) { Response.Clear(); Response.ContentType = "text/xml"; // Add Task string strSubject = string.Empty; string strDueDate = string.Empty; string strDueTime = string.Empty; string strProspectid = string.Empty; string strAssignedStatus = string.Empty; long temp; if (!string.IsNullOrEmpty(Request["subject"])) { strSubject = Request["subject"].ToString(); } if (!string.IsNullOrEmpty(Request["duedate"])) { strDueDate = Request["duedate"].ToString(); } if (!string.IsNullOrEmpty(Request["duetime"])) { strDueTime = Request["duetime"].ToString(); } if (!string.IsNullOrEmpty(Request["prospectid"])) { strProspectid = Request["prospectid"].ToString(); } if (!string.IsNullOrEmpty(Request["assignedstatus"])) { strAssignedStatus = Request["assignedstatus"].ToString(); } var masterDal = new Falcon.DataAccess.Master.MasterDAL(); var task = new Falcon.Entity.Other.ETask(); //TaskService objTaskService = new TaskService(); //EUserShellModuleRole objEUserShellModuleRole = new EUserShellModuleRole(); //ETask task = new ETask(); //task.TaskStatusType = new ETaskStatusType(); //task.TaskPriorityType = new ETaskPriorityType(); //task.TaskType = new ETaskType(); //task.UserShellModule = new HealthYes.Web.UI.TaskService.EUserShellModuleRole(); task.TaskStatusType = new Falcon.Entity.Other.ETaskStatusType(); task.TaskPriorityType = new Falcon.Entity.Other.ETaskPriorityType(); task.TaskType = new Falcon.Entity.Other.ETaskType(); task.UserShellModule = new Falcon.Entity.User.EUserShellModuleRole(); var currentSession = IoC.Resolve <ISessionContext>().UserSession; task.Active = true; task.Subject = strSubject; if (strDueDate != "") { task.DueDate = strDueDate; } if (strDueTime != "") { task.DueTime = strDueTime; } task.Notes = ""; task.StartDate = ""; task.StartTime = ""; task.UserShellModule.ShellID = currentSession.CurrentOrganizationRole.OrganizationId.ToString(); task.UserShellModule.RoleShellID = (int)currentSession.CurrentOrganizationRole.OrganizationRoleUserId; task.UserShellModule.RoleID = currentSession.CurrentOrganizationRole.RoleId.ToString(); task.UserShellModule.UserID = currentSession.UserId.ToString(); //task.UserShellModule = objEUserShellModuleRole; task.ProspectID = 0; if (!string.IsNullOrEmpty(strProspectid)) { task.ProspectID = Convert.ToInt64(strProspectid); } task.ContactID = 0; task.CreatedBY = Convert.ToInt32(currentSession.UserId); task.ModifiedBY = task.CreatedBY; //objTaskService.AddTask(task, objEUserShellModuleRole, out temp, out temp1); temp = masterDal.SaveTask(task, Convert.ToInt32(EOperationMode.Insert), currentSession.UserId.ToString(), currentSession.CurrentOrganizationRole.OrganizationId.ToString(), currentSession.CurrentOrganizationRole.RoleId.ToString()); if (temp == 0) { temp = 9999990; } if (Request["ishost"] == null || Request["ishost"] == "") { // Assign Prospect if (task.ProspectID > 0) { if (currentSession.CurrentOrganizationRole.CheckRole((long)Roles.SalesRep) && strAssignedStatus.Equals("2")) { FranchisorDAL objFranchisorDal = new FranchisorDAL(); //mode - 1 for Assign Prospect objFranchisorDal.AssignProspect(1, Convert.ToInt64(task.ProspectID), Convert.ToInt64(currentSession.UserId)); XmlDeclartion = XmlDeclartion + "<result>1</result>"; Response.Write(XmlDeclartion); } else { XmlDeclartion = XmlDeclartion + "<result>0</result>"; Response.Write(XmlDeclartion); } } } // task added to prospect else if (Request["ishost"] != null && Request["ishost"] != "") { XmlDeclartion = XmlDeclartion + "<result>1</result>"; Response.Write(XmlDeclartion); } } } else { XmlDeclartion = XmlDeclartion + "<result>2</result>"; Response.Write(XmlDeclartion); } }
private bool SaveMeeting() { string strUser = null; string strRole = null; string strShell = null; decimal minutes = 0; Int64 ProspectID = 0; MasterDAL objMasterDal = new MasterDAL(); var meeting = new Falcon.Entity.Other.EContactMeeting(); var currentSession = IoC.Resolve <ISessionContext>().UserSession; long temp; meeting.CallStatus = new Falcon.Entity.Other.ECallStatus(); meeting.Contact = new Falcon.Entity.Other.EContact(); if (ViewState["ContactMeetingID"] != null) { meeting.ContactMeetingID = Convert.ToInt32(ViewState["ContactMeetingID"]); meeting.ProspectID = 0; } meeting.Subject = txtSubject.Text; meeting.Description = txtDescription.Text; meeting.StartDate = txtStartDate.Text; if (txtStartTime.Text != null && txtStartTime.Text != "") { DateTime dt = Convert.ToDateTime(string.Format("{0:T}", txtStartTime.Text)); int Hour = Convert.ToInt16(dt.ToString("hh")); if ((dt.Minute > 60) || (dt.Second >= 60) || (Hour > 12)) { return(false); } meeting.StartTime = txtStartTime.Text; } else { meeting.StartTime = ""; } minutes = Convert.ToInt32(ddlDuration.SelectedValue); meeting.Duration = minutes; //What is this ?? - Bidhan meeting.AssignedToUserId = Convert.ToInt32(strUser); meeting.AssignedToShellID = Convert.ToInt32(strShell); meeting.AssignedToRoleID = Convert.ToInt32(strRole); meeting.CreatedByUserId = Convert.ToInt32(currentSession.UserId); meeting.CreatedByShellID = Convert.ToInt32(currentSession.CurrentOrganizationRole.OrganizationId); meeting.CreatedByRoleID = Convert.ToInt32(currentSession.CurrentOrganizationRole.RoleId); meeting.Reminder = false; meeting.CallStatus.CallStatusID = Convert.ToInt32(ddlStatus.SelectedValue); meeting.Venue = txtVenue.Text; // Assign Prospect if (!string.IsNullOrEmpty(Request["ProspectID"])) { ProspectID = Convert.ToInt64(Request["ProspectID"]); } meeting.ProspectID = ProspectID; if (!string.IsNullOrEmpty(HidAllContactID.Value)) { string strAllContact = HidAllContactID.Value; string[] strAllContactCall = strAllContact.Split(','); if (strAllContactCall.Length > 0) { for (int i = 0; i < strAllContactCall.Length; i++) { if (!string.IsNullOrEmpty(strAllContactCall[i])) { EContactMeeting ContactMeeting = new EContactMeeting(); ContactMeeting.CallStatus = new ECallStatus(); ContactMeeting.Contact = new EContact(); ContactMeeting.Contact.ContactID = Convert.ToInt32(strAllContactCall[i]); ContactMeeting.IsActive = true; ContactMeeting.ContactMeetingID = meeting.ContactMeetingID; ContactMeeting.CreatedByUserId = meeting.CreatedByUserId; ContactMeeting.CreatedByShellID = meeting.CreatedByShellID; ContactMeeting.CreatedByRoleID = meeting.CreatedByRoleID; ContactMeeting.AssignedToUserId = meeting.AssignedToUserId; ContactMeeting.AssignedToShellID = meeting.AssignedToShellID; ContactMeeting.AssignedToRoleID = meeting.AssignedToRoleID; ContactMeeting.ProspectID = meeting.ProspectID; ContactMeeting.Duration = meeting.Duration; ContactMeeting.Subject = meeting.Subject; ContactMeeting.Description = meeting.Description; ContactMeeting.StartDate = meeting.StartDate; ContactMeeting.StartTime = meeting.StartTime; ContactMeeting.CallStatus.CallStatusID = meeting.CallStatus.CallStatusID; ContactMeeting.Venue = meeting.Venue; if (ViewState["ContactMeetingID"] != null) { if (ViewState["ContactMeetingID"].ToString() != string.Empty) { temp = objMasterDal.SaveMeeting(ContactMeeting, Convert.ToInt32(EOperationMode.Update)); } } else { temp = objMasterDal.SaveMeeting(ContactMeeting, Convert.ToInt32(EOperationMode.Insert)); } } } } } else { if (ViewState["ContactMeetingID"] != null) { if (ViewState["ContactMeetingID"].ToString() != string.Empty) { temp = objMasterDal.SaveMeeting(meeting, Convert.ToInt32(EOperationMode.Update)); } } else { temp = objMasterDal.SaveMeeting(meeting, Convert.ToInt32(EOperationMode.Insert)); } } // Add Call if (chkboxCall.Checked) { EContactCall FollowUpCall = new EContactCall(); FollowUpCall.CallStatus = new ECallStatus(); FollowUpCall.Contact = new EContact(); FollowUpCall.IsActive = true; FollowUpCall.CreatedByUserId = meeting.CreatedByUserId; FollowUpCall.CreatedByShellID = meeting.CreatedByShellID; FollowUpCall.CreatedByRoleID = meeting.CreatedByRoleID; FollowUpCall.AssignedToUserId = meeting.AssignedToUserId; FollowUpCall.AssignedToShellID = meeting.AssignedToShellID; FollowUpCall.AssignedToRoleID = meeting.AssignedToRoleID; FollowUpCall.Contact.ContactID = meeting.Contact.ContactID; FollowUpCall.ProspectID = meeting.ProspectID; FollowUpCall.Duration = 0; //FollowUpCall.ContactCallID = meeting.ContactCallID; FollowUpCall.CallResult = 0; FollowUpCall.FutureAction = 0; // FollowUpCall.Subject = txtCallSubject.Text; FollowUpCall.Notes = ""; FollowUpCall.StartDate = txtCallStartDate.Text; FollowUpCall.StartTime = txtCallStartTime.Text; temp = objMasterDal.SaveCall(FollowUpCall, Convert.ToInt32(EOperationMode.Insert)); } //Add Meeting if (chkboxMeeting.Checked) { EContactMeeting objEContactMeeting = new EContactMeeting(); objEContactMeeting.Contact = new EContact(); objEContactMeeting.CallStatus = new ECallStatus(); objEContactMeeting.StartDate = txtMeetingStartDate.Text; objEContactMeeting.StartTime = txtMeetingStartTime.Text; objEContactMeeting.Venue = txtVenue.Text; objEContactMeeting.Subject = ""; objEContactMeeting.Description = ""; objEContactMeeting.AssignedToUserId = meeting.AssignedToUserId; objEContactMeeting.AssignedToShellID = meeting.AssignedToShellID; objEContactMeeting.AssignedToRoleID = meeting.AssignedToRoleID; objEContactMeeting.CreatedByUserId = meeting.CreatedByUserId; objEContactMeeting.CreatedByShellID = meeting.CreatedByShellID; objEContactMeeting.CreatedByRoleID = meeting.CreatedByRoleID; objEContactMeeting.Contact.ContactID = meeting.Contact.ContactID; objEContactMeeting.ProspectID = meeting.ProspectID; temp = objMasterDal.SaveMeeting(objEContactMeeting, Convert.ToInt32(EOperationMode.Insert)); } // Add Task if (chkboxTask.Checked) { if ((!string.IsNullOrEmpty(txtTask.Text)) || (!string.IsNullOrEmpty(txtTaskDueDate.Text)) || (!string.IsNullOrEmpty(txtTaskDueTime.Text))) { var masterDal = new Falcon.DataAccess.Master.MasterDAL(); var task = new Falcon.Entity.Other.ETask(); task.TaskStatusType = new Falcon.Entity.Other.ETaskStatusType(); task.TaskPriorityType = new Falcon.Entity.Other.ETaskPriorityType(); task.TaskType = new Falcon.Entity.Other.ETaskType(); task.UserShellModule = new Falcon.Entity.User.EUserShellModuleRole(); task.Active = true; task.Subject = txtTask.Text; if (txtTaskDueDate.Text != "") { task.DueDate = txtTaskDueDate.Text; } if (txtTaskDueTime.Text != "") { task.DueTime = txtTaskDueTime.Text; } task.Notes = ""; task.StartDate = DateTime.Now.ToString(); task.StartTime = DateTime.Now.ToString(); task.UserShellModule.ShellID = currentSession.CurrentOrganizationRole.OrganizationId.ToString(); task.UserShellModule.RoleShellID = (int)currentSession.CurrentOrganizationRole.OrganizationRoleUserId; task.UserShellModule.RoleID = currentSession.CurrentOrganizationRole.RoleId.ToString(); task.UserShellModule.UserID = currentSession.UserId.ToString(); task.ProspectID = meeting.ProspectID; task.ContactID = meeting.Contact.ContactID; task.CreatedBY = Convert.ToInt32(currentSession.UserId); task.ModifiedBY = Convert.ToInt32(currentSession.UserId); temp = masterDal.SaveTask(task, Convert.ToInt32(EOperationMode.Insert), currentSession.UserId.ToString(), currentSession.CurrentOrganizationRole.OrganizationId.ToString(), currentSession.CurrentOrganizationRole.RoleId.ToString()); if (temp == 0) { temp = 9999990; } } } // Assign prospect to salesrep if (ProspectID > 0) { if (currentSession.CurrentOrganizationRole.CheckRole((long)Roles.SalesRep)) { FranchisorDAL franchisorDAL = new FranchisorDAL(); franchisorDAL.AssignProspect(1, ProspectID, Convert.ToInt64(currentSession.UserId)); } } if (Request.QueryString["Referrer"] != null) { string strReferrer = Request.QueryString["Referrer"].ToString(); if ((strReferrer != string.Empty) && (strReferrer == "Calendar")) { Response.RedirectUser(this.ResolveUrl("~/App/Common/Calendar.aspx")); } } return(true); }