コード例 #1
0
        public IDataReader RetrieveBookCheckOutHistory(int bookID)
        {
            IDataReader reader  = null;
            SqlCommand  command = new SqlCommand();

            try
            {
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = Constants.SP_BookBorrowingHistory;

                command.Parameters.AddWithValue("@BookID", bookID);
                reader = base.ExecuteReader(command);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw new Exception("Oops! Something went wrong.");
            }
            catch (Exception ex)
            {
                ErroLogDBOperations db = ErroLogDBOperations.getInstance();
                db.ErrorLog(ex.Message, "In RetrieveBookCheckOutHistory ");

                if (!reader.IsClosed)
                {
                    reader.Close();
                }
                reader.Dispose();
            }
            finally
            {
                command.Dispose();
            }

            return(reader);
        }
コード例 #2
0
        public IDataReader RetriveGazetteHoliday()
        {
            IDataReader reader  = null;
            SqlCommand  command = new SqlCommand();

            try
            {
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = Constants.SP_RetriveGazetteHoliday;
                reader = base.ExecuteReader(command);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw new Exception("Oops! Something went wrong.");
            }
            catch (Exception ex)
            {
                ErroLogDBOperations db = ErroLogDBOperations.getInstance();
                db.ErrorLog(ex.Message, "In RetriveGazetteHoliday ");
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
                reader.Dispose();
            }
            finally
            {
                command.Dispose();
            }

            return(reader);
        }
コード例 #3
0
        public int CheckOut(int bookID, string Name, string MobileNo, string NationalID, DateTime checkOutDate, DateTime ReturnDate)
        {
            SqlCommand command = new SqlCommand();
            int        result  = 0;

            try
            {
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = Constants.SP_CheckOut;

                command.Parameters.AddWithValue("@BookID", bookID);
                command.Parameters.AddWithValue("@Name", Name);
                command.Parameters.AddWithValue("@MobileNo", MobileNo);
                command.Parameters.AddWithValue("@NationalID", NationalID);
                command.Parameters.AddWithValue("@CheckOutDate", checkOutDate);
                command.Parameters.AddWithValue("@ReturnDate", ReturnDate);

                result = base.ExecuteNonQuery(command);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw new Exception("Oops something went wrong.");
            }
            catch (Exception ex)
            {
                ErroLogDBOperations db = ErroLogDBOperations.getInstance();
                db.ErrorLog(ex.Message, "In CheckOut Book insertion");
            }
            finally
            {
                command.Dispose();
            }

            return(result);
        }
コード例 #4
0
        public int CheckIn(int bookID)
        {
            SqlCommand command = new SqlCommand();
            int        result  = 0;

            try
            {
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = Constants.SP_CheckIn;

                command.Parameters.AddWithValue("@BookID", bookID);
                result = base.ExecuteNonQuery(command);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw new Exception("Oops! Something went wrong.");
            }
            catch (Exception ex)
            {
                ErroLogDBOperations db = ErroLogDBOperations.getInstance();
                db.ErrorLog(ex.Message, "In CheckIn Book insertion");
            }
            finally
            {
                command.Dispose();
            }

            return(result);
        }
コード例 #5
0
        /// <summary>
        /// Return instance for a singleton DB operations class
        /// </summary>
        /// <returns></returns>
        public static ErroLogDBOperations getInstance()
        {
            if (_instance == null)
            {
                _instance = new ErroLogDBOperations();

                _instance.initialize();
            }

            return(_instance);
        }
コード例 #6
0
 private new void initialize()
 {
     try
     {
         base.initialize();
     }
     catch (Exception ex)
     {
         ErroLogDBOperations db = ErroLogDBOperations.getInstance();
         db.ErrorLog(ex.Message, "In BookCheckInCheckOutDBOperations initialize");
     }
 }