Exemplo n.º 1
0
        public MCQDTO InsertUpdateMCQUserStatus(string i_sConnectionString, MCQDTO i_objMCQDTO)
        {
            #region Paramters
            List <MCQDTO>     res      = null;
            string            sErrCode = string.Empty;
            PetaPoco.Database db       = null;
            int    out_nReturnValue;
            int    out_nSQLErrCode;
            string out_sSQLErrMessage;
            #endregion Paramters

            try
            {
                #region Output Param
                var nReturnValue = new SqlParameter("@out_nReturnValue", System.Data.SqlDbType.Int);
                nReturnValue.Direction = System.Data.ParameterDirection.Output;
                nReturnValue.Value     = 0;
                var nSQLErrCode = new SqlParameter("@out_nSQLErrCode", System.Data.SqlDbType.Int);
                nSQLErrCode.Direction = System.Data.ParameterDirection.Output;
                nSQLErrCode.Value     = 0;
                var sSQLErrMessage = new SqlParameter("@out_sSQLErrMessage", System.Data.SqlDbType.VarChar);
                sSQLErrMessage.Direction = System.Data.ParameterDirection.Output;
                sSQLErrMessage.Size      = 500;
                sSQLErrMessage.Value     = "";



                #endregion Output Param

                using (db = new PetaPoco.Database(i_sConnectionString, "System.Data.SqlClient")
                {
                    EnableAutoSelect = false
                })
                {
                    using (var scope = db.GetTransaction())
                    {
                        res = db.Fetch <MCQDTO>("exec st_MCQ_UsrStatusSave @UserInfoID,@MCQStatus,@MCQPerioEndDate "
                                                + ",@out_nReturnValue OUTPUT,@out_nSQLErrCode OUTPUT,@out_sSQLErrMessage OUTPUT",
                                                new
                        {
                            UserInfoID         = i_objMCQDTO.UserInfoID,
                            MCQStatus          = i_objMCQDTO.MCQStatus,
                            MCQPerioEndDate    = i_objMCQDTO.MCQPerioEndDate,
                            out_nReturnValue   = nReturnValue,
                            out_nSQLErrCode    = nSQLErrCode,
                            out_sSQLErrMessage = sSQLErrMessage
                        }).ToList();


                        if (Convert.ToInt32(nReturnValue.Value) != 0)
                        {
                            #region Error Code
                            Exception e = new Exception();
                            out_nReturnValue = Convert.ToInt32(nReturnValue.Value);
                            string sReturnValue = sLookUpPrefix + out_nReturnValue;
                            e.Data[0] = sReturnValue;
                            if (nSQLErrCode.Value != System.DBNull.Value)
                            {
                                out_nSQLErrCode = Convert.ToInt32(nSQLErrCode.Value);
                                e.Data[1]       = out_nSQLErrCode;
                            }
                            if (sSQLErrMessage.Value != System.DBNull.Value)
                            {
                                out_sSQLErrMessage = Convert.ToString(sSQLErrMessage.Value);
                                e.Data[2]          = out_sSQLErrMessage;
                            }
                            Exception ex = new Exception(db.LastSQL.ToString(), e);
                            throw ex;
                            #endregion  Error Code
                        }

                        else
                        {
                            scope.Complete();
                            return(res.FirstOrDefault());
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
Exemplo n.º 2
0
        public MCQDTO InsertUpdateMCQDetails(string i_sConnectionString, MCQDTO i_objMCQDTO, string Flag)
        {
            #region Paramters
            List <MCQDTO>     res      = null;
            string            sErrCode = string.Empty;
            PetaPoco.Database db       = null;
            int    out_nReturnValue;
            int    out_nSQLErrCode;
            string out_sSQLErrMessage;
            #endregion Paramters

            try
            {
                #region Output Param
                var nReturnValue = new SqlParameter("@out_nReturnValue", System.Data.SqlDbType.Int);
                nReturnValue.Direction = System.Data.ParameterDirection.Output;
                nReturnValue.Value     = 0;
                var nSQLErrCode = new SqlParameter("@out_nSQLErrCode", System.Data.SqlDbType.Int);
                nSQLErrCode.Direction = System.Data.ParameterDirection.Output;
                nSQLErrCode.Value     = 0;
                var sSQLErrMessage = new SqlParameter("@out_sSQLErrMessage", System.Data.SqlDbType.VarChar);
                sSQLErrMessage.Direction = System.Data.ParameterDirection.Output;
                sSQLErrMessage.Size      = 500;
                sSQLErrMessage.Value     = "";



                #endregion Output Param

                using (db = new PetaPoco.Database(i_sConnectionString, "System.Data.SqlClient")
                {
                    EnableAutoSelect = false
                })
                {
                    using (var scope = db.GetTransaction())
                    {
                        res = db.Fetch <MCQDTO>("exec st_MCQSettingSave @MCQS_ID OUTPUT,@inp_FirstTimeLogin,@inp_IsSpecificPeriodWise,@inp_FrequencyOfMCQ,@inp_IsDatewise,@inp_FrequencyDate,@inp_FrequencyDuration"
                                                + ",@inp_BlockUserAfterDuration,@inp_NoOfQuestionForDisplay,@inp_AccessTOApplicationForWriteAnswer,@inp_NoOfAttempts,@inp_BlockuserAfterExceedAtempts,@inp_UnblockForNextFrequency,@inp_iOperation,@inp_CreatedBy"
                                                + ",@out_nReturnValue OUTPUT,@out_nSQLErrCode OUTPUT,@out_sSQLErrMessage OUTPUT",
                                                new
                        {
                            MCQS_ID                               = i_objMCQDTO.MCQS_ID,
                            inp_FirstTimeLogin                    = i_objMCQDTO.FirstTimeLogin,
                            inp_IsSpecificPeriodWise              = i_objMCQDTO.IsSpecificPeriodWise,
                            inp_FrequencyOfMCQ                    = i_objMCQDTO.FrequencyOfMCQ,
                            inp_IsDatewise                        = i_objMCQDTO.IsDatewise,
                            inp_FrequencyDate                     = i_objMCQDTO.FrequencyDate,
                            inp_FrequencyDuration                 = i_objMCQDTO.FrequencyDuration,
                            inp_BlockUserAfterDuration            = i_objMCQDTO.BlockUserAfterDuration,
                            inp_NoOfQuestionForDisplay            = i_objMCQDTO.NoOfQuestionForDisplay,
                            inp_AccessTOApplicationForWriteAnswer = i_objMCQDTO.AccessTOApplicationForWriteAnswer,
                            inp_NoOfAttempts                      = i_objMCQDTO.NoOfAttempts,
                            inp_BlockuserAfterExceedAtempts       = i_objMCQDTO.BlockuserAfterExceedAtempts,
                            inp_UnblockForNextFrequency           = i_objMCQDTO.UnblockForNextFrequency,
                            inp_iOperation                        = Flag,
                            inp_CreatedBy                         = 1,
                            out_nReturnValue                      = nReturnValue,
                            out_nSQLErrCode                       = nSQLErrCode,
                            out_sSQLErrMessage                    = sSQLErrMessage
                        }).ToList();


                        if (Convert.ToInt32(nReturnValue.Value) != 0)
                        {
                            #region Error Code
                            Exception e = new Exception();
                            out_nReturnValue = Convert.ToInt32(nReturnValue.Value);
                            string sReturnValue = sLookUpPrefix + out_nReturnValue;
                            e.Data[0] = sReturnValue;
                            if (nSQLErrCode.Value != System.DBNull.Value)
                            {
                                out_nSQLErrCode = Convert.ToInt32(nSQLErrCode.Value);
                                e.Data[1]       = out_nSQLErrCode;
                            }
                            if (sSQLErrMessage.Value != System.DBNull.Value)
                            {
                                out_sSQLErrMessage = Convert.ToString(sSQLErrMessage.Value);
                                e.Data[2]          = out_sSQLErrMessage;
                            }
                            Exception ex = new Exception(db.LastSQL.ToString(), e);
                            throw ex;
                            #endregion  Error Code
                        }

                        else
                        {
                            scope.Complete();
                            return(res.FirstOrDefault());
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }