private void PopulateSaleLead()
        {
            TBL_MP_CRM_SM_SalesLead model = _UNIT.SalesLeadService.GetLeadMasterDBInfo(this.selectedSalesLeadID);

            txtLead.Text = string.Format("{0} dt. {1}", model.LeadNo, model.LeadDate.ToString("dd-MMMM-yy"));
            tabPageLeadRequirements.Text  = string.Format("Party: {0}", model.LeadName);
            txtDescription.Text           = string.Format("{0}", model.LeadRequirement);
            txtProjectName.Text           = model.LeadName;
            cboProjectSector.SelectedItem = ((List <SelectListItem>)cboProjectSector.DataSource).Where(x => x.ID == model.FK_ProjectType).FirstOrDefault();
            txtProjectValue.Text          = string.Format("{0:0.00}", model.EstimatedValue);

            if (model.FK_LeadSource == Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.LeadSourceAgency].DEFAULT_VALUE)
            {
                rboAgent.Checked   = true; _EnqGeneratedBy = "A"; GeneratorAgentID = (int)model.FK_AgentID;
                txtGeneratdBy.Text = _UNIT.PartiesService.GetPartyNameByPartyID(GeneratorAgentID);
            }
        }
        private async void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                errorProvider1.Clear();
                if (this.ValidateChildren())
                {
                    this.Cursor = Cursors.WaitCursor;
                    GatherData();
                    if (this.SalesEnquiryID == 0)
                    {
                        EnquiryModel.FK_YearID    = Program.CURR_USER.FinYearID;
                        EnquiryModel.FK_BranchID  = Program.CURR_USER.BranchID;
                        EnquiryModel.FK_CompanyID = Program.CURR_USER.CompanyID;

                        this.SalesEnquiryID = _UNIT.SalesEnquiryService.AddNewSalesEnquiry(EnquiryModel);

                        // CHANGE STATUS OF LEAD TO CONVERTED TO ENQUIRY AND SET REMARKS
                        TBL_MP_CRM_SM_SalesLead existingLead = _UNIT.AppDBContext.TBL_MP_CRM_SM_SalesLead.Where(x => x.PK_SalesLeadID == EnquiryModel.FK_SalesLeadID).FirstOrDefault();
                        existingLead.FK_Status   = Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.LeadStatusConverted].DEFAULT_VALUE;
                        existingLead.ReasonClose = string.Format("Sales Enquiry: {0} dt. {1}", EnquiryModel.SalesEnquiry_No, EnquiryModel.SalesEnquiry_Date.ToString("dd MMM yy hh:mmtt"));
                        _UNIT.AppDBContext.SaveChanges();

                        _UNIT.SalesEnquiryService.GenerateDefaultsFromSalesLeadIntoSalesEnquiry(selectedSalesLeadID, this.SalesEnquiryID);
                        await _UNIT.SalesEnquiryService.SendSalesEnquiryCreationEmail(this.SalesEnquiryID);
                    }
                    else
                    {
                        _UNIT.AppDBContext.SaveChanges();
                    }
                    this.Cursor       = Cursors.Default;
                    this.DialogResult = DialogResult.OK;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "frmSalesEnquiry::btnSave_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void GatherData()
        {
            try
            {
                if (this.SalesEnquiryID == 0)
                {
                    EnquiryModel = new TBL_MP_CRM_SalesEnquiry();
                    EnquiryModel.SalesEnquiry_No = _UNIT.SalesEnquiryService.GenerateNewSalesEnquiryNumber(Program.CURR_USER.FinYearID, Program.CURR_USER.BranchID, Program.CURR_USER.CompanyID);
                }
                else
                {
                    EnquiryModel = _UNIT.AppDBContext.TBL_MP_CRM_SalesEnquiry.Where(x => x.PK_SalesEnquiryID == this.SalesEnquiryID).FirstOrDefault();
                }

                EnquiryModel.SalesEnquiry_Date = dtEnquiryDate.Value;
                EnquiryModel.Enquiry_Due_Date  = dtEnquiryDueDate.Value;
                EnquiryModel.FK_SalesLeadID    = this.selectedSalesLeadID;

                EnquiryModel.Enquiry_Genrated_By      = _EnqGeneratedBy;
                EnquiryModel.Enquiry_Genrated_By_Name = txtGeneratdBy.Text;
                if (rboEmployee.Checked)
                {
                    EnquiryModel.FK_EnqGenerated_Employee_ID = GeneratorEmployeeID;
                }
                if (rboAgent.Checked)
                {
                    EnquiryModel.FK_EnqGenerated_Agent_ID = GeneratorAgentID;
                }
                EnquiryModel.Project_Name                  = txtProjectName.Text;
                EnquiryModel.General_Description           = txtDescription.Text;
                EnquiryModel.FK_Userlist_Enquiry_Status_ID = (int)cboEnquiryStatus.SelectedValue;
                if (EnquiryModel.FK_Userlist_Enquiry_Status_ID == STATUS_CLOSED_ID || EnquiryModel.FK_Userlist_Enquiry_Status_ID == STATUS_LOST_ID)
                {
                    EnquiryModel.ReasonClose = txtReasonLost.Text;
                }
                EnquiryModel.FK_AssignedTo = (int)cboAssignedTo.SelectedValue;
                EnquiryModel.FK_Userlist_ProjectType_ID     = (int)cboProjectSector.SelectedValue;
                EnquiryModel.FK_Userlist_Project_SubType_ID = (int)cboProjectSubType.SelectedValue;
                EnquiryModel.FK_Userlist_EnquiryType_ID     = (int)cboSalesEnquiryType.SelectedValue;
                EnquiryModel.FK_Userlist_Submission_Mode_ID = (int)cboSumissionMode.SelectedValue;
                EnquiryModel.FK_Userlist_EnquirySource_ID   = (int)cboEnquirySource.SelectedValue;
                EnquiryModel.FK_Userlist_ProjectStatus_ID   = (int)cboProjectStatus.SelectedValue;
                EnquiryModel.Project_Value = decimal.Parse(txtProjectValue.Text.Trim());


                EnquiryModel.FK_Project_Country_ID = (int)cboProjectCounty.SelectedValue;
                EnquiryModel.FK_Project_State_ID   = (int)cboProjectState.SelectedValue;
                EnquiryModel.FK_Project_City_ID    = (int)cboProjectCity.SelectedValue;

                TBL_MP_CRM_SM_SalesLead lead = _UNIT.SalesLeadService.GetLeadMasterDBInfo(this.selectedSalesLeadID);
                if (lead != null)
                {
                    EnquiryModel.FK_Customer_ID = lead.FK_PartyID;
                    EnquiryModel.Customer_Name  = _UNIT.PartiesService.GetPartyNameByPartyID((int)lead.FK_PartyID);
                    //EnquiryModel.Customer_Address] [varchar] (2000) NULL,
                }
                if (this.SalesEnquiryID == 0)
                {
                    EnquiryModel.FK_PreparedBy   = Program.CURR_USER.EmployeeID;
                    EnquiryModel.FK_CompanyID    = Program.CURR_USER.CompanyID;
                    EnquiryModel.FK_BranchID     = Program.CURR_USER.BranchID;
                    EnquiryModel.FK_YearID       = Program.CURR_USER.FinYearID;
                    EnquiryModel.IsActive        = true;
                    EnquiryModel.CreatedDatetime = AppCommon.GetServerDateTime();
                }
                else
                {
                    EnquiryModel.LastModifiedDate = AppCommon.GetServerDateTime();
                    EnquiryModel.LastModifiedBy   = Program.CURR_USER.EmployeeID;
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "frmSalesEnquiry::GatherData", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void ScatterData()
        {
            if (this.SalesEnquiryID == 0)
            {
                return;
            }
            try
            {
                EnquiryModel = _UNIT.AppDBContext.TBL_MP_CRM_SalesEnquiry.Where(x => x.PK_SalesEnquiryID == this.SalesEnquiryID).FirstOrDefault();
                if (EnquiryModel != null)
                {
                    txtEnquiryNo.Text                = EnquiryModel.SalesEnquiry_No;
                    dtEnquiryDate.Value              = EnquiryModel.SalesEnquiry_Date;
                    dtEnquiryDueDate.Value           = EnquiryModel.Enquiry_Due_Date.Value;
                    cboSalesEnquiryType.SelectedItem = ((List <SelectListItem>)cboSalesEnquiryType.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_EnquiryType_ID).FirstOrDefault();
                    cboSumissionMode.SelectedItem    = ((List <SelectListItem>)cboSumissionMode.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_Submission_Mode_ID).FirstOrDefault();
                    cboEnquirySource.SelectedItem    = ((List <SelectListItem>)cboEnquirySource.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_EnquirySource_ID).FirstOrDefault();
                    cboEnquiryStatus.SelectedItem    = ((List <SelectListItem>)cboEnquiryStatus.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_Enquiry_Status_ID).FirstOrDefault();
                    cboAssignedTo.SelectedItem       = ((List <SelectListItem>)cboAssignedTo.DataSource).Where(x => x.ID == EnquiryModel.FK_AssignedTo).FirstOrDefault();
                    if (EnquiryModel.FK_Userlist_Enquiry_Status_ID == STATUS_CLOSED_ID || EnquiryModel.FK_Userlist_Enquiry_Status_ID == STATUS_LOST_ID)
                    {
                        EnquiryModel.ReasonClose       = txtReasonLost.Text;
                        tabPageLeadCloseReason.Visible = true;
                    }

                    TBL_MP_CRM_SM_SalesLead lead = _UNIT.SalesLeadService.GetLeadMasterDBInfo((int)EnquiryModel.FK_SalesLeadID);
                    if (lead != null)
                    {
                        selectedSalesLeadID = lead.PK_SalesLeadID;
                        PopulateSaleLead();
                    }

                    txtDescription.Text           = EnquiryModel.General_Description;
                    txtProjectName.Text           = EnquiryModel.Project_Name;
                    SelectedCountryID             = (int)EnquiryModel.FK_Project_Country_ID;
                    cboProjectCounty.SelectedItem = ((List <SelectListItem>)cboProjectCounty.DataSource).Where(x => x.ID == SelectedCountryID).FirstOrDefault();
                    PopulateProjectStatesDropDowns();
                    SelectedStateID = (int)EnquiryModel.FK_Project_State_ID;
                    cboProjectState.SelectedItem = ((List <SelectListItem>)cboProjectState.DataSource).Where(x => x.ID == SelectedStateID).FirstOrDefault();
                    PopulateProjectCitiesDropDowns();
                    SelectedCityID = (int)EnquiryModel.FK_Project_City_ID;
                    cboProjectCity.SelectedItem    = ((List <SelectListItem>)cboProjectCity.DataSource).Where(x => x.ID == SelectedCityID).FirstOrDefault();
                    txtProjectValue.Text           = string.Format("{0:0.00}", EnquiryModel.Project_Value);
                    cboProjectSector.SelectedItem  = ((List <SelectListItem>)cboProjectSector.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_ProjectType_ID).FirstOrDefault();
                    cboProjectSubType.SelectedItem = ((List <SelectListItem>)cboProjectSubType.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_Project_SubType_ID).FirstOrDefault();
                    cboProjectStatus.SelectedItem  = ((List <SelectListItem>)cboProjectStatus.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_ProjectStatus_ID).FirstOrDefault();



                    switch (EnquiryModel.Enquiry_Genrated_By)
                    {
                    case "R": rboRefrence.Checked = true; break;

                    case "A": rboAgent.Checked = true; GeneratorAgentID = (int)EnquiryModel.FK_EnqGenerated_Agent_ID; break;

                    case "E": rboEmployee.Checked = true; GeneratorEmployeeID = (int)EnquiryModel.FK_EnqGenerated_Employee_ID; break;
                    }
                    _EnqGeneratedBy    = EnquiryModel.Enquiry_Genrated_By;
                    txtGeneratdBy.Text = EnquiryModel.Enquiry_Genrated_By_Name;
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "frmSalesEnquiry::ScatterData", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #5
0
        public int GenerateNotificationFor(APP_ENTITIES entity, int selectedID, int empID, string titleText, string bodyText)
        {
            int newNotificationID = 0;

            try
            {
                string notificationURL   = string.Empty;
                string notificationTitle = string.Empty;
                string notificatrionBody = string.Empty;
                int    notificationType  = 0;
                switch (entity)
                {
                case APP_ENTITIES.SALES_LEAD:
                    TBL_MP_CRM_SM_SalesLead lead = _dbContext.TBL_MP_CRM_SM_SalesLead.Where(x => x.PK_SalesLeadID == selectedID).FirstOrDefault();
                    if (lead != null)
                    {
                        notificationTitle = titleText;
                        notificatrionBody = bodyText;
                        notificationURL   = string.Format("../CRM/FrmMP_CRM_SM_SalesLead_AddEdit.aspx?LID={0}", selectedID);
                        notificationType  = (int)NOTIFICATION_CATEGORIES.NOTIFICATION_CRM;
                    }
                    break;

                case APP_ENTITIES.SALES_ENQUIRY:
                    TBL_MP_CRM_SM_SalesLead enquiry = _dbContext.TBL_MP_CRM_SM_SalesLead.Where(x => x.PK_SalesLeadID == selectedID).FirstOrDefault();
                    if (enquiry != null)
                    {
                        notificationTitle = titleText;
                        notificatrionBody = bodyText;
                        notificationURL   = string.Format("../CRM/FrmMP_CRM_SM_SalesLead_AddEdit.aspx?LID={0}", selectedID);
                        notificationType  = (int)NOTIFICATION_CATEGORIES.NOTIFICATION_CRM;
                    }
                    break;

                case APP_ENTITIES.SALES_QUOTATION:
                    TBL_MP_CRM_SM_SalesLead quotation = _dbContext.TBL_MP_CRM_SM_SalesLead.Where(x => x.PK_SalesLeadID == selectedID).FirstOrDefault();
                    if (quotation != null)
                    {
                        notificationTitle = titleText;
                        notificatrionBody = bodyText;
                        notificationType  = (int)NOTIFICATION_CATEGORIES.NOTIFICATION_CRM;
                    }
                    break;

                case APP_ENTITIES.SALES_ORDER:
                    TBL_MP_CRM_SM_SalesLead order = _dbContext.TBL_MP_CRM_SM_SalesLead.Where(x => x.PK_SalesLeadID == selectedID).FirstOrDefault();
                    if (order != null)
                    {
                        notificationTitle = titleText;
                        notificatrionBody = bodyText;
                        notificationType  = (int)NOTIFICATION_CATEGORIES.NOTIFICATION_CRM;
                    }
                    break;
                }
                //insert this notification in notification table
                TBL_MP_COMMON_Notification model = new TBL_MP_COMMON_Notification();
                model.NotificationTitle = notificationTitle;
                model.NotificationBody  = notificatrionBody;
                model.FK_EMPLOYEEID     = empID;
                model.URL = notificationURL;
                model.FK_NotificationType = notificationType;

                _dbContext.TBL_MP_COMMON_Notification.Add(model);
                _dbContext.SaveChanges();

                newNotificationID = model.PK_NotificationID;
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(newNotificationID);
        }
Beispiel #6
0
        public bool GatherData()
        {
            bool result = false;

            try
            {
                if (this.SelectedLeadID == 0)
                {
                    model = new TBL_MP_CRM_SM_SalesLead();
                }
                else
                {
                    model = _UNIT.SalesLeadService.GetLeadMasterDBInfo(this.SelectedLeadID);
                }

                if (model == null)
                {
                    MessageBox.Show("Cannot create Lead Master Object"); return(false);
                }

                model.LeadNo   = txtLeadNumber.Text.ToString();
                model.LeadDate = dtLeadDate.Value;
                if (model.LeadDate == null)
                {
                    MessageBox.Show("Select a valid Date of Lead creation", "GatherData", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                if (cboCompanies.SelectedItem != null)
                {
                    model.FK_PartyID = (int)cboCompanies.SelectedValue;
                    Tbl_MP_Master_Party party = _UNIT.PartiesService.GetPartyByPartyID((int)cboCompanies.SelectedValue);
                    if (party != null)
                    {
                        model.LeadName    = party.PartyName;
                        model.LeadEmailID = party.EmailID;
                        model.LeadWebsite = party.Website;
                    }
                }
                else
                {
                    MessageBox.Show("Select a valid Company and its Contacts to continue", "GatherData", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                model.LeadRequirement = txtLeadRequirements.Text;

                if (txtEstimatedValue.Text.Trim() != string.Empty)
                {
                    model.EstimatedValue       = Convert.ToDecimal(txtEstimatedValue.Text);
                    model.FK_EstimatedCurrency = (int)cboCurrency.SelectedValue;
                }
                else
                {
                    model.EstimatedValue = null;
                }

                if (cboAssignedTo.SelectedItem != null)
                {
                    model.FK_LeadAssignTo = (int)cboAssignedTo.SelectedValue;
                }
                else
                {
                    model.FK_LeadAssignTo = null;
                }
                if (model.FK_LeadAssignTo == null)
                {
                    MessageBox.Show("Select a valid Assignee for this Lead", "GatherData", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                if (cboProjectSector.SelectedItem != null)
                {
                    model.FK_ProjectType = (int)cboProjectSector.SelectedValue;
                }
                else
                {
                    model.FK_ProjectType = null;
                }


                model.FK_Status = (int)cboSalesLeadStatus.SelectedValue;
                if (model.FK_Status == closeStatusID || model.FK_Status == lostStatusID)
                {
                    model.ReasonClose = txtReasonLost.Text;
                }

                model.FK_LeadSource = (int)cboLeadSources.SelectedValue;
                if (model.FK_LeadSource != null)
                {
                    if (model.FK_LeadSource == Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.LeadSourceAgency].DEFAULT_VALUE)
                    {
                        model.FK_AgentID = (int)cboAgencies.SelectedValue;
                        if (model.FK_AgentID == null)
                        {
                            MessageBox.Show("Select a valid Agency/Consultant of Lead", "GatherData", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Select a valid Source of Lead", "GatherData", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }


                result = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "frmSalesLead::GatherData", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            return(result);
        }
Beispiel #7
0
        public void ScatterData()
        {
            try
            {
                model = _UNIT.SalesLeadService.GetLeadMasterDBInfo(this.SelectedLeadID);
                if (model != null)
                {
                    txtLeadNumber.Text = model.LeadNo;
                    dtLeadDate.Value   = model.LeadDate;

                    txtLeadRequirements.Text   = model.LeadRequirement;
                    txtGeneratedBy.Text        = ServiceEmployee.GetEmployeeNameByID((int)model.FK_LeadGeneratedBy);
                    cboAssignedTo.SelectedItem = ((List <SelectListItem>)cboAssignedTo.DataSource).Where(x => x.ID == model.FK_LeadAssignTo).FirstOrDefault();

                    cboSalesLeadStatus.SelectedItem = ((List <SelectListItem>)cboSalesLeadStatus.DataSource).Where(x => x.ID == model.FK_Status).FirstOrDefault();
                    if (model.FK_Status == Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.LeadStatusClose].DEFAULT_VALUE)
                    {
                        txtReasonLost.Text             = model.ReasonClose;
                        tabPageLeadCloseReason.Visible = true;
                    }

                    cboCompanies.SelectedItem = ((List <SelectListItem>)cboCompanies.DataSource).Where(x => x.ID == model.FK_PartyID).FirstOrDefault();
                    //scatter lead contacts
                    this.SelectedPartyID = ((SelectListItem)cboCompanies.SelectedItem).ID;
                    PopulateContactsGrid();
                    List <SelectContactModel> lstContacts = _UNIT.SalesLeadService.GetContactsForLeadID(this.SelectedLeadID);
                    if (lstContacts != null)
                    {
                        foreach (SelectContactModel contact in (List <SelectContactModel>)gridContacts.DataSource)
                        {
                            SelectContactModel found = lstContacts.Where(x => x.ContactID == contact.ContactID).FirstOrDefault();
                            if (found != null)
                            {
                                contact.Selected = true;
                            }
                        }
                    }

                    cboLeadSources.SelectedItem = ((List <SelectListItem>)cboLeadSources.DataSource).Where(x => x.ID == model.FK_LeadSource).FirstOrDefault();
                    if (model.FK_LeadSource == Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.LeadSourceAgency].DEFAULT_VALUE)
                    {
                        cboAgencies.SelectedItem = ((List <SelectListItem>)cboAgencies.DataSource).Where(x => x.ID == model.FK_AgentID).FirstOrDefault();
                        cboAgencies.Enabled      = btnAddAgency.Enabled = true;
                    }
                    else
                    {
                        cboAgencies.Enabled = btnAddAgency.Enabled = false;
                    }

                    if (model.EstimatedValue != null)
                    {
                        txtEstimatedValue.Text   = string.Format("{0:0.00}", model.EstimatedValue);
                        cboCurrency.SelectedItem = ((List <SelectListItem>)cboCurrency.DataSource).Where(x => x.ID == model.FK_EstimatedCurrency).FirstOrDefault();
                    }
                    else
                    {
                        txtEstimatedValue.Text = string.Empty;
                    }

                    cboProjectSector.SelectedItem = ((List <SelectListItem>)cboProjectSector.DataSource).Where(x => x.ID == model.FK_ProjectType).FirstOrDefault();

                    txtLeadRequirements.Text = model.LeadRequirement;
                }
                Application.DoEvents();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "frmSalesLead::ScatterData", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public async Task <bool> SendFollowUpEmail(int followupID)
        {
            bool   result     = false;
            string strSubject = string.Empty;
            string strMessage = string.Empty;
            string strMailTo  = string.Empty;

            try
            {
                TBL_MP_CRM_ScheduleCallLogFollowUp followup = _dbContext.TBL_MP_CRM_ScheduleCallLogFollowUp.Where(x => x.FollowUpID == followupID).FirstOrDefault();
                if (followup == null)
                {
                    MessageBox.Show("Unable to locate a valid Followup"); return(false);
                }

                TBL_MP_CRM_ScheduleCallLog schdeule = _dbContext.TBL_MP_CRM_ScheduleCallLog.Where(x => x.ScheduleID == followup.ScheduleID).FirstOrDefault();
                if (schdeule == null)
                {
                    MessageBox.Show("Unable to locate a valid Schedule for the selected FolowUp"); return(false);
                }

                strSubject  = string.Format("FOLLOWUP- {0}", schdeule.Subject);
                strMessage += string.Format("REMARKS\n{0}\n", followup.FollowUpRemark);
                strMessage += string.Format("\nAttended By - {0}", followup.TBL_MP_Master_Employee.EmployeeName);
                strMessage += string.Format("\nStatus - {0}", followup.TBL_MP_Admin_UserList.Admin_UserList_Desc);

                if ((bool)followup.NextFollowupRequired)
                {
                    strMessage += string.Format("\n\nNEXT FOLLOWUP DETAILS\n\n");
                    strMessage += String.Format("{0}\n", followup.NextFollowUpSubject);
                    strMessage += String.Format("Timings: {0} - {1}\n\n", followup.NextFollowUpStartDatetime.Value.ToString("dd MMM yy hh:mmtt"), followup.NextFollowUpEndDatetime.Value.ToString("dd MMM yy hh:mmtt"));
                    strMessage += String.Format("\nParty Name: {0}", schdeule.CustomerName.ToUpper());
                    strMessage += String.Format("\nContact: {0}", followup.NextFollowUpContactName.ToUpper());
                    strMessage += String.Format("\nPhone: {0}", followup.NextFollowUpContactNumber);
                    strMessage += String.Format("\nLocation: {0}\n", followup.NextFollowUpLocation);
                }
                else
                {
                    strMessage += string.Format("\n\nCLIENT INFO.\n");
                    strMessage += String.Format("\nParty Name: {0}", schdeule.CustomerName.ToUpper());
                    strMessage += String.Format("\nContact: {0}", schdeule.ContactPerson);
                    strMessage += String.Format("\nPhone: {0}", schdeule.ContactNumber);
                    strMessage += String.Format("\nLocation: {0}\n", schdeule.Location);
                }

                strMessage += String.Format("\n\nSOURCE INFO:\n");
                switch ((APP_ENTITIES)schdeule.EntityType)
                {
                case APP_ENTITIES.SALES_LEAD:
                    TBL_MP_CRM_SM_SalesLead lead = _dbContext.TBL_MP_CRM_SM_SalesLead.Where(x => x.PK_SalesLeadID == schdeule.EntityID).FirstOrDefault();
                    if (lead != null)
                    {
                        strMessage += String.Format("\nLead: {0} dt. {1}\n", lead.LeadNo, lead.LeadDate.ToString("dd MMM yyyy"));
                        strMessage += String.Format("\n{0}\n", lead.LeadRequirement);
                    }
                    break;
                }

                List <TBL_MP_CRM_ScheduleCallLogAssignee> lstAssignees = _dbContext.TBL_MP_CRM_ScheduleCallLogAssignee.Where(x => x.ScheduleID == schdeule.ScheduleID).Where(x => x.IsDeleted == false).ToList();
                foreach (TBL_MP_CRM_ScheduleCallLogAssignee ass in lstAssignees)
                {
                    strMailTo += ass.TBL_MP_Master_Employee.EmailAddress + ";";
                }
                string       strMailFrom = ServiceEmployee.GetEmployeeEmailByID((int)followup.CreatedBy);
                ServiceEmail mail        = new ServiceEmail();
                await mail.SendEmail((int)followup.CreatedBy, strMailFrom, strMailTo, strSubject, strMessage);

                result = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ServiceScheduleCallLog::SendFollowUpEmail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(result);
        }