private void btnpicREviewUpdateCompanyInfo_Click(object sender, EventArgs e)
 {
     Data.Models.Enrollment EnrollmentObj = (Data.Models.Enrollment)(enrollmentBindingSourceMain.Current);
     if (EnrollmentObj != null)
     {
         Boolean IsCompany = false;
         foreach (StudentAssociatedCompany SAC in EnrollmentObj.StudentEnrollment.Student.StudentAssociatedCompanies)
         {
             if (SAC.IsCurrentCompany)
             {
                 IsCompany = true;
             }
         }
         if (IsCompany)
         {
             using (ViewEditCompanyDetails frm = new ViewEditCompanyDetails(EnrollmentObj.StudentEnrollment.Student.StudentAssociatedCompanies.Where(a => a.IsCurrentCompany == true).FirstOrDefault().Company.CompanyID))
             {
                 //frm.txtCompaniesFilterCriteria.Text = EnrollmentObj.StudentEnrollment.Student.StudentAssociatedCompanies.Where(a => a.IsCurrentCompany == true).FirstOrDefault().Company.CompanyName;
                 frm.ShowDialog();
             }
         }
         else
         {
             MessageBox.Show("Student is private no Company Details Avaiable, Allocate the student to a company by configuring the student details.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
Exemplo n.º 2
0
        private void btnEmailClient_Click(object sender, EventArgs e)
        {
            Data.Models.Enrollment EnrollmentObj = ((Data.Models.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>();
            };

            frmEmailMessageV2 frm = new frmEmailMessageV2();

            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();
                };
            }
        }
Exemplo n.º 3
0
        private void dgvEnrollment_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            Data.Models.Enrollment EnrollmentObj = ((Data.Models.Enrollment)enrollmentBindingSource.Current);


            switch (e.ColumnIndex)
            {
            case 1:


                break;
            }
        }
 private void btnStudentInformation_Click(object sender, EventArgs e)
 {
     using (frmStudentAddUpdate frm = new frmStudentAddUpdate(CurrentEnrollment.StudentEnrollment.StudentID))
     {
         //frm.CurrentStudentID = CurrentEnrollment.Student.StudentID;
         frm.ShowDialog();
         if (frm.CurrentSelectedStudent != null)
         {
             Data.Models.Enrollment EnrollmentObj = (Data.Models.Enrollment)(enrollmentBindingSourceMain.Current);
             EnrollmentObj.StudentEnrollment.Student = frm.CurrentSelectedStudent;
             enrollmentBindingSourceMain.ResetCurrentItem();
         }
     }
 }
        private void btnpicEmailClient_Click(object sender, EventArgs e)
        {
            Data.Models.Enrollment EnrollmentObj = (Data.Models.Enrollment)(enrollmentBindingSourceMain.Current);

            using (frmEmailMessageV2 frm = new frmEmailMessageV2())
            {
                frm.txtMessageSubject.Text = "MCD Communication - Follow up on Enrollment - " + EnrollmentObj.StudentEnrollment.Student.Individual.FullName;
                frm.AddToEmailContact(new List <Individual>()
                {
                    (Individual)EnrollmentObj.StudentEnrollment.Student.Individual
                });
                frm.txtMessageSubject.ReadOnly = true;
                frm.ShowDialog();
            }
        }
Exemplo n.º 6
0
 private void populateApprenticeshipEnrollmentDocuments(int _EnrollentDocumentTypeID)
 {
     using (var Dbconnection = new MCDEntities())
     {
         Data.Models.Enrollment Enroll = ((Data.Models.Enrollment)(enrollmentBindingSource.Current));
         //fileBindingSource.DataSource = (from a in Dbconnection.ApprenticeshipEnrollmentDocuments
         //                                where a.EnrollmentID == Enroll.EnrollmentID
         //                                    && a.LookupEnrollentDocumentTypeID == _EnrollentDocumentTypeID
         //                                select new
         //                                {
         //                                    ImageID = a.File.ImageID,
         //                                    FileName = a.File.FileName + "." + a.File.FileExtension,
         //                                    DateCreated = a.File.DateCreated
         //                                }).ToList();
     };
 }
Exemplo n.º 7
0
        private void enrollmentDataGridView_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            var gridView = (DataGridView)sender;

            foreach (DataGridViewRow row in gridView.Rows)
            {
                if (!row.IsNewRow)
                {
                    Data.Models.Enrollment EnrollmentObj = (Data.Models.Enrollment)(row.DataBoundItem);

                    row.Cells[colStudentIDNumber1.Index].Value = EnrollmentObj.StudentEnrollment.Student.StudentIDNumber.ToString();
                    row.Cells[colFirstName1.Index].Value       = EnrollmentObj.StudentEnrollment.Student.Individual.IndividualFirstName.ToString();
                    row.Cells[colLastName1.Index].Value        = EnrollmentObj.StudentEnrollment.Student.Individual.IndividualLastname.ToString();
                    //row.Cells[colStatus.Index].Value = EnrollmentObj.LookupEnrollmentProgressState.EnrollmentProgressCurrentState.ToString();
                }
            }
        }
Exemplo n.º 8
0
        private void dgvPrerequisiteCourses_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            var gridView = (DataGridView)sender;

            foreach (DataGridViewRow row in gridView.Rows)
            {
                if (!row.IsNewRow)
                {
                    Data.Models.Enrollment EnrollmentObj = (Data.Models.Enrollment)(row.DataBoundItem);

                    row.Cells[colApprenticeshipPreRequisiteCurriculum.Index].Value = EnrollmentObj.Curriculum.CurriculumName.ToString();

                    CurriculumCourse CurriculumCourseObj = (from a in EnrollmentObj.CurriculumCourseEnrollments
                                                            where a.CurriculumCourse.CurriculumID == EnrollmentObj.CurriculumID
                                                            select a.CurriculumCourse)
                                                           .FirstOrDefault <CurriculumCourse>();
                    row.Cells[colApprenticeshipPreRequisiteCourse.Index].Value          = CurriculumCourseObj.Course.CourseName.ToString();
                    row.Cells[colApprenticeshipPrerequisteProcessingStatus.Index].Value = EnrollmentObj.LookupEnrollmentProgressState.EnrollmentProgressCurrentState.ToString();
                }
            }
        }
Exemplo n.º 9
0
 private void populateApprenticeshipCoursePreRequisites()
 {
     Data.Models.Enrollment EnrollObj = (Data.Models.Enrollment)enrollmentBindingSource.Current;
     if (EnrollObj != null)
     {
         using (var Dbconnection = new MCDEntities())
         {
             enrollmentPrerequisitesBindingSource.DataSource = (from a in Dbconnection.Enrollments
                                                                from b in a.CurriculumCourseEnrollments
                                                                where a.EnrolmentParentID == EnrollObj.EnrollmentID
                                                                select a)
                                                               .Include("CurriculumCourseEnrollments")
                                                               //.Include("Curriculum.CurriculumCourses")
                                                               //.Include("Curriculum.CurriculumCourses.Course")
                                                               .ToList <Data.Models.Enrollment>();
         };
     }
     else
     {
         enrollmentPrerequisitesBindingSource.Clear();
     }
 }
Exemplo n.º 10
0
 private void enrollmentBindingSourceMain_ListChanged(object sender, ListChangedEventArgs e)
 {
     Data.Models.Enrollment EnrollmentObj = (Data.Models.Enrollment)(enrollmentBindingSourceMain.Current);
     if (EnrollmentObj != null)
     {
         Boolean IsCompany = false;
         foreach (StudentAssociatedCompany SAC in EnrollmentObj.StudentEnrollment.Student.StudentAssociatedCompanies)
         {
             if (SAC.IsCurrentCompany)
             {
                 IsCompany = true;
             }
         }
         if (IsCompany)
         {
             txtCompanyNameDisplay.Text = EnrollmentObj.StudentEnrollment.Student.StudentAssociatedCompanies.Where(a => a.IsCurrentCompany == true).FirstOrDefault().Company.CompanyName;
         }
         else
         {
             txtCompanyNameDisplay.Text = "Private - " + EnrollmentObj.StudentEnrollment.Student.Individual.FullName;
         }
     }
 }
Exemplo n.º 11
0
        private void dgvEnrollment_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            var gridView = (DataGridView)sender;

            foreach (DataGridViewRow row in gridView.Rows)
            {
                if (!row.IsNewRow)
                {
                    Data.Models.Enrollment EnrollmentObj = (Data.Models.Enrollment)(row.DataBoundItem);

                    row.Cells[colApprenticeshipCurriculum.Index].Value = EnrollmentObj.Curriculum.CurriculumName.ToString();
                    //if (EnrollmentObj.ApprienticeshipEnrollment != null)
                    //{
                    //    row.Cells[colApprenticeshipSection.Index].Value = EnrollmentObj.ApprienticeshipEnrollment.LookupSectionalEnrollmentType.LookupSectionalEnrollmentTypeName.ToString();

                    //}
                    var CurriculumEnquiryObj = EnrollmentObj.CurriculumEnquiries.FirstOrDefault <CurriculumEnquiry>();;
                    if (CurriculumEnquiryObj != null)
                    {
                        row.Cells[colApprenticeshipEnqiry.Index].Value = CurriculumEnquiryObj.EnquiryID.ToString();
                    }
                }
            }
        }
Exemplo n.º 12
0
        private void populateEnrollment()
        {
            int EnrollmentToLoadID = 0;

            using (var Dbconnection = new MCDEntities())
            {
                //Load PreRequisteEnrollment
                if (CurrentEnrollmentPreRequisiteID != 0)
                {
                    EnrollmentToLoadID = this.CurrentEnrollmentPreRequisiteID;
                }
                else//Load Enrollment
                {
                    EnrollmentToLoadID = this.CurrentEnrollmentID;
                }
                CurrentEnrollment = (from a in Dbconnection.Enrollments
                                     where a.EnrollmentID == EnrollmentToLoadID
                                     select a)
                                    .Include(a => a.StudentEnrollment)
                                    .Include(a => a.StudentEnrollment.Student.StudentAssociatedCompanies)
                                    .Include(a => a.StudentEnrollment.Student.StudentAssociatedCompanies.Select(b => b.Company))
                                    .Include(a => a.StudentEnrollment.Student)
                                    .Include(a => a.StudentEnrollment.Student.Individual)
                                    .Include(a => a.StudentEnrollment.Student.Individual.ContactDetails)
                                    //.Include(a => a.CurriculumEnquiry)
                                    .Include(a => a.CurriculumCourseEnrollments)
                                    //LookupEnrollmentProgressState
                                    .Include(a => a.CurriculumCourseEnrollments.Select(b => b.LookupEnrollmentProgressState))
                                    .Include(a => a.CurriculumCourseEnrollments.Select(b => b.Schedules))
                                    .Include(a => a.CurriculumCourseEnrollments.Select(b => b.CurriculumCourse).Select(c => c.CurriculumCourseMinimumMaximum))
                                    .Include(a => a.CurriculumCourseEnrollments.Select(b => b.CurriculumCourse.CurriculumCourseDayCanBeScheduleds))
                                    .Include(a => a.Curriculum)
                                    .FirstOrDefault <Data.Models.Enrollment>();

                if (CurrentEnrollmentPreRequisiteID != 0)
                {
                    List <CurriculumCourseEnrollment> CurriculumCourseEnrollmentTemp = new List <CurriculumCourseEnrollment>();
                    foreach (CurriculumCourseEnrollment CurriculumCourseEnrollmentObj in CurrentEnrollment.CurriculumCourseEnrollments)
                    {
                        //             //trying code
                        //             CurrentEnrollment.CurriculumCourseEnrollments.Clear();
                        //             Dbconnection.Entry(blog)
                        //.Collection("Posts")
                        //.Query()
                        //.Where(p => p.Tags.Contains("entity-framework")
                        //.Load();
                        //             //end trying code

                        if (CurriculumCourseEnrollmentObj.CurriculumCourseEnrollmentID == this.CurrentCurriculumCourseEnrollmentID)
                        {
                            CurriculumCourseEnrollmentTemp.Add(CurriculumCourseEnrollmentObj);
                        }
                    }
                    CurrentEnrollment.CurriculumCourseEnrollments.Clear();
                    foreach (CurriculumCourseEnrollment CurriculumCourseEnrollmentObj in CurriculumCourseEnrollmentTemp)
                    {
                        CurrentEnrollment.CurriculumCourseEnrollments.Add(CurriculumCourseEnrollmentObj);
                    }

                    //SetControls
                }
                else
                {
                }

                enrollmentBindingSourceMain.DataSource = CurrentEnrollment;
            };
        }
Exemplo n.º 13
0
        private void populateEnrollmentFiles()
        {
            using (var Dbconnection = new MCDEntities())
            {
                List <EnrollmentFiles> EF = new List <EnrollmentFiles>();

                int filterID = Convert.ToInt32(cboAttachmentType.SelectedValue);
                if (filterID == (int)Common.Enum.EnumEnrollentDocumentTypes.ID_Documents)
                {
                    Data.Models.Enrollment EnrollmentObj = (Data.Models.Enrollment)(enrollmentBindingSourceMain.Current);
                    var ListOfFiles = (from a in Dbconnection.StudentIDDocuments
                                       where a.StudentID == EnrollmentObj.StudentEnrollment.StudentID
                                       select new
                    {
                        FileID = a.File.FileID,
                        FileName = a.File.FileName,
                        FileExtension = a.File.FileExtension,
                        EnrollentDocumentType = "Student ID Document",
                        EnrollmentDocumentTypeID = Common.Enum.EnumEnrollentDocumentTypes.ID_Documents
                    }).ToList();

                    foreach (var obj in ListOfFiles)
                    {
                        EF.Add(new EnrollmentFiles()
                        {
                            FileID                   = obj.FileID,
                            FileName                 = obj.FileName,
                            FileExtension            = obj.FileExtension,
                            EnrollmentDocumentTypeID = (int)Common.Enum.EnumEnrollentDocumentTypes.ID_Documents,
                            EnrollentDocumentType    = obj.EnrollentDocumentType
                        });
                    }
                }
                else
                {
                    var ListOfFiles = (from a in Dbconnection.EnrollmentDocuments
                                       where a.EnrollmentID == CurrentEnrollmentID &&
                                       a.LookupEnrollmentDocumentTypeID == filterID
                                       select new
                    {
                        FileID = a.File.FileID,
                        FileName = a.File.FileName,
                        FileExtension = a.File.FileExtension,
                        EnrollentDocumentType = a.LookupEnrollentDocumentType.EnrollmentDocumentType,
                        EnrollmentDocumentTypeID = a.LookupEnrollmentDocumentTypeID
                    }).ToList();

                    //List<File> AllFiles = new List<File>();
                    foreach (var obj in ListOfFiles)
                    {
                        EF.Add(new EnrollmentFiles()
                        {
                            FileID                   = obj.FileID,
                            FileName                 = obj.FileName,
                            FileExtension            = obj.FileExtension,
                            EnrollmentDocumentTypeID = obj.EnrollmentDocumentTypeID,
                            EnrollentDocumentType    = obj.EnrollentDocumentType
                        });
                    }
                }


                enrollmentFilesBindingSource.DataSource = EF;
            };
        }
        private void frmApprenticeshipEnrollmentFormV2_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MustSaveItems)
            {
                using (var Dbconnection = new MCDEntities())
                {
                    using (System.Data.Entity.DbContextTransaction dbTran = Dbconnection.Database.BeginTransaction())
                    {
                        try
                        {
                            //CRUD Operations
                            ///Step 1 Begin - Saves Main Enrollment
                            Dbconnection.Students.Attach(CurrentEnrollment.StudentEnrollment.Student);
                            Dbconnection.Entry(CurrentEnrollment.ApprienticeshipEnrollment).State = EntityState.Added;


                            Dbconnection.Entry(CurrentEnrollment).State = EntityState.Added;
                            Dbconnection.Entry(CurrentEnrollment.StudentEnrollment).State         = EntityState.Added;
                            Dbconnection.Entry(CurrentEnrollment.StudentEnrollment.Student).State = EntityState.Unchanged;
                            foreach (EnrollmentDocument ED in CurrentEnrollment.EnrollmentDocuments)
                            {
                                Dbconnection.Entry(ED).State      = EntityState.Added;
                                Dbconnection.Entry(ED.File).State = EntityState.Added;
                                // ED.LookupEnrollentDocumentType = null;
                                Dbconnection.LookupEnrollentDocumentTypes.Attach(ED.LookupEnrollentDocumentType);
                                Dbconnection.Entry(ED.LookupEnrollentDocumentType).State = EntityState.Unchanged;
                            }

                            CurrentEnrollment.ProgressFileID = Impendulo.Common.Verifiction.OfProgressFiles.VerifyStudentProgressFile(CurrentEnrollment.StudentEnrollment.StudentID);


                            Dbconnection.Enrollments.Add(CurrentEnrollment);
                            Dbconnection.SaveChanges();
                            if (IsCompanyEnrollment)
                            {
                                Common.Verifiction.OfProgressFiles.VerifyCompanyStudentProgressFile(CurrentEnrollment.StudentEnrollment.StudentID, this.CompanyProgressFileID);
                            }
                            //End Step 1
                            //Step 2 Get PreRequiestes Courses and and load them with the main enrollment

                            List <CurriculumPrequisiteCourse> CPC = (from a in Dbconnection.CurriculumPrequisiteCourses
                                                                     where a.CurriculumID == CurrentEnquiry.CurriculumID
                                                                     select a)
                                                                    .Include("CurriculumCourse")
                                                                    .ToList <CurriculumPrequisiteCourse>();

                            //Get All The Possible Cuuriculum that for partof the Pre-Requisites
                            List <int> PreRequisiteCurriculumID = (from a in CPC
                                                                   select a.CurriculumCourse.CurriculumID)
                                                                  .Distinct <int>()
                                                                  .ToList <int>();
                            //Create Enrollment for each possible Curriculum that that forms part of the list pre-requisite Courses.
                            foreach (int CurriculumIDForPreRquisiteCourseEnrollment in PreRequisiteCurriculumID)
                            {
                                //Creates a Enrollment Enrty for the Curriculum
                                Data.Models.Enrollment PreRequisisteCourseEnrollment = new Data.Models.Enrollment
                                {
                                    EnrolmentParentID = CurrentEnrollment.EnrollmentID,
                                    EnquiryID         = this.CurrentEnquiry.EnquiryID,
                                    ProgressFileID    = CurrentEnrollment.ProgressFileID,

                                    LookupEnrollmentProgressStateID = (int)EnumEnrollmentProgressStates.New_Enrollment,
                                    CurriculumID      = CurriculumIDForPreRquisiteCourseEnrollment,
                                    StudentEnrollment = new StudentEnrollment()
                                    {
                                        StudentID   = CurrentEnrollment.StudentEnrollment.StudentID,
                                        DateUpdated = DateTime.Now
                                    },
                                    DateIntitiated    = DateTime.Now,
                                    EnrollmentExcempt = false
                                };
                                Dbconnection.Enrollments.Add(PreRequisisteCourseEnrollment);
                                Dbconnection.SaveChanges();
                                //links each pre-Requisite Course to the Curriculum Linked.
                                foreach (CurriculumCourse CurriculumCourseToLink in (from a in CPC
                                                                                     where a.CurriculumCourse.CurriculumID == CurriculumIDForPreRquisiteCourseEnrollment
                                                                                     select a.CurriculumCourse)
                                         .Distinct <CurriculumCourse>().
                                         ToList <CurriculumCourse>())
                                {
                                    Dbconnection.CurriculumCourseEnrollments.Add(new CurriculumCourseEnrollment
                                    {
                                        LookupEnrollmentProgressStateID = (int)EnumEnrollmentProgressStates.New_Enrollment,
                                        CurriculumCourseID = CurriculumCourseToLink.CurriculumCourseID,
                                        EnrollmentID       = PreRequisisteCourseEnrollment.EnrollmentID,
                                        CourseCost         = CurriculumCourseToLink.Cost // Set the linked course to the default Cost for the course
                                    });
                                }
                                //Saves the sub set of Pre-Requisite Curriculum and linked courses.
                                Dbconnection.SaveChanges();
                            }

                            EquiryHistory hist = new EquiryHistory
                            {
                                EnquiryID  = CurrentEnquiry.EnquiryID,
                                EmployeeID = CurrentEmployeeLoggedIn.EmployeeID,
                                LookupEquiyHistoryTypeID = (int)EnumEquiryHistoryTypes.Enrollment_Student_Successfully_Enrolled,
                                DateEnquiryUpdated       = DateTime.Now,
                                EnquiryNotes             = "Initial Enrollment Completed Successfully for the the Following Individual - " + CurrentEnrollment.StudentEnrollment.Student.Individual.FullName.ToString() + "\n Enquiry Ref# - " + CurrentEnquiry.EnquiryID
                            };
                            Dbconnection.EquiryHistories.Add(hist);


                            ////saves all above operations within one transaction
                            Dbconnection.SaveChanges();

                            //commit transaction
                            dbTran.Commit();
                            IsSuccessfullySaved = true;
                        }
                        catch (Exception ex)
                        {
                            if (ex is DbEntityValidationException)
                            {
                                foreach (DbEntityValidationResult entityErr in ((DbEntityValidationException)ex).EntityValidationErrors)
                                {
                                    foreach (DbValidationError error in entityErr.ValidationErrors)
                                    {
                                        //MessageBox.Show(error.ErrorMessage, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        MetroMessageBox.Show(this, error.ErrorMessage, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    }
                                }
                            }
                            else
                            {
                                //MessageBox.Show(ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                MetroMessageBox.Show(this, ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            //Rollback transaction if exception occurs
                            dbTran.Rollback();
                        }
                    }
                };
            }
        }