Ejemplo n.º 1
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region /*--------- Create ---------*\
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Converts the  object properties to SQL paramters and executes the create  procedure 
        /// and updates the object with the SQL data by reference.
        /// </summary>
        /// <param name="RoundsLogObj">Model object.</param>
        /// <returns>The result of create query.</returns>
        //--------------------------------------------------------------------
        public bool Create(RoundsLogModel RoundsLogObj)
        {
            bool result = false;
            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("[dbo].[RoundsLog_Create]", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                //----------------------------------------------------------------------------------------------
                // Set the parameters
                //----------------------------------------------------------------------------------------------
				myCommand.Parameters.Add("@RoundID", SqlDbType.Int, 4).Direction = ParameterDirection.Output;
				myCommand.Parameters.Add("@IndexerID", SqlDbType.Int, 4).Value = RoundsLogObj.IndexerID;
				myCommand.Parameters.Add("@JournalCode", SqlDbType.VarChar, 20).Value = RoundsLogObj.JournalCode;
				myCommand.Parameters.Add("@RoundDate", SqlDbType.Date, 3).Value = RoundsLogObj.RoundDate;
				myCommand.Parameters.Add("@StatusID", SqlDbType.Int, 4).Value = RoundsLogObj.StatusID;
				myCommand.Parameters.Add("@NextEvaRound", SqlDbType.NVarChar, 128).Value = RoundsLogObj.NextEvaRound;
				myCommand.Parameters.Add("@Notes", SqlDbType.NVarChar, 2000).Value = RoundsLogObj.Notes;

                //----------------------------------------------------------------------------------------------
                // Execute the command
                //----------------------------------------------------------------------------------------------
                myConnection.Open();
                if (myCommand.ExecuteNonQuery() > 0)
                {
                    result = true;
                    //Get ID value from database and set it in object
				RoundsLogObj.RoundID = (int)myCommand.Parameters["@RoundID"].Value;

                }
                myConnection.Close();
                return result;
                //----------------------------------------------------------------------------------------------
            }
        }
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region /*--------- Update ---------*\
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Converts the object properties to SQL paramters and executes the update procedure.
        /// </summary>
        /// <param name="RoundsLogObj">Model object.</param>
        /// <returns>The result of update query.</returns>
        //--------------------------------------------------------------------
        public bool Update(RoundsLogModel RoundsLogObj)
        {
            bool result = false;
            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("[dbo].[RoundsLog_Update]", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                //----------------------------------------------------------------------------------------------
                // Set the parameters
                //----------------------------------------------------------------------------------------------
                
				myCommand.Parameters.Add("@RoundID", SqlDbType.Int).Value = RoundsLogObj.RoundID;
				myCommand.Parameters.Add("@IndexerID", SqlDbType.Int).Value = RoundsLogObj.IndexerID;
				myCommand.Parameters.Add("@JournalCode", SqlDbType.VarChar).Value = RoundsLogObj.JournalCode;
				myCommand.Parameters.Add("@RoundDate", SqlDbType.Date).Value = RoundsLogObj.RoundDate;
				myCommand.Parameters.Add("@StatusID", SqlDbType.Int).Value = RoundsLogObj.StatusID;
				myCommand.Parameters.Add("@NextEvaRound", SqlDbType.NVarChar).Value = RoundsLogObj.NextEvaRound;
				myCommand.Parameters.Add("@Notes", SqlDbType.NVarChar).Value = RoundsLogObj.Notes;

                //----------------------------------------------------------------------------------------------
                // Execute the command
                //----------------------------------------------------------------------------------------------
                myConnection.Open();
                if (myCommand.ExecuteNonQuery() > 0)
                {
                    result = true;
                }
                myConnection.Close();
                return result;
                //----------------------------------------------------------------------------------------------
            }
        }
Ejemplo n.º 3
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region --------------GetObject--------------
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the spesific record.
        /// </summary>
        /// <param name="ID">The model id.</param>
        /// <returns>Model object.</returns>
        //--------------------------------------------------------------------
        public static RoundsLogModel GetObject(int RoundID)
        {
            RoundsLogModel        RoundsLogObj = null;
            List <RoundsLogModel> list         = RoundsLogSqlDataPrvider.Instance.Get(RoundID);

            if (list != null && list.Count > 0)
            {
                RoundsLogObj = list[0];
            }
            return(RoundsLogObj);
        }
Ejemplo n.º 4
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region /*--------- PopulateModelFromIDataReader ---------*\
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Populates model from IDataReader .
        /// </summary>
        /// <param name="reader"></param>
        /// <returns>Model object.</returns>
        //--------------------------------------------------------------------
        private RoundsLogModel PopulateModelFromIDataReader(IDataReader reader)
        {
            //Create a new object
            RoundsLogModel RoundsLogObj = new RoundsLogModel();
            //Fill the object with data

			//------------------------------------------------
			//[RoundID]
			//------------------------------------------------
			if (reader["RoundID"] != DBNull.Value)
			    RoundsLogObj.RoundID = (int)reader["RoundID"];
			//------------------------------------------------
			//------------------------------------------------
			//[IndexerID]
			//------------------------------------------------
			if (reader["IndexerID"] != DBNull.Value)
			    RoundsLogObj.IndexerID = (int)reader["IndexerID"];
			//------------------------------------------------
			//------------------------------------------------
			//[JournalCode]
			//------------------------------------------------
			if (reader["JournalCode"] != DBNull.Value)
			    RoundsLogObj.JournalCode = (string)reader["JournalCode"];
			//------------------------------------------------
			//------------------------------------------------
			//[RoundDate]
			//------------------------------------------------
			if (reader["RoundDate"] != DBNull.Value)
			    RoundsLogObj.RoundDate = (DateTime)reader["RoundDate"];
			//------------------------------------------------
			//------------------------------------------------
			//[StatusID]
			//------------------------------------------------
			if (reader["StatusID"] != DBNull.Value)
			    RoundsLogObj.StatusID = (int)reader["StatusID"];
			//------------------------------------------------
			//------------------------------------------------
			//[NextEvaRound]
			//------------------------------------------------
			if (reader["NextEvaRound"] != DBNull.Value)
			    RoundsLogObj.NextEvaRound = (string)reader["NextEvaRound"];
			//------------------------------------------------
			//------------------------------------------------
			//[Notes]
			//------------------------------------------------
			if (reader["Notes"] != DBNull.Value)
			    RoundsLogObj.Notes = (string)reader["Notes"];
			//------------------------------------------------
            //Return the populated object
            return RoundsLogObj;
        }
Ejemplo n.º 5
0
        //------------------------------------------------------------------------------------------------------
        #endregion

        #region --------------Update--------------
        //------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Updates model object by calling sql data provider update method.
        /// </summary>
        /// <param name="RoundsLogObj">The model object.</param>
        /// <returns>The result of update operation.</returns>
        //--------------------------------------------------------------------
        public static bool Update(RoundsLogModel RoundsLogObj)
        {
            return(RoundsLogSqlDataPrvider.Instance.Update(RoundsLogObj));
        }