Esempio n. 1
0
        private static OrgGroupsData GetDataObjectFromReader(SqlDataReader dataReader)
        {
            OrgGroupsData data = new OrgGroupsData();

            if (dataReader.IsDBNull(dataReader.GetOrdinal("OrgGroupsID")))
            {
                data.OrgGroupsID = IdType.UNSET;
            }
            else
            {
                data.OrgGroupsID = new IdType(dataReader.GetInt32(dataReader.GetOrdinal("OrgGroupsID")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("Description")))
            {
                data.Description = StringType.UNSET;
            }
            else
            {
                data.Description = StringType.Parse(dataReader.GetString(dataReader.GetOrdinal("Description")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("IsActive")))
            {
                data.IsActive = BooleanType.UNSET;
            }
            else
            {
                data.IsActive = BooleanType.GetInstance(dataReader.GetBoolean(dataReader.GetOrdinal("IsActive")));
            }

            return(data);
        }
Esempio n. 2
0
        public static IdType Insert(OrgGroupsData data)
        {
            // Create and execute the command
            string sql = "Insert Into " + TABLE + "("
                         + "Description,"
                         + "IsActive,"
            ;

            sql = sql.Substring(0, sql.Length - 1) + ") values("
                  + "@Description,"
                  + "@IsActive,"
            ;
            sql = sql.Substring(0, sql.Length - 1) + ");select Scope_Identity() Id";
            SqlCommand cmd = GetSqlCommand(DatabaseEnum.INTRANET, sql, CommandType.Text, COMMAND_TIMEOUT);

            //Create the parameters and append them to the command object
            cmd.Parameters.Add(new SqlParameter("@Description", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "Description", DataRowVersion.Proposed, data.Description.DBValue));
            cmd.Parameters.Add(new SqlParameter("@IsActive", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, "IsActive", DataRowVersion.Proposed, !data.IsActive.IsValid ? data.IsActive.DBValue : data.IsActive.DBValue.Equals("Y") ? 1 : 0));

            // Execute the query
            SqlDataReader returnValue = cmd.ExecuteReader();

            returnValue.Read();
            int returnId = (int)(returnValue.GetDecimal(0));

            returnValue.Close();
            // Set the output paramter value(s)
            return(new IdType(returnId));
        }
Esempio n. 3
0
        public static OrgGroupsData Load(IdType orgGroupsID)
        {
            WhereClause w = new WhereClause();

            w.And("OrgGroupsID", orgGroupsID.DBValue);
            SqlDataReader dataReader = GetListReader(DatabaseEnum.INTRANET, TABLE, w, null, true);

            if (!dataReader.Read())
            {
                dataReader.Close();
                throw new FinderException("Load found no rows for OrgGroups.");
            }
            OrgGroupsData data = GetDataObjectFromReader(dataReader);

            dataReader.Close();
            return(data);
        }
Esempio n. 4
0
        public static void Update(OrgGroupsData data)
        {
            // Create and execute the command
            OrgGroupsData oldData = Load(data.OrgGroupsID);
            string        sql     = "Update " + TABLE + " set ";

            if (!oldData.Description.Equals(data.Description))
            {
                sql = sql + "Description=@Description,";
            }
            if (!oldData.IsActive.Equals(data.IsActive))
            {
                sql = sql + "IsActive=@IsActive,";
            }
            WhereClause w = new WhereClause();

            w.And("OrgGroupsID", data.OrgGroupsID.DBValue);
            sql = sql.Substring(0, sql.Length - 1) + w.FormatSql();
            SqlCommand cmd = GetSqlCommand(DatabaseEnum.INTRANET, sql, CommandType.Text, COMMAND_TIMEOUT);

            //Create the parameters and append them to the command object
            if (!oldData.OrgGroupsID.Equals(data.OrgGroupsID))
            {
                cmd.Parameters.Add(new SqlParameter("@OrgGroupsID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgGroupsID", DataRowVersion.Proposed, data.OrgGroupsID.DBValue));
            }
            if (!oldData.Description.Equals(data.Description))
            {
                cmd.Parameters.Add(new SqlParameter("@Description", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "Description", DataRowVersion.Proposed, data.Description.DBValue));
            }
            if (!oldData.IsActive.Equals(data.IsActive))
            {
                cmd.Parameters.Add(new SqlParameter("@IsActive", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, "IsActive", DataRowVersion.Proposed, !data.IsActive.IsValid ? data.IsActive.DBValue : data.IsActive.DBValue.Equals("Y") ? 1 : 0));
            }

            // Execute the query
            if (cmd.Parameters.Count > 0)
            {
                cmd.ExecuteNonQuery();
            }
        }