Esempio n. 1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="contact"></param>
    /// <param name="userID"></param>
    /// <param name="shell"></param>
    /// <param name="role"></param>
    /// <returns></returns>
    public Int64 SaveProspectContact(EContact contact, string userID, string shell, string role)
    {
        FranchisorDAL franchisorDAL = new FranchisorDAL();
        //Int64 returnresult = franchisorDAL.SaveNewProspectContact(contact, Convert.ToInt32(EOperationMode.Insert), prospectid, Convert.ToInt32(userID));
        Int64 returnresult = franchisorDAL.SaveContact(contact, Convert.ToInt32(EOperationMode.Insert), Convert.ToInt32(userID));

        if (returnresult > 0 && contact.ArrayProspectIDs != null)
        {
            foreach (Int64 prospectid in contact.ArrayProspectIDs)
            {
                franchisorDAL.SaveProspectContact(returnresult, prospectid, true);
                if (contact.ListProspectContactRole != null && contact.ListProspectContactRole.Count > 0)
                {
                    List <EProspectContactRole> listprospectcontactroleFORDAL = new List <EProspectContactRole>();
                    foreach (EProspectContactRole objproscontrole in contact.ListProspectContactRole)
                    {
                        if (objproscontrole.ProspectID == prospectid)
                        {
                            listprospectcontactroleFORDAL.Add(objproscontrole);
                        }
                    }

                    if (listprospectcontactroleFORDAL.Count > 0)
                    {
                        franchisorDAL.SaveProspectContactRoleMapping(listprospectcontactroleFORDAL, returnresult, prospectid);
                    }
                }
            }
        }

        return(returnresult);
    }
Esempio n. 2
0
    public Int64 UpdateContactDetail(EContact contact, string userID, string shell, string role)
    {
        FranchisorDAL franchisorDAL = new FranchisorDAL();
        Int64         returnresult  = franchisorDAL.SaveContact(contact, Convert.ToInt32(EOperationMode.Update), Convert.ToInt32(userID));

        if (returnresult >= 0)
        {
            returnresult = contact.ContactID;
        }
        else
        {
            returnresult = -1;
        }

        if (returnresult > 0 && contact.ArrayProspectIDs != null)
        {
            foreach (Int64 prospectid in contact.ArrayProspectIDs)
            {
                franchisorDAL.SaveProspectContact(returnresult, prospectid, true);
                var listprospectcontactroleFORDAL = new List <EProspectContactRole>();
                if (contact.ListProspectContactRole != null && contact.ListProspectContactRole.Count > 0)
                {
                    foreach (EProspectContactRole objproscontrole in contact.ListProspectContactRole)
                    {
                        if (objproscontrole.ProspectID == prospectid)
                        {
                            listprospectcontactroleFORDAL.Add(objproscontrole);
                        }
                    }
                }
                franchisorDAL.SaveProspectContactRoleMapping(listprospectcontactroleFORDAL, returnresult, prospectid);
            }
        }
        return(returnresult);
    }
Esempio n. 3
0
    /// <summary>
    /// To update prospect detail
    /// </summary>
    /// <param name="prospectList"></param>
    /// <param name="userID"></param>
    /// <param name="shell"></param>
    /// <param name="role"></param>
    /// <returns></returns>
    public Int64 UpdateProspectWithContact(EProspect prospect, string userID, string shell, string role)
    {
        FranchisorDAL franchisorDAL   = new FranchisorDAL();
        Int64         returnresult    = franchisorDAL.SaveProspect(prospect, Convert.ToInt32(EOperationMode.Update), userID, shell, role);
        Int64         returnContactID = 0;
        int           prospectid      = 0;

        if (returnresult == 0)
        {
            prospectid = Convert.ToInt32(prospect.ProspectID);

            if (prospect.AddressMailing != null)
            {
                // Save prospect mailing address
                franchisorDAL.SaveProspectAddress(prospect.AddressMailing, prospectid);
            }
            // Save prospect details
            if (prospect.ProspectDetails != null)
            {
                franchisorDAL.SaveProspectDetails(prospect.ProspectDetails, prospectid);
            }

            if (prospect.Contact != null && prospect.Contact.Count > 0)
            {
                for (int i = 0; i < prospect.Contact.Count; i++)
                {
                    if (prospect.Contact[i].IsDeleted == false)
                    {
                        // Save Prospect Communication
                        //returnContactID = franchisorDAL.SaveNewProspectContact(prospect.Contact[i], 2, prospectid, Convert.ToInt32(userID));
                        if (prospect.Contact[i].ContactID > 0)
                        {
                            returnContactID = franchisorDAL.SaveContact(prospect.Contact[i], Convert.ToInt32(EOperationMode.Update), Convert.ToInt32(userID));
                            if (returnContactID >= 0)
                            {
                                returnContactID = prospect.Contact[i].ContactID;
                            }
                            else
                            {
                                returnContactID = -1;
                            }
                        }
                        else
                        {
                            returnContactID = franchisorDAL.SaveContact(prospect.Contact[i], Convert.ToInt32(EOperationMode.Insert), Convert.ToInt32(userID));
                        }

                        if (returnContactID > 0)
                        {
                            franchisorDAL.SaveProspectContact(returnContactID, prospectid, true);
                            franchisorDAL.SaveProspectContactRoleMapping(prospect.Contact[i].ListProspectContactRole, returnContactID, prospectid);
                        }
                    }
                    else
                    {
                        //Deactivates the same record
                        franchisorDAL.SaveProspectContact(prospect.Contact[i].ContactID, prospectid, false);
                    }
                }
            }
        }
        if (prospect.ContactCall != null)
        {
            prospect.ContactCall.Contact           = new EContact();
            prospect.ContactCall.Contact.ContactID = Convert.ToInt32(returnContactID);
            prospect.ContactCall.ProspectID        = prospectid;
            franchisorDAL.SaveCall(prospect.ContactCall, Convert.ToInt32(EOperationMode.Insert));
        }
        if (prospect.ContactMeeting != null)
        {
            prospect.ContactMeeting.Contact           = new EContact();
            prospect.ContactMeeting.Contact.ContactID = Convert.ToInt32(returnContactID);
            prospect.ContactMeeting.ProspectID        = prospectid;
            franchisorDAL.SaveMeeting(prospect.ContactMeeting, Convert.ToInt32(EOperationMode.Insert));
        }
        if (prospect.Task != null)
        {
            prospect.Task.ContactID  = Convert.ToInt32(returnContactID);
            prospect.Task.ProspectID = prospectid;
            franchisorDAL.SaveTask(prospect.Task, Convert.ToInt32(EOperationMode.Insert), userID, shell, role);
        }

        return(returnresult);
    }
Esempio n. 4
0
    public Int64 UpdateHostWithContacts(EProspect prospect, string userID, string shell, string role)
    {
        FranchisorDAL franchisorDAL   = new FranchisorDAL();
        Int64         returnresult    = franchisorDAL.SaveHost(prospect, Convert.ToInt32(EOperationMode.Update), userID, shell, role);
        Int64         ContctID        = 0;
        Int64         returnContactID = 0;
        int           prospectid      = 0;

        if (returnresult == 0)
        {
            prospectid = Convert.ToInt32(prospect.ProspectID);

            // Save prospect details
            if (prospect.ProspectDetails != null)
            {
                franchisorDAL.SaveProspectDetails(prospect.ProspectDetails, prospectid);
            }

            if (prospect.Contact != null && prospect.Contact.Count > 0)
            {
                for (int i = 0; i < prospect.Contact.Count; i++)
                {
                    if (prospect.Contact[i].IsDeleted == false)
                    {
                        //returnContactID = franchisorDAL.SaveNewProspectContact(prospect.Contact[i], 2, prospectid, Convert.ToInt32(userID));
                        if (prospect.Contact[i].ContactID > 0)
                        {
                            returnContactID = franchisorDAL.SaveContact(prospect.Contact[i], Convert.ToInt32(EOperationMode.Update), Convert.ToInt32(userID));
                            if (returnContactID >= 0)
                            {
                                returnContactID = prospect.Contact[i].ContactID;
                            }
                            else
                            {
                                returnContactID = -1;
                            }
                        }
                        else
                        {
                            returnContactID = franchisorDAL.SaveContact(prospect.Contact[i], Convert.ToInt32(EOperationMode.Insert), Convert.ToInt32(userID));
                        }

                        if (returnContactID > 0)
                        {
                            franchisorDAL.SaveProspectContact(returnContactID, prospectid, true);
                            franchisorDAL.SaveProspectContactRoleMapping(prospect.Contact[i].ListProspectContactRole, returnContactID, prospectid);
                        }
                    }
                    else
                    {
                        //Delete the same record
                        franchisorDAL.SaveProspectContact(prospect.Contact[i].ContactID, prospectid, false);
                    }
                }
            }
            if (ContctID > 0 || prospectid > 0 && (prospect.ContactMeeting != null))
            {
                prospect.ContactMeeting.ProspectID        = prospectid;
                prospect.ContactMeeting.Contact.ContactID = Convert.ToInt32(returnContactID);
                franchisorDAL.SaveMeeting(prospect.ContactMeeting, Convert.ToInt32(EOperationMode.Insert));
            }
        }
        return(returnresult);
    }
Esempio n. 5
0
    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());
    }