public List<DataEntity> GetAllPosition()
        {
            try
            {
                SqlDataReader dr;
                List<DataEntity> lstPosition = new List<DataEntity>();

                dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "GetPosition", null);
                while (dr.Read())
                {
                    DataEntity objlocation = new DataEntity();
                    objlocation.PositionID = dr.GetInt32(0);
                    objlocation.Position = dr.GetString(1);
                    lstPosition.Add(objlocation);

                }


                return lstPosition;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public List <DataEntity> SetQuestionValue(Int32 I, Int32 J, string cat, Int32 CanId, string ExamDate)
        {
            try
            {
                List <DataEntity> lst = new List <DataEntity>();

                SqlParameter[] param =
                {
                    new SqlParameter("@FQuNo",       SqlDbType.Int),
                    new SqlParameter("@TQuNo",       SqlDbType.Int),
                    new SqlParameter("@Catgory",     SqlDbType.NVarChar),
                    new SqlParameter("@CandidateId", SqlDbType.Int),
                    new SqlParameter("@TDate",       SqlDbType.NVarChar)
                };

                param[0].Value = I;
                param[1].Value = J;
                param[2].Value = cat;
                param[3].Value = CanId;
                param[4].Value = ExamDate;


                SqlDataReader dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "SetQuestionValue", param);

                while (dr.Read())
                {
                    DataEntity DE = new DataEntity();
                    DE.FQuNo    = dr.GetInt32(0);
                    DE.Quvalue  = dr.GetInt32(1);
                    DE.QueGrade = dr.GetString(2);
                    lst.Add(DE);
                }

                return(lst);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
        public List <DataEntity> GetCandidateDetails(Int32 CanId, string Pdate)
        {
            try
            {
                SqlDataReader     dr;
                List <DataEntity> lstEmail = new List <DataEntity>();

                SqlParameter[] param =
                {
                    new  SqlParameter("@canid",    SqlDbType.Int),
                    new  SqlParameter("@Examdate", SqlDbType.NVarChar)
                };


                param[0].Value = CanId;
                param[1].Value = Pdate;

                dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "Email_GetCandidateDetails", param);
                while (dr.Read())
                {
                    DataEntity objlocation = new DataEntity();
                    objlocation.FirstNameTodisplayExampage = dr.GetString(0);
                    objlocation.FirstName = dr.GetString(1);
                    objlocation.EmailId   = dr.GetString(2);
                    objlocation.MobileNo  = dr.GetString(3);
                    objlocation.Position  = dr.GetString(4);
                    objlocation.ExamDate  = dr.GetString(5);
                    objlocation.StartTime = Convert.ToDateTime(dr.GetString(6)).ToString("HH:mm tt");
                    objlocation.EndTime   = System.DateTime.Now.ToString("HH:mm tt");
                    lstEmail.Add(objlocation);
                }


                return(lstEmail);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
        public string GetCAFScore(Int32 CanId, string Pdate)
        {
            try
            {
                SqlDataReader dr;
                string        CAFScore = string.Empty;

                SqlParameter[] param =
                {
                    new  SqlParameter("@Examdate",    SqlDbType.NVarChar),
                    new  SqlParameter("@candidateid", SqlDbType.Int)
                };
                param[0].Value = Pdate;
                param[1].Value = CanId;

                dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "GetCAFScore", param);
                while (dr.Read())
                {
                    DataEntity objlocation = new DataEntity();

                    if (dr.GetValue(0) != DBNull.Value)
                    {
                        CAFScore = dr.GetDecimal(0).ToString();
                    }

                    else
                    {
                        CAFScore = "0";
                    }
                }

                return(CAFScore);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #5
0
        private void SaveUpdateRecords(List <DataEntity> objSaveLst)
        {
            //string strQuery = string.Empty;
            //SqlConnection conn = new SqlConnection(DataConstant.SqlConn);

            //conn.Open();

            try
            {
                foreach (DataEntity de in objSaveLst)
                {
                    DataEntity InsertCAFAns = new DataEntity();
                    InsertCAFAns.QNo         = de.QNo;
                    InsertCAFAns.SelectedAns = de.SelectedAns;

                    //strQuery = "IF NOT EXISTS(select * from dbo.MHRI_PSI_RSI_CAF_Scores where Candidateid=" + Session["Candidateid"] + " and Category='CAF' and QuesNo='" + de.QNo + "' and QuestionChar='X' and convert(date,Examdate,101)=convert(date,GETDATE(),101)) " +
                    //" Insert into MHRI_PSI_RSI_CAF_Scores values(" + Session["Candidateid"] + ",getdate(),'" + de.QNo + "','X','" + de.SelectedAns + "','CAF')" +
                    //" else " +
                    //" Update MHRI_PSI_RSI_CAF_Scores set value='" + de.SelectedAns + "' where Candidateid=" + Session["Candidateid"] + " and Category='CAF' and QuesNo='" + de.QNo + "' and QuestionChar='X' and convert(date,Examdate,101)=convert(date,GETDATE(),101)";

                    DE.InsertCAFAnswer(InsertCAFAns, Convert.ToInt32(Session["Candidateid"]));

                    //SqlCommand cmd = new SqlCommand(strQuery, conn);

                    //cmd.ExecuteNonQuery();
                }

                lblmsg.Text = "Record saved sucessfully";
            }
            catch (Exception ex)
            {
                lblmsg.Text = ex.Message;
            }
            finally
            {
                //conn.Close();
            }
        }
        public List <DataEntity> GetCAFQuestion()
        {
            List <DataEntity> lstCAFquestion = new List <DataEntity>();

            string sqlquery = "select QNo,Q1,COALESCE(Q2,''),A1,A2,A3,A4,COALESCE(ImageURL,'') from CAF";



            //SqlCommand cmd = new SqlCommand("select QNo,Q1,COALESCE(Q2,''),A1,A2,A3,A4,COALESCE(ImageURL,'') from CAF", con);


            SqlDataReader dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.Text, sqlquery, null);

            while (dr.Read())
            {
                DataEntity obj = new DataEntity();
                obj.QNo = dr.GetInt32(0);
                obj.Q1  = dr.GetString(1);
                if (dr.GetString(2) != null)
                {
                    obj.Q2 = dr.GetString(2);
                }
                obj.A1 = dr.GetString(3);
                obj.A2 = dr.GetString(4);
                obj.A3 = dr.GetString(5);
                obj.A4 = dr.GetString(6);
                if (dr.GetString(7) != null)
                {
                    obj.strImageURL = dr.GetString(7);
                }
                obj.SelectedAns = 0;
                lstCAFquestion.Add(obj);
            }



            return(lstCAFquestion);
        }
Пример #7
0
 public void BindOptionButton(DataEntity X)
 {
     if (X.SelectedAns == 1)
     {
         RadioButton rd1 = (RadioButton)Repeater1.Items[0].FindControl("RadioButton1");
         rd1.Checked = true;
     }
     else if (X.SelectedAns == 2)
     {
         RadioButton rd2 = (RadioButton)Repeater1.Items[0].FindControl("RadioButton2");
         rd2.Checked = true;
     }
     else if (X.SelectedAns == 3)
     {
         RadioButton rd3 = (RadioButton)Repeater1.Items[0].FindControl("RadioButton3");
         rd3.Checked = true;
     }
     else if (X.SelectedAns == 4)
     {
         RadioButton rd4 = (RadioButton)Repeater1.Items[0].FindControl("RadioButton4");
         rd4.Checked = true;
     }
 }
        public Boolean AuthencateCandidate(DataEntity objCan)
        {
            try
            {
                Boolean CandidateFlag;
                CandidateFlag = false;

                SqlParameter[] param =
                {
                    new SqlParameter("@Fname",    SqlDbType.NVarChar),
                    new SqlParameter("@Lname",    SqlDbType.NVarChar),
                    new SqlParameter("@MobileNo", SqlDbType.NVarChar),
                    new SqlParameter("@EmailId",  SqlDbType.NVarChar),
                };
                param[0].Value = objCan.FirstName;
                param[1].Value = objCan.LastName;
                param[2].Value = objCan.MobileNo;
                param[3].Value = objCan.EmailId;

                SqlDataReader dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "AuthenticateCandidate", param);

                while (dr.Read())
                {
                    if (dr.GetInt32(0) == 1)
                    {
                        CandidateFlag = true;
                    }
                }

                return(CandidateFlag);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
        public List <DataEntity> GetAllPosition()
        {
            try
            {
                SqlDataReader     dr;
                List <DataEntity> lstPosition = new List <DataEntity>();

                dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "GetPosition", null);
                while (dr.Read())
                {
                    DataEntity objlocation = new DataEntity();
                    objlocation.PositionID = dr.GetInt32(0);
                    objlocation.Position   = dr.GetString(1);
                    lstPosition.Add(objlocation);
                }


                return(lstPosition);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public string  GetPSIScore(Int32 CanId, string Pdate)
        {
            try
            {
                SqlDataReader dr;
               string maxchar=string.Empty ;

                SqlParameter[] param ={

                         new  SqlParameter ("@Examdate",SqlDbType.NVarChar),
                         new  SqlParameter ("@candidateid",SqlDbType.Int)
                                      };
                param[0].Value = Pdate;
                param[1].Value = CanId;

                dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "GetcharectorScore", param);
                while (dr.Read())
                {
                    DataEntity objlocation = new DataEntity();
                    maxchar = maxchar+ dr.GetString(0);
                   
                   

                }

                return maxchar;
                
            }
            
            catch (Exception ex)
            {
                throw ex;
            }

        }
        public List<DataEntity> GetRSIScore(Int32 CanId, string Pdate)
        {
            try
            {
                SqlDataReader dr;
                List<DataEntity> lstRSI = new List<DataEntity>();

                SqlParameter[] param ={

                         new  SqlParameter ("@Examdate",SqlDbType.NVarChar),
                         new  SqlParameter ("@candidateid",SqlDbType.Int)
                                      };
                param[0].Value = Pdate;
                param[1].Value = CanId;

                dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "GetRSIScore", param);
                while (dr.Read())
                {
                    DataEntity objlocation = new DataEntity();
                    objlocation.QChar = dr.GetString(0);
                    objlocation.Quvalue = dr.GetInt32(1);
                    
                    lstRSI.Add(objlocation);

                }


                return lstRSI;
            }

            catch (Exception ex)
            {
                throw ex;
            }

        }
        public List<DataEntity> GetCandidateDetails(Int32 CanId,string Pdate)
        {
            try
            {
                SqlDataReader dr;
                List<DataEntity> lstEmail = new List<DataEntity>();

                SqlParameter[] param ={

                         new  SqlParameter ("@canid",SqlDbType.Int),
                         new  SqlParameter ("@Examdate",SqlDbType.NVarChar)
                                      };


                param[0].Value = CanId;
                param[1].Value = Pdate;

                dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "Email_GetCandidateDetails", param);
                while (dr.Read())
                {
                    DataEntity objlocation = new DataEntity();
                    objlocation.FirstNameTodisplayExampage = dr.GetString(0);
                    objlocation.FirstName = dr.GetString(1);
                    objlocation.EmailId = dr.GetString(2);
                    objlocation.MobileNo = dr.GetString(3);
                    objlocation.Position  = dr.GetString(4);
                    objlocation.ExamDate = dr.GetString(5);
                    objlocation.StartTime = Convert.ToDateTime(dr.GetString(6)).ToString("HH:mm tt");
                    objlocation.EndTime = System.DateTime.Now.ToString("HH:mm tt");
                    lstEmail.Add(objlocation);

                }


                return lstEmail;
            }

            catch (Exception ex)
            {
                throw ex;
            }

        }
        public List<DataEntity> SetQuestionValue(Int32 I, Int32 J, string cat,Int32 CanId,string ExamDate)
        {
            try
            {

                List<DataEntity> lst = new List<DataEntity>();

                SqlParameter[] param =
            {

                new SqlParameter ("@FQuNo",SqlDbType.Int),
                new SqlParameter ("@TQuNo",SqlDbType.Int),
                new SqlParameter ("@Catgory",SqlDbType.NVarChar),
                 new SqlParameter ("@CandidateId",SqlDbType.Int),
                new SqlParameter ("@TDate",SqlDbType.NVarChar)
                
                
                
            };

                param[0].Value = I;
                param[1].Value = J;
                param[2].Value = cat;
                param[3].Value = CanId;
                param[4].Value = ExamDate;


                SqlDataReader dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "SetQuestionValue", param);

                while (dr.Read())
                {
                    DataEntity DE = new DataEntity();
                    DE.FQuNo = dr.GetInt32(0);
                    DE.Quvalue = dr.GetInt32(1);
                    DE.QueGrade = dr.GetString(2);
                    lst.Add(DE);
                }

                return lst;
            }

            catch (Exception ex)
            {
                throw ex;
            }


        }
        public Int32 InsertCandidateDetails(DataEntity objCan)
        {
            try
            {


                Int32 CandidateID;
                CandidateID = 0;

                SqlParameter[] param =
            {

                new SqlParameter ("@Fname",SqlDbType.NVarChar),
                new SqlParameter ("@Lname",SqlDbType.NVarChar),
                new SqlParameter ("@MobileNo",SqlDbType.NVarChar),
                new SqlParameter ("@EmailId",SqlDbType.NVarChar),
                 new SqlParameter ("@LocationId",SqlDbType.Int),
                new SqlParameter ("@PositionId",SqlDbType.Int),
                new SqlParameter ("@Day",SqlDbType.NVarChar),
                new SqlParameter ("@month",SqlDbType.NVarChar),
               new SqlParameter ("@year",SqlDbType.NVarChar),
                new SqlParameter ("@qualificationid",SqlDbType.Int),
                new SqlParameter ("@ExperinceId",SqlDbType.Int),
                 new SqlParameter ("@Accdec",SqlDbType.Bit),
                 new SqlParameter ("@panNo",SqlDbType.NVarChar)
            };
                param[0].Value = objCan.FirstName;
                param[1].Value = objCan.LastName;
                param[2].Value = objCan.MobileNo;
                param[3].Value = objCan.EmailId;

                param[4].Value = objCan.LocationID;
                param[5].Value = objCan.PositionID;
                param[6].Value = objCan.Day;
                param[7].Value = objCan.Month;
                param[8].Value = objCan.Year;
                param[9].Value = objCan.QualificationId;
                param[10].Value = objCan.ExperienceId;
                param[11].Value = objCan.AcceptDec;
                param[12].Value = objCan.PanNo;

                SqlDataReader dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "InsetCandidateDetails", param);

                while (dr.Read())
                {

                    CandidateID = dr.GetInt32(0);


                }

                return CandidateID;
            }

            catch (Exception ex)
            {
                throw ex;
            }


        }
        public void SendEmail(Int32 Canid, string pdate)
        {
            DataAccess        DEmail = new DataAccess();
            List <DataEntity> lst    = new List <DataEntity>();
            List <DataEntity> lstrsi = new List <DataEntity>();


            if (MHRISesstion.HREmailid != "")
            {
                Int32 Canditeid = Canid;

                String Pdate = pdate;
                lst = DEmail.GetCandidateDetails(Canditeid, Pdate);
                string body = "<html> Hi </br></br> Please find the report of the pre-employment test below:</br></br></br> Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:[Name]</br> Email ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:[Emailid]</br> Mobile Number&nbsp;&nbsp;&nbsp;&nbsp;:[Mobile]</br> Position&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:[Position]</br> Exam Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:[ExamDate]</br>Exam Start Time&nbsp;&nbsp;:[StartTime]</br>Exam End Time&nbsp;&nbsp;&nbsp;:[EndTime] ";
                if (lst.Count > 0)
                {
                    body          = body.Replace("[Name]", lst[0].FirstName);
                    Candidatename = lst[0].FirstName;
                    body          = body.Replace("[Emailid]", lst[0].EmailId);
                    body          = body.Replace("[Mobile]", lst[0].MobileNo);
                    body          = body.Replace("[Position]", lst[0].Position);
                    body          = body.Replace("[ExamDate]", lst[0].ExamDate);
                    body          = body.Replace("[StartTime]", lst[0].StartTime);
                    body          = body.Replace("[EndTime]", lst[0].EndTime);
                }

                string CAFscore = DEmail.GetCAFScore(Canditeid, Pdate);

                //body = body + "</br></br></br></br> Section 1: CAF </br> Score obtained is " + CAFscore + " out of " + 15 + "</br></br> Section 2: RSI</br> The score of various career anchor are below : <table > ";
                body = body + "</br></br></br></br> Section 1: CAF </br> Score obtained is " + CAFscore + " out of " + 15;
                body = body + "</br> CAF Examination Duration is " + MHRISesstion.CandidateCAFduration.ToString() + "mins";
                body = body + "</br></br> Section 2: RSI</br> The score of various career anchor are below : <table > ";

                lstrsi = DEmail.GetRSIScore(Canditeid, Pdate);


                if (lstrsi.Count > 0)
                {
                    foreach (var obj in lstrsi)
                    {
                        DataEntity D1 = new DataEntity();



                        body = body + "<tr> <td>" + obj.QChar + "</td>" + "<td>" + obj.Quvalue + "</td></tr>";
                    }
                }

                body = body + "</table>";
                body = body + " </br></br> Section 3: PSI </br> The Profile according of PSI is :";//      +</html>";

                string psiscore = DEmail.GetPSIScore(Canditeid, Pdate);
                body = body + psiscore;



                string StrAbbreviations = DEmail.GetPSIAbbreviations(psiscore);

                if (StrAbbreviations != "")
                {
                    string bodypart = " </br> A short description of the same is below :- </br> <table > <tr> <td > </td> <td  >" + StrAbbreviations + "</td <td > </td> </tr> </table></html>";
                    body = body + bodypart;
                }

                else
                {
                    body = body + "</html>";
                }



                if (Candidatename != "")
                {
                    Subject = "Pre-Employment test score for candidate:-" + "  " + Candidatename;
                }

                else
                {
                    Subject = "Pre-Employment test score for candidate:-" + "  ";
                }



                EmailUtil.MHRISendMail(null, MHRISesstion.HREmailid, null, null, Subject, body, null, null, null, null, null);
                //EmailUtil.MHRISendMailTest(null, MHRISesstion.HREmailid, null, null, Subject, body, null, null, null, null, null);
            }
        }
        public void BindOptionButton(DataEntity X)
        {
            if (X.SelectedAns == 1)
            {
                RadioButton rd1 = (RadioButton)Repeater1.Items[0].FindControl("RadioButton1");
                rd1.Checked = true;
            }
            else if (X.SelectedAns == 2)
            {
                RadioButton rd2 = (RadioButton)Repeater1.Items[0].FindControl("RadioButton2");
                rd2.Checked = true;
            }
            else if (X.SelectedAns == 3)
            {
                RadioButton rd3 = (RadioButton)Repeater1.Items[0].FindControl("RadioButton3");
                rd3.Checked = true;
            }
            else if (X.SelectedAns == 4)
            {
                RadioButton rd4 = (RadioButton)Repeater1.Items[0].FindControl("RadioButton4");
                rd4.Checked = true;
            }

        }
        public List<DataEntity> GetCAFQuestion()
        {
            List<DataEntity> lstCAFquestion = new List<DataEntity>();

            string sqlquery="select QNo,Q1,COALESCE(Q2,''),A1,A2,A3,A4,COALESCE(ImageURL,'') from CAF";
           


            //SqlCommand cmd = new SqlCommand("select QNo,Q1,COALESCE(Q2,''),A1,A2,A3,A4,COALESCE(ImageURL,'') from CAF", con);


            SqlDataReader dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.Text, sqlquery, null); 
            while (dr.Read())
            {
                DataEntity obj = new DataEntity();
                obj.QNo = dr.GetInt32(0);
                obj.Q1 = dr.GetString(1);
                if (dr.GetString(2) != null)
                    obj.Q2 = dr.GetString(2);
                obj.A1 = dr.GetString(3);
                obj.A2 = dr.GetString(4);
                obj.A3 = dr.GetString(5);
                obj.A4 = dr.GetString(6);
                if (dr.GetString(7) != null)
                    obj.strImageURL = dr.GetString(7);
                obj.SelectedAns = 0;
                lstCAFquestion.Add(obj);
            } 



            return lstCAFquestion;

        }
        public string GetCAFScore(Int32 CanId, string Pdate)
        {
            try
            {
                SqlDataReader dr;
                string CAFScore = string.Empty;

                SqlParameter[] param ={

                         new  SqlParameter ("@Examdate",SqlDbType.NVarChar),
                         new  SqlParameter ("@candidateid",SqlDbType.Int)
                                      };
                param[0].Value = Pdate;
                param[1].Value = CanId;

                dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "GetCAFScore", param);
                while (dr.Read())
                {
                    DataEntity objlocation = new DataEntity();

                    if (dr.GetValue(0) != DBNull.Value)
                    {
                        CAFScore = dr.GetDecimal(0).ToString();
                    }

                    else
                    {
                        CAFScore = "0";
                    }

                }

                return CAFScore;

            }

            catch (Exception ex)
            {
                throw ex;
            }

        }
Пример #19
0
        protected void BtnLogin_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                bool IsvalidMobile, IsvalidEmial, IsvalidPAN;
                IsvalidMobile = ValidateMobileControl();
                IsvalidEmial  = ValidateEmailControl();
                IsvalidPAN    = ValidatePANControl();

                if (IsvalidMobile && IsvalidEmial && IsvalidPAN)
                {
                    Boolean Flag;
                    Flag = false;
                    DataAccess AuthenCandidate = new DataAccess();
                    DataEntity DE = new DataEntity();
                    DE.FirstName = txtfirstname.Text;
                    DE.LastName  = txtlastname.Text;
                    DE.MobileNo  = txtmobile.Text;
                    DE.EmailId   = txtEmail.Text;

                    //Flag = AuthenCandidate.AuthencateCandidate(DE);

                    Flag = true;
                    if (Flag == true)
                    {
                        DE.LocationID      = Convert.ToInt32(ddllocation.SelectedValue);
                        DE.PositionID      = Convert.ToInt32(ddlposition.SelectedValue);
                        DE.QualificationId = Convert.ToInt32(ddlQualification.SelectedValue);
                        DE.ExperienceId    = Convert.ToInt32(ddlExpeience.SelectedValue);
                        DE.Day             = ddlday.SelectedItem.Text;
                        DE.Month           = ddldobmonth.SelectedItem.Text;
                        DE.Year            = txtyear.Text;
                        if (chkdeclaration.Checked == true)
                        {
                            DE.AcceptDec = 1;
                        }
                        else
                        {
                            DE.AcceptDec = 0;
                        }

                        DE.PanNo = txtpanno.Text;


                        if (vadidateDOB(DE.Day, DE.Month, DE.Year))
                        {
                            if (chkdeclaration.Checked == true)
                            {
                                //Int32 can = AuthenCandidate.InsertCandidateDetails(DE);
                                MHRISesstion.CandidateId          = Convert.ToString(AuthenCandidate.InsertCandidateDetails(DE));
                                MHRISesstion.HRCandidateFirstName = txtfirstname.Text;
                                //MHRISesstion.TimeLeftofCAFTest = null;
                                Session["TimeLeftofCAFTest"] = null;
                                Response.Redirect("../Forms/CAF.aspx", false);
                            }
                            else
                            {
                                lblErrorMessage.Visible = true;
                                lblErrorMessage.Text    = "Please accept the declaration.";
                            }
                        }

                        else
                        {
                            lblErrorMessage.Visible = true;
                            lblErrorMessage.Text    = "DOB Not Proper Format And Year Should be >=1753 !!!!";
                        }
                    }
                    else
                    {
                        lblErrorMessage.Visible = true;
                        lblErrorMessage.Text    = "You Are Not Authorised,Please Contact HR !!!!";
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void BtnLogin_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                bool IsvalidMobile, IsvalidEmial, IsvalidPAN;
                IsvalidMobile = ValidateMobileControl();
                IsvalidEmial = ValidateEmailControl();
                IsvalidPAN = ValidatePANControl();

                if (IsvalidMobile && IsvalidEmial && IsvalidPAN)
                {


                    Boolean Flag;
                    Flag = false;
                    DataAccess AuthenCandidate = new DataAccess();
                    DataEntity DE = new DataEntity();
                    DE.FirstName = txtfirstname.Text;
                    DE.LastName = txtlastname.Text;
                    DE.MobileNo = txtmobile.Text;
                    DE.EmailId = txtEmail.Text;

                    //Flag = AuthenCandidate.AuthencateCandidate(DE);

                    Flag = true;
                    if (Flag == true)
                    {
                        DE.LocationID = Convert.ToInt32(ddllocation.SelectedValue);
                        DE.PositionID = Convert.ToInt32(ddlposition.SelectedValue);
                        DE.QualificationId = Convert.ToInt32(ddlQualification.SelectedValue);
                        DE.ExperienceId = Convert.ToInt32(ddlExpeience.SelectedValue);
                        DE.Day = ddlday.SelectedItem.Text;
                        DE.Month = ddldobmonth.SelectedItem.Text;
                        DE.Year = txtyear.Text;
                        if (chkdeclaration.Checked == true)
                        {
                            DE.AcceptDec = 1;
                        }
                        else
                        {
                            DE.AcceptDec = 0;
                        }

                        DE.PanNo = txtpanno.Text;
                                               

                        if (vadidateDOB(DE.Day, DE.Month, DE.Year))
                        {
                            if (chkdeclaration.Checked == true)
                            {
                                //Int32 can = AuthenCandidate.InsertCandidateDetails(DE);
                                MHRISesstion.CandidateId = Convert.ToString(AuthenCandidate.InsertCandidateDetails(DE));
                                MHRISesstion.HRCandidateFirstName = txtfirstname.Text;
                                //MHRISesstion.TimeLeftofCAFTest = null;
                                Session["TimeLeftofCAFTest"] = null;
                                Response.Redirect("../Forms/CAF.aspx", false);
                            }
                            else
                            {
                                lblErrorMessage.Visible = true;
                                lblErrorMessage.Text = "Please accept the declaration.";

                            }
                        }

                        else
                        {
                            lblErrorMessage.Visible = true;
                            lblErrorMessage.Text = "DOB Not Proper Format And Year Should be >=1753 !!!!";
                        }
                        
                    }
                    else
                    {
                        lblErrorMessage.Visible = true;
                        lblErrorMessage.Text = "You Are Not Authorised,Please Contact HR !!!!";

                    }
                }
            }

            catch (Exception ex)
            {

                throw ex;
            }
        }
        public string GetPSIAbbreviations(string score )
        {
            try
            {
                SqlDataReader dr;
                string Abbreviations = string.Empty;

                SqlParameter[] param ={

                         new  SqlParameter ("@qchar",SqlDbType.NVarChar)
                        
                                      };
                param[0].Value = score;

                dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "Get_PSI_Abbreviations", param);
                while (dr.Read())
                {
                    DataEntity objlocation = new DataEntity();
                    if (dr.GetValue(0) != DBNull.Value)
                    {
                        Abbreviations =  dr.GetString(0);
                    }



                }

                return Abbreviations;

            }

            catch (Exception ex)
            {
                throw ex;
            }

        }
        public List<DataEntity> GetAllExperience()
        {

            try
            {
                SqlDataReader dr;
                List<DataEntity> lstExperience = new List<DataEntity>();

                dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "GetAllExperience", null);
                while (dr.Read())
                {
                    DataEntity objExperience = new DataEntity();
                    objExperience.ExperienceId = dr.GetInt32(0);
                    objExperience.Experience = dr.GetString(1);
                    lstExperience.Add(objExperience);

                }


                return lstExperience;
            }

            catch (Exception ex)
            {
                throw ex;
            }

        }
        public void InsertCAFAnswer(DataEntity ObjCAFAnswer,Int32 CandidateId)
        {
            string strQuery = "IF NOT EXISTS(select * from dbo.MHRI_PSI_RSI_CAF_Scores where Candidateid=" + CandidateId + " and Category='CAF' and QuesNo='" + ObjCAFAnswer.QNo + "' and QuestionChar='X' and convert(date,Examdate,101)=convert(date,GETDATE(),101)) " +
                    " Insert into MHRI_PSI_RSI_CAF_Scores values(" + CandidateId + ",getdate(),'" + ObjCAFAnswer.QNo + "','X','" + ObjCAFAnswer.SelectedAns + "','CAF')" +
                    " else " +
                    " Update MHRI_PSI_RSI_CAF_Scores set value='" + ObjCAFAnswer.SelectedAns + "' where Candidateid=" + CandidateId + " and Category='CAF' and QuesNo='" + ObjCAFAnswer.QNo + "' and QuestionChar='X' and convert(date,Examdate,101)=convert(date,GETDATE(),101)";



            SqlHelper.ExecuteNonQuery(DataConstant.SqlConn, CommandType.Text, strQuery, null);

        }
        public Boolean AuthencateCandidate(DataEntity objCan)
        {
            try
            {

                Boolean CandidateFlag;
                CandidateFlag = false;

                SqlParameter[] param =
            {

                new SqlParameter ("@Fname",SqlDbType.NVarChar),
                new SqlParameter ("@Lname",SqlDbType.NVarChar),
                new SqlParameter ("@MobileNo",SqlDbType.NVarChar),
                new SqlParameter ("@EmailId",SqlDbType.NVarChar),
                
            };
                param[0].Value = objCan.FirstName;
                param[1].Value = objCan.LastName;
                param[2].Value = objCan.MobileNo;
                param[3].Value = objCan.EmailId;

                SqlDataReader dr = SqlHelper.ExecuteReader(DataConstant.SqlConn, CommandType.StoredProcedure, "AuthenticateCandidate", param);

                while (dr.Read())
                {
                    if (dr.GetInt32(0) == 1)
                    {
                        CandidateFlag = true;
                    }

                }

                return CandidateFlag;
            }

            catch (Exception ex)
            {
                throw ex;
            }


        }
        private void SaveUpdateRecords(List<DataEntity> objSaveLst)
        {
            //string strQuery = string.Empty;
            //SqlConnection conn = new SqlConnection(DataConstant.SqlConn);

            //conn.Open();
           
            try
            {
                foreach (DataEntity de in objSaveLst)
                {
                    DataEntity InsertCAFAns=new DataEntity ();
                    InsertCAFAns.QNo = de.QNo;
                    InsertCAFAns.SelectedAns = de.SelectedAns;
                   
                    //strQuery = "IF NOT EXISTS(select * from dbo.MHRI_PSI_RSI_CAF_Scores where Candidateid=" + Session["Candidateid"] + " and Category='CAF' and QuesNo='" + de.QNo + "' and QuestionChar='X' and convert(date,Examdate,101)=convert(date,GETDATE(),101)) " +
                    //" Insert into MHRI_PSI_RSI_CAF_Scores values(" + Session["Candidateid"] + ",getdate(),'" + de.QNo + "','X','" + de.SelectedAns + "','CAF')" +
                    //" else " +
                    //" Update MHRI_PSI_RSI_CAF_Scores set value='" + de.SelectedAns + "' where Candidateid=" + Session["Candidateid"] + " and Category='CAF' and QuesNo='" + de.QNo + "' and QuestionChar='X' and convert(date,Examdate,101)=convert(date,GETDATE(),101)";

                    DE.InsertCAFAnswer(InsertCAFAns,Convert.ToInt32(Session["Candidateid"]));

                    //SqlCommand cmd = new SqlCommand(strQuery, conn);

                    //cmd.ExecuteNonQuery();
                    
                }

                lblmsg.Text = "Record saved sucessfully";                
            }
            catch (Exception ex)
            {                
                lblmsg.Text = ex.Message;
            }
            finally
            {
                //conn.Close();
            }

        }
        public void SendEmail( Int32 Canid, string pdate)
        {

            DataAccess DEmail = new DataAccess();
            List<DataEntity> lst = new List<DataEntity>();
            List<DataEntity> lstrsi = new List<DataEntity>();

             
            if (MHRISesstion.HREmailid != "")
            {

                Int32 Canditeid = Canid;

                String Pdate = pdate;
                lst = DEmail.GetCandidateDetails(Canditeid, Pdate);
                string body = "<html> Hi </br></br> Please find the report of the pre-employment test below:</br></br></br> Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:[Name]</br> Email ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:[Emailid]</br> Mobile Number&nbsp;&nbsp;&nbsp;&nbsp;:[Mobile]</br> Position&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:[Position]</br> Exam Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:[ExamDate]</br>Exam Start Time&nbsp;&nbsp;:[StartTime]</br>Exam End Time&nbsp;&nbsp;&nbsp;:[EndTime] ";
                if (lst.Count > 0)
                {

                    body = body.Replace("[Name]", lst[0].FirstName);
                    Candidatename = lst[0].FirstName;
                    body = body.Replace("[Emailid]", lst[0].EmailId);
                    body = body.Replace("[Mobile]", lst[0].MobileNo);
                    body = body.Replace("[Position]", lst[0].Position);
                    body = body.Replace("[ExamDate]", lst[0].ExamDate);
                    body = body.Replace("[StartTime]", lst[0].StartTime);
                    body = body.Replace("[EndTime]", lst[0].EndTime);
                    
                }

                string CAFscore=DEmail.GetCAFScore(Canditeid, Pdate);

                //body = body + "</br></br></br></br> Section 1: CAF </br> Score obtained is " + CAFscore + " out of " + 15 + "</br></br> Section 2: RSI</br> The score of various career anchor are below : <table > ";
                body = body + "</br></br></br></br> Section 1: CAF </br> Score obtained is " + CAFscore + " out of " + 15;
                body = body + "</br> CAF Examination Duration is " + MHRISesstion.CandidateCAFduration.ToString() + "mins" ;
                body = body + "</br></br> Section 2: RSI</br> The score of various career anchor are below : <table > ";

                lstrsi = DEmail.GetRSIScore(Canditeid, Pdate);


                if (lstrsi.Count > 0)
                {
                    foreach (var obj in lstrsi)
                    {
                        DataEntity D1 = new DataEntity();



                        body = body + "<tr> <td>" + obj.QChar + "</td>" + "<td>" + obj.Quvalue + "</td></tr>";
                    }

                }

                body = body + "</table>";
                body = body + " </br></br> Section 3: PSI </br> The Profile according of PSI is :";//      +</html>";

                string psiscore = DEmail.GetPSIScore(Canditeid, Pdate);
                body = body + psiscore;




                string StrAbbreviations = DEmail.GetPSIAbbreviations(psiscore);

                if (StrAbbreviations != "")
                {
                    string bodypart = " </br> A short description of the same is below :- </br> <table > <tr> <td > </td> <td  >" + StrAbbreviations + "</td <td > </td> </tr> </table></html>";
                    body = body + bodypart;
                }

                else
                {
                    body = body + "</html>";
                }



                if (Candidatename != "")
                {
                    Subject = "Pre-Employment test score for candidate:-" + "  " + Candidatename;
                }
                
                else
                {
                    Subject = "Pre-Employment test score for candidate:-" + "  ";
                }

                

               
              EmailUtil.MHRISendMail(null, MHRISesstion.HREmailid, null, null, Subject, body, null, null, null, null, null);
             //EmailUtil.MHRISendMailTest(null, MHRISesstion.HREmailid, null, null, Subject, body, null, null, null, null, null);
            }
        }