public async Task <int> AddNewFollowUp(TBL_MP_CRM_ScheduleCallLogFollowUp model, int empID) { int newID = 0; try { model.CreatedBy = empID; model.CreatedDatetime = AppCommon.GetServerDateTime(); _dbContext.TBL_MP_CRM_ScheduleCallLogFollowUp.Add(model); _dbContext.SaveChanges(); int cnt = (from xx in _dbContext.TBL_MP_CRM_ScheduleCallLogFollowUp where xx.ScheduleID == model.ScheduleID select xx).Count(); model.FollowUpSequence = cnt; _dbContext.SaveChanges(); if (model.FollowUpStatus == FOLLOWUP_STATUS_CLOSE_ID) { TBL_MP_CRM_ScheduleCallLog log = _dbContext.TBL_MP_CRM_ScheduleCallLog.Where(x => x.ScheduleID == model.ScheduleID).FirstOrDefault(); log.ScheduleStatus = CALL_STATUS_CLOSE_ID; _dbContext.SaveChanges(); } newID = model.FollowUpID; this.IsScuccess = await this.SendFollowUpEmail(newID); Application.DoEvents(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ServiceScheduleCallLog::AddNewFollowUp", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(newID); }
private void gridFollowUps_RowEnter(object sender, DataGridViewCellEventArgs e) { try { this.SelectedFollowUpID = int.Parse(gridFollowUps.Rows[e.RowIndex].Cells["FollowUpID"].Value.ToString()); TBL_MP_CRM_ScheduleCallLogFollowUp followup = (new ServiceScheduleCallLog()).GetFollowUpDBItembyFollowUpID(this.SelectedFollowUpID); if (!ReadOnly && !_IsScheduleClosed) { if (followup != null) { if (followup.EmployeeID == Program.CURR_USER.EmployeeID) { btnEditFollowup.Enabled = btnDeleteFollowup.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True; } else { btnEditFollowup.Enabled = btnDeleteFollowup.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "ctrlScheduleCallLog::gridFollowUps_RowEnter", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public async Task <bool> UpdateFollowUp(TBL_MP_CRM_ScheduleCallLogFollowUp model, int empID) { bool result = false; try { TBL_MP_CRM_ScheduleCallLogFollowUp followup = _dbContext.TBL_MP_CRM_ScheduleCallLogFollowUp.Where(x => x.FollowUpID == model.FollowUpID).FirstOrDefault(); if (followup != null) { followup.FollowUpRemark = model.FollowUpRemark; followup.FollowUpStatus = model.FollowUpStatus; followup.NextFollowupRequired = model.NextFollowupRequired; if ((bool)followup.NextFollowupRequired) { followup.NextFollowupRequired = true; followup.NextFollowUpContactName = model.NextFollowUpContactName; followup.NextFollowUpContactNumber = model.NextFollowUpContactNumber; followup.NextFollowUpEndDatetime = model.NextFollowUpEndDatetime; followup.NextFollowUpLocation = model.NextFollowUpLocation; followup.NextFollowUpRemainder = model.NextFollowUpRemainder; followup.NextFollowUpStartDatetime = model.NextFollowUpStartDatetime; followup.NextFollowUpSubject = model.NextFollowUpSubject; } else { followup.NextFollowupRequired = false; followup.NextFollowUpContactName = ""; followup.NextFollowUpContactNumber = ""; followup.NextFollowUpEndDatetime = null; followup.NextFollowUpLocation = ""; followup.NextFollowUpRemainder = null; followup.NextFollowUpStartDatetime = null; followup.NextFollowUpSubject = ""; } } followup.ReasonClose = model.ReasonClose; followup.ModifiedBy = empID; followup.ModifiedDatetime = AppCommon.GetServerDateTime(); _dbContext.SaveChanges(); if (model.FollowUpStatus == FOLLOWUP_STATUS_CLOSE_ID) { TBL_MP_CRM_ScheduleCallLog log = _dbContext.TBL_MP_CRM_ScheduleCallLog.Where(x => x.ScheduleID == model.ScheduleID).FirstOrDefault(); log.ScheduleStatus = CALL_STATUS_CLOSE_ID; _dbContext.SaveChanges(); } result = await this.SendFollowUpEmail(model.FollowUpID); Application.DoEvents(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ServiceScheduleCallLog::AddNewFollowUp", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
public TBL_MP_CRM_ScheduleCallLogFollowUp GetFollowUpDBItembyFollowUpID(int followupID) { TBL_MP_CRM_ScheduleCallLogFollowUp model = null; try { model = _dbContext.TBL_MP_CRM_ScheduleCallLogFollowUp.Where(x => x.FollowUpID == followupID).FirstOrDefault(); } catch (Exception ex) { MessageBox.Show(ex.Message, "GetFollowUpDBItembyFollowUpID", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(model); }
private void frmFollowUp_Load(object sender, EventArgs e) { try { PopulateScheduelInfo(); PopulatesFollowUpStatus(); //cboFollowUpStatus.DataSource = _UOM.MasterService.GetAllFollowUpStatus(); //cboFollowUpStatus.DisplayMember = "Description"; //cboFollowUpStatus.ValueMember = "ID"; if (this.FollowUpID == 0) { dtScheduleStartDatetime.Value = dtScheduleEndDatetime.Value = dtReaminder.Value = AppCommon.GetServerDateTime(); this.NextFollowUpRequired = false; } else { dtScheduleStartDatetime.Value = dtScheduleEndDatetime.Value = dtReaminder.Value = AppCommon.GetServerDateTime(); TBL_MP_CRM_ScheduleCallLogFollowUp model = _UOM.ScheduleCallLogService.GetFollowUpDBItembyFollowUpID(this.FollowUpID); if (model != null) { txtRemarks.Text = model.FollowUpRemark; cboFollowUpStatus.SelectedItem = ((List <SelectListItem>)cboFollowUpStatus.DataSource).Where(x => x.ID == model.FollowUpStatus).FirstOrDefault(); if ((bool)model.NextFollowupRequired) { this.NextFollowUpRequired = (bool)model.NextFollowupRequired; txtSubject.Text = model.NextFollowUpSubject; dtScheduleStartDatetime.Value = model.NextFollowUpStartDatetime.Value; dtScheduleEndDatetime.Value = model.NextFollowUpEndDatetime.Value; dtReaminder.Value = model.NextFollowUpRemainder.Value; txtContactPerson.Text = model.NextFollowUpContactName; txtContactNumber.Text = model.NextFollowUpContactNumber; txtLocation.Text = model.NextFollowUpLocation; } } } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmFollowUp::frmFollowUp_Load", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool DeletedFollowUp(int FollowUpID, int empID) { bool result = false; try { TBL_MP_CRM_ScheduleCallLogFollowUp dbFollowUP = _dbContext.TBL_MP_CRM_ScheduleCallLogFollowUp.Where(x => x.FollowUpID == FollowUpID).FirstOrDefault(); dbFollowUP.DeleteDateTime = AppCommon.GetServerDateTime(); dbFollowUP.DeleteBy = empID; dbFollowUP.IsDeleted = true; // dbFollowUP.DeleteRemarks = reason; _dbContext.SaveChanges(); result = true; } catch (Exception ex) { MessageBox.Show(String.Format("{0}\n{1}", ex.Message, ex.InnerException.Message), "ServiceParties::DeleteParty", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
private async void btnSave_Click(object sender, EventArgs e) { try { errorProvider1.Clear(); if (this.ValidateChildren()) { TBL_MP_CRM_ScheduleCallLogFollowUp followupModel = null; if (this.FollowUpID == 0) { // INSERT NEW FOLLOWUP followupModel = new TBL_MP_CRM_ScheduleCallLogFollowUp(); followupModel.ScheduleID = this.SchdeuleID; followupModel.EmployeeID = Program.CURR_USER.EmployeeID; followupModel.FollowUpDateTime = AppCommon.GetServerDateTime(); followupModel.FollowUpRemark = txtRemarks.Text; if (cboFollowUpStatus.SelectedItem != null) { followupModel.FollowUpStatus = ((SelectListItem)cboFollowUpStatus.SelectedItem).ID; } followupModel.NextFollowupRequired = this.NextFollowUpRequired; if (this.NextFollowUpRequired) { followupModel.NextFollowUpSubject = txtSubject.Text; followupModel.NextFollowUpStartDatetime = dtScheduleStartDatetime.Value; followupModel.NextFollowUpEndDatetime = dtScheduleEndDatetime.Value; followupModel.NextFollowUpRemainder = dtReaminder.Value; followupModel.NextFollowUpContactName = txtContactPerson.Text; followupModel.NextFollowUpContactNumber = txtContactNumber.Text; followupModel.NextFollowUpLocation = txtLocation.Text; } int statusClose = Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.FollowUpStatusClose].DEFAULT_VALUE; if (followupModel.FollowUpStatus == statusClose) { followupModel.ReasonClose = txtReasonClose.Text; } else { followupModel.ReasonClose = ""; } Cursor = Cursors.AppStarting; this.FollowUpID = await _UOM.ScheduleCallLogService.AddNewFollowUp(followupModel, Program.CURR_USER.EmployeeID); if (this.FollowUpID > 0) { this.DialogResult = DialogResult.OK; } } else { // UPDATE EXSITING FOLLOWUP Cursor = Cursors.AppStarting; followupModel = _UOM.AppDBContext.TBL_MP_CRM_ScheduleCallLogFollowUp.Where(x => x.FollowUpID == this.FollowUpID).FirstOrDefault(); followupModel.FollowUpRemark = txtRemarks.Text; if (cboFollowUpStatus.SelectedItem != null) { followupModel.FollowUpStatus = ((SelectListItem)cboFollowUpStatus.SelectedItem).ID; } followupModel.NextFollowupRequired = this.NextFollowUpRequired; if (this.NextFollowUpRequired) { followupModel.NextFollowUpSubject = txtSubject.Text; followupModel.NextFollowUpStartDatetime = dtScheduleStartDatetime.Value; followupModel.NextFollowUpEndDatetime = dtScheduleEndDatetime.Value; followupModel.NextFollowUpRemainder = dtReaminder.Value; followupModel.NextFollowUpContactName = txtContactPerson.Text; followupModel.NextFollowUpContactNumber = txtContactNumber.Text; followupModel.NextFollowUpLocation = txtLocation.Text; } int statusClose = Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.FollowUpStatusClose].DEFAULT_VALUE; if (followupModel.FollowUpStatus == statusClose) { followupModel.ReasonClose = txtReasonClose.Text; } else { followupModel.ReasonClose = ""; } await _UOM.ScheduleCallLogService.UpdateFollowUp(followupModel, Program.CURR_USER.EmployeeID); Cursor = Cursors.Default; this.DialogResult = DialogResult.OK; } } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmFollowUp::btnSave_Click", 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); }