public static IdType Insert(OrgGroupsEmployeesData data)
        {
            // Create and execute the command
            string sql = "Insert Into " + TABLE + "("
                         + "OrgGroupsID,"
                         + "OrgEmployeesID,"
                         + "IsContentManager,"
            ;

            sql = sql.Substring(0, sql.Length - 1) + ") values("
                  + "@OrgGroupsID,"
                  + "@OrgEmployeesID,"
                  + "@IsContentManager,"
            ;
            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("@OrgGroupsID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgGroupsID", DataRowVersion.Proposed, data.OrgGroupsID.DBValue));
            cmd.Parameters.Add(new SqlParameter("@OrgEmployeesID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgEmployeesID", DataRowVersion.Proposed, data.OrgEmployeesID.DBValue));
            cmd.Parameters.Add(new SqlParameter("@IsContentManager", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, "IsContentManager", DataRowVersion.Proposed, !data.IsContentManager.IsValid ? data.IsContentManager.DBValue : data.IsContentManager.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));
        }
        public static void Update(OrgGroupsEmployeesData data)
        {
            // Create and execute the command
            OrgGroupsEmployeesData oldData = Load(data.OrgGroupsEmployeesID);
            string sql = "Update " + TABLE + " set ";

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

            w.And("OrgGroupsEmployeesID", data.OrgGroupsEmployeesID.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.OrgGroupsEmployeesID.Equals(data.OrgGroupsEmployeesID))
            {
                cmd.Parameters.Add(new SqlParameter("@OrgGroupsEmployeesID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgGroupsEmployeesID", DataRowVersion.Proposed, data.OrgGroupsEmployeesID.DBValue));
            }
            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.OrgEmployeesID.Equals(data.OrgEmployeesID))
            {
                cmd.Parameters.Add(new SqlParameter("@OrgEmployeesID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgEmployeesID", DataRowVersion.Proposed, data.OrgEmployeesID.DBValue));
            }
            if (!oldData.IsContentManager.Equals(data.IsContentManager))
            {
                cmd.Parameters.Add(new SqlParameter("@IsContentManager", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, "IsContentManager", DataRowVersion.Proposed, !data.IsContentManager.IsValid ? data.IsContentManager.DBValue : data.IsContentManager.DBValue.Equals("Y") ? 1 : 0));
            }

            // Execute the query
            if (cmd.Parameters.Count > 0)
            {
                cmd.ExecuteNonQuery();
            }
        }
        public static OrgGroupsEmployeesData Load(IdType orgGroupsEmployeesID)
        {
            WhereClause w = new WhereClause();

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

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

            dataReader.Close();
            return(data);
        }
        private static OrgGroupsEmployeesData GetDataObjectFromReader(SqlDataReader dataReader)
        {
            OrgGroupsEmployeesData data = new OrgGroupsEmployeesData();

            if (dataReader.IsDBNull(dataReader.GetOrdinal("OrgGroupsEmployeesID")))
            {
                data.OrgGroupsEmployeesID = IdType.UNSET;
            }
            else
            {
                data.OrgGroupsEmployeesID = new IdType(dataReader.GetInt32(dataReader.GetOrdinal("OrgGroupsEmployeesID")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("OrgGroupsID")))
            {
                data.OrgGroupsID = IntegerType.UNSET;
            }
            else
            {
                data.OrgGroupsID = new IntegerType(dataReader.GetInt32(dataReader.GetOrdinal("OrgGroupsID")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("OrgEmployeesID")))
            {
                data.OrgEmployeesID = IntegerType.UNSET;
            }
            else
            {
                data.OrgEmployeesID = new IntegerType(dataReader.GetInt32(dataReader.GetOrdinal("OrgEmployeesID")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("IsContentManager")))
            {
                data.IsContentManager = BooleanType.UNSET;
            }
            else
            {
                data.IsContentManager = BooleanType.GetInstance(dataReader.GetBoolean(dataReader.GetOrdinal("IsContentManager")));
            }

            return(data);
        }