Example #1
0
        public static List <HeatData> CreateTicket(string staffNumber, string crn, string termCode)
        {
            List <HeatData> heatData    = new List <HeatData>();
            string          sentToEmail = WebConfigurationManager.AppSettings["ToEmail"];

            try
            {
                UtilResultObject res = new UtilResultObject();

                StudentAttendanceClient response = new StudentAttendanceClient();

                Files.dbConnection con = new Files.dbConnection(); // 218720 VP  // 22178 VS

                string sclearsql = string.Concat("SELECT * FROM [IntHub].[dbo].[StaffBKI] " +
                                                 "WHERE BarCode = @staffNumber" +
                                                 " and isActive = 1 and StaffType in ('Payroll BT','Payroll KI')"
                                                 );
                SqlParameter[] parameter =
                {
                    new SqlParameter("@staffNumber", SqlDbType.VarChar)
                    {
                        Value = staffNumber
                    }
                };
                DataTable tempTable = null;
                tempTable = con.executeSelectQuery(sclearsql, parameter);
                string emailTofromDB = WebConfigurationManager.AppSettings["ToEmail"];

                if ((tempTable == null) || (tempTable.Rows.Count == 0))
                {
                    emailTofromDB = WebConfigurationManager.AppSettings["ToEmailLogin"];
                }
                else
                {
                    foreach (DataRow dr in tempTable.Rows)
                    {
                        emailTofromDB = dr["Login"].ToString();
                        sentToEmail   = dr["EmailInstitute"].ToString();
                    }
                }

                res = response.CreateHEATTicket(WebConfigurationManager.AppSettings["webServiceUsername"],
                                                WebConfigurationManager.AppSettings["webServicePassword"],
                                                emailTofromDB,
                                                staffNumber,
                                                crn,
                                                termCode);

                if (res.Status)
                {
                    try
                    {
                        MailMessage mail       = new MailMessage();
                        SmtpClient  SmtpServer = new SmtpClient("mail-relay.kbtm.kangan.edu.au");

                        mail.From = new MailAddress(WebConfigurationManager.AppSettings["FromEmail"]);

                        //Files.dbConnection con = new Files.dbConnection(); // 218720 VP  // 22178 VS


                        //string sclearsql = string.Concat("SELECT * FROM [IntHub].[dbo].[StaffBKI] " +
                        //                                         "WHERE BarCode = @staffNumber" +
                        //                                         " and isActive = 1 and StaffType in ('Payroll BT','Payroll KI')"
                        //                                );
                        //SqlParameter[] parameter = {
                        //                        new SqlParameter("@staffNumber", SqlDbType.VarChar) { Value =staffNumber }
                        //                         };
                        //DataTable tempTable = null;

                        //tempTable = con.executeSelectQuery(sclearsql, parameter);

                        //if ((tempTable == null) || (tempTable.Rows.Count == 0))
                        //{
                        //    mail.To.Add(WebConfigurationManager.AppSettings["ToEmail"]);
                        //}
                        //else
                        //{
                        //    foreach (DataRow dr in tempTable.Rows)
                        //    {
                        //        //dr["EmailInstitute"].ToString();
                        //        mail.To.Add(dr["EmailInstitute"].ToString());
                        //        sentToEmail = dr["EmailInstitute"].ToString();
                        //    }
                        //}
                        //where BarCode = CONVERT(varchar(50), 218720 )

                        mail.To.Add(sentToEmail);

                        mail.Subject = "Student Attendance Missing";

                        string heatCloseUrl = WebConfigurationManager.AppSettings["AttendanceSubmission"];
                        //string heatCloseUrl = WebConfigurationManager.AppSettings["HeatTicketClose"];

                        string url = heatCloseUrl + "?heatId=" + res.Message +
                                     "&teacherId=" + staffNumber
                                     + "&crn=" + crn
                                     + "&termCode=" + termCode
                                     + "&classDate=" + DateTime.Now.ToString("dd'/'MM'/'yyyy");

                        mail.Body = @"Heat Ticket is created." + " The id is:- " + res.Message + "\n" + url;

                        SmtpServer.Port = 25;

                        //SmtpServer.Send(mail);


                        HeatData hd = new HeatData();
                        hd.heatId        = res.Message;
                        hd.message       = res.Status.ToString();
                        hd.sentToEmail   = sentToEmail;
                        hd.emailTofromDB = emailTofromDB;
                        heatData.Add(hd);

                        return(heatData);
                    }
                    catch (Exception ex)
                    {
                        return(heatData);

                        throw ex;
                        //MessageBox.Show(ex.ToString());
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            //return message;
            return(heatData);
        }
        public static StudentApplicationData GetFormData(string applicationId) //string applicationId
        {
            Files.dbConnection     con = new Files.dbConnection();
            StudentApplicationData applicationDetails = new StudentApplicationData();

            try
            {
                string         sql_getApplicationDetails       = string.Concat("[dbo].[sp_getApplicationDetails]");
                DataTable      tempTable_getApplicationDetails = null;
                SqlParameter[] parameter =
                {
                    new SqlParameter("@applicationId", SqlDbType.VarChar)
                    {
                        Value = applicationId
                    }
                };

                tempTable_getApplicationDetails = con.executeSelectQuery(sql_getApplicationDetails, parameter);
                if ((tempTable_getApplicationDetails != null) || (tempTable_getApplicationDetails.Rows.Count >= 0))
                {
                    foreach (DataRow drr in tempTable_getApplicationDetails.Rows)
                    {
                        applicationDetails.vrt_title     = drr["Title"].ToString();
                        applicationDetails.firstName     = drr["FirstName"].ToString();
                        applicationDetails.lastname      = drr["Lastname"].ToString();
                        applicationDetails.emailaddress1 = drr["Email"].ToString();
                        applicationDetails.isEmailValid  = drr["IsEmailValid"].ToString();
                        applicationDetails.mobilephone   = drr["MobilePhone"].ToString();
                        applicationDetails.isNumberValid = drr["IsNumberValid"].ToString();
                        applicationDetails.birthdate     = drr["BirthdateFormatted"].ToString();//Birthdate

                        #region Get course and campus lookup
                        string         sql_getApplicationCourseCampus       = string.Concat("[dbo].[sp_getApplicationCourseCampus]");
                        DataTable      tempTable_getApplicationCourseCampus = null;
                        SqlParameter[] parameterApplicationCourseCampus     =
                        {
                            new SqlParameter("@applicationId", SqlDbType.VarChar)
                            {
                                Value = applicationId
                            }
                        };

                        tempTable_getApplicationCourseCampus = con.executeSelectQuery(sql_getApplicationCourseCampus, parameterApplicationCourseCampus);
                        applicationDetails.courseNCampus     = new List <CourseNCampus>();
                        if ((tempTable_getApplicationCourseCampus != null) && (tempTable_getApplicationCourseCampus.Rows.Count > 0))
                        {
                            foreach (DataRow dr in tempTable_getApplicationCourseCampus.Rows)
                            {
                                CourseNCampus cc = new CourseNCampus();

                                cc.vrt_course     = dr["CourseID"].ToString();
                                cc.vrt_courseCode = dr["CourseCode"].ToString();
                                cc.vrt_courseName = dr["Course"].ToString();
                                cc.txtCampus      = dr["CampusID"].ToString();
                                cc.txtCampusName  = dr["Campus"].ToString();
                                cc.courseCampusID = Int32.Parse(dr["CourseCampusID"].ToString());
                                applicationDetails.courseNCampus.Add(cc);
                            }
                        }
                        else
                        {
                            applicationDetails.courseNCampus.Add(new CourseNCampus());
                        }
                        #endregion

                        applicationDetails.studentGender       = drr["Gender"].ToString();
                        applicationDetails.address1_postalcode = drr["Postcode"].ToString();

                        #region Get Qualification Lookup
                        string         sql_getApplicationQualifications       = string.Concat("[dbo].[sp_getApplicationQualifications]");
                        DataTable      tempTable_getApplicationQualifications = null;
                        SqlParameter[] parameterApplicationQualifications     =
                        {
                            new SqlParameter("@applicationId", SqlDbType.VarChar)
                            {
                                Value = applicationId
                            }
                        };

                        tempTable_getApplicationQualifications = con.executeSelectQuery(sql_getApplicationQualifications, parameterApplicationQualifications);
                        applicationDetails.txtQualification    = new List <Qualification>();
                        if ((tempTable_getApplicationQualifications != null) && (tempTable_getApplicationQualifications.Rows.Count > 0))
                        {
                            foreach (DataRow dr in tempTable_getApplicationQualifications.Rows)
                            {
                                Qualification qual = new Qualification();

                                qual.qualificationID   = Int32.Parse(dr["QualificationID"].ToString());
                                qual.qualification     = dr["Qualification"].ToString();
                                qual.internalName      = dr["InternalName"].ToString();
                                qual.qualificationCode = dr["QualificationCode"].ToString();
                                qual.selected          = Boolean.Parse(dr["selected"].ToString());
                                applicationDetails.txtQualification.Add(qual);
                            }
                        }
                        #endregion

                        applicationDetails.vrt_successfullycompletedqualifications       = drr["CompletedQualification"].ToString();
                        applicationDetails.vrt_whatbroughtyoutothekanganinstitutewebsite = new WhatBroughtYouHere();
                        applicationDetails.vrt_whatbroughtyoutothekanganinstitutewebsite.vrt_whatbroughtyoutothekanganinstitutewebsite = drr["ReasonToChooseBKI"].ToString();
                        applicationDetails.vrt_whatbroughtyoutothekanganinstitutewebsite.reasonToChooseBKIID = Int32.Parse(drr["ReasonToChooseBKIID"].ToString());
                        applicationDetails.vrt_studiedatkanganinstitutebendigotafebefore = drr["StudiedHereBefore"].ToString();
                        applicationDetails.vrt_kibtstudentidnumber            = drr["PrevStudentNumber"].ToString();
                        applicationDetails.vrt_australiancitizenshipresidency = new Residency();
                        applicationDetails.vrt_australiancitizenshipresidency.vrt_australiancitizenshipresidency = drr["Residency"].ToString();
                        applicationDetails.vrt_australiancitizenshipresidency.residencyId = Int32.Parse(drr["ResidencyID"].ToString());
                        applicationDetails.vrt_australiancitizenshipresidency.type        = drr["ResidencyType"].ToString();
                        applicationDetails.vrt_aboriginalortorresstraitislander           = new Aboriginal();
                        applicationDetails.vrt_aboriginalortorresstraitislander.vrt_aboriginalortorresstraitislander = drr["Status"].ToString();
                        applicationDetails.vrt_aboriginalortorresstraitislander.statusId = Int32.Parse(drr["IndigenousStatusID"].ToString());
                        applicationDetails.hasUSI = drr["HasUSI"].ToString();
                        applicationDetails.vrt_uniquestudentidentifier          = drr["USI"].ToString();
                        applicationDetails.vrt_permissiontocheckfororcreateausi = drr["VerifyUSI"].ToString();
                        applicationDetails.applyUSI                         = drr["ApplyUSI"].ToString();
                        applicationDetails.streetNumber                     = drr["StreetNumber"].ToString();
                        applicationDetails.streetName                       = drr["StreetName"].ToString();
                        applicationDetails.city                             = drr["CityOfResidence"].ToString();
                        applicationDetails.state                            = new State();
                        applicationDetails.state.state                      = drr["State"].ToString();
                        applicationDetails.state.stateID                    = Int32.Parse(drr["StateOfResidenceId"].ToString());
                        applicationDetails.vrt_CityorTownofBirth            = drr["CityOfBirth"].ToString();
                        applicationDetails.isAddressValid                   = drr["IsAddressValid"].ToString(); // Accepts True or False
                        applicationDetails.vrt_CountryofBirth               = new Country();
                        applicationDetails.vrt_CountryofBirth.country       = drr["CountryOfBirth"].ToString();
                        applicationDetails.vrt_CountryofBirth.countryID     = Int32.Parse(drr["CountryOfBirthID"].ToString());
                        applicationDetails.vrt_CountryofResidence           = new Country();
                        applicationDetails.vrt_CountryofResidence.country   = drr["CountryOfResidence"].ToString();
                        applicationDetails.vrt_CountryofResidence.countryID = Int32.Parse(drr["CountryOfResidenceID"].ToString());
                        applicationDetails.idProof                          = new IdProof();
                        applicationDetails.idProof.internalName             = drr["InternalName"].ToString();
                        applicationDetails.idProof.type                     = drr["Type"].ToString();
                        applicationDetails.idProof.proofId                  = Int32.Parse(drr["ProofTypeID"].ToString());
                        applicationDetails.idProof.idProofName              = drr["IdentityProof"].ToString();
                        applicationDetails.idProofText                      = drr["ProofNumber"].ToString();
                        applicationDetails.partialSave                      = drr["PartialSave"].ToString();
                    }
                }
            }
            catch (Exception e)
            {
            }
            return(applicationDetails);
        }