Ejemplo n.º 1
0
        /// <summary>
        /// Populate business object from data reader
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <param name="dataReader">data reader</param>
        internal void PopulateBusinessObjectFromReader(CProcess_user_system businessObject, IDataReader dataReader)
        {
            businessObject.Idprocess_user_system = (short)dataReader.GetInt16(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Idprocess_user_system.ToString()));

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Cod_process.ToString())))
            {
                businessObject.Cod_process = dataReader.GetString(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Cod_process.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Cod_module.ToString())))
            {
                businessObject.Cod_module = dataReader.GetString(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Cod_module.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Cod_area.ToString())))
            {
                businessObject.Cod_area = dataReader.GetString(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Cod_area.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Iduser.ToString())))
            {
                businessObject.Iduser = (short?)dataReader.GetInt16(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Iduser.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Date_ini.ToString())))
            {
                businessObject.Date_ini = dataReader.GetDateTime(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Date_ini.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Date_end.ToString())))
            {
                businessObject.Date_end = dataReader.GetDateTime(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Date_end.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Usernew.ToString())))
            {
                businessObject.Usernew = dataReader.GetString(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Usernew.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Datenew.ToString())))
            {
                businessObject.Datenew = dataReader.GetDateTime(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Datenew.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Useredit.ToString())))
            {
                businessObject.Useredit = dataReader.GetString(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Useredit.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Dateedit.ToString())))
            {
                businessObject.Dateedit = dataReader.GetDateTime(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Dateedit.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Status.ToString())))
            {
                businessObject.Status = dataReader.GetBoolean(dataReader.GetOrdinal(CProcess_user_system.CProcess_user_systemFields.Status.ToString()));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// insert new row in the table
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <returns>true of successfully insert</returns>
        public bool Insert(CProcess_user_system businessObject)
        {
            NpgsqlCommand sqlCommand = new NpgsqlCommand();

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

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

            try
            {
                sqlCommand.Parameters.AddWithValue("p_idprocess_user_system", businessObject.Idprocess_user_system);
                sqlCommand.Parameters["p_idprocess_user_system"].NpgsqlDbType = NpgsqlDbType.Smallint;
                sqlCommand.Parameters["p_idprocess_user_system"].Direction    = ParameterDirection.InputOutput;

                sqlCommand.Parameters.AddWithValue("p_cod_process", businessObject.Cod_process);
                sqlCommand.Parameters["p_cod_process"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_cod_module", businessObject.Cod_module);
                sqlCommand.Parameters["p_cod_module"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_cod_area", businessObject.Cod_area);
                sqlCommand.Parameters["p_cod_area"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_iduser", businessObject.Iduser);
                sqlCommand.Parameters["p_iduser"].NpgsqlDbType = NpgsqlDbType.Smallint;
                sqlCommand.Parameters.AddWithValue("p_date_ini", businessObject.Date_ini);
                sqlCommand.Parameters["p_date_ini"].NpgsqlDbType = NpgsqlDbType.Timestamp;
                sqlCommand.Parameters.AddWithValue("p_date_end", businessObject.Date_end);
                sqlCommand.Parameters["p_date_end"].NpgsqlDbType = NpgsqlDbType.Timestamp;
                sqlCommand.Parameters.AddWithValue("p_usernew", businessObject.Usernew);
                sqlCommand.Parameters["p_usernew"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_datenew", businessObject.Datenew);
                sqlCommand.Parameters["p_datenew"].NpgsqlDbType = NpgsqlDbType.Date;
                sqlCommand.Parameters.AddWithValue("p_useredit", businessObject.Useredit);
                sqlCommand.Parameters["p_useredit"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_dateedit", businessObject.Dateedit);
                sqlCommand.Parameters["p_dateedit"].NpgsqlDbType = NpgsqlDbType.Date;
                sqlCommand.Parameters.AddWithValue("p_status", businessObject.Status);
                sqlCommand.Parameters["p_status"].NpgsqlDbType = NpgsqlDbType.Boolean;


                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();
                businessObject.Idprocess_user_system = Convert.ToInt16(sqlCommand.Parameters["p_idprocess_user_system"].Value);

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception("CProcess_user_system::Insert::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Populate business objects from the data reader
        /// </summary>
        /// <param name="dataReader">data reader</param>
        /// <returns>list of CProcess_user_system</returns>
        internal List <CProcess_user_system> PopulateObjectsFromReader(IDataReader dataReader)
        {
            List <CProcess_user_system> list = new List <CProcess_user_system>();

            while (dataReader.Read())
            {
                CProcess_user_system businessObject = new CProcess_user_system();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return(list);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Select by primary key
        /// </summary>
        /// <param name="keys">primary keys</param>
        /// <returns>CProcess_user_system business object</returns>
        public CProcess_user_system SelectByPrimaryKey(CProcess_user_systemKeys keys)
        {
            NpgsqlCommand sqlCommand = new NpgsqlCommand();

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

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

            try
            {
                sqlCommand.Parameters.Add(new NpgsqlParameter("p_idprocess_user_system", NpgsqlDbType.Smallint, 2, "", ParameterDirection.Input, false, 0, 0, DataRowVersion.Proposed, keys.Idprocess_user_system));


                MainConnection.Open();

                NpgsqlDataReader dataReader = sqlCommand.ExecuteReader();

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

                    PopulateBusinessObjectFromReader(businessObject, dataReader);

                    return(businessObject);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("CProcess_user_system::SelectByPrimaryKey::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }