Пример #1
0
        private void PopulateMessageBodyDefault()
        {
            switch (this.SOURCE_ENTITY)
            {
            case APP_ENTITIES.SALES_LEAD:
                LeadMasterInfoModel model = (new ServiceSalesLead()).GetLeadMasterInfo(this.SOURCE_ENTITY_ID);
                if (model != null)
                {
                    txtMessage.Text  = string.Format("\n\nLead : {0} dt. {1}", model.LeadNo, model.LeadDate.Value.ToString("dd MMM yyyy"));
                    txtMessage.Text += string.Format("\nParty : {0} ", model.LeadName);
                    txtMessage.Text += string.Format("\nRequirement:\n{0} ", model.LeadRequirement);
                }
                break;

            case APP_ENTITIES.SALES_ENQUIRY:
                TBL_MP_CRM_SalesEnquiry dbEnquiry = (new ServiceSalesEnquiry()).GetEnquiryMasterDBInfo(this.SOURCE_ENTITY_ID);
                if (dbEnquiry != null)
                {
                    txtMessage.Text  = string.Format("\n\nEnquiry : {0} dt. {1}", dbEnquiry.SalesEnquiry_No, dbEnquiry.SalesEnquiry_Date.ToString("dd MMM yyyy"));
                    txtMessage.Text += string.Format("\nParty : {0} ", dbEnquiry.Tbl_MP_Master_Party.PartyName);
                    txtMessage.Text += string.Format("\nRequirement:\n{0} ", dbEnquiry.General_Description);
                }
                break;
            }
        }
        public ScheduleCallAddEditModel GetSchdeuledCallAddEditModelForSchedule(int scheduleID)
        {
            ScheduleCallAddEditModel model = new ScheduleCallAddEditModel()
            {
                ScheduleID = scheduleID
            };

            try
            {
                TBL_MP_CRM_ScheduleCallLog log = _dbContext.TBL_MP_CRM_ScheduleCallLog.Where(x => x.ScheduleID == model.ScheduleID).FirstOrDefault();
                if (log != null)
                {
                    model.SOURCE_ENTITY    = (APP_ENTITIES)log.EntityType;
                    model.SOURCE_ENTITY_ID = (int)log.EntityID;
                    model.DB_MODEL         = log;
                    model.listAssignees    = this.GelAllAssigneesForSchedule(model.ScheduleID);
                    string strCaption = string.Empty;
                    switch (model.SOURCE_ENTITY)
                    {
                    case APP_ENTITIES.SALES_LEAD:
                        LeadMasterInfoModel leadInfo = (new ServiceSalesLead(_dbContext)).GetLeadMasterInfo(model.SOURCE_ENTITY_ID);
                        strCaption = string.Format("LEAD: {0} {1} dt. {2}", leadInfo.LeadNo, leadInfo.LeadName, leadInfo.LeadDate.Value.ToString("dd MMM yyyy"));
                        break;

                    case APP_ENTITIES.SALES_ENQUIRY:
                        TBL_MP_CRM_SalesEnquiry EnquiryInfo = (new ServiceSalesEnquiry(_dbContext)).GetEnquiryMasterDBInfo(model.SOURCE_ENTITY_ID);
                        strCaption = string.Format("ENQURIY: {0} dt. {1}", EnquiryInfo.SalesEnquiry_No, EnquiryInfo.SalesEnquiry_Date.ToString("dd MMM yyyy"));
                        break;

                    case APP_ENTITIES.SALES_QUOTATION:
                        TBL_MP_CRM_SalesQuotation QuotationInfo = (new ServiceSalesQuotation(_dbContext)).GetSalesQuotationMasterDBInfo(model.SOURCE_ENTITY_ID);
                        strCaption = string.Format("QUOTATION: {0} dt. {1}", QuotationInfo.Quotation_No, QuotationInfo.Quotation_Date.ToString("dd MMM yyyy"));
                        break;

                    case APP_ENTITIES.SALES_ORDER:
                        TBL_MP_CRM_SalesOrder OrderInfo = (new ServiceSalesOrder(_dbContext)).GetSalesOrderDBInfoByID(model.SOURCE_ENTITY_ID);
                        strCaption = string.Format("ORDER: {0} dt. {1}", OrderInfo.SalesOrderNo, OrderInfo.SalesOrderDate.ToString("dd MMM yyyy"));
                        break;
                    }
                    model.HeaderTitle = strCaption;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ServiceScheduleCallLog::GetSchdeuledCallInfo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(model);
        }
Пример #3
0
        public void PopulateLeadMasterInfo()
        {
            try
            {
                LeadMasterInfoModel _masterInfo = (new ServiceSalesLead()).GetLeadMasterInfo(this.SelectedLeadID);
                if (_masterInfo != null)
                {
                    headerGroupMain.ValuesPrimary.Heading = string.Format("{0} dt. {1}", _masterInfo.LeadNo, _masterInfo.LeadDate.Value.ToString("dd-MM-yyyy"));

                    headerStatus.Text        = string.Format("Status : {0}", _masterInfo.LeadStatus.ToUpper());
                    txtStatusDetails.Text    = _masterInfo.LeadStatusDescription;
                    lblLeadApprovalInfo.Text = _masterInfo.ApprovedBy;
                    lblLeadApprovalInfo.StateCommon.Back.Color1 = (_masterInfo.IsApproved)? Color.Green : Color.Red;
                    if (!ReadOnly)
                    {
                        WhosWhoModel model = Program.CONTROL_ACCESS.ListControlAccess.Where(x => x.FormID == this.SALES_LEAD_FORM_ID).FirstOrDefault();
                        if (model != null)
                        {
                            if (model.CanApprove)
                            {
                                if (_masterInfo.IsApproved == false)
                                {
                                    btnApproveLead.Visible = true;
                                }
                                else
                                {
                                    btnApproveLead.Visible = false;
                                }
                            }
                            else
                            {
                                btnApproveLead.Visible = false;
                            }
                        }
                    }

                    lblLeadName.Text       = string.Format("{0}", _masterInfo.LeadName);
                    lblWebSiteEmailId.Text = String.Format("{0}", _masterInfo.WebSite);
                    lblEmailId.Text        = string.Format("{0}", _masterInfo.EmailId);
                    lblLedRequirement.Text = string.Format("{0}", _masterInfo.LeadRequirement);
                    lblLeadSource.Text     = string.Format("{0}", _masterInfo.LeadSource);

                    lblEstimatedValue.Text = string.Format("{1} {0:0.00}", _masterInfo.EstimatedValue, _masterInfo.EstimatedValueCurrency);

                    lblGeneratedBy.Text = string.Format("{0}", _masterInfo.GeneratedBy);

                    lblAssignedTo.Text    = string.Format("{0}", _masterInfo.AssignedTo);
                    lblProjectSector.Text = string.Format("{0}", _masterInfo.ProjectSector);

                    gridContacts.DataSource = _service.GetContactsForLeadID(this.SelectedLeadID);
                    gridContacts.Columns["Selected"].Visible = gridContacts.Columns["ContactID"].Visible = false;

                    headerGroupMain.ValuesSecondary.Heading     = _masterInfo.CreationInfo;
                    headerGroupMain.ValuesSecondary.Description = _masterInfo.ModificationInfo;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ctrlSalesLeadGeneralDetails::PoulateLeadMasterInfo");
            }
        }
Пример #4
0
        public void PrepareForInsert()
        {
            DB_MODEL = new TBL_MP_CRM_ScheduleCallLog();
            string strCaption          = string.Empty;
            string strContactNames     = string.Empty;
            string strContactNumbers   = string.Empty;
            string strContactAddresses = string.Empty;

            try
            {
                switch (this.SOURCE_ENTITY)
                {
                case APP_ENTITIES.SALES_LEAD:
                    LeadMasterInfoModel leadInfo = (new ServiceSalesLead()).GetLeadMasterInfo(this.SOURCE_ENTITY_ID);
                    strCaption            = string.Format("LEAD: {0} {1} dt. {2}", leadInfo.LeadNo, leadInfo.LeadName, leadInfo.LeadDate.Value.ToString("dd MMM yyyy"));
                    DB_MODEL.CustomerName = leadInfo.LeadName;

                    List <SelectContactModel> listContacts = (new ServiceSalesLead()).GetContactsForLeadID(this.SOURCE_ENTITY_ID);
                    DB_MODEL.ContactPerson = string.Empty;
                    foreach (SelectContactModel model in listContacts)
                    {
                        string[] names = model.Description1.Split('\n');
                        DB_MODEL.ContactPerson += names[0] + ", ";
                        DB_MODEL.ContactNumber += model.Description2 + ", ";
                        DB_MODEL.Location      += model.Description1.Replace(names[0], "");
                    }

                    DB_MODEL.ContactPerson = DB_MODEL.ContactPerson.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.ContactNumber = DB_MODEL.ContactNumber.TrimEnd(' ').TrimEnd(',');

                    break;

                case APP_ENTITIES.SALES_ENQUIRY:
                    TBL_MP_CRM_SalesEnquiry dbEnquiry = (new ServiceSalesEnquiry()).GetEnquiryMasterDBInfo(this.SOURCE_ENTITY_ID);
                    strCaption            = string.Format("ENQUIRY: {0} {1} dt. {2}", dbEnquiry.SalesEnquiry_No, dbEnquiry.Project_Name, dbEnquiry.SalesEnquiry_Date.ToString("dd MMM yyyy"));
                    DB_MODEL.CustomerName = dbEnquiry.Tbl_MP_Master_Party.PartyName;
                    List <TBL_MP_CRM_SM_ContactReferences> listEnquiryContacts = (new ServiceSalesEnquiry()).GetAllCompanyContactsForSalesEnquiryDB(this.SOURCE_ENTITY_ID);
                    strContactNames = strContactNumbers = strContactAddresses = string.Empty;
                    foreach (TBL_MP_CRM_SM_ContactReferences refContact in listEnquiryContacts)
                    {
                        strContactNames     += string.Format("{0}\n", refContact.Tbl_MP_Master_PartyContact_Detail.ContactPersoneName);
                        strContactAddresses += string.Format("{0}\n\n", refContact.Tbl_MP_Master_PartyContact_Detail.Address);
                        strContactNumbers   += string.Format("Mobile: {0}  {1}", refContact.Tbl_MP_Master_PartyContact_Detail.MobileNo, refContact.Tbl_MP_Master_PartyContact_Detail.AltMobileNo);
                        strContactNumbers   += string.Format("Tel: {0}  {1}\n", refContact.Tbl_MP_Master_PartyContact_Detail.TelephoneNo, refContact.Tbl_MP_Master_PartyContact_Detail.AltTelephoneNo);
                    }

                    DB_MODEL.ContactPerson = strContactNames.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.ContactNumber = strContactNumbers.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.Location      = strContactAddresses;
                    break;

                case APP_ENTITIES.SALES_QUOTATION:
                    TBL_MP_CRM_SalesQuotation dbQuote = (new ServiceSalesQuotation()).GetSalesQuotationMasterDBInfo(this.SOURCE_ENTITY_ID);
                    strCaption            = string.Format("ENQUIRY: {0} dt. {1}", dbQuote.Quotation_No, dbQuote.Quotation_Date.ToString("dd MMM yyyy"));
                    DB_MODEL.CustomerName = dbQuote.Tbl_MP_Master_Party.PartyName;
                    List <TBL_MP_CRM_SM_ContactReferences> listQuoteContacts = (new ServiceSalesQuotation()).GetAllCompanyContactsForSalesQuotationDB(this.SOURCE_ENTITY_ID);
                    strContactNames = strContactNumbers = strContactAddresses = string.Empty;
                    foreach (TBL_MP_CRM_SM_ContactReferences refContact in listQuoteContacts)
                    {
                        strContactNames     += string.Format("{0}\n", refContact.Tbl_MP_Master_PartyContact_Detail.ContactPersoneName);
                        strContactAddresses += string.Format("{0}\n\n", refContact.Tbl_MP_Master_PartyContact_Detail.Address);
                        strContactNumbers   += string.Format("Mobile: {0}  {1}", refContact.Tbl_MP_Master_PartyContact_Detail.MobileNo, refContact.Tbl_MP_Master_PartyContact_Detail.AltMobileNo);
                        strContactNumbers   += string.Format("Tel: {0}  {1}\n", refContact.Tbl_MP_Master_PartyContact_Detail.TelephoneNo, refContact.Tbl_MP_Master_PartyContact_Detail.AltTelephoneNo);
                    }

                    DB_MODEL.ContactPerson = strContactNames.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.ContactNumber = strContactNumbers.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.Location      = strContactAddresses;
                    break;

                case APP_ENTITIES.SALES_ORDER:
                    TBL_MP_CRM_SalesOrder dbOrder = (new ServiceSalesOrder()).GetSalesOrderDBInfoByID(this.SOURCE_ENTITY_ID);
                    strCaption            = string.Format("ORDER: {0} dt. {1}", dbOrder.SalesOrderNo, dbOrder.SalesOrderDate.ToString("dd MMM yyyy"));
                    DB_MODEL.CustomerName = dbOrder.Tbl_MP_Master_Party.PartyName;
                    List <TBL_MP_CRM_SM_ContactReferences> listOrderContacts = (new ServiceSalesOrder()).GetAllCompanyContactsForSalesOrderDB(this.SOURCE_ENTITY_ID);
                    strContactNames = strContactNumbers = strContactAddresses = string.Empty;
                    foreach (TBL_MP_CRM_SM_ContactReferences refContact in listOrderContacts)
                    {
                        strContactNames     += string.Format("{0}\n", refContact.Tbl_MP_Master_PartyContact_Detail.ContactPersoneName);
                        strContactAddresses += string.Format("{0}\n\n", refContact.Tbl_MP_Master_PartyContact_Detail.Address);
                        strContactNumbers   += string.Format("Mobile: {0}  {1}", refContact.Tbl_MP_Master_PartyContact_Detail.MobileNo, refContact.Tbl_MP_Master_PartyContact_Detail.AltMobileNo);
                        strContactNumbers   += string.Format("Tel: {0}  {1}\n", refContact.Tbl_MP_Master_PartyContact_Detail.TelephoneNo, refContact.Tbl_MP_Master_PartyContact_Detail.AltTelephoneNo);
                    }

                    DB_MODEL.ContactPerson = strContactNames.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.ContactNumber = strContactNumbers.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.Location      = strContactAddresses;
                    break;
                }

                DateTime currDatetime = AppCommon.GetServerDateTime();
                DB_MODEL.StartAt  = currDatetime;
                DB_MODEL.EndsAt   = currDatetime.AddDays(1);
                DB_MODEL.Reminder = currDatetime.AddHours(-1);
                HeaderTitle       = strCaption;

                BindingList <MultiSelectListItem> allEmployees = AppCommon.ConvertToBindingList <MultiSelectListItem>((new ServiceMASTERS()).GetAllEmployeesMultiSelect());
                this.listAssignees = new BindingList <MultiSelectListItem>();
                MultiSelectListItem emp = allEmployees.Where(x => x.ID == currEmpID).FirstOrDefault();
                if (emp != null)
                {
                    this.listAssignees.Add(emp);
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ScheduleCallAddEditModel::PrepareForInsert", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public async Task <int> AddNewScheduleCall(ScheduleCallAddEditModel model, int createdBy)
        {
            string strMessage      = string.Empty;
            string strAssignees    = string.Empty;
            string strRequirements = string.Empty;

            try
            {
                progressForm      = new frmProgress();
                progressForm.Text = "CREATING A NEW SCHEDULE CALL";
                progressForm.lblProgressText.Text = "Inserting a New Business Schecule Call";
                progressForm.Show();
                Application.DoEvents();


                model.DB_MODEL.EntityType      = (int)model.SOURCE_ENTITY;
                model.DB_MODEL.EntityID        = (int)model.SOURCE_ENTITY_ID;
                model.DB_MODEL.CreatedBy       = createdBy;
                model.DB_MODEL.CreatedDatetime = AppCommon.GetServerDateTime();
                model.DB_MODEL.Reminder        = model.DB_MODEL.Reminder;
                model.DB_MODEL.IsDeleted       = false;
                model.DB_MODEL.Completed       = false;
                _dbContext.TBL_MP_CRM_ScheduleCallLog.Add(model.DB_MODEL);
                _dbContext.SaveChanges();
                model.ScheduleID = model.DB_MODEL.ScheduleID;

                progressForm.SetProgress(30, string.Format("\nSuccess ID: {0}\n\nInserting Assignees for this schedule in Database.", model.ScheduleID));
                Application.DoEvents();
                string mailTo = string.Empty;
                foreach (MultiSelectListItem item in model.listAssignees)
                {
                    _dbContext.TBL_MP_CRM_ScheduleCallLogAssignee.Add(new TBL_MP_CRM_ScheduleCallLogAssignee()
                    {
                        EmployeeID = item.ID,
                        IsDeleted  = false,
                        ScheduleID = model.ScheduleID
                    });
                    strAssignees += item.Description.Split('\n')[0] + " , ";
                    _dbContext.SaveChanges();
                    mailTo += ServiceEmployee.GetEmployeeEmailByID(item.ID) + ";";
                }
                strAssignees = strAssignees.TrimEnd(' ').TrimEnd(',');
                mailTo      += "*****@*****.**";
                progressForm.SetProgress(60, string.Format("\nSuccess: {0} Assignee(s) inserted in Database for Schdeule #{1}", model.listAssignees.Count, model.ScheduleID));
                progressForm.SetProgress(60, string.Format("\n\n\nSending Email to {0}", mailTo.Replace(";", "; ")));
                Application.DoEvents();
                ServiceEmail mail       = new ServiceEmail();
                string       strSubject = string.Format("New Schedule Call: {0}", model.DB_MODEL.Subject.ToUpper());

                switch (model.SOURCE_ENTITY)
                {
                case APP_ENTITIES.SALES_LEAD:
                    LeadMasterInfoModel lead = (new ServiceSalesLead(_dbContext)).GetLeadMasterInfo(model.SOURCE_ENTITY_ID);
                    if (lead != null)
                    {
                        strMessage     += String.Format("\n\n\nLead No.: {0} dt. {1}\nParty Name: {2}\n", lead.LeadNo, lead.LeadDate.Value.ToString("dd MMMyy"), lead.LeadName);
                        strRequirements = string.Format("Lead Requirements:\n{0}", lead.LeadRequirement);
                    }
                    break;

                case APP_ENTITIES.SALES_ENQUIRY:
                    TBL_MP_CRM_SalesEnquiry enquiry = (new ServiceSalesEnquiry(_dbContext)).GetEnquiryMasterDBInfo(model.SOURCE_ENTITY_ID);
                    if (enquiry != null)
                    {
                        strMessage += String.Format("\n\n\nEnquiry No.: {0} dt. {1}\nParty Name: {2}\n",
                                                    enquiry.SalesEnquiry_No,
                                                    enquiry.SalesEnquiry_Date.ToString("dd MMMyy"),
                                                    enquiry.Tbl_MP_Master_Party.PartyName);
                        strRequirements = string.Format("Description:\n{0}", enquiry.General_Description);
                    }
                    break;

                case APP_ENTITIES.SALES_QUOTATION:
                    TBL_MP_CRM_SalesQuotation quotation = (new ServiceSalesQuotation(_dbContext)).GetSalesQuotationMasterDBInfo(model.SOURCE_ENTITY_ID);
                    if (quotation != null)
                    {
                        strMessage += String.Format("\n\n\n Quotation No.: {0} dt. {1}\nParty Name: {2}\n",
                                                    quotation.Quotation_No,
                                                    quotation.Quotation_Date.ToString("dd MMMyy"),
                                                    quotation.Tbl_MP_Master_Party.PartyName);
                        strRequirements = string.Format("Special Note:\n{0}", quotation.SpecialNotes);
                    }
                    break;

                case APP_ENTITIES.SALES_ORDER:
                    TBL_MP_CRM_SalesOrder order = (new ServiceSalesOrder(_dbContext)).GetSalesOrderDBInfoByID(model.SOURCE_ENTITY_ID);
                    if (order != null)
                    {
                        strMessage += String.Format("\n\n\n Order No.: {0} dt. {1}\nParty Name: {2}\n",
                                                    order.SalesOrderNo,
                                                    order.SalesOrderDate.ToString("dd MMMyy"),
                                                    order.Tbl_MP_Master_Party.PartyName);
                        strRequirements = string.Empty;
                    }
                    break;
                }
                strMessage += string.Format("\nContact Person(s) : {0}", model.DB_MODEL.ContactPerson);
                strMessage += string.Format("\nContact Number(s) : {0}", model.DB_MODEL.ContactNumber);
                strMessage += string.Format("\nAddress : {0}", model.DB_MODEL.Location);
                strMessage += string.Format("\n\nSCHEDULE\nSchedule Type: {0}", (new ServiceMASTERS(_dbContext)).GetAllScheduleCallActions().Where(x => x.ID == model.DB_MODEL.ActionID).FirstOrDefault().Description);
                strMessage += string.Format("\nSchdeule Date: {0}\nSchedule Time:{1}", model.DB_MODEL.StartAt.Value.ToString("dd MMM yyyy"), model.DB_MODEL.StartAt.Value.ToString("hh:mm tt"));
                strMessage += string.Format("\nPlan/Action: {0}", model.DB_MODEL.Subject.ToUpper());
                strMessage += string.Format("\nRemarks: {0}\n", model.DB_MODEL.Remarks);


                strMessage += string.Format("\nAssigned To : {0}", strAssignees);

                strMessage += string.Format("\n\n{0}", strRequirements);


                string strEmailFrom = ServiceEmployee.GetEmployeeEmailByID(createdBy);
                await mail.SendScheduleCallCreatedEmailNotification(createdBy, strEmailFrom, mailTo, strSubject, strMessage);

                Application.DoEvents();
                progressForm.Close();
                this.IsScuccess = true;
                return(model.ScheduleID);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ServiceScheduleCallLog::AddNewScheduleCall", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(model.ScheduleID);
        }
        public async Task <bool> UpdateScheduleCall(ScheduleCallAddEditModel model, int empID)
        {
            try
            {
                progressForm      = new frmProgress();
                progressForm.Text = "UPDAING SCHEDULE CALL ID: " + model.ScheduleID;
                progressForm.lblProgressText.Text = "Updating Business Schecule Call Master Info";
                progressForm.Show();
                Application.DoEvents();
                int statusClose = _dbContext.APP_DEFAULTS.Where(x => x.ID == (int)APP_DEFAULT_VALUES.ScheduleCallStatusClose).FirstOrDefault().DEFAULT_VALUE;
                if (model.DB_MODEL.ScheduleStatus == statusClose)
                {
                    model.DB_MODEL.Completed = true;
                }

                model.DB_MODEL.EntityType       = (int)model.SOURCE_ENTITY;
                model.DB_MODEL.EntityID         = (int)model.SOURCE_ENTITY_ID;
                model.DB_MODEL.ModifiedBy       = empID;
                model.DB_MODEL.ModifiedDatetime = AppCommon.GetServerDateTime();
                model.DB_MODEL.Reminder         = model.DB_MODEL.Reminder;

                TBL_MP_CRM_ScheduleCallLog dbModel = _dbContext.TBL_MP_CRM_ScheduleCallLog.Where(x => x.ScheduleID == model.ScheduleID).FirstOrDefault();
                if (dbModel != null)
                {
                    dbModel.Subject          = model.DB_MODEL.Subject;
                    dbModel.Priority         = model.DB_MODEL.Priority;
                    dbModel.ActionID         = model.DB_MODEL.ActionID;
                    dbModel.ScheduleStatus   = model.DB_MODEL.ScheduleStatus;
                    dbModel.Completed        = model.DB_MODEL.Completed;
                    dbModel.ContactNumber    = model.DB_MODEL.ContactNumber;
                    dbModel.ContactPerson    = model.DB_MODEL.ContactPerson;
                    dbModel.CustomerName     = model.DB_MODEL.CustomerName;
                    dbModel.EndsAt           = model.DB_MODEL.EndsAt;
                    dbModel.StartAt          = model.DB_MODEL.StartAt;
                    dbModel.Reminder         = model.DB_MODEL.Reminder;
                    dbModel.EntityID         = model.DB_MODEL.EntityID;
                    dbModel.EntityType       = model.DB_MODEL.EntityType;
                    dbModel.ModifiedBy       = empID;
                    dbModel.ModifiedDatetime = AppCommon.GetServerDateTime();
                    dbModel.Remarks          = model.DB_MODEL.Remarks;

                    _dbContext.SaveChanges();
                }
                progressForm.SetProgress(25, string.Format("\nSuccess: Updated Schedule Call Information into the Database"));
                Application.DoEvents();


                progressForm.SetProgress(30, string.Format("\nSuccess ID: \n\nUpdating Assignees for this schedule in Database."));
                Application.DoEvents();
                string mailTo = string.Empty;

                // MARK ALL ASSIGNEES AS DELETED
                List <TBL_MP_CRM_ScheduleCallLogAssignee> dbAssignees = _dbContext.TBL_MP_CRM_ScheduleCallLogAssignee.Where(x => x.ScheduleID == model.ScheduleID).ToList();
                foreach (TBL_MP_CRM_ScheduleCallLogAssignee item in dbAssignees)
                {
                    item.IsDeleted = true;
                }
                _dbContext.SaveChanges();
                // OF EMPLOYEE FOUND SET DELETED=FALSE OR INSERT IF NOT FOUND
                foreach (MultiSelectListItem item in model.listAssignees)
                {
                    TBL_MP_CRM_ScheduleCallLogAssignee emp = _dbContext.TBL_MP_CRM_ScheduleCallLogAssignee.Where(x => x.ScheduleID == model.ScheduleID).Where(x => x.EmployeeID == item.ID).FirstOrDefault();
                    if (emp != null)
                    {
                        emp.IsDeleted = false;
                    }
                    else
                    {
                        _dbContext.TBL_MP_CRM_ScheduleCallLogAssignee.Add(new TBL_MP_CRM_ScheduleCallLogAssignee()
                        {
                            EmployeeID = item.ID,
                            IsDeleted  = false,
                            ScheduleID = model.ScheduleID
                        });
                    }
                    _dbContext.SaveChanges();
                    mailTo += ServiceEmployee.GetEmployeeEmailByID(item.ID) + ";";
                }

                mailTo += "*****@*****.**";
                progressForm.SetProgress(60, string.Format("\nSuccess: {0} Assignee(s) updated in Database for Schdeule #{1}", model.listAssignees.Count, model.ScheduleID));
                progressForm.SetProgress(60, string.Format("\n\n\nSending Email to {0}", mailTo.Replace(";", "; ")));
                Application.DoEvents();
                List <SelectListItem> scheduleStatusList = (new ServiceMASTERS()).GetAllScheduleCallsStatus();
                ServiceEmail          mail = new ServiceEmail();
                string strSubject          = string.Format("Updated Schedule Call: {0}", model.DB_MODEL.Subject);
                string strMessage          = string.Empty;
                strMessage += string.Format("{0}\nStatus: {1}", model.DB_MODEL.Subject.ToUpper(), scheduleStatusList.Where(x => x.ID == model.DB_MODEL.ScheduleStatus).FirstOrDefault().Description);
                strMessage += string.Format("\nRemarks:{0}\n", model.DB_MODEL.Remarks);
                strMessage += string.Format("\nParty : {0}", model.DB_MODEL.CustomerName);
                strMessage += string.Format("\nContact Person(s) : {0}", model.DB_MODEL.ContactPerson);
                strMessage += string.Format("\nContact Number(s) : {0}", model.DB_MODEL.ContactNumber);
                strMessage += string.Format("\nLocation : {0}", model.DB_MODEL.Location);
                strMessage += string.Format("\n\nStarts At : {0}", model.DB_MODEL.StartAt.Value.ToString("dd MMMyy hh:mmtt"));
                strMessage += string.Format("\nEnds At : {0}", model.DB_MODEL.StartAt.Value.ToString("dd MMMyyy hh:mmtt"));

                switch (model.SOURCE_ENTITY)
                {
                case APP_ENTITIES.SALES_LEAD:
                    LeadMasterInfoModel lead = (new ServiceSalesLead(_dbContext)).GetLeadMasterInfo(model.SOURCE_ENTITY_ID);
                    if (lead != null)
                    {
                        strMessage += String.Format("\n\n\nSOURCE INFO.\nLead: {0} dt. {1}\n{2}", lead.LeadNo, lead.LeadDate.Value.ToString("dd MMMyy"), lead.LeadRequirement);
                    }
                    break;
                }
                string strEmailAddress = ServiceEmployee.GetEmployeeEmailByID(empID);
                await mail.SendScheduleCallCreatedEmailNotification(empID, strEmailAddress, mailTo, strSubject, strMessage);

                Application.DoEvents();
                progressForm.Close();
                this.IsScuccess = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ServiceScheduleCallLog::UpdateScheduleCall", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(IsScuccess);
        }