Пример #1
0
        /// <summary>
        /// Populate business objects from the data reader
        /// </summary>
        /// <param name="dataReader">data reader</param>
        /// <returns>list of CMatrix_group</returns>
        internal List <CMatrix_group> PopulateObjectsFromReader(IDataReader dataReader)
        {
            List <CMatrix_group> list = new List <CMatrix_group>();

            while (dataReader.Read())
            {
                CMatrix_group businessObject = new CMatrix_group();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return(list);
        }
Пример #2
0
        /// <summary>
        /// Populate business object from data reader
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <param name="dataReader">data reader</param>
        internal void PopulateBusinessObjectFromReader(CMatrix_group businessObject, IDataReader dataReader)
        {
            businessObject.Idmatrix_group = dataReader.GetInt32(dataReader.GetOrdinal(CMatrix_group.CMatrix_groupFields.Idmatrix_group.ToString()));

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMatrix_group.CMatrix_groupFields.Sigla.ToString())))
            {
                businessObject.Sigla = dataReader.GetString(dataReader.GetOrdinal(CMatrix_group.CMatrix_groupFields.Sigla.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMatrix_group.CMatrix_groupFields.Name_group.ToString())))
            {
                businessObject.Name_group = dataReader.GetString(dataReader.GetOrdinal(CMatrix_group.CMatrix_groupFields.Name_group.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CMatrix_group.CMatrix_groupFields.Status.ToString())))
            {
                businessObject.Status = dataReader.GetBoolean(dataReader.GetOrdinal(CMatrix_group.CMatrix_groupFields.Status.ToString()));
            }
        }
Пример #3
0
        /// <summary>
        /// Select by primary key
        /// </summary>
        /// <param name="keys">primary keys</param>
        /// <returns>CMatrix_group business object</returns>
        public CMatrix_group SelectByPrimaryKey(CMatrix_groupKeys keys)
        {
            NpgsqlCommand sqlCommand = new NpgsqlCommand();

            sqlCommand.CommandText = "public.sp_matrix_group_SelectByPrimaryKey";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                sqlCommand.Parameters.Add(new NpgsqlParameter("p_idmatrix_group", NpgsqlDbType.Integer, 4, "", ParameterDirection.Input, false, 0, 0, DataRowVersion.Proposed, keys.Idmatrix_group));


                MainConnection.Open();

                NpgsqlDataReader dataReader = sqlCommand.ExecuteReader();

                if (dataReader.Read())
                {
                    CMatrix_group businessObject = new CMatrix_group();

                    PopulateBusinessObjectFromReader(businessObject, dataReader);

                    return(businessObject);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("CMatrix_group::SelectByPrimaryKey::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }
Пример #4
0
        /// <summary>
        /// insert new row in the table
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <returns>true of successfully insert</returns>
        public bool Insert(CMatrix_group businessObject)
        {
            NpgsqlCommand sqlCommand = new NpgsqlCommand();

            sqlCommand.CommandText = "public.sp_matrix_group_Insert";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                sqlCommand.Parameters.AddWithValue("p_idmatrix_group", businessObject.Idmatrix_group);
                sqlCommand.Parameters["p_idmatrix_group"].NpgsqlDbType = NpgsqlDbType.Integer;
                sqlCommand.Parameters["p_idmatrix_group"].Direction    = ParameterDirection.InputOutput;

                sqlCommand.Parameters.AddWithValue("p_sigla", businessObject.Sigla);
                sqlCommand.Parameters["p_sigla"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_name_group", businessObject.Name_group);
                sqlCommand.Parameters["p_name_group"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_status", businessObject.Status);
                sqlCommand.Parameters["p_status"].NpgsqlDbType = NpgsqlDbType.Boolean;


                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();
                businessObject.Idmatrix_group = Convert.ToInt32(sqlCommand.Parameters["p_idmatrix_group"].Value);

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception("CMatrix_group::Insert::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }
Пример #5
0
        /// <summary>
        /// update row in the table
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <returns>true for successfully updated</returns>
        public bool Update(CMatrix_group businessObject)
        {
            NpgsqlCommand sqlCommand = new NpgsqlCommand();

            sqlCommand.CommandText = "public.sp_matrix_group_Update";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                sqlCommand.Parameters.AddWithValue("p_idmatrix_group", businessObject.Idmatrix_group);
                sqlCommand.Parameters["p_idmatrix_group"].NpgsqlDbType = NpgsqlDbType.Integer;
                sqlCommand.Parameters.AddWithValue("p_sigla", businessObject.Sigla);
                sqlCommand.Parameters["p_sigla"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_name_group", businessObject.Name_group);
                sqlCommand.Parameters["p_name_group"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_status", businessObject.Status);
                sqlCommand.Parameters["p_status"].NpgsqlDbType = NpgsqlDbType.Boolean;


                MainConnection.Open();

                if (Convert.ToInt32(sqlCommand.ExecuteScalar()) > 0)
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw new Exception("CMatrix_group::Update::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }