예제 #1
0
        private static OrgPhoneNumbersData GetDataObjectFromReader(SqlDataReader dataReader)
        {
            OrgPhoneNumbersData data = new OrgPhoneNumbersData();

            if (dataReader.IsDBNull(dataReader.GetOrdinal("OrgPhoneNumbersID")))
            {
                data.OrgPhoneNumbersID = IdType.UNSET;
            }
            else
            {
                data.OrgPhoneNumbersID = new IdType(dataReader.GetInt32(dataReader.GetOrdinal("OrgPhoneNumbersID")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("OrgDepartmentsID")))
            {
                data.OrgDepartmentsID = IntegerType.UNSET;
            }
            else
            {
                data.OrgDepartmentsID = new IntegerType(dataReader.GetInt32(dataReader.GetOrdinal("OrgDepartmentsID")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("OrgLocationsID")))
            {
                data.OrgLocationsID = IntegerType.UNSET;
            }
            else
            {
                data.OrgLocationsID = new IntegerType(dataReader.GetInt32(dataReader.GetOrdinal("OrgLocationsID")));
            }
            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("Description")))
            {
                data.Description = StringType.UNSET;
            }
            else
            {
                data.Description = StringType.Parse(dataReader.GetString(dataReader.GetOrdinal("Description")));
            }
            if (dataReader.IsDBNull(dataReader.GetOrdinal("PhoneNumber")))
            {
                data.PhoneNumber = StringType.UNSET;
            }
            else
            {
                data.PhoneNumber = StringType.Parse(dataReader.GetString(dataReader.GetOrdinal("PhoneNumber")));
            }

            return(data);
        }
예제 #2
0
        public static OrgPhoneNumbersData Load(IdType orgPhoneNumbersID)
        {
            WhereClause w = new WhereClause();

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

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

            dataReader.Close();
            return(data);
        }
예제 #3
0
        public static IdType Insert(OrgPhoneNumbersData data)
        {
            // Create and execute the command
            string sql = "Insert Into " + TABLE + "("
                         + "OrgDepartmentsID,"
                         + "OrgLocationsID,"
                         + "OrgEmployeesID,"
                         + "Description,"
                         + "PhoneNumber,"
            ;

            sql = sql.Substring(0, sql.Length - 1) + ") values("
                  + "@OrgDepartmentsID,"
                  + "@OrgLocationsID,"
                  + "@OrgEmployeesID,"
                  + "@Description,"
                  + "@PhoneNumber,"
            ;
            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("@OrgDepartmentsID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgDepartmentsID", DataRowVersion.Proposed, data.OrgDepartmentsID.DBValue));
            cmd.Parameters.Add(new SqlParameter("@OrgLocationsID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgLocationsID", DataRowVersion.Proposed, data.OrgLocationsID.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("@Description", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "Description", DataRowVersion.Proposed, data.Description.DBValue));
            cmd.Parameters.Add(new SqlParameter("@PhoneNumber", SqlDbType.VarChar, 15, ParameterDirection.Input, false, 0, 0, "PhoneNumber", DataRowVersion.Proposed, data.PhoneNumber.DBValue));

            // 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));
        }
예제 #4
0
        public static void Update(OrgPhoneNumbersData data)
        {
            // Create and execute the command
            OrgPhoneNumbersData oldData = Load(data.OrgPhoneNumbersID);
            string sql = "Update " + TABLE + " set ";

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

            w.And("OrgPhoneNumbersID", data.OrgPhoneNumbersID.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.OrgPhoneNumbersID.Equals(data.OrgPhoneNumbersID))
            {
                cmd.Parameters.Add(new SqlParameter("@OrgPhoneNumbersID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgPhoneNumbersID", DataRowVersion.Proposed, data.OrgPhoneNumbersID.DBValue));
            }
            if (!oldData.OrgDepartmentsID.Equals(data.OrgDepartmentsID))
            {
                cmd.Parameters.Add(new SqlParameter("@OrgDepartmentsID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgDepartmentsID", DataRowVersion.Proposed, data.OrgDepartmentsID.DBValue));
            }
            if (!oldData.OrgLocationsID.Equals(data.OrgLocationsID))
            {
                cmd.Parameters.Add(new SqlParameter("@OrgLocationsID", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "OrgLocationsID", DataRowVersion.Proposed, data.OrgLocationsID.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.Description.Equals(data.Description))
            {
                cmd.Parameters.Add(new SqlParameter("@Description", SqlDbType.VarChar, 100, ParameterDirection.Input, false, 0, 0, "Description", DataRowVersion.Proposed, data.Description.DBValue));
            }
            if (!oldData.PhoneNumber.Equals(data.PhoneNumber))
            {
                cmd.Parameters.Add(new SqlParameter("@PhoneNumber", SqlDbType.VarChar, 15, ParameterDirection.Input, false, 0, 0, "PhoneNumber", DataRowVersion.Proposed, data.PhoneNumber.DBValue));
            }

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