private void btnEmailClient_Click(object sender, EventArgs e)
        {
            Enrollment        EnrollmentObj = ((Enrollment)enrollmentBindingSource.Current);
            CurriculumEnquiry CurriculumEnquiryObj;

            Data.Models.Enquiry CurrentEnquiryObj;
            using (var Dbconnection = new MCDEntities())
            {
                CurriculumEnquiryObj = (from a in Dbconnection.CurriculumEnquiries
                                        from b in a.Enrollments
                                        where
                                        b.EnrollmentID == EnrollmentObj.EnrollmentID &&
                                        a.CurriculumID == EnrollmentObj.CurriculumID
                                        select a).FirstOrDefault <CurriculumEnquiry>();

                CurrentEnquiryObj = (from a in Dbconnection.Enquiries
                                     where a.EnquiryID == CurriculumEnquiryObj.EnquiryID
                                     select a)
                                    .Include("Individuals")
                                    .Include("Individuals.ContactDetails")
                                    .FirstOrDefault <Data.Models.Enquiry>();
            };

            frmSendEmail frm = new frmSendEmail();

            List <ContactDetail> CustomEmailPerson = (from a in CurrentEnquiryObj.Individuals
                                                      from b in a.ContactDetails
                                                      where b.ContactTypeID == (int)Common.Enum.EnumContactTypes.Email_Address
                                                      select b).ToList <ContactDetail>();

            //Sets the Email Address For the Currently Selected Contact For this Enquiry
            foreach (ContactDetail ConDetObj in CustomEmailPerson)
            {
                if (frm.txtTestingToAddress.Text.Length > 0)
                {
                    frm.txtTestingToAddress.Text += ";";
                }
                frm.txtTestingToAddress.Text += ConDetObj.ContactDetailValue;
            }

            frm.txtTestSubject.Text = "Enquiry No: ( " + CurrentEnquiryObj.EnquiryID + "-" + CurriculumEnquiryObj.CurriculumEnquiryID + " ) Enquiry Feed Back";
            frm.txtTestMessage.Text = "Good Day \nThis is regarding the processing of your Enrollemnt - Ref: " + EnrollmentObj.EnrollmentID + "\n";
            frm.ShowDialog();
            if (frm.IsSent)
            {
                using (var Dbconnection = new MCDEntities())
                {
                    EquiryHistory hist = new EquiryHistory
                    {
                        EnquiryID  = CurrentEnquiryObj.EnquiryID,
                        EmployeeID = this.CurrentEmployeeLoggedIn.EmployeeID,
                        LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Enquiry_Custom_Email_Message_Sent,
                        DateEnquiryUpdated       = DateTime.Now,
                        EnquiryNotes             = "Custom Message Sent To Client Via Email\nSubject of the Message was:\n\n{" + frm.txtTestSubject.Text + "}\n\nBody Of the Message read:\n" + frm.txtTestMessage.Text
                    };
                    Dbconnection.EquiryHistories.Add(hist);
                    int IsSaved = Dbconnection.SaveChanges();
                };
            }
        }
 private void dgvIndividualContactDetails_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 2)
     {
         frmSendEmail frm = new frmSendEmail();
         frm.ShowDialog();
         if (dgvIndividualContactDetails.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Send Mail")
         {
         }
     }
 }
        private void dgvNewEnquiryTab_NewEnquiry_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            Data.Models.Enquiry En = null;
            if (curriculumEnquiriesBindingSource.List.Count > 0)
            {
                En = (Data.Models.Enquiry)dgvNewEnquiryTab_NewEnquiry.Rows[e.RowIndex].DataBoundItem;
            }

            switch (e.ColumnIndex)
            {
            case 2:
                if (En != null)
                {
                    if (!(Boolean)En.InitialConsultationComplete)
                    {
                        DialogResult Rtn1 = MessageBox.Show("Is Intial Consultation Completed?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (Rtn1 == DialogResult.Yes)
                        {
                            frmEnquiryInitialConsultation frm3 = new frmEnquiryInitialConsultation();

                            frm3.CurrentEnquiry = En;
                            frm3.EmployeeID     = CurrentEmployeeLoggedIn.EmployeeID;
                            frm3.ShowDialog();
                            dgvNewEnquiryTab_NewEnquiry.Refresh();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Consultation Already Completed,See History.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }


                break;
            //SEnd Email Message

            case 4:


                frmSendEmail frm = new frmSendEmail();
                frm.ShowDialog();
                if (dgvNewEnquiryTab_CurriculumEnquiry.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Send Mail")
                {
                }
                break;
            }
        }
 private void mnuEmail_Click(object sender, EventArgs e)
 {
     try
     {
         if (DGrid.RowCount <= 0)
         {
             return;
         }
         if (DGrid.CurrentRow == null)
         {
             return;
         }
         var rec = DGrid[dgEmail.Index, DGrid.CurrentRow.Index].Value.ToString();
         var frm = new frmSendEmail(rec);
         frm.ShowDialog();
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
     }
 }
        private void dgvNewEnquiryTab_CurriculumEnquiry_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //colNewEnquiry_Curriculum.Name
            //dgvNewEnquiryTab_CurriculumEnquiry.Rows[e.RowIndex].Cells[e.ColumnIndex].
            //row.Cells[colNewEnquiry_Curriculum.Index].Value
            // MessageBox.Show("Col Index : " + dgvNewEnquiryTab_CurriculumEnquiry.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());

            CurriculumEnquiry CE = (CurriculumEnquiry)dgvNewEnquiryTab_CurriculumEnquiry.Rows[e.RowIndex].DataBoundItem;

            Data.Models.Enquiry CurrentEnquiryObj = (Data.Models.Enquiry)NewEnquiryTab_NewEnquiryBindingSource.Current;
            switch (e.ColumnIndex)
            {
            case 1:
                //Close the enquiry
                DialogResult Rtn = MessageBox.Show("Are you Sure that you wish to Close this Enquiry?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (Rtn == DialogResult.Yes)
                {
                    using (var Dbconnection = new MCDEntities())
                    {
                        Dbconnection.CurriculumEnquiries.Attach(CE);
                        CE.EnquiryStatusID = (int)EnumEnquiryStatuses.Enquiry_Closed;
                        CE.LastUpdated     = DateTime.Now;
                        Dbconnection.Entry <CurriculumEnquiry>(CE).State = System.Data.Entity.EntityState.Modified;
                        Dbconnection.SaveChanges();
                        Dbconnection.CurriculumEnquiries.Remove(CE);
                    };
                }
                if (curriculumEnquiriesBindingSource.Count == 0)
                {
                    refreshNewEnquiry();
                }

                break;

            //Accept the Enquiry
            case 2:
                using (frmSendEmail frm = new frmSendEmail())
                {
                    List <ContactDetail> CustomEmailPerson = (from a in CurrentEnquiryObj.Individuals
                                                              from b in a.ContactDetails
                                                              where b.ContactTypeID == (int)Common.Enum.EnumContactTypes.Email_Address
                                                              select b).ToList <ContactDetail>();

                    //Sets the Email Address For the Currently Selected Contact For this Enquiry
                    foreach (ContactDetail ConDetObj in CustomEmailPerson)
                    {
                        if (frm.txtTestingToAddress.Text.Length > 0)
                        {
                            frm.txtTestingToAddress.Text += ";";
                        }
                        frm.txtTestingToAddress.Text += ConDetObj.ContactDetailValue;
                    }

                    frm.txtTestSubject.Text = "Enquiry No: ( " + CE.EnquiryID + "-" + CE.CurriculumEnquiryID + " ) Enquiry Feed Back";

                    frm.ShowDialog();
                    using (var Dbconnection = new MCDEntities())
                    {
                        EquiryHistory hist = new EquiryHistory
                        {
                            EnquiryID  = CE.EnquiryID,
                            EmployeeID = this.CurrentEmployeeLoggedIn.EmployeeID,
                            LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Enquiry_Custom_Email_Message_Sent,
                            DateEnquiryUpdated       = DateTime.Now,
                            EnquiryNotes             = "Custom Message Sent To Client Via Email\nSubject of the Message was:\n\n{" + frm.txtTestSubject.Text + "}\n\nBody Of the Message read:\n" + frm.txtTestMessage.Text
                        };
                        Dbconnection.EquiryHistories.Add(hist);
                        int IsSaved = Dbconnection.SaveChanges();
                        if (IsSaved > 0)
                        {
                            Dbconnection.CurriculumEnquiries.Attach(CE);
                            CE.LastUpdated = DateTime.Now;
                            Dbconnection.Entry <CurriculumEnquiry>(CE).State = EntityState.Modified;
                            Dbconnection.SaveChanges();
                        }
                        dgvNewEnquiryTab_CurriculumEnquiry.Refresh();
                    };
                }



                break;

            //Close the Equiry
            case 3:

                frmEnquiryViewHistory frm5 = new frmEnquiryViewHistory();
                frm5.CurrentEnquiryID = CurrentEnquiryObj.EnquiryID;
                frm5.ShowDialog();
                break;

            case 8:
                if (CurrentEnquiryObj.InitialConsultationComplete)
                {
                    if (!CE.InitialCurriculumEnquiryDocumentationSent)
                    {
                        frmInitailDocumentation frm3 = new frmInitailDocumentation();
                        frm3.ShowDialog();
                        if (!frm3.IsCanceled)
                        {
                            if (frm3.UseEmail)
                            {
                                frmSendEmail frm1 = new frmSendEmail();

                                List <ContactDetail> you = (from a in CurrentEnquiryObj.Individuals
                                                            from b in a.ContactDetails
                                                            where b.ContactTypeID == (int)Common.Enum.EnumContactTypes.Email_Address
                                                            select b).ToList <ContactDetail>();

                                //Sets the Email Address For the Currently Selected Contact For this Enquiry
                                foreach (ContactDetail ConDetObj in you)
                                {
                                    if (frm1.txtTestingToAddress.Text.Length > 0)
                                    {
                                        frm1.txtTestingToAddress.Text += ";";
                                    }
                                    frm1.txtTestingToAddress.Text += ConDetObj.ContactDetailValue;
                                }

                                frm1.txtTestSubject.Text = "Enquiry No: ( " + CurrentEnquiryObj.EnquiryID + "-" + CE.CurriculumEnquiryID + " ) Enquiry Feed Back";

                                using (var Dbconnection = new MCDEntities())
                                {
                                    List <MessageTemplate> MT = (from a in Dbconnection.MessageTemplates
                                                                 from b in a.Files
                                                                 where a.ProcessStepID == (int)EnumProcessSteps.Enquiry__Apprenticeship__Step_1__Documentation_To_Send
                                                                 select a).ToList <MessageTemplate>();

                                    MessageTemplate CurrentMessageTemplate = MT.FirstOrDefault <MessageTemplate>();
                                    string          Mess = "Good Day " + txtNewEnquiryTab_ContactPersonTitle.Text + " " + txtNewEnquiryTab_ContactPersonFirstName.Text + " " + txtNewEnquiryTab_ContactPersonLastName.Text + "\n \n";
                                    frm1.txtTestMessage.Text = "Please Reference the Following Line Equiry Number when returning any documentation: \n" +
                                                               "Enquiry No " + CE.EnquiryID + "-" + CE.CurriculumEnquiryID + "\n" + Mess + CurrentMessageTemplate.Message;
                                    foreach (MessageTemplate MTObj in MT)
                                    {
                                        foreach (Data.Models.File FileObj in MTObj.Files)
                                        {
                                            frm1.AttachmentsUsingDbImageFileID.Add(FileObj.FileID);
                                        }
                                    }
                                };
                                frm1.ShowDialog();
                                using (var Dbconnection = new MCDEntities())
                                {
                                    EquiryHistory hist = new EquiryHistory
                                    {
                                        EnquiryID  = CE.EnquiryID,
                                        EmployeeID = this.CurrentEmployeeLoggedIn.EmployeeID,
                                        LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Enquiry_Initial_Documentation_Sent,
                                        DateEnquiryUpdated       = DateTime.Now,
                                        EnquiryNotes             = "Documentation Sent To Client Via Email"
                                    };
                                    Dbconnection.EquiryHistories.Add(hist);
                                    int IsSaved = Dbconnection.SaveChanges();
                                    if (IsSaved > 0)
                                    {
                                        Dbconnection.CurriculumEnquiries.Attach(CE);
                                        CE.InitialCurriculumEnquiryDocumentationSent = true;
                                        CE.LastUpdated = DateTime.Now;
                                        Dbconnection.Entry <CurriculumEnquiry>(CE).State = EntityState.Modified;
                                        Dbconnection.SaveChanges();
                                    }
                                    dgvNewEnquiryTab_CurriculumEnquiry.Refresh();
                                };
                            }
                            else
                            {
                                using (var Dbconnection = new MCDEntities())
                                {
                                    EquiryHistory hist = new EquiryHistory
                                    {
                                        EnquiryID  = CE.EnquiryID,
                                        EmployeeID = this.CurrentEmployeeLoggedIn.EmployeeID,
                                        LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Enquiry_Initial_Documentation_Sent,
                                        DateEnquiryUpdated       = DateTime.Now,
                                        EnquiryNotes             = "Documentation Manually Given To Client"
                                    };
                                    Dbconnection.EquiryHistories.Add(hist);
                                    int IsSaved = Dbconnection.SaveChanges();
                                    if (IsSaved > 0)
                                    {
                                        Dbconnection.CurriculumEnquiries.Attach(CE);
                                        CE.InitialCurriculumEnquiryDocumentationSent = true;
                                        CE.LastUpdated = DateTime.Now;
                                        Dbconnection.Entry <CurriculumEnquiry>(CE).State = EntityState.Modified;
                                        Dbconnection.SaveChanges();
                                        dgvNewEnquiryTab_CurriculumEnquiry.Refresh();
                                    }
                                };
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Documentation Already Sent,\nUse Send Mail Option to send additional Mail.\nSee History For Details.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Initial Contsultation Not Completed!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                break;

            case 10:
                if (CE.Curriculum.DepartmentID == (int)EnumDepartments.Apprenticeship)
                {
                    if (CE.EnrollmentQuanity >= CE.Enrollments.Count)
                    {
                        frmApprenticeshipEnrollmentFormV2 frm6 = new frmApprenticeshipEnrollmentFormV2();
                        frm6.CurrentCurriculumEnquiry = CE;
                        curriculumEnquiriesBindingSource.ResetItem(e.RowIndex);
                        frm6.ShowDialog();
                        //Check to see if the amoount required to be enrolled equal the amount that have been enrolled.
                        //if (CE.EnrollmentQuanity <= CE.Enrollments.Count)
                        //{
                        //    using (var Dbconnection = new MCDEntities())
                        //    {
                        //        Dbconnection.CurriculumEnquiries.Attach(CE);
                        //        CE.EnquiryStatusID = (int)EnumEnquiryStatuses.Enquiry_Closed;
                        //        CE.LastUpdated = DateTime.Now;
                        //        Dbconnection.Entry<CurriculumEnquiry>(CE).State = System.Data.Entity.EntityState.Modified;
                        //        Dbconnection.SaveChanges();
                        //        Dbconnection.CurriculumEnquiries.Remove(CE);
                        //        int currentIndex = NewEnquiryTab_NewEnquiryBindingSource.Position;
                        //        refreshNewEnquiry();
                        //        NewEnquiryTab_NewEnquiryBindingSource.Position = currentIndex;
                        //        dgvNewEnquiryTab_CurriculumEnquiry.Refresh();

                        //    };
                        //}
                        DialogResult Rtn1 = MessageBox.Show("Do you wish to View the Enrollment,and course selection?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (Rtn1 == DialogResult.Yes)
                        {
                            using (frmEnrolmmentInprogress frm = new frmEnrolmmentInprogress())
                            {
                                frm.CurrentEmployeeLoggedIn   = this.CurrentEmployeeLoggedIn;
                                frm.CurrentSelectedDepartment = (Common.Enum.EnumDepartments)CE.Curriculum.DepartmentID;
                                // frmStudentCourseEnrollmentV2 frm7 = new frmStudentCourseEnrollmentV2();
                                frm.ShowDialog();
                            }
                        }
                    }
                }


                //frm6.CurrentEnrollments.ApprienticeshipEnrollment.(CE);
                break;

            case 11:
                using (frmEnrollmentSelectionForEquiry frm = new frmEnrollmentSelectionForEquiry())
                {
                    frm.SelectedCurriculumEnquiryID = CE.CurriculumEnquiryID;
                    frm.ShowDialog();
                    if (frm.SelectedEnrollmentID != 0)
                    {
                        using (frmEnrolmmentInprogress innerFrm = new frmEnrolmmentInprogress())
                        {
                            innerFrm.CurrentEmployeeLoggedIn   = this.CurrentEmployeeLoggedIn;
                            innerFrm.CurrentSelectedDepartment = (Common.Enum.EnumDepartments)CE.Curriculum.DepartmentID;
                            innerFrm.CurrentEnrollmentID       = frm.SelectedEnrollmentID;
                            innerFrm.ShowDialog();
                        }
                    }
                }



                break;
            }
        }
Exemple #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            frmSendEmail frm = new frmSendEmail();

            frm.ShowDialog();
        }
        private void dgvNewEnquiryCurrent_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //toolStrip1 catch which of the options where selected
            switch (e.ColumnIndex)
            {
            //Accept the Enquiry
            case 1:
                frmEnquiryViewContactInformation frm = new frmEnquiryViewContactInformation();
                frm.CurrentEnquiry = (Data.Models.Enquiry)NewEnquiryWorkbench_NewEnquiryBindingSource.Current;
                frm.ShowDialog();
                break;

            //Close the Equiry
            case 2:

                frmSendEmail         frm1 = new frmSendEmail();
                Data.Models.Enquiry  CurrentEnquiryObj = (Data.Models.Enquiry)NewEnquiryWorkbench_NewEnquiryBindingSource.Current;
                List <ContactDetail> you = (from a in CurrentEnquiryObj.Individuals
                                            from b in a.ContactDetails
                                            where b.ContactTypeID == (int)Common.Enum.EnumContactTypes.Email_Address
                                            select b).ToList <ContactDetail>();

                //Sets the Email Address For the Currently Selected Contact For this Enquiry
                foreach (ContactDetail ConDetObj in you)
                {
                    if (frm1.txtTestingToAddress.Text.Length > 0)
                    {
                        frm1.txtTestingToAddress.Text += ";";
                    }
                    frm1.txtTestingToAddress.Text += ConDetObj.ContactDetailValue;
                }



                using (var Dbconnection = new MCDEntities())
                {
                    List <MessageTemplate> MT = (from a in Dbconnection.MessageTemplates
                                                 from b in a.Files
                                                 where a.ProcessStepID == (int)EnumProcessSteps.Enquiry__Apprenticeship__Step_1__Documentation_To_Send
                                                 select a).ToList <MessageTemplate>();

                    MessageTemplate CurrentMessageTemplate = MT.FirstOrDefault <MessageTemplate>();
                    frm1.txtTestMessage.Text = CurrentMessageTemplate.Message;
                    foreach (MessageTemplate MTObj in MT)
                    {
                        foreach (Data.Models.File FileObj in MTObj.Files)
                        {
                            frm1.AttachmentsUsingDbImageFileID.Add(FileObj.FileID);
                        }
                    }
                };
                frm1.ShowDialog();
                break;

            //SEnd Email Message
            case 3:
                break;

            //View Enquiry History
            case 4:
                break;
            }
        }